1
+ import { ExtractPropTypes , PropType } from 'vue' ;
1
2
import PropTypes , { withUndefined } from '../_util/vue-types' ;
2
3
import { PaginationProps as getPaginationProps } from '../pagination' ;
3
4
import { SpinProps as getSpinProps } from '../spin' ;
4
5
import { Store } from './createStore' ;
5
6
import { tuple } from '../_util/type' ;
6
- import { ExtractPropTypes } from 'vue' ;
7
7
8
8
const PaginationProps = getPaginationProps ( ) ;
9
9
const SpinProps = getSpinProps ( ) ;
10
10
11
- // export type CompareFn<T> = (( a: T, b: T) => number) ;
11
+ export type CompareFn < T > = ( a : T , b : T , sortOrder ?: SortOrder ) => number ;
12
12
export const ColumnFilterItem = PropTypes . shape ( {
13
13
text : PropTypes . string ,
14
14
value : PropTypes . string ,
15
15
children : PropTypes . array ,
16
16
} ) . loose ;
17
17
18
- export const ColumnProps = {
18
+ export const columnProps = {
19
19
title : PropTypes . VNodeChild ,
20
20
key : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
21
21
dataIndex : PropTypes . string ,
@@ -52,7 +52,7 @@ export const ColumnProps = {
52
52
// onHeaderCell?: (props: ColumnProps<T>) => any;
53
53
} ;
54
54
55
- export type IColumnProps = Partial < ExtractPropTypes < typeof ColumnProps > > ;
55
+ export type ColumnProps = Partial < ExtractPropTypes < typeof columnProps > > ;
56
56
57
57
export interface TableComponents {
58
58
table ?: any ;
@@ -80,10 +80,10 @@ export const TableLocale = PropTypes.shape({
80
80
collapse : PropTypes . string ,
81
81
} ) . loose ;
82
82
83
- export const RowSelectionType = PropTypes . oneOf ( [ 'checkbox' , 'radio' ] ) ;
83
+ export const RowSelectionType = PropTypes . oneOf ( tuple ( 'checkbox' , 'radio' ) ) ;
84
84
// export type SelectionSelectFn<T> = (record: T, selected: boolean, selectedRows: Object[]) => any;
85
85
86
- export const TableRowSelection = {
86
+ export const tableRowSelection = {
87
87
type : RowSelectionType ,
88
88
selectedRowKeys : PropTypes . array ,
89
89
// onChange?: (selectedRowKeys: string[] | number[], selectedRows: Object[]) => any;
@@ -101,10 +101,12 @@ export const TableRowSelection = {
101
101
columnTitle : PropTypes . any ,
102
102
} ;
103
103
104
- export const TableProps = {
104
+ export type SortOrder = 'descend' | 'ascend' ;
105
+
106
+ export const tableProps = {
105
107
prefixCls : PropTypes . string ,
106
108
dropdownPrefixCls : PropTypes . string ,
107
- rowSelection : PropTypes . oneOfType ( [ PropTypes . shape ( TableRowSelection ) . loose , Object ] ) ,
109
+ rowSelection : PropTypes . oneOfType ( [ PropTypes . shape ( tableRowSelection ) . loose , Object ] ) ,
108
110
pagination : withUndefined (
109
111
PropTypes . oneOfType ( [
110
112
PropTypes . shape ( {
@@ -117,7 +119,9 @@ export const TableProps = {
117
119
size : PropTypes . oneOf ( tuple ( 'default' , 'middle' , 'small' , 'large' ) ) ,
118
120
dataSource : PropTypes . array ,
119
121
components : PropTypes . object ,
120
- columns : PropTypes . array ,
122
+ columns : {
123
+ type : Array as PropType < ColumnProps > ,
124
+ } ,
121
125
rowKey : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . func ] ) ,
122
126
rowClassName : PropTypes . func ,
123
127
expandedRowRender : PropTypes . any ,
@@ -137,10 +141,18 @@ export const TableProps = {
137
141
showHeader : PropTypes . looseBool ,
138
142
footer : PropTypes . func ,
139
143
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
+ } ,
141
151
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
+ } ,
144
156
tableLayout : PropTypes . string ,
145
157
getPopupContainer : PropTypes . func ,
146
158
expandIcon : PropTypes . func ,
@@ -153,9 +165,9 @@ export const TableProps = {
153
165
// children?: React.ReactNode;
154
166
} ;
155
167
156
- export type ITableRowSelection = Partial < ExtractPropTypes < typeof TableRowSelection > > ;
168
+ export type TableRowSelection = Partial < ExtractPropTypes < typeof tableRowSelection > > ;
157
169
158
- export type ITableProps = Partial < ExtractPropTypes < typeof TableProps > > ;
170
+ export type TableProps = Partial < ExtractPropTypes < typeof tableProps > > ;
159
171
160
172
export interface TableStateFilters {
161
173
[ key : string ] : string [ ] ;
@@ -164,9 +176,9 @@ export interface TableStateFilters {
164
176
export interface TableState {
165
177
pagination ?: Partial < ExtractPropTypes < typeof PaginationProps > > ;
166
178
filters ?: TableStateFilters ;
167
- sortColumn ?: Partial < ExtractPropTypes < typeof ColumnProps > > | null ;
179
+ sortColumn ?: ColumnProps | null ;
168
180
sortOrder ?: string ;
169
- columns ?: IColumnProps [ ] ;
181
+ columns ?: ColumnProps [ ] ;
170
182
}
171
183
172
184
// export type SelectionItemSelectFn = (key: string[]) => any;
0 commit comments