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