laif-ds 0.2.61 → 0.2.63

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,86 +1,86 @@
1
1
  "use client";
2
- import { jsx as c, jsxs as ae } from "react/jsx-runtime";
3
- import { useReactTable as $e } from "../../../../node_modules/@tanstack/react-table/build/lib/index.js";
4
- import { cn as et } from "../../../../lib/utils.js";
5
- import { useRef as f, useState as u, useEffect as N, useMemo as C } from "react";
6
- import { Button as tt } from "../../button.js";
2
+ import { jsx as c, jsxs as ie } from "react/jsx-runtime";
3
+ import { useReactTable as nt } from "../../../../node_modules/@tanstack/react-table/build/lib/index.js";
4
+ import { cn as ot } from "../../../../lib/utils.js";
5
+ import { useRef as f, useState as u, useEffect as H, useMemo as F } from "react";
6
+ import { Button as at } from "../../button.js";
7
7
  import { Checkbox as ye } from "../../checkbox.js";
8
- import { DataTableBody as nt } from "./components/data-table-body.js";
9
- import { DataTableColumnVisibility as rt } from "./components/data-table-column-visibility.js";
10
- import { DataTableFilters as ot } from "./components/data-table-filters.js";
11
- import { DataTablePaginationComponent as at } from "./components/data-table-pagination.js";
12
- import { DataTableSearchbar as it } from "./components/data-table-searchbar.js";
13
- import { DataTableSortingComponent as st } from "./components/data-table-sorting.js";
14
- import { applySearchFilterToRow as Re, debounce as lt, buildSearchFilter as ct, updatePageSizeFromContainer as ut, createDefaultAdvancedFilter as dt, createBadgeFilterFromHeader as mt } from "./data-table.service.js";
15
- import { DataTableActionsComponent as gt } from "./components/data-table-actions.js";
16
- import { defaultDataTableI18n as pt } from "./data-table-i18n.js";
17
- import { getPaginationRowModel as ft, getFilteredRowModel as ht, getSortedRowModel as bt, getCoreRowModel as Ft } from "../../../../node_modules/@tanstack/table-core/build/lib/index.js";
18
- function Gt({
19
- columns: Q,
8
+ import { DataTableBody as it } from "./components/data-table-body.js";
9
+ import { DataTableColumnVisibility as st } from "./components/data-table-column-visibility.js";
10
+ import { DataTableFilters as lt } from "./components/data-table-filters.js";
11
+ import { DataTablePaginationComponent as ct } from "./components/data-table-pagination.js";
12
+ import { DataTableSearchbar as ut } from "./components/data-table-searchbar.js";
13
+ import { DataTableSortingComponent as dt } from "./components/data-table-sorting.js";
14
+ import { applySearchFilterToRow as we, debounce as gt, buildSearchFilter as mt, updatePageSizeFromContainer as pt, createDefaultAdvancedFilter as ft, createBadgeFilterFromHeader as ht } from "./data-table.service.js";
15
+ import { DataTableActionsComponent as St } from "./components/data-table-actions.js";
16
+ import { defaultDataTableI18n as bt } from "./data-table-i18n.js";
17
+ import { getPaginationRowModel as vt, getFilteredRowModel as Ft, getSortedRowModel as Ct, getCoreRowModel as xt } from "../../../../node_modules/@tanstack/table-core/build/lib/index.js";
18
+ function Vt({
19
+ columns: Y,
20
20
  data: j,
21
- loading: B = !1,
22
- emptyComponent: Ie,
23
- className: Se,
21
+ loading: z = !1,
22
+ emptyComponent: Re,
23
+ className: Ie,
24
24
  rowSelection: Te = {},
25
- onRowSelectionChange: ie,
25
+ onRowSelectionChange: se,
26
26
  checkable: P = !1,
27
- onCheckedRowsChange: Y,
27
+ onCheckedRowsChange: Z,
28
28
  actions: ze = [],
29
- customComponentsLeft: ve,
29
+ customComponentsLeft: De,
30
30
  customComponentsRight: Be,
31
- hidePagination: Me = !1,
32
- hideActionsRow: _e = !1,
33
- i18n: h = pt,
34
- maxSortedColumns: se = 2,
31
+ hidePagination: _e = !1,
32
+ hideActionsRow: Me = !1,
33
+ i18n: h = bt,
34
+ maxSortedColumns: le = 2,
35
35
  initialState: d,
36
36
  // New mode-based API
37
- serverMode: a = !1,
38
- serverConfig: m,
39
- disableAutoPageSize: F = !1
37
+ serverMode: He = !1,
38
+ serverConfig: Ne,
39
+ disableAutoPageSize: b = !1
40
40
  }) {
41
- const q = f(null), le = (e) => !e || !e.sort_by || !e.sort_order ? [] : e.sort_by.map((t, o) => ({
41
+ const q = f(null), a = He === !0, g = a ? Ne : void 0, ce = (e) => !e || !e.sort_by || !e.sort_order ? [] : e.sort_by.map((t, o) => ({
42
42
  id: t,
43
43
  desc: e.sort_order[o] === "desc"
44
- })), De = (e) => {
45
- const t = le(e?.sorting), o = {
46
- sort_by: t.map((l) => l.id),
47
- sort_order: t.map((l) => l.desc ? "desc" : "asc")
44
+ })), Oe = (e) => {
45
+ const t = ce(e?.sorting), o = {
46
+ sort_by: t.map((s) => s.id),
47
+ sort_order: t.map((s) => s.desc ? "desc" : "asc")
48
48
  };
49
49
  return {
50
50
  computedSorting: t.length > 0 ? o : void 0,
51
51
  computedFilter: e?.computedFilter
52
52
  // Use provided value or undefined
53
53
  };
54
- }, [O, He] = u(() => le(d?.sorting)), [Ne] = u([]), [Oe, Ge] = u(
54
+ }, [N, Le] = u(() => ce(d?.sorting)), [Ge] = u([]), [ke, Ae] = u(
55
55
  () => d?.columnVisibility ?? {}
56
- ), [g, Le] = u(() => d?.filters?.searchbarFilter), [E, G] = u(() => d?.pagination ?? { pageIndex: 0, pageSize: 10 }), ce = f(m);
57
- ce.current = m;
58
- const W = f(m?.onStateChange);
59
- W.current = m?.onStateChange;
60
- const J = f(null), M = f(null), ke = f(0), ue = f(!1), de = f(null), K = f({}), me = f(null), Z = f(B);
61
- Z.current = B;
56
+ ), [m, Ve] = u(() => d?.filters?.searchbarFilter), [K, O] = u(() => d?.pagination ?? { pageIndex: 0, pageSize: 10 }), ue = f(g);
57
+ ue.current = g;
58
+ const E = f(g?.onStateChange);
59
+ E.current = g?.onStateChange;
60
+ const W = f(null), D = f(null), je = f(0), de = f(!1), ge = f(null), J = f({}), me = f(null), $ = f(z);
61
+ $.current = z;
62
62
  const L = (e) => {
63
- e.computedFilter && (K.current.computedFilter = e.computedFilter), e.computedSorting && (K.current.computedSorting = e.computedSorting);
63
+ e.computedFilter && (J.current.computedFilter = e.computedFilter), e.computedSorting && (J.current.computedSorting = e.computedSorting);
64
64
  const t = {
65
65
  ...e,
66
66
  // Use new computed values if available, otherwise use last known values
67
- computedFilter: e.computedFilter || K.current.computedFilter,
68
- computedSorting: e.computedSorting || K.current.computedSorting
67
+ computedFilter: e.computedFilter || J.current.computedFilter,
68
+ computedSorting: e.computedSorting || J.current.computedSorting
69
69
  };
70
- J.current = t, M.current && clearTimeout(M.current), M.current = setTimeout(() => {
71
- J.current && W.current && (ke.current = Date.now(), W.current(J.current), J.current = null, M.current = null);
70
+ W.current = t, D.current && clearTimeout(D.current), D.current = setTimeout(() => {
71
+ W.current && E.current && (je.current = Date.now(), E.current(W.current), W.current = null, D.current = null);
72
72
  }, 400);
73
73
  };
74
- N(() => {
74
+ H(() => {
75
75
  const e = setTimeout(() => {
76
- ue.current = !0;
76
+ de.current = !0;
77
77
  }, 100);
78
78
  return () => {
79
- clearTimeout(e), M.current && clearTimeout(M.current);
79
+ clearTimeout(e), D.current && clearTimeout(D.current);
80
80
  };
81
81
  }, []);
82
- const [n, k] = u(() => {
83
- const { computedSorting: e, computedFilter: t } = De(d);
82
+ const [r, G] = u(() => {
83
+ const { computedSorting: e, computedFilter: t } = Oe(d);
84
84
  return {
85
85
  pagination: d?.pagination ?? { pageIndex: 0, pageSize: 10 },
86
86
  sorting: d?.sorting,
@@ -89,10 +89,10 @@ function Gt({
89
89
  computedSorting: d?.computedSorting ?? e
90
90
  };
91
91
  });
92
- a && !m && console.warn("DataTable: Server mode requires serverConfig");
93
- const [Ae, ge] = u(0), [Ve, pe] = u(0), [je, Pe] = u({}), fe = ie ? Te : je, qe = ie || Pe, [w, $] = u(
92
+ a && !g && console.warn("DataTable: Server mode requires serverConfig");
93
+ const [Pe, pe] = u(0), [qe, fe] = u(0), [Ke, Ee] = u({}), he = se ? Te : Ke, We = se || Ee, [C, ee] = u(
94
94
  () => d?.filters?.filterBadges ?? []
95
- ), [y, ee] = u(() => d?.filters?.advancedFilterBadge), [U, Ee] = u(""), [he, be] = u([]), Fe = C(() => P ? [
95
+ ), [x, te] = u(() => d?.filters?.advancedFilterBadge), [U, Je] = u(""), [Se, be] = u([]), ve = F(() => P ? [
96
96
  {
97
97
  id: "data-table-integrated-checkbox-column",
98
98
  size: 24,
@@ -142,176 +142,181 @@ function Gt({
142
142
  listOptions: []
143
143
  }
144
144
  },
145
- ...Q
146
- ] : Q, [Q, P]), T = C(() => Fe.map(
145
+ ...Y
146
+ ] : Y, [Y, P]), I = F(() => ve.map(
147
147
  (e) => e
148
- ), [Fe]);
149
- N(() => {
150
- const e = (T ?? []).map((s) => s?.id ?? s?.accessorKey).filter(Boolean), t = new Set(he), o = new Set(e);
151
- t.size === o.size && [...t].every((s) => o.has(s)) || be(e);
152
- }, [T]);
153
- const _ = C(() => T.filter(
154
- (e) => !!e?.meta?.searchable
155
- ), [T]), z = C(() => _.map((e) => e.accessorKey ?? e.id).filter(Boolean), [_]), [X, We] = u(() => d?.computedFilter ?? {}), Je = {
156
- data: C(() => a || Object.keys(X).length === 0 ? j : j.filter((e) => Re({
148
+ ), [ve]), X = (e) => {
149
+ if (e.id) return e.id;
150
+ if ("accessorKey" in e && typeof e.accessorKey == "string")
151
+ return e.accessorKey;
152
+ }, Ue = (e) => {
153
+ const t = e.meta?.headerLabel;
154
+ return t || (typeof e.header == "string" ? e.header : X(e) ?? "-");
155
+ };
156
+ H(() => {
157
+ const e = (I ?? []).map(X).filter((l) => !!l), t = new Set(Se), o = new Set(e);
158
+ t.size === o.size && [...t].every((l) => o.has(l)) || be(e);
159
+ }, [I]);
160
+ const B = F(() => I.filter((e) => !!e.meta?.searchable), [I]), T = F(() => B.map((e) => "accessorKey" in e && typeof e.accessorKey == "string" ? e.accessorKey : e.id).filter((e) => !!e), [B]), [Q, Xe] = u(() => d?.computedFilter ?? {}), Qe = {
161
+ data: F(() => a || Object.keys(Q).length === 0 ? j : j.filter((e) => we({
157
162
  original: e,
158
163
  getValue: (o) => e[o]
159
- }, X)), [j, X, a]),
160
- columns: T,
161
- getCoreRowModel: Ft(),
164
+ }, Q)), [j, Q, a]),
165
+ columns: I,
166
+ getCoreRowModel: xt(),
162
167
  onSortingChange: (e) => {
163
- const t = typeof e == "function" ? e(O) : e;
164
- He(t);
168
+ const t = typeof e == "function" ? e(N) : e;
169
+ Le(t);
165
170
  },
166
- getSortedRowModel: bt(),
171
+ getSortedRowModel: Ct(),
167
172
  manualSorting: a,
168
- onColumnVisibilityChange: Ge,
169
- onRowSelectionChange: qe,
173
+ onColumnVisibilityChange: Ae,
174
+ onRowSelectionChange: We,
170
175
  onColumnOrderChange: be,
171
- getFilteredRowModel: ht(),
176
+ getFilteredRowModel: Ft(),
172
177
  manualFiltering: a,
173
- globalFilterFn: (e, t, o) => a || !o ? !0 : (z ?? []).some((l) => {
174
- const s = e.getValue(l);
175
- return Array.isArray(s) ? s.some(
178
+ globalFilterFn: (e, t, o) => a || !o ? !0 : (T ?? []).some((s) => {
179
+ const l = e.getValue(s);
180
+ return Array.isArray(l) ? l.some(
176
181
  (p) => String(p).toLowerCase().includes(o.toLowerCase())
177
- ) : String(s).toLowerCase().includes(o.toLowerCase());
182
+ ) : String(l).toLowerCase().includes(o.toLowerCase());
178
183
  }) ?? !1,
179
184
  filterFns: {
180
- advancedFilter: (e) => a ? !0 : Re(e, X)
185
+ advancedFilter: (e) => a ? !0 : we(e, Q)
181
186
  },
182
187
  onPaginationChange: (e) => {
183
- if (a && m) {
188
+ if (a && g) {
184
189
  if (typeof e == "object") {
185
- const t = F ? {
186
- ...n.pagination,
190
+ const t = b ? {
191
+ ...r.pagination,
187
192
  pageIndex: e.pageIndex
188
193
  } : {
189
- ...n.pagination,
194
+ ...r.pagination,
190
195
  pageIndex: e.pageIndex,
191
196
  pageSize: e.pageSize
192
197
  }, o = {
193
- ...n,
198
+ ...r,
194
199
  pagination: t,
195
200
  // Preserve computed values if they exist
196
- computedFilter: n.computedFilter,
197
- computedSorting: n.computedSorting
201
+ computedFilter: r.computedFilter,
202
+ computedSorting: r.computedSorting
198
203
  };
199
- k(o), L(o);
204
+ G(o), L(o);
200
205
  }
201
206
  } else
202
- G(
203
- typeof e == "object" ? (t) => F ? { ...t, pageIndex: e.pageIndex } : {
207
+ O(
208
+ typeof e == "object" ? (t) => b ? { ...t, pageIndex: e.pageIndex } : {
204
209
  pageIndex: e.pageIndex,
205
210
  pageSize: e.pageSize
206
211
  } : e
207
212
  );
208
213
  },
209
- getPaginationRowModel: ft(),
214
+ getPaginationRowModel: vt(),
210
215
  manualPagination: a,
211
- pageCount: a && B ? Ve : Ae,
216
+ pageCount: a && z ? qe : Pe,
212
217
  state: {
213
- sorting: O,
214
- columnFilters: Ne,
215
- columnVisibility: Oe,
216
- rowSelection: fe,
217
- globalFilter: g,
218
- pagination: a ? n.pagination : E,
219
- columnOrder: he
218
+ sorting: N,
219
+ columnFilters: Ge,
220
+ columnVisibility: ke,
221
+ rowSelection: he,
222
+ globalFilter: m,
223
+ pagination: a ? r.pagination : K,
224
+ columnOrder: Se
220
225
  },
221
226
  // Prevent implicit resets on data/columns changes so filters/sorting persist
222
227
  autoResetPageIndex: !1
223
- }, i = $e(Je), te = i.getFilteredRowModel();
224
- N(() => {
225
- if (a && m) {
228
+ }, i = nt(Qe), re = i.getFilteredRowModel();
229
+ H(() => {
230
+ if (a && g) {
226
231
  const e = Math.ceil(
227
- m.totalItems / (n.pagination.pageSize || 10)
232
+ g.totalItems / (r.pagination.pageSize || 10)
228
233
  );
229
- ge(e), !B && e > 0 && pe(e);
234
+ pe(e), !z && e > 0 && fe(e);
230
235
  } else {
231
- const e = te.rows.length, t = Math.ceil(e / E.pageSize);
232
- ge(t), pe(t);
236
+ const e = re.rows.length, t = Math.ceil(e / K.pageSize);
237
+ pe(t), fe(t);
233
238
  }
234
239
  }, [
235
240
  a,
236
- m?.totalItems,
237
- n.pagination.pageSize,
238
- n.pagination.pageIndex,
241
+ g?.totalItems,
242
+ r.pagination.pageSize,
243
+ r.pagination.pageIndex,
239
244
  i,
240
- te,
241
- E.pageSize,
242
- B
243
- ]), N(() => {
244
- if (F) return;
245
+ re,
246
+ K.pageSize,
247
+ z
248
+ ]), H(() => {
249
+ if (b) return;
245
250
  const e = () => {
246
- const R = q.current;
247
- if (!R) return;
248
- const D = R.querySelector(
251
+ const y = q.current;
252
+ if (!y) return;
253
+ const _ = y.querySelector(
249
254
  "thead tr"
250
- ), r = R.querySelector(
255
+ ), n = y.querySelector(
251
256
  "tbody tr"
252
- ), I = D?.getBoundingClientRect().height ?? 40;
253
- if (!!!r?.querySelector("td")) return;
254
- const v = r?.getBoundingClientRect().height ?? 32.5;
255
- ut(R, {
256
- rowHeight: v,
257
- headerHeight: I,
258
- onPageChange: a ? (S, x) => {
259
- if (m && ue.current) {
260
- const b = F ? {
261
- ...n.pagination,
262
- pageIndex: S
257
+ ), w = _?.getBoundingClientRect().height ?? 40;
258
+ if (!!!n?.querySelector("td")) return;
259
+ const A = n?.getBoundingClientRect().height ?? 32.5;
260
+ pt(y, {
261
+ rowHeight: A,
262
+ headerHeight: w,
263
+ onPageChange: a ? (R, v) => {
264
+ if (g && de.current) {
265
+ const S = b ? {
266
+ ...r.pagination,
267
+ pageIndex: R
263
268
  } : {
264
- ...n.pagination,
265
- pageIndex: S,
266
- pageSize: x
267
- }, re = b.pageIndex === n.pagination.pageIndex, oe = F || b.pageSize === n.pagination.pageSize;
268
- if (re && oe)
269
+ ...r.pagination,
270
+ pageIndex: R,
271
+ pageSize: v
272
+ }, oe = S.pageIndex === r.pagination.pageIndex, ae = b || S.pageSize === r.pagination.pageSize;
273
+ if (oe && ae)
269
274
  return;
270
275
  const V = {
271
- ...n,
272
- pagination: b,
276
+ ...r,
277
+ pagination: S,
273
278
  // Preserve computed values if they exist
274
- computedFilter: n.computedFilter,
275
- computedSorting: n.computedSorting
279
+ computedFilter: r.computedFilter,
280
+ computedSorting: r.computedSorting
276
281
  };
277
- k(V), Z.current || L(V);
282
+ G(V), $.current || L(V);
278
283
  }
279
- } : (S, x) => {
280
- G(
281
- (b) => F ? { ...b, pageIndex: S } : { pageIndex: S, pageSize: x }
284
+ } : (R, v) => {
285
+ O(
286
+ (S) => b ? { ...S, pageIndex: R } : { pageIndex: R, pageSize: v }
282
287
  );
283
288
  },
284
- setPagination: (S) => {
285
- const x = typeof S == "function" ? S(n.pagination) : S;
286
- if (a && m) {
287
- const b = F ? {
288
- ...n.pagination,
289
- pageIndex: x.pageIndex
289
+ setPagination: (R) => {
290
+ const v = typeof R == "function" ? R(r.pagination) : R;
291
+ if (a && g) {
292
+ const S = b ? {
293
+ ...r.pagination,
294
+ pageIndex: v.pageIndex
290
295
  } : {
291
- ...n.pagination,
292
- pageIndex: x.pageIndex,
293
- pageSize: x.pageSize
294
- }, re = b.pageIndex === n.pagination.pageIndex, oe = F || b.pageSize === n.pagination.pageSize;
295
- if (re && oe)
296
+ ...r.pagination,
297
+ pageIndex: v.pageIndex,
298
+ pageSize: v.pageSize
299
+ }, oe = S.pageIndex === r.pagination.pageIndex, ae = b || S.pageSize === r.pagination.pageSize;
300
+ if (oe && ae)
296
301
  return;
297
302
  const V = {
298
- ...n,
299
- pagination: b,
303
+ ...r,
304
+ pagination: S,
300
305
  // Preserve computed values if they exist
301
- computedFilter: n.computedFilter,
302
- computedSorting: n.computedSorting
306
+ computedFilter: r.computedFilter,
307
+ computedSorting: r.computedSorting
303
308
  };
304
- k(V), Z.current || L(V);
309
+ G(V), $.current || L(V);
305
310
  } else
306
- G(
307
- (b) => F ? { ...b, pageIndex: x.pageIndex } : {
308
- pageIndex: x.pageIndex,
309
- pageSize: x.pageSize
311
+ O(
312
+ (S) => b ? { ...S, pageIndex: v.pageIndex } : {
313
+ pageIndex: v.pageIndex,
314
+ pageSize: v.pageSize
310
315
  }
311
316
  );
312
317
  }
313
318
  });
314
- }, t = lt(() => {
319
+ }, t = gt(() => {
315
320
  requestAnimationFrame(() => {
316
321
  e();
317
322
  });
@@ -321,240 +326,240 @@ function Gt({
321
326
  e();
322
327
  });
323
328
  });
324
- const o = setTimeout(e, 200), l = document.fonts;
325
- l && typeof l.ready?.then == "function" && l.ready.then(() => e()), window.addEventListener("resize", t);
326
- const s = q.current, p = typeof ResizeObserver < "u" ? new ResizeObserver((R) => {
327
- const D = R[0];
328
- if (!D) return;
329
- const r = D.contentRect.height, I = me.current;
330
- (I === null || Math.abs(r - I) > 0.5) && (me.current = r, t());
329
+ const o = setTimeout(e, 200), s = document.fonts;
330
+ s && typeof s.ready?.then == "function" && s.ready.then(() => e()), window.addEventListener("resize", t);
331
+ const l = q.current, p = typeof ResizeObserver < "u" ? new ResizeObserver((y) => {
332
+ const _ = y[0];
333
+ if (!_) return;
334
+ const n = _.contentRect.height, w = me.current;
335
+ (w === null || Math.abs(n - w) > 0.5) && (me.current = n, t());
331
336
  }) : null;
332
- return s && p && p.observe(s), () => {
337
+ return l && p && p.observe(l), () => {
333
338
  window.removeEventListener("resize", t), clearTimeout(o), p && p.disconnect(), clearTimeout(o);
334
339
  };
335
340
  }, [
336
341
  a,
337
342
  q,
338
- F,
343
+ b,
339
344
  // Recalculate when the rendered rows count changes; helps when data arrives async
340
- te.rows.length
341
- ]), N(() => {
342
- if (Y && P) {
345
+ re.rows.length
346
+ ]), H(() => {
347
+ if (Z && P) {
343
348
  const e = i.getFilteredSelectedRowModel().rows.map((t) => t.original);
344
- Y(e);
349
+ Z(e);
345
350
  }
346
- }, [i, Y, P, fe]);
347
- const Ke = C(() => {
351
+ }, [i, Z, P, he]);
352
+ const Ye = F(() => {
348
353
  const e = i.getHeaderGroups()[0], t = e ? e.headers : [];
349
- return (i.getState().sorting || []).map((s) => t.find((p) => p.column.id === s.id)).filter(Boolean);
354
+ return (i.getState().sorting || []).map((l) => t.find((p) => p.column.id === l.id)).filter(Boolean);
350
355
  }, [
351
356
  i.getHeaderGroups,
352
357
  i.getState().sorting,
353
- T
354
- ]), ne = C(() => i.getHeaderGroups()[0].headers.filter((e) => e.column.columnDef.meta?.sortable), [i.getHeaderGroups, T]), A = C(() => i.getHeaderGroups()[0].headers.filter((e) => e.column.columnDef.meta?.filterable), [i.getHeaderGroups, T]), Ue = C(() => U ? A.filter((e) => (e.column.columnDef.header?.toString().toLowerCase() || "").includes(U.toLowerCase())) : A, [A, U]), xe = (e) => {
355
- $((t) => [...t, mt(e)]);
356
- }, Xe = () => {
357
- ee(dt());
358
- }, Qe = C(() => w.sort((e, t) => e.value === void 0 || e.value === "" ? 1 : t.value === void 0 || t.value === "" ? -1 : 1), [w]), Ce = f({
358
+ I
359
+ ]), ne = F(() => i.getHeaderGroups()[0].headers.filter((e) => e.column.columnDef.meta?.sortable), [i.getHeaderGroups, I]), k = F(() => i.getHeaderGroups()[0].headers.filter((e) => e.column.columnDef.meta?.filterable), [i.getHeaderGroups, I]), Ze = F(() => U ? k.filter((e) => (e.column.columnDef.meta?.headerLabel ?? (typeof e.column.columnDef.header == "string" ? e.column.columnDef.header : void 0) ?? e.column.id).toLowerCase().includes(U.toLowerCase())) : k, [k, U]), Fe = (e) => {
360
+ ee((t) => [...t, ht(e)]);
361
+ }, $e = () => {
362
+ te(ft());
363
+ }, et = F(() => C.sort((e, t) => e.value === void 0 || e.value === "" ? 1 : t.value === void 0 || t.value === "" ? -1 : 1), [C]), Ce = f({
359
364
  filterBadges: [],
360
365
  advancedFilterBadge: void 0,
361
366
  searchbarGlobalFilter: void 0
362
367
  });
363
- N(() => {
364
- const e = ct(
365
- w,
366
- y ?? void 0
367
- ), t = g && z.length > 0 ? z.length === 1 ? (() => {
368
- const r = z[0], H = _.find(
369
- (v) => (v.accessorKey ?? v.id) === r
368
+ H(() => {
369
+ const e = mt(
370
+ C,
371
+ x ?? void 0
372
+ ), t = m && T.length > 0 ? T.length === 1 ? (() => {
373
+ const n = T[0], M = B.find(
374
+ (A) => X(A) === n
370
375
  )?.meta?.type;
371
- return H === "list_multi_select" || H === "list_single_select" ? {
372
- [r]: {
376
+ return M === "list_multi_select" || M === "list_single_select" ? {
377
+ [n]: {
373
378
  operator: "array_overlap",
374
- value: [g]
379
+ value: [m]
375
380
  }
376
381
  } : {
377
- [r]: {
382
+ [n]: {
378
383
  operator: "like",
379
- value: g
384
+ value: m
380
385
  }
381
386
  };
382
387
  })() : {
383
- _or: z.map((r) => {
384
- const H = _.find(
385
- (v) => (v.accessorKey ?? v.id) === r
388
+ _or: T.map((n) => {
389
+ const M = B.find(
390
+ (A) => X(A) === n
386
391
  )?.meta?.type;
387
- return H === "list_multi_select" || H === "list_single_select" ? {
388
- [r]: {
392
+ return M === "list_multi_select" || M === "list_single_select" ? {
393
+ [n]: {
389
394
  operator: "array_overlap",
390
- value: [g]
395
+ value: [m]
391
396
  }
392
397
  } : {
393
- [r]: {
398
+ [n]: {
394
399
  operator: "like",
395
- value: g
400
+ value: m
396
401
  }
397
402
  };
398
403
  })
399
404
  } : null, o = [
400
405
  ...e && Object.keys(e).length > 0 ? [e] : [],
401
406
  ...t ? [t] : []
402
- ], l = o.length === 0 ? {} : o.length === 1 ? o[0] : { _and: o }, s = {
403
- sort_by: O.map((r) => r.id),
404
- sort_order: O.map((r) => r.desc ? "desc" : "asc")
405
- }, p = Ce.current, R = JSON.stringify(w) !== JSON.stringify(p.filterBadges) || JSON.stringify(y) !== JSON.stringify(p.advancedFilterBadge) || g !== p.searchbarGlobalFilter;
407
+ ], s = o.length === 0 ? {} : o.length === 1 ? o[0] : { _and: o }, l = {
408
+ sort_by: N.map((n) => n.id),
409
+ sort_order: N.map((n) => n.desc ? "desc" : "asc")
410
+ }, p = Ce.current, y = JSON.stringify(C) !== JSON.stringify(p.filterBadges) || JSON.stringify(x) !== JSON.stringify(p.advancedFilterBadge) || m !== p.searchbarGlobalFilter;
406
411
  Ce.current = {
407
- filterBadges: [...w],
408
- advancedFilterBadge: y ? { ...y } : void 0,
409
- searchbarGlobalFilter: g
412
+ filterBadges: [...C],
413
+ advancedFilterBadge: x ? { ...x } : void 0,
414
+ searchbarGlobalFilter: m
410
415
  };
411
- const D = ce.current;
412
- if (We(l), a && W.current && D) {
413
- const r = {
414
- ...n,
415
- computedFilter: l,
416
+ const _ = ue.current;
417
+ if (Xe(s), a && E.current && _) {
418
+ const n = {
419
+ ...r,
420
+ computedFilter: s,
416
421
  // Emit only computedSorting. Use empty arrays to signal "no sorting" when cleared.
417
- computedSorting: s,
422
+ computedSorting: l,
418
423
  filters: {
419
- filterBadges: w,
420
- advancedFilterBadge: y,
421
- searchbarFilter: g
424
+ filterBadges: C,
425
+ advancedFilterBadge: x,
426
+ searchbarFilter: m
422
427
  },
423
428
  pagination: {
424
- ...n.pagination,
429
+ ...r.pagination,
425
430
  // Only reset pageIndex to 0 when filters actually changed, not when just sorting changed
426
- pageIndex: R ? 0 : n.pagination.pageIndex
431
+ pageIndex: y ? 0 : r.pagination.pageIndex
427
432
  }
428
433
  };
429
- k(r);
430
- const I = JSON.stringify({
431
- computedFilter: r.computedFilter,
432
- computedSorting: r.computedSorting,
433
- filters: r.filters,
434
- pagination: r.pagination
434
+ G(n);
435
+ const w = JSON.stringify({
436
+ computedFilter: n.computedFilter,
437
+ computedSorting: n.computedSorting,
438
+ filters: n.filters,
439
+ pagination: n.pagination
435
440
  });
436
- de.current !== I && (de.current = I, L(r));
441
+ ge.current !== w && (ge.current = w, L(n));
437
442
  } else
438
- R && G((r) => ({
439
- ...r,
443
+ y && O((n) => ({
444
+ ...n,
440
445
  pageIndex: 0
441
446
  }));
442
447
  }, [
443
- w,
444
- y,
445
- g,
446
- z,
447
- _,
448
- O,
448
+ C,
449
+ x,
450
+ m,
451
+ T,
452
+ B,
453
+ N,
449
454
  a
450
455
  ]);
451
- const we = i.getAllLeafColumns(), Ye = we.filter((e) => e.getIsVisible()), Ze = we.filter((e) => !e.getIsVisible());
452
- return /* @__PURE__ */ ae(
456
+ const xe = i.getAllLeafColumns(), tt = xe.filter((e) => e.getIsVisible()), rt = xe.filter((e) => !e.getIsVisible());
457
+ return /* @__PURE__ */ ie(
453
458
  "div",
454
459
  {
455
- className: et(
460
+ className: ot(
456
461
  "flex h-full max-h-full min-h-[250px] w-full max-w-full min-w-0 flex-col gap-2",
457
- Se
462
+ Ie
458
463
  ),
459
464
  children: [
460
- !_e && /* @__PURE__ */ ae("div", { className: "flex w-full items-center justify-between gap-1", children: [
461
- /* @__PURE__ */ ae("div", { className: "flex min-w-0 flex-1 items-center gap-1 overflow-x-auto", children: [
465
+ !Me && /* @__PURE__ */ ie("div", { className: "flex w-full items-center justify-between gap-1", children: [
466
+ /* @__PURE__ */ ie("div", { className: "flex min-w-0 flex-1 items-center gap-1 overflow-x-auto", children: [
462
467
  ne.length > 0 && /* @__PURE__ */ c(
463
- st,
468
+ dt,
464
469
  {
465
470
  table: i,
466
- sortedColumns: Ke,
471
+ sortedColumns: Ye,
467
472
  sortableColumns: ne,
468
473
  i18n: h,
469
- maxSortedColumns: se
474
+ maxSortedColumns: le
470
475
  }
471
476
  ),
472
- ne.length > 0 && A.length > 0 && /* @__PURE__ */ c("div", { className: "border-d-border h-4 min-h-4 w-[1px] border-r" }),
473
- ve,
477
+ ne.length > 0 && k.length > 0 && /* @__PURE__ */ c("div", { className: "border-d-border h-4 min-h-4 w-[1px] border-r" }),
478
+ De,
474
479
  /* @__PURE__ */ c(
475
- ot,
480
+ lt,
476
481
  {
477
- advancedFilterBadge: y,
478
- setAdvancedFilterBadge: ee,
479
- filterableColumns: A,
480
- sortedFilterBadges: Qe,
481
- setFilterBadges: $,
482
+ advancedFilterBadge: x,
483
+ setAdvancedFilterBadge: te,
484
+ filterableColumns: k,
485
+ sortedFilterBadges: et,
486
+ setFilterBadges: ee,
482
487
  filterSearch: U,
483
- setFilterSearch: Ee,
484
- filteredColumns: Ue,
485
- handleAddFilter: xe,
486
- handleAddAdvancedFilter: Xe,
488
+ setFilterSearch: Je,
489
+ filteredColumns: Ze,
490
+ handleAddFilter: Fe,
491
+ handleAddAdvancedFilter: $e,
487
492
  i18n: h
488
493
  }
489
494
  )
490
495
  ] }),
491
496
  /* @__PURE__ */ c("div", { className: "border-d-border h-4 min-h-4 w-[1px] border-r" }),
492
497
  Be,
493
- (w.length || y) && /* @__PURE__ */ c(
494
- tt,
498
+ (C.length || x) && /* @__PURE__ */ c(
499
+ at,
495
500
  {
496
501
  className: "h-6 text-xs",
497
502
  iconLeft: "FunnelX",
498
503
  size: "sm",
499
504
  variant: "ghost-destructive",
500
505
  onClick: () => {
501
- $([]), ee(void 0);
506
+ ee([]), te(void 0);
502
507
  },
503
508
  children: h.reset
504
509
  }
505
510
  ),
506
- z.length > 0 && /* @__PURE__ */ c(
507
- it,
511
+ T.length > 0 && /* @__PURE__ */ c(
512
+ ut,
508
513
  {
509
514
  debounceMs: 300,
510
- onSearch: Le,
515
+ onSearch: Ve,
511
516
  i18n: h,
512
- initialValue: g ?? "",
513
- searchableColumnsHeaders: _.map(
514
- (e) => e.header ? e.header.toString() : e.id?.toString() ?? "-"
517
+ initialValue: m ?? "",
518
+ searchableColumnsHeaders: B.map(
519
+ (e) => Ue(e)
515
520
  )
516
521
  }
517
522
  ),
518
523
  /* @__PURE__ */ c(
519
- rt,
524
+ st,
520
525
  {
521
526
  table: i,
522
- visibleColumns: Ye,
523
- hiddenColumns: Ze,
527
+ visibleColumns: tt,
528
+ hiddenColumns: rt,
524
529
  i18n: h
525
530
  }
526
531
  ),
527
- /* @__PURE__ */ c(gt, { actions: ze, i18n: h })
532
+ /* @__PURE__ */ c(St, { actions: ze, i18n: h })
528
533
  ] }),
529
534
  /* @__PURE__ */ c(
530
- nt,
535
+ it,
531
536
  {
532
537
  table: i,
533
538
  tableContainerRef: q,
534
- loading: B,
539
+ loading: z,
535
540
  data: j,
536
- emptyComponent: Ie,
541
+ emptyComponent: Re,
537
542
  notFoundMessage: h?.notFoundMessage ?? "N/A",
538
- onAddFilter: xe,
539
- maxSortedColumns: se,
543
+ onAddFilter: Fe,
544
+ maxSortedColumns: le,
540
545
  i18n: h,
541
546
  isServerSide: a,
542
- filterBadges: w,
543
- advancedFilterBadge: y,
544
- searchbarGlobalFilter: g
547
+ filterBadges: C,
548
+ advancedFilterBadge: x,
549
+ searchbarGlobalFilter: m
545
550
  }
546
551
  ),
547
- !Me && /* @__PURE__ */ c(
548
- at,
552
+ !_e && /* @__PURE__ */ c(
553
+ ct,
549
554
  {
550
555
  table: i,
551
556
  isServerSide: a,
552
- clientPagination: E,
553
- serverState: a ? n : void 0,
554
- onServerStateChange: a && m ? (e) => {
555
- k(e), L(e);
557
+ clientPagination: K,
558
+ serverState: a ? r : void 0,
559
+ onServerStateChange: a && g ? (e) => {
560
+ G(e), L(e);
556
561
  } : void 0,
557
- totalItems: m?.totalItems,
562
+ totalItems: g?.totalItems,
558
563
  i18n: h
559
564
  }
560
565
  )
@@ -563,5 +568,5 @@ function Gt({
563
568
  );
564
569
  }
565
570
  export {
566
- Gt as DataTable
571
+ Vt as DataTable
567
572
  };