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