@akinon/ui-pagination 0.5.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +19 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +339 -1
- package/dist/cjs/types.d.ts +163 -0
- package/dist/esm/index.d.ts +19 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +340 -2
- package/dist/esm/types.d.ts +163 -0
- package/package.json +5 -4
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import type { PaginationProps as AntPaginationProps } from 'antd';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { IPaginationProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Pagination component for data navigation and display.
|
|
5
|
+
*
|
|
6
|
+
* The Pagination component is designed to handle large datasets by splitting them into smaller pages.
|
|
7
|
+
* It provides users with an intuitive way to navigate through the pages and configure the display options.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Supports light and dark themes for seamless integration with different designs.
|
|
11
|
+
* - Flexible alignment options (`start`, `center`, `end`) for proper placement within the layout.
|
|
12
|
+
* - Configurable page sizes, responsive behavior, and customization of displayed items.
|
|
13
|
+
* - Advanced features like quick jumpers, size changers, and simple mode for improved usability.
|
|
14
|
+
* - Extensive event handling for page and size changes, enabling dynamic interactions.
|
|
15
|
+
* - Customizable item rendering for full control over the pagination UI.
|
|
16
|
+
*
|
|
17
|
+
* The Pagination component ensures efficient navigation and enhances the user experience when dealing with large datasets.
|
|
18
|
+
*/
|
|
19
|
+
export declare const Pagination: ({ ...restPaginationProps }: IPaginationProps) => React.JSX.Element;
|
|
20
|
+
export type { IPaginationProps };
|
|
5
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,UAAU,+BAAgC,gBAAgB,sBAuXtE,CAAC;AAEF,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,10 +12,348 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.Pagination = void 0;
|
|
15
|
+
const ui_theme_1 = require("@akinon/ui-theme");
|
|
16
|
+
const cssinjs_1 = require("@ant-design/cssinjs");
|
|
15
17
|
const antd_1 = require("antd");
|
|
16
18
|
const React = require("react");
|
|
19
|
+
/**
|
|
20
|
+
* Pagination component for data navigation and display.
|
|
21
|
+
*
|
|
22
|
+
* The Pagination component is designed to handle large datasets by splitting them into smaller pages.
|
|
23
|
+
* It provides users with an intuitive way to navigate through the pages and configure the display options.
|
|
24
|
+
*
|
|
25
|
+
* Features:
|
|
26
|
+
* - Supports light and dark themes for seamless integration with different designs.
|
|
27
|
+
* - Flexible alignment options (`start`, `center`, `end`) for proper placement within the layout.
|
|
28
|
+
* - Configurable page sizes, responsive behavior, and customization of displayed items.
|
|
29
|
+
* - Advanced features like quick jumpers, size changers, and simple mode for improved usability.
|
|
30
|
+
* - Extensive event handling for page and size changes, enabling dynamic interactions.
|
|
31
|
+
* - Customizable item rendering for full control over the pagination UI.
|
|
32
|
+
*
|
|
33
|
+
* The Pagination component ensures efficient navigation and enhances the user experience when dealing with large datasets.
|
|
34
|
+
*/
|
|
17
35
|
const Pagination = (_a) => {
|
|
18
36
|
var restPaginationProps = __rest(_a, []);
|
|
19
|
-
|
|
37
|
+
const { getPrefixCls, theme } = React.useContext(antd_1.ConfigProvider.ConfigContext);
|
|
38
|
+
const { token, hashId } = (0, ui_theme_1.useToken)();
|
|
39
|
+
const paginationToken = token.Pagination;
|
|
40
|
+
const prefixWithoutHash = `${getPrefixCls()}-pagination`;
|
|
41
|
+
const prefixClsWithoutHash = `.${prefixWithoutHash}`;
|
|
42
|
+
const themeClassName = `${prefixWithoutHash}-${restPaginationProps.theme}`;
|
|
43
|
+
const totalPage = Math.ceil((restPaginationProps.total || 1) / (restPaginationProps.pageSize || 1));
|
|
44
|
+
const [currentPage, setCurrentPage] = React.useState(restPaginationProps.defaultCurrent || 1);
|
|
45
|
+
const [inputValue, setInputValue] = React.useState(currentPage);
|
|
46
|
+
const inputRef = React.useRef(null);
|
|
47
|
+
const spanRef = React.useRef(null);
|
|
48
|
+
const handlePageChange = (page, pageSize) => {
|
|
49
|
+
setCurrentPage(page);
|
|
50
|
+
setInputValue(page);
|
|
51
|
+
if (restPaginationProps.onChange) {
|
|
52
|
+
restPaginationProps.onChange(page, pageSize);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const handleInputChange = (e) => {
|
|
56
|
+
setInputValue(e.target.value);
|
|
57
|
+
};
|
|
58
|
+
const handleProcessNewPageNumber = () => {
|
|
59
|
+
const pageNumber = Number(inputValue);
|
|
60
|
+
if (!isNaN(pageNumber) && pageNumber >= 1 && pageNumber <= totalPage) {
|
|
61
|
+
handlePageChange(pageNumber, restPaginationProps.pageSize || 10);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
setInputValue(currentPage);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const handleInputKeyDown = (e) => {
|
|
68
|
+
if (e.key === 'Enter') {
|
|
69
|
+
handleProcessNewPageNumber();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const handleInputBlur = () => {
|
|
73
|
+
handleProcessNewPageNumber();
|
|
74
|
+
};
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
if (inputRef.current && spanRef.current) {
|
|
77
|
+
spanRef.current.textContent = String(inputValue);
|
|
78
|
+
inputRef.current.style.width = `${spanRef.current.offsetWidth + 10}px`;
|
|
79
|
+
}
|
|
80
|
+
}, [inputValue]);
|
|
81
|
+
React.useEffect(() => {
|
|
82
|
+
if (typeof restPaginationProps.current !== 'undefined') {
|
|
83
|
+
setInputValue(restPaginationProps.current);
|
|
84
|
+
}
|
|
85
|
+
}, [restPaginationProps.current]);
|
|
86
|
+
const useStyle = (0, cssinjs_1.useStyleRegister)({
|
|
87
|
+
token: token,
|
|
88
|
+
path: ['Pagination'],
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
+
theme: theme
|
|
91
|
+
}, () => {
|
|
92
|
+
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-pagination`;
|
|
93
|
+
const customTokens = theme.CustomTokens || {};
|
|
94
|
+
return {
|
|
95
|
+
[prefixCls]: {
|
|
96
|
+
'*': {
|
|
97
|
+
boxSizing: 'initial'
|
|
98
|
+
},
|
|
99
|
+
[`&${prefixClsWithoutHash}-simple`]: {
|
|
100
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
101
|
+
maxWidth: customTokens.sizing.sizeMaxContent,
|
|
102
|
+
[`${prefixClsWithoutHash}-simple-pager`]: {
|
|
103
|
+
minWidth: paginationToken.Simple.minWidth,
|
|
104
|
+
fontSize: paginationToken.fontSize,
|
|
105
|
+
fontWeight: paginationToken.Simple.fontWeight,
|
|
106
|
+
color: paginationToken.Simple.color
|
|
107
|
+
},
|
|
108
|
+
['input']: {
|
|
109
|
+
backgroundColor: `${customTokens.others.colorTransparent} !important`,
|
|
110
|
+
border: `${customTokens.border.borderNone} !important`,
|
|
111
|
+
color: paginationToken.Simple.input.textColor,
|
|
112
|
+
fontSize: paginationToken.fontSize,
|
|
113
|
+
fontWeight: customTokens.typography.fontWeightBold,
|
|
114
|
+
padding: customTokens.sizing.valueZero,
|
|
115
|
+
boxShadow: customTokens.layout.displayNone
|
|
116
|
+
},
|
|
117
|
+
[`${prefixClsWithoutHash}-prev, ${prefixClsWithoutHash}-next`]: {
|
|
118
|
+
minWidth: customTokens.sizing.sizeMaxContent,
|
|
119
|
+
[`svg`]: {
|
|
120
|
+
width: paginationToken.Simple.prevNextButton.svgWidth,
|
|
121
|
+
height: customTokens.sizing.valueFull,
|
|
122
|
+
fill: paginationToken.Simple.prevNextButton.svgFill
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
[`${prefixClsWithoutHash}-slash`]: {
|
|
126
|
+
margin: customTokens.sizing.valueZero,
|
|
127
|
+
paddingRight: paginationToken.Simple.slashPadding
|
|
128
|
+
},
|
|
129
|
+
[`&${prefixClsWithoutHash}-light`]: {
|
|
130
|
+
[`&${prefixClsWithoutHash}-simple`]: {
|
|
131
|
+
['input']: {
|
|
132
|
+
color: paginationToken.Simple.lightInputTextColor
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
[`&${prefixClsWithoutHash}-dark`]: {
|
|
137
|
+
[`&${prefixClsWithoutHash}-simple`]: {
|
|
138
|
+
['input']: {
|
|
139
|
+
color: paginationToken.Simple.darkInputTextColor
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[`${prefixClsWithoutHash}-options, ${prefixClsWithoutHash}-total-text`]: {
|
|
144
|
+
display: customTokens.layout.displayNone
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
[`&:not(&${prefixClsWithoutHash}-simple)`]: {
|
|
148
|
+
display: customTokens.layout.displayContents,
|
|
149
|
+
[`${prefixClsWithoutHash}-total-text`]: {
|
|
150
|
+
width: customTokens.sizing.sizeFitContent,
|
|
151
|
+
fontWeight: customTokens.typography.fontWeightMedium,
|
|
152
|
+
color: paginationToken.Table.totalText.color,
|
|
153
|
+
margin: paginationToken.Table.totalText.margin,
|
|
154
|
+
height: customTokens.sizing.valueFull,
|
|
155
|
+
display: customTokens.layout.displayFlex,
|
|
156
|
+
alignItems: customTokens.layout.flexCenter,
|
|
157
|
+
gridArea: 'total'
|
|
158
|
+
},
|
|
159
|
+
[`${prefixClsWithoutHash}-prev, ${prefixClsWithoutHash}-next`]: {
|
|
160
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
161
|
+
lineHeight: customTokens.others.lineHeightShort,
|
|
162
|
+
display: customTokens.layout.displayFlex,
|
|
163
|
+
margin: customTokens.sizing.valueZero,
|
|
164
|
+
[`${prefixClsWithoutHash}-item-link`]: {
|
|
165
|
+
border: `${customTokens.border.borderNone} !important`,
|
|
166
|
+
padding: customTokens.sizing.valueZero,
|
|
167
|
+
lineHeight: customTokens.others.lineHeightShort,
|
|
168
|
+
width: customTokens.sizing.sizeMaxContent,
|
|
169
|
+
height: customTokens.sizing.sizeMaxContent
|
|
170
|
+
},
|
|
171
|
+
[`svg`]: {
|
|
172
|
+
width: paginationToken.Table.prevNextButton.svgWidth,
|
|
173
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
174
|
+
fill: paginationToken.Table.prevNextButton.svgFill,
|
|
175
|
+
padding: paginationToken.Table.prevNextButton.svgPadding,
|
|
176
|
+
border: paginationToken.Table.prevNextButton.svgBorder
|
|
177
|
+
},
|
|
178
|
+
[`&${prefixClsWithoutHash}-prev`]: {
|
|
179
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
180
|
+
gridArea: 'previous',
|
|
181
|
+
[`svg`]: {
|
|
182
|
+
borderRightWidth: customTokens.sizing.valueZero,
|
|
183
|
+
borderRadius: paginationToken.Table.prevNextButton.prevSvgBorderRadius
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
[`&${prefixClsWithoutHash}-next`]: {
|
|
187
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
188
|
+
gridArea: 'next',
|
|
189
|
+
[`svg`]: {
|
|
190
|
+
borderLeftWidth: customTokens.sizing.valueZero,
|
|
191
|
+
borderRadius: paginationToken.Table.prevNextButton.nextSvgBorderRadius
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
[`${prefixClsWithoutHash}-item`]: {
|
|
196
|
+
[`&:not(&${prefixClsWithoutHash}-item-active, ${prefixClsWithoutHash}-item-${totalPage})`]: {
|
|
197
|
+
display: customTokens.layout.displayNone
|
|
198
|
+
},
|
|
199
|
+
[`&${prefixClsWithoutHash}-item-active, &${prefixClsWithoutHash}-item-${totalPage}`]: {
|
|
200
|
+
margin: customTokens.sizing.valueZero,
|
|
201
|
+
border: paginationToken.Table.pageInfo.border,
|
|
202
|
+
borderRadius: customTokens.sizing.valueZero,
|
|
203
|
+
minWidth: customTokens.sizing.sizeMaxContent,
|
|
204
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
205
|
+
[`a`]: {
|
|
206
|
+
padding: paginationToken.Table.pageInfo.padding,
|
|
207
|
+
lineHeight: customTokens.others.lineHeightShort,
|
|
208
|
+
width: customTokens.sizing.sizeMaxContent
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
[`&${prefixClsWithoutHash}-item-active`]: {
|
|
212
|
+
backgroundColor: paginationToken.Table.pageInfo.currentPageBgColor,
|
|
213
|
+
display: customTokens.layout.displayNone,
|
|
214
|
+
[`a`]: {
|
|
215
|
+
minWidth: paginationToken.Table.pageInfo.currentPageMinWidth,
|
|
216
|
+
color: paginationToken.Table.pageInfo.currentPageTextColor,
|
|
217
|
+
fontWeight: paginationToken.Table.pageInfo.currentPageFontWeight
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
[`${prefixClsWithoutHash}-jump-prev, ${prefixClsWithoutHash}-jump-next`]: {
|
|
222
|
+
display: customTokens.layout.displayNone
|
|
223
|
+
},
|
|
224
|
+
[`${prefixClsWithoutHash}-options`]: {
|
|
225
|
+
display: customTokens.layout.displayContents,
|
|
226
|
+
[`&-size-changer`]: {
|
|
227
|
+
gridArea: 'options',
|
|
228
|
+
width: customTokens.sizing.sizeFitContent,
|
|
229
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
230
|
+
display: customTokens.layout.displayFlex,
|
|
231
|
+
flexDirection: customTokens.layout.flexDirectionRow,
|
|
232
|
+
alignItems: customTokens.layout.flexCenter,
|
|
233
|
+
columnGap: paginationToken.Table.sizeChanger.colGap,
|
|
234
|
+
border: paginationToken.Table.sizeChanger.border,
|
|
235
|
+
borderRadius: paginationToken.Table.sizeChanger.borderRadius,
|
|
236
|
+
[`.akinon-select-selector`]: {
|
|
237
|
+
border: `${customTokens.border.borderNone} !important`,
|
|
238
|
+
lineHeight: customTokens.others.lineHeightShort,
|
|
239
|
+
padding: paginationToken.Table.sizeChanger.item1.padding,
|
|
240
|
+
[`.akinon-select-selection-item`]: {
|
|
241
|
+
paddingInlineEnd: customTokens.sizing.valueZero,
|
|
242
|
+
lineHeight: customTokens.others.lineHeightShort,
|
|
243
|
+
fontWeight: customTokens.typography.fontWeightBold
|
|
244
|
+
},
|
|
245
|
+
[`&::after`]: {
|
|
246
|
+
lineHeight: customTokens.others.lineHeightShort
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
[`.akinon-select-arrow`]: {
|
|
250
|
+
width: paginationToken.Table.sizeChanger.icon.width,
|
|
251
|
+
position: customTokens.layout.positionRelative,
|
|
252
|
+
height: customTokens.sizing.valueAuto,
|
|
253
|
+
top: customTokens.sizing.valueZero,
|
|
254
|
+
margin: customTokens.sizing.valueAuto,
|
|
255
|
+
fontWeight: customTokens.typography.fontWeightBold
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
[`:not(${prefixClsWithoutHash}-light)`]: {
|
|
260
|
+
[`&${prefixClsWithoutHash}-item-${totalPage}`]: {
|
|
261
|
+
backgroundColor: `${customTokens.others.colorTransparent} !important`,
|
|
262
|
+
[`a`]: {
|
|
263
|
+
color: paginationToken.Table.sizeChanger.item2.textColor
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
[`${prefixClsWithoutHash}-options`]: {
|
|
267
|
+
display: customTokens.layout.displayContents,
|
|
268
|
+
[`&-size-changer`]: {
|
|
269
|
+
background: `${customTokens.others.colorTransparent} !important`
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
[`.akinon-select-selector`]: {
|
|
273
|
+
background: `${customTokens.others.colorTransparent} !important`,
|
|
274
|
+
[`.akinon-select-selection-item`]: {
|
|
275
|
+
color: paginationToken.Table.sizeChanger.item2.textColor
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
[`.akinon-select-arrow`]: {
|
|
279
|
+
background: `${customTokens.others.colorTransparent} !important`
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
[`${prefixClsWithoutHash}-light`]: {
|
|
283
|
+
[`${prefixClsWithoutHash}-item-${totalPage}`]: {
|
|
284
|
+
backgroundColor: paginationToken.Table.pageInfo.totalPageBgColor,
|
|
285
|
+
[`a`]: {
|
|
286
|
+
color: paginationToken.Table.pageInfo.totalPageTextColor
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
[`${prefixClsWithoutHash}-options`]: {
|
|
290
|
+
[`&-size-changer`]: {
|
|
291
|
+
background: paginationToken.Table.sizeChanger.bgColor
|
|
292
|
+
},
|
|
293
|
+
[`.akinon-select-selector`]: {
|
|
294
|
+
background: paginationToken.Table.sizeChanger.item1.bgColor,
|
|
295
|
+
[`.akinon-select-selection-item`]: {
|
|
296
|
+
color: paginationToken.Table.sizeChanger.item2.textColor
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
[`.akinon-select-arrow`]: {
|
|
300
|
+
background: paginationToken.Table.sizeChanger.icon.bgColor
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
[`${prefixClsWithoutHash}-parent`]: {
|
|
307
|
+
display: customTokens.layout.displayGrid,
|
|
308
|
+
gridTemplateAreas: `'options total previous goto showTotal next'`,
|
|
309
|
+
gridTemplateColumns: 'max-content max-content max-content max-content max-content max-content',
|
|
310
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
311
|
+
maxWidth: customTokens.sizing.sizeMaxContent
|
|
312
|
+
},
|
|
313
|
+
[`${prefixClsWithoutHash}-options-quick-jumper-new`]: {
|
|
314
|
+
display: restPaginationProps.simple
|
|
315
|
+
? customTokens.layout.displayNone
|
|
316
|
+
: customTokens.layout.displayBlock,
|
|
317
|
+
gridArea: 'goto',
|
|
318
|
+
overflow: customTokens.others.valueHidden,
|
|
319
|
+
border: paginationToken.Jumper.border,
|
|
320
|
+
borderRight: customTokens.sizing.valueZero,
|
|
321
|
+
borderRadius: customTokens.sizing.valueZero,
|
|
322
|
+
['input, span']: {
|
|
323
|
+
backgroundColor: paginationToken.Jumper.bgColor,
|
|
324
|
+
color: paginationToken.Jumper.textColor,
|
|
325
|
+
fontWeight: customTokens.typography.fontWeightBold,
|
|
326
|
+
minWidth: paginationToken.Jumper.minWidth,
|
|
327
|
+
border: `${customTokens.border.borderNone} !important`,
|
|
328
|
+
height: paginationToken.Jumper.height,
|
|
329
|
+
boxShadow: customTokens.layout.displayNone,
|
|
330
|
+
textAlign: customTokens.typography.textAlignCenter,
|
|
331
|
+
outline: customTokens.layout.displayNone
|
|
332
|
+
},
|
|
333
|
+
['span']: {
|
|
334
|
+
visibility: customTokens.others.valueHidden,
|
|
335
|
+
whiteSpace: customTokens.typography.whiteSpacePre,
|
|
336
|
+
position: customTokens.layout.positionAbsolute
|
|
337
|
+
},
|
|
338
|
+
[`&:not(${prefixClsWithoutHash}-light)`]: {
|
|
339
|
+
['input, span']: {
|
|
340
|
+
backgroundColor: `${customTokens.others.colorTransparent} !important`,
|
|
341
|
+
color: paginationToken.Table.prevNextButton.svgFill
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
[`&${prefixClsWithoutHash}-light`]: {
|
|
345
|
+
['input, span']: {
|
|
346
|
+
backgroundColor: `${customTokens.others.colorTransparent} !important`,
|
|
347
|
+
color: paginationToken.Table.prevNextButton.svgFill
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
return useStyle(React.createElement("div", { className: `${prefixWithoutHash}-parent` },
|
|
354
|
+
React.createElement(antd_1.Pagination, Object.assign({}, restPaginationProps, { className: themeClassName, locale: { jump_to: '', page: '', items_per_page: '' }, onChange: handlePageChange })),
|
|
355
|
+
!restPaginationProps.simple && (React.createElement("div", { className: `${prefixWithoutHash}-options-quick-jumper-new ${themeClassName}` },
|
|
356
|
+
React.createElement("span", { ref: spanRef }),
|
|
357
|
+
React.createElement("input", { ref: inputRef, type: "text", value: inputValue, onChange: handleInputChange, onKeyDown: handleInputKeyDown, onBlur: handleInputBlur })))));
|
|
20
358
|
};
|
|
21
359
|
exports.Pagination = Pagination;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
|
|
2
|
+
import type { SelectProps } from 'antd';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
export type TPaginationAlign = 'start' | 'center' | 'end';
|
|
6
|
+
|
|
7
|
+
export type TPaginationItemRender = (
|
|
8
|
+
page,
|
|
9
|
+
type: 'page' | 'prev' | 'next',
|
|
10
|
+
originalElement
|
|
11
|
+
) => React.ReactNode;
|
|
12
|
+
|
|
13
|
+
export type TPaginationShowQuickJumper = boolean | { goButton: ReactNode };
|
|
14
|
+
|
|
15
|
+
export type TPaginationShowTotal = (total, range) => ReactNode;
|
|
16
|
+
|
|
17
|
+
export type TPaginationSimple = boolean | { readOnly?: boolean };
|
|
18
|
+
|
|
19
|
+
export type TPaginationSize = 'default' | 'small';
|
|
20
|
+
|
|
21
|
+
export type TPaginationOnChange = (page, pageSize) => ReactNode;
|
|
22
|
+
|
|
23
|
+
export type TPaginationOnShowSizeChange = (current, size) => ReactNode;
|
|
24
|
+
|
|
25
|
+
export interface IPaginationProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
26
|
+
/**
|
|
27
|
+
* Theme type
|
|
28
|
+
* @default dark
|
|
29
|
+
*/
|
|
30
|
+
theme?: 'light' | 'dark';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Alignment of the pagination component.
|
|
34
|
+
*/
|
|
35
|
+
align?: TPaginationAlign;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Current page number
|
|
39
|
+
*/
|
|
40
|
+
current?: number;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Default initial page number
|
|
44
|
+
* @default 1
|
|
45
|
+
*/
|
|
46
|
+
defaultCurrent?: number;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Default number of data items per page
|
|
50
|
+
* @default 10
|
|
51
|
+
*/
|
|
52
|
+
defaultPageSize?: number;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Disable pagination
|
|
56
|
+
*/
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether to hide pager on single page
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
hideOnSinglePage?: boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* To customize item's innerHTML
|
|
67
|
+
*/
|
|
68
|
+
itemRender?: TPaginationItemRender;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Number of data items per page
|
|
72
|
+
*/
|
|
73
|
+
pageSize?: number;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Specify the sizeChanger options
|
|
77
|
+
* @default
|
|
78
|
+
* [10, 20, 50, 100]
|
|
79
|
+
*/
|
|
80
|
+
pageSizeOptions?: string[] | number[];
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* If size is not specified, Pagination would resize according to the width of the window
|
|
84
|
+
*/
|
|
85
|
+
responsive?: boolean;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Show less page items
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
showLessItems?: boolean;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Determine whether you can jump to pages directly
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
showQuickJumper?: TPaginationShowQuickJumper;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Determine whether to show pageSize select, it will be true when total > 50
|
|
101
|
+
*/
|
|
102
|
+
showSizeChanger?: boolean | SelectProps;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Show page item's title
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
showTitle?: boolean;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* To display the total number and range
|
|
112
|
+
*/
|
|
113
|
+
showTotal?: TPaginationShowTotal;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Whether to use simple mode
|
|
117
|
+
*/
|
|
118
|
+
simple?: TPaginationSimple;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Specify the size of Pagination, can be set to small
|
|
122
|
+
* @default default
|
|
123
|
+
*/
|
|
124
|
+
size?: TPaginationSize;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Total number of data items
|
|
128
|
+
* @default 0
|
|
129
|
+
*/
|
|
130
|
+
total: number;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Called when the page number or pageSize is changed, and it takes the resulting page number and pageSize as its arguments
|
|
134
|
+
*/
|
|
135
|
+
onChange?: TPaginationOnChange;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Called when pageSize is changed
|
|
139
|
+
*/
|
|
140
|
+
onShowSizeChange?: TPaginationOnShowSizeChange;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Localization strings
|
|
144
|
+
*/
|
|
145
|
+
locale?: {
|
|
146
|
+
items_per_page?: string;
|
|
147
|
+
jump_to?: string;
|
|
148
|
+
jump_to_confirm?: string;
|
|
149
|
+
page?: string;
|
|
150
|
+
prev_page?: string;
|
|
151
|
+
next_page?: string;
|
|
152
|
+
prev_5?: string;
|
|
153
|
+
next_5?: string;
|
|
154
|
+
prev_3?: string;
|
|
155
|
+
next_3?: string;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Never use this prop. Akinon design system does not allow custom styles.
|
|
160
|
+
* @ignore
|
|
161
|
+
*/
|
|
162
|
+
style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
|
|
163
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import type { PaginationProps as AntPaginationProps } from 'antd';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { IPaginationProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Pagination component for data navigation and display.
|
|
5
|
+
*
|
|
6
|
+
* The Pagination component is designed to handle large datasets by splitting them into smaller pages.
|
|
7
|
+
* It provides users with an intuitive way to navigate through the pages and configure the display options.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Supports light and dark themes for seamless integration with different designs.
|
|
11
|
+
* - Flexible alignment options (`start`, `center`, `end`) for proper placement within the layout.
|
|
12
|
+
* - Configurable page sizes, responsive behavior, and customization of displayed items.
|
|
13
|
+
* - Advanced features like quick jumpers, size changers, and simple mode for improved usability.
|
|
14
|
+
* - Extensive event handling for page and size changes, enabling dynamic interactions.
|
|
15
|
+
* - Customizable item rendering for full control over the pagination UI.
|
|
16
|
+
*
|
|
17
|
+
* The Pagination component ensures efficient navigation and enhances the user experience when dealing with large datasets.
|
|
18
|
+
*/
|
|
19
|
+
export declare const Pagination: ({ ...restPaginationProps }: IPaginationProps) => React.JSX.Element;
|
|
20
|
+
export type { IPaginationProps };
|
|
5
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,UAAU,+BAAgC,gBAAgB,sBAuXtE,CAAC;AAEF,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -9,9 +9,347 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import {
|
|
12
|
+
import { useToken } from '@akinon/ui-theme';
|
|
13
|
+
import { useStyleRegister } from '@ant-design/cssinjs';
|
|
14
|
+
import { ConfigProvider, Pagination as AntPagination } from 'antd';
|
|
13
15
|
import * as React from 'react';
|
|
16
|
+
/**
|
|
17
|
+
* Pagination component for data navigation and display.
|
|
18
|
+
*
|
|
19
|
+
* The Pagination component is designed to handle large datasets by splitting them into smaller pages.
|
|
20
|
+
* It provides users with an intuitive way to navigate through the pages and configure the display options.
|
|
21
|
+
*
|
|
22
|
+
* Features:
|
|
23
|
+
* - Supports light and dark themes for seamless integration with different designs.
|
|
24
|
+
* - Flexible alignment options (`start`, `center`, `end`) for proper placement within the layout.
|
|
25
|
+
* - Configurable page sizes, responsive behavior, and customization of displayed items.
|
|
26
|
+
* - Advanced features like quick jumpers, size changers, and simple mode for improved usability.
|
|
27
|
+
* - Extensive event handling for page and size changes, enabling dynamic interactions.
|
|
28
|
+
* - Customizable item rendering for full control over the pagination UI.
|
|
29
|
+
*
|
|
30
|
+
* The Pagination component ensures efficient navigation and enhances the user experience when dealing with large datasets.
|
|
31
|
+
*/
|
|
14
32
|
export const Pagination = (_a) => {
|
|
15
33
|
var restPaginationProps = __rest(_a, []);
|
|
16
|
-
|
|
34
|
+
const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
|
|
35
|
+
const { token, hashId } = useToken();
|
|
36
|
+
const paginationToken = token.Pagination;
|
|
37
|
+
const prefixWithoutHash = `${getPrefixCls()}-pagination`;
|
|
38
|
+
const prefixClsWithoutHash = `.${prefixWithoutHash}`;
|
|
39
|
+
const themeClassName = `${prefixWithoutHash}-${restPaginationProps.theme}`;
|
|
40
|
+
const totalPage = Math.ceil((restPaginationProps.total || 1) / (restPaginationProps.pageSize || 1));
|
|
41
|
+
const [currentPage, setCurrentPage] = React.useState(restPaginationProps.defaultCurrent || 1);
|
|
42
|
+
const [inputValue, setInputValue] = React.useState(currentPage);
|
|
43
|
+
const inputRef = React.useRef(null);
|
|
44
|
+
const spanRef = React.useRef(null);
|
|
45
|
+
const handlePageChange = (page, pageSize) => {
|
|
46
|
+
setCurrentPage(page);
|
|
47
|
+
setInputValue(page);
|
|
48
|
+
if (restPaginationProps.onChange) {
|
|
49
|
+
restPaginationProps.onChange(page, pageSize);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const handleInputChange = (e) => {
|
|
53
|
+
setInputValue(e.target.value);
|
|
54
|
+
};
|
|
55
|
+
const handleProcessNewPageNumber = () => {
|
|
56
|
+
const pageNumber = Number(inputValue);
|
|
57
|
+
if (!isNaN(pageNumber) && pageNumber >= 1 && pageNumber <= totalPage) {
|
|
58
|
+
handlePageChange(pageNumber, restPaginationProps.pageSize || 10);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
setInputValue(currentPage);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const handleInputKeyDown = (e) => {
|
|
65
|
+
if (e.key === 'Enter') {
|
|
66
|
+
handleProcessNewPageNumber();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const handleInputBlur = () => {
|
|
70
|
+
handleProcessNewPageNumber();
|
|
71
|
+
};
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
if (inputRef.current && spanRef.current) {
|
|
74
|
+
spanRef.current.textContent = String(inputValue);
|
|
75
|
+
inputRef.current.style.width = `${spanRef.current.offsetWidth + 10}px`;
|
|
76
|
+
}
|
|
77
|
+
}, [inputValue]);
|
|
78
|
+
React.useEffect(() => {
|
|
79
|
+
if (typeof restPaginationProps.current !== 'undefined') {
|
|
80
|
+
setInputValue(restPaginationProps.current);
|
|
81
|
+
}
|
|
82
|
+
}, [restPaginationProps.current]);
|
|
83
|
+
const useStyle = useStyleRegister({
|
|
84
|
+
token: token,
|
|
85
|
+
path: ['Pagination'],
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
+
theme: theme
|
|
88
|
+
}, () => {
|
|
89
|
+
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-pagination`;
|
|
90
|
+
const customTokens = theme.CustomTokens || {};
|
|
91
|
+
return {
|
|
92
|
+
[prefixCls]: {
|
|
93
|
+
'*': {
|
|
94
|
+
boxSizing: 'initial'
|
|
95
|
+
},
|
|
96
|
+
[`&${prefixClsWithoutHash}-simple`]: {
|
|
97
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
98
|
+
maxWidth: customTokens.sizing.sizeMaxContent,
|
|
99
|
+
[`${prefixClsWithoutHash}-simple-pager`]: {
|
|
100
|
+
minWidth: paginationToken.Simple.minWidth,
|
|
101
|
+
fontSize: paginationToken.fontSize,
|
|
102
|
+
fontWeight: paginationToken.Simple.fontWeight,
|
|
103
|
+
color: paginationToken.Simple.color
|
|
104
|
+
},
|
|
105
|
+
['input']: {
|
|
106
|
+
backgroundColor: `${customTokens.others.colorTransparent} !important`,
|
|
107
|
+
border: `${customTokens.border.borderNone} !important`,
|
|
108
|
+
color: paginationToken.Simple.input.textColor,
|
|
109
|
+
fontSize: paginationToken.fontSize,
|
|
110
|
+
fontWeight: customTokens.typography.fontWeightBold,
|
|
111
|
+
padding: customTokens.sizing.valueZero,
|
|
112
|
+
boxShadow: customTokens.layout.displayNone
|
|
113
|
+
},
|
|
114
|
+
[`${prefixClsWithoutHash}-prev, ${prefixClsWithoutHash}-next`]: {
|
|
115
|
+
minWidth: customTokens.sizing.sizeMaxContent,
|
|
116
|
+
[`svg`]: {
|
|
117
|
+
width: paginationToken.Simple.prevNextButton.svgWidth,
|
|
118
|
+
height: customTokens.sizing.valueFull,
|
|
119
|
+
fill: paginationToken.Simple.prevNextButton.svgFill
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
[`${prefixClsWithoutHash}-slash`]: {
|
|
123
|
+
margin: customTokens.sizing.valueZero,
|
|
124
|
+
paddingRight: paginationToken.Simple.slashPadding
|
|
125
|
+
},
|
|
126
|
+
[`&${prefixClsWithoutHash}-light`]: {
|
|
127
|
+
[`&${prefixClsWithoutHash}-simple`]: {
|
|
128
|
+
['input']: {
|
|
129
|
+
color: paginationToken.Simple.lightInputTextColor
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
[`&${prefixClsWithoutHash}-dark`]: {
|
|
134
|
+
[`&${prefixClsWithoutHash}-simple`]: {
|
|
135
|
+
['input']: {
|
|
136
|
+
color: paginationToken.Simple.darkInputTextColor
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
[`${prefixClsWithoutHash}-options, ${prefixClsWithoutHash}-total-text`]: {
|
|
141
|
+
display: customTokens.layout.displayNone
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
[`&:not(&${prefixClsWithoutHash}-simple)`]: {
|
|
145
|
+
display: customTokens.layout.displayContents,
|
|
146
|
+
[`${prefixClsWithoutHash}-total-text`]: {
|
|
147
|
+
width: customTokens.sizing.sizeFitContent,
|
|
148
|
+
fontWeight: customTokens.typography.fontWeightMedium,
|
|
149
|
+
color: paginationToken.Table.totalText.color,
|
|
150
|
+
margin: paginationToken.Table.totalText.margin,
|
|
151
|
+
height: customTokens.sizing.valueFull,
|
|
152
|
+
display: customTokens.layout.displayFlex,
|
|
153
|
+
alignItems: customTokens.layout.flexCenter,
|
|
154
|
+
gridArea: 'total'
|
|
155
|
+
},
|
|
156
|
+
[`${prefixClsWithoutHash}-prev, ${prefixClsWithoutHash}-next`]: {
|
|
157
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
158
|
+
lineHeight: customTokens.others.lineHeightShort,
|
|
159
|
+
display: customTokens.layout.displayFlex,
|
|
160
|
+
margin: customTokens.sizing.valueZero,
|
|
161
|
+
[`${prefixClsWithoutHash}-item-link`]: {
|
|
162
|
+
border: `${customTokens.border.borderNone} !important`,
|
|
163
|
+
padding: customTokens.sizing.valueZero,
|
|
164
|
+
lineHeight: customTokens.others.lineHeightShort,
|
|
165
|
+
width: customTokens.sizing.sizeMaxContent,
|
|
166
|
+
height: customTokens.sizing.sizeMaxContent
|
|
167
|
+
},
|
|
168
|
+
[`svg`]: {
|
|
169
|
+
width: paginationToken.Table.prevNextButton.svgWidth,
|
|
170
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
171
|
+
fill: paginationToken.Table.prevNextButton.svgFill,
|
|
172
|
+
padding: paginationToken.Table.prevNextButton.svgPadding,
|
|
173
|
+
border: paginationToken.Table.prevNextButton.svgBorder
|
|
174
|
+
},
|
|
175
|
+
[`&${prefixClsWithoutHash}-prev`]: {
|
|
176
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
177
|
+
gridArea: 'previous',
|
|
178
|
+
[`svg`]: {
|
|
179
|
+
borderRightWidth: customTokens.sizing.valueZero,
|
|
180
|
+
borderRadius: paginationToken.Table.prevNextButton.prevSvgBorderRadius
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
[`&${prefixClsWithoutHash}-next`]: {
|
|
184
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
185
|
+
gridArea: 'next',
|
|
186
|
+
[`svg`]: {
|
|
187
|
+
borderLeftWidth: customTokens.sizing.valueZero,
|
|
188
|
+
borderRadius: paginationToken.Table.prevNextButton.nextSvgBorderRadius
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
[`${prefixClsWithoutHash}-item`]: {
|
|
193
|
+
[`&:not(&${prefixClsWithoutHash}-item-active, ${prefixClsWithoutHash}-item-${totalPage})`]: {
|
|
194
|
+
display: customTokens.layout.displayNone
|
|
195
|
+
},
|
|
196
|
+
[`&${prefixClsWithoutHash}-item-active, &${prefixClsWithoutHash}-item-${totalPage}`]: {
|
|
197
|
+
margin: customTokens.sizing.valueZero,
|
|
198
|
+
border: paginationToken.Table.pageInfo.border,
|
|
199
|
+
borderRadius: customTokens.sizing.valueZero,
|
|
200
|
+
minWidth: customTokens.sizing.sizeMaxContent,
|
|
201
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
202
|
+
[`a`]: {
|
|
203
|
+
padding: paginationToken.Table.pageInfo.padding,
|
|
204
|
+
lineHeight: customTokens.others.lineHeightShort,
|
|
205
|
+
width: customTokens.sizing.sizeMaxContent
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
[`&${prefixClsWithoutHash}-item-active`]: {
|
|
209
|
+
backgroundColor: paginationToken.Table.pageInfo.currentPageBgColor,
|
|
210
|
+
display: customTokens.layout.displayNone,
|
|
211
|
+
[`a`]: {
|
|
212
|
+
minWidth: paginationToken.Table.pageInfo.currentPageMinWidth,
|
|
213
|
+
color: paginationToken.Table.pageInfo.currentPageTextColor,
|
|
214
|
+
fontWeight: paginationToken.Table.pageInfo.currentPageFontWeight
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
[`${prefixClsWithoutHash}-jump-prev, ${prefixClsWithoutHash}-jump-next`]: {
|
|
219
|
+
display: customTokens.layout.displayNone
|
|
220
|
+
},
|
|
221
|
+
[`${prefixClsWithoutHash}-options`]: {
|
|
222
|
+
display: customTokens.layout.displayContents,
|
|
223
|
+
[`&-size-changer`]: {
|
|
224
|
+
gridArea: 'options',
|
|
225
|
+
width: customTokens.sizing.sizeFitContent,
|
|
226
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
227
|
+
display: customTokens.layout.displayFlex,
|
|
228
|
+
flexDirection: customTokens.layout.flexDirectionRow,
|
|
229
|
+
alignItems: customTokens.layout.flexCenter,
|
|
230
|
+
columnGap: paginationToken.Table.sizeChanger.colGap,
|
|
231
|
+
border: paginationToken.Table.sizeChanger.border,
|
|
232
|
+
borderRadius: paginationToken.Table.sizeChanger.borderRadius,
|
|
233
|
+
[`.akinon-select-selector`]: {
|
|
234
|
+
border: `${customTokens.border.borderNone} !important`,
|
|
235
|
+
lineHeight: customTokens.others.lineHeightShort,
|
|
236
|
+
padding: paginationToken.Table.sizeChanger.item1.padding,
|
|
237
|
+
[`.akinon-select-selection-item`]: {
|
|
238
|
+
paddingInlineEnd: customTokens.sizing.valueZero,
|
|
239
|
+
lineHeight: customTokens.others.lineHeightShort,
|
|
240
|
+
fontWeight: customTokens.typography.fontWeightBold
|
|
241
|
+
},
|
|
242
|
+
[`&::after`]: {
|
|
243
|
+
lineHeight: customTokens.others.lineHeightShort
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
[`.akinon-select-arrow`]: {
|
|
247
|
+
width: paginationToken.Table.sizeChanger.icon.width,
|
|
248
|
+
position: customTokens.layout.positionRelative,
|
|
249
|
+
height: customTokens.sizing.valueAuto,
|
|
250
|
+
top: customTokens.sizing.valueZero,
|
|
251
|
+
margin: customTokens.sizing.valueAuto,
|
|
252
|
+
fontWeight: customTokens.typography.fontWeightBold
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
[`:not(${prefixClsWithoutHash}-light)`]: {
|
|
257
|
+
[`&${prefixClsWithoutHash}-item-${totalPage}`]: {
|
|
258
|
+
backgroundColor: `${customTokens.others.colorTransparent} !important`,
|
|
259
|
+
[`a`]: {
|
|
260
|
+
color: paginationToken.Table.sizeChanger.item2.textColor
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
[`${prefixClsWithoutHash}-options`]: {
|
|
264
|
+
display: customTokens.layout.displayContents,
|
|
265
|
+
[`&-size-changer`]: {
|
|
266
|
+
background: `${customTokens.others.colorTransparent} !important`
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
[`.akinon-select-selector`]: {
|
|
270
|
+
background: `${customTokens.others.colorTransparent} !important`,
|
|
271
|
+
[`.akinon-select-selection-item`]: {
|
|
272
|
+
color: paginationToken.Table.sizeChanger.item2.textColor
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
[`.akinon-select-arrow`]: {
|
|
276
|
+
background: `${customTokens.others.colorTransparent} !important`
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
[`${prefixClsWithoutHash}-light`]: {
|
|
280
|
+
[`${prefixClsWithoutHash}-item-${totalPage}`]: {
|
|
281
|
+
backgroundColor: paginationToken.Table.pageInfo.totalPageBgColor,
|
|
282
|
+
[`a`]: {
|
|
283
|
+
color: paginationToken.Table.pageInfo.totalPageTextColor
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
[`${prefixClsWithoutHash}-options`]: {
|
|
287
|
+
[`&-size-changer`]: {
|
|
288
|
+
background: paginationToken.Table.sizeChanger.bgColor
|
|
289
|
+
},
|
|
290
|
+
[`.akinon-select-selector`]: {
|
|
291
|
+
background: paginationToken.Table.sizeChanger.item1.bgColor,
|
|
292
|
+
[`.akinon-select-selection-item`]: {
|
|
293
|
+
color: paginationToken.Table.sizeChanger.item2.textColor
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
[`.akinon-select-arrow`]: {
|
|
297
|
+
background: paginationToken.Table.sizeChanger.icon.bgColor
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
[`${prefixClsWithoutHash}-parent`]: {
|
|
304
|
+
display: customTokens.layout.displayGrid,
|
|
305
|
+
gridTemplateAreas: `'options total previous goto showTotal next'`,
|
|
306
|
+
gridTemplateColumns: 'max-content max-content max-content max-content max-content max-content',
|
|
307
|
+
height: customTokens.sizing.sizeMaxContent,
|
|
308
|
+
maxWidth: customTokens.sizing.sizeMaxContent
|
|
309
|
+
},
|
|
310
|
+
[`${prefixClsWithoutHash}-options-quick-jumper-new`]: {
|
|
311
|
+
display: restPaginationProps.simple
|
|
312
|
+
? customTokens.layout.displayNone
|
|
313
|
+
: customTokens.layout.displayBlock,
|
|
314
|
+
gridArea: 'goto',
|
|
315
|
+
overflow: customTokens.others.valueHidden,
|
|
316
|
+
border: paginationToken.Jumper.border,
|
|
317
|
+
borderRight: customTokens.sizing.valueZero,
|
|
318
|
+
borderRadius: customTokens.sizing.valueZero,
|
|
319
|
+
['input, span']: {
|
|
320
|
+
backgroundColor: paginationToken.Jumper.bgColor,
|
|
321
|
+
color: paginationToken.Jumper.textColor,
|
|
322
|
+
fontWeight: customTokens.typography.fontWeightBold,
|
|
323
|
+
minWidth: paginationToken.Jumper.minWidth,
|
|
324
|
+
border: `${customTokens.border.borderNone} !important`,
|
|
325
|
+
height: paginationToken.Jumper.height,
|
|
326
|
+
boxShadow: customTokens.layout.displayNone,
|
|
327
|
+
textAlign: customTokens.typography.textAlignCenter,
|
|
328
|
+
outline: customTokens.layout.displayNone
|
|
329
|
+
},
|
|
330
|
+
['span']: {
|
|
331
|
+
visibility: customTokens.others.valueHidden,
|
|
332
|
+
whiteSpace: customTokens.typography.whiteSpacePre,
|
|
333
|
+
position: customTokens.layout.positionAbsolute
|
|
334
|
+
},
|
|
335
|
+
[`&:not(${prefixClsWithoutHash}-light)`]: {
|
|
336
|
+
['input, span']: {
|
|
337
|
+
backgroundColor: `${customTokens.others.colorTransparent} !important`,
|
|
338
|
+
color: paginationToken.Table.prevNextButton.svgFill
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
[`&${prefixClsWithoutHash}-light`]: {
|
|
342
|
+
['input, span']: {
|
|
343
|
+
backgroundColor: `${customTokens.others.colorTransparent} !important`,
|
|
344
|
+
color: paginationToken.Table.prevNextButton.svgFill
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
});
|
|
350
|
+
return useStyle(React.createElement("div", { className: `${prefixWithoutHash}-parent` },
|
|
351
|
+
React.createElement(AntPagination, Object.assign({}, restPaginationProps, { className: themeClassName, locale: { jump_to: '', page: '', items_per_page: '' }, onChange: handlePageChange })),
|
|
352
|
+
!restPaginationProps.simple && (React.createElement("div", { className: `${prefixWithoutHash}-options-quick-jumper-new ${themeClassName}` },
|
|
353
|
+
React.createElement("span", { ref: spanRef }),
|
|
354
|
+
React.createElement("input", { ref: inputRef, type: "text", value: inputValue, onChange: handleInputChange, onKeyDown: handleInputKeyDown, onBlur: handleInputBlur })))));
|
|
17
355
|
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
|
|
2
|
+
import type { SelectProps } from 'antd';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
export type TPaginationAlign = 'start' | 'center' | 'end';
|
|
6
|
+
|
|
7
|
+
export type TPaginationItemRender = (
|
|
8
|
+
page,
|
|
9
|
+
type: 'page' | 'prev' | 'next',
|
|
10
|
+
originalElement
|
|
11
|
+
) => React.ReactNode;
|
|
12
|
+
|
|
13
|
+
export type TPaginationShowQuickJumper = boolean | { goButton: ReactNode };
|
|
14
|
+
|
|
15
|
+
export type TPaginationShowTotal = (total, range) => ReactNode;
|
|
16
|
+
|
|
17
|
+
export type TPaginationSimple = boolean | { readOnly?: boolean };
|
|
18
|
+
|
|
19
|
+
export type TPaginationSize = 'default' | 'small';
|
|
20
|
+
|
|
21
|
+
export type TPaginationOnChange = (page, pageSize) => ReactNode;
|
|
22
|
+
|
|
23
|
+
export type TPaginationOnShowSizeChange = (current, size) => ReactNode;
|
|
24
|
+
|
|
25
|
+
export interface IPaginationProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
26
|
+
/**
|
|
27
|
+
* Theme type
|
|
28
|
+
* @default dark
|
|
29
|
+
*/
|
|
30
|
+
theme?: 'light' | 'dark';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Alignment of the pagination component.
|
|
34
|
+
*/
|
|
35
|
+
align?: TPaginationAlign;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Current page number
|
|
39
|
+
*/
|
|
40
|
+
current?: number;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Default initial page number
|
|
44
|
+
* @default 1
|
|
45
|
+
*/
|
|
46
|
+
defaultCurrent?: number;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Default number of data items per page
|
|
50
|
+
* @default 10
|
|
51
|
+
*/
|
|
52
|
+
defaultPageSize?: number;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Disable pagination
|
|
56
|
+
*/
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether to hide pager on single page
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
hideOnSinglePage?: boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* To customize item's innerHTML
|
|
67
|
+
*/
|
|
68
|
+
itemRender?: TPaginationItemRender;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Number of data items per page
|
|
72
|
+
*/
|
|
73
|
+
pageSize?: number;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Specify the sizeChanger options
|
|
77
|
+
* @default
|
|
78
|
+
* [10, 20, 50, 100]
|
|
79
|
+
*/
|
|
80
|
+
pageSizeOptions?: string[] | number[];
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* If size is not specified, Pagination would resize according to the width of the window
|
|
84
|
+
*/
|
|
85
|
+
responsive?: boolean;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Show less page items
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
showLessItems?: boolean;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Determine whether you can jump to pages directly
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
showQuickJumper?: TPaginationShowQuickJumper;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Determine whether to show pageSize select, it will be true when total > 50
|
|
101
|
+
*/
|
|
102
|
+
showSizeChanger?: boolean | SelectProps;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Show page item's title
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
showTitle?: boolean;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* To display the total number and range
|
|
112
|
+
*/
|
|
113
|
+
showTotal?: TPaginationShowTotal;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Whether to use simple mode
|
|
117
|
+
*/
|
|
118
|
+
simple?: TPaginationSimple;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Specify the size of Pagination, can be set to small
|
|
122
|
+
* @default default
|
|
123
|
+
*/
|
|
124
|
+
size?: TPaginationSize;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Total number of data items
|
|
128
|
+
* @default 0
|
|
129
|
+
*/
|
|
130
|
+
total: number;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Called when the page number or pageSize is changed, and it takes the resulting page number and pageSize as its arguments
|
|
134
|
+
*/
|
|
135
|
+
onChange?: TPaginationOnChange;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Called when pageSize is changed
|
|
139
|
+
*/
|
|
140
|
+
onShowSizeChange?: TPaginationOnShowSizeChange;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Localization strings
|
|
144
|
+
*/
|
|
145
|
+
locale?: {
|
|
146
|
+
items_per_page?: string;
|
|
147
|
+
jump_to?: string;
|
|
148
|
+
jump_to_confirm?: string;
|
|
149
|
+
page?: string;
|
|
150
|
+
prev_page?: string;
|
|
151
|
+
next_page?: string;
|
|
152
|
+
prev_5?: string;
|
|
153
|
+
next_5?: string;
|
|
154
|
+
prev_3?: string;
|
|
155
|
+
next_3?: string;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Never use this prop. Akinon design system does not allow custom styles.
|
|
160
|
+
* @ignore
|
|
161
|
+
*/
|
|
162
|
+
style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
|
|
163
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/ui-pagination",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Pagination component for Akinon UI",
|
|
6
6
|
"type": "module",
|
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"antd": "5.
|
|
13
|
+
"antd": "5.22.6"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"clean-package": "2.2.0",
|
|
17
17
|
"copyfiles": "^2.4.1",
|
|
18
18
|
"rimraf": "^5.0.5",
|
|
19
|
-
"typescript": "
|
|
20
|
-
"@akinon/typescript-config": "0.
|
|
19
|
+
"typescript": "*",
|
|
20
|
+
"@akinon/typescript-config": "1.0.1",
|
|
21
|
+
"@akinon/ui-theme": "1.0.1"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
24
|
"react": ">=18",
|