1+ import { ExtractPropTypes , PropType } from 'vue' ;
12import PropTypes , { withUndefined } from '../_util/vue-types' ;
23import { PaginationProps as getPaginationProps } from '../pagination' ;
34import { SpinProps as getSpinProps } from '../spin' ;
45import { Store } from './createStore' ;
56import { tuple } from '../_util/type' ;
6- import { ExtractPropTypes } from 'vue' ;
77
88const PaginationProps = getPaginationProps ( ) ;
99const SpinProps = getSpinProps ( ) ;
1010
11- // export type CompareFn<T> = (( a: T, b: T) => number) ;
11+ export type CompareFn < T > = ( a : T , b : T , sortOrder ?: SortOrder ) => number ;
1212export const ColumnFilterItem = PropTypes . shape ( {
1313 text : PropTypes . string ,
1414 value : PropTypes . string ,
1515 children : PropTypes . array ,
1616} ) . loose ;
1717
18- export const ColumnProps = {
18+ export const columnProps = {
1919 title : PropTypes . VNodeChild ,
2020 key : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
2121 dataIndex : PropTypes . string ,
@@ -52,7 +52,7 @@ export const ColumnProps = {
5252 // onHeaderCell?: (props: ColumnProps<T>) => any;
5353} ;
5454
55- export type IColumnProps = Partial < ExtractPropTypes < typeof ColumnProps > > ;
55+ export type ColumnProps = Partial < ExtractPropTypes < typeof columnProps > > ;
5656
5757export interface TableComponents {
5858 table ?: any ;
@@ -80,10 +80,10 @@ export const TableLocale = PropTypes.shape({
8080 collapse : PropTypes . string ,
8181} ) . loose ;
8282
83- export const RowSelectionType = PropTypes . oneOf ( [ 'checkbox' , 'radio' ] ) ;
83+ export const RowSelectionType = PropTypes . oneOf ( tuple ( 'checkbox' , 'radio' ) ) ;
8484// export type SelectionSelectFn<T> = (record: T, selected: boolean, selectedRows: Object[]) => any;
8585
86- export const TableRowSelection = {
86+ export const tableRowSelection = {
8787 type : RowSelectionType ,
8888 selectedRowKeys : PropTypes . array ,
8989 // onChange?: (selectedRowKeys: string[] | number[], selectedRows: Object[]) => any;
@@ -101,10 +101,12 @@ export const TableRowSelection = {
101101 columnTitle : PropTypes . any ,
102102} ;
103103
104- export const TableProps = {
104+ export type SortOrder = 'descend' | 'ascend' ;
105+
106+ export const tableProps = {
105107 prefixCls : PropTypes . string ,
106108 dropdownPrefixCls : PropTypes . string ,
107- rowSelection : PropTypes . oneOfType ( [ PropTypes . shape ( TableRowSelection ) . loose , Object ] ) ,
109+ rowSelection : PropTypes . oneOfType ( [ PropTypes . shape ( tableRowSelection ) . loose , Object ] ) ,
108110 pagination : withUndefined (
109111 PropTypes . oneOfType ( [
110112 PropTypes . shape ( {
@@ -117,7 +119,9 @@ export const TableProps = {
117119 size : PropTypes . oneOf ( tuple ( 'default' , 'middle' , 'small' , 'large' ) ) ,
118120 dataSource : PropTypes . array ,
119121 components : PropTypes . object ,
120- columns : PropTypes . array ,
122+ columns : {
123+ type : Array as PropType < ColumnProps > ,
124+ } ,
121125 rowKey : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . func ] ) ,
122126 rowClassName : PropTypes . func ,
123127 expandedRowRender : PropTypes . any ,
@@ -137,10 +141,18 @@ export const TableProps = {
137141 showHeader : PropTypes . looseBool ,
138142 footer : PropTypes . func ,
139143 title : PropTypes . func ,
140- scroll : PropTypes . object ,
144+ scroll : {
145+ type : Object as PropType < {
146+ x ?: boolean | number | string ;
147+ y ?: boolean | number | string ;
148+ scrollToFirstRowOnChange ?: boolean ;
149+ } > ,
150+ } ,
141151 childrenColumnName : PropTypes . oneOfType ( [ PropTypes . array , PropTypes . string ] ) ,
142- bodyStyle : PropTypes . any ,
143- sortDirections : PropTypes . array ,
152+ bodyStyle : PropTypes . style ,
153+ sortDirections : {
154+ type : Array as PropType < SortOrder [ ] > ,
155+ } ,
144156 tableLayout : PropTypes . string ,
145157 getPopupContainer : PropTypes . func ,
146158 expandIcon : PropTypes . func ,
@@ -153,9 +165,9 @@ export const TableProps = {
153165 // children?: React.ReactNode;
154166} ;
155167
156- export type ITableRowSelection = Partial < ExtractPropTypes < typeof TableRowSelection > > ;
168+ export type TableRowSelection = Partial < ExtractPropTypes < typeof tableRowSelection > > ;
157169
158- export type ITableProps = Partial < ExtractPropTypes < typeof TableProps > > ;
170+ export type TableProps = Partial < ExtractPropTypes < typeof tableProps > > ;
159171
160172export interface TableStateFilters {
161173 [ key : string ] : string [ ] ;
@@ -164,9 +176,9 @@ export interface TableStateFilters {
164176export interface TableState {
165177 pagination ?: Partial < ExtractPropTypes < typeof PaginationProps > > ;
166178 filters ?: TableStateFilters ;
167- sortColumn ?: Partial < ExtractPropTypes < typeof ColumnProps > > | null ;
179+ sortColumn ?: ColumnProps | null ;
168180 sortOrder ?: string ;
169- columns ?: IColumnProps [ ] ;
181+ columns ?: ColumnProps [ ] ;
170182}
171183
172184// export type SelectionItemSelectFn = (key: string[]) => any;
0 commit comments