@@ -8,9 +8,11 @@ import Pagination, { PaginationConfig } from '../pagination';
88import { Row } from '../grid' ;
99
1010import 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' ;
1213import { cloneElement } from '../_util/vnode' ;
13- import { provide , inject } from 'vue' ;
14+ import { provide , inject , defineComponent , App } from 'vue' ;
15+ import { tuple } from '../_util/type' ;
1416
1517export { ListItemProps , ListItemMetaProps } from './Item' ;
1618
@@ -29,7 +31,7 @@ export const ListGridType = {
2931 xxl : PropTypes . oneOf ( ColumnCount ) ,
3032} ;
3133
32- export const ListSize = [ 'small' , 'default' , 'large' ] ;
34+ export const ListSize = tuple ( 'small' , 'default' , 'large' ) ;
3335
3436export const ListProps = ( ) => ( {
3537 bordered : PropTypes . looseBool ,
@@ -52,7 +54,7 @@ export const ListProps = () => ({
5254 locale : PropTypes . object ,
5355} ) ;
5456
55- const List = {
57+ const List = defineComponent ( {
5658 inheritAttrs : false ,
5759 Item,
5860 name : 'AList' ,
@@ -65,31 +67,35 @@ const List = {
6567 } ) ,
6668 created ( ) {
6769 provide ( 'listContext' , this ) ;
68- } ,
69- setup ( ) {
70- return {
71- configProvider : inject ( 'configProvider' , defaultConfigProvider ) ,
72- } ;
73- } ,
74-
75- data ( ) {
76- this . keys = [ ] ;
7770 this . defaultPaginationProps = {
7871 current : 1 ,
7972 pageSize : 10 ,
80- onChange : ( page , pageSize ) => {
73+ onChange : ( page : number , pageSize : number ) => {
8174 const { pagination } = this ;
8275 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 ) ;
8578 }
8679 } ,
8780 total : 0 ,
8881 } ;
8982 this . onPaginationChange = this . triggerPaginationEvent ( 'onChange' ) ;
9083 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 ( ) {
9196 const { pagination } = this . $props ;
92- const paginationObj = pagination && typeof pagination === 'object' ? pagination : { } ;
97+ const paginationObj : Partial < typeof pagination > =
98+ pagination && typeof pagination === 'object' ? pagination : { } ;
9399 return {
94100 paginationCurrent : paginationObj . defaultCurrent || 1 ,
95101 paginationSize : paginationObj . defaultPageSize || 10 ,
@@ -163,7 +169,7 @@ const List = {
163169 paginationSize,
164170 $attrs,
165171 } = this ;
166- const getPrefixCls = this . configProvider . getPrefixCls ;
172+ const { getPrefixCls } = this . configProvider ;
167173 const prefixCls = getPrefixCls ( 'list' , customizePrefixCls ) ;
168174 const { class : className , ...restAttrs } = $attrs ;
169175 const loadMore = getComponent ( this , 'loadMore' ) ;
@@ -209,7 +215,7 @@ const List = {
209215 total : dataSource . length ,
210216 current : paginationCurrent ,
211217 pageSize : paginationSize ,
212- ...( pagination || { } ) ,
218+ ...( ( pagination as any ) || { } ) ,
213219 } ;
214220 classString ;
215221 const largestPage = Math . ceil ( paginationProps . total / paginationProps . pageSize ) ;
@@ -276,10 +282,10 @@ const List = {
276282 </ div >
277283 ) ;
278284 } ,
279- } ;
285+ } ) ;
280286
281287/* istanbul ignore next */
282- List . install = function ( app ) {
288+ List . install = function ( app : App ) {
283289 app . component ( List . name , List ) ;
284290 app . component ( List . Item . name , List . Item ) ;
285291 app . component ( List . Item . Meta . displayName , List . Item . Meta ) ;
0 commit comments