lite-table-js 1.0.0
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/README.md +71 -0
- package/dist/index.js +3874 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -0
- package/types/index.d.ts +174 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3874 @@
|
|
|
1
|
+
import e, { memo as t, useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import { AlertCircle as s, AreaChart as c, ArrowDown as l, ArrowUp as u, ArrowUpDown as d, BarChart3 as f, Bookmark as p, Check as m, ChevronDown as h, ChevronLeft as g, ChevronRight as _, ChevronsLeft as v, ChevronsRight as y, Database as b, Download as x, Edit3 as S, Filter as C, GripVertical as w, LayoutGrid as T, LineChart as E, List as D, MoreVertical as O, PieChart as ee, Plus as k, RefreshCw as A, RotateCcw as j, Save as M, Search as N, SlidersHorizontal as P, Table2 as te, Trash2 as F, X as I } from "lucide-react";
|
|
3
|
+
import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
|
|
4
|
+
import { createPortal as B } from "react-dom";
|
|
5
|
+
import { Area as V, AreaChart as H, Bar as U, BarChart as W, CartesianGrid as G, Cell as K, Legend as q, Line as ne, LineChart as J, Pie as re, PieChart as ie, ResponsiveContainer as ae, Tooltip as oe, XAxis as se, YAxis as Y } from "recharts";
|
|
6
|
+
//#region src/utils.js
|
|
7
|
+
function X(e, t) {
|
|
8
|
+
return t.split(".").reduce((e, t) => e?.[t], e);
|
|
9
|
+
}
|
|
10
|
+
function Z(e, t) {
|
|
11
|
+
if (t.accessorFn) return t.accessorFn(e);
|
|
12
|
+
if (t.accessorKey) return X(e, t.accessorKey);
|
|
13
|
+
}
|
|
14
|
+
function ce(e, t, n) {
|
|
15
|
+
return typeof t == "function" ? t(e) : typeof t == "string" ? String(X(e, t)) : e.id === void 0 ? e._id === void 0 ? e.key === void 0 ? String(n) : String(e.key) : String(e._id) : String(e.id);
|
|
16
|
+
}
|
|
17
|
+
function le(e, t, n) {
|
|
18
|
+
if (!t.length) return e;
|
|
19
|
+
let r = [...e];
|
|
20
|
+
return r.sort((e, r) => {
|
|
21
|
+
for (let i of t) {
|
|
22
|
+
if (!i.direction) continue;
|
|
23
|
+
let t = n.find((e) => e.id === i.columnId);
|
|
24
|
+
if (!t) continue;
|
|
25
|
+
if (t.sortFn) {
|
|
26
|
+
let n = t.sortFn(e, r, i.direction);
|
|
27
|
+
if (n !== 0) return n;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
let a = ue(Z(e, t), Z(r, t));
|
|
31
|
+
if (a !== 0) return i.direction === "asc" ? a : -a;
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
}), r;
|
|
35
|
+
}
|
|
36
|
+
function ue(e, t) {
|
|
37
|
+
return e == null && t == null ? 0 : e == null ? -1 : t == null ? 1 : typeof e == "string" && typeof t == "string" ? e.localeCompare(t, void 0, { sensitivity: "base" }) : typeof e == "number" && typeof t == "number" ? e - t : e instanceof Date && t instanceof Date ? e.getTime() - t.getTime() : String(e).localeCompare(String(t));
|
|
38
|
+
}
|
|
39
|
+
function de(e, t, n, r) {
|
|
40
|
+
let i = e;
|
|
41
|
+
if (n.trim()) {
|
|
42
|
+
let e = n.toLowerCase();
|
|
43
|
+
i = i.filter((t) => r.some((n) => {
|
|
44
|
+
let r = Z(t, n);
|
|
45
|
+
return r != null && String(r).toLowerCase().includes(e);
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
for (let e of t) {
|
|
49
|
+
let t = r.find((t) => t.id === e.columnId);
|
|
50
|
+
t && (i = i.filter((n) => fe(Z(n, t), e)));
|
|
51
|
+
}
|
|
52
|
+
return i;
|
|
53
|
+
}
|
|
54
|
+
function fe(e, t) {
|
|
55
|
+
let { value: n, operator: r = "contains" } = t;
|
|
56
|
+
if (n == null || n === "" || Array.isArray(n) && !n.length) return !0;
|
|
57
|
+
if (Array.isArray(n)) return n.includes(e);
|
|
58
|
+
let i = String(e ?? "").toLowerCase(), a = String(n).toLowerCase();
|
|
59
|
+
switch (r) {
|
|
60
|
+
case "eq": return e === n;
|
|
61
|
+
case "neq": return e !== n;
|
|
62
|
+
case "gt": return Number(e) > Number(n);
|
|
63
|
+
case "gte": return Number(e) >= Number(n);
|
|
64
|
+
case "lt": return Number(e) < Number(n);
|
|
65
|
+
case "lte": return Number(e) <= Number(n);
|
|
66
|
+
case "contains": return i.includes(a);
|
|
67
|
+
case "startsWith": return i.startsWith(a);
|
|
68
|
+
case "endsWith": return i.endsWith(a);
|
|
69
|
+
default: return i.includes(a);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function Q(e, t, n) {
|
|
73
|
+
let r = (t - 1) * n;
|
|
74
|
+
return e.slice(r, r + n);
|
|
75
|
+
}
|
|
76
|
+
function $(e, t) {
|
|
77
|
+
let n = /* @__PURE__ */ new Map();
|
|
78
|
+
for (let r of e) {
|
|
79
|
+
let e = X(r, t), i = n.get(e) ?? [];
|
|
80
|
+
i.push(r), n.set(e, i);
|
|
81
|
+
}
|
|
82
|
+
return n;
|
|
83
|
+
}
|
|
84
|
+
function pe(e, t, n = "export") {
|
|
85
|
+
let r = t.map((e) => e.header), i = e.map((e) => t.map((t) => {
|
|
86
|
+
let n = Z(e, t), r = String(n ?? "");
|
|
87
|
+
return r.includes(",") || r.includes("\"") || r.includes("\n") ? `"${r.replace(/"/g, "\"\"")}"` : r;
|
|
88
|
+
}));
|
|
89
|
+
he([r.join(","), ...i.map((e) => e.join(","))].join("\n"), `${n}.csv`, "text/csv");
|
|
90
|
+
}
|
|
91
|
+
function me(e, t = "export") {
|
|
92
|
+
he(JSON.stringify(e, null, 2), `${t}.json`, "application/json");
|
|
93
|
+
}
|
|
94
|
+
function he(e, t, n) {
|
|
95
|
+
let r = new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
96
|
+
a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
97
|
+
}
|
|
98
|
+
function ge(e, t, n, r) {
|
|
99
|
+
if (r) {
|
|
100
|
+
r(e, t);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
switch (e) {
|
|
104
|
+
case "csv":
|
|
105
|
+
pe(t, n);
|
|
106
|
+
break;
|
|
107
|
+
case "excel":
|
|
108
|
+
pe(t, n, "export");
|
|
109
|
+
break;
|
|
110
|
+
case "pdf":
|
|
111
|
+
console.warn("PDF export requires a custom onExport handler");
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function _e(e, t, n) {
|
|
116
|
+
let r = [...e], [i] = r.splice(t, 1);
|
|
117
|
+
return r.splice(n, 0, i), r;
|
|
118
|
+
}
|
|
119
|
+
function ve(e, t, n) {
|
|
120
|
+
return Math.min(Math.max(e, t), n);
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/hooks/useSorting.js
|
|
124
|
+
function ye({ config: e, columns: t }) {
|
|
125
|
+
let [r, a] = o(e?.defaultSort ?? []), s = e?.sort !== void 0, c = s ? e.sort : r, l = n((n) => {
|
|
126
|
+
if (!t.find((e) => e.id === n)?.sortable) return;
|
|
127
|
+
let r = c.find((e) => e.columnId === n), i;
|
|
128
|
+
if (r) i = r.direction === "asc" ? c.map((e) => e.columnId === n ? {
|
|
129
|
+
...e,
|
|
130
|
+
direction: "desc"
|
|
131
|
+
} : e) : c.filter((e) => e.columnId !== n);
|
|
132
|
+
else {
|
|
133
|
+
let t = {
|
|
134
|
+
columnId: n,
|
|
135
|
+
direction: "asc"
|
|
136
|
+
};
|
|
137
|
+
i = e?.multi ? [...c, t] : [t];
|
|
138
|
+
}
|
|
139
|
+
s ? e?.onSortChange?.(i) : a(i);
|
|
140
|
+
}, [
|
|
141
|
+
c,
|
|
142
|
+
t,
|
|
143
|
+
e,
|
|
144
|
+
s
|
|
145
|
+
]), u = n((e) => c.find((t) => t.columnId === e)?.direction ?? null, [c]), d = n((t) => {
|
|
146
|
+
s ? e?.onSortChange?.(t) : a(t);
|
|
147
|
+
}, [e, s]), f = n((e) => le(e, c, t), [c, t]);
|
|
148
|
+
return i(() => ({
|
|
149
|
+
sorting: c,
|
|
150
|
+
toggleSort: l,
|
|
151
|
+
getSortDirection: u,
|
|
152
|
+
setSorting: d,
|
|
153
|
+
applySorting: f
|
|
154
|
+
}), [
|
|
155
|
+
c,
|
|
156
|
+
l,
|
|
157
|
+
u,
|
|
158
|
+
d,
|
|
159
|
+
f
|
|
160
|
+
]);
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/hooks/useFilters.js
|
|
164
|
+
function be({ config: e, columns: t }) {
|
|
165
|
+
let [r, a] = o([]), [s, c] = o(""), [l, u] = o(e?.presets ?? []), d = e?.filters !== void 0, f = e?.globalSearch !== void 0, p = d ? e.filters : r, m = f ? e.globalSearch : s, h = n((t, n, r) => {
|
|
166
|
+
let i = p.filter((e) => e.columnId !== t);
|
|
167
|
+
n !== "" && n != null && !(Array.isArray(n) && !n.length) && i.push({
|
|
168
|
+
columnId: t,
|
|
169
|
+
value: n,
|
|
170
|
+
operator: r
|
|
171
|
+
}), d ? e?.onFilterChange?.(i) : a(i);
|
|
172
|
+
}, [
|
|
173
|
+
p,
|
|
174
|
+
e,
|
|
175
|
+
d
|
|
176
|
+
]), g = n((t) => {
|
|
177
|
+
d ? e?.onFilterChange?.(t) : a(t);
|
|
178
|
+
}, [e, d]), _ = n(() => {
|
|
179
|
+
d ? e?.onFilterChange?.([]) : a([]), f ? e?.onGlobalSearchChange?.("") : c("");
|
|
180
|
+
}, [
|
|
181
|
+
e,
|
|
182
|
+
d,
|
|
183
|
+
f
|
|
184
|
+
]), v = n((t) => {
|
|
185
|
+
f ? e?.onGlobalSearchChange?.(t) : c(t);
|
|
186
|
+
}, [e, f]), y = n((e) => p.find((t) => t.columnId === e)?.value ?? "", [p]), b = n((e) => de(e, p, m, t), [
|
|
187
|
+
p,
|
|
188
|
+
m,
|
|
189
|
+
t
|
|
190
|
+
]), x = n((t) => {
|
|
191
|
+
let n = {
|
|
192
|
+
id: `preset_${Date.now()}`,
|
|
193
|
+
name: t,
|
|
194
|
+
filters: [...p],
|
|
195
|
+
globalSearch: m
|
|
196
|
+
};
|
|
197
|
+
return u((e) => [...e, n]), e?.onPresetSave?.(n), n;
|
|
198
|
+
}, [
|
|
199
|
+
p,
|
|
200
|
+
m,
|
|
201
|
+
e
|
|
202
|
+
]), S = n((t) => {
|
|
203
|
+
d ? e?.onFilterChange?.(t.filters) : a(t.filters), t.globalSearch !== void 0 && v(t.globalSearch);
|
|
204
|
+
}, [
|
|
205
|
+
e,
|
|
206
|
+
d,
|
|
207
|
+
v
|
|
208
|
+
]), C = n((t) => {
|
|
209
|
+
u((e) => e.filter((e) => e.id !== t)), e?.onPresetDelete?.(t);
|
|
210
|
+
}, [e]);
|
|
211
|
+
return i(() => ({
|
|
212
|
+
filters: p,
|
|
213
|
+
globalSearch: m,
|
|
214
|
+
setFilter: h,
|
|
215
|
+
setFilters: g,
|
|
216
|
+
clearFilters: _,
|
|
217
|
+
setGlobalSearch: v,
|
|
218
|
+
getFilterValue: y,
|
|
219
|
+
applyFilters: b,
|
|
220
|
+
presets: l,
|
|
221
|
+
savePreset: x,
|
|
222
|
+
loadPreset: S,
|
|
223
|
+
deletePreset: C
|
|
224
|
+
}), [
|
|
225
|
+
p,
|
|
226
|
+
m,
|
|
227
|
+
h,
|
|
228
|
+
g,
|
|
229
|
+
_,
|
|
230
|
+
v,
|
|
231
|
+
y,
|
|
232
|
+
b,
|
|
233
|
+
l,
|
|
234
|
+
x,
|
|
235
|
+
S,
|
|
236
|
+
C
|
|
237
|
+
]);
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/hooks/usePagination.js
|
|
241
|
+
function xe({ config: e, totalItems: t }) {
|
|
242
|
+
let [r, a] = o(1), [s, c] = o(e?.pageSize ?? 10), l = e?.page !== void 0, u = e?.onPageSizeChange !== void 0 && e?.pageSize !== void 0, d = l ? e.page : r, f = u ? e.pageSize : s, p = e?.pageSizeOptions ?? [
|
|
243
|
+
10,
|
|
244
|
+
25,
|
|
245
|
+
50,
|
|
246
|
+
100
|
|
247
|
+
], m = e?.totalItems ?? t, h = Math.max(1, Math.ceil(m / f)), g = n((t) => {
|
|
248
|
+
let n = Math.max(1, Math.min(t, h));
|
|
249
|
+
l ? e?.onPageChange?.(n) : a(n);
|
|
250
|
+
}, [
|
|
251
|
+
h,
|
|
252
|
+
e,
|
|
253
|
+
l
|
|
254
|
+
]), _ = n((t) => {
|
|
255
|
+
c(t), e?.onPageSizeChange?.(t), l ? e?.onPageChange?.(1) : a(1);
|
|
256
|
+
}, [e, l]), v = n((e) => Q(e, d, f), [d, f]), y = d > h ? 1 : d;
|
|
257
|
+
return i(() => ({
|
|
258
|
+
page: y,
|
|
259
|
+
pageSize: f,
|
|
260
|
+
totalPages: h,
|
|
261
|
+
totalItems: m,
|
|
262
|
+
pageSizeOptions: p,
|
|
263
|
+
setPage: g,
|
|
264
|
+
setPageSize: _,
|
|
265
|
+
applyPagination: v,
|
|
266
|
+
isInfinite: e?.infinite ?? !1,
|
|
267
|
+
hasMore: e?.hasMore ?? !1,
|
|
268
|
+
onLoadMore: e?.onLoadMore
|
|
269
|
+
}), [
|
|
270
|
+
y,
|
|
271
|
+
f,
|
|
272
|
+
h,
|
|
273
|
+
m,
|
|
274
|
+
p,
|
|
275
|
+
g,
|
|
276
|
+
_,
|
|
277
|
+
v,
|
|
278
|
+
e
|
|
279
|
+
]);
|
|
280
|
+
}
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/hooks/useSelection.js
|
|
283
|
+
function Se({ config: e, data: t }) {
|
|
284
|
+
let [r, s] = o([]), c = a(null), l = e?.mode ?? "none", u = e?.selectedKeys !== void 0, d = u ? e.selectedKeys : r, f = n((t, n) => ce(t, e?.rowKey, n), [e?.rowKey]), p = n((n) => {
|
|
285
|
+
let r = t.filter((e, t) => n.includes(f(e, t)));
|
|
286
|
+
u || s(n), e?.onSelectionChange?.(n, r);
|
|
287
|
+
}, [
|
|
288
|
+
t,
|
|
289
|
+
f,
|
|
290
|
+
e,
|
|
291
|
+
u
|
|
292
|
+
]), m = n((e) => {
|
|
293
|
+
l !== "none" && (p(l === "single" ? d.includes(e) ? [] : [e] : d.includes(e) ? d.filter((t) => t !== e) : [...d, e]), c.current = e);
|
|
294
|
+
}, [
|
|
295
|
+
l,
|
|
296
|
+
d,
|
|
297
|
+
p
|
|
298
|
+
]), h = n((e, t) => {
|
|
299
|
+
if (l !== "multiple") {
|
|
300
|
+
m(e);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
let n = c.current;
|
|
304
|
+
if (!n) {
|
|
305
|
+
m(e);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
let r = t.map((e, t) => f(e, t)), i = r.indexOf(n), a = r.indexOf(e);
|
|
309
|
+
if (i === -1 || a === -1) {
|
|
310
|
+
m(e);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
let o = Math.min(i, a), s = Math.max(i, a), u = r.slice(o, s + 1);
|
|
314
|
+
p([...new Set([...d, ...u])]), c.current = e;
|
|
315
|
+
}, [
|
|
316
|
+
l,
|
|
317
|
+
d,
|
|
318
|
+
f,
|
|
319
|
+
p,
|
|
320
|
+
m
|
|
321
|
+
]), g = n((e) => {
|
|
322
|
+
if (l !== "multiple") return;
|
|
323
|
+
let t = e.map((e, t) => f(e, t));
|
|
324
|
+
t.every((e) => d.includes(e)) ? p(d.filter((e) => !t.includes(e))) : p([...new Set([...d, ...t])]);
|
|
325
|
+
}, [
|
|
326
|
+
l,
|
|
327
|
+
d,
|
|
328
|
+
f,
|
|
329
|
+
p
|
|
330
|
+
]), _ = n((e) => d.includes(e), [d]), v = n((e) => e.length ? e.every((e, t) => d.includes(f(e, t))) : !1, [d, f]), y = n((e) => {
|
|
331
|
+
if (!e.length) return !1;
|
|
332
|
+
let t = e.map((e, t) => f(e, t));
|
|
333
|
+
return t.some((e) => d.includes(e)) && !t.every((e) => d.includes(e));
|
|
334
|
+
}, [d, f]), b = n(() => {
|
|
335
|
+
p([]), c.current = null;
|
|
336
|
+
}, [p]), x = i(() => t.filter((e, t) => d.includes(f(e, t))), [
|
|
337
|
+
t,
|
|
338
|
+
d,
|
|
339
|
+
f
|
|
340
|
+
]);
|
|
341
|
+
return i(() => ({
|
|
342
|
+
mode: l,
|
|
343
|
+
selectedKeys: d,
|
|
344
|
+
selectedRows: x,
|
|
345
|
+
toggleRow: m,
|
|
346
|
+
selectRange: h,
|
|
347
|
+
toggleAll: g,
|
|
348
|
+
isSelected: _,
|
|
349
|
+
isAllSelected: v,
|
|
350
|
+
isSomeSelected: y,
|
|
351
|
+
clearSelection: b,
|
|
352
|
+
getKey: f,
|
|
353
|
+
showCheckbox: e?.showCheckbox ?? l !== "none"
|
|
354
|
+
}), [
|
|
355
|
+
l,
|
|
356
|
+
d,
|
|
357
|
+
x,
|
|
358
|
+
m,
|
|
359
|
+
h,
|
|
360
|
+
g,
|
|
361
|
+
_,
|
|
362
|
+
v,
|
|
363
|
+
y,
|
|
364
|
+
b,
|
|
365
|
+
f,
|
|
366
|
+
e
|
|
367
|
+
]);
|
|
368
|
+
}
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/hooks/useColumnManager.js
|
|
371
|
+
function Ce({ columns: e, enableVisibility: t = !1, enableResizing: r = !1, enableReordering: a = !1 }) {
|
|
372
|
+
let [s, c] = o(() => {
|
|
373
|
+
let t = /* @__PURE__ */ new Set();
|
|
374
|
+
return e.forEach((e) => {
|
|
375
|
+
e.visible === !1 && t.add(e.id);
|
|
376
|
+
}), t;
|
|
377
|
+
}), [l, u] = o(() => e.map((e) => e.id)), [d, f] = o(() => {
|
|
378
|
+
let t = {};
|
|
379
|
+
return e.forEach((e) => {
|
|
380
|
+
e.width && (t[e.id] = e.width);
|
|
381
|
+
}), t;
|
|
382
|
+
}), p = n((e) => {
|
|
383
|
+
t && c((t) => {
|
|
384
|
+
let n = new Set(t);
|
|
385
|
+
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
386
|
+
});
|
|
387
|
+
}, [t]), m = n((e, t) => {
|
|
388
|
+
a && u((n) => _e(n, e, t));
|
|
389
|
+
}, [a]), h = n((e, t) => {
|
|
390
|
+
!a || e === t || u((n) => {
|
|
391
|
+
let r = n.indexOf(e), i = n.indexOf(t);
|
|
392
|
+
return r === -1 || i === -1 ? n : _e(n, r, i);
|
|
393
|
+
});
|
|
394
|
+
}, [a]), g = n((t, n) => {
|
|
395
|
+
if (!r) return;
|
|
396
|
+
let i = e.find((e) => e.id === t), a = i?.minWidth ?? 50, o = i?.maxWidth ?? 1e3;
|
|
397
|
+
f((e) => ({
|
|
398
|
+
...e,
|
|
399
|
+
[t]: ve(n, a, o)
|
|
400
|
+
}));
|
|
401
|
+
}, [r, e]), _ = i(() => {
|
|
402
|
+
let t = l.map((t) => e.find((e) => e.id === t)).filter((e) => e != null && !s.has(e.id)), n = new Set(l), r = e.filter((e) => !n.has(e.id) && !s.has(e.id));
|
|
403
|
+
return [...t, ...r];
|
|
404
|
+
}, [
|
|
405
|
+
e,
|
|
406
|
+
l,
|
|
407
|
+
s
|
|
408
|
+
]), v = i(() => _.filter((e) => e.pin === "left"), [_]), y = i(() => _.filter((e) => e.pin === "right"), [_]), b = i(() => _.filter((e) => !e.pin), [_]), x = n((e) => c(new Set(e)), []), S = n((e) => u(e), []), C = n((e) => f(e), []);
|
|
409
|
+
return i(() => ({
|
|
410
|
+
visibleColumns: _,
|
|
411
|
+
pinnedLeft: v,
|
|
412
|
+
pinnedRight: y,
|
|
413
|
+
unpinned: b,
|
|
414
|
+
hiddenColumns: s,
|
|
415
|
+
columnOrder: l,
|
|
416
|
+
columnWidths: d,
|
|
417
|
+
toggleColumnVisibility: p,
|
|
418
|
+
reorderColumns: m,
|
|
419
|
+
reorderColumnsById: h,
|
|
420
|
+
resizeColumn: g,
|
|
421
|
+
setHiddenColumnIds: x,
|
|
422
|
+
setColumnOrderIds: S,
|
|
423
|
+
setColumnWidthMap: C,
|
|
424
|
+
enableVisibility: t,
|
|
425
|
+
enableResizing: r,
|
|
426
|
+
enableReordering: a,
|
|
427
|
+
allColumns: e
|
|
428
|
+
}), [
|
|
429
|
+
_,
|
|
430
|
+
v,
|
|
431
|
+
y,
|
|
432
|
+
b,
|
|
433
|
+
s,
|
|
434
|
+
l,
|
|
435
|
+
d,
|
|
436
|
+
p,
|
|
437
|
+
m,
|
|
438
|
+
h,
|
|
439
|
+
g,
|
|
440
|
+
x,
|
|
441
|
+
S,
|
|
442
|
+
C,
|
|
443
|
+
t,
|
|
444
|
+
r,
|
|
445
|
+
a,
|
|
446
|
+
e
|
|
447
|
+
]);
|
|
448
|
+
}
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/hooks/usePersistence.js
|
|
451
|
+
function we({ persistKey: e, syncUrl: t, state: i, onRestore: a }) {
|
|
452
|
+
let o = n(() => {
|
|
453
|
+
if (e) try {
|
|
454
|
+
let t = {
|
|
455
|
+
sorting: i.sorting,
|
|
456
|
+
filters: i.filters,
|
|
457
|
+
globalSearch: i.globalSearch,
|
|
458
|
+
page: i.page,
|
|
459
|
+
pageSize: i.pageSize,
|
|
460
|
+
viewMode: i.viewMode,
|
|
461
|
+
hiddenColumns: Array.from(i.hiddenColumns),
|
|
462
|
+
columnOrder: i.columnOrder
|
|
463
|
+
};
|
|
464
|
+
localStorage.setItem(`datatable_${e}`, JSON.stringify(t));
|
|
465
|
+
} catch {}
|
|
466
|
+
}, [e, i]), s = n(() => {
|
|
467
|
+
if (!e) return null;
|
|
468
|
+
try {
|
|
469
|
+
let t = localStorage.getItem(`datatable_${e}`);
|
|
470
|
+
if (!t) return null;
|
|
471
|
+
let n = JSON.parse(t);
|
|
472
|
+
return {
|
|
473
|
+
...n,
|
|
474
|
+
hiddenColumns: n.hiddenColumns ? new Set(n.hiddenColumns) : void 0
|
|
475
|
+
};
|
|
476
|
+
} catch {
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
}, [e]), c = n(() => {
|
|
480
|
+
if (!t) return;
|
|
481
|
+
let e = new URLSearchParams();
|
|
482
|
+
i.page > 1 && e.set("page", String(i.page)), i.pageSize !== 10 && e.set("pageSize", String(i.pageSize)), i.globalSearch && e.set("q", i.globalSearch), i.sorting.length && e.set("sort", JSON.stringify(i.sorting)), i.filters.length && e.set("filters", JSON.stringify(i.filters)), i.viewMode !== "table" && e.set("view", i.viewMode);
|
|
483
|
+
let n = e.toString(), r = n ? `${window.location.pathname}?${n}` : window.location.pathname;
|
|
484
|
+
window.history.replaceState(null, "", r);
|
|
485
|
+
}, [t, i]), l = n(() => {
|
|
486
|
+
if (!t) return null;
|
|
487
|
+
try {
|
|
488
|
+
let e = new URLSearchParams(window.location.search), t = {}, n = e.get("page");
|
|
489
|
+
n && (t.page = Number(n));
|
|
490
|
+
let r = e.get("pageSize");
|
|
491
|
+
r && (t.pageSize = Number(r));
|
|
492
|
+
let i = e.get("q");
|
|
493
|
+
i && (t.globalSearch = i);
|
|
494
|
+
let a = e.get("sort");
|
|
495
|
+
a && (t.sorting = JSON.parse(a));
|
|
496
|
+
let o = e.get("filters");
|
|
497
|
+
o && (t.filters = JSON.parse(o));
|
|
498
|
+
let s = e.get("view");
|
|
499
|
+
return s && (t.viewMode = s), Object.keys(t).length ? t : null;
|
|
500
|
+
} catch {
|
|
501
|
+
return null;
|
|
502
|
+
}
|
|
503
|
+
}, [t]);
|
|
504
|
+
return r(() => {
|
|
505
|
+
o(), c();
|
|
506
|
+
}, [o, c]), r(() => {
|
|
507
|
+
let e = l(), t = {
|
|
508
|
+
...s(),
|
|
509
|
+
...e
|
|
510
|
+
};
|
|
511
|
+
Object.keys(t).length && a?.(t);
|
|
512
|
+
}, []), {
|
|
513
|
+
saveToStorage: o,
|
|
514
|
+
loadFromStorage: s,
|
|
515
|
+
syncToUrl: c,
|
|
516
|
+
loadFromUrl: l
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region src/hooks/usePresets.js
|
|
521
|
+
var Te = "datatable_presets_";
|
|
522
|
+
function Ee(e) {
|
|
523
|
+
return `${Te}${e}`;
|
|
524
|
+
}
|
|
525
|
+
function De(e) {
|
|
526
|
+
try {
|
|
527
|
+
let t = localStorage.getItem(Ee(e));
|
|
528
|
+
return t ? JSON.parse(t) : [];
|
|
529
|
+
} catch {
|
|
530
|
+
return [];
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
function Oe(e, t) {
|
|
534
|
+
try {
|
|
535
|
+
localStorage.setItem(Ee(e), JSON.stringify(t));
|
|
536
|
+
} catch {}
|
|
537
|
+
}
|
|
538
|
+
function ke({ tableId: e }) {
|
|
539
|
+
let [t, r] = o(() => De(e)), a = n((t, n) => {
|
|
540
|
+
let i = Date.now(), a = {
|
|
541
|
+
id: `preset_${i}_${Math.random().toString(36).slice(2, 8)}`,
|
|
542
|
+
name: t,
|
|
543
|
+
config: n,
|
|
544
|
+
createdAt: i,
|
|
545
|
+
updatedAt: i
|
|
546
|
+
};
|
|
547
|
+
return r((t) => {
|
|
548
|
+
let n = [...t, a];
|
|
549
|
+
return Oe(e, n), n;
|
|
550
|
+
}), a;
|
|
551
|
+
}, [e]), s = n((e) => t.find((t) => t.name === e)?.config ?? null, [t]), c = n((e) => t.find((t) => t.id === e)?.config ?? null, [t]), l = n((t, n) => {
|
|
552
|
+
r((r) => {
|
|
553
|
+
let i = r.map((e) => e.id === t ? {
|
|
554
|
+
...e,
|
|
555
|
+
config: {
|
|
556
|
+
...e.config,
|
|
557
|
+
...n
|
|
558
|
+
},
|
|
559
|
+
updatedAt: Date.now()
|
|
560
|
+
} : e);
|
|
561
|
+
return Oe(e, i), i;
|
|
562
|
+
});
|
|
563
|
+
}, [e]), u = n((t) => {
|
|
564
|
+
r((n) => {
|
|
565
|
+
let r = n.filter((e) => e.id !== t);
|
|
566
|
+
return Oe(e, r), r;
|
|
567
|
+
});
|
|
568
|
+
}, [e]), d = n((t, n) => {
|
|
569
|
+
r((r) => {
|
|
570
|
+
let i = r.map((e) => e.id === t ? {
|
|
571
|
+
...e,
|
|
572
|
+
name: n,
|
|
573
|
+
updatedAt: Date.now()
|
|
574
|
+
} : e);
|
|
575
|
+
return Oe(e, i), i;
|
|
576
|
+
});
|
|
577
|
+
}, [e]), f = n(() => {
|
|
578
|
+
r([]), Oe(e, []);
|
|
579
|
+
}, [e]);
|
|
580
|
+
return i(() => ({
|
|
581
|
+
presets: t,
|
|
582
|
+
savePreset: a,
|
|
583
|
+
loadPreset: s,
|
|
584
|
+
loadPresetById: c,
|
|
585
|
+
updatePreset: l,
|
|
586
|
+
deletePreset: u,
|
|
587
|
+
renamePreset: d,
|
|
588
|
+
clearAllPresets: f
|
|
589
|
+
}), [
|
|
590
|
+
t,
|
|
591
|
+
a,
|
|
592
|
+
s,
|
|
593
|
+
c,
|
|
594
|
+
l,
|
|
595
|
+
u,
|
|
596
|
+
d,
|
|
597
|
+
f
|
|
598
|
+
]);
|
|
599
|
+
}
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/themes.js
|
|
602
|
+
var Ae = {
|
|
603
|
+
background: "#ffffff",
|
|
604
|
+
foreground: "#111827",
|
|
605
|
+
primary: "#2563eb",
|
|
606
|
+
primaryLight: "#eff6ff",
|
|
607
|
+
border: "#e5e7eb",
|
|
608
|
+
muted: "#f3f4f6",
|
|
609
|
+
hover: "#f9fafb",
|
|
610
|
+
selected: "#eff6ff",
|
|
611
|
+
surface: "#f9fafb",
|
|
612
|
+
textSecondary: "#6b7280"
|
|
613
|
+
}, je = {
|
|
614
|
+
background: "#111827",
|
|
615
|
+
foreground: "#f3f4f6",
|
|
616
|
+
primary: "#3b82f6",
|
|
617
|
+
primaryLight: "#1e3a5f",
|
|
618
|
+
border: "#374151",
|
|
619
|
+
muted: "#1f2937",
|
|
620
|
+
hover: "#1f2937",
|
|
621
|
+
selected: "#1e3a5f",
|
|
622
|
+
surface: "#1f2937",
|
|
623
|
+
textSecondary: "#9ca3af"
|
|
624
|
+
}, Me = {
|
|
625
|
+
background: "#ffffff",
|
|
626
|
+
foreground: "#1e1b4b",
|
|
627
|
+
primary: "#7c3aed",
|
|
628
|
+
primaryLight: "#ede9fe",
|
|
629
|
+
border: "#ddd6fe",
|
|
630
|
+
muted: "#f5f3ff",
|
|
631
|
+
hover: "#f5f3ff",
|
|
632
|
+
selected: "#ede9fe",
|
|
633
|
+
surface: "#f8f7ff",
|
|
634
|
+
textSecondary: "#6d28d9"
|
|
635
|
+
}, Ne = {
|
|
636
|
+
background: "#ffffff",
|
|
637
|
+
foreground: "#1a1a2e",
|
|
638
|
+
primary: "#0f766e",
|
|
639
|
+
primaryLight: "#f0fdfa",
|
|
640
|
+
border: "#e2e8f0",
|
|
641
|
+
muted: "#f8fafc",
|
|
642
|
+
hover: "#f1f5f9",
|
|
643
|
+
selected: "#f0fdfa",
|
|
644
|
+
surface: "#f8fafc",
|
|
645
|
+
textSecondary: "#64748b"
|
|
646
|
+
}, Pe = {
|
|
647
|
+
fontFamily: "inherit",
|
|
648
|
+
fontSize: "0.875rem",
|
|
649
|
+
headerFontSize: "0.75rem",
|
|
650
|
+
headerFontWeight: 600
|
|
651
|
+
}, Fe = {
|
|
652
|
+
cellPaddingX: "1rem",
|
|
653
|
+
cellPaddingY: "0.5rem",
|
|
654
|
+
compactCellPaddingY: "0.25rem",
|
|
655
|
+
rowHeight: "2.5rem"
|
|
656
|
+
};
|
|
657
|
+
function Ie(e) {
|
|
658
|
+
return {
|
|
659
|
+
"--dt-bg": e.background,
|
|
660
|
+
"--dt-surface": e.surface,
|
|
661
|
+
"--dt-border": e.border,
|
|
662
|
+
"--dt-text": e.foreground,
|
|
663
|
+
"--dt-text-secondary": e.textSecondary,
|
|
664
|
+
"--dt-brand": e.primary,
|
|
665
|
+
"--dt-brand-light": e.primaryLight,
|
|
666
|
+
"--dt-hover": e.hover,
|
|
667
|
+
"--dt-selected": e.selected,
|
|
668
|
+
"--dt-muted": e.muted
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
function Le(e, t, n = Pe, r = Fe, i) {
|
|
672
|
+
return {
|
|
673
|
+
name: e,
|
|
674
|
+
colors: t,
|
|
675
|
+
typography: n,
|
|
676
|
+
spacing: r,
|
|
677
|
+
header: {
|
|
678
|
+
backgroundColor: t.surface,
|
|
679
|
+
color: t.textSecondary,
|
|
680
|
+
borderBottom: `1px solid ${t.border}`,
|
|
681
|
+
fontWeight: n.headerFontWeight,
|
|
682
|
+
fontSize: n.headerFontSize,
|
|
683
|
+
textTransform: "uppercase",
|
|
684
|
+
letterSpacing: "0.05em"
|
|
685
|
+
},
|
|
686
|
+
row: {
|
|
687
|
+
backgroundColor: t.background,
|
|
688
|
+
color: t.foreground,
|
|
689
|
+
borderBottom: `1px solid ${t.muted}`,
|
|
690
|
+
fontFamily: n.fontFamily,
|
|
691
|
+
fontSize: n.fontSize
|
|
692
|
+
},
|
|
693
|
+
cell: {
|
|
694
|
+
padding: `${r.cellPaddingY} ${r.cellPaddingX}`,
|
|
695
|
+
fontSize: n.fontSize
|
|
696
|
+
},
|
|
697
|
+
selectedRow: { backgroundColor: t.selected },
|
|
698
|
+
hoverRow: { backgroundColor: t.hover },
|
|
699
|
+
stripedRow: { backgroundColor: t.muted },
|
|
700
|
+
toolbar: {
|
|
701
|
+
backgroundColor: t.background,
|
|
702
|
+
borderBottom: `1px solid ${t.border}`
|
|
703
|
+
},
|
|
704
|
+
pagination: {
|
|
705
|
+
backgroundColor: t.background,
|
|
706
|
+
borderTop: `1px solid ${t.border}`
|
|
707
|
+
},
|
|
708
|
+
tooltip: {
|
|
709
|
+
backgroundColor: t.foreground,
|
|
710
|
+
color: t.background,
|
|
711
|
+
padding: "0.375rem 0.625rem",
|
|
712
|
+
borderRadius: "0.375rem",
|
|
713
|
+
fontSize: "0.75rem",
|
|
714
|
+
boxShadow: "0 4px 6px -1px rgba(0,0,0,0.1)"
|
|
715
|
+
},
|
|
716
|
+
cssVariables: Ie(t),
|
|
717
|
+
...i
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
var Re = Le("light", Ae), ze = Le("dark", je), Be = Le("quartz", Me), Ve = Le("alpine", Ne, {
|
|
721
|
+
...Pe,
|
|
722
|
+
fontFamily: "'Inter', system-ui, sans-serif",
|
|
723
|
+
headerFontWeight: 700
|
|
724
|
+
}, {
|
|
725
|
+
...Fe,
|
|
726
|
+
cellPaddingY: "0.625rem"
|
|
727
|
+
}), He = {
|
|
728
|
+
light: Re,
|
|
729
|
+
dark: ze,
|
|
730
|
+
quartz: Be,
|
|
731
|
+
alpine: Ve
|
|
732
|
+
};
|
|
733
|
+
function Ue(e, t) {
|
|
734
|
+
let n = e.colors && t.colors ? {
|
|
735
|
+
...e.colors,
|
|
736
|
+
...t.colors
|
|
737
|
+
} : t.colors ?? e.colors, r = e.typography && t.typography ? {
|
|
738
|
+
...e.typography,
|
|
739
|
+
...t.typography
|
|
740
|
+
} : t.typography ?? e.typography, i = e.spacing && t.spacing ? {
|
|
741
|
+
...e.spacing,
|
|
742
|
+
...t.spacing
|
|
743
|
+
} : t.spacing ?? e.spacing;
|
|
744
|
+
return {
|
|
745
|
+
...e,
|
|
746
|
+
...t,
|
|
747
|
+
colors: n,
|
|
748
|
+
typography: r,
|
|
749
|
+
spacing: i,
|
|
750
|
+
header: {
|
|
751
|
+
...e.header,
|
|
752
|
+
...t.header
|
|
753
|
+
},
|
|
754
|
+
row: {
|
|
755
|
+
...e.row,
|
|
756
|
+
...t.row
|
|
757
|
+
},
|
|
758
|
+
cell: {
|
|
759
|
+
...e.cell,
|
|
760
|
+
...t.cell
|
|
761
|
+
},
|
|
762
|
+
selectedRow: {
|
|
763
|
+
...e.selectedRow,
|
|
764
|
+
...t.selectedRow
|
|
765
|
+
},
|
|
766
|
+
hoverRow: {
|
|
767
|
+
...e.hoverRow,
|
|
768
|
+
...t.hoverRow
|
|
769
|
+
},
|
|
770
|
+
stripedRow: {
|
|
771
|
+
...e.stripedRow,
|
|
772
|
+
...t.stripedRow
|
|
773
|
+
},
|
|
774
|
+
toolbar: {
|
|
775
|
+
...e.toolbar,
|
|
776
|
+
...t.toolbar
|
|
777
|
+
},
|
|
778
|
+
pagination: {
|
|
779
|
+
...e.pagination,
|
|
780
|
+
...t.pagination
|
|
781
|
+
},
|
|
782
|
+
tooltip: {
|
|
783
|
+
...e.tooltip,
|
|
784
|
+
...t.tooltip
|
|
785
|
+
},
|
|
786
|
+
cssVariables: {
|
|
787
|
+
...e.cssVariables,
|
|
788
|
+
...t.cssVariables
|
|
789
|
+
},
|
|
790
|
+
conditionalRules: [...e.conditionalRules ?? [], ...t.conditionalRules ?? []],
|
|
791
|
+
rowRules: [...e.rowRules ?? [], ...t.rowRules ?? []]
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
//#endregion
|
|
795
|
+
//#region src/hooks/useTheme.js
|
|
796
|
+
var We = "datatable_theme_";
|
|
797
|
+
function Ge({ themeConfig: e, persistKey: t }) {
|
|
798
|
+
let [r, a] = o(() => {
|
|
799
|
+
if (t) try {
|
|
800
|
+
return localStorage.getItem(`${We}${t}`) ?? e?.name ?? "light";
|
|
801
|
+
} catch {}
|
|
802
|
+
return e?.name ?? "light";
|
|
803
|
+
}), s = n((e) => {
|
|
804
|
+
if (a(e), t) try {
|
|
805
|
+
localStorage.setItem(`${We}${t}`, e);
|
|
806
|
+
} catch {}
|
|
807
|
+
}, [t]), c = i(() => e || (He[r] ?? He.light), [e, r]), l = i(() => c?.cssVariables ?? void 0, [c]), u = i(() => (e, t, n, r) => {
|
|
808
|
+
let i = { ...c.row };
|
|
809
|
+
if (n && c.selectedRow ? i = {
|
|
810
|
+
...i,
|
|
811
|
+
...c.selectedRow
|
|
812
|
+
} : r && t % 2 == 1 && c.stripedRow && (i = {
|
|
813
|
+
...i,
|
|
814
|
+
...c.stripedRow
|
|
815
|
+
}), c.conditionalRules) for (let t of c.conditionalRules) t.condition(e) && t.style && (i = {
|
|
816
|
+
...i,
|
|
817
|
+
...t.style
|
|
818
|
+
});
|
|
819
|
+
if (c.rowRules) for (let t of c.rowRules) t.condition(e) && t.style && (i = {
|
|
820
|
+
...i,
|
|
821
|
+
...t.style
|
|
822
|
+
});
|
|
823
|
+
return i;
|
|
824
|
+
}, [c]), d = i(() => (e, t) => {
|
|
825
|
+
let n = { ...c.cell };
|
|
826
|
+
if (c.conditionalRules) for (let r of c.conditionalRules) r.condition(e, t) && r.style && (n = {
|
|
827
|
+
...n,
|
|
828
|
+
...r.style
|
|
829
|
+
});
|
|
830
|
+
return n;
|
|
831
|
+
}, [c]), f = i(() => () => ({ ...c.header }), [c]), p = i(() => c.conditionalRules?.length || c.rowRules?.length ? (e, t) => {
|
|
832
|
+
let n = [];
|
|
833
|
+
if (c.conditionalRules) for (let r of c.conditionalRules) r.condition(e, t) && r.className && n.push(r.className);
|
|
834
|
+
if (!t && c.rowRules) for (let t of c.rowRules) t.condition(e) && t.className && n.push(t.className);
|
|
835
|
+
return n.join(" ");
|
|
836
|
+
} : () => "", [c]);
|
|
837
|
+
return i(() => ({
|
|
838
|
+
themeConfig: c,
|
|
839
|
+
activeThemeName: r,
|
|
840
|
+
switchTheme: s,
|
|
841
|
+
cssVarStyle: l,
|
|
842
|
+
headerStyle: c.header,
|
|
843
|
+
toolbarStyle: c.toolbar,
|
|
844
|
+
paginationStyle: c.pagination,
|
|
845
|
+
tooltipStyle: c.tooltip,
|
|
846
|
+
getRowStyle: u,
|
|
847
|
+
getCellStyle: d,
|
|
848
|
+
getHeaderStyle: f,
|
|
849
|
+
getConditionalClassName: p
|
|
850
|
+
}), [
|
|
851
|
+
c,
|
|
852
|
+
r,
|
|
853
|
+
s,
|
|
854
|
+
l,
|
|
855
|
+
u,
|
|
856
|
+
d,
|
|
857
|
+
f,
|
|
858
|
+
p
|
|
859
|
+
]);
|
|
860
|
+
}
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/hooks/useVirtualization.js
|
|
863
|
+
function Ke({ totalItems: e, config: t }) {
|
|
864
|
+
let s = t?.enabled ?? !1, c = t?.rowHeight ?? 40, l = t?.overscan ?? 5, u = a(null), [d, f] = o(0), [p, m] = o(0);
|
|
865
|
+
r(() => {
|
|
866
|
+
if (!s) return;
|
|
867
|
+
let e = u.current;
|
|
868
|
+
if (!e) return;
|
|
869
|
+
let t = new ResizeObserver((e) => {
|
|
870
|
+
for (let t of e) m(t.contentRect.height);
|
|
871
|
+
});
|
|
872
|
+
return t.observe(e), m(e.clientHeight), () => t.disconnect();
|
|
873
|
+
}, [s]);
|
|
874
|
+
let h = n(() => {
|
|
875
|
+
!s || !u.current || f(u.current.scrollTop);
|
|
876
|
+
}, [s]), g = i(() => {
|
|
877
|
+
if (!s) return {
|
|
878
|
+
startIndex: 0,
|
|
879
|
+
endIndex: e,
|
|
880
|
+
offsetTop: 0,
|
|
881
|
+
totalHeight: 0,
|
|
882
|
+
visibleCount: e
|
|
883
|
+
};
|
|
884
|
+
let t = e * c, n = Math.ceil(p / c), r = Math.max(0, Math.floor(d / c) - l);
|
|
885
|
+
return {
|
|
886
|
+
startIndex: r,
|
|
887
|
+
endIndex: Math.min(e, r + n + l * 2),
|
|
888
|
+
offsetTop: r * c,
|
|
889
|
+
totalHeight: t,
|
|
890
|
+
visibleCount: n
|
|
891
|
+
};
|
|
892
|
+
}, [
|
|
893
|
+
s,
|
|
894
|
+
e,
|
|
895
|
+
c,
|
|
896
|
+
p,
|
|
897
|
+
d,
|
|
898
|
+
l
|
|
899
|
+
]), _ = n((e) => s ? e.slice(g.startIndex, g.endIndex) : e, [s, g]);
|
|
900
|
+
return i(() => ({
|
|
901
|
+
enabled: s,
|
|
902
|
+
containerRef: u,
|
|
903
|
+
handleScroll: h,
|
|
904
|
+
virtualRange: g,
|
|
905
|
+
getVirtualItems: _,
|
|
906
|
+
rowHeight: c,
|
|
907
|
+
spacerStyle: s ? {
|
|
908
|
+
height: g.totalHeight,
|
|
909
|
+
position: "relative"
|
|
910
|
+
} : void 0,
|
|
911
|
+
offsetStyle: s ? { transform: `translateY(${g.offsetTop}px)` } : void 0
|
|
912
|
+
}), [
|
|
913
|
+
s,
|
|
914
|
+
h,
|
|
915
|
+
g,
|
|
916
|
+
_,
|
|
917
|
+
c
|
|
918
|
+
]);
|
|
919
|
+
}
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region src/hooks/useRowGrouping.js
|
|
922
|
+
function qe(e, t) {
|
|
923
|
+
if (!e.length) return null;
|
|
924
|
+
switch (t) {
|
|
925
|
+
case "sum": return e.reduce((e, t) => Number(e) + Number(t), 0);
|
|
926
|
+
case "avg": return e.reduce((e, t) => Number(e) + Number(t), 0) / e.length;
|
|
927
|
+
case "count": return e.length;
|
|
928
|
+
case "min": return Math.min(...e.map(Number));
|
|
929
|
+
case "max": return Math.max(...e.map(Number));
|
|
930
|
+
case "first": return e[0];
|
|
931
|
+
case "last": return e[e.length - 1];
|
|
932
|
+
default: return e.length;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
function Je({ config: e, columns: t }) {
|
|
936
|
+
let [r, a] = o(() => e?.defaultExpanded ? new Set(["__all__"]) : /* @__PURE__ */ new Set()), s = n((e) => r.has("__all__") || r.has(e), [r]), c = n((e) => {
|
|
937
|
+
a((t) => {
|
|
938
|
+
let n = new Set(t);
|
|
939
|
+
return n.has("__all__") ? (n.delete("__all__"), n.delete(e), n) : (n.has(e) ? n.delete(e) : n.add(e), n);
|
|
940
|
+
});
|
|
941
|
+
}, []), l = n(() => a(new Set(["__all__"])), []), u = n(() => a(/* @__PURE__ */ new Set()), []), d = n((n) => {
|
|
942
|
+
if (!e?.groupBy?.length) return n;
|
|
943
|
+
let r = e.groupBy, i = e.aggregations ?? {};
|
|
944
|
+
function a(e, n, o) {
|
|
945
|
+
if (n >= r.length) return e;
|
|
946
|
+
let c = r[n], l = /* @__PURE__ */ new Map();
|
|
947
|
+
for (let t of e) {
|
|
948
|
+
let e = X(t, c) ?? "__null__";
|
|
949
|
+
l.has(e) || l.set(e, []), l.get(e).push(t);
|
|
950
|
+
}
|
|
951
|
+
let u = [];
|
|
952
|
+
for (let [e, r] of l) {
|
|
953
|
+
let l = `${o}${c}:${e}`, d = {};
|
|
954
|
+
for (let [e, n] of Object.entries(i)) {
|
|
955
|
+
let i = t.find((t) => t.id === e);
|
|
956
|
+
i && (d[e] = qe(r.map((e) => Z(e, i)), n));
|
|
957
|
+
}
|
|
958
|
+
u.push({
|
|
959
|
+
__isGroupRow: !0,
|
|
960
|
+
__groupKey: l,
|
|
961
|
+
__groupValue: e,
|
|
962
|
+
__groupField: c,
|
|
963
|
+
__level: n,
|
|
964
|
+
__children: r,
|
|
965
|
+
__aggregates: d
|
|
966
|
+
}), s(l) && u.push(...a(r, n + 1, `${l}/`));
|
|
967
|
+
}
|
|
968
|
+
return u;
|
|
969
|
+
}
|
|
970
|
+
return a(n, 0, "");
|
|
971
|
+
}, [
|
|
972
|
+
e,
|
|
973
|
+
t,
|
|
974
|
+
s
|
|
975
|
+
]);
|
|
976
|
+
return i(() => ({
|
|
977
|
+
enabled: !!e?.groupBy?.length,
|
|
978
|
+
expandedGroups: r,
|
|
979
|
+
isGroupExpanded: s,
|
|
980
|
+
toggleGroup: c,
|
|
981
|
+
expandAllGroups: l,
|
|
982
|
+
collapseAllGroups: u,
|
|
983
|
+
applyGrouping: d
|
|
984
|
+
}), [
|
|
985
|
+
e,
|
|
986
|
+
r,
|
|
987
|
+
s,
|
|
988
|
+
c,
|
|
989
|
+
l,
|
|
990
|
+
u,
|
|
991
|
+
d
|
|
992
|
+
]);
|
|
993
|
+
}
|
|
994
|
+
//#endregion
|
|
995
|
+
//#region src/hooks/useTreeData.js
|
|
996
|
+
function Ye({ config: e, rowKey: t }) {
|
|
997
|
+
let [r, a] = o(() => e?.defaultExpanded ? new Set(["__all__"]) : /* @__PURE__ */ new Set()), s = n((e, n) => typeof t == "function" ? t(e) : typeof t == "string" ? String(X(e, t)) : e.id === void 0 ? String(n) : String(e.id), [t]), c = n((e) => r.has("__all__") || r.has(e), [r]), l = n((e) => {
|
|
998
|
+
a((t) => {
|
|
999
|
+
let n = new Set(t);
|
|
1000
|
+
return n.has("__all__") ? (n.delete("__all__"), n.delete(e), n) : (n.has(e) ? n.delete(e) : n.add(e), n);
|
|
1001
|
+
});
|
|
1002
|
+
}, []), u = n((t) => {
|
|
1003
|
+
if (!e) return t.map((e, t) => ({
|
|
1004
|
+
row: e,
|
|
1005
|
+
level: 0,
|
|
1006
|
+
hasChildren: !1,
|
|
1007
|
+
isExpanded: !1,
|
|
1008
|
+
treeKey: s(e, t)
|
|
1009
|
+
}));
|
|
1010
|
+
let n = e.childrenField, r = [];
|
|
1011
|
+
function i(e, t, a) {
|
|
1012
|
+
e.forEach((e, o) => {
|
|
1013
|
+
let l = s(e, a + o), u = X(e, n), d = Array.isArray(u) && u.length > 0, f = d && c(l);
|
|
1014
|
+
r.push({
|
|
1015
|
+
row: e,
|
|
1016
|
+
level: t,
|
|
1017
|
+
hasChildren: d,
|
|
1018
|
+
isExpanded: f,
|
|
1019
|
+
treeKey: l
|
|
1020
|
+
}), f && u && i(u, t + 1, r.length);
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
return i(t, 0, 0), r;
|
|
1024
|
+
}, [
|
|
1025
|
+
e,
|
|
1026
|
+
s,
|
|
1027
|
+
c
|
|
1028
|
+
]), d = e?.indentSize ?? 24;
|
|
1029
|
+
return i(() => ({
|
|
1030
|
+
enabled: !!e,
|
|
1031
|
+
flattenTree: u,
|
|
1032
|
+
toggleNode: l,
|
|
1033
|
+
isNodeExpanded: c,
|
|
1034
|
+
expandedNodes: r,
|
|
1035
|
+
indentSize: d
|
|
1036
|
+
}), [
|
|
1037
|
+
e,
|
|
1038
|
+
u,
|
|
1039
|
+
l,
|
|
1040
|
+
c,
|
|
1041
|
+
r,
|
|
1042
|
+
d
|
|
1043
|
+
]);
|
|
1044
|
+
}
|
|
1045
|
+
//#endregion
|
|
1046
|
+
//#region src/hooks/useEditing.js
|
|
1047
|
+
function Xe({ config: e, columns: t, data: r, getKey: a }) {
|
|
1048
|
+
let [s, c] = o(null), [l, u] = o(null), [d, f] = o({}), [p, m] = o({}), h = n((e, t) => c({
|
|
1049
|
+
rowKey: e,
|
|
1050
|
+
columnId: t
|
|
1051
|
+
}), []), g = n((n, i, o) => {
|
|
1052
|
+
let s = t.find((e) => e.id === i), l = r.find((e, t) => a(e, t) === n), u = s?.validation ?? e?.validation?.[i];
|
|
1053
|
+
if (u && l && s) {
|
|
1054
|
+
let e = u.validate(o, l, s);
|
|
1055
|
+
if (e) return m((t) => ({
|
|
1056
|
+
...t,
|
|
1057
|
+
[i]: e
|
|
1058
|
+
})), e;
|
|
1059
|
+
}
|
|
1060
|
+
return m((e) => {
|
|
1061
|
+
let t = { ...e };
|
|
1062
|
+
return delete t[i], t;
|
|
1063
|
+
}), c(null), null;
|
|
1064
|
+
}, [
|
|
1065
|
+
t,
|
|
1066
|
+
r,
|
|
1067
|
+
a,
|
|
1068
|
+
e?.validation
|
|
1069
|
+
]), _ = n(() => {
|
|
1070
|
+
c(null), m({});
|
|
1071
|
+
}, []), v = n((n) => {
|
|
1072
|
+
if (!e?.enabled) return;
|
|
1073
|
+
let i = r.find((e, t) => a(e, t) === n);
|
|
1074
|
+
if (!i) return;
|
|
1075
|
+
let o = {};
|
|
1076
|
+
t.forEach((e) => {
|
|
1077
|
+
e.editable && (o[e.id] = Z(i, e));
|
|
1078
|
+
}), u(n), f(o), m({});
|
|
1079
|
+
}, [
|
|
1080
|
+
e?.enabled,
|
|
1081
|
+
r,
|
|
1082
|
+
a,
|
|
1083
|
+
t
|
|
1084
|
+
]), y = n((e, t) => {
|
|
1085
|
+
f((n) => ({
|
|
1086
|
+
...n,
|
|
1087
|
+
[e]: t
|
|
1088
|
+
})), m((t) => {
|
|
1089
|
+
if (!t[e]) return t;
|
|
1090
|
+
let n = { ...t };
|
|
1091
|
+
return delete n[e], n;
|
|
1092
|
+
});
|
|
1093
|
+
}, []), b = n(() => {
|
|
1094
|
+
if (!l) return !1;
|
|
1095
|
+
let n = r.find((e, t) => a(e, t) === l);
|
|
1096
|
+
if (!n) return !1;
|
|
1097
|
+
let i = {};
|
|
1098
|
+
return t.forEach((t) => {
|
|
1099
|
+
if (!t.editable) return;
|
|
1100
|
+
let r = t.validation ?? e?.validation?.[t.id];
|
|
1101
|
+
if (!r) return;
|
|
1102
|
+
let a = r.validate(d[t.id], n, t);
|
|
1103
|
+
a && (i[t.id] = a);
|
|
1104
|
+
}), m(i), Object.keys(i).length === 0;
|
|
1105
|
+
}, [
|
|
1106
|
+
l,
|
|
1107
|
+
r,
|
|
1108
|
+
a,
|
|
1109
|
+
t,
|
|
1110
|
+
e?.validation,
|
|
1111
|
+
d
|
|
1112
|
+
]), x = n(async () => !l || !e?.onSave || !b() ? !1 : (await e.onSave(l, d), u(null), f({}), m({}), !0), [
|
|
1113
|
+
l,
|
|
1114
|
+
e,
|
|
1115
|
+
b,
|
|
1116
|
+
d
|
|
1117
|
+
]), S = n(() => {
|
|
1118
|
+
e?.onCancel?.(l ?? ""), u(null), f({}), m({});
|
|
1119
|
+
}, [e, l]), C = n((e) => l === e, [l]), w = n((e) => p[e] ?? null, [p]);
|
|
1120
|
+
return i(() => ({
|
|
1121
|
+
editingCell: s,
|
|
1122
|
+
startCellEdit: h,
|
|
1123
|
+
saveCellEdit: g,
|
|
1124
|
+
cancelCellEdit: _,
|
|
1125
|
+
editingRowKey: l,
|
|
1126
|
+
pendingEdits: d,
|
|
1127
|
+
validationErrors: p,
|
|
1128
|
+
startRowEdit: v,
|
|
1129
|
+
updatePendingEdit: y,
|
|
1130
|
+
validateRow: b,
|
|
1131
|
+
saveRowEdit: x,
|
|
1132
|
+
cancelRowEdit: S,
|
|
1133
|
+
isEditingRow: C,
|
|
1134
|
+
getCellError: w
|
|
1135
|
+
}), [
|
|
1136
|
+
s,
|
|
1137
|
+
h,
|
|
1138
|
+
g,
|
|
1139
|
+
_,
|
|
1140
|
+
l,
|
|
1141
|
+
d,
|
|
1142
|
+
p,
|
|
1143
|
+
v,
|
|
1144
|
+
y,
|
|
1145
|
+
b,
|
|
1146
|
+
x,
|
|
1147
|
+
S,
|
|
1148
|
+
C,
|
|
1149
|
+
w
|
|
1150
|
+
]);
|
|
1151
|
+
}
|
|
1152
|
+
//#endregion
|
|
1153
|
+
//#region src/hooks/useChartConfig.js
|
|
1154
|
+
var Ze = "datatable_charts_";
|
|
1155
|
+
function Qe(e) {
|
|
1156
|
+
try {
|
|
1157
|
+
let t = localStorage.getItem(`${Ze}${e}`);
|
|
1158
|
+
return t ? JSON.parse(t) : [];
|
|
1159
|
+
} catch {
|
|
1160
|
+
return [];
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
function $e(e, t) {
|
|
1164
|
+
try {
|
|
1165
|
+
localStorage.setItem(`${Ze}${e}`, JSON.stringify(t));
|
|
1166
|
+
} catch {}
|
|
1167
|
+
}
|
|
1168
|
+
function et({ tableId: e } = {}) {
|
|
1169
|
+
let t = e ?? "__default__", [r, a] = o(() => Qe(t)), [s, c] = o(!1), [l, u] = o(null), d = n((e) => {
|
|
1170
|
+
let n = {
|
|
1171
|
+
id: `chart_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`,
|
|
1172
|
+
config: {
|
|
1173
|
+
...e,
|
|
1174
|
+
id: void 0
|
|
1175
|
+
},
|
|
1176
|
+
createdAt: Date.now()
|
|
1177
|
+
};
|
|
1178
|
+
return a((e) => {
|
|
1179
|
+
let r = [...e, n];
|
|
1180
|
+
return $e(t, r), r;
|
|
1181
|
+
}), n;
|
|
1182
|
+
}, [t]), f = n((e, n) => {
|
|
1183
|
+
a((r) => {
|
|
1184
|
+
let i = r.map((t) => t.id === e ? {
|
|
1185
|
+
...t,
|
|
1186
|
+
config: {
|
|
1187
|
+
...t.config,
|
|
1188
|
+
...n
|
|
1189
|
+
}
|
|
1190
|
+
} : t);
|
|
1191
|
+
return $e(t, i), i;
|
|
1192
|
+
});
|
|
1193
|
+
}, [t]), p = n((e) => {
|
|
1194
|
+
a((n) => {
|
|
1195
|
+
let r = n.filter((t) => t.id !== e);
|
|
1196
|
+
return $e(t, r), r;
|
|
1197
|
+
});
|
|
1198
|
+
}, [t]), m = n(() => {
|
|
1199
|
+
a([]), $e(t, []);
|
|
1200
|
+
}, [t]), h = n((e) => {
|
|
1201
|
+
u(e ?? null), c(!0);
|
|
1202
|
+
}, []), g = n(() => {
|
|
1203
|
+
c(!1), u(null);
|
|
1204
|
+
}, []), _ = i(() => l ? r.find((e) => e.id === l) ?? null : null, [l, r]);
|
|
1205
|
+
return i(() => ({
|
|
1206
|
+
charts: r,
|
|
1207
|
+
addChart: d,
|
|
1208
|
+
updateChart: f,
|
|
1209
|
+
removeChart: p,
|
|
1210
|
+
clearCharts: m,
|
|
1211
|
+
builderOpen: s,
|
|
1212
|
+
openBuilder: h,
|
|
1213
|
+
closeBuilder: g,
|
|
1214
|
+
editingChart: _,
|
|
1215
|
+
editingChartId: l
|
|
1216
|
+
}), [
|
|
1217
|
+
r,
|
|
1218
|
+
d,
|
|
1219
|
+
f,
|
|
1220
|
+
p,
|
|
1221
|
+
m,
|
|
1222
|
+
s,
|
|
1223
|
+
h,
|
|
1224
|
+
g,
|
|
1225
|
+
_,
|
|
1226
|
+
l
|
|
1227
|
+
]);
|
|
1228
|
+
}
|
|
1229
|
+
//#endregion
|
|
1230
|
+
//#region src/hooks/useDataTable.js
|
|
1231
|
+
function tt(e) {
|
|
1232
|
+
let { data: t, columns: a, mode: s = "client", serverSide: c, loading: l = !1, sorting: u, filtering: d, pagination: f, selection: p, expandable: m, plugins: h = [], viewMode: g, onViewModeChange: _, columnVisibility: v = !1, columnResizing: y = !1, columnReordering: b = !1, persistKey: x, syncUrl: S, themeConfig: C, rowGrouping: w, treeData: T, rowPinning: E, virtualization: D, rowEditing: O } = e, [ee, k] = o(g ?? "table"), A = g ?? ee, j = n((e) => {
|
|
1233
|
+
_ ? _(e) : k(e);
|
|
1234
|
+
}, [_]), [M, N] = o([]), P = m?.expandedKeys ?? M, te = n((e) => {
|
|
1235
|
+
let t = P.includes(e) ? P.filter((t) => t !== e) : [...P, e];
|
|
1236
|
+
m?.onExpandChange ? m.onExpandChange(t) : N(t);
|
|
1237
|
+
}, [P, m]), F = n((e, t) => ce(e, p?.rowKey, t), [p?.rowKey]), I = Xe({
|
|
1238
|
+
config: O,
|
|
1239
|
+
columns: a,
|
|
1240
|
+
data: t,
|
|
1241
|
+
getKey: F
|
|
1242
|
+
}), L = I.editingCell, R = I.startCellEdit, z = Ce({
|
|
1243
|
+
columns: a,
|
|
1244
|
+
enableVisibility: v,
|
|
1245
|
+
enableResizing: y,
|
|
1246
|
+
enableReordering: b
|
|
1247
|
+
}), B = ye({
|
|
1248
|
+
config: u,
|
|
1249
|
+
columns: a
|
|
1250
|
+
}), V = be({
|
|
1251
|
+
config: d,
|
|
1252
|
+
columns: a
|
|
1253
|
+
}), H = Ge({ themeConfig: C }), U = Je({
|
|
1254
|
+
config: w,
|
|
1255
|
+
columns: a
|
|
1256
|
+
}), W = Ye({
|
|
1257
|
+
config: T,
|
|
1258
|
+
rowKey: p?.rowKey
|
|
1259
|
+
}), G = ke({ tableId: x ?? "__default__" }), K = et({ tableId: x }), [q, ne] = o(E?.pinnedTop ?? []), [J, re] = o(E?.pinnedBottom ?? []), ie = n((e, t) => {
|
|
1260
|
+
ne((t) => t.filter((t) => t !== e)), re((t) => t.filter((t) => t !== e)), t === "top" && ne((t) => [...t, e]), t === "bottom" && re((t) => [...t, e]), E?.onPinChange?.(t === "top" ? [...q, e] : q.filter((t) => t !== e), t === "bottom" ? [...J, e] : J.filter((t) => t !== e));
|
|
1261
|
+
}, [
|
|
1262
|
+
q,
|
|
1263
|
+
J,
|
|
1264
|
+
E
|
|
1265
|
+
]), [ae, oe] = o([]), [se, Y] = o(0), [X, Z] = o(!1), le = i(() => s === "server" ? ae : V.applyFilters(t), [
|
|
1266
|
+
s,
|
|
1267
|
+
t,
|
|
1268
|
+
ae,
|
|
1269
|
+
V
|
|
1270
|
+
]), ue = i(() => s === "server" ? le : B.applySorting(le), [
|
|
1271
|
+
s,
|
|
1272
|
+
le,
|
|
1273
|
+
B
|
|
1274
|
+
]), de = i(() => {
|
|
1275
|
+
let e = ue;
|
|
1276
|
+
for (let t of h) t.processData && (e = t.processData(e, he));
|
|
1277
|
+
return e;
|
|
1278
|
+
}, [ue, h]), fe = s === "server" ? se : de.length, Q = xe({
|
|
1279
|
+
config: f,
|
|
1280
|
+
totalItems: fe
|
|
1281
|
+
}), $ = i(() => s === "server" || Q.isInfinite ? de : Q.applyPagination(de), [
|
|
1282
|
+
s,
|
|
1283
|
+
de,
|
|
1284
|
+
Q
|
|
1285
|
+
]), pe = Ke({
|
|
1286
|
+
totalItems: $.length,
|
|
1287
|
+
config: D
|
|
1288
|
+
}), me = Se({
|
|
1289
|
+
config: p,
|
|
1290
|
+
data: t
|
|
1291
|
+
});
|
|
1292
|
+
r(() => {
|
|
1293
|
+
if (s !== "server" || !c?.onFetch) return;
|
|
1294
|
+
let e = !1;
|
|
1295
|
+
return Z(!0), c.onFetch({
|
|
1296
|
+
page: Q.page,
|
|
1297
|
+
pageSize: Q.pageSize,
|
|
1298
|
+
sort: B.sorting,
|
|
1299
|
+
filters: V.filters,
|
|
1300
|
+
globalSearch: V.globalSearch
|
|
1301
|
+
}).then((t) => {
|
|
1302
|
+
e || (oe(t.data), Y(t.totalItems));
|
|
1303
|
+
}).finally(() => {
|
|
1304
|
+
e || Z(!1);
|
|
1305
|
+
}), () => {
|
|
1306
|
+
e = !0;
|
|
1307
|
+
};
|
|
1308
|
+
}, [
|
|
1309
|
+
s,
|
|
1310
|
+
c,
|
|
1311
|
+
Q.page,
|
|
1312
|
+
Q.pageSize,
|
|
1313
|
+
B.sorting,
|
|
1314
|
+
V.filters,
|
|
1315
|
+
V.globalSearch
|
|
1316
|
+
]);
|
|
1317
|
+
let he = i(() => ({
|
|
1318
|
+
data: t,
|
|
1319
|
+
processedData: $,
|
|
1320
|
+
columns: a,
|
|
1321
|
+
visibleColumns: z.visibleColumns,
|
|
1322
|
+
sorting: B.sorting,
|
|
1323
|
+
filters: V.filters,
|
|
1324
|
+
globalSearch: V.globalSearch,
|
|
1325
|
+
page: Q.page,
|
|
1326
|
+
pageSize: Q.pageSize,
|
|
1327
|
+
totalItems: fe,
|
|
1328
|
+
selectedKeys: me.selectedKeys,
|
|
1329
|
+
expandedKeys: P,
|
|
1330
|
+
viewMode: A,
|
|
1331
|
+
columnOrder: z.columnOrder,
|
|
1332
|
+
columnWidths: z.columnWidths,
|
|
1333
|
+
editingCell: L
|
|
1334
|
+
}), [
|
|
1335
|
+
t,
|
|
1336
|
+
$,
|
|
1337
|
+
a,
|
|
1338
|
+
z,
|
|
1339
|
+
B,
|
|
1340
|
+
V,
|
|
1341
|
+
Q,
|
|
1342
|
+
fe,
|
|
1343
|
+
me,
|
|
1344
|
+
P,
|
|
1345
|
+
A,
|
|
1346
|
+
L
|
|
1347
|
+
]);
|
|
1348
|
+
we({
|
|
1349
|
+
persistKey: x,
|
|
1350
|
+
syncUrl: S,
|
|
1351
|
+
state: {
|
|
1352
|
+
sorting: B.sorting,
|
|
1353
|
+
filters: V.filters,
|
|
1354
|
+
globalSearch: V.globalSearch,
|
|
1355
|
+
page: Q.page,
|
|
1356
|
+
pageSize: Q.pageSize,
|
|
1357
|
+
viewMode: A,
|
|
1358
|
+
hiddenColumns: z.hiddenColumns,
|
|
1359
|
+
columnOrder: z.columnOrder
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
let ge = n(() => ({
|
|
1363
|
+
columnOrder: z.columnOrder,
|
|
1364
|
+
hiddenColumns: Array.from(z.hiddenColumns),
|
|
1365
|
+
columnWidths: z.columnWidths,
|
|
1366
|
+
sorting: B.sorting,
|
|
1367
|
+
filters: V.filters,
|
|
1368
|
+
globalSearch: V.globalSearch,
|
|
1369
|
+
pageSize: Q.pageSize,
|
|
1370
|
+
viewMode: A
|
|
1371
|
+
}), [
|
|
1372
|
+
z,
|
|
1373
|
+
B,
|
|
1374
|
+
V,
|
|
1375
|
+
Q,
|
|
1376
|
+
A
|
|
1377
|
+
]), _e = n((e) => {
|
|
1378
|
+
let t = G.loadPresetById(e);
|
|
1379
|
+
t && (t.columnOrder?.length && z.setColumnOrderIds(t.columnOrder), t.hiddenColumns && z.setHiddenColumnIds(t.hiddenColumns), t.columnWidths && z.setColumnWidthMap(t.columnWidths), B.setSorting(t.sorting ?? []), V.setFilters(t.filters ?? []), V.setGlobalSearch(t.globalSearch ?? ""), t.pageSize && Q.setPageSize(t.pageSize), t.viewMode && j(t.viewMode));
|
|
1380
|
+
}, [
|
|
1381
|
+
G,
|
|
1382
|
+
z,
|
|
1383
|
+
B,
|
|
1384
|
+
V,
|
|
1385
|
+
Q,
|
|
1386
|
+
j
|
|
1387
|
+
]), ve = i(() => $.filter((e, t) => q.includes(F(e, t))), [
|
|
1388
|
+
$,
|
|
1389
|
+
q,
|
|
1390
|
+
F
|
|
1391
|
+
]), Te = i(() => $.filter((e, t) => J.includes(F(e, t))), [
|
|
1392
|
+
$,
|
|
1393
|
+
J,
|
|
1394
|
+
F
|
|
1395
|
+
]), Ee = i(() => $.filter((e, t) => {
|
|
1396
|
+
let n = F(e, t);
|
|
1397
|
+
return !q.includes(n) && !J.includes(n);
|
|
1398
|
+
}), [
|
|
1399
|
+
$,
|
|
1400
|
+
q,
|
|
1401
|
+
J,
|
|
1402
|
+
F
|
|
1403
|
+
]);
|
|
1404
|
+
return {
|
|
1405
|
+
state: he,
|
|
1406
|
+
processedData: $,
|
|
1407
|
+
allFilteredData: de,
|
|
1408
|
+
loading: l || X,
|
|
1409
|
+
sorting: B,
|
|
1410
|
+
filtering: V,
|
|
1411
|
+
pagination: Q,
|
|
1412
|
+
selection: me,
|
|
1413
|
+
columnManager: z,
|
|
1414
|
+
viewMode: A,
|
|
1415
|
+
setViewMode: j,
|
|
1416
|
+
expandedKeys: P,
|
|
1417
|
+
toggleExpand: te,
|
|
1418
|
+
editingCell: L,
|
|
1419
|
+
setEditingCell: R,
|
|
1420
|
+
editing: I,
|
|
1421
|
+
theme: H,
|
|
1422
|
+
rowGrouping: U,
|
|
1423
|
+
treeData: W,
|
|
1424
|
+
presets: G,
|
|
1425
|
+
chartConfig: K,
|
|
1426
|
+
virtualization: pe,
|
|
1427
|
+
pinnedTopRows: ve,
|
|
1428
|
+
pinnedBottomRows: Te,
|
|
1429
|
+
unpinnedData: Ee,
|
|
1430
|
+
pinRow: ie,
|
|
1431
|
+
getKey: F,
|
|
1432
|
+
getCurrentPresetConfig: ge,
|
|
1433
|
+
applyPreset: _e,
|
|
1434
|
+
plugins: h
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
//#endregion
|
|
1438
|
+
//#region src/exportUtils.js
|
|
1439
|
+
function nt(e, t) {
|
|
1440
|
+
let n = URL.createObjectURL(e), r = document.createElement("a");
|
|
1441
|
+
r.href = n, r.download = t, document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(n);
|
|
1442
|
+
}
|
|
1443
|
+
function rt(e, t) {
|
|
1444
|
+
return t?.length ? t.map((t) => e.find((e) => e.id === t)).filter((e) => e != null) : e;
|
|
1445
|
+
}
|
|
1446
|
+
function it(e, t) {
|
|
1447
|
+
return e.map((e) => t.map((t) => {
|
|
1448
|
+
let n = Z(e, t);
|
|
1449
|
+
return String(n ?? "");
|
|
1450
|
+
}));
|
|
1451
|
+
}
|
|
1452
|
+
function at(e, t, n, r = "export") {
|
|
1453
|
+
let i = rt(t, n), a = i.map((e) => e.header), o = it(e, i), s = (e) => e.includes(",") || e.includes("\"") || e.includes("\n") ? `"${e.replace(/"/g, "\"\"")}"` : e, c = [a.map(s).join(","), ...o.map((e) => e.map(s).join(","))].join("\n");
|
|
1454
|
+
nt(new Blob(["" + c], { type: "text/csv;charset=utf-8;" }), `${r}.csv`);
|
|
1455
|
+
}
|
|
1456
|
+
async function ot(e, t, n, r = "export", i = "Sheet1") {
|
|
1457
|
+
let a = rt(t, n), o = a.map((e) => e.header), s = it(e, a);
|
|
1458
|
+
try {
|
|
1459
|
+
let e = await import("xlsx"), t = [o, ...s], n = e.utils.aoa_to_sheet(t);
|
|
1460
|
+
n["!cols"] = o.map((e, t) => {
|
|
1461
|
+
let n = Math.max(e.length, ...s.map((e) => (e[t] ?? "").length));
|
|
1462
|
+
return { wch: Math.min(n + 2, 50) };
|
|
1463
|
+
});
|
|
1464
|
+
let a = e.utils.book_new();
|
|
1465
|
+
e.utils.book_append_sheet(a, n, i), e.writeFile(a, `${r}.xlsx`);
|
|
1466
|
+
} catch {
|
|
1467
|
+
console.warn("xlsx library not available, falling back to CSV export"), at(e, t, n, r);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
//#endregion
|
|
1471
|
+
//#region src/components/Toolbar.jsx
|
|
1472
|
+
function st({ globalSearch: e, onSearchChange: t, searchDebounce: n = 300, viewMode: i, onViewModeChange: a, views: s = [
|
|
1473
|
+
"table",
|
|
1474
|
+
"grid",
|
|
1475
|
+
"list"
|
|
1476
|
+
], exportFormats: c, onExport: l, hasActiveFilters: u = !1, onClearFilters: d, pluginToolbar: f, className: p = "" }) {
|
|
1477
|
+
let [m, h] = o(e), [g, _] = o(!1);
|
|
1478
|
+
r(() => {
|
|
1479
|
+
let e = setTimeout(() => t(m), n);
|
|
1480
|
+
return () => clearTimeout(e);
|
|
1481
|
+
}, [
|
|
1482
|
+
m,
|
|
1483
|
+
n,
|
|
1484
|
+
t
|
|
1485
|
+
]), r(() => {
|
|
1486
|
+
h(e);
|
|
1487
|
+
}, [e]);
|
|
1488
|
+
let v = {
|
|
1489
|
+
table: /* @__PURE__ */ R(te, { className: "h-4 w-4" }),
|
|
1490
|
+
grid: /* @__PURE__ */ R(T, { className: "h-4 w-4" }),
|
|
1491
|
+
list: /* @__PURE__ */ R(D, { className: "h-4 w-4" })
|
|
1492
|
+
};
|
|
1493
|
+
return /* @__PURE__ */ z("div", {
|
|
1494
|
+
className: `flex flex-wrap items-center gap-2 px-4 py-3 border-b border-[var(--app-border,#e5e7eb)] ${p}`,
|
|
1495
|
+
children: [
|
|
1496
|
+
/* @__PURE__ */ z("div", {
|
|
1497
|
+
className: "relative flex-1 min-w-[200px] max-w-md",
|
|
1498
|
+
children: [
|
|
1499
|
+
/* @__PURE__ */ R(N, { className: "h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2" }),
|
|
1500
|
+
/* @__PURE__ */ R("input", {
|
|
1501
|
+
type: "text",
|
|
1502
|
+
value: m,
|
|
1503
|
+
onChange: (e) => h(e.target.value),
|
|
1504
|
+
placeholder: "Search...",
|
|
1505
|
+
className: "w-full h-9 pl-9 pr-8 text-sm rounded-md border border-gray-300 dark:border-gray-600 focus:outline-none focus:ring-2 focus:ring-brand-500 focus:border-brand-500 bg-[var(--app-bg)]",
|
|
1506
|
+
"aria-label": "Search table"
|
|
1507
|
+
}),
|
|
1508
|
+
m && /* @__PURE__ */ R("button", {
|
|
1509
|
+
type: "button",
|
|
1510
|
+
onClick: () => {
|
|
1511
|
+
h(""), t("");
|
|
1512
|
+
},
|
|
1513
|
+
className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",
|
|
1514
|
+
"aria-label": "Clear search",
|
|
1515
|
+
children: /* @__PURE__ */ R(I, { className: "h-4 w-4" })
|
|
1516
|
+
})
|
|
1517
|
+
]
|
|
1518
|
+
}),
|
|
1519
|
+
u && /* @__PURE__ */ z("button", {
|
|
1520
|
+
type: "button",
|
|
1521
|
+
onClick: d,
|
|
1522
|
+
className: "inline-flex items-center gap-1 px-2 py-1.5 text-xs font-medium text-brand-700 bg-brand-50 rounded-md hover:bg-brand-100 transition-colors",
|
|
1523
|
+
children: [
|
|
1524
|
+
/* @__PURE__ */ R(P, { className: "h-3 w-3" }),
|
|
1525
|
+
"Filters active",
|
|
1526
|
+
/* @__PURE__ */ R(j, { className: "h-3 w-3 ml-1" })
|
|
1527
|
+
]
|
|
1528
|
+
}),
|
|
1529
|
+
f,
|
|
1530
|
+
/* @__PURE__ */ z("div", {
|
|
1531
|
+
className: "flex items-center gap-1 ml-auto",
|
|
1532
|
+
children: [c && c.length > 0 && l && /* @__PURE__ */ R(ct, {
|
|
1533
|
+
formats: c,
|
|
1534
|
+
onExport: l,
|
|
1535
|
+
isOpen: g,
|
|
1536
|
+
onToggleOpen: () => _((e) => !e),
|
|
1537
|
+
onClose: () => _(!1)
|
|
1538
|
+
}), s.length > 1 && /* @__PURE__ */ R("div", {
|
|
1539
|
+
className: "flex items-center border border-gray-300 dark:border-gray-600 rounded-md overflow-hidden",
|
|
1540
|
+
children: s.map((e) => /* @__PURE__ */ R("button", {
|
|
1541
|
+
type: "button",
|
|
1542
|
+
onClick: () => a(e),
|
|
1543
|
+
className: `p-2 transition-colors ${i === e ? "bg-brand-600 text-white" : "bg-[var(--app-bg)] text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700"}`,
|
|
1544
|
+
title: `${e.charAt(0).toUpperCase() + e.slice(1)} view`,
|
|
1545
|
+
"aria-label": `Switch to ${e} view`,
|
|
1546
|
+
"aria-pressed": i === e,
|
|
1547
|
+
children: v[e]
|
|
1548
|
+
}, e))
|
|
1549
|
+
})]
|
|
1550
|
+
})
|
|
1551
|
+
]
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
function ct({ formats: t, onExport: n, isOpen: r, onToggleOpen: i, onClose: a }) {
|
|
1555
|
+
let o = e.useRef(null);
|
|
1556
|
+
e.useEffect(() => {
|
|
1557
|
+
if (!r) return;
|
|
1558
|
+
let e = (e) => {
|
|
1559
|
+
o.current && !o.current.contains(e.target) && a();
|
|
1560
|
+
};
|
|
1561
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
1562
|
+
}, [r, a]);
|
|
1563
|
+
let s = {
|
|
1564
|
+
csv: "Export CSV",
|
|
1565
|
+
excel: "Export Excel",
|
|
1566
|
+
pdf: "Export PDF"
|
|
1567
|
+
};
|
|
1568
|
+
return /* @__PURE__ */ z("div", {
|
|
1569
|
+
className: "relative",
|
|
1570
|
+
ref: o,
|
|
1571
|
+
children: [/* @__PURE__ */ R("button", {
|
|
1572
|
+
type: "button",
|
|
1573
|
+
onClick: i,
|
|
1574
|
+
className: "p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",
|
|
1575
|
+
"aria-label": "Export data",
|
|
1576
|
+
children: /* @__PURE__ */ R(x, { className: "h-4 w-4" })
|
|
1577
|
+
}), r && /* @__PURE__ */ R("div", {
|
|
1578
|
+
className: "absolute right-0 top-full mt-1 z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 min-w-[140px]",
|
|
1579
|
+
children: t.map((e) => /* @__PURE__ */ R("button", {
|
|
1580
|
+
type: "button",
|
|
1581
|
+
onClick: () => {
|
|
1582
|
+
n(e), a();
|
|
1583
|
+
},
|
|
1584
|
+
className: "w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",
|
|
1585
|
+
children: s[e]
|
|
1586
|
+
}, e))
|
|
1587
|
+
})]
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
//#endregion
|
|
1591
|
+
//#region src/components/BulkActions.jsx
|
|
1592
|
+
function lt({ selectedCount: e, selectedRows: t, actions: n, onClearSelection: r }) {
|
|
1593
|
+
return e === 0 ? null : /* @__PURE__ */ z("div", {
|
|
1594
|
+
className: "flex items-center gap-3 px-4 py-2 bg-brand-50 dark:bg-brand-900/20 border-b border-brand-200 dark:border-brand-800 animate-in slide-in-from-top-1",
|
|
1595
|
+
children: [
|
|
1596
|
+
/* @__PURE__ */ z("span", {
|
|
1597
|
+
className: "text-sm font-medium text-brand-700 dark:text-brand-300",
|
|
1598
|
+
children: [e, " selected"]
|
|
1599
|
+
}),
|
|
1600
|
+
/* @__PURE__ */ R("div", {
|
|
1601
|
+
className: "flex items-center gap-2",
|
|
1602
|
+
children: n.map((e) => /* @__PURE__ */ z("button", {
|
|
1603
|
+
type: "button",
|
|
1604
|
+
onClick: () => e.onClick(t),
|
|
1605
|
+
className: `inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${e.variant === "danger" ? "text-red-700 bg-red-100 hover:bg-red-200 dark:text-red-300 dark:bg-red-900/30 dark:hover:bg-red-900/50" : "text-brand-700 bg-brand-100 hover:bg-brand-200 dark:text-brand-300 dark:bg-brand-900/30 dark:hover:bg-brand-900/50"}`,
|
|
1606
|
+
children: [e.icon, e.label]
|
|
1607
|
+
}, e.id))
|
|
1608
|
+
}),
|
|
1609
|
+
/* @__PURE__ */ R("button", {
|
|
1610
|
+
type: "button",
|
|
1611
|
+
onClick: r,
|
|
1612
|
+
className: "ml-auto p-1 text-gray-400 hover:text-gray-600 transition-colors",
|
|
1613
|
+
"aria-label": "Clear selection",
|
|
1614
|
+
children: /* @__PURE__ */ R(I, { className: "h-4 w-4" })
|
|
1615
|
+
})
|
|
1616
|
+
]
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
//#endregion
|
|
1620
|
+
//#region src/components/ColumnFilter.jsx
|
|
1621
|
+
function ut({ column: e, value: t, onChange: n }) {
|
|
1622
|
+
let [r, i] = o(!1), a = e.filterType ?? "text", s = t !== "" && t != null && !(Array.isArray(t) && !t.length);
|
|
1623
|
+
if (e.filterComponent) {
|
|
1624
|
+
let r = e.filterComponent;
|
|
1625
|
+
return /* @__PURE__ */ R(r, {
|
|
1626
|
+
column: e,
|
|
1627
|
+
value: t,
|
|
1628
|
+
onChange: (t) => n(e.id, t)
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
return /* @__PURE__ */ z("div", {
|
|
1632
|
+
className: "relative inline-block",
|
|
1633
|
+
children: [/* @__PURE__ */ R("button", {
|
|
1634
|
+
type: "button",
|
|
1635
|
+
onClick: () => i((e) => !e),
|
|
1636
|
+
className: `p-1 rounded transition-colors ${s ? "text-brand-600 bg-brand-50" : "text-gray-400 hover:text-gray-600 hover:bg-gray-100"}`,
|
|
1637
|
+
"aria-label": `Filter ${e.header}`,
|
|
1638
|
+
children: /* @__PURE__ */ R(C, { className: "h-3.5 w-3.5" })
|
|
1639
|
+
}), r && /* @__PURE__ */ R(dt, {
|
|
1640
|
+
column: e,
|
|
1641
|
+
filterType: a,
|
|
1642
|
+
value: t,
|
|
1643
|
+
onChange: n,
|
|
1644
|
+
onClose: () => i(!1)
|
|
1645
|
+
})]
|
|
1646
|
+
});
|
|
1647
|
+
}
|
|
1648
|
+
function dt({ column: t, filterType: r, value: i, onChange: a, onClose: o }) {
|
|
1649
|
+
let s = e.useRef(null);
|
|
1650
|
+
e.useEffect(() => {
|
|
1651
|
+
let e = (e) => {
|
|
1652
|
+
s.current && !s.current.contains(e.target) && o();
|
|
1653
|
+
};
|
|
1654
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
1655
|
+
}, [o]);
|
|
1656
|
+
let c = n(() => {
|
|
1657
|
+
a(t.id, ""), o();
|
|
1658
|
+
}, [
|
|
1659
|
+
t.id,
|
|
1660
|
+
a,
|
|
1661
|
+
o
|
|
1662
|
+
]);
|
|
1663
|
+
return /* @__PURE__ */ z("div", {
|
|
1664
|
+
ref: s,
|
|
1665
|
+
className: "absolute left-0 top-full mt-1 z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[200px]",
|
|
1666
|
+
children: [
|
|
1667
|
+
/* @__PURE__ */ z("div", {
|
|
1668
|
+
className: "flex items-center justify-between mb-2",
|
|
1669
|
+
children: [/* @__PURE__ */ z("span", {
|
|
1670
|
+
className: "text-xs font-medium text-gray-500",
|
|
1671
|
+
children: ["Filter: ", t.header]
|
|
1672
|
+
}), /* @__PURE__ */ R("button", {
|
|
1673
|
+
type: "button",
|
|
1674
|
+
onClick: c,
|
|
1675
|
+
className: "text-xs text-gray-400 hover:text-gray-600",
|
|
1676
|
+
children: /* @__PURE__ */ R(I, { className: "h-3 w-3" })
|
|
1677
|
+
})]
|
|
1678
|
+
}),
|
|
1679
|
+
r === "text" && /* @__PURE__ */ R("input", {
|
|
1680
|
+
type: "text",
|
|
1681
|
+
value: String(i ?? ""),
|
|
1682
|
+
onChange: (e) => a(t.id, e.target.value, "contains"),
|
|
1683
|
+
placeholder: `Filter ${t.header}...`,
|
|
1684
|
+
className: "w-full px-2 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg)]",
|
|
1685
|
+
autoFocus: !0
|
|
1686
|
+
}),
|
|
1687
|
+
r === "number" && /* @__PURE__ */ R("input", {
|
|
1688
|
+
type: "number",
|
|
1689
|
+
value: String(i ?? ""),
|
|
1690
|
+
onChange: (e) => a(t.id, e.target.value ? Number(e.target.value) : "", "eq"),
|
|
1691
|
+
placeholder: `Filter ${t.header}...`,
|
|
1692
|
+
className: "w-full px-2 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg)]",
|
|
1693
|
+
autoFocus: !0
|
|
1694
|
+
}),
|
|
1695
|
+
r === "date" && /* @__PURE__ */ R("input", {
|
|
1696
|
+
type: "date",
|
|
1697
|
+
value: String(i ?? ""),
|
|
1698
|
+
onChange: (e) => a(t.id, e.target.value, "eq"),
|
|
1699
|
+
className: "w-full px-2 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg)]"
|
|
1700
|
+
}),
|
|
1701
|
+
r === "select" && t.filterOptions && /* @__PURE__ */ z("select", {
|
|
1702
|
+
value: String(i ?? ""),
|
|
1703
|
+
onChange: (e) => a(t.id, e.target.value, "eq"),
|
|
1704
|
+
className: "w-full px-2 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg)]",
|
|
1705
|
+
children: [/* @__PURE__ */ R("option", {
|
|
1706
|
+
value: "",
|
|
1707
|
+
children: "All"
|
|
1708
|
+
}), t.filterOptions.map((e) => /* @__PURE__ */ R("option", {
|
|
1709
|
+
value: e.value,
|
|
1710
|
+
children: e.label
|
|
1711
|
+
}, e.value))]
|
|
1712
|
+
}),
|
|
1713
|
+
r === "multi-select" && t.filterOptions && /* @__PURE__ */ R(ft, {
|
|
1714
|
+
options: t.filterOptions,
|
|
1715
|
+
value: Array.isArray(i) ? i : [],
|
|
1716
|
+
onChange: (e) => a(t.id, e)
|
|
1717
|
+
})
|
|
1718
|
+
]
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
function ft({ options: e, value: t, onChange: n }) {
|
|
1722
|
+
let r = (e) => {
|
|
1723
|
+
n(t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
|
|
1724
|
+
};
|
|
1725
|
+
return /* @__PURE__ */ R("div", {
|
|
1726
|
+
className: "max-h-48 overflow-y-auto space-y-1",
|
|
1727
|
+
children: e.map((e) => /* @__PURE__ */ z("label", {
|
|
1728
|
+
className: "flex items-center gap-2 px-1 py-0.5 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 rounded",
|
|
1729
|
+
children: [/* @__PURE__ */ R("input", {
|
|
1730
|
+
type: "checkbox",
|
|
1731
|
+
checked: t.includes(e.value),
|
|
1732
|
+
onChange: () => r(e.value),
|
|
1733
|
+
className: "h-3.5 w-3.5 rounded border-gray-300 text-brand-600 focus:ring-brand-600"
|
|
1734
|
+
}), /* @__PURE__ */ R("span", {
|
|
1735
|
+
className: "text-sm text-gray-700 dark:text-gray-300",
|
|
1736
|
+
children: e.label
|
|
1737
|
+
})]
|
|
1738
|
+
}, e.value))
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
//#endregion
|
|
1742
|
+
//#region src/components/FloatingFilterRow.jsx
|
|
1743
|
+
function pt({ columns: e, getFilterValue: t, onFilterChange: n, showCheckbox: r = !1, showExpandToggle: i = !1, showActions: a = !1, compact: o = !1 }) {
|
|
1744
|
+
let s = o ? "py-1" : "py-1.5";
|
|
1745
|
+
return /* @__PURE__ */ z("tr", {
|
|
1746
|
+
className: "bg-[var(--app-surface,#f9fafb)] border-b border-[var(--app-border,#e5e7eb)]",
|
|
1747
|
+
children: [
|
|
1748
|
+
r && /* @__PURE__ */ R("td", { className: `px-4 ${s}` }),
|
|
1749
|
+
i && /* @__PURE__ */ R("td", { className: `px-2 ${s}` }),
|
|
1750
|
+
e.map((e) => /* @__PURE__ */ R("td", {
|
|
1751
|
+
className: `px-2 ${s}`,
|
|
1752
|
+
children: e.filterable !== !1 && e.filterType ? /* @__PURE__ */ R(mt, {
|
|
1753
|
+
column: e,
|
|
1754
|
+
value: t(e.id),
|
|
1755
|
+
onChange: n
|
|
1756
|
+
}) : null
|
|
1757
|
+
}, e.id)),
|
|
1758
|
+
a && /* @__PURE__ */ R("td", { className: `px-4 ${s}` })
|
|
1759
|
+
]
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
function mt({ column: e, value: t, onChange: i }) {
|
|
1763
|
+
let s = e.filterType ?? "text", [c, l] = o(String(t ?? "")), u = a();
|
|
1764
|
+
r(() => {
|
|
1765
|
+
l(String(t ?? ""));
|
|
1766
|
+
}, [t]);
|
|
1767
|
+
let d = n((t) => {
|
|
1768
|
+
l(t), clearTimeout(u.current), u.current = setTimeout(() => {
|
|
1769
|
+
i(e.id, t, "contains");
|
|
1770
|
+
}, 300);
|
|
1771
|
+
}, [e.id, i]), f = n(() => {
|
|
1772
|
+
l(""), clearTimeout(u.current), i(e.id, "");
|
|
1773
|
+
}, [e.id, i]);
|
|
1774
|
+
if (e.filterComponent) {
|
|
1775
|
+
let n = e.filterComponent;
|
|
1776
|
+
return /* @__PURE__ */ R(n, {
|
|
1777
|
+
column: e,
|
|
1778
|
+
value: t,
|
|
1779
|
+
onChange: (t) => i(e.id, t)
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
return s === "select" ? /* @__PURE__ */ z("select", {
|
|
1783
|
+
value: String(t ?? ""),
|
|
1784
|
+
onChange: (t) => i(e.id, t.target.value, "eq"),
|
|
1785
|
+
className: "w-full px-1.5 py-1 text-xs border border-gray-200 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg,white)] text-gray-700",
|
|
1786
|
+
"aria-label": `Filter ${e.header}`,
|
|
1787
|
+
children: [/* @__PURE__ */ R("option", {
|
|
1788
|
+
value: "",
|
|
1789
|
+
children: "All"
|
|
1790
|
+
}), e.filterOptions?.map((e) => /* @__PURE__ */ R("option", {
|
|
1791
|
+
value: e.value,
|
|
1792
|
+
children: e.label
|
|
1793
|
+
}, e.value))]
|
|
1794
|
+
}) : s === "number" ? /* @__PURE__ */ z("div", {
|
|
1795
|
+
className: "relative",
|
|
1796
|
+
children: [/* @__PURE__ */ R("input", {
|
|
1797
|
+
type: "number",
|
|
1798
|
+
value: c,
|
|
1799
|
+
onChange: (t) => {
|
|
1800
|
+
l(t.target.value), i(e.id, t.target.value ? Number(t.target.value) : "", "eq");
|
|
1801
|
+
},
|
|
1802
|
+
placeholder: "...",
|
|
1803
|
+
className: "w-full px-1.5 py-1 text-xs border border-gray-200 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg,white)] pr-5",
|
|
1804
|
+
"aria-label": `Filter ${e.header}`
|
|
1805
|
+
}), c && /* @__PURE__ */ R(ht, { onClick: f })]
|
|
1806
|
+
}) : s === "date" ? /* @__PURE__ */ R("input", {
|
|
1807
|
+
type: "date",
|
|
1808
|
+
value: String(t ?? ""),
|
|
1809
|
+
onChange: (t) => i(e.id, t.target.value, "eq"),
|
|
1810
|
+
className: "w-full px-1.5 py-1 text-xs border border-gray-200 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg,white)]",
|
|
1811
|
+
"aria-label": `Filter ${e.header}`
|
|
1812
|
+
}) : /* @__PURE__ */ z("div", {
|
|
1813
|
+
className: "relative",
|
|
1814
|
+
children: [/* @__PURE__ */ R("input", {
|
|
1815
|
+
type: "text",
|
|
1816
|
+
value: c,
|
|
1817
|
+
onChange: (e) => d(e.target.value),
|
|
1818
|
+
placeholder: "Filter...",
|
|
1819
|
+
className: "w-full px-1.5 py-1 text-xs border border-gray-200 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg,white)] pr-5",
|
|
1820
|
+
"aria-label": `Filter ${e.header}`
|
|
1821
|
+
}), c && /* @__PURE__ */ R(ht, { onClick: f })]
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
function ht({ onClick: e }) {
|
|
1825
|
+
return /* @__PURE__ */ R("button", {
|
|
1826
|
+
type: "button",
|
|
1827
|
+
onClick: e,
|
|
1828
|
+
className: "absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-gray-400 hover:text-gray-600 rounded",
|
|
1829
|
+
"aria-label": "Clear filter",
|
|
1830
|
+
children: /* @__PURE__ */ R(I, { className: "h-3 w-3" })
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
//#endregion
|
|
1834
|
+
//#region src/components/DataTableHeader.jsx
|
|
1835
|
+
var gt = "application/x-datatable-column";
|
|
1836
|
+
function _t({ columns: e, getSortDirection: t, onSort: r, columnWidths: s, onResize: c, enableResizing: l = !1, enableReordering: u = !1, onReorder: d, onReorderById: f, showCheckbox: p = !1, isAllSelected: m = !1, isSomeSelected: h = !1, onToggleAll: g, showExpandToggle: _ = !1, showActions: v = !1, compact: y = !1, getFilterValue: b, onFilterChange: x, floatingFilters: S = !1, showColumnGroups: C = !1 }) {
|
|
1837
|
+
let [T, E] = o(null), [D, O] = o(null), [ee, k] = o(null), A = a(/* @__PURE__ */ new Map()), j = n((e, t) => {
|
|
1838
|
+
if (!u) return;
|
|
1839
|
+
E(t), e.dataTransfer.setData(gt, t), e.dataTransfer.effectAllowed = "move";
|
|
1840
|
+
let n = A.current.get(t);
|
|
1841
|
+
if (n) {
|
|
1842
|
+
let t = n.cloneNode(!0);
|
|
1843
|
+
t.style.position = "absolute", t.style.top = "-9999px", t.style.left = "-9999px", t.style.opacity = "0.85", t.style.background = "var(--app-surface, #f9fafb)", t.style.border = "1px solid var(--app-border, #e5e7eb)", t.style.borderRadius = "6px", t.style.padding = "8px 12px", t.style.boxShadow = "0 4px 12px rgba(0,0,0,0.15)", t.style.whiteSpace = "nowrap", document.body.appendChild(t), e.dataTransfer.setDragImage(t, 20, 20), requestAnimationFrame(() => document.body.removeChild(t));
|
|
1844
|
+
}
|
|
1845
|
+
}, [u]), M = n((e, t) => {
|
|
1846
|
+
if (!u || !T || T === t) return;
|
|
1847
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "move";
|
|
1848
|
+
let n = A.current.get(t);
|
|
1849
|
+
if (n) {
|
|
1850
|
+
let r = n.getBoundingClientRect(), i = r.left + r.width / 2;
|
|
1851
|
+
O(t), k(e.clientX < i ? "left" : "right");
|
|
1852
|
+
}
|
|
1853
|
+
}, [u, T]), N = n((e, t) => {
|
|
1854
|
+
let n = e.relatedTarget, r = A.current.get(t);
|
|
1855
|
+
r && n && r.contains(n) || D === t && (O(null), k(null));
|
|
1856
|
+
}, [D]), P = n((t, n) => {
|
|
1857
|
+
t.preventDefault();
|
|
1858
|
+
let r = t.dataTransfer.getData(gt);
|
|
1859
|
+
if (!r || r === n) {
|
|
1860
|
+
F();
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
if (f) {
|
|
1864
|
+
let t = e.findIndex((e) => e.id === n), i = e.findIndex((e) => e.id === r);
|
|
1865
|
+
t !== -1 && i !== -1 && f(r, n);
|
|
1866
|
+
} else if (d) {
|
|
1867
|
+
let t = e.findIndex((e) => e.id === r), i = e.findIndex((e) => e.id === n);
|
|
1868
|
+
t !== -1 && i !== -1 && d(t, i);
|
|
1869
|
+
}
|
|
1870
|
+
F();
|
|
1871
|
+
}, [
|
|
1872
|
+
e,
|
|
1873
|
+
d,
|
|
1874
|
+
f
|
|
1875
|
+
]), te = n(() => F(), []), F = () => {
|
|
1876
|
+
E(null), O(null), k(null);
|
|
1877
|
+
}, I = n((e) => (t) => {
|
|
1878
|
+
t ? A.current.set(e, t) : A.current.delete(e);
|
|
1879
|
+
}, []), L = i(() => {
|
|
1880
|
+
if (!C || !e.some((e) => e.group)) return null;
|
|
1881
|
+
let t = [], n, r = 0;
|
|
1882
|
+
return e.forEach((i, a) => {
|
|
1883
|
+
i.group === n ? r++ : (r > 0 && t.push({
|
|
1884
|
+
label: n ?? "",
|
|
1885
|
+
colSpan: r
|
|
1886
|
+
}), n = i.group, r = 1), a === e.length - 1 && t.push({
|
|
1887
|
+
label: n ?? "",
|
|
1888
|
+
colSpan: r
|
|
1889
|
+
});
|
|
1890
|
+
}), t;
|
|
1891
|
+
}, [e, C]), B = y ? "py-2" : "py-3";
|
|
1892
|
+
return /* @__PURE__ */ z("thead", {
|
|
1893
|
+
className: "bg-[var(--app-surface,#f9fafb)] border-b border-[var(--app-border,#e5e7eb)]",
|
|
1894
|
+
children: [
|
|
1895
|
+
L && /* @__PURE__ */ z("tr", {
|
|
1896
|
+
className: "border-b border-[var(--app-border,#e5e7eb)]",
|
|
1897
|
+
children: [
|
|
1898
|
+
p && /* @__PURE__ */ R("th", { className: "px-4 py-1" }),
|
|
1899
|
+
_ && /* @__PURE__ */ R("th", { className: "px-2 py-1" }),
|
|
1900
|
+
L.map((e, t) => /* @__PURE__ */ R("th", {
|
|
1901
|
+
colSpan: e.colSpan,
|
|
1902
|
+
className: "px-4 py-1.5 text-center text-[10px] font-bold uppercase tracking-widest text-gray-400 border-x border-[var(--app-border,#e5e7eb)] first:border-l-0 last:border-r-0",
|
|
1903
|
+
children: e.label
|
|
1904
|
+
}, `${e.label}-${t}`)),
|
|
1905
|
+
v && /* @__PURE__ */ R("th", { className: "px-4 py-1" })
|
|
1906
|
+
]
|
|
1907
|
+
}),
|
|
1908
|
+
/* @__PURE__ */ z("tr", { children: [
|
|
1909
|
+
p && /* @__PURE__ */ R("th", {
|
|
1910
|
+
className: `px-4 ${B} w-12`,
|
|
1911
|
+
children: /* @__PURE__ */ R("input", {
|
|
1912
|
+
type: "checkbox",
|
|
1913
|
+
checked: m,
|
|
1914
|
+
ref: (e) => {
|
|
1915
|
+
e && (e.indeterminate = h);
|
|
1916
|
+
},
|
|
1917
|
+
onChange: g,
|
|
1918
|
+
className: "h-4 w-4 rounded border-gray-300 text-brand-600 focus:ring-brand-600",
|
|
1919
|
+
"aria-label": "Select all rows"
|
|
1920
|
+
})
|
|
1921
|
+
}),
|
|
1922
|
+
_ && /* @__PURE__ */ R("th", { className: `px-2 ${B} w-10` }),
|
|
1923
|
+
e.map((e) => {
|
|
1924
|
+
let n = t(e.id), i = s[e.id], a = i ? {
|
|
1925
|
+
width: i,
|
|
1926
|
+
minWidth: i
|
|
1927
|
+
} : {}, o = T === e.id, d = D === e.id, f = d && ee === "left", p = d && ee === "right", m = e.filterable !== !1 && e.filterType && b && x;
|
|
1928
|
+
return /* @__PURE__ */ z("th", {
|
|
1929
|
+
ref: I(e.id),
|
|
1930
|
+
className: `
|
|
1931
|
+
px-4 ${B} text-left text-xs font-semibold uppercase tracking-wider
|
|
1932
|
+
text-[var(--app-text-secondary,#6b7280)] select-none relative group
|
|
1933
|
+
transition-opacity duration-150
|
|
1934
|
+
${o ? "opacity-30" : ""}
|
|
1935
|
+
${u ? "cursor-grab active:cursor-grabbing" : ""}
|
|
1936
|
+
`,
|
|
1937
|
+
style: a,
|
|
1938
|
+
draggable: u,
|
|
1939
|
+
onDragStart: (t) => j(t, e.id),
|
|
1940
|
+
onDragOver: (t) => M(t, e.id),
|
|
1941
|
+
onDragLeave: (t) => N(t, e.id),
|
|
1942
|
+
onDrop: (t) => P(t, e.id),
|
|
1943
|
+
onDragEnd: te,
|
|
1944
|
+
children: [
|
|
1945
|
+
f && /* @__PURE__ */ R("div", { className: "absolute left-0 top-1 bottom-1 w-0.5 bg-brand-500 rounded-full z-10 animate-pulse" }),
|
|
1946
|
+
p && /* @__PURE__ */ R("div", { className: "absolute right-0 top-1 bottom-1 w-0.5 bg-brand-500 rounded-full z-10 animate-pulse" }),
|
|
1947
|
+
/* @__PURE__ */ z("div", {
|
|
1948
|
+
className: "flex items-center gap-1",
|
|
1949
|
+
children: [
|
|
1950
|
+
u && /* @__PURE__ */ R(w, { className: `h-3.5 w-3.5 shrink-0 transition-all duration-150
|
|
1951
|
+
${o ? "text-brand-500 opacity-100" : "text-gray-400 opacity-0 group-hover:opacity-100"}
|
|
1952
|
+
` }),
|
|
1953
|
+
e.headerCell ? e.headerCell({
|
|
1954
|
+
column: e,
|
|
1955
|
+
sortDirection: n,
|
|
1956
|
+
onSort: () => r(e.id)
|
|
1957
|
+
}) : /* @__PURE__ */ z("button", {
|
|
1958
|
+
type: "button",
|
|
1959
|
+
className: `flex items-center gap-1 ${e.sortable === !1 ? "cursor-default" : "cursor-pointer hover:text-[var(--app-text)]"}`,
|
|
1960
|
+
onClick: () => e.sortable !== !1 && r(e.id),
|
|
1961
|
+
disabled: e.sortable === !1,
|
|
1962
|
+
onDragStart: (e) => {
|
|
1963
|
+
e.stopPropagation(), e.preventDefault();
|
|
1964
|
+
},
|
|
1965
|
+
children: [/* @__PURE__ */ R("span", { children: e.header }), e.sortable !== !1 && /* @__PURE__ */ R(yt, { direction: n })]
|
|
1966
|
+
}),
|
|
1967
|
+
m && /* @__PURE__ */ R("div", {
|
|
1968
|
+
onClick: (e) => e.stopPropagation(),
|
|
1969
|
+
onDragStart: (e) => {
|
|
1970
|
+
e.stopPropagation(), e.preventDefault();
|
|
1971
|
+
},
|
|
1972
|
+
draggable: !1,
|
|
1973
|
+
children: /* @__PURE__ */ R(ut, {
|
|
1974
|
+
column: e,
|
|
1975
|
+
value: b(e.id),
|
|
1976
|
+
onChange: x
|
|
1977
|
+
})
|
|
1978
|
+
}),
|
|
1979
|
+
l && e.resizable !== !1 && /* @__PURE__ */ R(bt, {
|
|
1980
|
+
columnId: e.id,
|
|
1981
|
+
currentWidth: i ?? e.width ?? 150,
|
|
1982
|
+
onResize: c
|
|
1983
|
+
})
|
|
1984
|
+
]
|
|
1985
|
+
})
|
|
1986
|
+
]
|
|
1987
|
+
}, e.id);
|
|
1988
|
+
}),
|
|
1989
|
+
v && /* @__PURE__ */ R("th", {
|
|
1990
|
+
className: `px-4 ${B} text-right text-xs font-semibold uppercase tracking-wider text-[var(--app-text-secondary,#6b7280)] w-24`,
|
|
1991
|
+
children: "Actions"
|
|
1992
|
+
})
|
|
1993
|
+
] }),
|
|
1994
|
+
S && b && x && /* @__PURE__ */ R(pt, {
|
|
1995
|
+
columns: e,
|
|
1996
|
+
getFilterValue: b,
|
|
1997
|
+
onFilterChange: x,
|
|
1998
|
+
showCheckbox: p,
|
|
1999
|
+
showExpandToggle: _,
|
|
2000
|
+
showActions: v,
|
|
2001
|
+
compact: y
|
|
2002
|
+
})
|
|
2003
|
+
]
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
var vt = t(_t);
|
|
2007
|
+
function yt({ direction: e }) {
|
|
2008
|
+
return e === "asc" ? /* @__PURE__ */ R(u, { className: "h-3.5 w-3.5" }) : e === "desc" ? /* @__PURE__ */ R(l, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ R(d, { className: "h-3.5 w-3.5 opacity-30" });
|
|
2009
|
+
}
|
|
2010
|
+
function bt({ columnId: e, currentWidth: t, onResize: r }) {
|
|
2011
|
+
let i = a(0), o = a(t);
|
|
2012
|
+
return /* @__PURE__ */ R("div", {
|
|
2013
|
+
className: "absolute right-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-brand-500 opacity-0 group-hover:opacity-100 transition-opacity",
|
|
2014
|
+
onMouseDown: n((n) => {
|
|
2015
|
+
n.preventDefault(), n.stopPropagation(), i.current = n.clientX, o.current = t;
|
|
2016
|
+
let a = (t) => {
|
|
2017
|
+
let n = t.clientX - i.current;
|
|
2018
|
+
r(e, o.current + n);
|
|
2019
|
+
}, s = () => {
|
|
2020
|
+
document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", s);
|
|
2021
|
+
};
|
|
2022
|
+
document.addEventListener("mousemove", a), document.addEventListener("mouseup", s);
|
|
2023
|
+
}, [
|
|
2024
|
+
e,
|
|
2025
|
+
t,
|
|
2026
|
+
r
|
|
2027
|
+
]),
|
|
2028
|
+
draggable: !1,
|
|
2029
|
+
onDragStart: (e) => {
|
|
2030
|
+
e.stopPropagation(), e.preventDefault();
|
|
2031
|
+
},
|
|
2032
|
+
role: "separator",
|
|
2033
|
+
"aria-orientation": "vertical"
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
//#endregion
|
|
2037
|
+
//#region src/components/CellTooltip.jsx
|
|
2038
|
+
function xt({ content: e, children: t, delay: r = 400, style: i, disabled: s = !1 }) {
|
|
2039
|
+
let [c, l] = o(!1), [u, d] = o({
|
|
2040
|
+
top: 0,
|
|
2041
|
+
left: 0
|
|
2042
|
+
}), f = a(), p = a(null), m = n(() => {
|
|
2043
|
+
s || !e || (f.current = setTimeout(() => {
|
|
2044
|
+
let e = p.current;
|
|
2045
|
+
if (!e) return;
|
|
2046
|
+
let t = e.getBoundingClientRect(), n = t.top - 6, r = t.left + t.width / 2;
|
|
2047
|
+
r = Math.max(60, Math.min(r, window.innerWidth - 60)), d({
|
|
2048
|
+
top: n,
|
|
2049
|
+
left: r
|
|
2050
|
+
}), l(!0);
|
|
2051
|
+
}, r));
|
|
2052
|
+
}, [
|
|
2053
|
+
e,
|
|
2054
|
+
r,
|
|
2055
|
+
s
|
|
2056
|
+
]), h = n(() => {
|
|
2057
|
+
clearTimeout(f.current), l(!1);
|
|
2058
|
+
}, []);
|
|
2059
|
+
return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("span", {
|
|
2060
|
+
ref: p,
|
|
2061
|
+
onMouseEnter: m,
|
|
2062
|
+
onMouseLeave: h,
|
|
2063
|
+
onFocus: m,
|
|
2064
|
+
onBlur: h,
|
|
2065
|
+
className: "contents",
|
|
2066
|
+
children: t
|
|
2067
|
+
}), c && e && B(/* @__PURE__ */ R("div", {
|
|
2068
|
+
role: "tooltip",
|
|
2069
|
+
className: "fixed z-[99999] pointer-events-none animate-in fade-in duration-150",
|
|
2070
|
+
style: {
|
|
2071
|
+
top: u.top,
|
|
2072
|
+
left: u.left,
|
|
2073
|
+
transform: "translate(-50%, -100%)",
|
|
2074
|
+
...St,
|
|
2075
|
+
...i
|
|
2076
|
+
},
|
|
2077
|
+
children: e
|
|
2078
|
+
}), document.body)] });
|
|
2079
|
+
}
|
|
2080
|
+
var St = {
|
|
2081
|
+
backgroundColor: "#1f2937",
|
|
2082
|
+
color: "#f9fafb",
|
|
2083
|
+
padding: "0.375rem 0.625rem",
|
|
2084
|
+
borderRadius: "0.375rem",
|
|
2085
|
+
fontSize: "0.75rem",
|
|
2086
|
+
maxWidth: "300px",
|
|
2087
|
+
whiteSpace: "pre-wrap",
|
|
2088
|
+
boxShadow: "0 4px 6px -1px rgba(0,0,0,0.1)"
|
|
2089
|
+
};
|
|
2090
|
+
//#endregion
|
|
2091
|
+
//#region src/components/TableCell.jsx
|
|
2092
|
+
function Ct({ row: e, rowIndex: t, column: n, isEditing: r, onStartEdit: i, onSaveEdit: a, onCancelEdit: o, width: s, className: c = "", validationError: l, pendingValue: u, onPendingChange: d, enableTooltip: f = !1, tooltipStyle: p, themeCellStyle: m }) {
|
|
2093
|
+
let h = Z(e, n), g = n.align === "center" ? "text-center" : n.align === "right" ? "text-right" : "text-left", _ = {
|
|
2094
|
+
...s ? {
|
|
2095
|
+
width: s,
|
|
2096
|
+
minWidth: s
|
|
2097
|
+
} : {},
|
|
2098
|
+
...m
|
|
2099
|
+
}, v = l ? "ring-1 ring-red-400" : "";
|
|
2100
|
+
if (r && d !== void 0) {
|
|
2101
|
+
if (n.editCell) {
|
|
2102
|
+
let t = {
|
|
2103
|
+
value: u ?? h,
|
|
2104
|
+
row: e,
|
|
2105
|
+
column: n,
|
|
2106
|
+
onSave: (e) => {
|
|
2107
|
+
d(e);
|
|
2108
|
+
},
|
|
2109
|
+
onCancel: o,
|
|
2110
|
+
error: l
|
|
2111
|
+
};
|
|
2112
|
+
return /* @__PURE__ */ z("td", {
|
|
2113
|
+
className: `px-4 py-2 ${g} ${n.className ?? ""} ${c}`,
|
|
2114
|
+
style: _,
|
|
2115
|
+
children: [n.editCell(t), l && /* @__PURE__ */ R("p", {
|
|
2116
|
+
className: "text-xs text-red-500 mt-0.5",
|
|
2117
|
+
children: l
|
|
2118
|
+
})]
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
return /* @__PURE__ */ R("td", {
|
|
2122
|
+
className: `px-4 py-2 ${g} ${n.className ?? ""} ${c}`,
|
|
2123
|
+
style: _,
|
|
2124
|
+
children: /* @__PURE__ */ R(Et, {
|
|
2125
|
+
value: u ?? h,
|
|
2126
|
+
onSave: (e) => d(e),
|
|
2127
|
+
onCancel: o,
|
|
2128
|
+
error: l
|
|
2129
|
+
})
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
if (r && n.editCell) {
|
|
2133
|
+
let t = {
|
|
2134
|
+
value: h,
|
|
2135
|
+
row: e,
|
|
2136
|
+
column: n,
|
|
2137
|
+
onSave: a,
|
|
2138
|
+
onCancel: o,
|
|
2139
|
+
error: l
|
|
2140
|
+
};
|
|
2141
|
+
return /* @__PURE__ */ z("td", {
|
|
2142
|
+
className: `px-4 py-2 ${g} ${n.className ?? ""} ${c}`,
|
|
2143
|
+
style: _,
|
|
2144
|
+
children: [n.editCell(t), l && /* @__PURE__ */ R("p", {
|
|
2145
|
+
className: "text-xs text-red-500 mt-0.5",
|
|
2146
|
+
children: l
|
|
2147
|
+
})]
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
if (r && n.editable) return /* @__PURE__ */ R("td", {
|
|
2151
|
+
className: `px-4 py-2 ${g} ${n.className ?? ""} ${c} ${v}`,
|
|
2152
|
+
style: _,
|
|
2153
|
+
children: /* @__PURE__ */ R(Et, {
|
|
2154
|
+
value: h,
|
|
2155
|
+
onSave: a,
|
|
2156
|
+
onCancel: o,
|
|
2157
|
+
error: l
|
|
2158
|
+
})
|
|
2159
|
+
});
|
|
2160
|
+
let y = n.cell ? n.cell({
|
|
2161
|
+
value: h,
|
|
2162
|
+
row: e,
|
|
2163
|
+
rowIndex: t,
|
|
2164
|
+
column: n
|
|
2165
|
+
}) : h ?? "—", b = Tt(n, h, e, t, f);
|
|
2166
|
+
return /* @__PURE__ */ R("td", {
|
|
2167
|
+
className: `px-4 py-2 text-sm text-[var(--app-text)] ${g} ${n.className ?? ""} ${c}`,
|
|
2168
|
+
style: _,
|
|
2169
|
+
onDoubleClick: n.editable ? i : void 0,
|
|
2170
|
+
children: b ? /* @__PURE__ */ R(xt, {
|
|
2171
|
+
content: b,
|
|
2172
|
+
style: p,
|
|
2173
|
+
children: y
|
|
2174
|
+
}) : y
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2177
|
+
var wt = t(Ct);
|
|
2178
|
+
function Tt(e, t, n, r, i) {
|
|
2179
|
+
return !e.tooltip && !i ? null : typeof e.tooltip == "function" ? e.tooltip({
|
|
2180
|
+
value: t,
|
|
2181
|
+
row: n,
|
|
2182
|
+
rowIndex: r,
|
|
2183
|
+
column: e
|
|
2184
|
+
}) || null : e.tooltip === !0 ? t == null ? null : String(t) : null;
|
|
2185
|
+
}
|
|
2186
|
+
function Et({ value: e, onSave: t, onCancel: r, error: i }) {
|
|
2187
|
+
let [a, s] = o(String(e ?? ""));
|
|
2188
|
+
return /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("input", {
|
|
2189
|
+
type: "text",
|
|
2190
|
+
value: a,
|
|
2191
|
+
onChange: (e) => s(e.target.value),
|
|
2192
|
+
onKeyDown: n((e) => {
|
|
2193
|
+
e.key === "Enter" && t(a), e.key === "Escape" && r();
|
|
2194
|
+
}, [
|
|
2195
|
+
a,
|
|
2196
|
+
t,
|
|
2197
|
+
r
|
|
2198
|
+
]),
|
|
2199
|
+
onBlur: () => t(a),
|
|
2200
|
+
className: `w-full px-2 py-1 text-sm border rounded focus:outline-none focus:ring-1 bg-[var(--app-bg)] ${i ? "border-red-400 focus:ring-red-400" : "border-brand-500 focus:ring-brand-500"}`,
|
|
2201
|
+
autoFocus: !0
|
|
2202
|
+
}), i && /* @__PURE__ */ R("p", {
|
|
2203
|
+
className: "text-xs text-red-500 mt-0.5",
|
|
2204
|
+
children: i
|
|
2205
|
+
})] });
|
|
2206
|
+
}
|
|
2207
|
+
//#endregion
|
|
2208
|
+
//#region src/components/PortalDropdown.jsx
|
|
2209
|
+
function Dt({ anchorRef: e, open: t, onClose: i, children: s, align: c = "right", offset: l = 4, minWidth: u = 140, className: d = "" }) {
|
|
2210
|
+
let f = a(null), [p, m] = o({
|
|
2211
|
+
top: 0,
|
|
2212
|
+
left: 0
|
|
2213
|
+
}), [h, g] = o(!1), [_, v] = o(!1), y = n(() => {
|
|
2214
|
+
let t = e.current, n = f.current;
|
|
2215
|
+
if (!t || !n) return;
|
|
2216
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = window.innerHeight, o = window.innerWidth, s = a - r.bottom - l, u = r.top - l, d = s < i.height && u > s;
|
|
2217
|
+
g(d);
|
|
2218
|
+
let p = d ? r.top - i.height - l : r.bottom + l, h = c === "right" ? r.right - i.width : r.left;
|
|
2219
|
+
h = Math.max(8, Math.min(h, o - i.width - 8)), m({
|
|
2220
|
+
top: p,
|
|
2221
|
+
left: h
|
|
2222
|
+
}), v(!0);
|
|
2223
|
+
}, [
|
|
2224
|
+
e,
|
|
2225
|
+
c,
|
|
2226
|
+
l
|
|
2227
|
+
]);
|
|
2228
|
+
return r(() => {
|
|
2229
|
+
if (!t) {
|
|
2230
|
+
v(!1);
|
|
2231
|
+
return;
|
|
2232
|
+
}
|
|
2233
|
+
let e = requestAnimationFrame(y), n = () => y();
|
|
2234
|
+
return window.addEventListener("scroll", n, !0), window.addEventListener("resize", n), () => {
|
|
2235
|
+
cancelAnimationFrame(e), window.removeEventListener("scroll", n, !0), window.removeEventListener("resize", n);
|
|
2236
|
+
};
|
|
2237
|
+
}, [t, y]), r(() => {
|
|
2238
|
+
if (!t) return;
|
|
2239
|
+
let n = (t) => {
|
|
2240
|
+
let n = t.target;
|
|
2241
|
+
f.current && !f.current.contains(n) && e.current && !e.current.contains(n) && i();
|
|
2242
|
+
};
|
|
2243
|
+
return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
|
|
2244
|
+
}, [
|
|
2245
|
+
t,
|
|
2246
|
+
i,
|
|
2247
|
+
e
|
|
2248
|
+
]), r(() => {
|
|
2249
|
+
if (!t) return;
|
|
2250
|
+
let e = (e) => {
|
|
2251
|
+
e.key === "Escape" && i();
|
|
2252
|
+
};
|
|
2253
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
2254
|
+
}, [t, i]), t ? B(/* @__PURE__ */ R("div", {
|
|
2255
|
+
ref: f,
|
|
2256
|
+
role: "menu",
|
|
2257
|
+
className: `fixed z-[9999] bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 transition-opacity duration-150 ${_ ? "opacity-100" : "opacity-0"} ${h ? "origin-bottom" : "origin-top"} ${d}`,
|
|
2258
|
+
style: {
|
|
2259
|
+
top: p.top,
|
|
2260
|
+
left: p.left,
|
|
2261
|
+
minWidth: u
|
|
2262
|
+
},
|
|
2263
|
+
children: s
|
|
2264
|
+
}), document.body) : null;
|
|
2265
|
+
}
|
|
2266
|
+
//#endregion
|
|
2267
|
+
//#region src/components/DataTableRow.jsx
|
|
2268
|
+
function Ot({ row: t, rowIndex: r, rowKey: i, columns: o, columnWidths: s, isSelected: c, isExpanded: l, showCheckbox: u, showExpandToggle: d, rowActions: f, onToggleSelect: p, onShiftSelect: m, onToggleExpand: g, onClick: v, onDoubleClick: y, editingCell: b, onStartEdit: x, onSaveEdit: S, onCancelEdit: C, expandContent: w, striped: T = !1, compact: E = !1, rowClassName: D = "", rowStyle: ee, onContextMenu: k, validationErrors: A, pendingEdits: j, isEditingRow: M = !1, onPendingChange: N, enableTooltips: P = !1, tooltipStyle: te, getCellStyle: F }) {
|
|
2269
|
+
let [I, B] = e.useState(!1), V = a(null), H = n(() => v?.(t), [v, t]), U = n(() => y?.(t), [y, t]), W = E ? "py-1" : "py-2", G = c ? "bg-brand-50 dark:bg-brand-900/20" : T && r % 2 == 1 ? "bg-gray-50/50 dark:bg-gray-800/30" : "bg-[var(--app-bg,white)]", K = f && f.some((e) => !e.hidden?.(t));
|
|
2270
|
+
return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("tr", {
|
|
2271
|
+
className: `border-b border-[var(--app-border,#e5e7eb)] hover:bg-[var(--app-hover,#f3f4f6)] transition-colors ${G} ${v ? "cursor-pointer" : ""} ${D}`,
|
|
2272
|
+
style: ee,
|
|
2273
|
+
onClick: H,
|
|
2274
|
+
onDoubleClick: U,
|
|
2275
|
+
onContextMenu: k,
|
|
2276
|
+
role: "row",
|
|
2277
|
+
"aria-selected": c,
|
|
2278
|
+
children: [
|
|
2279
|
+
u && /* @__PURE__ */ R("td", {
|
|
2280
|
+
className: `px-4 ${W} w-12`,
|
|
2281
|
+
children: /* @__PURE__ */ R("input", {
|
|
2282
|
+
type: "checkbox",
|
|
2283
|
+
checked: c,
|
|
2284
|
+
onChange: (e) => {
|
|
2285
|
+
e.nativeEvent instanceof MouseEvent && e.nativeEvent.shiftKey && m ? m(i) : p(i);
|
|
2286
|
+
},
|
|
2287
|
+
onClick: (e) => e.stopPropagation(),
|
|
2288
|
+
className: "h-4 w-4 rounded border-gray-300 text-brand-600 focus:ring-brand-600",
|
|
2289
|
+
"aria-label": `Select row ${r + 1}`
|
|
2290
|
+
})
|
|
2291
|
+
}),
|
|
2292
|
+
d && /* @__PURE__ */ R("td", {
|
|
2293
|
+
className: `px-2 ${W} w-10`,
|
|
2294
|
+
children: /* @__PURE__ */ R("button", {
|
|
2295
|
+
type: "button",
|
|
2296
|
+
onClick: (e) => {
|
|
2297
|
+
e.stopPropagation(), g(i);
|
|
2298
|
+
},
|
|
2299
|
+
className: "p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",
|
|
2300
|
+
"aria-label": l ? "Collapse row" : "Expand row",
|
|
2301
|
+
"aria-expanded": l,
|
|
2302
|
+
children: R(l ? h : _, { className: "h-4 w-4 text-gray-500" })
|
|
2303
|
+
})
|
|
2304
|
+
}),
|
|
2305
|
+
o.map((e) => {
|
|
2306
|
+
let n = M ? e.editable ?? !1 : b?.rowKey === i && b?.columnId === e.id;
|
|
2307
|
+
return /* @__PURE__ */ R(wt, {
|
|
2308
|
+
row: t,
|
|
2309
|
+
rowIndex: r,
|
|
2310
|
+
column: e,
|
|
2311
|
+
width: s[e.id],
|
|
2312
|
+
isEditing: n,
|
|
2313
|
+
onStartEdit: () => x(i, e.id),
|
|
2314
|
+
onSaveEdit: (t) => S(i, e.id, t),
|
|
2315
|
+
onCancelEdit: C,
|
|
2316
|
+
validationError: A?.[e.id],
|
|
2317
|
+
pendingValue: M ? j?.[e.id] : void 0,
|
|
2318
|
+
onPendingChange: M && N ? (t) => N(e.id, t) : void 0,
|
|
2319
|
+
enableTooltip: P,
|
|
2320
|
+
tooltipStyle: te,
|
|
2321
|
+
themeCellStyle: F?.(t, e)
|
|
2322
|
+
}, e.id);
|
|
2323
|
+
}),
|
|
2324
|
+
K && /* @__PURE__ */ R("td", {
|
|
2325
|
+
className: `px-4 ${W} text-right`,
|
|
2326
|
+
children: /* @__PURE__ */ z("div", {
|
|
2327
|
+
className: "inline-block",
|
|
2328
|
+
children: [/* @__PURE__ */ R("button", {
|
|
2329
|
+
ref: V,
|
|
2330
|
+
type: "button",
|
|
2331
|
+
onClick: (e) => {
|
|
2332
|
+
e.stopPropagation(), B((e) => !e);
|
|
2333
|
+
},
|
|
2334
|
+
className: "p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",
|
|
2335
|
+
"aria-label": "Row actions",
|
|
2336
|
+
"aria-haspopup": "menu",
|
|
2337
|
+
"aria-expanded": I,
|
|
2338
|
+
children: /* @__PURE__ */ R(O, { className: "h-4 w-4 text-gray-500" })
|
|
2339
|
+
}), /* @__PURE__ */ R(Dt, {
|
|
2340
|
+
anchorRef: V,
|
|
2341
|
+
open: I,
|
|
2342
|
+
onClose: () => B(!1),
|
|
2343
|
+
align: "right",
|
|
2344
|
+
children: /* @__PURE__ */ R(At, {
|
|
2345
|
+
row: t,
|
|
2346
|
+
actions: f,
|
|
2347
|
+
onClose: () => B(!1)
|
|
2348
|
+
})
|
|
2349
|
+
})]
|
|
2350
|
+
})
|
|
2351
|
+
}),
|
|
2352
|
+
!K && f && /* @__PURE__ */ R("td", { className: `px-4 ${W}` })
|
|
2353
|
+
]
|
|
2354
|
+
}), l && w && /* @__PURE__ */ R("tr", {
|
|
2355
|
+
className: "bg-gray-50/50 dark:bg-gray-800/20",
|
|
2356
|
+
children: /* @__PURE__ */ R("td", {
|
|
2357
|
+
colSpan: o.length + (u ? 1 : 0) + (d ? 1 : 0) + (f ? 1 : 0),
|
|
2358
|
+
className: "px-8 py-4",
|
|
2359
|
+
children: w
|
|
2360
|
+
})
|
|
2361
|
+
})] });
|
|
2362
|
+
}
|
|
2363
|
+
var kt = t(Ot);
|
|
2364
|
+
function At({ row: e, actions: t, onClose: n }) {
|
|
2365
|
+
return /* @__PURE__ */ R(L, { children: t.filter((t) => !t.hidden?.(e)).map((t) => /* @__PURE__ */ z("button", {
|
|
2366
|
+
type: "button",
|
|
2367
|
+
onClick: (r) => {
|
|
2368
|
+
r.stopPropagation(), t.onClick(e), n();
|
|
2369
|
+
},
|
|
2370
|
+
disabled: t.disabled?.(e),
|
|
2371
|
+
className: `w-full text-left px-3 py-2 text-sm flex items-center gap-2 transition-colors
|
|
2372
|
+
${t.variant === "danger" ? "text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}
|
|
2373
|
+
${t.disabled?.(e) ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
|
|
2374
|
+
`,
|
|
2375
|
+
role: "menuitem",
|
|
2376
|
+
children: [t.icon, t.label]
|
|
2377
|
+
}, t.id)) });
|
|
2378
|
+
}
|
|
2379
|
+
//#endregion
|
|
2380
|
+
//#region src/components/GroupRow.jsx
|
|
2381
|
+
function jt({ group: e, colSpan: t, isExpanded: n, onToggle: r, renderGroupHeader: i }) {
|
|
2382
|
+
return /* @__PURE__ */ R("tr", {
|
|
2383
|
+
className: "bg-gray-50 dark:bg-gray-800/50 border-b border-[var(--app-border,#e5e7eb)]",
|
|
2384
|
+
children: /* @__PURE__ */ R("td", {
|
|
2385
|
+
colSpan: t,
|
|
2386
|
+
className: "px-4 py-2",
|
|
2387
|
+
children: /* @__PURE__ */ z("div", {
|
|
2388
|
+
className: "flex items-center gap-2",
|
|
2389
|
+
style: { paddingLeft: e.__level * 24 },
|
|
2390
|
+
children: [/* @__PURE__ */ R("button", {
|
|
2391
|
+
type: "button",
|
|
2392
|
+
onClick: () => r(e.__groupKey),
|
|
2393
|
+
className: "p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",
|
|
2394
|
+
"aria-label": n ? "Collapse group" : "Expand group",
|
|
2395
|
+
"aria-expanded": n,
|
|
2396
|
+
children: R(n ? h : _, { className: "h-4 w-4 text-gray-500" })
|
|
2397
|
+
}), i ? i(e.__groupKey, e.__groupValue, e.__children, e.__level) : /* @__PURE__ */ z("span", {
|
|
2398
|
+
className: "text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
2399
|
+
children: [
|
|
2400
|
+
e.__groupField,
|
|
2401
|
+
": ",
|
|
2402
|
+
String(e.__groupValue ?? "N/A"),
|
|
2403
|
+
/* @__PURE__ */ z("span", {
|
|
2404
|
+
className: "ml-2 text-xs text-gray-400 font-normal",
|
|
2405
|
+
children: [
|
|
2406
|
+
"(",
|
|
2407
|
+
e.__children.length,
|
|
2408
|
+
" items)"
|
|
2409
|
+
]
|
|
2410
|
+
}),
|
|
2411
|
+
Object.entries(e.__aggregates).length > 0 && /* @__PURE__ */ R("span", {
|
|
2412
|
+
className: "ml-3 text-xs text-gray-400",
|
|
2413
|
+
children: Object.entries(e.__aggregates).map(([e, t]) => /* @__PURE__ */ z("span", {
|
|
2414
|
+
className: "ml-2",
|
|
2415
|
+
children: [
|
|
2416
|
+
e,
|
|
2417
|
+
": ",
|
|
2418
|
+
typeof t == "number" ? t.toLocaleString() : String(t)
|
|
2419
|
+
]
|
|
2420
|
+
}, e))
|
|
2421
|
+
})
|
|
2422
|
+
]
|
|
2423
|
+
})]
|
|
2424
|
+
})
|
|
2425
|
+
})
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
//#endregion
|
|
2429
|
+
//#region src/components/TableView.jsx
|
|
2430
|
+
function Mt({ table: e, props: t, onContextMenu: o }) {
|
|
2431
|
+
let { processedData: s, sorting: c, filtering: l, selection: u, columnManager: d, expandedKeys: f, toggleExpand: p, editingCell: m, setEditingCell: h, getKey: g, pagination: _, theme: v, rowGrouping: y, treeData: b, virtualization: x, pinnedTopRows: S, pinnedBottomRows: C, unpinnedData: w } = e, { expandable: T, rowActions: E, onRowClick: D, onRowDoubleClick: O, onCellEdit: ee, striped: k = !1, compact: A = !1, maxHeight: j, bordered: M = !1, rowClassName: N, rowPinning: P, rowGrouping: te, treeData: F, enableTooltips: I = !1, onRowReorder: L, floatingFilters: B = !1 } = t, V = a(null), H = x.enabled ? x.containerRef : V;
|
|
2432
|
+
r(() => {
|
|
2433
|
+
if (!_.isInfinite || !_.hasMore || !_.onLoadMore) return;
|
|
2434
|
+
let e = H.current;
|
|
2435
|
+
if (!e) return;
|
|
2436
|
+
let t = () => {
|
|
2437
|
+
let { scrollTop: t, scrollHeight: n, clientHeight: r } = e;
|
|
2438
|
+
n - t - r < 100 && _.onLoadMore?.();
|
|
2439
|
+
};
|
|
2440
|
+
return e.addEventListener("scroll", t), () => e.removeEventListener("scroll", t);
|
|
2441
|
+
}, [_, H]);
|
|
2442
|
+
let U = n((e, t) => {
|
|
2443
|
+
h({
|
|
2444
|
+
rowKey: e,
|
|
2445
|
+
columnId: t
|
|
2446
|
+
});
|
|
2447
|
+
}, [h]), W = n((e, t, n) => {
|
|
2448
|
+
ee?.(e, t, n), h(null);
|
|
2449
|
+
}, [ee, h]), G = n(() => h(null), [h]), K = T?.enabled ?? !1, q = !!E?.length, ne = !!(P && (S.length || C.length)), J = ne ? w : s, re = i(() => y.enabled ? y.applyGrouping(J) : J, [y, J]), ie = i(() => x.enabled ? x.getVirtualItems(re) : re, [x, re]), ae = i(() => b.enabled && F ? b.flattenTree(ie) : null, [
|
|
2450
|
+
b,
|
|
2451
|
+
F,
|
|
2452
|
+
ie
|
|
2453
|
+
]), oe = j ? {
|
|
2454
|
+
maxHeight: j,
|
|
2455
|
+
overflow: "auto"
|
|
2456
|
+
} : x.enabled ? {
|
|
2457
|
+
height: "100%",
|
|
2458
|
+
overflow: "auto"
|
|
2459
|
+
} : {}, se = d.visibleColumns.length + (u.showCheckbox ? 1 : 0) + (K ? 1 : 0) + (q ? 1 : 0), Y = (t, n, r = "") => {
|
|
2460
|
+
let i = g(t, n), a = typeof N == "function" ? N(t) : N ?? "", c = ae?.find((e) => e.treeKey === i), l = e.editing.isEditingRow(i), h = v.getRowStyle(t, n, u.isSelected(i), k), _ = v.getConditionalClassName(t);
|
|
2461
|
+
return /* @__PURE__ */ R(kt, {
|
|
2462
|
+
row: t,
|
|
2463
|
+
rowIndex: n,
|
|
2464
|
+
rowKey: i,
|
|
2465
|
+
columns: d.visibleColumns,
|
|
2466
|
+
columnWidths: d.columnWidths,
|
|
2467
|
+
isSelected: u.isSelected(i),
|
|
2468
|
+
isExpanded: f.includes(i),
|
|
2469
|
+
showCheckbox: u.showCheckbox,
|
|
2470
|
+
showExpandToggle: K || (c?.hasChildren ?? !1),
|
|
2471
|
+
rowActions: E,
|
|
2472
|
+
onToggleSelect: u.toggleRow,
|
|
2473
|
+
onShiftSelect: (e) => u.selectRange(e, s),
|
|
2474
|
+
onToggleExpand: c ? () => b.toggleNode(i) : p,
|
|
2475
|
+
onClick: D,
|
|
2476
|
+
onDoubleClick: O,
|
|
2477
|
+
editingCell: m,
|
|
2478
|
+
onStartEdit: U,
|
|
2479
|
+
onSaveEdit: W,
|
|
2480
|
+
onCancelEdit: G,
|
|
2481
|
+
expandContent: T?.render?.(t),
|
|
2482
|
+
striped: k,
|
|
2483
|
+
compact: A,
|
|
2484
|
+
rowClassName: `${a} ${_} ${r}`,
|
|
2485
|
+
rowStyle: h,
|
|
2486
|
+
onContextMenu: o ? (e) => o(e, t) : void 0,
|
|
2487
|
+
isEditingRow: l,
|
|
2488
|
+
validationErrors: l ? e.editing.validationErrors : void 0,
|
|
2489
|
+
pendingEdits: l ? e.editing.pendingEdits : void 0,
|
|
2490
|
+
onPendingChange: l ? e.editing.updatePendingEdit : void 0,
|
|
2491
|
+
enableTooltips: I,
|
|
2492
|
+
tooltipStyle: v.tooltipStyle,
|
|
2493
|
+
getCellStyle: v.getCellStyle
|
|
2494
|
+
}, i);
|
|
2495
|
+
};
|
|
2496
|
+
return /* @__PURE__ */ z("div", {
|
|
2497
|
+
ref: H,
|
|
2498
|
+
style: oe,
|
|
2499
|
+
className: "overflow-x-auto",
|
|
2500
|
+
onScroll: x.enabled ? x.handleScroll : void 0,
|
|
2501
|
+
children: [x.enabled && /* @__PURE__ */ R("div", {
|
|
2502
|
+
style: x.spacerStyle,
|
|
2503
|
+
children: /* @__PURE__ */ R("div", {
|
|
2504
|
+
style: x.offsetStyle,
|
|
2505
|
+
children: /* @__PURE__ */ R(X, {})
|
|
2506
|
+
})
|
|
2507
|
+
}), !x.enabled && /* @__PURE__ */ R(X, {})]
|
|
2508
|
+
});
|
|
2509
|
+
function X() {
|
|
2510
|
+
return /* @__PURE__ */ z("table", {
|
|
2511
|
+
className: `w-full text-sm ${M ? "border-collapse" : ""}`,
|
|
2512
|
+
role: "grid",
|
|
2513
|
+
"aria-label": t.ariaLabel ?? "Data table",
|
|
2514
|
+
children: [/* @__PURE__ */ R(vt, {
|
|
2515
|
+
columns: d.visibleColumns,
|
|
2516
|
+
getSortDirection: c.getSortDirection,
|
|
2517
|
+
onSort: c.toggleSort,
|
|
2518
|
+
columnWidths: d.columnWidths,
|
|
2519
|
+
onResize: d.resizeColumn,
|
|
2520
|
+
enableResizing: d.enableResizing,
|
|
2521
|
+
enableReordering: d.enableReordering,
|
|
2522
|
+
onReorder: d.reorderColumns,
|
|
2523
|
+
onReorderById: d.reorderColumnsById,
|
|
2524
|
+
showCheckbox: u.showCheckbox,
|
|
2525
|
+
isAllSelected: u.isAllSelected(s),
|
|
2526
|
+
isSomeSelected: u.isSomeSelected(s),
|
|
2527
|
+
onToggleAll: () => u.toggleAll(s),
|
|
2528
|
+
showExpandToggle: K,
|
|
2529
|
+
showActions: q,
|
|
2530
|
+
compact: A,
|
|
2531
|
+
getFilterValue: l.getFilterValue,
|
|
2532
|
+
onFilterChange: l.setFilter,
|
|
2533
|
+
floatingFilters: B,
|
|
2534
|
+
showColumnGroups: !0
|
|
2535
|
+
}), /* @__PURE__ */ z("tbody", { children: [
|
|
2536
|
+
ne && S.map((e, t) => Y(e, t, "bg-blue-50/50 dark:bg-blue-900/10")),
|
|
2537
|
+
ne && S.length > 0 && /* @__PURE__ */ R("tr", { children: /* @__PURE__ */ R("td", {
|
|
2538
|
+
colSpan: se,
|
|
2539
|
+
className: "h-0.5 bg-blue-200 dark:bg-blue-800"
|
|
2540
|
+
}) }),
|
|
2541
|
+
ae ? ae.map((e, t) => Y(e.row, t)) : ie.map((e, t) => {
|
|
2542
|
+
let n = e;
|
|
2543
|
+
return n.__isGroupRow ? /* @__PURE__ */ R(jt, {
|
|
2544
|
+
group: n,
|
|
2545
|
+
colSpan: se,
|
|
2546
|
+
isExpanded: y.isGroupExpanded(n.__groupKey),
|
|
2547
|
+
onToggle: y.toggleGroup,
|
|
2548
|
+
renderGroupHeader: te?.renderGroupHeader
|
|
2549
|
+
}, n.__groupKey) : Y(e, t);
|
|
2550
|
+
}),
|
|
2551
|
+
ne && C.length > 0 && /* @__PURE__ */ R("tr", { children: /* @__PURE__ */ R("td", {
|
|
2552
|
+
colSpan: se,
|
|
2553
|
+
className: "h-0.5 bg-blue-200 dark:bg-blue-800"
|
|
2554
|
+
}) }),
|
|
2555
|
+
ne && C.map((e, t) => Y(e, t, "bg-blue-50/50 dark:bg-blue-900/10"))
|
|
2556
|
+
] })]
|
|
2557
|
+
});
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
//#endregion
|
|
2561
|
+
//#region src/components/GridView.jsx
|
|
2562
|
+
function Nt({ table: e, props: t }) {
|
|
2563
|
+
let { processedData: n, selection: r, columnManager: i, getKey: a } = e, { renderGridCard: o, onRowClick: s, theme: c } = t;
|
|
2564
|
+
return /* @__PURE__ */ R("div", {
|
|
2565
|
+
className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 p-4",
|
|
2566
|
+
children: n.map((e, t) => {
|
|
2567
|
+
let n = a(e, t), l = r.isSelected(n);
|
|
2568
|
+
return o ? /* @__PURE__ */ R("div", {
|
|
2569
|
+
className: `${l ? "ring-2 ring-brand-500" : ""} ${s ? "cursor-pointer" : ""}`,
|
|
2570
|
+
onClick: () => s?.(e),
|
|
2571
|
+
children: o(e)
|
|
2572
|
+
}, n) : /* @__PURE__ */ z("div", {
|
|
2573
|
+
className: `bg-[var(--app-bg,white)] border border-[var(--app-border,#e5e7eb)] rounded-lg p-4 shadow-sm hover:shadow-md transition-shadow
|
|
2574
|
+
${l ? "ring-2 ring-brand-500" : ""}
|
|
2575
|
+
${s ? "cursor-pointer" : ""}
|
|
2576
|
+
${c?.gridCard ?? ""}
|
|
2577
|
+
`,
|
|
2578
|
+
onClick: () => s?.(e),
|
|
2579
|
+
role: "article",
|
|
2580
|
+
children: [r.showCheckbox && /* @__PURE__ */ R("div", {
|
|
2581
|
+
className: "mb-3",
|
|
2582
|
+
children: /* @__PURE__ */ R("input", {
|
|
2583
|
+
type: "checkbox",
|
|
2584
|
+
checked: l,
|
|
2585
|
+
onChange: () => r.toggleRow(n),
|
|
2586
|
+
onClick: (e) => e.stopPropagation(),
|
|
2587
|
+
className: "h-4 w-4 rounded border-gray-300 text-brand-600 focus:ring-brand-600",
|
|
2588
|
+
"aria-label": `Select item ${t + 1}`
|
|
2589
|
+
})
|
|
2590
|
+
}), /* @__PURE__ */ R("div", {
|
|
2591
|
+
className: "space-y-2",
|
|
2592
|
+
children: i.visibleColumns.slice(0, 6).map((n) => {
|
|
2593
|
+
let r = Z(e, n), i = n.cell ? n.cell({
|
|
2594
|
+
value: r,
|
|
2595
|
+
row: e,
|
|
2596
|
+
rowIndex: t,
|
|
2597
|
+
column: n
|
|
2598
|
+
}) : r ?? "—";
|
|
2599
|
+
return /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("span", {
|
|
2600
|
+
className: "text-xs font-medium text-gray-500 uppercase",
|
|
2601
|
+
children: n.header
|
|
2602
|
+
}), /* @__PURE__ */ R("div", {
|
|
2603
|
+
className: "text-sm text-[var(--app-text)]",
|
|
2604
|
+
children: i
|
|
2605
|
+
})] }, n.id);
|
|
2606
|
+
})
|
|
2607
|
+
})]
|
|
2608
|
+
}, n);
|
|
2609
|
+
})
|
|
2610
|
+
});
|
|
2611
|
+
}
|
|
2612
|
+
//#endregion
|
|
2613
|
+
//#region src/components/ListView.jsx
|
|
2614
|
+
function Pt({ table: e, props: t }) {
|
|
2615
|
+
let { processedData: n, selection: r, columnManager: i, getKey: a } = e, { renderListItem: o, onRowClick: s, theme: c } = t;
|
|
2616
|
+
return /* @__PURE__ */ R("div", {
|
|
2617
|
+
className: "divide-y divide-[var(--app-border,#e5e7eb)]",
|
|
2618
|
+
children: n.map((e, t) => {
|
|
2619
|
+
let n = a(e, t), l = r.isSelected(n);
|
|
2620
|
+
return o ? /* @__PURE__ */ R("div", {
|
|
2621
|
+
className: `${l ? "bg-brand-50 dark:bg-brand-900/20" : ""} ${s ? "cursor-pointer" : ""}`,
|
|
2622
|
+
children: o(e)
|
|
2623
|
+
}, n) : /* @__PURE__ */ z("div", {
|
|
2624
|
+
className: `flex items-center gap-4 px-4 py-3 hover:bg-[var(--app-hover,#f3f4f6)] transition-colors
|
|
2625
|
+
${l ? "bg-brand-50 dark:bg-brand-900/20" : ""}
|
|
2626
|
+
${s ? "cursor-pointer" : ""}
|
|
2627
|
+
${c?.listItem ?? ""}
|
|
2628
|
+
`,
|
|
2629
|
+
onClick: () => s?.(e),
|
|
2630
|
+
role: "listitem",
|
|
2631
|
+
children: [r.showCheckbox && /* @__PURE__ */ R("input", {
|
|
2632
|
+
type: "checkbox",
|
|
2633
|
+
checked: l,
|
|
2634
|
+
onChange: () => r.toggleRow(n),
|
|
2635
|
+
onClick: (e) => e.stopPropagation(),
|
|
2636
|
+
className: "h-4 w-4 rounded border-gray-300 text-brand-600 focus:ring-brand-600 shrink-0",
|
|
2637
|
+
"aria-label": `Select item ${t + 1}`
|
|
2638
|
+
}), /* @__PURE__ */ R("div", {
|
|
2639
|
+
className: "flex-1 flex items-center gap-6 min-w-0",
|
|
2640
|
+
children: i.visibleColumns.slice(0, 5).map((n) => {
|
|
2641
|
+
let r = Z(e, n), i = n.cell ? n.cell({
|
|
2642
|
+
value: r,
|
|
2643
|
+
row: e,
|
|
2644
|
+
rowIndex: t,
|
|
2645
|
+
column: n
|
|
2646
|
+
}) : r ?? "—";
|
|
2647
|
+
return /* @__PURE__ */ z("div", {
|
|
2648
|
+
className: "min-w-0",
|
|
2649
|
+
children: [/* @__PURE__ */ R("span", {
|
|
2650
|
+
className: "text-xs text-gray-500 block",
|
|
2651
|
+
children: n.header
|
|
2652
|
+
}), /* @__PURE__ */ R("div", {
|
|
2653
|
+
className: "text-sm text-[var(--app-text)] truncate",
|
|
2654
|
+
children: i
|
|
2655
|
+
})]
|
|
2656
|
+
}, n.id);
|
|
2657
|
+
})
|
|
2658
|
+
})]
|
|
2659
|
+
}, n);
|
|
2660
|
+
})
|
|
2661
|
+
});
|
|
2662
|
+
}
|
|
2663
|
+
//#endregion
|
|
2664
|
+
//#region src/components/DataTablePagination.jsx
|
|
2665
|
+
function Ft({ page: e, pageSize: t, totalPages: n, totalItems: r, pageSizeOptions: i, onPageChange: a, onPageSizeChange: o }) {
|
|
2666
|
+
let s = (e - 1) * t + 1, c = Math.min(e * t, r), l = () => {
|
|
2667
|
+
if (n <= 7) return Array.from({ length: n }, (e, t) => t + 1);
|
|
2668
|
+
let t = [1];
|
|
2669
|
+
e > 3 && t.push("...");
|
|
2670
|
+
let r = Math.max(2, e - 1), i = Math.min(n - 1, e + 1);
|
|
2671
|
+
for (let e = r; e <= i; e++) t.push(e);
|
|
2672
|
+
return e < n - 2 && t.push("..."), t.push(n), t;
|
|
2673
|
+
};
|
|
2674
|
+
return /* @__PURE__ */ z("div", {
|
|
2675
|
+
className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between px-4 py-3 border-t border-[var(--app-border,#e5e7eb)]",
|
|
2676
|
+
children: [/* @__PURE__ */ z("div", {
|
|
2677
|
+
className: "flex items-center gap-3",
|
|
2678
|
+
children: [/* @__PURE__ */ z("span", {
|
|
2679
|
+
className: "text-sm text-gray-500",
|
|
2680
|
+
children: [
|
|
2681
|
+
s,
|
|
2682
|
+
"–",
|
|
2683
|
+
c,
|
|
2684
|
+
" of ",
|
|
2685
|
+
r
|
|
2686
|
+
]
|
|
2687
|
+
}), /* @__PURE__ */ R("select", {
|
|
2688
|
+
value: t,
|
|
2689
|
+
onChange: (e) => o(Number(e.target.value)),
|
|
2690
|
+
className: "h-8 px-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-[var(--app-bg)] focus:outline-none focus:ring-1 focus:ring-brand-500",
|
|
2691
|
+
"aria-label": "Rows per page",
|
|
2692
|
+
children: i.map((e) => /* @__PURE__ */ z("option", {
|
|
2693
|
+
value: e,
|
|
2694
|
+
children: [e, " / page"]
|
|
2695
|
+
}, e))
|
|
2696
|
+
})]
|
|
2697
|
+
}), /* @__PURE__ */ z("div", {
|
|
2698
|
+
className: "flex items-center gap-1",
|
|
2699
|
+
children: [
|
|
2700
|
+
/* @__PURE__ */ R(It, {
|
|
2701
|
+
onClick: () => a(1),
|
|
2702
|
+
disabled: e <= 1,
|
|
2703
|
+
"aria-label": "First page",
|
|
2704
|
+
children: /* @__PURE__ */ R(v, { className: "h-4 w-4" })
|
|
2705
|
+
}),
|
|
2706
|
+
/* @__PURE__ */ R(It, {
|
|
2707
|
+
onClick: () => a(e - 1),
|
|
2708
|
+
disabled: e <= 1,
|
|
2709
|
+
"aria-label": "Previous page",
|
|
2710
|
+
children: /* @__PURE__ */ R(g, { className: "h-4 w-4" })
|
|
2711
|
+
}),
|
|
2712
|
+
l().map((t, n) => t === "..." ? /* @__PURE__ */ R("span", {
|
|
2713
|
+
className: "px-2 text-sm text-gray-400",
|
|
2714
|
+
children: "…"
|
|
2715
|
+
}, `ellipsis-${n}`) : /* @__PURE__ */ R(It, {
|
|
2716
|
+
onClick: () => a(t),
|
|
2717
|
+
active: t === e,
|
|
2718
|
+
"aria-label": `Page ${t}`,
|
|
2719
|
+
"aria-current": t === e ? "page" : void 0,
|
|
2720
|
+
children: t
|
|
2721
|
+
}, t)),
|
|
2722
|
+
/* @__PURE__ */ R(It, {
|
|
2723
|
+
onClick: () => a(e + 1),
|
|
2724
|
+
disabled: e >= n,
|
|
2725
|
+
"aria-label": "Next page",
|
|
2726
|
+
children: /* @__PURE__ */ R(_, { className: "h-4 w-4" })
|
|
2727
|
+
}),
|
|
2728
|
+
/* @__PURE__ */ R(It, {
|
|
2729
|
+
onClick: () => a(n),
|
|
2730
|
+
disabled: e >= n,
|
|
2731
|
+
"aria-label": "Last page",
|
|
2732
|
+
children: /* @__PURE__ */ R(y, { className: "h-4 w-4" })
|
|
2733
|
+
})
|
|
2734
|
+
]
|
|
2735
|
+
})]
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
function It({ children: e, onClick: t, disabled: n = !1, active: r = !1, ...i }) {
|
|
2739
|
+
return /* @__PURE__ */ R("button", {
|
|
2740
|
+
type: "button",
|
|
2741
|
+
onClick: t,
|
|
2742
|
+
disabled: n,
|
|
2743
|
+
className: `inline-flex items-center justify-center h-8 min-w-[32px] px-2 text-sm rounded-md transition-colors
|
|
2744
|
+
${r ? "bg-brand-600 text-white font-medium" : n ? "text-gray-300 dark:text-gray-600 cursor-not-allowed" : "text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,
|
|
2745
|
+
...i,
|
|
2746
|
+
children: e
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
//#endregion
|
|
2750
|
+
//#region src/components/SidebarPanel.jsx
|
|
2751
|
+
function Lt({ panels: e, activePanel: t, onClose: n, columns: r, hiddenColumns: i, columnOrder: a, onToggleColumn: o, onReorderColumns: s, filters: c, onFilterChange: l, onClearFilters: u }) {
|
|
2752
|
+
let d = e.find((e) => e.type === t);
|
|
2753
|
+
return d ? /* @__PURE__ */ z("div", {
|
|
2754
|
+
className: "w-64 border-l border-[var(--app-border,#e5e7eb)] bg-[var(--app-bg,white)] flex flex-col overflow-hidden shrink-0",
|
|
2755
|
+
children: [/* @__PURE__ */ z("div", {
|
|
2756
|
+
className: "flex items-center justify-between px-3 py-2 border-b border-[var(--app-border,#e5e7eb)]",
|
|
2757
|
+
children: [/* @__PURE__ */ R("span", {
|
|
2758
|
+
className: "text-sm font-semibold text-[var(--app-text)]",
|
|
2759
|
+
children: d.title
|
|
2760
|
+
}), /* @__PURE__ */ R("button", {
|
|
2761
|
+
type: "button",
|
|
2762
|
+
onClick: n,
|
|
2763
|
+
className: "p-1 text-gray-400 hover:text-gray-600 rounded transition-colors",
|
|
2764
|
+
"aria-label": "Close panel",
|
|
2765
|
+
children: /* @__PURE__ */ R(I, { className: "h-4 w-4" })
|
|
2766
|
+
})]
|
|
2767
|
+
}), /* @__PURE__ */ z("div", {
|
|
2768
|
+
className: "flex-1 overflow-y-auto p-3",
|
|
2769
|
+
children: [
|
|
2770
|
+
d.type === "columns" && r && o && /* @__PURE__ */ R(Rt, {
|
|
2771
|
+
columns: r,
|
|
2772
|
+
hiddenColumns: i ?? /* @__PURE__ */ new Set(),
|
|
2773
|
+
onToggle: o
|
|
2774
|
+
}),
|
|
2775
|
+
d.type === "filters" && r && l && /* @__PURE__ */ R(zt, {
|
|
2776
|
+
columns: r,
|
|
2777
|
+
filters: c ?? [],
|
|
2778
|
+
onFilterChange: l,
|
|
2779
|
+
onClearFilters: u
|
|
2780
|
+
}),
|
|
2781
|
+
d.type === "custom" && d.render?.()
|
|
2782
|
+
]
|
|
2783
|
+
})]
|
|
2784
|
+
}) : null;
|
|
2785
|
+
}
|
|
2786
|
+
function Rt({ columns: e, hiddenColumns: t, onToggle: n }) {
|
|
2787
|
+
return /* @__PURE__ */ z("div", {
|
|
2788
|
+
className: "space-y-1",
|
|
2789
|
+
children: [/* @__PURE__ */ R("p", {
|
|
2790
|
+
className: "text-xs text-gray-500 mb-2",
|
|
2791
|
+
children: "Toggle column visibility"
|
|
2792
|
+
}), e.map((e) => /* @__PURE__ */ z("label", {
|
|
2793
|
+
className: "flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700",
|
|
2794
|
+
children: [/* @__PURE__ */ R("input", {
|
|
2795
|
+
type: "checkbox",
|
|
2796
|
+
checked: !t.has(e.id),
|
|
2797
|
+
onChange: () => n(e.id),
|
|
2798
|
+
className: "h-3.5 w-3.5 rounded border-gray-300 text-brand-600 focus:ring-brand-600"
|
|
2799
|
+
}), /* @__PURE__ */ R("span", {
|
|
2800
|
+
className: "text-sm text-gray-700 dark:text-gray-300 truncate",
|
|
2801
|
+
children: e.header
|
|
2802
|
+
})]
|
|
2803
|
+
}, e.id))]
|
|
2804
|
+
});
|
|
2805
|
+
}
|
|
2806
|
+
function zt({ columns: e, filters: t, onFilterChange: n, onClearFilters: r }) {
|
|
2807
|
+
let i = e.filter((e) => e.filterable !== !1 && e.filterType);
|
|
2808
|
+
return /* @__PURE__ */ z("div", {
|
|
2809
|
+
className: "space-y-3",
|
|
2810
|
+
children: [
|
|
2811
|
+
r && t.length > 0 && /* @__PURE__ */ R("button", {
|
|
2812
|
+
type: "button",
|
|
2813
|
+
onClick: r,
|
|
2814
|
+
className: "text-xs text-brand-600 hover:text-brand-700 underline",
|
|
2815
|
+
children: "Clear all filters"
|
|
2816
|
+
}),
|
|
2817
|
+
i.length === 0 && /* @__PURE__ */ R("p", {
|
|
2818
|
+
className: "text-xs text-gray-400",
|
|
2819
|
+
children: "No filterable columns"
|
|
2820
|
+
}),
|
|
2821
|
+
i.map((e) => {
|
|
2822
|
+
let r = t.find((t) => t.columnId === e.id)?.value ?? "";
|
|
2823
|
+
return /* @__PURE__ */ z("div", { children: [
|
|
2824
|
+
/* @__PURE__ */ R("label", {
|
|
2825
|
+
className: "text-xs font-medium text-gray-500 block mb-1",
|
|
2826
|
+
children: e.header
|
|
2827
|
+
}),
|
|
2828
|
+
(e.filterType === "text" || e.filterType === "number") && /* @__PURE__ */ R("input", {
|
|
2829
|
+
type: e.filterType === "number" ? "number" : "text",
|
|
2830
|
+
value: String(r),
|
|
2831
|
+
onChange: (t) => n(e.id, t.target.value, "contains"),
|
|
2832
|
+
placeholder: "Filter...",
|
|
2833
|
+
className: "w-full px-2 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg)]"
|
|
2834
|
+
}),
|
|
2835
|
+
e.filterType === "select" && e.filterOptions && /* @__PURE__ */ z("select", {
|
|
2836
|
+
value: String(r),
|
|
2837
|
+
onChange: (t) => n(e.id, t.target.value, "eq"),
|
|
2838
|
+
className: "w-full px-2 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg)]",
|
|
2839
|
+
children: [/* @__PURE__ */ R("option", {
|
|
2840
|
+
value: "",
|
|
2841
|
+
children: "All"
|
|
2842
|
+
}), e.filterOptions.map((e) => /* @__PURE__ */ R("option", {
|
|
2843
|
+
value: e.value,
|
|
2844
|
+
children: e.label
|
|
2845
|
+
}, e.value))]
|
|
2846
|
+
})
|
|
2847
|
+
] }, e.id);
|
|
2848
|
+
})
|
|
2849
|
+
]
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
//#endregion
|
|
2853
|
+
//#region src/components/PresetManager.jsx
|
|
2854
|
+
function Bt({ presets: t, onSave: n, onLoad: r, onDelete: i, onRename: a, getCurrentConfig: s }) {
|
|
2855
|
+
let [c, l] = o(!1), [u, d] = o(""), [f, h] = o(null), [g, _] = o(""), v = e.useRef(null);
|
|
2856
|
+
e.useEffect(() => {
|
|
2857
|
+
if (!c) return;
|
|
2858
|
+
let e = (e) => {
|
|
2859
|
+
v.current && !v.current.contains(e.target) && (l(!1), h(null));
|
|
2860
|
+
};
|
|
2861
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
2862
|
+
}, [c]);
|
|
2863
|
+
let y = () => {
|
|
2864
|
+
u.trim() && (n(u.trim(), s()), d(""));
|
|
2865
|
+
}, b = (e) => {
|
|
2866
|
+
g.trim() && (a(e, g.trim()), h(null));
|
|
2867
|
+
};
|
|
2868
|
+
return /* @__PURE__ */ z("div", {
|
|
2869
|
+
className: "relative",
|
|
2870
|
+
ref: v,
|
|
2871
|
+
children: [/* @__PURE__ */ z("button", {
|
|
2872
|
+
type: "button",
|
|
2873
|
+
onClick: () => l((e) => !e),
|
|
2874
|
+
className: "inline-flex items-center gap-1.5 px-3 py-2 text-sm text-gray-600 hover:text-gray-800 hover:bg-gray-100 rounded-md transition-colors",
|
|
2875
|
+
"aria-label": "Table presets",
|
|
2876
|
+
title: "Table presets",
|
|
2877
|
+
children: [
|
|
2878
|
+
/* @__PURE__ */ R(p, { className: "h-4 w-4" }),
|
|
2879
|
+
"Presets",
|
|
2880
|
+
t.length > 0 && /* @__PURE__ */ R("span", {
|
|
2881
|
+
className: "ml-1 text-xs bg-gray-200 text-gray-600 rounded-full px-1.5 py-0.5",
|
|
2882
|
+
children: t.length
|
|
2883
|
+
})
|
|
2884
|
+
]
|
|
2885
|
+
}), c && /* @__PURE__ */ z("div", {
|
|
2886
|
+
className: "absolute right-0 top-full mt-1 z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[280px]",
|
|
2887
|
+
children: [/* @__PURE__ */ z("div", {
|
|
2888
|
+
className: "flex items-center gap-2 mb-3",
|
|
2889
|
+
children: [/* @__PURE__ */ R("input", {
|
|
2890
|
+
type: "text",
|
|
2891
|
+
value: u,
|
|
2892
|
+
onChange: (e) => d(e.target.value),
|
|
2893
|
+
onKeyDown: (e) => e.key === "Enter" && y(),
|
|
2894
|
+
placeholder: "Save current view as...",
|
|
2895
|
+
className: "flex-1 px-2 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg)]"
|
|
2896
|
+
}), /* @__PURE__ */ R("button", {
|
|
2897
|
+
type: "button",
|
|
2898
|
+
onClick: y,
|
|
2899
|
+
disabled: !u.trim(),
|
|
2900
|
+
className: "p-1.5 text-brand-600 hover:bg-brand-50 rounded disabled:opacity-50",
|
|
2901
|
+
"aria-label": "Save preset",
|
|
2902
|
+
children: /* @__PURE__ */ R(M, { className: "h-4 w-4" })
|
|
2903
|
+
})]
|
|
2904
|
+
}), t.length === 0 ? /* @__PURE__ */ R("p", {
|
|
2905
|
+
className: "text-xs text-gray-400 text-center py-2",
|
|
2906
|
+
children: "No saved presets"
|
|
2907
|
+
}) : /* @__PURE__ */ R("div", {
|
|
2908
|
+
className: "space-y-1 max-h-64 overflow-y-auto",
|
|
2909
|
+
children: t.map((e) => /* @__PURE__ */ R("div", {
|
|
2910
|
+
className: "flex items-center justify-between px-2 py-1.5 rounded hover:bg-gray-50 dark:hover:bg-gray-700 group",
|
|
2911
|
+
children: f === e.id ? /* @__PURE__ */ z("div", {
|
|
2912
|
+
className: "flex items-center gap-1 flex-1",
|
|
2913
|
+
children: [/* @__PURE__ */ R("input", {
|
|
2914
|
+
type: "text",
|
|
2915
|
+
value: g,
|
|
2916
|
+
onChange: (e) => _(e.target.value),
|
|
2917
|
+
onKeyDown: (t) => {
|
|
2918
|
+
t.key === "Enter" && b(e.id), t.key === "Escape" && h(null);
|
|
2919
|
+
},
|
|
2920
|
+
className: "flex-1 px-1 py-0.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-brand-500 bg-[var(--app-bg)]",
|
|
2921
|
+
autoFocus: !0
|
|
2922
|
+
}), /* @__PURE__ */ R("button", {
|
|
2923
|
+
type: "button",
|
|
2924
|
+
onClick: () => b(e.id),
|
|
2925
|
+
className: "p-1 text-green-600 hover:bg-green-50 rounded",
|
|
2926
|
+
children: /* @__PURE__ */ R(m, { className: "h-3 w-3" })
|
|
2927
|
+
})]
|
|
2928
|
+
}) : /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("button", {
|
|
2929
|
+
type: "button",
|
|
2930
|
+
onClick: () => {
|
|
2931
|
+
r(e.id), l(!1);
|
|
2932
|
+
},
|
|
2933
|
+
className: "text-sm text-gray-700 dark:text-gray-300 truncate flex-1 text-left",
|
|
2934
|
+
title: `Load "${e.name}"`,
|
|
2935
|
+
children: e.name
|
|
2936
|
+
}), /* @__PURE__ */ z("div", {
|
|
2937
|
+
className: "flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",
|
|
2938
|
+
children: [/* @__PURE__ */ R("button", {
|
|
2939
|
+
type: "button",
|
|
2940
|
+
onClick: () => {
|
|
2941
|
+
h(e.id), _(e.name);
|
|
2942
|
+
},
|
|
2943
|
+
className: "p-1 text-gray-400 hover:text-gray-600",
|
|
2944
|
+
"aria-label": `Rename preset ${e.name}`,
|
|
2945
|
+
children: /* @__PURE__ */ R(S, { className: "h-3 w-3" })
|
|
2946
|
+
}), /* @__PURE__ */ R("button", {
|
|
2947
|
+
type: "button",
|
|
2948
|
+
onClick: () => i(e.id),
|
|
2949
|
+
className: "p-1 text-gray-400 hover:text-red-500",
|
|
2950
|
+
"aria-label": `Delete preset ${e.name}`,
|
|
2951
|
+
children: /* @__PURE__ */ R(F, { className: "h-3 w-3" })
|
|
2952
|
+
})]
|
|
2953
|
+
})] })
|
|
2954
|
+
}, e.id))
|
|
2955
|
+
})]
|
|
2956
|
+
})]
|
|
2957
|
+
});
|
|
2958
|
+
}
|
|
2959
|
+
//#endregion
|
|
2960
|
+
//#region src/components/ContextMenu.jsx
|
|
2961
|
+
function Vt({ x: e, y: t, row: n, items: i, onClose: o }) {
|
|
2962
|
+
let s = a(null);
|
|
2963
|
+
r(() => {
|
|
2964
|
+
let e = (e) => {
|
|
2965
|
+
s.current && !s.current.contains(e.target) && o();
|
|
2966
|
+
}, t = (e) => {
|
|
2967
|
+
e.key === "Escape" && o();
|
|
2968
|
+
};
|
|
2969
|
+
return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
|
|
2970
|
+
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
|
|
2971
|
+
};
|
|
2972
|
+
}, [o]), r(() => {
|
|
2973
|
+
if (!s.current) return;
|
|
2974
|
+
let n = s.current.getBoundingClientRect(), r = s.current;
|
|
2975
|
+
n.right > window.innerWidth && (r.style.left = `${e - n.width}px`), n.bottom > window.innerHeight && (r.style.top = `${t - n.height}px`);
|
|
2976
|
+
}, [e, t]);
|
|
2977
|
+
let c = i.filter((e) => !e.hidden?.(n));
|
|
2978
|
+
return c.length ? /* @__PURE__ */ R("div", {
|
|
2979
|
+
ref: s,
|
|
2980
|
+
className: "fixed z-[9999] bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl py-1 min-w-[160px] animate-in fade-in zoom-in-95 duration-100",
|
|
2981
|
+
style: {
|
|
2982
|
+
left: e,
|
|
2983
|
+
top: t
|
|
2984
|
+
},
|
|
2985
|
+
role: "menu",
|
|
2986
|
+
children: c.map((e) => e.separator ? /* @__PURE__ */ R("div", {
|
|
2987
|
+
className: "my-1 border-t border-gray-200 dark:border-gray-700",
|
|
2988
|
+
role: "separator"
|
|
2989
|
+
}, e.id) : /* @__PURE__ */ z("button", {
|
|
2990
|
+
type: "button",
|
|
2991
|
+
onClick: () => {
|
|
2992
|
+
e.onClick(n), o();
|
|
2993
|
+
},
|
|
2994
|
+
disabled: e.disabled?.(n),
|
|
2995
|
+
className: `w-full text-left px-3 py-2 text-sm flex items-center gap-2 transition-colors ${e.variant === "danger" ? "text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"} ${e.disabled?.(n) ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}`,
|
|
2996
|
+
role: "menuitem",
|
|
2997
|
+
children: [e.icon && /* @__PURE__ */ R("span", {
|
|
2998
|
+
className: "w-4 h-4 flex-shrink-0",
|
|
2999
|
+
children: e.icon
|
|
3000
|
+
}), e.label]
|
|
3001
|
+
}, e.id))
|
|
3002
|
+
}) : null;
|
|
3003
|
+
}
|
|
3004
|
+
//#endregion
|
|
3005
|
+
//#region src/components/StatusBar.jsx
|
|
3006
|
+
function Ht({ config: e, data: t, state: n }) {
|
|
3007
|
+
let r = i(() => e.computeItems?.(t, n) ?? [], [
|
|
3008
|
+
e,
|
|
3009
|
+
t,
|
|
3010
|
+
n
|
|
3011
|
+
]), a = i(() => [...e.items ?? [], ...r], [e.items, r]);
|
|
3012
|
+
return a.length ? /* @__PURE__ */ R("div", {
|
|
3013
|
+
className: `flex items-center gap-4 px-4 py-2 text-xs text-gray-500 border-t border-[var(--app-border,#e5e7eb)] bg-[var(--app-surface,#f9fafb)] ${e.className ?? ""}`,
|
|
3014
|
+
role: "status",
|
|
3015
|
+
"aria-label": "Table status",
|
|
3016
|
+
children: a.map((e) => /* @__PURE__ */ z("div", {
|
|
3017
|
+
className: "flex items-center gap-1.5",
|
|
3018
|
+
children: [
|
|
3019
|
+
e.icon && /* @__PURE__ */ R("span", {
|
|
3020
|
+
className: "w-3.5 h-3.5 flex-shrink-0",
|
|
3021
|
+
children: e.icon
|
|
3022
|
+
}),
|
|
3023
|
+
/* @__PURE__ */ z("span", {
|
|
3024
|
+
className: "text-gray-400",
|
|
3025
|
+
children: [e.label, ":"]
|
|
3026
|
+
}),
|
|
3027
|
+
/* @__PURE__ */ R("span", {
|
|
3028
|
+
className: "font-medium text-gray-600",
|
|
3029
|
+
children: e.value
|
|
3030
|
+
})
|
|
3031
|
+
]
|
|
3032
|
+
}, e.id))
|
|
3033
|
+
}) : null;
|
|
3034
|
+
}
|
|
3035
|
+
//#endregion
|
|
3036
|
+
//#region src/hooks/useChartData.js
|
|
3037
|
+
var Ut = [
|
|
3038
|
+
"#6366f1",
|
|
3039
|
+
"#f59e0b",
|
|
3040
|
+
"#10b981",
|
|
3041
|
+
"#ef4444",
|
|
3042
|
+
"#8b5cf6",
|
|
3043
|
+
"#06b6d4",
|
|
3044
|
+
"#f97316",
|
|
3045
|
+
"#84cc16",
|
|
3046
|
+
"#ec4899",
|
|
3047
|
+
"#14b8a6"
|
|
3048
|
+
];
|
|
3049
|
+
function Wt(e) {
|
|
3050
|
+
if (typeof e == "number") return e;
|
|
3051
|
+
if (typeof e == "boolean") return e ? 1 : 0;
|
|
3052
|
+
let t = Number(e);
|
|
3053
|
+
return isNaN(t) ? 0 : t;
|
|
3054
|
+
}
|
|
3055
|
+
function Gt(e, t) {
|
|
3056
|
+
if (!e.length) return 0;
|
|
3057
|
+
switch (t) {
|
|
3058
|
+
case "sum": return e.reduce((e, t) => e + t, 0);
|
|
3059
|
+
case "avg": return e.reduce((e, t) => e + t, 0) / e.length;
|
|
3060
|
+
case "count": return e.length;
|
|
3061
|
+
case "min": return Math.min(...e);
|
|
3062
|
+
case "max": return Math.max(...e);
|
|
3063
|
+
default: return e.reduce((e, t) => e + t, 0);
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
function Kt(e, t, n, r, i) {
|
|
3067
|
+
let a = n.find((e) => e.id === t.groupBy);
|
|
3068
|
+
if (!a) return [];
|
|
3069
|
+
let o = /* @__PURE__ */ new Map();
|
|
3070
|
+
e.forEach((e) => {
|
|
3071
|
+
let t = String(Z(e, a) ?? "Unknown"), n = o.get(t) ?? [];
|
|
3072
|
+
n.push(e), o.set(t, n);
|
|
3073
|
+
});
|
|
3074
|
+
let s = t.aggregation ?? "sum";
|
|
3075
|
+
return Array.from(o.entries()).map(([e, t]) => {
|
|
3076
|
+
let n = { label: e };
|
|
3077
|
+
return i.forEach((e) => {
|
|
3078
|
+
let r = t.map((t) => Wt(Z(t, e)));
|
|
3079
|
+
n[e.id] = Gt(r, s);
|
|
3080
|
+
}), n;
|
|
3081
|
+
});
|
|
3082
|
+
}
|
|
3083
|
+
function qt({ data: e, config: t, columns: n }) {
|
|
3084
|
+
return {
|
|
3085
|
+
chartData: i(() => {
|
|
3086
|
+
if (!e.length || !t.labelColumn || !t.dataColumns.length) return [];
|
|
3087
|
+
let r = n.find((e) => e.id === t.labelColumn);
|
|
3088
|
+
if (!r) return [];
|
|
3089
|
+
let i = t.dataColumns.map((e) => n.find((t) => t.id === e)).filter((e) => e != null);
|
|
3090
|
+
return i.length ? t.groupBy ? Kt(e, t, n, r, i) : e.map((e) => {
|
|
3091
|
+
let t = { label: String(Z(e, r) ?? "") };
|
|
3092
|
+
return i.forEach((n) => {
|
|
3093
|
+
t[n.id] = Wt(Z(e, n));
|
|
3094
|
+
}), t;
|
|
3095
|
+
}) : [];
|
|
3096
|
+
}, [
|
|
3097
|
+
e,
|
|
3098
|
+
t,
|
|
3099
|
+
n
|
|
3100
|
+
]),
|
|
3101
|
+
series: i(() => t.dataColumns.map((e, r) => ({
|
|
3102
|
+
key: e,
|
|
3103
|
+
name: n.find((t) => t.id === e)?.header ?? e,
|
|
3104
|
+
color: t.colors?.[r] ?? Ut[r % Ut.length]
|
|
3105
|
+
})), [
|
|
3106
|
+
t.dataColumns,
|
|
3107
|
+
t.colors,
|
|
3108
|
+
n
|
|
3109
|
+
])
|
|
3110
|
+
};
|
|
3111
|
+
}
|
|
3112
|
+
//#endregion
|
|
3113
|
+
//#region src/components/DataChart.jsx
|
|
3114
|
+
function Jt({ data: e, config: t, columns: r, onRemove: i, onEdit: o, className: s = "" }) {
|
|
3115
|
+
let { chartData: c, series: l } = qt({
|
|
3116
|
+
data: e,
|
|
3117
|
+
config: t,
|
|
3118
|
+
columns: r
|
|
3119
|
+
}), u = a(null), d = t.height ?? 300, f = n(async () => {
|
|
3120
|
+
if (u.current) try {
|
|
3121
|
+
let { toPng: e } = await import("html-to-image"), n = await e(u.current, { backgroundColor: "#ffffff" }), r = document.createElement("a");
|
|
3122
|
+
r.download = `${t.title || "chart"}.png`, r.href = n, r.click();
|
|
3123
|
+
} catch {}
|
|
3124
|
+
}, [t.title]);
|
|
3125
|
+
return c.length ? /* @__PURE__ */ z("div", {
|
|
3126
|
+
className: `bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden ${s}`,
|
|
3127
|
+
children: [/* @__PURE__ */ z("div", {
|
|
3128
|
+
className: "flex items-center justify-between px-4 py-2 border-b border-gray-100 dark:border-gray-800",
|
|
3129
|
+
children: [/* @__PURE__ */ R("span", {
|
|
3130
|
+
className: "text-sm font-medium text-gray-700 dark:text-gray-300 truncate",
|
|
3131
|
+
children: t.title || "Chart"
|
|
3132
|
+
}), /* @__PURE__ */ z("div", {
|
|
3133
|
+
className: "flex items-center gap-1",
|
|
3134
|
+
children: [
|
|
3135
|
+
/* @__PURE__ */ R("button", {
|
|
3136
|
+
type: "button",
|
|
3137
|
+
onClick: f,
|
|
3138
|
+
className: "p-1 text-gray-400 hover:text-gray-600 rounded transition-colors",
|
|
3139
|
+
title: "Export as PNG",
|
|
3140
|
+
children: /* @__PURE__ */ R(x, { className: "h-3.5 w-3.5" })
|
|
3141
|
+
}),
|
|
3142
|
+
o && /* @__PURE__ */ R("button", {
|
|
3143
|
+
type: "button",
|
|
3144
|
+
onClick: o,
|
|
3145
|
+
className: "p-1 text-gray-400 hover:text-brand-600 rounded transition-colors",
|
|
3146
|
+
title: "Edit chart",
|
|
3147
|
+
children: /* @__PURE__ */ R(S, { className: "h-3.5 w-3.5" })
|
|
3148
|
+
}),
|
|
3149
|
+
i && /* @__PURE__ */ R("button", {
|
|
3150
|
+
type: "button",
|
|
3151
|
+
onClick: i,
|
|
3152
|
+
className: "p-1 text-gray-400 hover:text-red-500 rounded transition-colors",
|
|
3153
|
+
title: "Remove chart",
|
|
3154
|
+
children: /* @__PURE__ */ R(I, { className: "h-3.5 w-3.5" })
|
|
3155
|
+
})
|
|
3156
|
+
]
|
|
3157
|
+
})]
|
|
3158
|
+
}), /* @__PURE__ */ R("div", {
|
|
3159
|
+
ref: u,
|
|
3160
|
+
className: "px-2 py-3",
|
|
3161
|
+
children: /* @__PURE__ */ R(ae, {
|
|
3162
|
+
width: "100%",
|
|
3163
|
+
height: d,
|
|
3164
|
+
children: Yt(t, c, l)
|
|
3165
|
+
})
|
|
3166
|
+
})]
|
|
3167
|
+
}) : /* @__PURE__ */ R("div", {
|
|
3168
|
+
className: `flex items-center justify-center h-48 text-sm text-gray-400 border border-dashed border-gray-300 rounded-lg ${s}`,
|
|
3169
|
+
children: "No data to display"
|
|
3170
|
+
});
|
|
3171
|
+
}
|
|
3172
|
+
function Yt(e, t, n) {
|
|
3173
|
+
let r = e.showLegend ?? !0, i = e.showTooltip ?? !0;
|
|
3174
|
+
switch (e.type) {
|
|
3175
|
+
case "bar": return /* @__PURE__ */ z(W, {
|
|
3176
|
+
data: t,
|
|
3177
|
+
children: [
|
|
3178
|
+
/* @__PURE__ */ R(G, {
|
|
3179
|
+
strokeDasharray: "3 3",
|
|
3180
|
+
stroke: "#e5e7eb"
|
|
3181
|
+
}),
|
|
3182
|
+
/* @__PURE__ */ R(se, {
|
|
3183
|
+
dataKey: "label",
|
|
3184
|
+
tick: { fontSize: 12 }
|
|
3185
|
+
}),
|
|
3186
|
+
/* @__PURE__ */ R(Y, { tick: { fontSize: 12 } }),
|
|
3187
|
+
i && /* @__PURE__ */ R(oe, {}),
|
|
3188
|
+
r && /* @__PURE__ */ R(q, {}),
|
|
3189
|
+
n.map((t) => /* @__PURE__ */ R(U, {
|
|
3190
|
+
dataKey: t.key,
|
|
3191
|
+
name: t.name,
|
|
3192
|
+
fill: t.color,
|
|
3193
|
+
stackId: e.stacked ? "stack" : void 0,
|
|
3194
|
+
radius: [
|
|
3195
|
+
2,
|
|
3196
|
+
2,
|
|
3197
|
+
0,
|
|
3198
|
+
0
|
|
3199
|
+
]
|
|
3200
|
+
}, t.key))
|
|
3201
|
+
]
|
|
3202
|
+
});
|
|
3203
|
+
case "line": return /* @__PURE__ */ z(J, {
|
|
3204
|
+
data: t,
|
|
3205
|
+
children: [
|
|
3206
|
+
/* @__PURE__ */ R(G, {
|
|
3207
|
+
strokeDasharray: "3 3",
|
|
3208
|
+
stroke: "#e5e7eb"
|
|
3209
|
+
}),
|
|
3210
|
+
/* @__PURE__ */ R(se, {
|
|
3211
|
+
dataKey: "label",
|
|
3212
|
+
tick: { fontSize: 12 }
|
|
3213
|
+
}),
|
|
3214
|
+
/* @__PURE__ */ R(Y, { tick: { fontSize: 12 } }),
|
|
3215
|
+
i && /* @__PURE__ */ R(oe, {}),
|
|
3216
|
+
r && /* @__PURE__ */ R(q, {}),
|
|
3217
|
+
n.map((e) => /* @__PURE__ */ R(ne, {
|
|
3218
|
+
type: "monotone",
|
|
3219
|
+
dataKey: e.key,
|
|
3220
|
+
name: e.name,
|
|
3221
|
+
stroke: e.color,
|
|
3222
|
+
strokeWidth: 2,
|
|
3223
|
+
dot: { r: 3 },
|
|
3224
|
+
activeDot: { r: 5 }
|
|
3225
|
+
}, e.key))
|
|
3226
|
+
]
|
|
3227
|
+
});
|
|
3228
|
+
case "area": return /* @__PURE__ */ z(H, {
|
|
3229
|
+
data: t,
|
|
3230
|
+
children: [
|
|
3231
|
+
/* @__PURE__ */ R(G, {
|
|
3232
|
+
strokeDasharray: "3 3",
|
|
3233
|
+
stroke: "#e5e7eb"
|
|
3234
|
+
}),
|
|
3235
|
+
/* @__PURE__ */ R(se, {
|
|
3236
|
+
dataKey: "label",
|
|
3237
|
+
tick: { fontSize: 12 }
|
|
3238
|
+
}),
|
|
3239
|
+
/* @__PURE__ */ R(Y, { tick: { fontSize: 12 } }),
|
|
3240
|
+
i && /* @__PURE__ */ R(oe, {}),
|
|
3241
|
+
r && /* @__PURE__ */ R(q, {}),
|
|
3242
|
+
n.map((t) => /* @__PURE__ */ R(V, {
|
|
3243
|
+
type: "monotone",
|
|
3244
|
+
dataKey: t.key,
|
|
3245
|
+
name: t.name,
|
|
3246
|
+
stroke: t.color,
|
|
3247
|
+
fill: t.color,
|
|
3248
|
+
fillOpacity: .15,
|
|
3249
|
+
stackId: e.stacked ? "stack" : void 0
|
|
3250
|
+
}, t.key))
|
|
3251
|
+
]
|
|
3252
|
+
});
|
|
3253
|
+
case "pie": return /* @__PURE__ */ z(ie, { children: [
|
|
3254
|
+
i && /* @__PURE__ */ R(oe, {}),
|
|
3255
|
+
r && /* @__PURE__ */ R(q, {}),
|
|
3256
|
+
/* @__PURE__ */ R(re, {
|
|
3257
|
+
data: t,
|
|
3258
|
+
dataKey: n[0]?.key ?? "value",
|
|
3259
|
+
nameKey: "label",
|
|
3260
|
+
cx: "50%",
|
|
3261
|
+
cy: "50%",
|
|
3262
|
+
outerRadius: "80%",
|
|
3263
|
+
label: ({ name: e, percent: t }) => `${e} ${(t * 100).toFixed(0)}%`,
|
|
3264
|
+
labelLine: !1,
|
|
3265
|
+
children: t.map((t, n) => /* @__PURE__ */ R(K, { fill: e.colors?.[n] ?? Ut[n % Ut.length] }, n))
|
|
3266
|
+
})
|
|
3267
|
+
] });
|
|
3268
|
+
default: return /* @__PURE__ */ z(W, {
|
|
3269
|
+
data: t,
|
|
3270
|
+
children: [
|
|
3271
|
+
/* @__PURE__ */ R(se, { dataKey: "label" }),
|
|
3272
|
+
/* @__PURE__ */ R(Y, {}),
|
|
3273
|
+
n.map((e) => /* @__PURE__ */ R(U, {
|
|
3274
|
+
dataKey: e.key,
|
|
3275
|
+
fill: e.color
|
|
3276
|
+
}, e.key))
|
|
3277
|
+
]
|
|
3278
|
+
});
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
//#endregion
|
|
3282
|
+
//#region src/components/ChartPanel.jsx
|
|
3283
|
+
function Xt({ charts: e, data: t, columns: n, onAddChart: r, onEditChart: i, onRemoveChart: a }) {
|
|
3284
|
+
return e.length ? /* @__PURE__ */ z("div", {
|
|
3285
|
+
className: "border-t border-gray-200 dark:border-gray-700 p-4",
|
|
3286
|
+
children: [/* @__PURE__ */ z("div", {
|
|
3287
|
+
className: "flex items-center justify-between mb-3",
|
|
3288
|
+
children: [/* @__PURE__ */ z("span", {
|
|
3289
|
+
className: "text-xs font-medium text-gray-500 uppercase tracking-wide",
|
|
3290
|
+
children: [
|
|
3291
|
+
"Charts (",
|
|
3292
|
+
e.length,
|
|
3293
|
+
")"
|
|
3294
|
+
]
|
|
3295
|
+
}), /* @__PURE__ */ z("button", {
|
|
3296
|
+
type: "button",
|
|
3297
|
+
onClick: r,
|
|
3298
|
+
className: "inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-brand-600 hover:bg-brand-50 rounded transition-colors",
|
|
3299
|
+
children: [/* @__PURE__ */ R(k, { className: "h-3.5 w-3.5" }), "Add"]
|
|
3300
|
+
})]
|
|
3301
|
+
}), /* @__PURE__ */ R("div", {
|
|
3302
|
+
className: "grid grid-cols-1 md:grid-cols-2 gap-4",
|
|
3303
|
+
children: e.map((e) => /* @__PURE__ */ R(Jt, {
|
|
3304
|
+
data: t,
|
|
3305
|
+
config: e.config,
|
|
3306
|
+
columns: n,
|
|
3307
|
+
onEdit: () => i(e.id),
|
|
3308
|
+
onRemove: () => a(e.id)
|
|
3309
|
+
}, e.id))
|
|
3310
|
+
})]
|
|
3311
|
+
}) : /* @__PURE__ */ R("div", {
|
|
3312
|
+
className: "border-t border-gray-200 dark:border-gray-700 px-4 py-6",
|
|
3313
|
+
children: /* @__PURE__ */ z("div", {
|
|
3314
|
+
className: "flex flex-col items-center justify-center text-center",
|
|
3315
|
+
children: [
|
|
3316
|
+
/* @__PURE__ */ R(f, { className: "h-8 w-8 text-gray-300 mb-2" }),
|
|
3317
|
+
/* @__PURE__ */ R("p", {
|
|
3318
|
+
className: "text-sm text-gray-400 mb-3",
|
|
3319
|
+
children: "No charts yet"
|
|
3320
|
+
}),
|
|
3321
|
+
/* @__PURE__ */ z("button", {
|
|
3322
|
+
type: "button",
|
|
3323
|
+
onClick: r,
|
|
3324
|
+
className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-brand-600 bg-brand-50 rounded-lg hover:bg-brand-100 transition-colors",
|
|
3325
|
+
children: [/* @__PURE__ */ R(k, { className: "h-4 w-4" }), "Create Chart"]
|
|
3326
|
+
})
|
|
3327
|
+
]
|
|
3328
|
+
})
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
//#endregion
|
|
3332
|
+
//#region src/components/ChartBuilderModal.jsx
|
|
3333
|
+
var Zt = [
|
|
3334
|
+
{
|
|
3335
|
+
type: "bar",
|
|
3336
|
+
label: "Bar",
|
|
3337
|
+
icon: /* @__PURE__ */ R(f, { className: "h-5 w-5" })
|
|
3338
|
+
},
|
|
3339
|
+
{
|
|
3340
|
+
type: "line",
|
|
3341
|
+
label: "Line",
|
|
3342
|
+
icon: /* @__PURE__ */ R(E, { className: "h-5 w-5" })
|
|
3343
|
+
},
|
|
3344
|
+
{
|
|
3345
|
+
type: "area",
|
|
3346
|
+
label: "Area",
|
|
3347
|
+
icon: /* @__PURE__ */ R(c, { className: "h-5 w-5" })
|
|
3348
|
+
},
|
|
3349
|
+
{
|
|
3350
|
+
type: "pie",
|
|
3351
|
+
label: "Pie",
|
|
3352
|
+
icon: /* @__PURE__ */ R(ee, { className: "h-5 w-5" })
|
|
3353
|
+
}
|
|
3354
|
+
], Qt = [
|
|
3355
|
+
{
|
|
3356
|
+
value: "",
|
|
3357
|
+
label: "None"
|
|
3358
|
+
},
|
|
3359
|
+
{
|
|
3360
|
+
value: "sum",
|
|
3361
|
+
label: "Sum"
|
|
3362
|
+
},
|
|
3363
|
+
{
|
|
3364
|
+
value: "avg",
|
|
3365
|
+
label: "Average"
|
|
3366
|
+
},
|
|
3367
|
+
{
|
|
3368
|
+
value: "count",
|
|
3369
|
+
label: "Count"
|
|
3370
|
+
},
|
|
3371
|
+
{
|
|
3372
|
+
value: "min",
|
|
3373
|
+
label: "Min"
|
|
3374
|
+
},
|
|
3375
|
+
{
|
|
3376
|
+
value: "max",
|
|
3377
|
+
label: "Max"
|
|
3378
|
+
}
|
|
3379
|
+
];
|
|
3380
|
+
function $t({ open: e, onClose: t, onSave: a, onUpdate: s, columns: c, data: l, editingChart: u }) {
|
|
3381
|
+
let [d, f] = o("bar"), [p, m] = o(""), [h, g] = o(""), [_, v] = o([]), [y, b] = o(""), [x, S] = o(""), [C, w] = o(!0), [T, E] = o(!0), [D, O] = o(!1);
|
|
3382
|
+
r(() => {
|
|
3383
|
+
if (u) {
|
|
3384
|
+
let e = u.config;
|
|
3385
|
+
f(e.type), m(e.title ?? ""), g(e.labelColumn), v(e.dataColumns), b(e.groupBy ?? ""), S(e.aggregation ?? ""), w(e.showLegend ?? !0), E(e.showTooltip ?? !0), O(e.stacked ?? !1);
|
|
3386
|
+
} else e && (f("bar"), m(""), g(""), v([]), b(""), S(""), w(!0), E(!0), O(!1));
|
|
3387
|
+
}, [u, e]);
|
|
3388
|
+
let ee = i(() => ({
|
|
3389
|
+
type: d,
|
|
3390
|
+
title: p || "Preview",
|
|
3391
|
+
labelColumn: h,
|
|
3392
|
+
dataColumns: _,
|
|
3393
|
+
groupBy: y || void 0,
|
|
3394
|
+
aggregation: x || void 0,
|
|
3395
|
+
showLegend: C,
|
|
3396
|
+
showTooltip: T,
|
|
3397
|
+
stacked: D,
|
|
3398
|
+
height: 240
|
|
3399
|
+
}), [
|
|
3400
|
+
d,
|
|
3401
|
+
p,
|
|
3402
|
+
h,
|
|
3403
|
+
_,
|
|
3404
|
+
y,
|
|
3405
|
+
x,
|
|
3406
|
+
C,
|
|
3407
|
+
T,
|
|
3408
|
+
D
|
|
3409
|
+
]), k = h && _.length > 0, A = n(() => {
|
|
3410
|
+
if (!k) return;
|
|
3411
|
+
let e = {
|
|
3412
|
+
type: d,
|
|
3413
|
+
title: p || void 0,
|
|
3414
|
+
labelColumn: h,
|
|
3415
|
+
dataColumns: _,
|
|
3416
|
+
groupBy: y || void 0,
|
|
3417
|
+
aggregation: x || void 0,
|
|
3418
|
+
showLegend: C,
|
|
3419
|
+
showTooltip: T,
|
|
3420
|
+
stacked: D
|
|
3421
|
+
};
|
|
3422
|
+
u && s ? s(u.id, e) : a(e), t();
|
|
3423
|
+
}, [
|
|
3424
|
+
k,
|
|
3425
|
+
d,
|
|
3426
|
+
p,
|
|
3427
|
+
h,
|
|
3428
|
+
_,
|
|
3429
|
+
y,
|
|
3430
|
+
x,
|
|
3431
|
+
C,
|
|
3432
|
+
T,
|
|
3433
|
+
D,
|
|
3434
|
+
u,
|
|
3435
|
+
s,
|
|
3436
|
+
a,
|
|
3437
|
+
t
|
|
3438
|
+
]), j = (e) => {
|
|
3439
|
+
v((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
|
|
3440
|
+
};
|
|
3441
|
+
if (!e) return null;
|
|
3442
|
+
let M = "w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-brand-500 bg-white dark:bg-gray-800";
|
|
3443
|
+
return /* @__PURE__ */ z("div", {
|
|
3444
|
+
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
3445
|
+
children: [/* @__PURE__ */ R("div", {
|
|
3446
|
+
className: "absolute inset-0 bg-black/40",
|
|
3447
|
+
onClick: t
|
|
3448
|
+
}), /* @__PURE__ */ z("div", {
|
|
3449
|
+
className: "relative bg-white dark:bg-gray-900 rounded-xl shadow-2xl w-full max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",
|
|
3450
|
+
children: [
|
|
3451
|
+
/* @__PURE__ */ z("div", {
|
|
3452
|
+
className: "flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",
|
|
3453
|
+
children: [/* @__PURE__ */ R("h2", {
|
|
3454
|
+
className: "text-lg font-semibold text-gray-900 dark:text-gray-100",
|
|
3455
|
+
children: u ? "Edit Chart" : "Create Chart"
|
|
3456
|
+
}), /* @__PURE__ */ R("button", {
|
|
3457
|
+
type: "button",
|
|
3458
|
+
onClick: t,
|
|
3459
|
+
className: "p-1 text-gray-400 hover:text-gray-600 rounded",
|
|
3460
|
+
children: /* @__PURE__ */ R(I, { className: "h-5 w-5" })
|
|
3461
|
+
})]
|
|
3462
|
+
}),
|
|
3463
|
+
/* @__PURE__ */ R("div", {
|
|
3464
|
+
className: "flex-1 overflow-y-auto p-6",
|
|
3465
|
+
children: /* @__PURE__ */ z("div", {
|
|
3466
|
+
className: "grid grid-cols-1 lg:grid-cols-2 gap-6",
|
|
3467
|
+
children: [/* @__PURE__ */ z("div", {
|
|
3468
|
+
className: "space-y-4",
|
|
3469
|
+
children: [
|
|
3470
|
+
/* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("label", {
|
|
3471
|
+
className: "block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",
|
|
3472
|
+
children: "Chart Type"
|
|
3473
|
+
}), /* @__PURE__ */ R("div", {
|
|
3474
|
+
className: "flex gap-2",
|
|
3475
|
+
children: Zt.map((e) => /* @__PURE__ */ z("button", {
|
|
3476
|
+
type: "button",
|
|
3477
|
+
onClick: () => f(e.type),
|
|
3478
|
+
className: `flex flex-col items-center gap-1 px-4 py-2.5 rounded-lg border-2 transition-colors ${d === e.type ? "border-brand-500 bg-brand-50 text-brand-700" : "border-gray-200 text-gray-500 hover:border-gray-300"}`,
|
|
3479
|
+
children: [e.icon, /* @__PURE__ */ R("span", {
|
|
3480
|
+
className: "text-xs font-medium",
|
|
3481
|
+
children: e.label
|
|
3482
|
+
})]
|
|
3483
|
+
}, e.type))
|
|
3484
|
+
})] }),
|
|
3485
|
+
/* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("label", {
|
|
3486
|
+
className: "block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1",
|
|
3487
|
+
children: "Title"
|
|
3488
|
+
}), /* @__PURE__ */ R("input", {
|
|
3489
|
+
type: "text",
|
|
3490
|
+
value: p,
|
|
3491
|
+
onChange: (e) => m(e.target.value),
|
|
3492
|
+
placeholder: "Chart title...",
|
|
3493
|
+
className: "w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-brand-500 bg-white dark:bg-gray-800"
|
|
3494
|
+
})] }),
|
|
3495
|
+
/* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("label", {
|
|
3496
|
+
className: "block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1",
|
|
3497
|
+
children: d === "pie" ? "Label Column" : "X-Axis Column"
|
|
3498
|
+
}), /* @__PURE__ */ z("select", {
|
|
3499
|
+
value: h,
|
|
3500
|
+
onChange: (e) => g(e.target.value),
|
|
3501
|
+
className: M,
|
|
3502
|
+
children: [/* @__PURE__ */ R("option", {
|
|
3503
|
+
value: "",
|
|
3504
|
+
children: "Select column..."
|
|
3505
|
+
}), c.map((e) => /* @__PURE__ */ R("option", {
|
|
3506
|
+
value: e.id,
|
|
3507
|
+
children: e.header
|
|
3508
|
+
}, e.id))]
|
|
3509
|
+
})] }),
|
|
3510
|
+
/* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("label", {
|
|
3511
|
+
className: "block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1",
|
|
3512
|
+
children: d === "pie" ? "Value Column" : "Y-Axis Columns"
|
|
3513
|
+
}), /* @__PURE__ */ R("div", {
|
|
3514
|
+
className: "flex flex-wrap gap-1.5 p-2 border border-gray-300 rounded-lg min-h-[40px] bg-white dark:bg-gray-800",
|
|
3515
|
+
children: c.map((e) => /* @__PURE__ */ R("button", {
|
|
3516
|
+
type: "button",
|
|
3517
|
+
onClick: () => j(e.id),
|
|
3518
|
+
className: `px-2.5 py-1 text-xs rounded-md transition-colors ${_.includes(e.id) ? "bg-brand-100 text-brand-700 font-medium" : "bg-gray-100 text-gray-600 hover:bg-gray-200"}`,
|
|
3519
|
+
children: e.header
|
|
3520
|
+
}, e.id))
|
|
3521
|
+
})] }),
|
|
3522
|
+
/* @__PURE__ */ z("div", {
|
|
3523
|
+
className: "grid grid-cols-2 gap-3",
|
|
3524
|
+
children: [/* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("label", {
|
|
3525
|
+
className: "block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1",
|
|
3526
|
+
children: "Group By"
|
|
3527
|
+
}), /* @__PURE__ */ z("select", {
|
|
3528
|
+
value: y,
|
|
3529
|
+
onChange: (e) => b(e.target.value),
|
|
3530
|
+
className: M,
|
|
3531
|
+
children: [/* @__PURE__ */ R("option", {
|
|
3532
|
+
value: "",
|
|
3533
|
+
children: "None"
|
|
3534
|
+
}), c.map((e) => /* @__PURE__ */ R("option", {
|
|
3535
|
+
value: e.id,
|
|
3536
|
+
children: e.header
|
|
3537
|
+
}, e.id))]
|
|
3538
|
+
})] }), /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("label", {
|
|
3539
|
+
className: "block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1",
|
|
3540
|
+
children: "Aggregation"
|
|
3541
|
+
}), /* @__PURE__ */ R("select", {
|
|
3542
|
+
value: x,
|
|
3543
|
+
onChange: (e) => S(e.target.value),
|
|
3544
|
+
className: M,
|
|
3545
|
+
children: Qt.map((e) => /* @__PURE__ */ R("option", {
|
|
3546
|
+
value: e.value,
|
|
3547
|
+
children: e.label
|
|
3548
|
+
}, e.value))
|
|
3549
|
+
})] })]
|
|
3550
|
+
}),
|
|
3551
|
+
/* @__PURE__ */ z("div", {
|
|
3552
|
+
className: "flex flex-wrap gap-4",
|
|
3553
|
+
children: [
|
|
3554
|
+
/* @__PURE__ */ R(en, {
|
|
3555
|
+
label: "Legend",
|
|
3556
|
+
checked: C,
|
|
3557
|
+
onChange: w
|
|
3558
|
+
}),
|
|
3559
|
+
/* @__PURE__ */ R(en, {
|
|
3560
|
+
label: "Tooltip",
|
|
3561
|
+
checked: T,
|
|
3562
|
+
onChange: E
|
|
3563
|
+
}),
|
|
3564
|
+
(d === "bar" || d === "area") && /* @__PURE__ */ R(en, {
|
|
3565
|
+
label: "Stacked",
|
|
3566
|
+
checked: D,
|
|
3567
|
+
onChange: O
|
|
3568
|
+
})
|
|
3569
|
+
]
|
|
3570
|
+
})
|
|
3571
|
+
]
|
|
3572
|
+
}), /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("label", {
|
|
3573
|
+
className: "block text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",
|
|
3574
|
+
children: "Live Preview"
|
|
3575
|
+
}), /* @__PURE__ */ R(Jt, {
|
|
3576
|
+
data: l,
|
|
3577
|
+
config: ee,
|
|
3578
|
+
columns: c
|
|
3579
|
+
})] })]
|
|
3580
|
+
})
|
|
3581
|
+
}),
|
|
3582
|
+
/* @__PURE__ */ z("div", {
|
|
3583
|
+
className: "flex items-center justify-end gap-3 px-6 py-4 border-t border-gray-200 dark:border-gray-700",
|
|
3584
|
+
children: [/* @__PURE__ */ R("button", {
|
|
3585
|
+
type: "button",
|
|
3586
|
+
onClick: t,
|
|
3587
|
+
className: "px-4 py-2 text-sm text-gray-600 hover:text-gray-800 rounded-lg transition-colors",
|
|
3588
|
+
children: "Cancel"
|
|
3589
|
+
}), /* @__PURE__ */ R("button", {
|
|
3590
|
+
type: "button",
|
|
3591
|
+
onClick: A,
|
|
3592
|
+
disabled: !k,
|
|
3593
|
+
className: "px-4 py-2 text-sm font-medium text-white bg-brand-600 rounded-lg hover:bg-brand-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
|
|
3594
|
+
children: u ? "Update Chart" : "Create Chart"
|
|
3595
|
+
})]
|
|
3596
|
+
})
|
|
3597
|
+
]
|
|
3598
|
+
})]
|
|
3599
|
+
});
|
|
3600
|
+
}
|
|
3601
|
+
function en({ label: e, checked: t, onChange: n }) {
|
|
3602
|
+
return /* @__PURE__ */ z("label", {
|
|
3603
|
+
className: "flex items-center gap-2 cursor-pointer select-none",
|
|
3604
|
+
children: [/* @__PURE__ */ R("input", {
|
|
3605
|
+
type: "checkbox",
|
|
3606
|
+
checked: t,
|
|
3607
|
+
onChange: (e) => n(e.target.checked),
|
|
3608
|
+
className: "h-4 w-4 rounded border-gray-300 text-brand-600 focus:ring-brand-500"
|
|
3609
|
+
}), /* @__PURE__ */ R("span", {
|
|
3610
|
+
className: "text-sm text-gray-600",
|
|
3611
|
+
children: e
|
|
3612
|
+
})]
|
|
3613
|
+
});
|
|
3614
|
+
}
|
|
3615
|
+
//#endregion
|
|
3616
|
+
//#region src/components/DataTable.jsx
|
|
3617
|
+
function tn(e) {
|
|
3618
|
+
let { loading: t = !1, error: r = null, onRetry: a, bulkActions: c, exportFormats: l, onExport: u, views: d = ["table"], theme: f, emptyText: p = "No data found", emptyIcon: m = b, className: h = "", filtering: g, columnVisibility: _ = !1, plugins: v = [], ariaLabel: y, ariaDescribedBy: x, sidebarPanels: S, contextMenu: C, persistKey: w, statusBar: T } = e, E = tt(e), { processedData: D, allFilteredData: O, sorting: ee, filtering: k, pagination: j, selection: M, columnManager: N, viewMode: P, setViewMode: te, presets: F, getCurrentPresetConfig: I, applyPreset: B, theme: V, chartConfig: H } = E, [U, W] = o(null), [G, K] = o(null), q = n((e, t) => {
|
|
3619
|
+
C?.length && (e.preventDefault(), K({
|
|
3620
|
+
x: e.clientX,
|
|
3621
|
+
y: e.clientY,
|
|
3622
|
+
row: t
|
|
3623
|
+
}));
|
|
3624
|
+
}, [C]), ne = i(() => (e) => {
|
|
3625
|
+
if (u) {
|
|
3626
|
+
u(e, O);
|
|
3627
|
+
return;
|
|
3628
|
+
}
|
|
3629
|
+
let t = N.visibleColumns;
|
|
3630
|
+
switch (e) {
|
|
3631
|
+
case "csv":
|
|
3632
|
+
at(O, t);
|
|
3633
|
+
break;
|
|
3634
|
+
case "excel":
|
|
3635
|
+
ot(O, t);
|
|
3636
|
+
break;
|
|
3637
|
+
default: ge(e, O, t, u);
|
|
3638
|
+
}
|
|
3639
|
+
}, [
|
|
3640
|
+
O,
|
|
3641
|
+
N.visibleColumns,
|
|
3642
|
+
u
|
|
3643
|
+
]), J = i(() => v.map((e) => e.renderToolbar?.(E.state)).filter(Boolean), [v, E.state]), re = i(() => v.map((e) => e.renderFooter?.(E.state)).filter(Boolean), [v, E.state]), ie = k.filters.length > 0 || k.globalSearch.length > 0, ae = V.cssVarStyle ?? {};
|
|
3644
|
+
return /* @__PURE__ */ z("div", {
|
|
3645
|
+
className: `bg-[var(--dt-bg,var(--app-bg,white))] border border-[var(--dt-border,var(--app-border,#e5e7eb))] rounded-lg shadow-sm overflow-hidden flex ${f?.wrapper ?? ""} ${h}`,
|
|
3646
|
+
style: ae,
|
|
3647
|
+
role: "region",
|
|
3648
|
+
"aria-label": y ?? "Data table",
|
|
3649
|
+
"aria-describedby": x,
|
|
3650
|
+
children: [
|
|
3651
|
+
/* @__PURE__ */ z("div", {
|
|
3652
|
+
className: "flex-1 flex flex-col min-w-0 overflow-hidden",
|
|
3653
|
+
children: [
|
|
3654
|
+
/* @__PURE__ */ R(st, {
|
|
3655
|
+
globalSearch: k.globalSearch,
|
|
3656
|
+
onSearchChange: k.setGlobalSearch,
|
|
3657
|
+
searchDebounce: g?.searchDebounce,
|
|
3658
|
+
viewMode: P,
|
|
3659
|
+
onViewModeChange: te,
|
|
3660
|
+
views: d,
|
|
3661
|
+
exportFormats: l,
|
|
3662
|
+
onExport: ne,
|
|
3663
|
+
columns: N.allColumns,
|
|
3664
|
+
hiddenColumns: N.hiddenColumns,
|
|
3665
|
+
onToggleColumn: N.toggleColumnVisibility,
|
|
3666
|
+
enableColumnVisibility: _,
|
|
3667
|
+
hasActiveFilters: ie,
|
|
3668
|
+
onClearFilters: k.clearFilters,
|
|
3669
|
+
pluginToolbar: /* @__PURE__ */ z(L, { children: [
|
|
3670
|
+
J,
|
|
3671
|
+
w && /* @__PURE__ */ R(Bt, {
|
|
3672
|
+
presets: F.presets,
|
|
3673
|
+
onSave: F.savePreset,
|
|
3674
|
+
onLoad: B,
|
|
3675
|
+
onDelete: F.deletePreset,
|
|
3676
|
+
onRename: F.renamePreset,
|
|
3677
|
+
getCurrentConfig: I
|
|
3678
|
+
}),
|
|
3679
|
+
S?.map((e) => /* @__PURE__ */ R("button", {
|
|
3680
|
+
type: "button",
|
|
3681
|
+
onClick: () => W(U === e.type ? null : e.type),
|
|
3682
|
+
className: `p-2 rounded-md transition-colors ${U === e.type ? "bg-brand-100 text-brand-700" : "text-gray-500 hover:text-gray-700 hover:bg-gray-100"}`,
|
|
3683
|
+
title: e.title,
|
|
3684
|
+
"aria-label": e.title,
|
|
3685
|
+
"aria-pressed": U === e.type,
|
|
3686
|
+
children: e.icon
|
|
3687
|
+
}, e.type))
|
|
3688
|
+
] }),
|
|
3689
|
+
className: f?.toolbar
|
|
3690
|
+
}),
|
|
3691
|
+
c && c.length > 0 && /* @__PURE__ */ R(lt, {
|
|
3692
|
+
selectedCount: M.selectedKeys.length,
|
|
3693
|
+
selectedRows: M.selectedRows,
|
|
3694
|
+
actions: c,
|
|
3695
|
+
onClearSelection: M.clearSelection
|
|
3696
|
+
}),
|
|
3697
|
+
r && /* @__PURE__ */ z("div", {
|
|
3698
|
+
className: "flex flex-col items-center justify-center py-16 px-6",
|
|
3699
|
+
children: [
|
|
3700
|
+
/* @__PURE__ */ R(s, { className: "h-12 w-12 text-red-400 mb-4" }),
|
|
3701
|
+
/* @__PURE__ */ R("p", {
|
|
3702
|
+
className: "text-sm text-red-600 mb-4",
|
|
3703
|
+
children: r
|
|
3704
|
+
}),
|
|
3705
|
+
a && /* @__PURE__ */ z("button", {
|
|
3706
|
+
type: "button",
|
|
3707
|
+
onClick: a,
|
|
3708
|
+
className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-brand-600 rounded-md hover:bg-brand-700 transition-colors",
|
|
3709
|
+
children: [/* @__PURE__ */ R(A, { className: "h-4 w-4" }), "Retry"]
|
|
3710
|
+
})
|
|
3711
|
+
]
|
|
3712
|
+
}),
|
|
3713
|
+
!r && t && /* @__PURE__ */ R("div", {
|
|
3714
|
+
className: "p-4",
|
|
3715
|
+
children: /* @__PURE__ */ R(nn, {
|
|
3716
|
+
rows: j.pageSize,
|
|
3717
|
+
columns: N.visibleColumns.length
|
|
3718
|
+
})
|
|
3719
|
+
}),
|
|
3720
|
+
!r && !t && D.length === 0 && /* @__PURE__ */ z("div", {
|
|
3721
|
+
className: "flex flex-col items-center justify-center py-16 px-6",
|
|
3722
|
+
children: [
|
|
3723
|
+
/* @__PURE__ */ R("div", {
|
|
3724
|
+
className: "w-14 h-14 rounded-full bg-gray-100 dark:bg-gray-800 flex items-center justify-center mb-4",
|
|
3725
|
+
children: /* @__PURE__ */ R(m, { className: "h-7 w-7 text-gray-400" })
|
|
3726
|
+
}),
|
|
3727
|
+
/* @__PURE__ */ R("p", {
|
|
3728
|
+
className: "text-sm text-gray-500",
|
|
3729
|
+
children: p
|
|
3730
|
+
}),
|
|
3731
|
+
ie && /* @__PURE__ */ R("button", {
|
|
3732
|
+
type: "button",
|
|
3733
|
+
onClick: k.clearFilters,
|
|
3734
|
+
className: "mt-3 text-sm text-brand-600 hover:text-brand-700 underline",
|
|
3735
|
+
children: "Clear all filters"
|
|
3736
|
+
})
|
|
3737
|
+
]
|
|
3738
|
+
}),
|
|
3739
|
+
!r && !t && D.length > 0 && /* @__PURE__ */ z(L, { children: [
|
|
3740
|
+
P === "table" && /* @__PURE__ */ R(Mt, {
|
|
3741
|
+
table: E,
|
|
3742
|
+
props: e,
|
|
3743
|
+
onContextMenu: q
|
|
3744
|
+
}),
|
|
3745
|
+
P === "grid" && /* @__PURE__ */ R(Nt, {
|
|
3746
|
+
table: E,
|
|
3747
|
+
props: e
|
|
3748
|
+
}),
|
|
3749
|
+
P === "list" && /* @__PURE__ */ R(Pt, {
|
|
3750
|
+
table: E,
|
|
3751
|
+
props: e
|
|
3752
|
+
})
|
|
3753
|
+
] }),
|
|
3754
|
+
T?.position === "top" && /* @__PURE__ */ R(Ht, {
|
|
3755
|
+
config: T,
|
|
3756
|
+
data: O,
|
|
3757
|
+
state: E.state
|
|
3758
|
+
}),
|
|
3759
|
+
!r && !j.isInfinite && D.length > 0 && /* @__PURE__ */ R(Ft, {
|
|
3760
|
+
page: j.page,
|
|
3761
|
+
pageSize: j.pageSize,
|
|
3762
|
+
totalPages: j.totalPages,
|
|
3763
|
+
totalItems: j.totalItems,
|
|
3764
|
+
pageSizeOptions: j.pageSizeOptions,
|
|
3765
|
+
onPageChange: j.setPage,
|
|
3766
|
+
onPageSizeChange: j.setPageSize
|
|
3767
|
+
}),
|
|
3768
|
+
T && T.position !== "top" && /* @__PURE__ */ R(Ht, {
|
|
3769
|
+
config: T,
|
|
3770
|
+
data: O,
|
|
3771
|
+
state: E.state
|
|
3772
|
+
}),
|
|
3773
|
+
re.length > 0 && /* @__PURE__ */ R("div", {
|
|
3774
|
+
className: "border-t border-[var(--app-border,#e5e7eb)]",
|
|
3775
|
+
children: re
|
|
3776
|
+
}),
|
|
3777
|
+
w && /* @__PURE__ */ R(Xt, {
|
|
3778
|
+
charts: H.charts,
|
|
3779
|
+
data: O,
|
|
3780
|
+
columns: N.allColumns,
|
|
3781
|
+
onAddChart: () => H.openBuilder(),
|
|
3782
|
+
onEditChart: (e) => H.openBuilder(e),
|
|
3783
|
+
onRemoveChart: H.removeChart
|
|
3784
|
+
})
|
|
3785
|
+
]
|
|
3786
|
+
}),
|
|
3787
|
+
S && U && /* @__PURE__ */ R(Lt, {
|
|
3788
|
+
panels: S,
|
|
3789
|
+
activePanel: U,
|
|
3790
|
+
onClose: () => W(null),
|
|
3791
|
+
columns: N.allColumns,
|
|
3792
|
+
hiddenColumns: N.hiddenColumns,
|
|
3793
|
+
columnOrder: N.columnOrder,
|
|
3794
|
+
onToggleColumn: N.toggleColumnVisibility,
|
|
3795
|
+
onReorderColumns: N.reorderColumnsById,
|
|
3796
|
+
filters: k.filters,
|
|
3797
|
+
onFilterChange: k.setFilter,
|
|
3798
|
+
onClearFilters: k.clearFilters
|
|
3799
|
+
}),
|
|
3800
|
+
G && C && /* @__PURE__ */ R(Vt, {
|
|
3801
|
+
x: G.x,
|
|
3802
|
+
y: G.y,
|
|
3803
|
+
row: G.row,
|
|
3804
|
+
items: C,
|
|
3805
|
+
onClose: () => K(null)
|
|
3806
|
+
}),
|
|
3807
|
+
w && /* @__PURE__ */ R($t, {
|
|
3808
|
+
open: H.builderOpen,
|
|
3809
|
+
onClose: H.closeBuilder,
|
|
3810
|
+
onSave: H.addChart,
|
|
3811
|
+
onUpdate: H.updateChart,
|
|
3812
|
+
columns: N.allColumns,
|
|
3813
|
+
data: O,
|
|
3814
|
+
editingChart: H.editingChart
|
|
3815
|
+
})
|
|
3816
|
+
]
|
|
3817
|
+
});
|
|
3818
|
+
}
|
|
3819
|
+
function nn({ rows: e, columns: t }) {
|
|
3820
|
+
return /* @__PURE__ */ z("div", {
|
|
3821
|
+
className: "space-y-3",
|
|
3822
|
+
role: "status",
|
|
3823
|
+
"aria-label": "Loading data",
|
|
3824
|
+
children: [
|
|
3825
|
+
/* @__PURE__ */ R("div", {
|
|
3826
|
+
className: "flex gap-4 px-2",
|
|
3827
|
+
children: Array.from({ length: Math.min(t, 6) }).map((e, t) => /* @__PURE__ */ R("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse flex-1" }, t))
|
|
3828
|
+
}),
|
|
3829
|
+
Array.from({ length: Math.min(e, 8) }).map((e, n) => /* @__PURE__ */ R("div", {
|
|
3830
|
+
className: "flex gap-4 px-2",
|
|
3831
|
+
children: Array.from({ length: Math.min(t, 6) }).map((e, t) => /* @__PURE__ */ R("div", {
|
|
3832
|
+
className: "h-8 bg-gray-100 dark:bg-gray-800 rounded animate-pulse flex-1",
|
|
3833
|
+
style: { animationDelay: `${n * 50 + t * 25}ms` }
|
|
3834
|
+
}, t))
|
|
3835
|
+
}, n)),
|
|
3836
|
+
/* @__PURE__ */ R("span", {
|
|
3837
|
+
className: "sr-only",
|
|
3838
|
+
children: "Loading..."
|
|
3839
|
+
})
|
|
3840
|
+
]
|
|
3841
|
+
});
|
|
3842
|
+
}
|
|
3843
|
+
//#endregion
|
|
3844
|
+
//#region src/plugins.js
|
|
3845
|
+
function rn() {
|
|
3846
|
+
return { name: "row-number" };
|
|
3847
|
+
}
|
|
3848
|
+
function an(e, t) {
|
|
3849
|
+
return {
|
|
3850
|
+
name: "grouping",
|
|
3851
|
+
processData: (t, n) => {
|
|
3852
|
+
let r = $(t, e), i = [];
|
|
3853
|
+
return r.forEach((e) => {
|
|
3854
|
+
i.push(...e);
|
|
3855
|
+
}), i;
|
|
3856
|
+
}
|
|
3857
|
+
};
|
|
3858
|
+
}
|
|
3859
|
+
function on() {
|
|
3860
|
+
return {
|
|
3861
|
+
name: "selection-summary",
|
|
3862
|
+
renderFooter: (t) => t.selectedKeys.length === 0 ? null : e.createElement("div", { className: "px-4 py-2 text-sm text-gray-500" }, `${t.selectedKeys.length} of ${t.totalItems} row(s) selected`)
|
|
3863
|
+
};
|
|
3864
|
+
}
|
|
3865
|
+
function sn(e, t) {
|
|
3866
|
+
return {
|
|
3867
|
+
name: e,
|
|
3868
|
+
processData: (e) => t(e)
|
|
3869
|
+
};
|
|
3870
|
+
}
|
|
3871
|
+
//#endregion
|
|
3872
|
+
export { lt as BulkActions, xt as CellTooltip, $t as ChartBuilderModal, Xt as ChartPanel, ut as ColumnFilter, Vt as ContextMenu, Jt as DataChart, tn as DataTable, wt as DataTableCell, vt as DataTableHeader, Ft as DataTablePagination, kt as DataTableRow, pt as FloatingFilterRow, Nt as GridView, jt as GroupRowComponent, Pt as ListView, Dt as PortalDropdown, Bt as PresetManager, Lt as SidebarPanel, Ht as StatusBar, Mt as TableView, st as Toolbar, Ve as alpineTheme, He as builtInThemes, an as createGroupingPlugin, rn as createRowNumberPlugin, on as createSelectionSummaryPlugin, Ue as createTheme, sn as createTransformPlugin, ze as darkTheme, at as exportToCSV, pe as exportToCSVLegacy, ot as exportToExcel, me as exportToJSON, de as filterData, Z as getCellValue, X as getNestedValue, ce as getRowKey, $ as groupData, ge as handleExport, Re as lightTheme, Q as paginateData, Be as quartzTheme, _e as reorderArray, le as sortData, et as useChartConfig, qt as useChartData, Ce as useColumnManager, tt as useDataTable, Xe as useEditing, be as useFilters, xe as usePagination, we as usePersistence, ke as usePresets, Je as useRowGrouping, Se as useSelection, ye as useSorting, Ge as useTheme, Ye as useTreeData, Ke as useVirtualization };
|
|
3873
|
+
|
|
3874
|
+
//# sourceMappingURL=index.js.map
|