laif-ds 0.2.42 → 0.2.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index4.js +5 -5
- package/dist/_virtual/index5.js +5 -5
- package/dist/components/ui/spinner.js +67 -0
- package/dist/components/ui/tables/data-table/components/data-table-actions.js +30 -22
- package/dist/components/ui/tables/data-table/components/data-table-advanced-filter.js +92 -89
- package/dist/components/ui/tables/data-table/components/data-table-body.js +216 -169
- package/dist/components/ui/tables/data-table/components/data-table-column-visibility.js +38 -38
- package/dist/components/ui/tables/data-table/components/data-table-filters.js +3 -3
- package/dist/components/ui/tables/data-table/components/data-table-searchbar.js +4 -1
- package/dist/components/ui/tables/data-table/components/data-table-sorting.js +30 -30
- package/dist/components/ui/tables/data-table/data-table.js +136 -129
- package/dist/components/ui/tables/data-table/data-table.service.js +11 -9
- package/dist/components/ui/tables/data-table/data-table.utils.js +302 -0
- package/dist/index.d.ts +398 -1
- package/dist/index.js +377 -348
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.js +1 -1
- package/dist/node_modules/unified/lib/index.js +1 -1
- package/dist/styles.v3.css +1 -1
- package/package.json +1 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as c, jsxs as ae } from "react/jsx-runtime";
|
|
3
|
-
import { useReactTable as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { useRef as
|
|
6
|
-
import { Button as
|
|
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";
|
|
7
7
|
import { Checkbox as ye } from "../../checkbox.js";
|
|
8
|
-
import { DataTableBody as
|
|
9
|
-
import { DataTableColumnVisibility as
|
|
10
|
-
import { DataTableFilters as
|
|
11
|
-
import { DataTablePaginationComponent as
|
|
12
|
-
import { DataTableSearchbar as
|
|
13
|
-
import { DataTableSortingComponent as
|
|
14
|
-
import { applySearchFilterToRow as Re, debounce as
|
|
15
|
-
import { DataTableActionsComponent as
|
|
16
|
-
import { defaultDataTableI18n as
|
|
17
|
-
import { getPaginationRowModel as
|
|
18
|
-
function
|
|
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
19
|
columns: Q,
|
|
20
20
|
data: P,
|
|
21
21
|
loading: B = !1,
|
|
@@ -26,9 +26,11 @@ function Nt({
|
|
|
26
26
|
checkable: V = !1,
|
|
27
27
|
onCheckedRowsChange: Y,
|
|
28
28
|
actions: ze = [],
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
customComponentsLeft: ve,
|
|
30
|
+
customComponentsRight: Be,
|
|
31
|
+
hidePagination: Me = !1,
|
|
32
|
+
hideActionsRow: _e = !1,
|
|
33
|
+
i18n: h = pt,
|
|
32
34
|
maxSortedColumns: se = 2,
|
|
33
35
|
initialState: m,
|
|
34
36
|
// New mode-based API
|
|
@@ -36,10 +38,10 @@ function Nt({
|
|
|
36
38
|
serverConfig: d,
|
|
37
39
|
disableAutoPageSize: F = !1
|
|
38
40
|
}) {
|
|
39
|
-
const q =
|
|
41
|
+
const q = f(null), le = (e) => !e || !e.sort_by || !e.sort_order ? [] : e.sort_by.map((t, o) => ({
|
|
40
42
|
id: t,
|
|
41
43
|
desc: e.sort_order[o] === "desc"
|
|
42
|
-
})),
|
|
44
|
+
})), De = (e) => {
|
|
43
45
|
const t = le(e?.sorting), o = {
|
|
44
46
|
sort_by: t.map((l) => l.id),
|
|
45
47
|
sort_order: t.map((l) => l.desc ? "desc" : "asc")
|
|
@@ -49,11 +51,11 @@ function Nt({
|
|
|
49
51
|
computedFilter: e?.computedFilter
|
|
50
52
|
// Use provided value or undefined
|
|
51
53
|
};
|
|
52
|
-
}, [O,
|
|
54
|
+
}, [O, He] = u(() => le(m?.sorting)), [Ne] = u([]), [Oe, Ge] = u({}), [g, Le] = u(() => m?.filters?.searchbarFilter), [E, G] = u(() => m?.pagination ?? { pageIndex: 0, pageSize: 10 }), ce = f(d);
|
|
53
55
|
ce.current = d;
|
|
54
|
-
const W =
|
|
56
|
+
const W = f(d?.onStateChange);
|
|
55
57
|
W.current = d?.onStateChange;
|
|
56
|
-
const J =
|
|
58
|
+
const J = f(null), M = f(null), ke = f(0), ue = f(!1), de = f(null), K = f({}), me = f(null), Z = f(B);
|
|
57
59
|
Z.current = B;
|
|
58
60
|
const L = (e) => {
|
|
59
61
|
e.computedFilter && (K.current.computedFilter = e.computedFilter), e.computedSorting && (K.current.computedSorting = e.computedSorting);
|
|
@@ -64,7 +66,7 @@ function Nt({
|
|
|
64
66
|
computedSorting: e.computedSorting || K.current.computedSorting
|
|
65
67
|
};
|
|
66
68
|
J.current = t, M.current && clearTimeout(M.current), M.current = setTimeout(() => {
|
|
67
|
-
J.current && W.current && (
|
|
69
|
+
J.current && W.current && (ke.current = Date.now(), W.current(J.current), J.current = null, M.current = null);
|
|
68
70
|
}, 400);
|
|
69
71
|
};
|
|
70
72
|
N(() => {
|
|
@@ -76,7 +78,7 @@ function Nt({
|
|
|
76
78
|
};
|
|
77
79
|
}, []);
|
|
78
80
|
const [n, k] = u(() => {
|
|
79
|
-
const { computedSorting: e, computedFilter: t } =
|
|
81
|
+
const { computedSorting: e, computedFilter: t } = De(m);
|
|
80
82
|
return {
|
|
81
83
|
pagination: m?.pagination ?? { pageIndex: 0, pageSize: 10 },
|
|
82
84
|
sorting: m?.sorting,
|
|
@@ -86,9 +88,9 @@ function Nt({
|
|
|
86
88
|
};
|
|
87
89
|
});
|
|
88
90
|
a && !d && console.warn("DataTable: Server mode requires serverConfig");
|
|
89
|
-
const [
|
|
91
|
+
const [Ae, ge] = u(0), [je, pe] = u(0), [Pe, Ve] = u({}), fe = ie ? Te : Pe, qe = ie || Ve, [w, $] = u(
|
|
90
92
|
() => m?.filters?.filterBadges ?? []
|
|
91
|
-
), [
|
|
93
|
+
), [y, ee] = u(() => m?.filters?.advancedFilterBadge), [U, Ee] = u(""), [he, be] = u([]), Fe = C(() => V ? [
|
|
92
94
|
{
|
|
93
95
|
id: "data-table-integrated-checkbox-column",
|
|
94
96
|
size: 24,
|
|
@@ -105,7 +107,7 @@ function Nt({
|
|
|
105
107
|
className: "cursor-pointer",
|
|
106
108
|
checked: e.getIsAllPageRowsSelected(),
|
|
107
109
|
onCheckedChange: (t) => e.toggleAllPageRowsSelected(!!t),
|
|
108
|
-
"aria-label":
|
|
110
|
+
"aria-label": h.selectAll
|
|
109
111
|
}
|
|
110
112
|
)
|
|
111
113
|
}
|
|
@@ -121,7 +123,7 @@ function Nt({
|
|
|
121
123
|
className: "cursor-pointer",
|
|
122
124
|
checked: e.getIsSelected(),
|
|
123
125
|
onCheckedChange: (t) => e.toggleSelected(!!t),
|
|
124
|
-
"aria-label":
|
|
126
|
+
"aria-label": h.selectRow
|
|
125
127
|
}
|
|
126
128
|
)
|
|
127
129
|
}
|
|
@@ -148,28 +150,28 @@ function Nt({
|
|
|
148
150
|
}, [T]);
|
|
149
151
|
const _ = C(() => T.filter(
|
|
150
152
|
(e) => !!e?.meta?.searchable
|
|
151
|
-
), [T]), z = C(() => _.map((e) => e.
|
|
153
|
+
), [T]), z = C(() => _.map((e) => e.accessorKey ?? e.id).filter(Boolean), [_]), [X, We] = u(() => m?.computedFilter ?? {}), Je = {
|
|
152
154
|
data: C(() => a || Object.keys(X).length === 0 ? P : P.filter((e) => Re({
|
|
153
155
|
original: e,
|
|
154
156
|
getValue: (o) => e[o]
|
|
155
157
|
}, X)), [P, X, a]),
|
|
156
158
|
columns: T,
|
|
157
|
-
getCoreRowModel:
|
|
159
|
+
getCoreRowModel: Ft(),
|
|
158
160
|
onSortingChange: (e) => {
|
|
159
161
|
const t = typeof e == "function" ? e(O) : e;
|
|
160
|
-
|
|
162
|
+
He(t);
|
|
161
163
|
},
|
|
162
|
-
getSortedRowModel:
|
|
164
|
+
getSortedRowModel: bt(),
|
|
163
165
|
manualSorting: a,
|
|
164
|
-
onColumnVisibilityChange:
|
|
165
|
-
onRowSelectionChange:
|
|
166
|
+
onColumnVisibilityChange: Ge,
|
|
167
|
+
onRowSelectionChange: qe,
|
|
166
168
|
onColumnOrderChange: be,
|
|
167
|
-
getFilteredRowModel:
|
|
169
|
+
getFilteredRowModel: ht(),
|
|
168
170
|
manualFiltering: a,
|
|
169
171
|
globalFilterFn: (e, t, o) => a || !o ? !0 : (z ?? []).some((l) => {
|
|
170
172
|
const s = e.getValue(l);
|
|
171
173
|
return Array.isArray(s) ? s.some(
|
|
172
|
-
(
|
|
174
|
+
(p) => String(p).toLowerCase().includes(o.toLowerCase())
|
|
173
175
|
) : String(s).toLowerCase().includes(o.toLowerCase());
|
|
174
176
|
}) ?? !1,
|
|
175
177
|
filterFns: {
|
|
@@ -202,21 +204,21 @@ function Nt({
|
|
|
202
204
|
} : e
|
|
203
205
|
);
|
|
204
206
|
},
|
|
205
|
-
getPaginationRowModel:
|
|
207
|
+
getPaginationRowModel: ft(),
|
|
206
208
|
manualPagination: a,
|
|
207
|
-
pageCount: a && B ?
|
|
209
|
+
pageCount: a && B ? je : Ae,
|
|
208
210
|
state: {
|
|
209
211
|
sorting: O,
|
|
210
|
-
columnFilters:
|
|
211
|
-
columnVisibility:
|
|
212
|
+
columnFilters: Ne,
|
|
213
|
+
columnVisibility: Oe,
|
|
212
214
|
rowSelection: fe,
|
|
213
|
-
globalFilter:
|
|
215
|
+
globalFilter: g,
|
|
214
216
|
pagination: a ? n.pagination : E,
|
|
215
217
|
columnOrder: he
|
|
216
218
|
},
|
|
217
219
|
// Prevent implicit resets on data/columns changes so filters/sorting persist
|
|
218
220
|
autoResetPageIndex: !1
|
|
219
|
-
}, i =
|
|
221
|
+
}, i = $e(Je), te = i.getFilteredRowModel();
|
|
220
222
|
N(() => {
|
|
221
223
|
if (a && d) {
|
|
222
224
|
const e = Math.ceil(
|
|
@@ -239,26 +241,26 @@ function Nt({
|
|
|
239
241
|
]), N(() => {
|
|
240
242
|
if (F) return;
|
|
241
243
|
const e = () => {
|
|
242
|
-
const
|
|
243
|
-
if (!
|
|
244
|
-
const D =
|
|
244
|
+
const R = q.current;
|
|
245
|
+
if (!R) return;
|
|
246
|
+
const D = R.querySelector(
|
|
245
247
|
"thead tr"
|
|
246
|
-
), r =
|
|
248
|
+
), r = R.querySelector(
|
|
247
249
|
"tbody tr"
|
|
248
|
-
),
|
|
250
|
+
), I = D?.getBoundingClientRect().height ?? 40;
|
|
249
251
|
if (!!!r?.querySelector("td")) return;
|
|
250
252
|
const v = r?.getBoundingClientRect().height ?? 32.5;
|
|
251
|
-
|
|
253
|
+
ut(R, {
|
|
252
254
|
rowHeight: v,
|
|
253
|
-
headerHeight:
|
|
254
|
-
onPageChange: a ? (
|
|
255
|
+
headerHeight: I,
|
|
256
|
+
onPageChange: a ? (S, x) => {
|
|
255
257
|
if (d && ue.current) {
|
|
256
258
|
const b = F ? {
|
|
257
259
|
...n.pagination,
|
|
258
|
-
pageIndex:
|
|
260
|
+
pageIndex: S
|
|
259
261
|
} : {
|
|
260
262
|
...n.pagination,
|
|
261
|
-
pageIndex:
|
|
263
|
+
pageIndex: S,
|
|
262
264
|
pageSize: x
|
|
263
265
|
}, re = b.pageIndex === n.pagination.pageIndex, oe = F || b.pageSize === n.pagination.pageSize;
|
|
264
266
|
if (re && oe)
|
|
@@ -272,13 +274,13 @@ function Nt({
|
|
|
272
274
|
};
|
|
273
275
|
k(j), Z.current || L(j);
|
|
274
276
|
}
|
|
275
|
-
} : (
|
|
277
|
+
} : (S, x) => {
|
|
276
278
|
G(
|
|
277
|
-
(b) => F ? { ...b, pageIndex:
|
|
279
|
+
(b) => F ? { ...b, pageIndex: S } : { pageIndex: S, pageSize: x }
|
|
278
280
|
);
|
|
279
281
|
},
|
|
280
|
-
setPagination: (
|
|
281
|
-
const x = typeof
|
|
282
|
+
setPagination: (S) => {
|
|
283
|
+
const x = typeof S == "function" ? S(n.pagination) : S;
|
|
282
284
|
if (a && d) {
|
|
283
285
|
const b = F ? {
|
|
284
286
|
...n.pagination,
|
|
@@ -307,7 +309,7 @@ function Nt({
|
|
|
307
309
|
);
|
|
308
310
|
}
|
|
309
311
|
});
|
|
310
|
-
}, t =
|
|
312
|
+
}, t = lt(() => {
|
|
311
313
|
requestAnimationFrame(() => {
|
|
312
314
|
e();
|
|
313
315
|
});
|
|
@@ -319,14 +321,14 @@ function Nt({
|
|
|
319
321
|
});
|
|
320
322
|
const o = setTimeout(e, 200), l = document.fonts;
|
|
321
323
|
l && typeof l.ready?.then == "function" && l.ready.then(() => e()), window.addEventListener("resize", t);
|
|
322
|
-
const s = q.current,
|
|
323
|
-
const D =
|
|
324
|
+
const s = q.current, p = typeof ResizeObserver < "u" ? new ResizeObserver((R) => {
|
|
325
|
+
const D = R[0];
|
|
324
326
|
if (!D) return;
|
|
325
|
-
const r = D.contentRect.height,
|
|
326
|
-
(
|
|
327
|
+
const r = D.contentRect.height, I = me.current;
|
|
328
|
+
(I === null || Math.abs(r - I) > 0.5) && (me.current = r, t());
|
|
327
329
|
}) : null;
|
|
328
|
-
return s &&
|
|
329
|
-
window.removeEventListener("resize", t), clearTimeout(o),
|
|
330
|
+
return s && p && p.observe(s), () => {
|
|
331
|
+
window.removeEventListener("resize", t), clearTimeout(o), p && p.disconnect(), clearTimeout(o);
|
|
330
332
|
};
|
|
331
333
|
}, [
|
|
332
334
|
a,
|
|
@@ -340,55 +342,55 @@ function Nt({
|
|
|
340
342
|
Y(e);
|
|
341
343
|
}
|
|
342
344
|
}, [i, Y, V, fe]);
|
|
343
|
-
const
|
|
345
|
+
const Ke = C(() => {
|
|
344
346
|
const e = i.getHeaderGroups()[0], t = e ? e.headers : [];
|
|
345
|
-
return (i.getState().sorting || []).map((s) => t.find((
|
|
347
|
+
return (i.getState().sorting || []).map((s) => t.find((p) => p.column.id === s.id)).filter(Boolean);
|
|
346
348
|
}, [
|
|
347
349
|
i.getHeaderGroups,
|
|
348
350
|
i.getState().sorting,
|
|
349
351
|
T
|
|
350
|
-
]), 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]),
|
|
351
|
-
$((t) => [...t,
|
|
352
|
-
},
|
|
353
|
-
ee(
|
|
354
|
-
},
|
|
352
|
+
]), 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) => {
|
|
353
|
+
$((t) => [...t, mt(e)]);
|
|
354
|
+
}, Xe = () => {
|
|
355
|
+
ee(dt());
|
|
356
|
+
}, Qe = C(() => w.sort((e, t) => e.value === void 0 || e.value === "" ? 1 : t.value === void 0 || t.value === "" ? -1 : 1), [w]), Ce = f({
|
|
355
357
|
filterBadges: [],
|
|
356
358
|
advancedFilterBadge: void 0,
|
|
357
359
|
searchbarGlobalFilter: void 0
|
|
358
360
|
});
|
|
359
361
|
N(() => {
|
|
360
|
-
const e =
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
), t =
|
|
362
|
+
const e = ct(
|
|
363
|
+
w,
|
|
364
|
+
y ?? void 0
|
|
365
|
+
), t = g && z.length > 0 ? z.length === 1 ? (() => {
|
|
364
366
|
const r = z[0], H = _.find(
|
|
365
|
-
(v) => (v.
|
|
367
|
+
(v) => (v.accessorKey ?? v.id) === r
|
|
366
368
|
)?.meta?.type;
|
|
367
369
|
return H === "list_multi_select" || H === "list_single_select" ? {
|
|
368
370
|
[r]: {
|
|
369
371
|
operator: "array_overlap",
|
|
370
|
-
value: [
|
|
372
|
+
value: [g]
|
|
371
373
|
}
|
|
372
374
|
} : {
|
|
373
375
|
[r]: {
|
|
374
376
|
operator: "like",
|
|
375
|
-
value:
|
|
377
|
+
value: g
|
|
376
378
|
}
|
|
377
379
|
};
|
|
378
380
|
})() : {
|
|
379
381
|
_or: z.map((r) => {
|
|
380
382
|
const H = _.find(
|
|
381
|
-
(v) => (v.
|
|
383
|
+
(v) => (v.accessorKey ?? v.id) === r
|
|
382
384
|
)?.meta?.type;
|
|
383
385
|
return H === "list_multi_select" || H === "list_single_select" ? {
|
|
384
386
|
[r]: {
|
|
385
387
|
operator: "array_overlap",
|
|
386
|
-
value: [
|
|
388
|
+
value: [g]
|
|
387
389
|
}
|
|
388
390
|
} : {
|
|
389
391
|
[r]: {
|
|
390
392
|
operator: "like",
|
|
391
|
-
value:
|
|
393
|
+
value: g
|
|
392
394
|
}
|
|
393
395
|
};
|
|
394
396
|
})
|
|
@@ -398,94 +400,96 @@ function Nt({
|
|
|
398
400
|
], l = o.length === 0 ? {} : o.length === 1 ? o[0] : { _and: o }, s = {
|
|
399
401
|
sort_by: O.map((r) => r.id),
|
|
400
402
|
sort_order: O.map((r) => r.desc ? "desc" : "asc")
|
|
401
|
-
},
|
|
403
|
+
}, p = Ce.current, R = JSON.stringify(w) !== JSON.stringify(p.filterBadges) || JSON.stringify(y) !== JSON.stringify(p.advancedFilterBadge) || g !== p.searchbarGlobalFilter;
|
|
402
404
|
Ce.current = {
|
|
403
|
-
filterBadges: [...
|
|
404
|
-
advancedFilterBadge:
|
|
405
|
-
searchbarGlobalFilter:
|
|
405
|
+
filterBadges: [...w],
|
|
406
|
+
advancedFilterBadge: y ? { ...y } : void 0,
|
|
407
|
+
searchbarGlobalFilter: g
|
|
406
408
|
};
|
|
407
409
|
const D = ce.current;
|
|
408
|
-
if (
|
|
410
|
+
if (We(l), a && W.current && D) {
|
|
409
411
|
const r = {
|
|
410
412
|
...n,
|
|
411
413
|
computedFilter: l,
|
|
412
414
|
// Emit only computedSorting. Use empty arrays to signal "no sorting" when cleared.
|
|
413
415
|
computedSorting: s,
|
|
414
416
|
filters: {
|
|
415
|
-
filterBadges:
|
|
416
|
-
advancedFilterBadge:
|
|
417
|
-
searchbarFilter:
|
|
417
|
+
filterBadges: w,
|
|
418
|
+
advancedFilterBadge: y,
|
|
419
|
+
searchbarFilter: g
|
|
418
420
|
},
|
|
419
421
|
pagination: {
|
|
420
422
|
...n.pagination,
|
|
421
423
|
// Only reset pageIndex to 0 when filters actually changed, not when just sorting changed
|
|
422
|
-
pageIndex:
|
|
424
|
+
pageIndex: R ? 0 : n.pagination.pageIndex
|
|
423
425
|
}
|
|
424
426
|
};
|
|
425
427
|
k(r);
|
|
426
|
-
const
|
|
428
|
+
const I = JSON.stringify({
|
|
427
429
|
computedFilter: r.computedFilter,
|
|
428
430
|
computedSorting: r.computedSorting,
|
|
429
431
|
filters: r.filters,
|
|
430
432
|
pagination: r.pagination
|
|
431
433
|
});
|
|
432
|
-
de.current !==
|
|
434
|
+
de.current !== I && (de.current = I, L(r));
|
|
433
435
|
} else
|
|
434
|
-
|
|
436
|
+
R && G((r) => ({
|
|
435
437
|
...r,
|
|
436
438
|
pageIndex: 0
|
|
437
439
|
}));
|
|
438
440
|
}, [
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
441
|
+
w,
|
|
442
|
+
y,
|
|
443
|
+
g,
|
|
442
444
|
z,
|
|
443
445
|
_,
|
|
444
446
|
O,
|
|
445
447
|
a
|
|
446
448
|
]);
|
|
447
|
-
const we = i.getAllLeafColumns(),
|
|
449
|
+
const we = i.getAllLeafColumns(), Ye = we.filter((e) => e.getIsVisible()), Ze = we.filter((e) => !e.getIsVisible());
|
|
448
450
|
return /* @__PURE__ */ ae(
|
|
449
451
|
"div",
|
|
450
452
|
{
|
|
451
|
-
className:
|
|
453
|
+
className: et(
|
|
452
454
|
"flex h-full max-h-full min-h-[250px] w-full max-w-full min-w-0 flex-col gap-2",
|
|
453
455
|
Se
|
|
454
456
|
),
|
|
455
457
|
children: [
|
|
456
|
-
!
|
|
458
|
+
!_e && /* @__PURE__ */ ae("div", { className: "flex w-full items-center justify-between gap-1", children: [
|
|
457
459
|
/* @__PURE__ */ ae("div", { className: "flex min-w-0 flex-1 items-center gap-1 overflow-x-auto", children: [
|
|
458
460
|
ne.length > 0 && /* @__PURE__ */ c(
|
|
459
|
-
|
|
461
|
+
st,
|
|
460
462
|
{
|
|
461
463
|
table: i,
|
|
462
|
-
sortedColumns:
|
|
464
|
+
sortedColumns: Ke,
|
|
463
465
|
sortableColumns: ne,
|
|
464
|
-
i18n:
|
|
466
|
+
i18n: h,
|
|
465
467
|
maxSortedColumns: se
|
|
466
468
|
}
|
|
467
469
|
),
|
|
468
470
|
ne.length > 0 && A.length > 0 && /* @__PURE__ */ c("div", { className: "border-d-border h-4 min-h-4 w-[1px] border-r" }),
|
|
471
|
+
ve,
|
|
469
472
|
/* @__PURE__ */ c(
|
|
470
|
-
|
|
473
|
+
ot,
|
|
471
474
|
{
|
|
472
|
-
advancedFilterBadge:
|
|
475
|
+
advancedFilterBadge: y,
|
|
473
476
|
setAdvancedFilterBadge: ee,
|
|
474
477
|
filterableColumns: A,
|
|
475
|
-
sortedFilterBadges:
|
|
478
|
+
sortedFilterBadges: Qe,
|
|
476
479
|
setFilterBadges: $,
|
|
477
480
|
filterSearch: U,
|
|
478
|
-
setFilterSearch:
|
|
479
|
-
filteredColumns:
|
|
481
|
+
setFilterSearch: Ee,
|
|
482
|
+
filteredColumns: Ue,
|
|
480
483
|
handleAddFilter: xe,
|
|
481
|
-
handleAddAdvancedFilter:
|
|
482
|
-
i18n:
|
|
484
|
+
handleAddAdvancedFilter: Xe,
|
|
485
|
+
i18n: h
|
|
483
486
|
}
|
|
484
487
|
)
|
|
485
488
|
] }),
|
|
486
489
|
/* @__PURE__ */ c("div", { className: "border-d-border h-4 min-h-4 w-[1px] border-r" }),
|
|
487
|
-
|
|
488
|
-
|
|
490
|
+
Be,
|
|
491
|
+
(w.length || y) && /* @__PURE__ */ c(
|
|
492
|
+
tt,
|
|
489
493
|
{
|
|
490
494
|
className: "h-6 text-xs",
|
|
491
495
|
iconLeft: "FunnelX",
|
|
@@ -494,49 +498,52 @@ function Nt({
|
|
|
494
498
|
onClick: () => {
|
|
495
499
|
$([]), ee(void 0);
|
|
496
500
|
},
|
|
497
|
-
children:
|
|
501
|
+
children: h.reset
|
|
498
502
|
}
|
|
499
503
|
),
|
|
500
504
|
z.length > 0 && /* @__PURE__ */ c(
|
|
501
|
-
|
|
505
|
+
it,
|
|
502
506
|
{
|
|
503
507
|
debounceMs: 300,
|
|
504
|
-
onSearch:
|
|
505
|
-
i18n:
|
|
506
|
-
initialValue:
|
|
508
|
+
onSearch: Le,
|
|
509
|
+
i18n: h,
|
|
510
|
+
initialValue: g ?? "",
|
|
507
511
|
searchableColumnsHeaders: _.map(
|
|
508
512
|
(e) => e.header ? e.header.toString() : e.id?.toString() ?? "-"
|
|
509
513
|
)
|
|
510
514
|
}
|
|
511
515
|
),
|
|
512
516
|
/* @__PURE__ */ c(
|
|
513
|
-
|
|
517
|
+
rt,
|
|
514
518
|
{
|
|
515
519
|
table: i,
|
|
516
|
-
visibleColumns:
|
|
517
|
-
hiddenColumns:
|
|
518
|
-
i18n:
|
|
520
|
+
visibleColumns: Ye,
|
|
521
|
+
hiddenColumns: Ze,
|
|
522
|
+
i18n: h
|
|
519
523
|
}
|
|
520
524
|
),
|
|
521
|
-
/* @__PURE__ */ c(
|
|
525
|
+
/* @__PURE__ */ c(gt, { actions: ze, i18n: h })
|
|
522
526
|
] }),
|
|
523
527
|
/* @__PURE__ */ c(
|
|
524
|
-
|
|
528
|
+
nt,
|
|
525
529
|
{
|
|
526
530
|
table: i,
|
|
527
531
|
tableContainerRef: q,
|
|
528
532
|
loading: B,
|
|
529
533
|
data: P,
|
|
530
534
|
emptyComponent: Ie,
|
|
531
|
-
notFoundMessage:
|
|
535
|
+
notFoundMessage: h?.notFoundMessage ?? "N/A",
|
|
532
536
|
onAddFilter: xe,
|
|
533
537
|
maxSortedColumns: se,
|
|
534
|
-
i18n:
|
|
535
|
-
isServerSide: a
|
|
538
|
+
i18n: h,
|
|
539
|
+
isServerSide: a,
|
|
540
|
+
filterBadges: w,
|
|
541
|
+
advancedFilterBadge: y,
|
|
542
|
+
searchbarGlobalFilter: g
|
|
536
543
|
}
|
|
537
544
|
),
|
|
538
|
-
!
|
|
539
|
-
|
|
545
|
+
!Me && /* @__PURE__ */ c(
|
|
546
|
+
at,
|
|
540
547
|
{
|
|
541
548
|
table: i,
|
|
542
549
|
isServerSide: a,
|
|
@@ -546,7 +553,7 @@ function Nt({
|
|
|
546
553
|
k(e), L(e);
|
|
547
554
|
} : void 0,
|
|
548
555
|
totalItems: d?.totalItems,
|
|
549
|
-
i18n:
|
|
556
|
+
i18n: h
|
|
550
557
|
}
|
|
551
558
|
)
|
|
552
559
|
]
|
|
@@ -554,5 +561,5 @@ function Nt({
|
|
|
554
561
|
);
|
|
555
562
|
}
|
|
556
563
|
export {
|
|
557
|
-
|
|
564
|
+
Gt as DataTable
|
|
558
565
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getListMultiSelectFilterOptions as v, getListSingleSelectFilterOptions as D, getDateTimeFilterOptions as
|
|
2
|
+
import { getListMultiSelectFilterOptions as v, getListSingleSelectFilterOptions as D, getDateTimeFilterOptions as A, getDateFilterOptions as F, getBooleanFilterOptions as b, getNumberFilterOptions as T, getStringFilterOptions as q } from "./data-table-constants.js";
|
|
3
3
|
import { defaultDataTableI18n as m } from "./data-table-i18n.js";
|
|
4
|
-
function
|
|
4
|
+
function O(e, a = "string") {
|
|
5
5
|
const t = (s) => {
|
|
6
6
|
switch (s) {
|
|
7
7
|
case "string":
|
|
@@ -11,9 +11,9 @@ function L(e, a = "string") {
|
|
|
11
11
|
case "boolean":
|
|
12
12
|
return b(m)?.[0]?.value ?? "eq";
|
|
13
13
|
case "date":
|
|
14
|
-
return
|
|
14
|
+
return F(m)?.[0]?.value ?? "eq";
|
|
15
15
|
case "datetime":
|
|
16
|
-
return
|
|
16
|
+
return A(m)?.[0]?.value ?? "date_time_before";
|
|
17
17
|
case "list_single_select":
|
|
18
18
|
return D(m)?.[0]?.value ?? "array_overlap";
|
|
19
19
|
case "list_multi_select":
|
|
@@ -26,6 +26,7 @@ function L(e, a = "string") {
|
|
|
26
26
|
id: crypto.randomUUID(),
|
|
27
27
|
columnId: e?.id || "",
|
|
28
28
|
columnLabel: e?.column.columnDef.header?.toString() || "",
|
|
29
|
+
columnAccessorKey: (e?.column.columnDef?.accessorKey ?? e?.id) || "",
|
|
29
30
|
columnType: e?.column.columnDef.meta?.type || a,
|
|
30
31
|
operator: t(
|
|
31
32
|
e?.column.columnDef.meta?.type
|
|
@@ -33,7 +34,7 @@ function L(e, a = "string") {
|
|
|
33
34
|
listOptions: e?.column.columnDef.meta?.listOptions
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function I() {
|
|
37
38
|
const e = () => crypto.randomUUID();
|
|
38
39
|
return {
|
|
39
40
|
id: e(),
|
|
@@ -44,6 +45,7 @@ function O() {
|
|
|
44
45
|
{
|
|
45
46
|
id: e(),
|
|
46
47
|
columnId: "",
|
|
48
|
+
columnAccessorKey: "",
|
|
47
49
|
columnLabel: "",
|
|
48
50
|
columnType: "string",
|
|
49
51
|
operator: "eq",
|
|
@@ -58,7 +60,7 @@ function k(e, a) {
|
|
|
58
60
|
const t = e.filter((n) => n.operator === "eq_null" || n.operator === "n_eq_null" ? !0 : n.value === void 0 || n.value === "" ? !1 : n.columnType === "list_multi_select" ? (Array.isArray(n.value) ? n.value.filter((l) => l !== void 0) : [n.value].filter((l) => l !== void 0)).length > 0 : !0), u = a ? ((n) => {
|
|
59
61
|
const p = (l) => {
|
|
60
62
|
const _ = l.conditions.filter((o) => !o.columnId || !o.operator ? !1 : o.operator === "eq_null" || o.operator === "n_eq_null" ? !0 : o.value === void 0 ? !1 : o.columnType === "list_multi_select" ? (Array.isArray(o.value) ? o.value.filter((y) => y !== void 0) : [o.value].filter((y) => y !== void 0)).length > 0 : !0).map((o) => ({
|
|
61
|
-
[o.
|
|
63
|
+
[o.columnAccessorKey]: {
|
|
62
64
|
operator: o.operator,
|
|
63
65
|
value: o.operator === "eq_null" || o.operator === "n_eq_null" ? "" : o.columnType === "list_single_select" ? Array.isArray(o.value) ? o.value.filter((f) => f !== void 0) : [o.value].filter((f) => f !== void 0) : o.value
|
|
64
66
|
}
|
|
@@ -71,7 +73,7 @@ function k(e, a) {
|
|
|
71
73
|
return p(n.rootGroup);
|
|
72
74
|
})(a) : null, c = t.map(
|
|
73
75
|
(n) => ({
|
|
74
|
-
[n.
|
|
76
|
+
[n.columnAccessorKey]: {
|
|
75
77
|
operator: n.operator,
|
|
76
78
|
value: n.operator === "eq_null" || n.operator === "n_eq_null" ? "" : n.columnType === "list_single_select" ? Array.isArray(n.value) ? n.value.filter((p) => p !== void 0) : [n.value].filter((p) => p !== void 0) : n.value ?? ""
|
|
77
79
|
}
|
|
@@ -246,8 +248,8 @@ export {
|
|
|
246
248
|
C as applyClientSideFilter,
|
|
247
249
|
h as applySearchFilterToRow,
|
|
248
250
|
k as buildSearchFilter,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
+
O as createBadgeFilterFromHeader,
|
|
252
|
+
I as createDefaultAdvancedFilter,
|
|
251
253
|
M as debounce,
|
|
252
254
|
x as getIconFromColumnType,
|
|
253
255
|
H as updatePageSizeFromContainer
|