@@ -8,9 +8,11 @@ import Pagination, { PaginationConfig } from '../pagination';
8
8
import { Row } from '../grid' ;
9
9
10
10
import Item from './Item' ;
11
- import { initDefaultProps , getComponent , getSlot } from '../_util/props-util' ;
11
+ import { getComponent , getSlot } from '../_util/props-util' ;
12
+ import initDefaultProps from '../_util/props-util/initDefaultProps' ;
12
13
import { cloneElement } from '../_util/vnode' ;
13
- import { provide , inject } from 'vue' ;
14
+ import { provide , inject , defineComponent , App } from 'vue' ;
15
+ import { tuple } from '../_util/type' ;
14
16
15
17
export { ListItemProps , ListItemMetaProps } from './Item' ;
16
18
@@ -29,7 +31,7 @@ export const ListGridType = {
29
31
xxl : PropTypes . oneOf ( ColumnCount ) ,
30
32
} ;
31
33
32
- export const ListSize = [ 'small' , 'default' , 'large' ] ;
34
+ export const ListSize = tuple ( 'small' , 'default' , 'large' ) ;
33
35
34
36
export const ListProps = ( ) => ( {
35
37
bordered : PropTypes . looseBool ,
@@ -52,7 +54,7 @@ export const ListProps = () => ({
52
54
locale : PropTypes . object ,
53
55
} ) ;
54
56
55
- const List = {
57
+ const List = defineComponent ( {
56
58
inheritAttrs : false ,
57
59
Item,
58
60
name : 'AList' ,
@@ -65,31 +67,35 @@ const List = {
65
67
} ) ,
66
68
created ( ) {
67
69
provide ( 'listContext' , this ) ;
68
- } ,
69
- setup ( ) {
70
- return {
71
- configProvider : inject ( 'configProvider' , defaultConfigProvider ) ,
72
- } ;
73
- } ,
74
-
75
- data ( ) {
76
- this . keys = [ ] ;
77
70
this . defaultPaginationProps = {
78
71
current : 1 ,
79
72
pageSize : 10 ,
80
- onChange : ( page , pageSize ) => {
73
+ onChange : ( page : number , pageSize : number ) => {
81
74
const { pagination } = this ;
82
75
this . paginationCurrent = page ;
83
- if ( pagination && pagination . onChange ) {
84
- pagination . onChange ( page , pageSize ) ;
76
+ if ( pagination && ( pagination as any ) . onChange ) {
77
+ ( pagination as any ) . onChange ( page , pageSize ) ;
85
78
}
86
79
} ,
87
80
total : 0 ,
88
81
} ;
89
82
this . onPaginationChange = this . triggerPaginationEvent ( 'onChange' ) ;
90
83
this . onPaginationShowSizeChange = this . triggerPaginationEvent ( 'onShowSizeChange' ) ;
84
+ } ,
85
+ setup ( ) {
86
+ return {
87
+ keys : [ ] ,
88
+ defaultPaginationProps : { } ,
89
+ onPaginationChange : null ,
90
+ onPaginationShowSizeChange : null ,
91
+ configProvider : inject ( 'configProvider' , defaultConfigProvider ) ,
92
+ } ;
93
+ } ,
94
+
95
+ data ( ) {
91
96
const { pagination } = this . $props ;
92
- const paginationObj = pagination && typeof pagination === 'object' ? pagination : { } ;
97
+ const paginationObj : Partial < typeof pagination > =
98
+ pagination && typeof pagination === 'object' ? pagination : { } ;
93
99
return {
94
100
paginationCurrent : paginationObj . defaultCurrent || 1 ,
95
101
paginationSize : paginationObj . defaultPageSize || 10 ,
@@ -163,7 +169,7 @@ const List = {
163
169
paginationSize,
164
170
$attrs,
165
171
} = this ;
166
- const getPrefixCls = this . configProvider . getPrefixCls ;
172
+ const { getPrefixCls } = this . configProvider ;
167
173
const prefixCls = getPrefixCls ( 'list' , customizePrefixCls ) ;
168
174
const { class : className , ...restAttrs } = $attrs ;
169
175
const loadMore = getComponent ( this , 'loadMore' ) ;
@@ -209,7 +215,7 @@ const List = {
209
215
total : dataSource . length ,
210
216
current : paginationCurrent ,
211
217
pageSize : paginationSize ,
212
- ...( pagination || { } ) ,
218
+ ...( ( pagination as any ) || { } ) ,
213
219
} ;
214
220
classString ;
215
221
const largestPage = Math . ceil ( paginationProps . total / paginationProps . pageSize ) ;
@@ -276,10 +282,10 @@ const List = {
276
282
</ div >
277
283
) ;
278
284
} ,
279
- } ;
285
+ } ) ;
280
286
281
287
/* istanbul ignore next */
282
- List . install = function ( app ) {
288
+ List . install = function ( app : App ) {
283
289
app . component ( List . name , List ) ;
284
290
app . component ( List . Item . name , List . Item ) ;
285
291
app . component ( List . Item . Meta . displayName , List . Item . Meta ) ;
0 commit comments