1
- import type { ExtractPropTypes , PropType } from 'vue' ;
1
+ import type { ExtractPropTypes } from 'vue' ;
2
2
import { computed , toRef , defineComponent } from 'vue' ;
3
3
import LeftOutlined from '@ant-design/icons-vue/LeftOutlined' ;
4
4
import RightOutlined from '@ant-design/icons-vue/RightOutlined' ;
@@ -11,50 +11,55 @@ import enUS from '../vc-pagination/locale/en_US';
11
11
import classNames from '../_util/classNames' ;
12
12
import useConfigInject from '../config-provider/hooks/useConfigInject' ;
13
13
import useBreakpoint from '../_util/hooks/useBreakpoint' ;
14
+ import { booleanType , arrayType , stringType , functionType , someType } from '../_util/type' ;
15
+
16
+ // CSSINJS
17
+ import useStyle from './style' ;
14
18
15
19
export const paginationProps = ( ) => ( {
16
20
total : Number ,
17
21
defaultCurrent : Number ,
18
- disabled : { type : Boolean , default : undefined } ,
22
+ disabled : booleanType ( ) ,
19
23
current : Number ,
20
24
defaultPageSize : Number ,
21
25
pageSize : Number ,
22
- hideOnSinglePage : { type : Boolean , default : undefined } ,
23
- showSizeChanger : { type : Boolean , default : undefined } ,
24
- pageSizeOptions : Array as PropType < ( string | number ) [ ] > ,
25
- buildOptionText : Function as PropType < ( opt : { value : any } ) => any > ,
26
- showQuickJumper : {
27
- type : [ Boolean , Object ] as PropType < boolean | { goButton ?: any } > ,
28
- default : undefined as boolean | { goButton ?: any } ,
29
- } ,
30
- showTotal : Function as PropType < ( total : number , range : [ number , number ] ) => any > ,
31
- size : String as PropType < 'default' | 'small' > ,
32
- simple : { type : Boolean , default : undefined } ,
26
+ hideOnSinglePage : booleanType ( ) ,
27
+ showSizeChanger : booleanType ( ) ,
28
+ pageSizeOptions : arrayType < ( string | number ) [ ] > ( ) ,
29
+ buildOptionText : functionType < ( opt : { value : any } ) => any > ( ) ,
30
+ showQuickJumper : someType < boolean | { goButton ?: any } > (
31
+ [ Boolean , Object ] ,
32
+ undefined as boolean | { goButton ?: any } ,
33
+ ) ,
34
+ showTotal : functionType < ( total : number , range : [ number , number ] ) => any > ( ) ,
35
+ size : stringType < 'default' | 'small' > ( ) ,
36
+ simple : booleanType ( ) ,
33
37
locale : Object ,
34
38
prefixCls : String ,
35
39
selectPrefixCls : String ,
36
40
totalBoundaryShowSizeChanger : Number ,
37
41
selectComponentClass : String ,
38
- itemRender : Function as PropType <
39
- ( opt : {
40
- page : number ;
41
- type : 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next' ;
42
- originalElement : any ;
43
- } ) => any
44
- > ,
42
+ itemRender :
43
+ functionType <
44
+ ( opt : {
45
+ page : number ;
46
+ type : 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next' ;
47
+ originalElement : any ;
48
+ } ) => any
49
+ > ( ) ,
45
50
role : String ,
46
51
responsive : Boolean ,
47
- showLessItems : { type : Boolean , default : undefined } ,
48
- onChange : Function as PropType < ( page : number , pageSize : number ) => void > ,
49
- onShowSizeChange : Function as PropType < ( current : number , size : number ) => void > ,
50
- 'onUpdate:current' : Function as PropType < ( current : number ) => void > ,
51
- 'onUpdate:pageSize' : Function as PropType < ( size : number ) => void > ,
52
+ showLessItems : booleanType ( ) ,
53
+ onChange : functionType < ( page : number , pageSize : number ) => void > ( ) ,
54
+ onShowSizeChange : functionType < ( current : number , size : number ) => void > ( ) ,
55
+ 'onUpdate:current' : functionType < ( current : number ) => void > ( ) ,
56
+ 'onUpdate:pageSize' : functionType < ( size : number ) => void > ( ) ,
52
57
} ) ;
53
58
54
59
export type PaginationPosition = 'top' | 'bottom' | 'both' ;
55
60
export const paginationConfig = ( ) => ( {
56
61
...paginationProps ( ) ,
57
- position : String as PropType < PaginationPosition > ,
62
+ position : stringType < PaginationPosition > ( ) ,
58
63
} ) ;
59
64
60
65
export type PaginationProps = Partial < ExtractPropTypes < ReturnType < typeof paginationProps > > > ;
@@ -81,6 +86,10 @@ export default defineComponent({
81
86
// emits: ['change', 'showSizeChange', 'update:current', 'update:pageSize'],
82
87
setup ( props , { slots, attrs } ) {
83
88
const { prefixCls, configProvider, direction } = useConfigInject ( 'pagination' , props ) ;
89
+
90
+ // style
91
+ const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
92
+
84
93
const selectPrefixCls = computed ( ( ) =>
85
94
configProvider . getPrefixCls ( 'select' , props . selectPrefixCls ) ,
86
95
) ;
@@ -152,11 +161,12 @@ export default defineComponent({
152
161
class : classNames (
153
162
{ mini : isSmall , [ `${ prefixCls . value } -rtl` ] : direction . value === 'rtl' } ,
154
163
attrs . class ,
164
+ hashId . value ,
155
165
) ,
156
166
itemRender,
157
167
} ;
158
168
159
- return < VcPagination { ...paginationProps } /> ;
169
+ return wrapSSR ( < VcPagination { ...paginationProps } /> ) ;
160
170
} ;
161
171
} ,
162
172
} ) ;
0 commit comments