-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3863504
commit ce4ab41
Showing
12 changed files
with
285 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,193 +1,42 @@ | ||
import React, { useMemo, useReducer } from 'react' | ||
import { Table } from 'antd' | ||
import ProTable from '@ant-design/pro-table' | ||
import React, { Suspense, lazy } from 'react' | ||
import { useRoutes } from 'react-router-dom' | ||
import './App.css' | ||
import { useAntdResizableHeader } from '@minko-fe/use-antd-resizable-header' | ||
import '@minko-fe/use-antd-resizable-header/dist/style.css' | ||
|
||
const tcls: any[] = [ | ||
{ | ||
title: '333', | ||
dataIndex: 'name', | ||
key: 'name', | ||
width: 100, | ||
fixed: 'left', | ||
filters: [ | ||
{ | ||
text: 'Joe', | ||
value: 'Joe', | ||
}, | ||
{ | ||
text: 'John', | ||
value: 'John', | ||
}, | ||
], | ||
onFilter: (value, record) => record.name.indexOf(value) === 0, | ||
}, | ||
{ | ||
title: 'Other', | ||
children: [ | ||
{ | ||
title: 'Age', | ||
dataIndex: 'age', | ||
key: 'age', | ||
width: 150, | ||
sorter: (a, b) => a.age - b.age, | ||
}, | ||
{ | ||
title: 'Address', | ||
children: [ | ||
{ | ||
title: 'Street', | ||
dataIndex: 'street', | ||
key: 'street', | ||
width: 150, | ||
}, | ||
{ | ||
title: 'Block', | ||
children: [ | ||
{ | ||
title: 'Building', | ||
dataIndex: 'building', | ||
key: 'building', | ||
width: 100, | ||
}, | ||
{ | ||
title: 'Door No.', | ||
dataIndex: 'number', | ||
key: 'number', | ||
width: 100, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
title: 'Company', | ||
children: [ | ||
{ | ||
title: 'Company Address', | ||
dataIndex: 'companyAddress', | ||
key: 'companyAddress', | ||
width: 200, | ||
}, | ||
{ | ||
title: 'Company Name', | ||
dataIndex: 'companyName', | ||
key: 'companyName', | ||
}, | ||
], | ||
}, | ||
{ | ||
title: 'Gender', | ||
dataIndex: 'gender', | ||
key: 'gender', | ||
width: 80, | ||
fixed: 'right', | ||
}, | ||
] | ||
|
||
const data: any[] = [] | ||
for (let i = 0; i < 100; i++) { | ||
data.push({ | ||
key: i, | ||
name: 'John Brown', | ||
age: i + 1, | ||
street: 'Lake Park', | ||
building: 'C', | ||
number: 2035, | ||
companyAddress: 'Lake Street 42', | ||
companyName: 'SoftLake Co', | ||
gender: 'M', | ||
}) | ||
interface FunctionalImportType { | ||
(): any | ||
} | ||
|
||
function App() { | ||
const [x, setX] = useReducer((s) => s + 1, 0) | ||
|
||
const { components, resizableColumns, tableWidth } = useAntdResizableHeader({ | ||
columns: tcls, | ||
columnsState: { | ||
persistenceType: 'localStorage', | ||
persistenceKey: 'test', | ||
// eslint-disable-next-line no-restricted-syntax | ||
export default function App() { | ||
const comp = (C) => { | ||
return ( | ||
<Suspense fallback={<div />}> | ||
<C /> | ||
</Suspense> | ||
) | ||
} | ||
|
||
const routes = [ | ||
{ | ||
path: '/', | ||
component: () => import('./basic'), | ||
}, | ||
}) | ||
|
||
const proColumns = useMemo( | ||
() => [ | ||
{ | ||
title: 'Pro-Name', | ||
width: 100, | ||
dataIndex: 'name', | ||
key: 'name', | ||
fixed: 'left', | ||
}, | ||
{ | ||
title: 'Age', | ||
width: 100, | ||
dataIndex: 'age', | ||
key: 'age', | ||
}, | ||
{ | ||
title: 'x', | ||
width: 100, | ||
dataIndex: 'x', | ||
key: 'x', | ||
}, | ||
{ | ||
title: 'y', | ||
width: 100, | ||
dataIndex: 'y', | ||
key: 'y', | ||
}, | ||
{ | ||
title: 'Column 1', | ||
dataIndex: 'address', | ||
}, | ||
{ | ||
title: 'test render', | ||
dataIndex: 'testRender', | ||
width: 111, | ||
render: () => { | ||
return <div onClick={() => setX()}>{x}</div> | ||
}, | ||
}, | ||
{ | ||
title: 'Action', | ||
key: 'operation', | ||
fixed: 'right', | ||
render: (_, record) => { | ||
return <span>{record?.age}</span> | ||
}, | ||
width: 100, | ||
}, | ||
], | ||
[x], | ||
) | ||
|
||
const { | ||
components: cp, | ||
resizableColumns: rp, | ||
tableWidth: tp, | ||
} = useAntdResizableHeader({ | ||
columns: proColumns, | ||
defaultWidth: 444, | ||
columnsState: { | ||
persistenceType: 'localStorage', | ||
persistenceKey: 'fds', | ||
{ | ||
path: '/36', | ||
component: () => import('./36'), | ||
}, | ||
}) | ||
|
||
return ( | ||
<div className='App'> | ||
<Table columns={resizableColumns} components={components} dataSource={data} scroll={{ x: tableWidth }} /> | ||
{ | ||
path: '/37', | ||
component: () => import('./37'), | ||
}, | ||
] | ||
|
||
<ProTable columns={rp} components={cp} dataSource={data} scroll={{ x: tp }} /> | ||
</div> | ||
const element = useRoutes( | ||
routes.map((t) => ({ | ||
element: comp(lazy(t.component as FunctionalImportType)), | ||
...t, | ||
})), | ||
) | ||
} | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
export default App | ||
return <div>{element}</div> | ||
} |
Oops, something went wrong.