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