chore: Update Table ts definition (#29084)

* chore: bump rc-table ver

* chore: Fix ts definition

* docs: fix doc
This commit is contained in:
二货机器人 2021-01-28 01:21:58 +08:00 committed by GitHub
parent 0e95728fc9
commit 08f25f0c8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 11 deletions

View File

@ -152,7 +152,7 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
); );
const mergedSize = customizeSize || size; const mergedSize = customizeSize || size;
const tableLocale = { ...contextLocale.Table, ...locale } as TableLocale; const tableLocale = { ...contextLocale.Table, ...locale } as TableLocale;
const rawData: RecordType[] = dataSource || EMPTY_LIST; const rawData: readonly RecordType[] = dataSource || EMPTY_LIST;
const { getPrefixCls } = React.useContext(ConfigContext); const { getPrefixCls } = React.useContext(ConfigContext);
const prefixCls = getPrefixCls('table', customizePrefixCls); const prefixCls = getPrefixCls('table', customizePrefixCls);
@ -236,7 +236,12 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
} }
}; };
/** Controlled state in `columns` is not a good idea that makes too many code (1000+ line?) to read state out and then put it back to title render. Move these code into `hooks` but still too complex. We should provides Table props like `sorter` & `filter` to handle control in next big version. */ /**
* Controlled state in `columns` is not a good idea that makes too many code (1000+ line?) to
* read state out and then put it back to title render. Move these code into `hooks` but still
* too complex. We should provides Table props like `sorter` & `filter` to handle control in next
* big version.
*/
// ============================ Sorter ============================= // ============================ Sorter =============================
const onSorterChange = ( const onSorterChange = (

View File

@ -2,14 +2,14 @@ import * as React from 'react';
import { Key, GetRowKey } from '../interface'; import { Key, GetRowKey } from '../interface';
interface MapCache<RecordType> { interface MapCache<RecordType> {
data?: RecordType[]; data?: readonly RecordType[];
childrenColumnName?: string; childrenColumnName?: string;
kvMap?: Map<Key, RecordType>; kvMap?: Map<Key, RecordType>;
getRowKey?: Function; getRowKey?: Function;
} }
export default function useLazyKVMap<RecordType>( export default function useLazyKVMap<RecordType>(
data: RecordType[], data: readonly RecordType[],
childrenColumnName: string, childrenColumnName: string,
getRowKey: GetRowKey<RecordType>, getRowKey: GetRowKey<RecordType>,
) { ) {
@ -25,7 +25,7 @@ export default function useLazyKVMap<RecordType>(
const kvMap = new Map<Key, RecordType>(); const kvMap = new Map<Key, RecordType>();
/* eslint-disable no-inner-declarations */ /* eslint-disable no-inner-declarations */
function dig(records: RecordType[]) { function dig(records: readonly RecordType[]) {
records.forEach((record, index) => { records.forEach((record, index) => {
const rowKey = getRowKey(record, index); const rowKey = getRowKey(record, index);
kvMap.set(rowKey, record); kvMap.set(rowKey, record);

View File

@ -244,7 +244,7 @@ function generateSorterInfo<RecordType>(
} }
export function getSortData<RecordType>( export function getSortData<RecordType>(
data: RecordType[], data: readonly RecordType[],
sortStates: SortState<RecordType>[], sortStates: SortState<RecordType>[],
childrenColumnName: string, childrenColumnName: string,
): RecordType[] { ): RecordType[] {

View File

@ -175,7 +175,7 @@ export interface TableCurrentDataSource<RecordType> {
export interface SorterResult<RecordType> { export interface SorterResult<RecordType> {
column?: ColumnType<RecordType>; column?: ColumnType<RecordType>;
order?: SortOrder; order?: SortOrder;
field?: Key | Key[]; field?: Key | readonly Key[];
columnKey?: Key; columnKey?: Key;
} }

View File

@ -6,7 +6,7 @@ export function getColumnKey<RecordType>(column: ColumnType<RecordType>, default
return column.key; return column.key;
} }
if (column.dataIndex) { if (column.dataIndex) {
return Array.isArray(column.dataIndex) ? column.dataIndex.join('.') : column.dataIndex; return (Array.isArray(column.dataIndex) ? column.dataIndex.join('.') : column.dataIndex) as Key;
} }
return defaultKey; return defaultKey;

View File

@ -98,7 +98,7 @@ ReactDOM.render(<LinksList />, mountNode);
- Hacknews: [Show HN: Antd A set of high-quality React components](https://news.ycombinator.com/item?id=13053137) - Hacknews: [Show HN: Antd A set of high-quality React components](https://news.ycombinator.com/item?id=13053137)
- Alligator: [Crafting Beautiful UIs in React Using Ant Design](https://alligator.io/react/beautiful-uis-ant-design/) - Alligator: [Crafting Beautiful UIs in React Using Ant Design](https://alligator.io/react/beautiful-uis-ant-design/)
- [Introduction to Ant Design](https://blog.logrocket.com/introduction-to-ant-design/) - [Introduction to Ant Design](https://blog.logrocket.com/introduction-to-ant-design/)
- [Build a React App with Ant Design Principles ](https://developer.okta.com/blog/2020/09/16/ant-design-react-app) - [Build a React App with Ant Design Principles](https://developer.okta.com/blog/2020/09/16/ant-design-react-app)
- [Meet Antd, an enterprise React UI library](https://medium.com/javascript-in-plain-english/antd-library-what-why-useful-or-not-5fec225b639d) - [Meet Antd, an enterprise React UI library](https://medium.com/javascript-in-plain-english/antd-library-what-why-useful-or-not-5fec225b639d)
## How to Contribute ## How to Contribute

View File

@ -100,7 +100,7 @@ ReactDOM.render(<LinksList />, mountNode);
- Alligator: [Crafting Beautiful UIs in React Using Ant Design](https://alligator.io/react/beautiful-uis-ant-design/) - Alligator: [Crafting Beautiful UIs in React Using Ant Design](https://alligator.io/react/beautiful-uis-ant-design/)
- [漫谈 Material Design & Ant Design](http://dwbbb.com/blog/MaterialDesignAntDesign/) - [漫谈 Material Design & Ant Design](http://dwbbb.com/blog/MaterialDesignAntDesign/)
- [Introduction to Ant Design](https://blog.logrocket.com/introduction-to-ant-design/) - [Introduction to Ant Design](https://blog.logrocket.com/introduction-to-ant-design/)
- [Build a React App with Ant Design Principles ](https://developer.okta.com/blog/2020/09/16/ant-design-react-app) - [Build a React App with Ant Design Principles](https://developer.okta.com/blog/2020/09/16/ant-design-react-app)
- [Meet Antd, an enterprise React UI library](https://medium.com/javascript-in-plain-english/antd-library-what-why-useful-or-not-5fec225b639d) - [Meet Antd, an enterprise React UI library](https://medium.com/javascript-in-plain-english/antd-library-what-why-useful-or-not-5fec225b639d)
## 如何贡献 ## 如何贡献

View File

@ -140,7 +140,7 @@
"rc-slider": "~9.7.1", "rc-slider": "~9.7.1",
"rc-steps": "~4.1.0", "rc-steps": "~4.1.0",
"rc-switch": "~3.2.0", "rc-switch": "~3.2.0",
"rc-table": "~7.12.0", "rc-table": "~7.13.0",
"rc-tabs": "~11.7.0", "rc-tabs": "~11.7.0",
"rc-textarea": "~0.3.0", "rc-textarea": "~0.3.0",
"rc-tooltip": "~5.0.0", "rc-tooltip": "~5.0.0",