Browse Source

chore: Update Table ts definition (#29084)

* chore: bump rc-table ver

* chore: Fix ts definition

* docs: fix doc
pull/29088/head
二货机器人 4 years ago
committed by GitHub
parent
commit
08f25f0c8f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      components/table/Table.tsx
  2. 6
      components/table/hooks/useLazyKVMap.ts
  3. 2
      components/table/hooks/useSorter.tsx
  4. 2
      components/table/interface.tsx
  5. 2
      components/table/util.ts
  6. 2
      docs/spec/introduce.en-US.md
  7. 2
      docs/spec/introduce.zh-CN.md
  8. 2
      package.json

9
components/table/Table.tsx

@ -152,7 +152,7 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
);
const mergedSize = customizeSize || size;
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 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 =============================
const onSorterChange = (

6
components/table/hooks/useLazyKVMap.ts

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

2
components/table/hooks/useSorter.tsx

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

2
components/table/interface.tsx

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

2
components/table/util.ts

@ -6,7 +6,7 @@ export function getColumnKey<RecordType>(column: ColumnType<RecordType>, default
return column.key;
}
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;

2
docs/spec/introduce.en-US.md

@ -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)
- 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/)
- [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)
## How to Contribute

2
docs/spec/introduce.zh-CN.md

@ -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/)
- [漫谈 Material Design & Ant Design](http://dwbbb.com/blog/MaterialDesignAntDesign/)
- [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)
## 如何贡献

2
package.json

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

Loading…
Cancel
Save