@yamada-ui/pagination 0.2.6 → 0.2.7
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/{chunk-3KNXDAHV.mjs → chunk-QYITLVQJ.mjs} +16 -4
- package/dist/{chunk-3JXQPHJH.mjs → chunk-SGJ63NEB.mjs} +1 -1
- package/dist/{chunk-OQAHPAGR.mjs → chunk-TE22MBG6.mjs} +38 -8
- package/dist/index.js +52 -10
- package/dist/index.mjs +3 -3
- package/dist/pagination-item.mjs +2 -2
- package/dist/pagination.js +52 -10
- package/dist/pagination.mjs +3 -3
- package/dist/use-pagination.js +16 -4
- package/dist/use-pagination.mjs +1 -1
- package/package.json +6 -6
|
@@ -25,7 +25,10 @@ var usePagination = ({
|
|
|
25
25
|
onChange: rest.onChange
|
|
26
26
|
});
|
|
27
27
|
const onFirst = useCallback(() => setCurrentPage(1), [setCurrentPage]);
|
|
28
|
-
const onLast = useCallback(
|
|
28
|
+
const onLast = useCallback(
|
|
29
|
+
() => setCurrentPage(total),
|
|
30
|
+
[setCurrentPage, total]
|
|
31
|
+
);
|
|
29
32
|
const onPrev = useCallback(
|
|
30
33
|
() => setCurrentPage((prev) => prev === 1 ? prev : prev - 1),
|
|
31
34
|
[setCurrentPage]
|
|
@@ -34,13 +37,22 @@ var usePagination = ({
|
|
|
34
37
|
() => setCurrentPage((prev) => prev === total ? prev : prev + 1),
|
|
35
38
|
[setCurrentPage, total]
|
|
36
39
|
);
|
|
37
|
-
const onChange = useCallback(
|
|
40
|
+
const onChange = useCallback(
|
|
41
|
+
(page2) => setCurrentPage(page2),
|
|
42
|
+
[setCurrentPage]
|
|
43
|
+
);
|
|
38
44
|
const range = useMemo(() => {
|
|
39
45
|
const minimumTotal = computedSiblings * 2 + 3 + computedBoundaries * 2;
|
|
40
46
|
if (minimumTotal >= total)
|
|
41
47
|
return computedRange(1, total);
|
|
42
|
-
const prevSiblings = Math.max(
|
|
43
|
-
|
|
48
|
+
const prevSiblings = Math.max(
|
|
49
|
+
currentPage - computedSiblings,
|
|
50
|
+
computedBoundaries
|
|
51
|
+
);
|
|
52
|
+
const nextSiblings = Math.min(
|
|
53
|
+
currentPage + computedSiblings,
|
|
54
|
+
total - computedBoundaries
|
|
55
|
+
);
|
|
44
56
|
const prevDots = prevSiblings > computedBoundaries + 2;
|
|
45
57
|
const nextDots = nextSiblings < total - (computedBoundaries + 1);
|
|
46
58
|
if (!prevDots && nextDots) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PaginationItem
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SGJ63NEB.mjs";
|
|
4
4
|
import {
|
|
5
5
|
PaginationProvider,
|
|
6
6
|
usePagination
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QYITLVQJ.mjs";
|
|
8
8
|
|
|
9
9
|
// src/pagination.tsx
|
|
10
10
|
import {
|
|
@@ -35,7 +35,17 @@ var Pagination = forwardRef((props, ref) => {
|
|
|
35
35
|
} = omitThemeProps(mergedProps);
|
|
36
36
|
const computedWithControls = useValue(withControls);
|
|
37
37
|
const computedWithEdges = useValue(withEdges);
|
|
38
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
currentPage,
|
|
40
|
+
total,
|
|
41
|
+
isDisabled,
|
|
42
|
+
onFirst,
|
|
43
|
+
onLast,
|
|
44
|
+
onPrev,
|
|
45
|
+
onNext,
|
|
46
|
+
onChange,
|
|
47
|
+
range
|
|
48
|
+
} = usePagination(rest);
|
|
39
49
|
const children = useMemo(
|
|
40
50
|
() => range.map((page, key) => /* @__PURE__ */ jsx(
|
|
41
51
|
Component,
|
|
@@ -53,7 +63,11 @@ var Pagination = forwardRef((props, ref) => {
|
|
|
53
63
|
)),
|
|
54
64
|
[Component, currentPage, isDisabled, onChange, range, itemProps]
|
|
55
65
|
);
|
|
56
|
-
const css = {
|
|
66
|
+
const css = {
|
|
67
|
+
display: "flex",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
...styles.container
|
|
70
|
+
};
|
|
57
71
|
return /* @__PURE__ */ jsx(PaginationProvider, { value: styles, children: /* @__PURE__ */ jsxs(
|
|
58
72
|
ui.div,
|
|
59
73
|
{
|
|
@@ -72,7 +86,11 @@ var Pagination = forwardRef((props, ref) => {
|
|
|
72
86
|
isDisabled: isDisabled || currentPage === 1,
|
|
73
87
|
...edgeProps,
|
|
74
88
|
...edgeFirstProps,
|
|
75
|
-
onClick: handlerAll(
|
|
89
|
+
onClick: handlerAll(
|
|
90
|
+
edgeProps == null ? void 0 : edgeProps.onClick,
|
|
91
|
+
edgeFirstProps == null ? void 0 : edgeFirstProps.onClick,
|
|
92
|
+
onFirst
|
|
93
|
+
)
|
|
76
94
|
}
|
|
77
95
|
) : null,
|
|
78
96
|
computedWithControls ? /* @__PURE__ */ jsx(
|
|
@@ -83,7 +101,11 @@ var Pagination = forwardRef((props, ref) => {
|
|
|
83
101
|
isDisabled: isDisabled || currentPage === 1,
|
|
84
102
|
...controlProps,
|
|
85
103
|
...controlPrevProps,
|
|
86
|
-
onClick: handlerAll(
|
|
104
|
+
onClick: handlerAll(
|
|
105
|
+
controlProps == null ? void 0 : controlProps.onClick,
|
|
106
|
+
controlPrevProps == null ? void 0 : controlPrevProps.onClick,
|
|
107
|
+
onPrev
|
|
108
|
+
)
|
|
87
109
|
}
|
|
88
110
|
) : null,
|
|
89
111
|
children,
|
|
@@ -95,7 +117,11 @@ var Pagination = forwardRef((props, ref) => {
|
|
|
95
117
|
isDisabled: isDisabled || currentPage === total,
|
|
96
118
|
...controlProps,
|
|
97
119
|
...controlNextProps,
|
|
98
|
-
onClick: handlerAll(
|
|
120
|
+
onClick: handlerAll(
|
|
121
|
+
controlProps == null ? void 0 : controlProps.onClick,
|
|
122
|
+
controlNextProps == null ? void 0 : controlNextProps.onClick,
|
|
123
|
+
onNext
|
|
124
|
+
)
|
|
99
125
|
}
|
|
100
126
|
) : null,
|
|
101
127
|
computedWithEdges ? /* @__PURE__ */ jsx(
|
|
@@ -106,7 +132,11 @@ var Pagination = forwardRef((props, ref) => {
|
|
|
106
132
|
isDisabled: isDisabled || currentPage === total,
|
|
107
133
|
...edgeProps,
|
|
108
134
|
...edgeLastProps,
|
|
109
|
-
onClick: handlerAll(
|
|
135
|
+
onClick: handlerAll(
|
|
136
|
+
edgeProps == null ? void 0 : edgeProps.onClick,
|
|
137
|
+
edgeLastProps == null ? void 0 : edgeLastProps.onClick,
|
|
138
|
+
onLast
|
|
139
|
+
)
|
|
110
140
|
}
|
|
111
141
|
) : null
|
|
112
142
|
]
|
package/dist/index.js
CHANGED
|
@@ -111,7 +111,10 @@ var usePagination = ({
|
|
|
111
111
|
onChange: rest.onChange
|
|
112
112
|
});
|
|
113
113
|
const onFirst = (0, import_react.useCallback)(() => setCurrentPage(1), [setCurrentPage]);
|
|
114
|
-
const onLast = (0, import_react.useCallback)(
|
|
114
|
+
const onLast = (0, import_react.useCallback)(
|
|
115
|
+
() => setCurrentPage(total),
|
|
116
|
+
[setCurrentPage, total]
|
|
117
|
+
);
|
|
115
118
|
const onPrev = (0, import_react.useCallback)(
|
|
116
119
|
() => setCurrentPage((prev) => prev === 1 ? prev : prev - 1),
|
|
117
120
|
[setCurrentPage]
|
|
@@ -120,13 +123,22 @@ var usePagination = ({
|
|
|
120
123
|
() => setCurrentPage((prev) => prev === total ? prev : prev + 1),
|
|
121
124
|
[setCurrentPage, total]
|
|
122
125
|
);
|
|
123
|
-
const onChange = (0, import_react.useCallback)(
|
|
126
|
+
const onChange = (0, import_react.useCallback)(
|
|
127
|
+
(page2) => setCurrentPage(page2),
|
|
128
|
+
[setCurrentPage]
|
|
129
|
+
);
|
|
124
130
|
const range = (0, import_react.useMemo)(() => {
|
|
125
131
|
const minimumTotal = computedSiblings * 2 + 3 + computedBoundaries * 2;
|
|
126
132
|
if (minimumTotal >= total)
|
|
127
133
|
return computedRange(1, total);
|
|
128
|
-
const prevSiblings = Math.max(
|
|
129
|
-
|
|
134
|
+
const prevSiblings = Math.max(
|
|
135
|
+
currentPage - computedSiblings,
|
|
136
|
+
computedBoundaries
|
|
137
|
+
);
|
|
138
|
+
const nextSiblings = Math.min(
|
|
139
|
+
currentPage + computedSiblings,
|
|
140
|
+
total - computedBoundaries
|
|
141
|
+
);
|
|
130
142
|
const prevDots = prevSiblings > computedBoundaries + 2;
|
|
131
143
|
const nextDots = nextSiblings < total - (computedBoundaries + 1);
|
|
132
144
|
if (!prevDots && nextDots) {
|
|
@@ -229,7 +241,17 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
229
241
|
} = (0, import_core2.omitThemeProps)(mergedProps);
|
|
230
242
|
const computedWithControls = (0, import_use_value2.useValue)(withControls);
|
|
231
243
|
const computedWithEdges = (0, import_use_value2.useValue)(withEdges);
|
|
232
|
-
const {
|
|
244
|
+
const {
|
|
245
|
+
currentPage,
|
|
246
|
+
total,
|
|
247
|
+
isDisabled,
|
|
248
|
+
onFirst,
|
|
249
|
+
onLast,
|
|
250
|
+
onPrev,
|
|
251
|
+
onNext,
|
|
252
|
+
onChange,
|
|
253
|
+
range
|
|
254
|
+
} = usePagination(rest);
|
|
233
255
|
const children = (0, import_react2.useMemo)(
|
|
234
256
|
() => range.map((page, key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
235
257
|
Component,
|
|
@@ -247,7 +269,11 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
247
269
|
)),
|
|
248
270
|
[Component, currentPage, isDisabled, onChange, range, itemProps]
|
|
249
271
|
);
|
|
250
|
-
const css = {
|
|
272
|
+
const css = {
|
|
273
|
+
display: "flex",
|
|
274
|
+
alignItems: "center",
|
|
275
|
+
...styles.container
|
|
276
|
+
};
|
|
251
277
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PaginationProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
252
278
|
import_core2.ui.div,
|
|
253
279
|
{
|
|
@@ -266,7 +292,11 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
266
292
|
isDisabled: isDisabled || currentPage === 1,
|
|
267
293
|
...edgeProps,
|
|
268
294
|
...edgeFirstProps,
|
|
269
|
-
onClick: (0, import_utils3.handlerAll)(
|
|
295
|
+
onClick: (0, import_utils3.handlerAll)(
|
|
296
|
+
edgeProps == null ? void 0 : edgeProps.onClick,
|
|
297
|
+
edgeFirstProps == null ? void 0 : edgeFirstProps.onClick,
|
|
298
|
+
onFirst
|
|
299
|
+
)
|
|
270
300
|
}
|
|
271
301
|
) : null,
|
|
272
302
|
computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -277,7 +307,11 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
277
307
|
isDisabled: isDisabled || currentPage === 1,
|
|
278
308
|
...controlProps,
|
|
279
309
|
...controlPrevProps,
|
|
280
|
-
onClick: (0, import_utils3.handlerAll)(
|
|
310
|
+
onClick: (0, import_utils3.handlerAll)(
|
|
311
|
+
controlProps == null ? void 0 : controlProps.onClick,
|
|
312
|
+
controlPrevProps == null ? void 0 : controlPrevProps.onClick,
|
|
313
|
+
onPrev
|
|
314
|
+
)
|
|
281
315
|
}
|
|
282
316
|
) : null,
|
|
283
317
|
children,
|
|
@@ -289,7 +323,11 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
289
323
|
isDisabled: isDisabled || currentPage === total,
|
|
290
324
|
...controlProps,
|
|
291
325
|
...controlNextProps,
|
|
292
|
-
onClick: (0, import_utils3.handlerAll)(
|
|
326
|
+
onClick: (0, import_utils3.handlerAll)(
|
|
327
|
+
controlProps == null ? void 0 : controlProps.onClick,
|
|
328
|
+
controlNextProps == null ? void 0 : controlNextProps.onClick,
|
|
329
|
+
onNext
|
|
330
|
+
)
|
|
293
331
|
}
|
|
294
332
|
) : null,
|
|
295
333
|
computedWithEdges ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -300,7 +338,11 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
300
338
|
isDisabled: isDisabled || currentPage === total,
|
|
301
339
|
...edgeProps,
|
|
302
340
|
...edgeLastProps,
|
|
303
|
-
onClick: (0, import_utils3.handlerAll)(
|
|
341
|
+
onClick: (0, import_utils3.handlerAll)(
|
|
342
|
+
edgeProps == null ? void 0 : edgeProps.onClick,
|
|
343
|
+
edgeLastProps == null ? void 0 : edgeLastProps.onClick,
|
|
344
|
+
onLast
|
|
345
|
+
)
|
|
304
346
|
}
|
|
305
347
|
) : null
|
|
306
348
|
]
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Pagination
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-TE22MBG6.mjs";
|
|
4
|
+
import "./chunk-SGJ63NEB.mjs";
|
|
5
5
|
import "./chunk-IXTXZCRI.mjs";
|
|
6
6
|
import {
|
|
7
7
|
usePagination
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QYITLVQJ.mjs";
|
|
9
9
|
export {
|
|
10
10
|
Pagination,
|
|
11
11
|
usePagination
|
package/dist/pagination-item.mjs
CHANGED
package/dist/pagination.js
CHANGED
|
@@ -108,7 +108,10 @@ var usePagination = ({
|
|
|
108
108
|
onChange: rest.onChange
|
|
109
109
|
});
|
|
110
110
|
const onFirst = (0, import_react.useCallback)(() => setCurrentPage(1), [setCurrentPage]);
|
|
111
|
-
const onLast = (0, import_react.useCallback)(
|
|
111
|
+
const onLast = (0, import_react.useCallback)(
|
|
112
|
+
() => setCurrentPage(total),
|
|
113
|
+
[setCurrentPage, total]
|
|
114
|
+
);
|
|
112
115
|
const onPrev = (0, import_react.useCallback)(
|
|
113
116
|
() => setCurrentPage((prev) => prev === 1 ? prev : prev - 1),
|
|
114
117
|
[setCurrentPage]
|
|
@@ -117,13 +120,22 @@ var usePagination = ({
|
|
|
117
120
|
() => setCurrentPage((prev) => prev === total ? prev : prev + 1),
|
|
118
121
|
[setCurrentPage, total]
|
|
119
122
|
);
|
|
120
|
-
const onChange = (0, import_react.useCallback)(
|
|
123
|
+
const onChange = (0, import_react.useCallback)(
|
|
124
|
+
(page2) => setCurrentPage(page2),
|
|
125
|
+
[setCurrentPage]
|
|
126
|
+
);
|
|
121
127
|
const range = (0, import_react.useMemo)(() => {
|
|
122
128
|
const minimumTotal = computedSiblings * 2 + 3 + computedBoundaries * 2;
|
|
123
129
|
if (minimumTotal >= total)
|
|
124
130
|
return computedRange(1, total);
|
|
125
|
-
const prevSiblings = Math.max(
|
|
126
|
-
|
|
131
|
+
const prevSiblings = Math.max(
|
|
132
|
+
currentPage - computedSiblings,
|
|
133
|
+
computedBoundaries
|
|
134
|
+
);
|
|
135
|
+
const nextSiblings = Math.min(
|
|
136
|
+
currentPage + computedSiblings,
|
|
137
|
+
total - computedBoundaries
|
|
138
|
+
);
|
|
127
139
|
const prevDots = prevSiblings > computedBoundaries + 2;
|
|
128
140
|
const nextDots = nextSiblings < total - (computedBoundaries + 1);
|
|
129
141
|
if (!prevDots && nextDots) {
|
|
@@ -226,7 +238,17 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
226
238
|
} = (0, import_core2.omitThemeProps)(mergedProps);
|
|
227
239
|
const computedWithControls = (0, import_use_value2.useValue)(withControls);
|
|
228
240
|
const computedWithEdges = (0, import_use_value2.useValue)(withEdges);
|
|
229
|
-
const {
|
|
241
|
+
const {
|
|
242
|
+
currentPage,
|
|
243
|
+
total,
|
|
244
|
+
isDisabled,
|
|
245
|
+
onFirst,
|
|
246
|
+
onLast,
|
|
247
|
+
onPrev,
|
|
248
|
+
onNext,
|
|
249
|
+
onChange,
|
|
250
|
+
range
|
|
251
|
+
} = usePagination(rest);
|
|
230
252
|
const children = (0, import_react2.useMemo)(
|
|
231
253
|
() => range.map((page, key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
232
254
|
Component,
|
|
@@ -244,7 +266,11 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
244
266
|
)),
|
|
245
267
|
[Component, currentPage, isDisabled, onChange, range, itemProps]
|
|
246
268
|
);
|
|
247
|
-
const css = {
|
|
269
|
+
const css = {
|
|
270
|
+
display: "flex",
|
|
271
|
+
alignItems: "center",
|
|
272
|
+
...styles.container
|
|
273
|
+
};
|
|
248
274
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PaginationProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
249
275
|
import_core2.ui.div,
|
|
250
276
|
{
|
|
@@ -263,7 +289,11 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
263
289
|
isDisabled: isDisabled || currentPage === 1,
|
|
264
290
|
...edgeProps,
|
|
265
291
|
...edgeFirstProps,
|
|
266
|
-
onClick: (0, import_utils3.handlerAll)(
|
|
292
|
+
onClick: (0, import_utils3.handlerAll)(
|
|
293
|
+
edgeProps == null ? void 0 : edgeProps.onClick,
|
|
294
|
+
edgeFirstProps == null ? void 0 : edgeFirstProps.onClick,
|
|
295
|
+
onFirst
|
|
296
|
+
)
|
|
267
297
|
}
|
|
268
298
|
) : null,
|
|
269
299
|
computedWithControls ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -274,7 +304,11 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
274
304
|
isDisabled: isDisabled || currentPage === 1,
|
|
275
305
|
...controlProps,
|
|
276
306
|
...controlPrevProps,
|
|
277
|
-
onClick: (0, import_utils3.handlerAll)(
|
|
307
|
+
onClick: (0, import_utils3.handlerAll)(
|
|
308
|
+
controlProps == null ? void 0 : controlProps.onClick,
|
|
309
|
+
controlPrevProps == null ? void 0 : controlPrevProps.onClick,
|
|
310
|
+
onPrev
|
|
311
|
+
)
|
|
278
312
|
}
|
|
279
313
|
) : null,
|
|
280
314
|
children,
|
|
@@ -286,7 +320,11 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
286
320
|
isDisabled: isDisabled || currentPage === total,
|
|
287
321
|
...controlProps,
|
|
288
322
|
...controlNextProps,
|
|
289
|
-
onClick: (0, import_utils3.handlerAll)(
|
|
323
|
+
onClick: (0, import_utils3.handlerAll)(
|
|
324
|
+
controlProps == null ? void 0 : controlProps.onClick,
|
|
325
|
+
controlNextProps == null ? void 0 : controlNextProps.onClick,
|
|
326
|
+
onNext
|
|
327
|
+
)
|
|
290
328
|
}
|
|
291
329
|
) : null,
|
|
292
330
|
computedWithEdges ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -297,7 +335,11 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
|
297
335
|
isDisabled: isDisabled || currentPage === total,
|
|
298
336
|
...edgeProps,
|
|
299
337
|
...edgeLastProps,
|
|
300
|
-
onClick: (0, import_utils3.handlerAll)(
|
|
338
|
+
onClick: (0, import_utils3.handlerAll)(
|
|
339
|
+
edgeProps == null ? void 0 : edgeProps.onClick,
|
|
340
|
+
edgeLastProps == null ? void 0 : edgeLastProps.onClick,
|
|
341
|
+
onLast
|
|
342
|
+
)
|
|
301
343
|
}
|
|
302
344
|
) : null
|
|
303
345
|
]
|
package/dist/pagination.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Pagination
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-TE22MBG6.mjs";
|
|
4
|
+
import "./chunk-SGJ63NEB.mjs";
|
|
5
5
|
import "./chunk-IXTXZCRI.mjs";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-QYITLVQJ.mjs";
|
|
7
7
|
export {
|
|
8
8
|
Pagination
|
|
9
9
|
};
|
package/dist/use-pagination.js
CHANGED
|
@@ -52,7 +52,10 @@ var usePagination = ({
|
|
|
52
52
|
onChange: rest.onChange
|
|
53
53
|
});
|
|
54
54
|
const onFirst = (0, import_react.useCallback)(() => setCurrentPage(1), [setCurrentPage]);
|
|
55
|
-
const onLast = (0, import_react.useCallback)(
|
|
55
|
+
const onLast = (0, import_react.useCallback)(
|
|
56
|
+
() => setCurrentPage(total),
|
|
57
|
+
[setCurrentPage, total]
|
|
58
|
+
);
|
|
56
59
|
const onPrev = (0, import_react.useCallback)(
|
|
57
60
|
() => setCurrentPage((prev) => prev === 1 ? prev : prev - 1),
|
|
58
61
|
[setCurrentPage]
|
|
@@ -61,13 +64,22 @@ var usePagination = ({
|
|
|
61
64
|
() => setCurrentPage((prev) => prev === total ? prev : prev + 1),
|
|
62
65
|
[setCurrentPage, total]
|
|
63
66
|
);
|
|
64
|
-
const onChange = (0, import_react.useCallback)(
|
|
67
|
+
const onChange = (0, import_react.useCallback)(
|
|
68
|
+
(page2) => setCurrentPage(page2),
|
|
69
|
+
[setCurrentPage]
|
|
70
|
+
);
|
|
65
71
|
const range = (0, import_react.useMemo)(() => {
|
|
66
72
|
const minimumTotal = computedSiblings * 2 + 3 + computedBoundaries * 2;
|
|
67
73
|
if (minimumTotal >= total)
|
|
68
74
|
return computedRange(1, total);
|
|
69
|
-
const prevSiblings = Math.max(
|
|
70
|
-
|
|
75
|
+
const prevSiblings = Math.max(
|
|
76
|
+
currentPage - computedSiblings,
|
|
77
|
+
computedBoundaries
|
|
78
|
+
);
|
|
79
|
+
const nextSiblings = Math.min(
|
|
80
|
+
currentPage + computedSiblings,
|
|
81
|
+
total - computedBoundaries
|
|
82
|
+
);
|
|
71
83
|
const prevDots = prevSiblings > computedBoundaries + 2;
|
|
72
84
|
const nextDots = nextSiblings < total - (computedBoundaries + 1);
|
|
73
85
|
if (!prevDots && nextDots) {
|
package/dist/use-pagination.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamada-ui/pagination",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Yamada UI pagination component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yamada",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"url": "https://github.com/hirotomoyamada/yamada-ui/issues"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@yamada-ui/core": "0.5.
|
|
39
|
-
"@yamada-ui/utils": "0.1.
|
|
40
|
-
"@yamada-ui/icon": "0.2.
|
|
41
|
-
"@yamada-ui/use-controllable-state": "0.1.
|
|
42
|
-
"@yamada-ui/use-value": "0.1.
|
|
38
|
+
"@yamada-ui/core": "0.5.2",
|
|
39
|
+
"@yamada-ui/utils": "0.1.4",
|
|
40
|
+
"@yamada-ui/icon": "0.2.7",
|
|
41
|
+
"@yamada-ui/use-controllable-state": "0.1.5",
|
|
42
|
+
"@yamada-ui/use-value": "0.1.19"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"react": "^18.0.0",
|