-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add useSelections * refactor: rewrite useSelections and add test * fix: fix test of useSelections * refactor: useUpdateEffect (#103) * feat: add useUpdateEffect * feat: useSelections add setSelected and add test * refactor: return object instead of array * feat: add demo for useSelections * docs: add document for useSelections * fix: fix demo of useSelections * feat: add usePagination * chore: add usePagination reference * fix: Put the function with same deps into one useMeno * feat: useAntdTable add sorter, filters * fix: deps error * fix: change halfSelected -> partiallySelected * fix: useAntdTable determine if filters are equal change to a more robust method * feat: add usePagination (#105) * feat: add usePagination
- Loading branch information
1 parent
d1aeeff
commit 9092737
Showing
19 changed files
with
1,127 additions
and
34 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Table } from 'antd'; | ||
import React from 'react'; | ||
import useAntdTable from '.'; | ||
|
||
const Demo = () => { | ||
const getTableData = ({ current, pageSize, ...rest }) => { | ||
console.log(current, pageSize, rest); | ||
return fetch(`https://randomuser.me/api?results=55&page=${current}&size=${pageSize}`) | ||
.then(res => res.json()) | ||
.then(res => ({ | ||
page: res.info.page, | ||
total: res.info.results, | ||
data: res.results, | ||
})); | ||
}; | ||
|
||
const { tableProps, filters, sorter } = useAntdTable(getTableData, [], { | ||
defaultPageSize: 5, | ||
}); | ||
|
||
const columns = [ | ||
{ | ||
title: 'name', | ||
dataIndex: 'name', | ||
key: 'name', | ||
width: 100, | ||
render(_, record) { | ||
return record.name.title; | ||
}, | ||
}, | ||
{ | ||
title: 'email', | ||
dataIndex: 'email', | ||
key: 'email', | ||
sorter: true, | ||
sortOrder: sorter.field === 'email' && sorter.order, | ||
width: 350, | ||
}, | ||
{ | ||
title: 'phone', | ||
dataIndex: 'phone', | ||
key: 'phone', | ||
}, | ||
{ | ||
title: 'gender', | ||
key: 'gender', | ||
filters: [{ text: 'male', value: 'male' }, { text: 'female', value: 'female' }], | ||
filteredValue: filters.gender, | ||
width: 200, | ||
dataIndex: 'gender', | ||
}, | ||
]; | ||
|
||
return <Table columns={columns} rowKey="email" {...tableProps} />; | ||
}; | ||
|
||
export default Demo; |
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
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
Oops, something went wrong.
9092737
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: