laif-ds 0.1.54 → 0.1.56

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,6 +1,3 @@
1
1
  "use client";
2
- import { __require as r } from "../node_modules/use-sync-external-store/shim/index.js";
3
- var i = r();
4
- export {
5
- i as s
6
- };
2
+ import { __require as e } from "../node_modules/react-is/index.js";
3
+ e();
@@ -1,3 +1,6 @@
1
1
  "use client";
2
- import { __require as e } from "../node_modules/react-is/index.js";
3
- e();
2
+ import { __require as r } from "../node_modules/use-sync-external-store/shim/index.js";
3
+ var i = r();
4
+ export {
5
+ i as s
6
+ };
@@ -124,7 +124,7 @@ function ke({
124
124
  return /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
125
125
  l && /* @__PURE__ */ e(ee, { htmlFor: T, className: B, children: l }),
126
126
  /* @__PURE__ */ s(re, { open: p, onOpenChange: N, children: [
127
- /* @__PURE__ */ e(ae, { asChild: !0, children: /* @__PURE__ */ e(
127
+ /* @__PURE__ */ e(ae, { children: /* @__PURE__ */ e(
128
128
  V,
129
129
  {
130
130
  id: T,
@@ -168,7 +168,7 @@ function ke({
168
168
  /* @__PURE__ */ e(
169
169
  oe,
170
170
  {
171
- className: "!outline-none !focus:outline-none !focus-visible:outline-none !focus:ring-0 !focus:ring-offset-0 !focus-visible:ring-0 !focus-visible:ring-offset-0 !border-none",
171
+ className: "!focus:outline-none !focus-visible:outline-none !focus:ring-0 !focus:ring-offset-0 !focus-visible:ring-0 !focus-visible:ring-offset-0 !border-none !outline-none",
172
172
  placeholder: `Search ${typeof l == "string" ? l.toLowerCase() : "options"}...`,
173
173
  value: I,
174
174
  onValueChange: (t) => {
@@ -1,75 +1,60 @@
1
1
  "use client";
2
- import { jsx as t, jsxs as w } from "react/jsx-runtime";
3
- import { useReactTable as K, flexRender as k } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
4
- import q, { useState as b, useEffect as J } from "react";
5
- import { Checkbox as D } from "./checkbox.js";
6
- import { cn as Q } from "../../lib/utils.js";
7
- import { Input as U } from "./input.js";
8
- import { ScrollArea as A, ScrollBar as C } from "./scroll-area.js";
9
- import { AppMultipleSelectDropdown as X } from "./app-multiple-select-dropdown.js";
10
- import { Table as Y, TableHeader as Z, TableRow as x, TableHead as B, TableBody as ee, TableCell as p } from "./table.js";
11
- import { Skeleton as le } from "./skeleton.js";
12
- import { getFilteredRowModel as te, getSortedRowModel as oe, getPaginationRowModel as ne, getCoreRowModel as ae } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
13
- function ce(s, r, n, d) {
14
- const i = s.getValue(r), u = d == null ? void 0 : d.find((o) => o.column === r), m = (u == null ? void 0 : u.innerFiltersMode) ?? "OR";
15
- if (Array.isArray(i))
16
- return m === "AND" ? n.every((o) => i.includes(o)) : n.some((o) => i.includes(o));
17
- switch (m) {
18
- case "AND":
19
- return n.every((o) => String(i) === o);
20
- case "OR":
21
- default:
22
- return n.some((o) => String(i) === o);
23
- }
24
- }
25
- function ie(s) {
26
- return s.reduce(
27
- (r, n) => (n.filterFn && (r[n.column] = (d, i, u) => {
28
- const m = d.getValue(i);
29
- switch (n.innerFiltersMode ?? "OR") {
30
- case "AND":
31
- return u.every(
32
- (g) => n.filterFn(m, [g])
33
- );
34
- case "OR":
35
- default:
36
- return u.some(
37
- (g) => n.filterFn(m, [g])
38
- );
39
- }
40
- }), r),
41
- {}
42
- ) || {};
43
- }
44
- function xe({
45
- columns: s,
46
- data: r,
47
- loading: n = !1,
48
- emptyComponent: d,
49
- className: i,
50
- rowSelection: u = {},
51
- onRowSelectionChange: m,
52
- checkable: o = !1,
53
- onCheckedRowsChange: g,
54
- notFoundMessage: V = "Nessun risultato trovato.",
55
- searchBar: f = void 0,
56
- dropdownFilters: a = void 0
57
- // outerFiltersMode = EFiltersMode.AND,
2
+ import { jsx as t, jsxs as C } from "react/jsx-runtime";
3
+ import { useReactTable as ue, flexRender as J } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
4
+ import { useState as h, useRef as _, useMemo as de, useEffect as M } from "react";
5
+ import { cn as fe } from "../../lib/utils.js";
6
+ import { createCustomFilterFns as xe, ELogicalFilterOperator as he, debounce as se, createMultiValueFilterFn as Ce, updatePageSizeFromContainer as be } from "./data-table.service.js";
7
+ import { Pagination as we, PaginationContent as re, PaginationItem as I, PaginationFirst as Ie, PaginationPrevious as Re, PaginationLink as ze, PaginationNext as Ne, PaginationLast as Me } from "./pagination.js";
8
+ import { Checkbox as K } from "./checkbox.js";
9
+ import { Input as ye } from "./input.js";
10
+ import { ScrollArea as q, ScrollBar as F } from "./scroll-area.js";
11
+ import { AppMultipleSelectDropdown as ke } from "./app-multiple-select-dropdown.js";
12
+ import { Table as Pe, TableHeader as He, TableRow as y, TableHead as De, TableBody as Fe, TableCell as V } from "./table.js";
13
+ import { Skeleton as Ve } from "./skeleton.js";
14
+ import { getPaginationRowModel as je, getFilteredRowModel as Le, getSortedRowModel as Te, getCoreRowModel as Ae } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
15
+ function pe({
16
+ columns: R,
17
+ data: j,
18
+ loading: Q = !1,
19
+ emptyComponent: U,
20
+ className: X,
21
+ rowSelection: Y = {},
22
+ onRowSelectionChange: L,
23
+ checkable: z = !1,
24
+ onCheckedRowsChange: k,
25
+ notFoundMessage: Z = "Nessun risultato trovato.",
26
+ searchBar: x = void 0,
27
+ dropdownFilters: u = void 0,
28
+ totalItems: P = void 0,
29
+ datatableSizes: b = {
30
+ rowHeight: 32.5,
31
+ // default table row height in pixels
32
+ headerHeight: 40,
33
+ // default table header height in pixels
34
+ containerHeight: 600
35
+ // default container height in pixels
36
+ },
37
+ paginationPlaceholders: m = void 0,
38
+ serverOptions: g = void 0,
39
+ setServerOptions: i = void 0
58
40
  }) {
59
- var v;
60
- const [T, z] = b([]), [$, j] = b([]), [H, P] = b({}), [y, F] = b(""), [L, O] = b({}), N = m ? u : L, _ = m || O, G = q.useMemo(() => o ? [
41
+ var S, E;
42
+ const [p, B] = h([]), [v, O] = h([]), [ee, le] = h({}), [r, te] = h(""), [ae, ne] = h({}), T = L ? Y : ae, ie = L || ne, [N, ge] = h({}), d = !!g, [w, H] = h({
43
+ pageIndex: 0,
44
+ pageSize: 10
45
+ }), [oe, A] = h(0), D = _(null), $ = _(void 0), ce = de(() => z ? [
61
46
  {
62
47
  id: "select",
63
- header: ({ table: e }) => /* @__PURE__ */ t("div", { className: "text-center", children: /* @__PURE__ */ t(
64
- D,
48
+ header: ({ table: e }) => /* @__PURE__ */ t(
49
+ K,
65
50
  {
66
51
  checked: e.getIsAllPageRowsSelected(),
67
52
  onCheckedChange: (l) => e.toggleAllPageRowsSelected(!!l),
68
53
  "aria-label": "Seleziona tutti"
69
54
  }
70
- ) }),
55
+ ),
71
56
  cell: ({ row: e }) => /* @__PURE__ */ t("div", { className: "text-center", children: /* @__PURE__ */ t(
72
- D,
57
+ K,
73
58
  {
74
59
  checked: e.getIsSelected(),
75
60
  onCheckedChange: (l) => e.toggleSelected(!!l),
@@ -79,140 +64,385 @@ function xe({
79
64
  enableSorting: !1,
80
65
  enableHiding: !1
81
66
  },
82
- ...s
83
- ] : s, [s, o]).map((e) => {
84
- const l = a == null ? void 0 : a.find(
85
- (c) => c.column === (e == null ? void 0 : e.accessorKey)
67
+ ...R
68
+ ] : R, [R, z]).map((e) => {
69
+ const l = u == null ? void 0 : u.find(
70
+ (n) => n.column === (e == null ? void 0 : e.accessorKey)
86
71
  );
87
72
  return {
88
73
  ...e,
89
74
  filterFn: l != null && l.filterFn ? l.column : "multiValue"
90
75
  };
91
- }), I = {
92
- data: r,
93
- columns: G,
94
- getCoreRowModel: ae(),
95
- getPaginationRowModel: ne(),
96
- onSortingChange: z,
97
- getSortedRowModel: oe(),
98
- onColumnVisibilityChange: P,
99
- onRowSelectionChange: _,
100
- getFilteredRowModel: te(),
101
- globalFilterFn: (e, l, c) => c ? (f == null ? void 0 : f.columns.some((S) => {
102
- const R = e.getValue(S);
103
- return String(R).toLowerCase().includes(c.toLowerCase());
104
- })) ?? !1 : !0,
76
+ }), me = {
77
+ data: j,
78
+ columns: ce,
79
+ getCoreRowModel: Ae(),
80
+ onSortingChange: B,
81
+ getSortedRowModel: Te(),
82
+ onColumnVisibilityChange: le,
83
+ onRowSelectionChange: ie,
84
+ getFilteredRowModel: Le(),
85
+ globalFilterFn: (e, l, n) => d || !n ? !0 : (x == null ? void 0 : x.columns.some((o) => {
86
+ const c = e.getValue(o);
87
+ return String(c).toLowerCase().includes(n.toLowerCase());
88
+ })) ?? !1,
105
89
  filterFns: {
106
- multiValue: (e, l, c) => ce(e, l, c, a),
107
- ...ie(a ?? [])
90
+ multiValue: (e, l, n) => Ce(
91
+ e,
92
+ l,
93
+ n,
94
+ u,
95
+ g
96
+ ),
97
+ ...xe(u ?? [], g)
98
+ },
99
+ onPaginationChange: (e) => {
100
+ d ? typeof e == "object" && i && i((l) => ({
101
+ ...l,
102
+ pagination: {
103
+ pageIndex: e.pageIndex,
104
+ pageSize: e.pageSize
105
+ }
106
+ })) : H(e);
108
107
  },
108
+ getPaginationRowModel: je(),
109
+ manualPagination: d,
110
+ pageCount: oe,
109
111
  state: {
110
- sorting: T,
111
- columnFilters: $,
112
- columnVisibility: H,
113
- rowSelection: N,
114
- globalFilter: y
112
+ sorting: p,
113
+ columnFilters: v,
114
+ columnVisibility: ee,
115
+ rowSelection: T,
116
+ globalFilter: r,
117
+ pagination: (g == null ? void 0 : g.pagination) ?? w
118
+ }
119
+ }, a = ue(me);
120
+ M(() => {
121
+ let e;
122
+ if (x && r && (e || (e = {}), e.searchbarFilters = {
123
+ value: r,
124
+ columns: x.columns
125
+ }), u && Object.keys(N).length > 0) {
126
+ const c = {};
127
+ for (const f of u) {
128
+ const s = N[f.column];
129
+ s && s.length > 0 && (c[f.column] = {
130
+ column: f.column,
131
+ value: s,
132
+ logic: f.innerFiltersMode || he.OR
133
+ });
134
+ }
135
+ Object.keys(c).length > 0 && (e || (e = {}), e.dropdownFilters = c);
115
136
  }
116
- }, h = K(I);
117
- return J(() => {
118
- if (g && o) {
119
- const e = h.getFilteredSelectedRowModel().rows.map((l) => l.original);
120
- g(e);
137
+ const l = $.current, n = e;
138
+ JSON.stringify(l ?? {}) !== JSON.stringify(n ?? {}) && i && ($.current = n, i((c) => ({
139
+ ...c,
140
+ pagination: {
141
+ pageIndex: 0,
142
+ pageSize: (g == null ? void 0 : g.pagination.pageSize) ?? 10
143
+ },
144
+ filters: n
145
+ })));
146
+ }, [
147
+ u,
148
+ N,
149
+ x,
150
+ r,
151
+ g,
152
+ i
153
+ ]);
154
+ const G = a.getFilteredRowModel();
155
+ return M(() => {
156
+ var e;
157
+ if (d)
158
+ A(
159
+ Math.ceil(
160
+ (P ?? 0) / (((e = g.pagination) == null ? void 0 : e.pageSize) || w.pageSize || 10)
161
+ )
162
+ );
163
+ else {
164
+ const l = G.rows.length;
165
+ A(Math.ceil(l / w.pageSize));
121
166
  }
122
- }, [h, g, o, N]), /* @__PURE__ */ w("div", { className: Q("flex h-full w-full flex-col gap-2", i), children: [
123
- (f || (a == null ? void 0 : a.length)) && /* @__PURE__ */ w("div", { className: "flex flex-col items-start justify-between gap-2 sm:flex-row sm:items-end", children: [
124
- f && /* @__PURE__ */ t(
125
- U,
126
- {
127
- iconLeft: "Search",
128
- placeholder: f.placeholder ?? "Cerca...",
129
- value: y,
130
- onChange: (e) => {
131
- F(e.target.value || "");
132
- },
133
- className: "w-60"
167
+ }, [
168
+ d,
169
+ P,
170
+ g == null ? void 0 : g.pagination,
171
+ a,
172
+ G,
173
+ w.pageSize
174
+ ]), M(() => {
175
+ const e = se(() => {
176
+ const l = D.current;
177
+ l && be(l, {
178
+ rowHeight: b.rowHeight,
179
+ headerHeight: b.headerHeight,
180
+ containerHeight: b.containerHeight,
181
+ onPageChange: d ? (n, o) => {
182
+ i == null || i((c) => ({
183
+ ...c,
184
+ pagination: { pageIndex: n, pageSize: o }
185
+ }));
186
+ } : (n, o) => {
187
+ H({ pageIndex: n, pageSize: o });
188
+ },
189
+ setPagination: (n) => {
190
+ const o = typeof n == "function" ? n({ pageIndex: 0, pageSize: 10 }) : n;
191
+ d ? i == null || i((c) => ({
192
+ ...c,
193
+ pagination: {
194
+ ...c.pagination,
195
+ pageIndex: o.pageIndex,
196
+ pageSize: o.pageSize
197
+ }
198
+ })) : H({
199
+ pageIndex: o.pageIndex,
200
+ pageSize: o.pageSize
201
+ });
134
202
  }
203
+ });
204
+ }, 200);
205
+ return e(), window.addEventListener("resize", e), () => {
206
+ window.removeEventListener("resize", e);
207
+ };
208
+ }, [
209
+ d,
210
+ b.containerHeight,
211
+ b.headerHeight,
212
+ b.rowHeight,
213
+ D,
214
+ i
215
+ // should be stable, but include for clarity
216
+ ]), M(() => {
217
+ if (k && z) {
218
+ const e = a.getFilteredSelectedRowModel().rows.map((l) => l.original);
219
+ k(e);
220
+ }
221
+ }, [a, k, z, T]), /* @__PURE__ */ C(
222
+ "div",
223
+ {
224
+ className: fe(
225
+ "flex h-full max-h-full min-h-0 w-full max-w-full flex-col gap-2",
226
+ X
135
227
  ),
136
- /* @__PURE__ */ t("div", { className: "flex h-full max-w-full min-w-0 flex-1 items-center", children: a && a.length > 0 && /* @__PURE__ */ w(A, { className: "h-full w-full", children: [
137
- /* @__PURE__ */ t(C, { orientation: "horizontal" }),
138
- /* @__PURE__ */ t("div", { className: "flex w-full max-w-full min-w-0 items-center justify-start gap-2 sm:justify-end", children: a.map((e, l) => {
139
- const [c, S] = b([]);
140
- return /* @__PURE__ */ t(
141
- X,
228
+ children: [
229
+ (x || (u == null ? void 0 : u.length)) && /* @__PURE__ */ C("div", { className: "flex flex-col items-start justify-between gap-2 sm:flex-row sm:items-end", children: [
230
+ x && /* @__PURE__ */ t(
231
+ ye,
142
232
  {
143
- className: "w-60",
144
- options: e.items,
145
- value: c,
146
- placeholder: e.placeholder,
147
- label: e.label,
148
- onChange: (R) => {
149
- S(R), j((W) => {
150
- const M = W.filter(
151
- (E) => E.id !== e.column
152
- );
153
- return R.length === 0 ? M : [
154
- ...M,
155
- { id: e.column, value: R }
156
- ];
157
- });
158
- }
159
- },
160
- l
161
- );
162
- }) })
163
- ] }) })
164
- ] }),
165
- /* @__PURE__ */ w(A, { className: "border-d-border h-full min-h-0 w-full rounded-md border", children: [
166
- /* @__PURE__ */ t(C, { orientation: "horizontal" }),
167
- /* @__PURE__ */ t(C, { orientation: "vertical" }),
168
- /* @__PURE__ */ w(Y, { children: [
169
- /* @__PURE__ */ t(Z, { children: h.getHeaderGroups().map((e) => /* @__PURE__ */ t(x, { children: e.headers.map((l) => /* @__PURE__ */ t(
170
- B,
171
- {
172
- className: `bg-d-secondary sticky top-0 z-10 ${l.column.columnDef.sticky ? "left-0" : ""}`,
173
- children: l.isPlaceholder ? null : k(
174
- l.column.columnDef.header,
175
- l.getContext()
176
- )
177
- },
178
- l.id
179
- )) }, e.id)) }),
180
- /* @__PURE__ */ t(ee, { children: n ? Array.from({ length: r.length || 8 }).map((e, l) => /* @__PURE__ */ t(x, { children: h.getHeaderGroups()[0].headers.map((c, S) => /* @__PURE__ */ t(
181
- p,
182
- {
183
- className: `w-full ${c.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
184
- children: /* @__PURE__ */ t(le, { className: "h-6 w-full" })
185
- },
186
- `skeleton-cell-${l}-${S}`
187
- )) }, `skeleton-row-${l}`)) : (v = h.getRowModel().rows) != null && v.length ? h.getRowModel().rows.map((e) => /* @__PURE__ */ t(
188
- x,
189
- {
190
- "data-state": e.getIsSelected() && "selected",
191
- children: e.getVisibleCells().map((l) => /* @__PURE__ */ t(
192
- p,
193
- {
194
- className: `${l.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
195
- children: k(
196
- l.column.columnDef.cell,
197
- l.getContext()
198
- )
233
+ iconLeft: "Search",
234
+ placeholder: x.placeholder ?? "Cerca...",
235
+ value: r,
236
+ onChange: (e) => {
237
+ te(e.target.value);
199
238
  },
200
- l.id
201
- ))
202
- },
203
- e.id
204
- )) : /* @__PURE__ */ t(x, { children: /* @__PURE__ */ t(
205
- p,
239
+ className: "w-60"
240
+ }
241
+ ),
242
+ /* @__PURE__ */ t("div", { className: "flex h-full max-w-full min-w-0 flex-1 items-center", children: u && u.length > 0 && /* @__PURE__ */ C(q, { className: "h-full w-full", children: [
243
+ /* @__PURE__ */ t(F, { orientation: "horizontal" }),
244
+ /* @__PURE__ */ t("div", { className: "flex w-full max-w-full min-w-0 items-center justify-start gap-2 sm:justify-end", children: u.map((e, l) => {
245
+ const n = N[e.column] ?? [];
246
+ return /* @__PURE__ */ t(
247
+ ke,
248
+ {
249
+ className: "w-60",
250
+ options: e.items,
251
+ value: n,
252
+ placeholder: e.placeholder,
253
+ label: e.label,
254
+ onChange: (o) => {
255
+ ge((c) => ({
256
+ ...c,
257
+ [e.column]: o
258
+ })), O((c) => {
259
+ const f = c.filter(
260
+ (s) => s.id !== e.column
261
+ );
262
+ return o.length === 0 ? f : [
263
+ ...f,
264
+ { id: e.column, value: o }
265
+ ];
266
+ });
267
+ }
268
+ },
269
+ l
270
+ );
271
+ }) })
272
+ ] }) })
273
+ ] }),
274
+ /* @__PURE__ */ t(
275
+ "div",
206
276
  {
207
- colSpan: s.length,
208
- className: "pt-4 text-center",
209
- children: d || V
277
+ className: "flex max-h-full min-h-0 max-w-full min-w-0 flex-1",
278
+ ref: D,
279
+ children: /* @__PURE__ */ C(q, { className: "border-d-border h-full min-h-0 w-full rounded-md border", children: [
280
+ /* @__PURE__ */ t(F, { orientation: "horizontal" }),
281
+ /* @__PURE__ */ t(F, { orientation: "vertical" }),
282
+ /* @__PURE__ */ C(Pe, { children: [
283
+ /* @__PURE__ */ t(He, { children: a.getHeaderGroups().map((e) => /* @__PURE__ */ t(y, { children: e.headers.map((l) => /* @__PURE__ */ t(
284
+ De,
285
+ {
286
+ className: `bg-d-secondary sticky top-0 z-10 ${l.column.columnDef.sticky ? "left-0" : ""}`,
287
+ children: l.isPlaceholder ? null : J(
288
+ l.column.columnDef.header,
289
+ l.getContext()
290
+ )
291
+ },
292
+ l.id
293
+ )) }, e.id)) }),
294
+ /* @__PURE__ */ t(Fe, { children: Q ? Array.from({ length: j.length || 8 }).map((e, l) => /* @__PURE__ */ t(y, { children: a.getHeaderGroups()[0].headers.map((n, o) => /* @__PURE__ */ t(
295
+ V,
296
+ {
297
+ className: `w-full ${n.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
298
+ children: /* @__PURE__ */ t(Ve, { className: "h-6 w-full" })
299
+ },
300
+ `skeleton-cell-${l}-${o}`
301
+ )) }, `skeleton-row-${l}`)) : (S = a.getRowModel().rows) != null && S.length ? a.getRowModel().rows.map((e) => /* @__PURE__ */ t(
302
+ y,
303
+ {
304
+ "data-state": e.getIsSelected() && "selected",
305
+ children: e.getVisibleCells().map((l) => /* @__PURE__ */ t(
306
+ V,
307
+ {
308
+ className: `${l.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
309
+ children: J(
310
+ l.column.columnDef.cell,
311
+ l.getContext()
312
+ )
313
+ },
314
+ l.id
315
+ ))
316
+ },
317
+ e.id
318
+ )) : /* @__PURE__ */ t(y, { children: /* @__PURE__ */ t(
319
+ V,
320
+ {
321
+ colSpan: R.length,
322
+ className: "pt-4 text-center",
323
+ children: U || Z
324
+ }
325
+ ) }) })
326
+ ] })
327
+ ] })
210
328
  }
211
- ) }) })
212
- ] })
213
- ] })
214
- ] });
329
+ ),
330
+ /* @__PURE__ */ C(we, { className: "h-9", children: [
331
+ /* @__PURE__ */ t("div", { className: "flex h-full flex-1 items-center align-middle", children: /* @__PURE__ */ t("div", { className: "text-d-foreground hidden text-sm md:flex", children: Math.min(
332
+ ((E = g == null ? void 0 : g.pagination) == null ? void 0 : E.pageSize) ?? w.pageSize,
333
+ a.getFilteredRowModel().rows.length ?? 9999
334
+ ) + " / " + (g ? P ?? "missing totalItems" : a.getFilteredRowModel().rows.length) + " " + ((m == null ? void 0 : m.rows) ?? "Rows") }) }),
335
+ /* @__PURE__ */ C(re, { children: [
336
+ /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(
337
+ Ie,
338
+ {
339
+ size: "sm",
340
+ isDisabled: !a.getCanPreviousPage(),
341
+ label: m == null ? void 0 : m.first,
342
+ onClick: () => {
343
+ d ? i == null || i((e) => ({
344
+ ...e,
345
+ pagination: {
346
+ ...e.pagination,
347
+ pageIndex: 0
348
+ }
349
+ })) : a.setPageIndex(0);
350
+ },
351
+ "aria-label": "Go to first page"
352
+ }
353
+ ) }),
354
+ /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(
355
+ Re,
356
+ {
357
+ size: "sm",
358
+ isDisabled: !a.getCanPreviousPage(),
359
+ label: m == null ? void 0 : m.previous,
360
+ onClick: () => {
361
+ if (a.getCanPreviousPage())
362
+ if (d) {
363
+ const e = (g == null ? void 0 : g.pagination.pageIndex) ?? w.pageIndex, l = Math.max(e - 1, 0);
364
+ i == null || i((n) => ({
365
+ ...n,
366
+ pagination: {
367
+ ...n.pagination,
368
+ pageIndex: l
369
+ }
370
+ }));
371
+ } else
372
+ a.previousPage();
373
+ }
374
+ }
375
+ ) }),
376
+ (() => {
377
+ const e = a.getState().pagination.pageIndex, l = a.getPageCount(), n = 5;
378
+ let o = Math.max(
379
+ 0,
380
+ e - Math.floor(n / 2)
381
+ ), c = o + n;
382
+ return c > l && (c = l, o = Math.max(0, c - n)), a.getPageOptions().slice(o, c).map((f, s) => /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(
383
+ ze,
384
+ {
385
+ size: "icon",
386
+ isActive: e === f,
387
+ onClick: () => {
388
+ if (d) {
389
+ if (e === f) return;
390
+ i == null || i((W) => ({
391
+ ...W,
392
+ pagination: {
393
+ ...W.pagination,
394
+ pageIndex: f
395
+ }
396
+ }));
397
+ } else
398
+ a.setPageIndex(f);
399
+ },
400
+ children: f + 1
401
+ }
402
+ ) }, s));
403
+ })(),
404
+ /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(
405
+ Ne,
406
+ {
407
+ size: "sm",
408
+ isDisabled: !a.getCanNextPage(),
409
+ label: m == null ? void 0 : m.next,
410
+ onClick: () => {
411
+ a.getCanNextPage() && (d ? i == null || i((e) => ({
412
+ ...e,
413
+ pagination: {
414
+ ...e.pagination,
415
+ pageIndex: e.pagination.pageIndex + 1
416
+ }
417
+ })) : a.nextPage());
418
+ }
419
+ }
420
+ ) }),
421
+ /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(
422
+ Me,
423
+ {
424
+ size: "sm",
425
+ isDisabled: !a.getCanNextPage(),
426
+ label: m == null ? void 0 : m.last,
427
+ onClick: () => {
428
+ d ? i == null || i((e) => ({
429
+ ...e,
430
+ pagination: {
431
+ ...e.pagination,
432
+ pageIndex: a.getPageCount() - 1
433
+ }
434
+ })) : a.setPageIndex(a.getPageCount() - 1);
435
+ },
436
+ "aria-label": "Go to last page"
437
+ }
438
+ ) })
439
+ ] }),
440
+ /* @__PURE__ */ t("div", { className: "flex h-full flex-1 items-center justify-end align-middle", children: /* @__PURE__ */ t("div", { className: "text-d-foreground hidden text-sm md:flex", children: (a.getPageCount() ? a.getState().pagination.pageIndex + 1 : 0) + " / " + a.getPageCount() + " " + ((m == null ? void 0 : m.pages) ?? "Pages") }) })
441
+ ] })
442
+ ]
443
+ }
444
+ );
215
445
  }
216
446
  export {
217
- xe as DataTable
447
+ pe as DataTable
218
448
  };