@sytechui/pagination 2.2.27
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/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/chunk-5S65XA6Q.mjs +82 -0
- package/dist/chunk-BIG4ST5P.mjs +217 -0
- package/dist/chunk-BNRXGTRW.mjs +18 -0
- package/dist/chunk-MA7OMMHX.mjs +18 -0
- package/dist/chunk-RL6XUYZP.mjs +235 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +589 -0
- package/dist/index.mjs +27 -0
- package/dist/pagination-cursor.d.mts +12 -0
- package/dist/pagination-cursor.d.ts +12 -0
- package/dist/pagination-cursor.js +37 -0
- package/dist/pagination-cursor.mjs +7 -0
- package/dist/pagination-item.d.mts +11 -0
- package/dist/pagination-item.d.ts +11 -0
- package/dist/pagination-item.js +113 -0
- package/dist/pagination-item.mjs +8 -0
- package/dist/pagination.d.mts +13 -0
- package/dist/pagination.d.ts +13 -0
- package/dist/pagination.js +570 -0
- package/dist/pagination.mjs +11 -0
- package/dist/use-pagination-item.d.mts +53 -0
- package/dist/use-pagination-item.d.ts +53 -0
- package/dist/use-pagination-item.js +105 -0
- package/dist/use-pagination-item.mjs +7 -0
- package/dist/use-pagination.d.mts +374 -0
- package/dist/use-pagination.d.ts +374 -0
- package/dist/use-pagination.js +269 -0
- package/dist/use-pagination.mjs +9 -0
- package/package.json +63 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import * as _sytechui_system from '@sytechui/system';
|
|
3
|
+
import { HTMLHeroUIProps, PropGetter } from '@sytechui/system';
|
|
4
|
+
import { SlotsToClasses, PaginationSlots, PaginationVariantProps } from '@sytechui/theme';
|
|
5
|
+
import { Ref, Key, ReactNode } from 'react';
|
|
6
|
+
import { PaginationItemValue, UsePaginationProps as UsePaginationProps$1 } from '@sytechui/use-pagination';
|
|
7
|
+
import { PressEvent } from '@react-types/shared';
|
|
8
|
+
|
|
9
|
+
type PaginationItemRenderProps = {
|
|
10
|
+
/**
|
|
11
|
+
* The pagination item ref.
|
|
12
|
+
*/
|
|
13
|
+
ref?: Ref<any>;
|
|
14
|
+
/**
|
|
15
|
+
* React key.
|
|
16
|
+
*/
|
|
17
|
+
key?: Key;
|
|
18
|
+
/**
|
|
19
|
+
* The pagination item value.
|
|
20
|
+
*/
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* The pagination item value.
|
|
24
|
+
*/
|
|
25
|
+
value: PaginationItemValue;
|
|
26
|
+
/**
|
|
27
|
+
* The pagination item index.
|
|
28
|
+
*/
|
|
29
|
+
index: number;
|
|
30
|
+
/**
|
|
31
|
+
* Calculated pagination item position. This includes the dots.
|
|
32
|
+
*/
|
|
33
|
+
page: number;
|
|
34
|
+
/**
|
|
35
|
+
* The pagination total number of pages.
|
|
36
|
+
*/
|
|
37
|
+
total: number;
|
|
38
|
+
/**
|
|
39
|
+
* The active page number.
|
|
40
|
+
*/
|
|
41
|
+
activePage: number;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the pagination item is active.
|
|
44
|
+
*/
|
|
45
|
+
isActive: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the item is before the active page.
|
|
48
|
+
*/
|
|
49
|
+
isBefore: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the pagination item is the first item in the pagination.
|
|
52
|
+
*/
|
|
53
|
+
isFirst: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the pagination item is the last item in the pagination.
|
|
56
|
+
*/
|
|
57
|
+
isLast: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the pagination item is the next item in the pagination.
|
|
60
|
+
*/
|
|
61
|
+
isNext: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Number of pages that are added or subtracted on the '...' button.
|
|
64
|
+
* @default 5
|
|
65
|
+
*/
|
|
66
|
+
dotsJump: number;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the pagination item is the previous item in the pagination.
|
|
69
|
+
*/
|
|
70
|
+
isPrevious: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The pagination item className.
|
|
73
|
+
*/
|
|
74
|
+
className: string;
|
|
75
|
+
/**
|
|
76
|
+
* Callback to go to the next page.
|
|
77
|
+
*/
|
|
78
|
+
onNext: () => void;
|
|
79
|
+
/**
|
|
80
|
+
* Callback to go to the previous page.
|
|
81
|
+
*/
|
|
82
|
+
onPrevious: () => void;
|
|
83
|
+
/**
|
|
84
|
+
* Callback to go to the page.
|
|
85
|
+
*/
|
|
86
|
+
setPage: (page: number) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Callback fired when the item is clicked.
|
|
89
|
+
* @param e PressEvent
|
|
90
|
+
*/
|
|
91
|
+
onPress?: (e: PressEvent) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Function to get the aria-label of the item.
|
|
94
|
+
*/
|
|
95
|
+
getAriaLabel?: (page?: PaginationItemValue) => string | undefined;
|
|
96
|
+
};
|
|
97
|
+
interface Props extends Omit<HTMLHeroUIProps<"nav">, "onChange"> {
|
|
98
|
+
/**
|
|
99
|
+
* Ref to the DOM node.
|
|
100
|
+
*/
|
|
101
|
+
ref?: Ref<HTMLElement>;
|
|
102
|
+
/**
|
|
103
|
+
* Number of pages that are added or subtracted on the '...' button.
|
|
104
|
+
* @default 5
|
|
105
|
+
*/
|
|
106
|
+
dotsJump?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Non disable next/previous controls
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
loop?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Whether the pagination should display controls (left/right arrows).
|
|
114
|
+
* @default true
|
|
115
|
+
*/
|
|
116
|
+
showControls?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Render a custom pagination item.
|
|
119
|
+
* @param props Pagination item props
|
|
120
|
+
* @returns ReactNode
|
|
121
|
+
*/
|
|
122
|
+
renderItem?: (props: PaginationItemRenderProps) => ReactNode;
|
|
123
|
+
/**
|
|
124
|
+
* Function to get the aria-label of the item. If not provided, pagination will use the default one.
|
|
125
|
+
*/
|
|
126
|
+
getItemAriaLabel?: (page?: string | PaginationItemValue) => string;
|
|
127
|
+
/**
|
|
128
|
+
* Classname or List of classes to change the classNames of the element.
|
|
129
|
+
* if `className` is passed, it will be added to the base slot.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* <Pagination classNames={{
|
|
134
|
+
* base:"base-classes",
|
|
135
|
+
* prev: "prev-classes", // prev button classes
|
|
136
|
+
* item: "item-classes",
|
|
137
|
+
* next: "next-classes", // next button classes
|
|
138
|
+
* cursor: "cursor-classes", // this is the one that moves when an item is selected
|
|
139
|
+
* forwardIcon: "forward-icon-classes", // forward icon
|
|
140
|
+
* ellipsis: "ellipsis-classes", // ellipsis icon
|
|
141
|
+
* chevronNext: "chevron-next-classes", // chevron next icon
|
|
142
|
+
* }} />
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
classNames?: SlotsToClasses<PaginationSlots>;
|
|
146
|
+
}
|
|
147
|
+
type UsePaginationProps = Props & UsePaginationProps$1 & PaginationVariantProps;
|
|
148
|
+
declare const CURSOR_TRANSITION_TIMEOUT = 300;
|
|
149
|
+
declare function usePagination(originalProps: UsePaginationProps): {
|
|
150
|
+
Component: _sytechui_system.As<any>;
|
|
151
|
+
showControls: boolean;
|
|
152
|
+
dotsJump: number;
|
|
153
|
+
slots: {
|
|
154
|
+
base: (slotProps?: ({
|
|
155
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
156
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
157
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
158
|
+
isDisabled?: boolean | undefined;
|
|
159
|
+
disableAnimation?: boolean | undefined;
|
|
160
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
161
|
+
isCompact?: boolean | undefined;
|
|
162
|
+
showShadow?: boolean | undefined;
|
|
163
|
+
disableCursorAnimation?: boolean | undefined;
|
|
164
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
165
|
+
wrapper: (slotProps?: ({
|
|
166
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
167
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
168
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
169
|
+
isDisabled?: boolean | undefined;
|
|
170
|
+
disableAnimation?: boolean | undefined;
|
|
171
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
172
|
+
isCompact?: boolean | undefined;
|
|
173
|
+
showShadow?: boolean | undefined;
|
|
174
|
+
disableCursorAnimation?: boolean | undefined;
|
|
175
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
176
|
+
item: (slotProps?: ({
|
|
177
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
178
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
179
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
180
|
+
isDisabled?: boolean | undefined;
|
|
181
|
+
disableAnimation?: boolean | undefined;
|
|
182
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
183
|
+
isCompact?: boolean | undefined;
|
|
184
|
+
showShadow?: boolean | undefined;
|
|
185
|
+
disableCursorAnimation?: boolean | undefined;
|
|
186
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
187
|
+
prev: (slotProps?: ({
|
|
188
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
189
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
190
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
191
|
+
isDisabled?: boolean | undefined;
|
|
192
|
+
disableAnimation?: boolean | undefined;
|
|
193
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
194
|
+
isCompact?: boolean | undefined;
|
|
195
|
+
showShadow?: boolean | undefined;
|
|
196
|
+
disableCursorAnimation?: boolean | undefined;
|
|
197
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
198
|
+
next: (slotProps?: ({
|
|
199
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
200
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
201
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
202
|
+
isDisabled?: boolean | undefined;
|
|
203
|
+
disableAnimation?: boolean | undefined;
|
|
204
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
205
|
+
isCompact?: boolean | undefined;
|
|
206
|
+
showShadow?: boolean | undefined;
|
|
207
|
+
disableCursorAnimation?: boolean | undefined;
|
|
208
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
209
|
+
cursor: (slotProps?: ({
|
|
210
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
211
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
212
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
213
|
+
isDisabled?: boolean | undefined;
|
|
214
|
+
disableAnimation?: boolean | undefined;
|
|
215
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
216
|
+
isCompact?: boolean | undefined;
|
|
217
|
+
showShadow?: boolean | undefined;
|
|
218
|
+
disableCursorAnimation?: boolean | undefined;
|
|
219
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
220
|
+
forwardIcon: (slotProps?: ({
|
|
221
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
222
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
223
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
224
|
+
isDisabled?: boolean | undefined;
|
|
225
|
+
disableAnimation?: boolean | undefined;
|
|
226
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
227
|
+
isCompact?: boolean | undefined;
|
|
228
|
+
showShadow?: boolean | undefined;
|
|
229
|
+
disableCursorAnimation?: boolean | undefined;
|
|
230
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
231
|
+
ellipsis: (slotProps?: ({
|
|
232
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
233
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
234
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
235
|
+
isDisabled?: boolean | undefined;
|
|
236
|
+
disableAnimation?: boolean | undefined;
|
|
237
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
238
|
+
isCompact?: boolean | undefined;
|
|
239
|
+
showShadow?: boolean | undefined;
|
|
240
|
+
disableCursorAnimation?: boolean | undefined;
|
|
241
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
242
|
+
chevronNext: (slotProps?: ({
|
|
243
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
244
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
245
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
246
|
+
isDisabled?: boolean | undefined;
|
|
247
|
+
disableAnimation?: boolean | undefined;
|
|
248
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
249
|
+
isCompact?: boolean | undefined;
|
|
250
|
+
showShadow?: boolean | undefined;
|
|
251
|
+
disableCursorAnimation?: boolean | undefined;
|
|
252
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
253
|
+
} & {
|
|
254
|
+
base: (slotProps?: ({
|
|
255
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
256
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
257
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
258
|
+
isDisabled?: boolean | undefined;
|
|
259
|
+
disableAnimation?: boolean | undefined;
|
|
260
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
261
|
+
isCompact?: boolean | undefined;
|
|
262
|
+
showShadow?: boolean | undefined;
|
|
263
|
+
disableCursorAnimation?: boolean | undefined;
|
|
264
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
265
|
+
wrapper: (slotProps?: ({
|
|
266
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
267
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
268
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
269
|
+
isDisabled?: boolean | undefined;
|
|
270
|
+
disableAnimation?: boolean | undefined;
|
|
271
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
272
|
+
isCompact?: boolean | undefined;
|
|
273
|
+
showShadow?: boolean | undefined;
|
|
274
|
+
disableCursorAnimation?: boolean | undefined;
|
|
275
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
276
|
+
item: (slotProps?: ({
|
|
277
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
278
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
279
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
280
|
+
isDisabled?: boolean | undefined;
|
|
281
|
+
disableAnimation?: boolean | undefined;
|
|
282
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
283
|
+
isCompact?: boolean | undefined;
|
|
284
|
+
showShadow?: boolean | undefined;
|
|
285
|
+
disableCursorAnimation?: boolean | undefined;
|
|
286
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
287
|
+
prev: (slotProps?: ({
|
|
288
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
289
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
290
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
291
|
+
isDisabled?: boolean | undefined;
|
|
292
|
+
disableAnimation?: boolean | undefined;
|
|
293
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
294
|
+
isCompact?: boolean | undefined;
|
|
295
|
+
showShadow?: boolean | undefined;
|
|
296
|
+
disableCursorAnimation?: boolean | undefined;
|
|
297
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
298
|
+
next: (slotProps?: ({
|
|
299
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
300
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
301
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
302
|
+
isDisabled?: boolean | undefined;
|
|
303
|
+
disableAnimation?: boolean | undefined;
|
|
304
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
305
|
+
isCompact?: boolean | undefined;
|
|
306
|
+
showShadow?: boolean | undefined;
|
|
307
|
+
disableCursorAnimation?: boolean | undefined;
|
|
308
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
309
|
+
cursor: (slotProps?: ({
|
|
310
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
311
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
312
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
313
|
+
isDisabled?: boolean | undefined;
|
|
314
|
+
disableAnimation?: boolean | undefined;
|
|
315
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
316
|
+
isCompact?: boolean | undefined;
|
|
317
|
+
showShadow?: boolean | undefined;
|
|
318
|
+
disableCursorAnimation?: boolean | undefined;
|
|
319
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
320
|
+
forwardIcon: (slotProps?: ({
|
|
321
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
322
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
323
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
324
|
+
isDisabled?: boolean | undefined;
|
|
325
|
+
disableAnimation?: boolean | undefined;
|
|
326
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
327
|
+
isCompact?: boolean | undefined;
|
|
328
|
+
showShadow?: boolean | undefined;
|
|
329
|
+
disableCursorAnimation?: boolean | undefined;
|
|
330
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
331
|
+
ellipsis: (slotProps?: ({
|
|
332
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
333
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
334
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
335
|
+
isDisabled?: boolean | undefined;
|
|
336
|
+
disableAnimation?: boolean | undefined;
|
|
337
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
338
|
+
isCompact?: boolean | undefined;
|
|
339
|
+
showShadow?: boolean | undefined;
|
|
340
|
+
disableCursorAnimation?: boolean | undefined;
|
|
341
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
342
|
+
chevronNext: (slotProps?: ({
|
|
343
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
344
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
345
|
+
radius?: "none" | "md" | "full" | "sm" | "lg" | undefined;
|
|
346
|
+
isDisabled?: boolean | undefined;
|
|
347
|
+
disableAnimation?: boolean | undefined;
|
|
348
|
+
variant?: "flat" | "bordered" | "faded" | "light" | undefined;
|
|
349
|
+
isCompact?: boolean | undefined;
|
|
350
|
+
showShadow?: boolean | undefined;
|
|
351
|
+
disableCursorAnimation?: boolean | undefined;
|
|
352
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
353
|
+
} & {};
|
|
354
|
+
classNames: SlotsToClasses<"prev" | "next" | "base" | "cursor" | "wrapper" | "ellipsis" | "chevronNext" | "item" | "forwardIcon"> | undefined;
|
|
355
|
+
loop: boolean;
|
|
356
|
+
total: number;
|
|
357
|
+
range: PaginationItemValue[];
|
|
358
|
+
activePage: number;
|
|
359
|
+
getItemRef: (node: HTMLElement | null, value: number) => void;
|
|
360
|
+
disableAnimation: boolean;
|
|
361
|
+
disableCursorAnimation: boolean;
|
|
362
|
+
setPage: (pageNumber: number) => void;
|
|
363
|
+
onPrevious: () => void;
|
|
364
|
+
onNext: () => void;
|
|
365
|
+
renderItem: ((props: PaginationItemRenderProps) => ReactNode) | undefined;
|
|
366
|
+
getBaseProps: PropGetter;
|
|
367
|
+
getWrapperProps: PropGetter;
|
|
368
|
+
getItemProps: PropGetter;
|
|
369
|
+
getCursorProps: PropGetter;
|
|
370
|
+
getItemAriaLabel: (page?: string | PaginationItemValue) => string | undefined;
|
|
371
|
+
};
|
|
372
|
+
type UsePaginationReturn = ReturnType<typeof usePagination>;
|
|
373
|
+
|
|
374
|
+
export { CURSOR_TRANSITION_TIMEOUT, type PaginationItemRenderProps, type UsePaginationProps, type UsePaginationReturn, usePagination };
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/use-pagination.ts
|
|
32
|
+
var use_pagination_exports = {};
|
|
33
|
+
__export(use_pagination_exports, {
|
|
34
|
+
CURSOR_TRANSITION_TIMEOUT: () => CURSOR_TRANSITION_TIMEOUT,
|
|
35
|
+
usePagination: () => usePagination
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(use_pagination_exports);
|
|
38
|
+
var import_shared_utils = require("@sytechui/shared-utils");
|
|
39
|
+
var import_use_pagination = require("@sytechui/use-pagination");
|
|
40
|
+
var import_react = require("react");
|
|
41
|
+
var import_system = require("@sytechui/system");
|
|
42
|
+
var import_use_pagination2 = require("@sytechui/use-pagination");
|
|
43
|
+
var import_scroll_into_view_if_needed = __toESM(require("scroll-into-view-if-needed"));
|
|
44
|
+
var import_theme = require("@sytechui/theme");
|
|
45
|
+
var import_react_utils = require("@sytechui/react-utils");
|
|
46
|
+
var import_shared_utils2 = require("@sytechui/shared-utils");
|
|
47
|
+
var import_use_intersection_observer = require("@sytechui/use-intersection-observer");
|
|
48
|
+
var CURSOR_TRANSITION_TIMEOUT = 300;
|
|
49
|
+
function usePagination(originalProps) {
|
|
50
|
+
var _a, _b, _c, _d;
|
|
51
|
+
const globalContext = (0, import_system.useProviderContext)();
|
|
52
|
+
const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.pagination.variantKeys);
|
|
53
|
+
const {
|
|
54
|
+
as,
|
|
55
|
+
ref,
|
|
56
|
+
classNames,
|
|
57
|
+
dotsJump = 5,
|
|
58
|
+
loop = false,
|
|
59
|
+
showControls = false,
|
|
60
|
+
total = 1,
|
|
61
|
+
initialPage = 1,
|
|
62
|
+
page,
|
|
63
|
+
siblings,
|
|
64
|
+
boundaries,
|
|
65
|
+
onChange,
|
|
66
|
+
className,
|
|
67
|
+
renderItem,
|
|
68
|
+
getItemAriaLabel: getItemAriaLabelProp,
|
|
69
|
+
...otherProps
|
|
70
|
+
} = props;
|
|
71
|
+
const Component = as || "nav";
|
|
72
|
+
const domRef = (0, import_react_utils.useDOMRef)(ref);
|
|
73
|
+
const cursorRef = (0, import_react.useRef)(null);
|
|
74
|
+
const itemsRef = (0, import_react.useRef)();
|
|
75
|
+
const cursorTimer = (0, import_react.useRef)();
|
|
76
|
+
const disableAnimation = (_b = (_a = originalProps == null ? void 0 : originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
|
|
77
|
+
const disableCursorAnimation = (_d = (_c = originalProps == null ? void 0 : originalProps.disableCursorAnimation) != null ? _c : disableAnimation) != null ? _d : false;
|
|
78
|
+
function getItemsRefMap() {
|
|
79
|
+
if (!itemsRef.current) {
|
|
80
|
+
itemsRef.current = /* @__PURE__ */ new Map();
|
|
81
|
+
}
|
|
82
|
+
return itemsRef.current;
|
|
83
|
+
}
|
|
84
|
+
function getItemRef(node, value) {
|
|
85
|
+
const map = getItemsRefMap();
|
|
86
|
+
if (node) {
|
|
87
|
+
map.set(value, node);
|
|
88
|
+
} else {
|
|
89
|
+
map.delete(value);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function scrollTo(value, skipAnimation) {
|
|
93
|
+
const map = getItemsRefMap();
|
|
94
|
+
const node = map.get(value);
|
|
95
|
+
if (!node || !cursorRef.current) return;
|
|
96
|
+
cursorTimer.current && clearTimeout(cursorTimer.current);
|
|
97
|
+
(0, import_scroll_into_view_if_needed.default)(node, {
|
|
98
|
+
scrollMode: "always",
|
|
99
|
+
behavior: "smooth",
|
|
100
|
+
block: "start",
|
|
101
|
+
inline: "start",
|
|
102
|
+
boundary: domRef.current
|
|
103
|
+
});
|
|
104
|
+
const { offsetLeft } = node;
|
|
105
|
+
if (skipAnimation) {
|
|
106
|
+
cursorRef.current.setAttribute("data-moving", "false");
|
|
107
|
+
cursorRef.current.style.transform = `translateX(${offsetLeft}px) scale(1)`;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
cursorRef.current.setAttribute("data-moving", "true");
|
|
111
|
+
cursorRef.current.style.transform = `translateX(${offsetLeft}px) scale(1.1)`;
|
|
112
|
+
cursorTimer.current = setTimeout(() => {
|
|
113
|
+
if (cursorRef.current) {
|
|
114
|
+
cursorRef.current.style.transform = `translateX(${offsetLeft}px) scale(1)`;
|
|
115
|
+
}
|
|
116
|
+
cursorTimer.current = setTimeout(() => {
|
|
117
|
+
var _a2;
|
|
118
|
+
(_a2 = cursorRef.current) == null ? void 0 : _a2.setAttribute("data-moving", "false");
|
|
119
|
+
cursorTimer.current && clearTimeout(cursorTimer.current);
|
|
120
|
+
}, CURSOR_TRANSITION_TIMEOUT);
|
|
121
|
+
}, CURSOR_TRANSITION_TIMEOUT);
|
|
122
|
+
}
|
|
123
|
+
const { range, activePage, setPage, previous, next, first, last } = (0, import_use_pagination2.usePagination)({
|
|
124
|
+
page,
|
|
125
|
+
total,
|
|
126
|
+
initialPage,
|
|
127
|
+
siblings,
|
|
128
|
+
boundaries,
|
|
129
|
+
showControls,
|
|
130
|
+
onChange
|
|
131
|
+
});
|
|
132
|
+
const [setRef, isVisible] = (0, import_use_intersection_observer.useIntersectionObserver)();
|
|
133
|
+
(0, import_react.useEffect)(() => {
|
|
134
|
+
if (domRef.current) {
|
|
135
|
+
setRef(domRef.current);
|
|
136
|
+
}
|
|
137
|
+
}, [domRef.current]);
|
|
138
|
+
const activePageRef = (0, import_react.useRef)(activePage);
|
|
139
|
+
(0, import_react.useEffect)(() => {
|
|
140
|
+
if (activePage && !disableAnimation && isVisible) {
|
|
141
|
+
scrollTo(activePage, activePage === activePageRef.current);
|
|
142
|
+
}
|
|
143
|
+
activePageRef.current = activePage;
|
|
144
|
+
}, [
|
|
145
|
+
page,
|
|
146
|
+
activePage,
|
|
147
|
+
disableAnimation,
|
|
148
|
+
disableCursorAnimation,
|
|
149
|
+
isVisible,
|
|
150
|
+
originalProps.dotsJump,
|
|
151
|
+
originalProps.isCompact,
|
|
152
|
+
originalProps.showControls
|
|
153
|
+
]);
|
|
154
|
+
const slots = (0, import_react.useMemo)(
|
|
155
|
+
() => (0, import_theme.pagination)({
|
|
156
|
+
...variantProps,
|
|
157
|
+
disableAnimation,
|
|
158
|
+
disableCursorAnimation
|
|
159
|
+
}),
|
|
160
|
+
[(0, import_shared_utils.objectToDeps)(variantProps), disableCursorAnimation, disableAnimation]
|
|
161
|
+
);
|
|
162
|
+
const baseStyles = (0, import_theme.cn)(classNames == null ? void 0 : classNames.base, className);
|
|
163
|
+
const onNext = () => {
|
|
164
|
+
if (loop && activePage === total) {
|
|
165
|
+
return first();
|
|
166
|
+
}
|
|
167
|
+
return next();
|
|
168
|
+
};
|
|
169
|
+
const onPrevious = () => {
|
|
170
|
+
if (loop && activePage === 1) {
|
|
171
|
+
return last();
|
|
172
|
+
}
|
|
173
|
+
return previous();
|
|
174
|
+
};
|
|
175
|
+
const getBaseProps = (props2 = {}) => {
|
|
176
|
+
return {
|
|
177
|
+
...props2,
|
|
178
|
+
ref: domRef,
|
|
179
|
+
role: "navigation",
|
|
180
|
+
"aria-label": props2["aria-label"] || "pagination navigation",
|
|
181
|
+
"data-slot": "base",
|
|
182
|
+
"data-controls": (0, import_shared_utils2.dataAttr)(showControls),
|
|
183
|
+
"data-loop": (0, import_shared_utils2.dataAttr)(loop),
|
|
184
|
+
"data-dots-jump": dotsJump,
|
|
185
|
+
"data-total": total,
|
|
186
|
+
"data-active-page": activePage,
|
|
187
|
+
className: slots.base({ class: (0, import_theme.cn)(baseStyles, props2 == null ? void 0 : props2.className) }),
|
|
188
|
+
...otherProps
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
const getWrapperProps = (props2 = {}) => {
|
|
192
|
+
return {
|
|
193
|
+
...props2,
|
|
194
|
+
"data-slot": "wrapper",
|
|
195
|
+
className: slots.wrapper({ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.wrapper, props2 == null ? void 0 : props2.className) })
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
const getItemAriaLabel = (page2) => {
|
|
199
|
+
if (!page2) return;
|
|
200
|
+
if (getItemAriaLabelProp) {
|
|
201
|
+
return getItemAriaLabelProp(page2);
|
|
202
|
+
}
|
|
203
|
+
switch (page2) {
|
|
204
|
+
case import_use_pagination.PaginationItemType.DOTS:
|
|
205
|
+
return "dots element";
|
|
206
|
+
case import_use_pagination.PaginationItemType.PREV:
|
|
207
|
+
return "previous page button";
|
|
208
|
+
case import_use_pagination.PaginationItemType.NEXT:
|
|
209
|
+
return "next page button";
|
|
210
|
+
case "first":
|
|
211
|
+
return "first page button";
|
|
212
|
+
case "last":
|
|
213
|
+
return "last page button";
|
|
214
|
+
default:
|
|
215
|
+
return `pagination item ${page2}`;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const getItemProps = (props2 = {}) => {
|
|
219
|
+
return {
|
|
220
|
+
...props2,
|
|
221
|
+
ref: (node) => getItemRef(node, props2.value),
|
|
222
|
+
"data-slot": "item",
|
|
223
|
+
isActive: props2.value === activePage,
|
|
224
|
+
className: slots.item({ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.item, props2 == null ? void 0 : props2.className) }),
|
|
225
|
+
onPress: () => {
|
|
226
|
+
if (props2.value !== activePage) {
|
|
227
|
+
setPage(props2.value);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
const getCursorProps = (props2 = {}) => {
|
|
233
|
+
return {
|
|
234
|
+
...props2,
|
|
235
|
+
ref: cursorRef,
|
|
236
|
+
activePage,
|
|
237
|
+
"data-slot": "cursor",
|
|
238
|
+
className: slots.cursor({ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.cursor, props2 == null ? void 0 : props2.className) })
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
return {
|
|
242
|
+
Component,
|
|
243
|
+
showControls,
|
|
244
|
+
dotsJump,
|
|
245
|
+
slots,
|
|
246
|
+
classNames,
|
|
247
|
+
loop,
|
|
248
|
+
total,
|
|
249
|
+
range,
|
|
250
|
+
activePage,
|
|
251
|
+
getItemRef,
|
|
252
|
+
disableAnimation,
|
|
253
|
+
disableCursorAnimation,
|
|
254
|
+
setPage,
|
|
255
|
+
onPrevious,
|
|
256
|
+
onNext,
|
|
257
|
+
renderItem,
|
|
258
|
+
getBaseProps,
|
|
259
|
+
getWrapperProps,
|
|
260
|
+
getItemProps,
|
|
261
|
+
getCursorProps,
|
|
262
|
+
getItemAriaLabel
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
266
|
+
0 && (module.exports = {
|
|
267
|
+
CURSOR_TRANSITION_TIMEOUT,
|
|
268
|
+
usePagination
|
|
269
|
+
});
|