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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with
16 additions and
11 deletions
components/table/Table.tsx
components/table/hooks/useLazyKVMap.ts
components/table/hooks/useSorter.tsx
components/table/interface.tsx
components/table/util.ts
docs/spec/introduce.en-US.md
docs/spec/introduce.zh-CN.md
package.json
@ -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 = (
@ -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 ) ;
@ -244,7 +244,7 @@ function generateSorterInfo<RecordType>(
}
export function getSortData < RecordType > (
data : RecordType [ ] ,
data : readonly RecordType [ ] ,
sortStates : SortState < RecordType > [ ] ,
childrenColumnName : string ,
) : RecordType [ ] {
@ -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 ;
}
@ -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 ;
@ -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
@ -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 )
## 如何贡献
@ -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" ,