@boxcustodia/library 2.0.0-alpha.30 → 2.0.0-alpha.32

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.
@@ -1,99 +1,100 @@
1
1
  "use client";
2
- import { jsx as r, jsxs as b, Fragment as G } from "react/jsx-runtime";
3
- import w from "../../node_modules/lucide-react/dist/esm/icons/chevrons-up-down.es.js";
4
- import { useRender as T } from "../../node_modules/@base-ui/react/use-render/useRender.es.js";
5
- import D from "../../node_modules/lucide-react/dist/esm/icons/chevron-up.es.js";
6
- import $ from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.es.js";
7
- import { cn as n } from "../../lib/cn.es.js";
8
- import { SelectRoot as V } from "../../node_modules/@base-ui/react/select/root/SelectRoot.es.js";
9
- import { SelectTrigger as B } from "../../node_modules/@base-ui/react/select/trigger/SelectTrigger.es.js";
10
- import { SelectIcon as R } from "../../node_modules/@base-ui/react/select/icon/SelectIcon.es.js";
11
- import { mergeProps as U } from "../../node_modules/@base-ui/react/merge-props/mergeProps.es.js";
12
- import { SelectValue as A } from "../../node_modules/@base-ui/react/select/value/SelectValue.es.js";
13
- import { SelectPortal as F } from "../../node_modules/@base-ui/react/select/portal/SelectPortal.es.js";
14
- import { SelectPositioner as M } from "../../node_modules/@base-ui/react/select/positioner/SelectPositioner.es.js";
15
- import { SelectPopup as W } from "../../node_modules/@base-ui/react/select/popup/SelectPopup.es.js";
16
- import { SelectScrollUpArrow as q } from "../../node_modules/@base-ui/react/select/scroll-up-arrow/SelectScrollUpArrow.es.js";
17
- import { SelectList as E } from "../../node_modules/@base-ui/react/select/list/SelectList.es.js";
18
- import { SelectScrollDownArrow as H } from "../../node_modules/@base-ui/react/select/scroll-down-arrow/SelectScrollDownArrow.es.js";
19
- import { SelectItem as J } from "../../node_modules/@base-ui/react/select/item/SelectItem.es.js";
20
- import { SelectItemText as K } from "../../node_modules/@base-ui/react/select/item-text/SelectItemText.es.js";
21
- import { SelectItemIndicator as O } from "../../node_modules/@base-ui/react/select/item-indicator/SelectItemIndicator.es.js";
22
- import { Separator as Q } from "../../node_modules/@base-ui/react/separator/Separator.es.js";
23
- import { SelectGroup as X } from "../../node_modules/@base-ui/react/select/group/SelectGroup.es.js";
24
- import { SelectGroupLabel as Y } from "../../node_modules/@base-ui/react/select/group-label/SelectGroupLabel.es.js";
25
- import { SelectLabel as Z } from "../../node_modules/@base-ui/react/select/label/SelectLabel.es.js";
26
- import { inputBaseClasses as ee } from "../input/input.es.js";
27
- const N = n(
28
- ee,
2
+ import { jsx as r, jsxs as p, Fragment as T } from "react/jsx-runtime";
3
+ import * as $ from "react";
4
+ import I from "../../node_modules/lucide-react/dist/esm/icons/chevrons-up-down.es.js";
5
+ import { useRender as V } from "../../node_modules/@base-ui/react/use-render/useRender.es.js";
6
+ import R from "../../node_modules/lucide-react/dist/esm/icons/chevron-up.es.js";
7
+ import B from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.es.js";
8
+ import { cn as l } from "../../lib/cn.es.js";
9
+ import { SelectRoot as U } from "../../node_modules/@base-ui/react/select/root/SelectRoot.es.js";
10
+ import { SelectTrigger as A } from "../../node_modules/@base-ui/react/select/trigger/SelectTrigger.es.js";
11
+ import { SelectIcon as E } from "../../node_modules/@base-ui/react/select/icon/SelectIcon.es.js";
12
+ import { mergeProps as K } from "../../node_modules/@base-ui/react/merge-props/mergeProps.es.js";
13
+ import { SelectValue as M } from "../../node_modules/@base-ui/react/select/value/SelectValue.es.js";
14
+ import { SelectPortal as q } from "../../node_modules/@base-ui/react/select/portal/SelectPortal.es.js";
15
+ import { SelectPositioner as F } from "../../node_modules/@base-ui/react/select/positioner/SelectPositioner.es.js";
16
+ import { SelectPopup as O } from "../../node_modules/@base-ui/react/select/popup/SelectPopup.es.js";
17
+ import { SelectScrollUpArrow as W } from "../../node_modules/@base-ui/react/select/scroll-up-arrow/SelectScrollUpArrow.es.js";
18
+ import { SelectList as H } from "../../node_modules/@base-ui/react/select/list/SelectList.es.js";
19
+ import { SelectScrollDownArrow as J } from "../../node_modules/@base-ui/react/select/scroll-down-arrow/SelectScrollDownArrow.es.js";
20
+ import { SelectItem as Q } from "../../node_modules/@base-ui/react/select/item/SelectItem.es.js";
21
+ import { SelectItemText as X } from "../../node_modules/@base-ui/react/select/item-text/SelectItemText.es.js";
22
+ import { SelectItemIndicator as Y } from "../../node_modules/@base-ui/react/select/item-indicator/SelectItemIndicator.es.js";
23
+ import { Separator as Z } from "../../node_modules/@base-ui/react/separator/Separator.es.js";
24
+ import { SelectGroup as ee } from "../../node_modules/@base-ui/react/select/group/SelectGroup.es.js";
25
+ import { SelectGroupLabel as te } from "../../node_modules/@base-ui/react/select/group-label/SelectGroupLabel.es.js";
26
+ import { SelectLabel as re } from "../../node_modules/@base-ui/react/select/label/SelectLabel.es.js";
27
+ import { inputBaseClasses as oe } from "../input/input.es.js";
28
+ const L = l(
29
+ oe,
29
30
  "relative inline-flex items-center justify-between gap-2 select-none text-left text-foreground",
30
31
  "focus-visible:border-ring",
31
32
  "aria-invalid:border-error focus-visible:aria-invalid:ring-error/20",
32
33
  "has-aria-invalid:border-error has-focus-visible:has-aria-invalid:ring-error/20",
33
34
  "data-disabled:cursor-not-allowed data-disabled:opacity-50",
34
35
  "[&_svg]:pointer-events-none [&_svg]:shrink-0"
35
- ), y = "-me-1 size-4.5 opacity-80 sm:size-4";
36
- function te({
36
+ ), k = "-me-1 size-4.5 opacity-80 sm:size-4";
37
+ function ae({
37
38
  ...e
38
39
  }) {
39
- return /* @__PURE__ */ r(V, { ...e });
40
+ return /* @__PURE__ */ r(U, { ...e });
40
41
  }
41
- function re({
42
+ function ne({
42
43
  className: e,
43
44
  children: t,
44
- icon: a,
45
- ...i
45
+ icon: n,
46
+ ...s
46
47
  }) {
47
- return /* @__PURE__ */ b(
48
- B,
48
+ return /* @__PURE__ */ p(
49
+ A,
49
50
  {
50
- className: n(N, e),
51
+ className: l(L, e),
51
52
  "data-slot": "select-trigger",
52
- ...i,
53
+ ...s,
53
54
  children: [
54
55
  t,
55
56
  /* @__PURE__ */ r(
56
- R,
57
+ E,
57
58
  {
58
59
  "data-slot": "select-icon",
59
60
  className: "text-muted-foreground hover:text-foreground transition-colors",
60
- children: a ?? /* @__PURE__ */ r(w, { className: y })
61
+ children: n ?? /* @__PURE__ */ r(I, { className: k })
61
62
  }
62
63
  )
63
64
  ]
64
65
  }
65
66
  );
66
67
  }
67
- function Ve({
68
+ function Ue({
68
69
  className: e,
69
70
  render: t,
70
- children: a,
71
- icon: i,
72
- ...c
71
+ children: n,
72
+ icon: s,
73
+ ...d
73
74
  }) {
74
- const s = t ? void 0 : "button", d = {
75
- children: /* @__PURE__ */ b(G, { children: [
76
- /* @__PURE__ */ r("span", { className: "flex-1 truncate in-data-placeholder:text-muted-foreground/72", children: a }),
77
- i ?? /* @__PURE__ */ r(w, { className: y })
75
+ const i = t ? void 0 : "button", u = {
76
+ children: /* @__PURE__ */ p(T, { children: [
77
+ /* @__PURE__ */ r("span", { className: "flex-1 truncate in-data-placeholder:text-muted-foreground/72", children: n }),
78
+ s ?? /* @__PURE__ */ r(I, { className: k })
78
79
  ] }),
79
- className: n(N, "min-w-0", e),
80
+ className: l(L, "min-w-0", e),
80
81
  "data-slot": "select-button",
81
- type: s
82
+ type: i
82
83
  };
83
- return T({
84
+ return V({
84
85
  defaultTagName: "button",
85
- props: U(d, c),
86
+ props: K(u, d),
86
87
  render: t
87
88
  });
88
89
  }
89
- function oe({
90
+ function le({
90
91
  className: e,
91
92
  ...t
92
93
  }) {
93
94
  return /* @__PURE__ */ r(
94
- A,
95
+ M,
95
96
  {
96
- className: n(
97
+ className: l(
97
98
  "flex-1 truncate data-placeholder:text-muted-foreground",
98
99
  e
99
100
  ),
@@ -102,48 +103,48 @@ function oe({
102
103
  }
103
104
  );
104
105
  }
105
- function ae({
106
+ function se({
106
107
  className: e,
107
108
  children: t,
108
- side: a = "bottom",
109
- sideOffset: i = 4,
110
- align: c = "start",
111
- alignOffset: s = 0,
112
- alignItemWithTrigger: d = !1,
113
- anchor: u,
114
- portalProps: f,
109
+ side: n = "bottom",
110
+ sideOffset: s = 4,
111
+ align: d = "start",
112
+ alignOffset: i = 0,
113
+ alignItemWithTrigger: u = !1,
114
+ anchor: f,
115
+ portalProps: c,
115
116
  ...m
116
117
  }) {
117
- return /* @__PURE__ */ r(F, { ...f, children: /* @__PURE__ */ r(
118
- M,
118
+ return /* @__PURE__ */ r(q, { ...c, children: /* @__PURE__ */ r(
119
+ F,
119
120
  {
120
- align: c,
121
- alignItemWithTrigger: d,
122
- alignOffset: s,
123
- anchor: u,
121
+ align: d,
122
+ alignItemWithTrigger: u,
123
+ alignOffset: i,
124
+ anchor: f,
124
125
  className: "z-50 select-none",
125
126
  "data-slot": "select-positioner",
126
- side: a,
127
- sideOffset: i,
128
- children: /* @__PURE__ */ b(
129
- W,
127
+ side: n,
128
+ sideOffset: s,
129
+ children: /* @__PURE__ */ p(
130
+ O,
130
131
  {
131
132
  className: "origin-(--transform-origin) text-foreground outline-none duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",
132
133
  "data-slot": "select-popup",
133
134
  ...m,
134
135
  children: [
135
136
  /* @__PURE__ */ r(
136
- q,
137
+ W,
137
138
  {
138
139
  className: "top-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:top-px before:h-[200%] before:rounded-t-[calc(var(--radius-lg)-1px)] before:bg-linear-to-b before:from-50% before:from-popover",
139
140
  "data-slot": "select-scroll-up-arrow",
140
- children: /* @__PURE__ */ r(D, { className: "relative size-4.5 sm:size-4" })
141
+ children: /* @__PURE__ */ r(R, { className: "relative size-4.5 sm:size-4" })
141
142
  }
142
143
  ),
143
144
  /* @__PURE__ */ r("div", { className: "relative h-full min-w-(--anchor-width) rounded-lg border bg-popover not-dark:bg-clip-padding shadow-lg/5 before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]", children: /* @__PURE__ */ r(
144
- E,
145
+ H,
145
146
  {
146
- className: n(
147
+ className: l(
147
148
  "max-h-[min(24rem,var(--available-height))] overflow-y-auto p-1",
148
149
  e
149
150
  ),
@@ -152,11 +153,11 @@ function ae({
152
153
  }
153
154
  ) }),
154
155
  /* @__PURE__ */ r(
155
- H,
156
+ J,
156
157
  {
157
158
  className: "bottom-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:bottom-px before:h-[200%] before:rounded-b-[calc(var(--radius-lg)-1px)] before:bg-linear-to-t before:from-50% before:from-popover",
158
159
  "data-slot": "select-scroll-down-arrow",
159
- children: /* @__PURE__ */ r($, { className: "relative size-4.5 sm:size-4" })
160
+ children: /* @__PURE__ */ r(B, { className: "relative size-4.5 sm:size-4" })
160
161
  }
161
162
  )
162
163
  ]
@@ -165,23 +166,23 @@ function ae({
165
166
  }
166
167
  ) });
167
168
  }
168
- function le({
169
+ function ie({
169
170
  className: e,
170
171
  children: t,
171
- ...a
172
+ ...n
172
173
  }) {
173
- return /* @__PURE__ */ b(
174
- J,
174
+ return /* @__PURE__ */ p(
175
+ Q,
175
176
  {
176
- className: n(
177
+ className: l(
177
178
  "grid min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1fr_1rem] items-center gap-2 rounded-sm py-1 px-2 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
178
179
  e
179
180
  ),
180
181
  "data-slot": "select-item",
181
- ...a,
182
+ ...n,
182
183
  children: [
183
- /* @__PURE__ */ r(K, { className: "col-start-1 min-w-0", children: t }),
184
- /* @__PURE__ */ r(O, { className: "col-start-2", children: /* @__PURE__ */ r(
184
+ /* @__PURE__ */ r(X, { className: "col-start-1 min-w-0", children: t }),
185
+ /* @__PURE__ */ r(Y, { className: "col-start-2", children: /* @__PURE__ */ r(
185
186
  "svg",
186
187
  {
187
188
  "aria-hidden": "true",
@@ -201,25 +202,25 @@ function le({
201
202
  }
202
203
  );
203
204
  }
204
- function Be({
205
+ function Ae({
205
206
  className: e,
206
207
  ...t
207
208
  }) {
208
209
  return /* @__PURE__ */ r(
209
- Q,
210
+ Z,
210
211
  {
211
- className: n("mx-2 my-1 h-px bg-border", e),
212
+ className: l("mx-2 my-1 h-px bg-border", e),
212
213
  "data-slot": "select-separator",
213
214
  ...t
214
215
  }
215
216
  );
216
217
  }
217
- function Re(e) {
218
- return /* @__PURE__ */ r(X, { "data-slot": "select-group", ...e });
218
+ function Ee(e) {
219
+ return /* @__PURE__ */ r(ee, { "data-slot": "select-group", ...e });
219
220
  }
220
- function Ue(e) {
221
+ function Ke(e) {
221
222
  return /* @__PURE__ */ r(
222
- Y,
223
+ te,
223
224
  {
224
225
  className: "px-2 py-1.5 font-medium text-muted-foreground text-xs",
225
226
  "data-slot": "select-group-label",
@@ -227,14 +228,14 @@ function Ue(e) {
227
228
  }
228
229
  );
229
230
  }
230
- function Ae({
231
+ function Me({
231
232
  className: e,
232
233
  ...t
233
234
  }) {
234
235
  return /* @__PURE__ */ r(
235
- Z,
236
+ re,
236
237
  {
237
- className: n(
238
+ className: l(
238
239
  "not-in-data-[slot=field]:mb-2 inline-flex cursor-default items-center gap-2 font-medium text-base/4.5 text-foreground sm:text-sm/4",
239
240
  e
240
241
  ),
@@ -243,7 +244,7 @@ function Ae({
243
244
  }
244
245
  );
245
246
  }
246
- function ne(e) {
247
+ function ce(e) {
247
248
  if (e == null) return "";
248
249
  if (typeof e == "string" || typeof e == "number") return String(e);
249
250
  if (typeof e == "object") {
@@ -254,7 +255,7 @@ function ne(e) {
254
255
  }
255
256
  return String(e);
256
257
  }
257
- function ie(e) {
258
+ function de(e) {
258
259
  if (e == null) return "";
259
260
  if (typeof e == "string" || typeof e == "number") return String(e);
260
261
  if (typeof e == "object") {
@@ -264,88 +265,101 @@ function ie(e) {
264
265
  }
265
266
  return String(e);
266
267
  }
267
- function se(e) {
268
+ function ue(e) {
268
269
  return e != null && typeof e == "object" && "disabled" in e ? !!e.disabled : !1;
269
270
  }
270
- function Fe(e) {
271
+ function qe(e) {
271
272
  const {
272
273
  items: t,
273
- getLabel: a,
274
- getId: i,
275
- getDisabled: c,
276
- renderItem: s,
277
- placeholder: d,
278
- onValueChange: u,
279
- value: f,
274
+ getLabel: n,
275
+ getId: s,
276
+ getDisabled: d,
277
+ renderItem: i,
278
+ placeholder: u,
279
+ onValueChange: f,
280
+ value: c,
280
281
  defaultValue: m,
281
- multiple: h,
282
- className: z,
283
- classNames: v,
284
- icon: L,
285
- "aria-invalid": S,
286
- ...I
287
- } = e, x = a ?? ne, l = i ?? ie, C = c ?? se, _ = h ? f?.map(l) : f != null ? l(f) : void 0, P = h ? m?.map(l) : m != null ? l(m) : void 0;
288
- return /* @__PURE__ */ b(
289
- te,
282
+ multiple: g,
283
+ className: C,
284
+ classNames: w,
285
+ icon: _,
286
+ "aria-invalid": N,
287
+ ...P
288
+ } = e, y = n ?? ce, S = s ?? de, j = d ?? ue, b = (o) => String(S(o)), v = (o) => t.find((a) => b(a) === o) ?? null, z = $.useRef(!1);
289
+ if (process.env.NODE_ENV !== "production" && !z.current) {
290
+ const o = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
291
+ for (const h of t) {
292
+ const x = b(h);
293
+ o.has(x) && a.add(x), o.add(x);
294
+ }
295
+ a.size > 0 && (z.current = !0, console.warn(
296
+ `[Select] Multiple items resolve to the same id (${[...a].join(", ")}). Provide a \`getId\` that returns a unique value per item.`
297
+ ));
298
+ }
299
+ const D = g ? c?.map((o) => String(o)) : c == null ? c : String(c), G = g ? m?.map(
300
+ (o) => String(o)
301
+ ) : m == null ? void 0 : String(m);
302
+ return /* @__PURE__ */ p(
303
+ ae,
290
304
  {
291
305
  itemToStringLabel: (o) => {
292
- const p = t.find((g) => l(g) === o);
293
- return p ? x(p) : o;
306
+ const a = v(o);
307
+ return a ? y(a) : o;
294
308
  },
295
- multiple: h,
296
- value: _,
297
- defaultValue: P,
309
+ multiple: g,
310
+ value: D,
311
+ defaultValue: G,
298
312
  onValueChange: (o) => {
299
- if (h) {
300
- const g = (o ?? []).map((j) => t.find((k) => l(k) === j) ?? null).filter(Boolean);
301
- u?.(g);
313
+ if (g) {
314
+ const h = (o ?? []).map(v).filter(Boolean);
315
+ f?.(h.map(S), h);
302
316
  } else {
303
317
  if (o == null) {
304
- u?.(null);
318
+ f?.(null, null);
305
319
  return;
306
320
  }
307
- const p = t.find((g) => l(g) === o) ?? null;
308
- u?.(p);
321
+ const a = v(o);
322
+ f?.(a ? S(a) : null, a);
309
323
  }
310
324
  },
311
- ...I,
325
+ ...P,
312
326
  children: [
313
327
  /* @__PURE__ */ r(
314
- re,
328
+ ne,
315
329
  {
316
- className: z,
317
- icon: L,
318
- ...S === void 0 ? {} : { "aria-invalid": S },
319
- children: /* @__PURE__ */ r(oe, { placeholder: d })
330
+ className: C,
331
+ icon: _,
332
+ ...N === void 0 ? {} : { "aria-invalid": N },
333
+ children: /* @__PURE__ */ r(le, { placeholder: u })
320
334
  }
321
335
  ),
322
- /* @__PURE__ */ r(ae, { className: v?.popup, children: t.map((o) => /* @__PURE__ */ r(
323
- le,
336
+ /* @__PURE__ */ r(se, { className: w?.popup, children: t.map((o) => /* @__PURE__ */ r(
337
+ ie,
324
338
  {
325
- value: l(o),
326
- disabled: C(o),
327
- className: v?.item,
328
- children: s ? s(o) : x(o)
339
+ value: b(o),
340
+ disabled: j(o),
341
+ className: w?.item,
342
+ children: i ? i(o) : y(o)
329
343
  },
330
- l(o)
344
+ b(o)
331
345
  )) })
332
346
  ]
333
347
  }
334
348
  );
335
349
  }
336
350
  export {
337
- Fe as Select,
338
- Ve as SelectButton,
339
- ae as SelectContent,
340
- Re as SelectGroup,
341
- Ue as SelectGroupLabel,
342
- le as SelectItem,
343
- Ae as SelectLabel,
344
- ae as SelectPopup,
345
- te as SelectRoot,
346
- Be as SelectSeparator,
347
- re as SelectTrigger,
348
- oe as SelectValue,
349
- N as selectTriggerClasses,
350
- y as selectTriggerIconClassName
351
+ qe as Select,
352
+ Ue as SelectButton,
353
+ se as SelectContent,
354
+ Ee as SelectGroup,
355
+ Ke as SelectGroupLabel,
356
+ ie as SelectItem,
357
+ Me as SelectLabel,
358
+ se as SelectPopup,
359
+ ae as SelectRoot,
360
+ Ae as SelectSeparator,
361
+ ne as SelectTrigger,
362
+ le as SelectValue,
363
+ L as selectTriggerClasses,
364
+ k as selectTriggerIconClassName
351
365
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),f=require("../internal/use-latest-ref.cjs.js"),G=10,O=1;function m(e,r){return e<=0||Number.isNaN(e)?(process.env.NODE_ENV!=="production"&&(!r||!r.current)&&(r&&(r.current=!0),console.warn(`[usePagination] pageSize must be a positive number, received ${e}. Coercing to 1.`)),1):Math.floor(e)}function U(e,r){return e<=0?0:Math.ceil(e/r)}function d(e,r){return r<=0||Number.isNaN(e)?1:Math.min(Math.max(1,Math.floor(e)),r)}function j({totalItems:e,pageSize:r,defaultPageSize:z=G,onPageSizeChange:b,page:C,defaultPage:A=O,onPageChange:T,onPaginationChange:_}){const[p,R]=n.useState(A),[S,h]=n.useState(z),x=n.useRef(!1),c=m(r??S,x),o=U(e,c),u=d(C??p,o),i=f.useLatestRef(u),y=f.useLatestRef(c),s=f.useLatestRef(o),L=f.useLatestRef(T),N=f.useLatestRef(b),D=f.useLatestRef(_),P=n.useRef(!1),l=n.useRef(null),E=n.useRef(null);n.useEffect(()=>{if(!P.current)return;const t=d(p,s.current);l.current!==t&&(l.current=t,L.current?.(t))},[p]),n.useEffect(()=>{if(!P.current)return;const t=m(S);E.current!==t&&(E.current=t,N.current?.(t))},[S]),n.useEffect(()=>{P.current&&D.current?.({page:u,pageSize:c})},[u,c]),n.useEffect(()=>{P.current=!0},[]);const F=n.useMemo(()=>{const t=g=>{const a=d(g,s.current);a!==i.current&&R(a)};return{goTo:g=>{s.current<=0||t(g)},next:()=>{i.current>=s.current||t(i.current+1)},prev:()=>{i.current<=1||t(i.current-1)},firstPage:()=>{s.current<=0||t(1)},lastPage:()=>{s.current<=0||t(s.current)},setPageSize:g=>{const a=m(g);a!==y.current&&(E.current=a,h(a),N.current?.(a),i.current!==1&&(l.current=1,L.current?.(1)),R(1))}}},[R,h]),v=o<=0?!0:u<=1,M=o<=0?!0:u>=o,q=e<=0?{start:0,end:0}:{start:(u-1)*c+1,end:Math.min(u*c,e)};return{page:u,pageSize:c,pageCount:o,isFirstPage:v,isLastPage:M,hasPrevPage:!v,hasNextPage:!M,range:q,...F}}exports.usePagination=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),o=require("../internal/use-latest-ref.cjs.js"),O=10,U=1;function d(e,r){return e<=0||Number.isNaN(e)?(process.env.NODE_ENV!=="production"&&(!r||!r.current)&&(r&&(r.current=!0),console.warn(`[usePagination] pageSize must be a positive number, received ${e}. Coercing to 1.`)),1):Math.floor(e)}function j(e,r){return e<=0?0:Math.ceil(e/r)}function h(e,r){return r<=0||Number.isNaN(e)?1:Math.min(Math.max(1,Math.floor(e)),r)}function V({totalItems:e,pageSize:r,defaultPageSize:z=O,onPageSizeChange:b,page:C,defaultPage:A=U,onPageChange:T,onPaginationChange:_}){const[P,S]=n.useState(A),[l,L]=n.useState(z),x=n.useRef(!1),s=d(r??l,x),i=j(e,s),c=h(C??P,i),f=o.useLatestRef(c),y=o.useLatestRef(P),D=o.useLatestRef(s),a=o.useLatestRef(i),E=o.useLatestRef(T),N=o.useLatestRef(b),F=o.useLatestRef(_),R=n.useRef(!1),p=n.useRef(null),m=n.useRef(null);n.useEffect(()=>{if(!R.current)return;const t=h(P,a.current);p.current!==t&&(p.current=t,E.current?.(t))},[P]),n.useEffect(()=>{if(!R.current)return;const t=d(l);m.current!==t&&(m.current=t,N.current?.(t))},[l]),n.useEffect(()=>{R.current&&F.current?.({page:c,pageSize:s})},[c,s]),n.useEffect(()=>{R.current=!0},[]);const q=n.useMemo(()=>{const t=g=>{const u=h(g,a.current);u!==f.current&&(y.current===u&&(p.current=u,E.current?.(u)),S(u))};return{goTo:g=>{a.current<=0||t(g)},next:()=>{f.current>=a.current||t(f.current+1)},prev:()=>{f.current<=1||t(f.current-1)},firstPage:()=>{a.current<=0||t(1)},lastPage:()=>{a.current<=0||t(a.current)},setPageSize:g=>{const u=d(g);u!==D.current&&(m.current=u,L(u),N.current?.(u),f.current!==1&&(p.current=1,E.current?.(1)),S(1))}}},[S,L]),v=i<=0?!0:c<=1,M=i<=0?!0:c>=i,G=e<=0?{start:0,end:0}:{start:(c-1)*s+1,end:Math.min(c*s,e)};return{page:c,pageSize:s,pageCount:i,isFirstPage:v,isLastPage:M,hasPrevPage:!v,hasNextPage:!M,range:G,...q}}exports.usePagination=V;
@@ -1,83 +1,83 @@
1
- import { useState as b, useRef as P, useEffect as p, useMemo as V } from "react";
2
- import { useLatestRef as s } from "../internal/use-latest-ref.es.js";
3
- const Z = 10, $ = 1;
1
+ import { useState as b, useRef as S, useEffect as l, useMemo as Z } from "react";
2
+ import { useLatestRef as o } from "../internal/use-latest-ref.es.js";
3
+ const $ = 10, j = 1;
4
4
  function d(e, t) {
5
5
  return e <= 0 || Number.isNaN(e) ? (process.env.NODE_ENV !== "production" && (!t || !t.current) && (t && (t.current = !0), console.warn(
6
6
  `[usePagination] pageSize must be a positive number, received ${e}. Coercing to 1.`
7
7
  )), 1) : Math.floor(e);
8
8
  }
9
- function j(e, t) {
9
+ function k(e, t) {
10
10
  return e <= 0 ? 0 : Math.ceil(e / t);
11
11
  }
12
12
  function N(e, t) {
13
13
  return t <= 0 || Number.isNaN(e) ? 1 : Math.min(Math.max(1, Math.floor(e)), t);
14
14
  }
15
- function B({
15
+ function H({
16
16
  totalItems: e,
17
17
  pageSize: t,
18
- defaultPageSize: x = Z,
18
+ defaultPageSize: x = $,
19
19
  onPageSizeChange: A,
20
20
  page: L,
21
- defaultPage: _ = $,
21
+ defaultPage: _ = j,
22
22
  onPageChange: D,
23
23
  onPaginationChange: F
24
24
  }) {
25
- const [S, l] = b(_), [m, R] = b(x), T = P(!1), u = d(t ?? m, T), o = j(e, u), n = N(L ?? S, o), i = s(n), G = s(u), c = s(o), v = s(D), z = s(A), U = s(F), g = P(!1), h = P(null), E = P(null);
26
- p(() => {
27
- if (!g.current) return;
28
- const r = N(S, c.current);
29
- h.current !== r && (h.current = r, v.current?.(r));
30
- }, [S]), p(() => {
31
- if (!g.current) return;
32
- const r = d(m);
33
- E.current !== r && (E.current = r, z.current?.(r));
34
- }, [m]), p(() => {
35
- g.current && U.current?.({ page: n, pageSize: u });
36
- }, [n, u]), p(() => {
37
- g.current = !0;
25
+ const [g, m] = b(_), [h, v] = b(x), T = S(!1), c = d(t ?? h, T), i = k(e, c), u = N(L ?? g, i), s = o(u), G = o(g), U = o(c), a = o(i), E = o(D), z = o(A), y = o(F), P = S(!1), p = S(null), R = S(null);
26
+ l(() => {
27
+ if (!P.current) return;
28
+ const r = N(g, a.current);
29
+ p.current !== r && (p.current = r, E.current?.(r));
30
+ }, [g]), l(() => {
31
+ if (!P.current) return;
32
+ const r = d(h);
33
+ R.current !== r && (R.current = r, z.current?.(r));
34
+ }, [h]), l(() => {
35
+ P.current && y.current?.({ page: u, pageSize: c });
36
+ }, [u, c]), l(() => {
37
+ P.current = !0;
38
38
  }, []);
39
- const y = V(() => {
39
+ const O = Z(() => {
40
40
  const r = (f) => {
41
- const a = N(f, c.current);
42
- a !== i.current && l(a);
41
+ const n = N(f, a.current);
42
+ n !== s.current && (G.current === n && (p.current = n, E.current?.(n)), m(n));
43
43
  };
44
44
  return {
45
45
  goTo: (f) => {
46
- c.current <= 0 || r(f);
46
+ a.current <= 0 || r(f);
47
47
  },
48
48
  next: () => {
49
- i.current >= c.current || r(i.current + 1);
49
+ s.current >= a.current || r(s.current + 1);
50
50
  },
51
51
  prev: () => {
52
- i.current <= 1 || r(i.current - 1);
52
+ s.current <= 1 || r(s.current - 1);
53
53
  },
54
54
  firstPage: () => {
55
- c.current <= 0 || r(1);
55
+ a.current <= 0 || r(1);
56
56
  },
57
57
  lastPage: () => {
58
- c.current <= 0 || r(c.current);
58
+ a.current <= 0 || r(a.current);
59
59
  },
60
60
  setPageSize: (f) => {
61
- const a = d(f);
62
- a !== G.current && (E.current = a, R(a), z.current?.(a), i.current !== 1 && (h.current = 1, v.current?.(1)), l(1));
61
+ const n = d(f);
62
+ n !== U.current && (R.current = n, v(n), z.current?.(n), s.current !== 1 && (p.current = 1, E.current?.(1)), m(1));
63
63
  }
64
64
  };
65
- }, [l, R]), M = o <= 0 ? !0 : n <= 1, C = o <= 0 ? !0 : n >= o, O = e <= 0 ? { start: 0, end: 0 } : {
66
- start: (n - 1) * u + 1,
67
- end: Math.min(n * u, e)
65
+ }, [m, v]), M = i <= 0 ? !0 : u <= 1, C = i <= 0 ? !0 : u >= i, V = e <= 0 ? { start: 0, end: 0 } : {
66
+ start: (u - 1) * c + 1,
67
+ end: Math.min(u * c, e)
68
68
  };
69
69
  return {
70
- page: n,
71
- pageSize: u,
72
- pageCount: o,
70
+ page: u,
71
+ pageSize: c,
72
+ pageCount: i,
73
73
  isFirstPage: M,
74
74
  isLastPage: C,
75
75
  hasPrevPage: !M,
76
76
  hasNextPage: !C,
77
- range: O,
78
- ...y
77
+ range: V,
78
+ ...O
79
79
  };
80
80
  }
81
81
  export {
82
- B as usePagination
82
+ H as usePagination
83
83
  };