yk-grid 0.1.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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +355 -0
  3. package/dist/server.cjs +88 -0
  4. package/dist/server.mjs +3144 -0
  5. package/dist/types/DataGrid.d.ts +5 -0
  6. package/dist/types/ai/aiClient.d.ts +3 -0
  7. package/dist/types/ai/applyCommand.d.ts +3 -0
  8. package/dist/types/ai/schema.d.ts +28 -0
  9. package/dist/types/index.d.ts +2 -0
  10. package/dist/types/server/gridAiRoute.d.ts +47 -0
  11. package/dist/types/server/index.d.ts +1 -0
  12. package/dist/types/server/providers/anthropic.d.ts +7 -0
  13. package/dist/types/server/providers/openai.d.ts +7 -0
  14. package/dist/types/server/providers/types.d.ts +3 -0
  15. package/dist/types/server/schema.d.ts +28 -0
  16. package/dist/types/state/aggregations.d.ts +2 -0
  17. package/dist/types/state/exportCsv.d.ts +3 -0
  18. package/dist/types/state/gridReducer.d.ts +43 -0
  19. package/dist/types/state/paginate.d.ts +3 -0
  20. package/dist/types/state/processRows.d.ts +5 -0
  21. package/dist/types/state/selection.d.ts +1 -0
  22. package/dist/types/state/useGridState.d.ts +8 -0
  23. package/dist/types/types.d.ts +106 -0
  24. package/dist/types/ui/AiBar.d.ts +13 -0
  25. package/dist/types/ui/Cell.d.ts +13 -0
  26. package/dist/types/ui/ColumnMenu.d.ts +10 -0
  27. package/dist/types/ui/FilterPanel.d.ts +11 -0
  28. package/dist/types/ui/GroupRow.d.ts +9 -0
  29. package/dist/types/ui/HeaderCell.d.ts +21 -0
  30. package/dist/types/ui/NumberFilter.d.ts +9 -0
  31. package/dist/types/ui/Pagination.d.ts +10 -0
  32. package/dist/types/ui/Row.d.ts +20 -0
  33. package/dist/types/ui/SelectionCell.d.ts +10 -0
  34. package/dist/types/ui/Toolbar.d.ts +21 -0
  35. package/dist/yk-grid.cjs.js +8 -0
  36. package/dist/yk-grid.css +2 -0
  37. package/dist/yk-grid.es.js +1973 -0
  38. package/package.json +90 -0
@@ -0,0 +1,1973 @@
1
+ import e, { forwardRef as t, useCallback as n, useEffect as r, useId as i, useImperativeHandle as a, useMemo as o, useReducer as s, useRef as c, useState as l } from "react";
2
+ import { useVirtualizer as u } from "@tanstack/react-virtual";
3
+ import { createPortal as d } from "react-dom";
4
+ import { z as f } from "zod";
5
+ //#region \0rolldown/runtime.js
6
+ var p = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), m = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
7
+ if (typeof require < "u") return require.apply(this, arguments);
8
+ throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
9
+ });
10
+ //#endregion
11
+ //#region src/components/DataGrid/state/gridReducer.ts
12
+ function h(e, t) {
13
+ switch (t.type) {
14
+ case "SET_SORT": return {
15
+ ...e,
16
+ sorts: t.sorts
17
+ };
18
+ case "SET_FILTER": return {
19
+ ...e,
20
+ filters: t.filters,
21
+ pagination: {
22
+ ...e.pagination,
23
+ pageIndex: 0
24
+ }
25
+ };
26
+ case "SET_GROUPING": return {
27
+ ...e,
28
+ grouping: t.grouping,
29
+ pagination: {
30
+ ...e.pagination,
31
+ pageIndex: 0
32
+ }
33
+ };
34
+ case "SET_PAGE": return {
35
+ ...e,
36
+ pagination: {
37
+ ...e.pagination,
38
+ pageIndex: t.pageIndex
39
+ }
40
+ };
41
+ case "SET_PAGE_SIZE": return {
42
+ ...e,
43
+ pagination: {
44
+ ...e.pagination,
45
+ pageSize: t.pageSize,
46
+ pageIndex: 0
47
+ }
48
+ };
49
+ case "SET_COLUMN_SIZE": return {
50
+ ...e,
51
+ columnSizing: {
52
+ ...e.columnSizing,
53
+ [t.columnId]: t.width
54
+ }
55
+ };
56
+ case "SET_COLUMN_VISIBILITY": return {
57
+ ...e,
58
+ columnVisibility: {
59
+ ...e.columnVisibility,
60
+ [t.columnId]: t.visible
61
+ }
62
+ };
63
+ case "TOGGLE_SELECT": {
64
+ let n = new Set(e.selection);
65
+ return t.mode === "single" ? n.has(t.rowId) ? n.clear() : (n.clear(), n.add(t.rowId)) : n.has(t.rowId) ? n.delete(t.rowId) : n.add(t.rowId), {
66
+ ...e,
67
+ selection: n
68
+ };
69
+ }
70
+ case "SELECT_ALL": return {
71
+ ...e,
72
+ selection: new Set(t.rowIds)
73
+ };
74
+ case "CLEAR_SELECTION": return {
75
+ ...e,
76
+ selection: /* @__PURE__ */ new Set()
77
+ };
78
+ case "TOGGLE_EXPAND": {
79
+ let n = new Set(e.expanded);
80
+ return n.has(t.groupId) ? n.delete(t.groupId) : n.add(t.groupId), {
81
+ ...e,
82
+ expanded: n
83
+ };
84
+ }
85
+ case "APPLY_AI": return {
86
+ ...e,
87
+ ...t.partial.sorts !== void 0 && { sorts: t.partial.sorts },
88
+ ...t.partial.filters !== void 0 && { filters: t.partial.filters },
89
+ ...t.partial.grouping !== void 0 && { grouping: t.partial.grouping },
90
+ pagination: {
91
+ ...e.pagination,
92
+ pageIndex: 0
93
+ }
94
+ };
95
+ case "RESET": return {
96
+ ...e,
97
+ sorts: [],
98
+ filters: [],
99
+ grouping: [],
100
+ pagination: {
101
+ ...e.pagination,
102
+ pageIndex: 0
103
+ }
104
+ };
105
+ default: return e;
106
+ }
107
+ }
108
+ //#endregion
109
+ //#region src/components/DataGrid/state/useGridState.ts
110
+ var g = {
111
+ sorts: [],
112
+ filters: [],
113
+ grouping: [],
114
+ expanded: /* @__PURE__ */ new Set(),
115
+ selection: /* @__PURE__ */ new Set(),
116
+ pagination: {
117
+ pageIndex: 0,
118
+ pageSize: 20
119
+ },
120
+ columnSizing: {},
121
+ columnVisibility: {}
122
+ };
123
+ function _(e, t) {
124
+ return {
125
+ ...g,
126
+ ...e,
127
+ pagination: {
128
+ pageIndex: 0,
129
+ pageSize: t,
130
+ ...e?.pagination
131
+ }
132
+ };
133
+ }
134
+ function v(e) {
135
+ let [t, r] = s(h, e);
136
+ return {
137
+ state: t,
138
+ dispatch: n((e) => {
139
+ r(e);
140
+ }, [])
141
+ };
142
+ }
143
+ //#endregion
144
+ //#region src/components/DataGrid/state/aggregations.ts
145
+ function y(e, t) {
146
+ if (t === "count") return e.length;
147
+ if (e.length === 0) return null;
148
+ switch (t) {
149
+ case "sum": return e.reduce((e, t) => e + t, 0);
150
+ case "avg": return e.reduce((e, t) => e + t, 0) / e.length;
151
+ case "min": return Math.min(...e);
152
+ case "max": return Math.max(...e);
153
+ }
154
+ }
155
+ //#endregion
156
+ //#region src/components/DataGrid/state/processRows.ts
157
+ function b(e, t) {
158
+ return e instanceof Date && t instanceof Date ? e.valueOf() - t.valueOf() : typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t), void 0, {
159
+ numeric: !0,
160
+ sensitivity: "base"
161
+ });
162
+ }
163
+ function x(e) {
164
+ if (typeof e == "number") return e;
165
+ let t = new Date(e);
166
+ return isNaN(t.valueOf()) ? NaN : t.valueOf();
167
+ }
168
+ function ee(e, t) {
169
+ if (e === null) return !1;
170
+ let { operator: n, value: r } = t;
171
+ switch (n) {
172
+ case "eq": return e instanceof Date ? e.toISOString().startsWith(String(r)) : typeof e == "number" ? e === Number(r) : String(e).toLowerCase() === String(r).toLowerCase();
173
+ case "contains": return String(e).toLowerCase().includes(String(r).toLowerCase());
174
+ case "gt": return e instanceof Date ? e.valueOf() > x(r) : typeof e == "number" ? e > Number(r) : String(e).localeCompare(String(r)) > 0;
175
+ case "gte": return e instanceof Date ? e.valueOf() >= x(r) : typeof e == "number" ? e >= Number(r) : String(e).localeCompare(String(r)) >= 0;
176
+ case "lt": return e instanceof Date ? e.valueOf() < x(r) : typeof e == "number" ? e < Number(r) : String(e).localeCompare(String(r)) < 0;
177
+ case "lte": return e instanceof Date ? e.valueOf() <= x(r) : typeof e == "number" ? e <= Number(r) : String(e).localeCompare(String(r)) <= 0;
178
+ case "between": {
179
+ if (!Array.isArray(r) || r.length < 2) return !0;
180
+ let [t, n] = r;
181
+ if (e instanceof Date) {
182
+ let r = e.valueOf();
183
+ return r >= x(t) && r <= x(n);
184
+ }
185
+ if (typeof e == "number") return e >= Number(t) && e <= Number(n);
186
+ let i = String(e).toLowerCase();
187
+ return i >= String(t).toLowerCase() && i <= String(n).toLowerCase();
188
+ }
189
+ case "in": return (Array.isArray(r) ? r : [r]).some((t) => String(e).toLowerCase() === String(t).toLowerCase());
190
+ }
191
+ }
192
+ function S(e, t, n) {
193
+ return n.length === 0 ? e : [...e].sort((e, r) => {
194
+ for (let { columnId: i, direction: a } of n) {
195
+ let n = t.get(i);
196
+ if (!n) continue;
197
+ let o = n.accessor(e), s = n.accessor(r);
198
+ if (o === null && s === null) continue;
199
+ if (o === null) return 1;
200
+ if (s === null) return -1;
201
+ let c = b(o, s);
202
+ if (c !== 0) return a === "asc" ? c : -c;
203
+ }
204
+ return 0;
205
+ });
206
+ }
207
+ function C(e, t, n, r, i, a) {
208
+ let o = n.grouping[i], s = t.get(o);
209
+ if (!s) return e.map((e) => ({
210
+ _type: "data",
211
+ row: e
212
+ }));
213
+ let c = [], l = /* @__PURE__ */ new Map();
214
+ for (let t of e) {
215
+ let e = s.accessor(t), n = e === null ? "\0null" : e instanceof Date ? e.toISOString() : String(e);
216
+ l.has(n) || (l.set(n, c.length), c.push({
217
+ key: n,
218
+ value: e,
219
+ rows: []
220
+ })), c[l.get(n)].rows.push(t);
221
+ }
222
+ let u = n.sorts.find((e) => e.columnId === o);
223
+ u && c.sort((e, t) => {
224
+ if (e.value === null && t.value === null) return 0;
225
+ if (e.value === null) return 1;
226
+ if (t.value === null) return -1;
227
+ let n = b(e.value, t.value);
228
+ return u.direction === "asc" ? n : -n;
229
+ });
230
+ let d = [];
231
+ for (let e of c) {
232
+ let s = {};
233
+ for (let [n, r] of t) r.aggregation && (s[n] = y(r.aggregation === "count" ? Array.from({ length: e.rows.length }, () => 1) : e.rows.map((e) => r.accessor(e)).filter((e) => typeof e == "number"), r.aggregation));
234
+ let c = a ? `${a}|${o}:${e.key}` : `${o}:${e.key}`, l = n.expanded.has(c), u = {
235
+ _type: "group",
236
+ id: c,
237
+ columnId: o,
238
+ value: e.value,
239
+ depth: r,
240
+ childCount: e.rows.length,
241
+ aggregates: s,
242
+ isExpanded: l
243
+ };
244
+ if (d.push(u), l) if (i + 1 < n.grouping.length) d.push(...C(e.rows, t, n, r + 1, i + 1, c));
245
+ else {
246
+ let r = n.sorts.filter((e) => !n.grouping.includes(e.columnId)), i = S(e.rows, t, r);
247
+ d.push(...i.map((e) => ({
248
+ _type: "data",
249
+ row: e
250
+ })));
251
+ }
252
+ }
253
+ return d;
254
+ }
255
+ function te(e, t, n) {
256
+ if (n.length === 0) return e;
257
+ let r = new Map(t.map((e) => [e.id, e]));
258
+ return e.filter((e) => n.every((t) => {
259
+ let n = r.get(t.columnId);
260
+ return n ? ee(n.accessor(e), t) : !0;
261
+ }));
262
+ }
263
+ function ne(e, t, n) {
264
+ let r = new Map(t.map((e) => [e.id, e])), i = te(e, t, n.filters);
265
+ return n.grouping.length === 0 ? S(i, r, n.sorts).map((e) => ({
266
+ _type: "data",
267
+ row: e
268
+ })) : C(i, r, n, 0, 0, "");
269
+ }
270
+ //#endregion
271
+ //#region src/components/DataGrid/state/paginate.ts
272
+ function w(e, t) {
273
+ let { pageIndex: n, pageSize: r } = t, i = n * r;
274
+ return e.slice(i, i + r);
275
+ }
276
+ function re(e, t) {
277
+ return Math.max(1, Math.ceil(e / t));
278
+ }
279
+ //#endregion
280
+ //#region src/components/DataGrid/state/selection.ts
281
+ function T(e, t, n) {
282
+ return e.size === 0 ? [] : t.filter((t) => e.has(n(t)));
283
+ }
284
+ //#endregion
285
+ //#region src/components/DataGrid/state/exportCsv.ts
286
+ function E(e) {
287
+ if (e == null) return "";
288
+ let t = String(e), n = /^[=+\-@\t\r]/.test(t) ? `\t${t}` : t;
289
+ return n.includes(",") || n.includes("\n") || n.includes("\"") ? `"${n.replace(/"/g, "\"\"")}"` : n;
290
+ }
291
+ function ie(e, t) {
292
+ let n = t.filter((e) => e.hideable !== !0 || e.defaultHidden !== !0);
293
+ return [n.map((e) => E(e.header)).join(","), ...e.map((e) => n.map((t) => {
294
+ let n = t.exportValue ? t.exportValue(e) : t.accessor(e);
295
+ return E(n instanceof Date ? n.toISOString() : n);
296
+ }).join(","))].join("\n");
297
+ }
298
+ function ae(e, t) {
299
+ let n = new Blob([e], { type: "text/csv;charset=utf-8;" }), r = URL.createObjectURL(n), i = document.createElement("a");
300
+ i.href = r, i.download = t, i.click(), URL.revokeObjectURL(r);
301
+ }
302
+ //#endregion
303
+ //#region src/components/DataGrid/ai/applyCommand.ts
304
+ function D(e, t) {
305
+ if (e.reset) return [{ type: "RESET" }];
306
+ let n = {};
307
+ return e.filters && (n.filters = e.filters.filter((e) => t.has(e.columnId))), e.sorts && (n.sorts = e.sorts.filter((e) => t.has(e.columnId))), e.grouping && (n.grouping = e.grouping.filter((e) => t.has(e))), [{
308
+ type: "APPLY_AI",
309
+ partial: n
310
+ }];
311
+ }
312
+ var O = {
313
+ th: "_th_b545v_1",
314
+ content: "_content_b545v_6",
315
+ label: "_label_b545v_14",
316
+ indicators: "_indicators_b545v_23",
317
+ arrow: "_arrow_b545v_38",
318
+ arrowIdle: "_arrowIdle_b545v_42",
319
+ sortIndex: "_sortIndex_b545v_47",
320
+ headerActions: "_headerActions_b545v_56",
321
+ headerActionsVisible: "_headerActionsVisible_b545v_65",
322
+ menuBtnOpen: "_menuBtnOpen_b545v_68",
323
+ filterBtnActive: "_filterBtnActive_b545v_69",
324
+ filterBtn: "_filterBtn_b545v_69",
325
+ menuBtn: "_menuBtn_b545v_68",
326
+ resizeHandle: "_resizeHandle_b545v_115",
327
+ sortable: "_sortable_b545v_132"
328
+ }, k = /* @__PURE__ */ p(((e) => {
329
+ var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
330
+ function r(e, n, r) {
331
+ var i = null;
332
+ if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
333
+ else r = n;
334
+ return n = r.ref, {
335
+ $$typeof: t,
336
+ type: e,
337
+ key: i,
338
+ ref: n === void 0 ? null : n,
339
+ props: r
340
+ };
341
+ }
342
+ e.Fragment = n, e.jsx = r, e.jsxs = r;
343
+ })), A = /* @__PURE__ */ p(((e) => {
344
+ process.env.NODE_ENV !== "production" && (function() {
345
+ function t(e) {
346
+ if (e == null) return null;
347
+ if (typeof e == "function") return e.$$typeof === T ? null : e.displayName || e.name || null;
348
+ if (typeof e == "string") return e;
349
+ switch (e) {
350
+ case v: return "Fragment";
351
+ case b: return "Profiler";
352
+ case y: return "StrictMode";
353
+ case C: return "Suspense";
354
+ case te: return "SuspenseList";
355
+ case re: return "Activity";
356
+ }
357
+ if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
358
+ case _: return "Portal";
359
+ case ee: return e.displayName || "Context";
360
+ case x: return (e._context.displayName || "Context") + ".Consumer";
361
+ case S:
362
+ var n = e.render;
363
+ return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
364
+ case ne: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
365
+ case w:
366
+ n = e._payload, e = e._init;
367
+ try {
368
+ return t(e(n));
369
+ } catch {}
370
+ }
371
+ return null;
372
+ }
373
+ function n(e) {
374
+ return "" + e;
375
+ }
376
+ function r(e) {
377
+ try {
378
+ n(e);
379
+ var t = !1;
380
+ } catch {
381
+ t = !0;
382
+ }
383
+ if (t) {
384
+ t = console;
385
+ var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
386
+ return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
387
+ }
388
+ }
389
+ function i(e) {
390
+ if (e === v) return "<>";
391
+ if (typeof e == "object" && e && e.$$typeof === w) return "<...>";
392
+ try {
393
+ var n = t(e);
394
+ return n ? "<" + n + ">" : "<...>";
395
+ } catch {
396
+ return "<...>";
397
+ }
398
+ }
399
+ function a() {
400
+ var e = E.A;
401
+ return e === null ? null : e.getOwner();
402
+ }
403
+ function o() {
404
+ return Error("react-stack-top-frame");
405
+ }
406
+ function s(e) {
407
+ if (ie.call(e, "key")) {
408
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
409
+ if (t && t.isReactWarning) return !1;
410
+ }
411
+ return e.key !== void 0;
412
+ }
413
+ function c(e, t) {
414
+ function n() {
415
+ O || (O = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
416
+ }
417
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
418
+ get: n,
419
+ configurable: !0
420
+ });
421
+ }
422
+ function l() {
423
+ var e = t(this.type);
424
+ return k[e] || (k[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
425
+ }
426
+ function u(e, t, n, r, i, a) {
427
+ var o = n.ref;
428
+ return e = {
429
+ $$typeof: g,
430
+ type: e,
431
+ key: t,
432
+ props: n,
433
+ _owner: r
434
+ }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
435
+ enumerable: !1,
436
+ value: null
437
+ }) : Object.defineProperty(e, "ref", {
438
+ enumerable: !1,
439
+ get: l
440
+ }), e._store = {}, Object.defineProperty(e._store, "validated", {
441
+ configurable: !1,
442
+ enumerable: !1,
443
+ writable: !0,
444
+ value: 0
445
+ }), Object.defineProperty(e, "_debugInfo", {
446
+ configurable: !1,
447
+ enumerable: !1,
448
+ writable: !0,
449
+ value: null
450
+ }), Object.defineProperty(e, "_debugStack", {
451
+ configurable: !1,
452
+ enumerable: !1,
453
+ writable: !0,
454
+ value: i
455
+ }), Object.defineProperty(e, "_debugTask", {
456
+ configurable: !1,
457
+ enumerable: !1,
458
+ writable: !0,
459
+ value: a
460
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
461
+ }
462
+ function d(e, n, i, o, l, d) {
463
+ var p = n.children;
464
+ if (p !== void 0) if (o) if (ae(p)) {
465
+ for (o = 0; o < p.length; o++) f(p[o]);
466
+ Object.freeze && Object.freeze(p);
467
+ } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
468
+ else f(p);
469
+ if (ie.call(n, "key")) {
470
+ p = t(e);
471
+ var m = Object.keys(n).filter(function(e) {
472
+ return e !== "key";
473
+ });
474
+ o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", M[p + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, p, m, p), M[p + o] = !0);
475
+ }
476
+ if (p = null, i !== void 0 && (r(i), p = "" + i), s(n) && (r(n.key), p = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
477
+ else i = n;
478
+ return p && c(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), u(e, p, i, a(), l, d);
479
+ }
480
+ function f(e) {
481
+ p(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === w && (e._payload.status === "fulfilled" ? p(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
482
+ }
483
+ function p(e) {
484
+ return typeof e == "object" && !!e && e.$$typeof === g;
485
+ }
486
+ var h = m("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), ee = Symbol.for("react.context"), S = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), te = Symbol.for("react.suspense_list"), ne = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), re = Symbol.for("react.activity"), T = Symbol.for("react.client.reference"), E = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ie = Object.prototype.hasOwnProperty, ae = Array.isArray, D = console.createTask ? console.createTask : function() {
487
+ return null;
488
+ };
489
+ h = { react_stack_bottom_frame: function(e) {
490
+ return e();
491
+ } };
492
+ var O, k = {}, A = h.react_stack_bottom_frame.bind(h, o)(), j = D(i(o)), M = {};
493
+ e.Fragment = v, e.jsx = function(e, t, n) {
494
+ var r = 1e4 > E.recentlyCreatedOwnerStacks++;
495
+ return d(e, t, n, !1, r ? Error("react-stack-top-frame") : A, r ? D(i(e)) : j);
496
+ }, e.jsxs = function(e, t, n) {
497
+ var r = 1e4 > E.recentlyCreatedOwnerStacks++;
498
+ return d(e, t, n, !0, r ? Error("react-stack-top-frame") : A, r ? D(i(e)) : j);
499
+ };
500
+ })();
501
+ })), j = (/* @__PURE__ */ p(((e, t) => {
502
+ process.env.NODE_ENV === "production" ? t.exports = k() : t.exports = A();
503
+ })))(), M = {
504
+ asc: "ascending",
505
+ desc: "descending"
506
+ };
507
+ function N({ filled: e }) {
508
+ return /* @__PURE__ */ (0, j.jsx)("svg", {
509
+ width: "10",
510
+ height: "10",
511
+ viewBox: "0 0 10 10",
512
+ fill: "none",
513
+ "aria-hidden": "true",
514
+ children: e ? /* @__PURE__ */ (0, j.jsx)("path", {
515
+ d: "M1 1h8L6 5v3.5L4 7.5V5L1 1z",
516
+ fill: "currentColor"
517
+ }) : /* @__PURE__ */ (0, j.jsx)("path", {
518
+ d: "M1 1h8L6 5v3.5L4 7.5V5L1 1z",
519
+ stroke: "currentColor",
520
+ strokeWidth: "1",
521
+ fill: "none"
522
+ })
523
+ });
524
+ }
525
+ function oe({ column: e, sortEntry: t, sortIndex: n, totalSorts: r, width: i, onSort: a, enableResize: o, onResize: s, enableMenu: c, menuOpen: l, onToggleMenu: u, columnMenuSlot: d, filterActive: f = !1, filterPanelOpen: p = !1, onToggleFilter: m }) {
526
+ let h = e.sortable !== !1 && !!a, g = o && e.resizable !== !1 && !!s, _ = t?.direction;
527
+ function v(t) {
528
+ h && a(e.id, t.shiftKey);
529
+ }
530
+ function y(t) {
531
+ h && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), a(e.id, t.shiftKey));
532
+ }
533
+ function b(t) {
534
+ t.preventDefault(), t.stopPropagation();
535
+ let n = t.clientX, r = t.target.closest("th").getBoundingClientRect().width;
536
+ function i(t) {
537
+ let i = t.clientX - n, a = Math.max(e.minWidth ?? 50, r + i);
538
+ s(e.id, Math.round(a));
539
+ }
540
+ function a() {
541
+ document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", a);
542
+ }
543
+ document.addEventListener("mousemove", i), document.addEventListener("mouseup", a);
544
+ }
545
+ let x = _ ? M[_] : h ? "none" : void 0;
546
+ return /* @__PURE__ */ (0, j.jsxs)("th", {
547
+ style: {
548
+ width: i ?? e.width,
549
+ position: "relative"
550
+ },
551
+ "aria-sort": x,
552
+ onClick: h ? v : void 0,
553
+ onKeyDown: h ? y : void 0,
554
+ tabIndex: h ? 0 : void 0,
555
+ role: h ? "columnheader" : void 0,
556
+ className: [O.th, h && O.sortable].filter(Boolean).join(" "),
557
+ children: [
558
+ /* @__PURE__ */ (0, j.jsxs)("span", {
559
+ className: O.content,
560
+ children: [
561
+ /* @__PURE__ */ (0, j.jsx)("span", {
562
+ className: O.label,
563
+ children: e.header
564
+ }),
565
+ h && /* @__PURE__ */ (0, j.jsxs)("span", {
566
+ className: O.indicators,
567
+ "aria-hidden": "true",
568
+ children: [
569
+ _ === "asc" && /* @__PURE__ */ (0, j.jsx)("span", {
570
+ className: O.arrow,
571
+ children: "↑"
572
+ }),
573
+ _ === "desc" && /* @__PURE__ */ (0, j.jsx)("span", {
574
+ className: O.arrow,
575
+ children: "↓"
576
+ }),
577
+ !_ && /* @__PURE__ */ (0, j.jsx)("span", {
578
+ className: O.arrowIdle,
579
+ children: "↕"
580
+ }),
581
+ r > 1 && n >= 0 && /* @__PURE__ */ (0, j.jsx)("span", {
582
+ className: O.sortIndex,
583
+ children: n + 1
584
+ })
585
+ ]
586
+ }),
587
+ /* @__PURE__ */ (0, j.jsxs)("span", {
588
+ className: [O.headerActions, m && O.headerActionsVisible].filter(Boolean).join(" "),
589
+ children: [m && /* @__PURE__ */ (0, j.jsx)("button", {
590
+ type: "button",
591
+ className: [O.filterBtn, (f || p) && O.filterBtnActive].filter(Boolean).join(" "),
592
+ onClick: (t) => {
593
+ t.stopPropagation(), m(e.id, t.currentTarget.getBoundingClientRect());
594
+ },
595
+ "aria-label": `Filter ${e.header}`,
596
+ "aria-haspopup": "dialog",
597
+ "aria-expanded": p,
598
+ tabIndex: -1,
599
+ children: /* @__PURE__ */ (0, j.jsx)(N, { filled: f })
600
+ }), c && e.hideable !== !1 && /* @__PURE__ */ (0, j.jsx)("button", {
601
+ type: "button",
602
+ className: [O.menuBtn, l && O.menuBtnOpen].filter(Boolean).join(" "),
603
+ onClick: (t) => {
604
+ t.stopPropagation(), u?.(e.id, t.currentTarget.getBoundingClientRect());
605
+ },
606
+ "aria-label": `Column options for ${e.header}`,
607
+ "aria-expanded": l,
608
+ tabIndex: -1,
609
+ children: "⋮"
610
+ })]
611
+ })
612
+ ]
613
+ }),
614
+ g && /* @__PURE__ */ (0, j.jsx)("span", {
615
+ className: O.resizeHandle,
616
+ onMouseDown: b,
617
+ role: "separator",
618
+ "aria-label": `Resize ${e.header}`,
619
+ "aria-orientation": "vertical"
620
+ }),
621
+ d
622
+ ]
623
+ });
624
+ }
625
+ var P = {
626
+ panel: "_panel_l8qj5_1",
627
+ heading: "_heading_l8qj5_13",
628
+ section: "_section_l8qj5_24",
629
+ field: "_field_l8qj5_33",
630
+ label: "_label_l8qj5_39",
631
+ select: "_select_l8qj5_45",
632
+ input: "_input_l8qj5_65",
633
+ rangeRow: "_rangeRow_l8qj5_100",
634
+ rangeSep: "_rangeSep_l8qj5_110",
635
+ searchRow: "_searchRow_l8qj5_118",
636
+ searchIcon: "_searchIcon_l8qj5_124",
637
+ searchInput: "_searchInput_l8qj5_132",
638
+ checkboxList: "_checkboxList_l8qj5_163",
639
+ checkboxItem: "_checkboxItem_l8qj5_175",
640
+ checkbox: "_checkbox_l8qj5_163",
641
+ checkboxLabel: "_checkboxLabel_l8qj5_203",
642
+ noResults: "_noResults_l8qj5_211",
643
+ clearBtn: "_clearBtn_l8qj5_221",
644
+ srOnly: "_srOnly_l8qj5_248"
645
+ }, F = [
646
+ {
647
+ value: "eq",
648
+ label: "Equals",
649
+ symbol: "="
650
+ },
651
+ {
652
+ value: "gt",
653
+ label: "Greater than",
654
+ symbol: ">"
655
+ },
656
+ {
657
+ value: "gte",
658
+ label: "Greater than or equal",
659
+ symbol: "≥"
660
+ },
661
+ {
662
+ value: "lt",
663
+ label: "Less than",
664
+ symbol: "<"
665
+ },
666
+ {
667
+ value: "lte",
668
+ label: "Less than or equal",
669
+ symbol: "≤"
670
+ },
671
+ {
672
+ value: "between",
673
+ label: "Between",
674
+ symbol: "↔"
675
+ }
676
+ ];
677
+ function se(e) {
678
+ return e === "gt" || e === "gte" || e === "lt" || e === "lte" || e === "between" ? e : "eq";
679
+ }
680
+ function I(e) {
681
+ let t = e.trim();
682
+ if (t === "") return null;
683
+ let n = Number(t);
684
+ return isNaN(n) ? null : n;
685
+ }
686
+ var ce = 300;
687
+ function le({ column: e, filterEntry: t, filterOptions: n, anchorRect: a, onClose: o, onChange: s }) {
688
+ let l = c(null), u = i(), f = Math.min(a.left, typeof window < "u" ? window.innerWidth - 252 : a.left), p = {
689
+ top: a.bottom + 6,
690
+ left: Math.max(4, f)
691
+ };
692
+ r(() => {
693
+ function e(e) {
694
+ l.current && !l.current.contains(e.target) && o();
695
+ }
696
+ function t(e) {
697
+ e.key === "Escape" && o();
698
+ }
699
+ function n() {
700
+ o();
701
+ }
702
+ return document.addEventListener("pointerdown", e), document.addEventListener("keydown", t), window.addEventListener("scroll", n, {
703
+ capture: !0,
704
+ passive: !0
705
+ }), () => {
706
+ document.removeEventListener("pointerdown", e), document.removeEventListener("keydown", t), window.removeEventListener("scroll", n, { capture: !0 });
707
+ };
708
+ }, [o]);
709
+ let m = e.filterType ?? "text";
710
+ return d(/* @__PURE__ */ (0, j.jsxs)("div", {
711
+ ref: l,
712
+ className: P.panel,
713
+ style: p,
714
+ role: "dialog",
715
+ "aria-labelledby": u,
716
+ "aria-modal": "false",
717
+ children: [
718
+ /* @__PURE__ */ (0, j.jsxs)("p", {
719
+ id: u,
720
+ className: P.heading,
721
+ children: ["Filter ", e.header]
722
+ }),
723
+ m === "number" && /* @__PURE__ */ (0, j.jsx)(L, {
724
+ columnHeader: e.header,
725
+ filterEntry: t,
726
+ onChange: s
727
+ }),
728
+ (m === "text" || m === "date") && /* @__PURE__ */ (0, j.jsx)(R, {
729
+ columnHeader: e.header,
730
+ filterType: m,
731
+ filterEntry: t,
732
+ onChange: s
733
+ }),
734
+ m === "select" && /* @__PURE__ */ (0, j.jsx)(ue, {
735
+ columnHeader: e.header,
736
+ options: n ?? e.filterOptions ?? [],
737
+ filterEntry: t,
738
+ onChange: s
739
+ })
740
+ ]
741
+ }), document.body);
742
+ }
743
+ function L({ columnHeader: e, filterEntry: t, onChange: n }) {
744
+ let r = i(), a = i(), [o, s] = l(() => se(t?.operator ?? null)), [u, d] = l(() => {
745
+ let e = t?.value;
746
+ return e == null ? "" : Array.isArray(e) ? e[0] === void 0 ? "" : String(e[0]) : String(e);
747
+ }), [f, p] = l(() => {
748
+ let e = t?.value;
749
+ return Array.isArray(e) ? e[1] === void 0 ? "" : String(e[1]) : "";
750
+ }), m = c(null);
751
+ function h(e, t, r) {
752
+ m.current && clearTimeout(m.current), m.current = setTimeout(() => {
753
+ if (e === "between") {
754
+ let e = I(t), i = I(r);
755
+ n(e !== null && i !== null ? [e, i] : null, "between");
756
+ } else n(I(t), e);
757
+ }, ce);
758
+ }
759
+ let g = u !== "" || f !== "";
760
+ return /* @__PURE__ */ (0, j.jsxs)("div", {
761
+ className: P.section,
762
+ children: [
763
+ /* @__PURE__ */ (0, j.jsxs)("div", {
764
+ className: P.field,
765
+ children: [/* @__PURE__ */ (0, j.jsx)("label", {
766
+ htmlFor: r,
767
+ className: P.label,
768
+ children: "Operator"
769
+ }), /* @__PURE__ */ (0, j.jsx)("select", {
770
+ id: r,
771
+ className: P.select,
772
+ value: o,
773
+ onChange: (e) => {
774
+ let t = e.target.value;
775
+ s(t), h(t, u, f);
776
+ },
777
+ children: F.map((e) => /* @__PURE__ */ (0, j.jsxs)("option", {
778
+ value: e.value,
779
+ children: [
780
+ e.symbol,
781
+ " ",
782
+ e.label
783
+ ]
784
+ }, e.value))
785
+ })]
786
+ }),
787
+ o === "between" ? /* @__PURE__ */ (0, j.jsxs)("div", {
788
+ className: P.field,
789
+ children: [/* @__PURE__ */ (0, j.jsx)("label", {
790
+ className: P.label,
791
+ children: "Range"
792
+ }), /* @__PURE__ */ (0, j.jsxs)("div", {
793
+ className: P.rangeRow,
794
+ children: [
795
+ /* @__PURE__ */ (0, j.jsx)("input", {
796
+ type: "number",
797
+ className: P.input,
798
+ value: u,
799
+ placeholder: "Min",
800
+ onChange: (e) => {
801
+ d(e.target.value), h(o, e.target.value, f);
802
+ },
803
+ "aria-label": `Minimum value for ${e}`,
804
+ style: { fontVariantNumeric: "tabular-nums" },
805
+ autoFocus: !0
806
+ }),
807
+ /* @__PURE__ */ (0, j.jsx)("span", {
808
+ className: P.rangeSep,
809
+ "aria-hidden": "true",
810
+ children: "–"
811
+ }),
812
+ /* @__PURE__ */ (0, j.jsx)("input", {
813
+ type: "number",
814
+ className: P.input,
815
+ value: f,
816
+ placeholder: "Max",
817
+ onChange: (e) => {
818
+ p(e.target.value), h(o, u, e.target.value);
819
+ },
820
+ "aria-label": `Maximum value for ${e}`,
821
+ style: { fontVariantNumeric: "tabular-nums" }
822
+ })
823
+ ]
824
+ })]
825
+ }) : /* @__PURE__ */ (0, j.jsxs)("div", {
826
+ className: P.field,
827
+ children: [/* @__PURE__ */ (0, j.jsx)("label", {
828
+ htmlFor: a,
829
+ className: P.label,
830
+ children: "Value"
831
+ }), /* @__PURE__ */ (0, j.jsx)("input", {
832
+ id: a,
833
+ type: "number",
834
+ className: P.input,
835
+ value: u,
836
+ placeholder: "Enter value…",
837
+ onChange: (e) => {
838
+ d(e.target.value), h(o, e.target.value, f);
839
+ },
840
+ "aria-label": `Filter value for ${e}`,
841
+ style: { fontVariantNumeric: "tabular-nums" },
842
+ autoFocus: !0
843
+ })]
844
+ }),
845
+ g && /* @__PURE__ */ (0, j.jsx)("button", {
846
+ type: "button",
847
+ className: P.clearBtn,
848
+ onClick: () => {
849
+ m.current && clearTimeout(m.current), d(""), p(""), n(null, o);
850
+ },
851
+ children: "Clear filter"
852
+ })
853
+ ]
854
+ });
855
+ }
856
+ function R({ columnHeader: e, filterType: t, filterEntry: n, onChange: r }) {
857
+ let a = i(), o = t === "date" ? "eq" : "contains", [s, u] = l(n?.value == null ? "" : String(n.value)), d = c(null);
858
+ function f(e) {
859
+ d.current && clearTimeout(d.current), d.current = setTimeout(() => {
860
+ r(e.trim() === "" ? null : e.trim(), o);
861
+ }, ce);
862
+ }
863
+ return /* @__PURE__ */ (0, j.jsxs)("div", {
864
+ className: P.section,
865
+ children: [/* @__PURE__ */ (0, j.jsxs)("div", {
866
+ className: P.field,
867
+ children: [/* @__PURE__ */ (0, j.jsx)("label", {
868
+ htmlFor: a,
869
+ className: P.label,
870
+ children: t === "date" ? "Date" : "Contains"
871
+ }), /* @__PURE__ */ (0, j.jsx)("input", {
872
+ id: a,
873
+ type: t === "date" ? "date" : "text",
874
+ className: P.input,
875
+ value: s,
876
+ placeholder: t === "date" ? void 0 : "Filter…",
877
+ onChange: (e) => {
878
+ u(e.target.value), f(e.target.value);
879
+ },
880
+ "aria-label": `Filter ${e}`,
881
+ autoFocus: !0
882
+ })]
883
+ }), s !== "" && /* @__PURE__ */ (0, j.jsx)("button", {
884
+ type: "button",
885
+ className: P.clearBtn,
886
+ onClick: () => {
887
+ d.current && clearTimeout(d.current), u(""), r(null, o);
888
+ },
889
+ children: "Clear filter"
890
+ })]
891
+ });
892
+ }
893
+ function z(e) {
894
+ if (!e) return /* @__PURE__ */ new Set();
895
+ let { value: t } = e;
896
+ return Array.isArray(t) ? new Set(t.map(String)) : t != null && String(t) !== "" ? new Set([String(t)]) : /* @__PURE__ */ new Set();
897
+ }
898
+ function ue({ columnHeader: e, options: t, filterEntry: a, onChange: o }) {
899
+ let s = i(), [u, d] = l(""), [f, p] = l(() => z(a)), m = t.filter((e) => e.toLowerCase().includes(u.toLowerCase())), h = m.length > 0 && m.every((e) => f.has(e)), g = m.some((e) => f.has(e)), _ = c(null);
900
+ r(() => {
901
+ _.current && (_.current.indeterminate = g && !h);
902
+ }, [g, h]);
903
+ let v = n((e) => {
904
+ p(e), o(e.size > 0 ? Array.from(e) : null, "in");
905
+ }, [o]);
906
+ function y() {
907
+ if (h) {
908
+ let e = new Set(f);
909
+ m.forEach((t) => e.delete(t)), v(e);
910
+ } else {
911
+ let e = new Set(f);
912
+ m.forEach((t) => e.add(t)), v(e);
913
+ }
914
+ }
915
+ function b(e) {
916
+ let t = new Set(f);
917
+ t.has(e) ? t.delete(e) : t.add(e), v(t);
918
+ }
919
+ return /* @__PURE__ */ (0, j.jsxs)("div", {
920
+ className: P.section,
921
+ children: [
922
+ /* @__PURE__ */ (0, j.jsxs)("div", {
923
+ className: P.searchRow,
924
+ children: [
925
+ /* @__PURE__ */ (0, j.jsxs)("label", {
926
+ htmlFor: s,
927
+ className: P.srOnly,
928
+ children: [
929
+ "Search ",
930
+ e,
931
+ " options"
932
+ ]
933
+ }),
934
+ /* @__PURE__ */ (0, j.jsx)("span", {
935
+ className: P.searchIcon,
936
+ "aria-hidden": "true",
937
+ children: /* @__PURE__ */ (0, j.jsx)(de, {})
938
+ }),
939
+ /* @__PURE__ */ (0, j.jsx)("input", {
940
+ id: s,
941
+ type: "search",
942
+ className: P.searchInput,
943
+ value: u,
944
+ placeholder: "Search…",
945
+ onChange: (e) => d(e.target.value),
946
+ autoFocus: !0
947
+ })
948
+ ]
949
+ }),
950
+ /* @__PURE__ */ (0, j.jsxs)("div", {
951
+ className: P.checkboxList,
952
+ role: "group",
953
+ "aria-label": `Filter ${e} by value`,
954
+ children: [
955
+ t.length > 0 && /* @__PURE__ */ (0, j.jsxs)("label", {
956
+ className: P.checkboxItem,
957
+ children: [/* @__PURE__ */ (0, j.jsx)("input", {
958
+ ref: _,
959
+ type: "checkbox",
960
+ className: P.checkbox,
961
+ checked: h,
962
+ onChange: y,
963
+ "aria-label": "Select all"
964
+ }), /* @__PURE__ */ (0, j.jsx)("span", {
965
+ className: P.checkboxLabel,
966
+ children: "(Select All)"
967
+ })]
968
+ }),
969
+ m.length === 0 && /* @__PURE__ */ (0, j.jsx)("p", {
970
+ className: P.noResults,
971
+ children: "No matching options"
972
+ }),
973
+ m.map((e) => /* @__PURE__ */ (0, j.jsxs)("label", {
974
+ className: P.checkboxItem,
975
+ children: [/* @__PURE__ */ (0, j.jsx)("input", {
976
+ type: "checkbox",
977
+ className: P.checkbox,
978
+ checked: f.has(e),
979
+ onChange: () => b(e),
980
+ "aria-label": e
981
+ }), /* @__PURE__ */ (0, j.jsx)("span", {
982
+ className: P.checkboxLabel,
983
+ children: e
984
+ })]
985
+ }, e))
986
+ ]
987
+ }),
988
+ f.size > 0 && /* @__PURE__ */ (0, j.jsx)("button", {
989
+ type: "button",
990
+ className: P.clearBtn,
991
+ onClick: () => v(/* @__PURE__ */ new Set()),
992
+ children: "Clear filter"
993
+ })
994
+ ]
995
+ });
996
+ }
997
+ function de() {
998
+ return /* @__PURE__ */ (0, j.jsxs)("svg", {
999
+ width: "12",
1000
+ height: "12",
1001
+ viewBox: "0 0 12 12",
1002
+ "aria-hidden": "true",
1003
+ style: { display: "block" },
1004
+ children: [/* @__PURE__ */ (0, j.jsx)("circle", {
1005
+ cx: "5",
1006
+ cy: "5",
1007
+ r: "3.5",
1008
+ fill: "none",
1009
+ stroke: "currentColor",
1010
+ strokeWidth: "1.3"
1011
+ }), /* @__PURE__ */ (0, j.jsx)("line", {
1012
+ x1: "7.8",
1013
+ y1: "7.8",
1014
+ x2: "11",
1015
+ y2: "11",
1016
+ stroke: "currentColor",
1017
+ strokeWidth: "1.3",
1018
+ strokeLinecap: "round"
1019
+ })]
1020
+ });
1021
+ }
1022
+ var B = {
1023
+ groupRow: "_groupRow_16hmo_1",
1024
+ labelCell: "_labelCell_16hmo_10",
1025
+ toggleBtn: "_toggleBtn_16hmo_18",
1026
+ colHeader: "_colHeader_16hmo_45",
1027
+ groupValue: "_groupValue_16hmo_53",
1028
+ childCount: "_childCount_16hmo_58",
1029
+ aggregateCell: "_aggregateCell_16hmo_63"
1030
+ };
1031
+ //#endregion
1032
+ //#region src/components/DataGrid/ui/GroupRow.tsx
1033
+ function fe(e) {
1034
+ return e === null ? "(empty)" : e instanceof Date ? e.toLocaleDateString() : String(e);
1035
+ }
1036
+ function pe(e, t) {
1037
+ return e === null ? null : t === "avg" ? e.toFixed(2) : t === "count" ? String(e) : e.toLocaleString();
1038
+ }
1039
+ function me({ row: e, columns: t, visibleColumnIds: n, onToggle: r }) {
1040
+ let i = t.filter((e) => n.has(e.id)), a = t.find((t) => t.id === e.columnId);
1041
+ return /* @__PURE__ */ (0, j.jsx)("tr", {
1042
+ className: B.groupRow,
1043
+ "aria-level": e.depth + 1,
1044
+ children: i.map((t, n) => {
1045
+ if (n === 0) return /* @__PURE__ */ (0, j.jsxs)("td", {
1046
+ className: B.labelCell,
1047
+ style: { paddingLeft: `${e.depth * 1.5 + .5}rem` },
1048
+ colSpan: 1,
1049
+ children: [
1050
+ /* @__PURE__ */ (0, j.jsx)("button", {
1051
+ className: B.toggleBtn,
1052
+ onClick: r,
1053
+ "aria-expanded": e.isExpanded,
1054
+ "aria-label": `${e.isExpanded ? "Collapse" : "Expand"} group ${fe(e.value)}`,
1055
+ type: "button",
1056
+ children: e.isExpanded ? "▼" : "▶"
1057
+ }),
1058
+ /* @__PURE__ */ (0, j.jsxs)("span", {
1059
+ className: B.colHeader,
1060
+ children: [a?.header ?? e.columnId, ":"]
1061
+ }),
1062
+ /* @__PURE__ */ (0, j.jsx)("span", {
1063
+ className: B.groupValue,
1064
+ children: fe(e.value)
1065
+ }),
1066
+ /* @__PURE__ */ (0, j.jsxs)("span", {
1067
+ className: B.childCount,
1068
+ children: [
1069
+ "(",
1070
+ e.childCount,
1071
+ ")"
1072
+ ]
1073
+ })
1074
+ ]
1075
+ }, t.id);
1076
+ let i = e.aggregates[t.id], o = t.aggregation;
1077
+ return /* @__PURE__ */ (0, j.jsx)("td", {
1078
+ className: B.aggregateCell,
1079
+ children: o && i !== void 0 ? pe(i, o) : null
1080
+ }, t.id);
1081
+ })
1082
+ });
1083
+ }
1084
+ var V = {
1085
+ td: "_td_13y42_1",
1086
+ editable: "_editable_13y42_5",
1087
+ editInput: "_editInput_13y42_13"
1088
+ };
1089
+ //#endregion
1090
+ //#region src/components/DataGrid/ui/Cell.tsx
1091
+ function he({ column: e, row: t, onCellClick: n, isEditing: i = !1, onStartEdit: a, onCommitEdit: o, onCancelEdit: s }) {
1092
+ let u = e.accessor(t), [d, f] = l(""), p = c(!1), m = c(!1);
1093
+ r(() => {
1094
+ i && (f(u === null ? "" : String(u)), p.current = !1, m.current = !1);
1095
+ }, [i, u]);
1096
+ let h = () => {
1097
+ if (m.current || p.current) return;
1098
+ p.current = !0;
1099
+ let n = e.filterType === "number" || typeof u == "number" ? parseFloat(d) || 0 : d;
1100
+ o?.(n, t, e), s?.();
1101
+ }, g = () => {
1102
+ m.current = !0, s?.();
1103
+ };
1104
+ if (i) {
1105
+ let t = e.filterType === "number" || typeof u == "number";
1106
+ return /* @__PURE__ */ (0, j.jsx)("td", { children: /* @__PURE__ */ (0, j.jsx)("input", {
1107
+ className: V.editInput,
1108
+ type: t ? "number" : "text",
1109
+ value: d,
1110
+ "aria-label": `Edit ${e.header}`,
1111
+ autoFocus: !0,
1112
+ onChange: (e) => f(e.target.value),
1113
+ onKeyDown: (e) => {
1114
+ e.key === "Enter" || e.key === "Tab" ? (e.preventDefault(), h()) : e.key === "Escape" && g();
1115
+ },
1116
+ onBlur: h
1117
+ }) });
1118
+ }
1119
+ let _ = !!n, v = !!e.editable && !!a, y = e.cell ? e.cell(u, t) : String(u ?? "");
1120
+ return /* @__PURE__ */ (0, j.jsx)("td", {
1121
+ className: v ? V.editable : void 0,
1122
+ onClick: _ ? (r) => {
1123
+ r.stopPropagation(), n(u, t, e, r);
1124
+ } : void 0,
1125
+ onDoubleClick: v ? a : void 0,
1126
+ style: _ ? { cursor: "pointer" } : void 0,
1127
+ children: y
1128
+ });
1129
+ }
1130
+ var ge = {
1131
+ selectionCell: "_selectionCell_1237t_1",
1132
+ checkbox: "_checkbox_1237t_12"
1133
+ }, _e = {
1134
+ width: 40,
1135
+ minWidth: 40,
1136
+ maxWidth: 40
1137
+ };
1138
+ function ve({ checked: t, indeterminate: n, onChange: r, ariaLabel: i, isHeader: a = !1 }) {
1139
+ let o = e.useRef(null);
1140
+ return e.useEffect(() => {
1141
+ o.current && (o.current.indeterminate = !!n);
1142
+ }, [n]), /* @__PURE__ */ (0, j.jsx)(a ? "th" : "td", {
1143
+ className: ge.selectionCell,
1144
+ role: a ? "columnheader" : "gridcell",
1145
+ style: _e,
1146
+ children: /* @__PURE__ */ (0, j.jsx)("input", {
1147
+ ref: o,
1148
+ type: "checkbox",
1149
+ className: ge.checkbox,
1150
+ checked: t,
1151
+ onChange: r,
1152
+ "aria-label": i
1153
+ })
1154
+ });
1155
+ }
1156
+ //#endregion
1157
+ //#region src/components/DataGrid/ui/Row.tsx
1158
+ function ye({ row: e, rowIndex: t, rowId: n, columns: r, visibleColumnIds: i, selectionMode: a = "none", isSelected: o = !1, onToggleSelect: s, onRowClick: c, onCellClick: l, editingColumnId: u, onStartEdit: d, onCommitEdit: f, onCancelEdit: p }) {
1159
+ let m = !!c, h = u !== void 0;
1160
+ return /* @__PURE__ */ (0, j.jsxs)("tr", {
1161
+ "aria-selected": a === "none" ? void 0 : o,
1162
+ onClick: m ? (n) => {
1163
+ h || c(e, t, n);
1164
+ } : void 0,
1165
+ onKeyDown: m ? (n) => {
1166
+ h || (n.key === "Enter" || n.key === " ") && (n.preventDefault(), c(e, t, n));
1167
+ } : void 0,
1168
+ role: m ? "button" : void 0,
1169
+ tabIndex: m ? 0 : void 0,
1170
+ style: m ? { cursor: "pointer" } : void 0,
1171
+ children: [a !== "none" && /* @__PURE__ */ (0, j.jsx)(ve, {
1172
+ checked: o,
1173
+ onChange: () => s?.(n),
1174
+ ariaLabel: o ? "Deselect row" : "Select row"
1175
+ }), r.filter((e) => i.has(e.id)).map((t) => /* @__PURE__ */ (0, j.jsx)(he, {
1176
+ column: t,
1177
+ row: e,
1178
+ onCellClick: l,
1179
+ isEditing: u === t.id,
1180
+ onStartEdit: d ? () => d(n, t.id) : void 0,
1181
+ onCommitEdit: f,
1182
+ onCancelEdit: p
1183
+ }, t.id))]
1184
+ });
1185
+ }
1186
+ var H = {
1187
+ wrapper: "_wrapper_1x1x3_16",
1188
+ tableContainer: "_tableContainer_1x1x3_26",
1189
+ loadingOverlay: "_loadingOverlay_1x1x3_32",
1190
+ spinner: "_spinner_1x1x3_42",
1191
+ spin: "_spin_1x1x3_42",
1192
+ table: "_table_1x1x3_26",
1193
+ vsOuter: "_vsOuter_1x1x3_96",
1194
+ vsBody: "_vsBody_1x1x3_101",
1195
+ emptyState: "_emptyState_1x1x3_105",
1196
+ toolbar: "_toolbar_1x1x3_112",
1197
+ pagination: "_pagination_1x1x3_122",
1198
+ paginationControls: "_paginationControls_1x1x3_132",
1199
+ paginationBtn: "_paginationBtn_1x1x3_138",
1200
+ paginationInfo: "_paginationInfo_1x1x3_166",
1201
+ pageSizeLabel: "_pageSizeLabel_1x1x3_173",
1202
+ pageSizeSelect: "_pageSizeSelect_1x1x3_181"
1203
+ }, be = [
1204
+ 10,
1205
+ 20,
1206
+ 50,
1207
+ 100
1208
+ ];
1209
+ function xe({ pageIndex: e, pageCount: t, pageSize: n, totalRows: r, onPageChange: i, onPageSizeChange: a }) {
1210
+ let o = r === 0 ? 0 : e * n + 1, s = Math.min((e + 1) * n, r);
1211
+ return /* @__PURE__ */ (0, j.jsxs)("div", {
1212
+ className: H.pagination,
1213
+ role: "navigation",
1214
+ "aria-label": "Pagination",
1215
+ children: [/* @__PURE__ */ (0, j.jsx)("span", {
1216
+ className: H.paginationInfo,
1217
+ children: r === 0 ? "No results" : `${o}–${s} of ${r}`
1218
+ }), /* @__PURE__ */ (0, j.jsxs)("div", {
1219
+ className: H.paginationControls,
1220
+ children: [
1221
+ /* @__PURE__ */ (0, j.jsxs)("label", {
1222
+ className: H.pageSizeLabel,
1223
+ children: ["Rows", /* @__PURE__ */ (0, j.jsx)("select", {
1224
+ className: H.pageSizeSelect,
1225
+ value: n,
1226
+ onChange: (e) => a(Number(e.target.value)),
1227
+ "aria-label": "Rows per page",
1228
+ children: be.map((e) => /* @__PURE__ */ (0, j.jsx)("option", {
1229
+ value: e,
1230
+ children: e
1231
+ }, e))
1232
+ })]
1233
+ }),
1234
+ /* @__PURE__ */ (0, j.jsx)("button", {
1235
+ className: H.paginationBtn,
1236
+ disabled: e === 0,
1237
+ onClick: () => i(0),
1238
+ "aria-label": "First page",
1239
+ children: "«"
1240
+ }),
1241
+ /* @__PURE__ */ (0, j.jsx)("button", {
1242
+ className: H.paginationBtn,
1243
+ disabled: e === 0,
1244
+ onClick: () => i(e - 1),
1245
+ "aria-label": "Previous page",
1246
+ children: "‹"
1247
+ }),
1248
+ /* @__PURE__ */ (0, j.jsxs)("span", {
1249
+ className: H.paginationInfo,
1250
+ "aria-current": "page",
1251
+ children: [
1252
+ e + 1,
1253
+ " / ",
1254
+ t
1255
+ ]
1256
+ }),
1257
+ /* @__PURE__ */ (0, j.jsx)("button", {
1258
+ className: H.paginationBtn,
1259
+ disabled: e >= t - 1,
1260
+ onClick: () => i(e + 1),
1261
+ "aria-label": "Next page",
1262
+ children: "›"
1263
+ }),
1264
+ /* @__PURE__ */ (0, j.jsx)("button", {
1265
+ className: H.paginationBtn,
1266
+ disabled: e >= t - 1,
1267
+ onClick: () => i(t - 1),
1268
+ "aria-label": "Last page",
1269
+ children: "»"
1270
+ })
1271
+ ]
1272
+ })]
1273
+ });
1274
+ }
1275
+ var U = {
1276
+ toolbar: "_toolbar_12gxd_1",
1277
+ selectionCount: "_selectionCount_12gxd_12",
1278
+ clearBtn: "_clearBtn_12gxd_21",
1279
+ exportBtn: "_exportBtn_12gxd_36"
1280
+ };
1281
+ //#endregion
1282
+ //#region src/components/DataGrid/ui/Toolbar.tsx
1283
+ function Se({ selectedRows: e, selectedIds: t, processedRows: n, gridState: r, clearSelection: i, enableCsvExport: a, onExport: o, toolbarActions: s, columns: c }) {
1284
+ if (!(a || s || e.length > 0)) return null;
1285
+ let l = {
1286
+ selectedRows: e,
1287
+ selectedIds: t,
1288
+ processedRows: n,
1289
+ gridState: r,
1290
+ clearSelection: i
1291
+ };
1292
+ return /* @__PURE__ */ (0, j.jsxs)("div", {
1293
+ className: U.toolbar,
1294
+ role: "toolbar",
1295
+ "aria-label": "Grid toolbar",
1296
+ children: [
1297
+ e.length > 0 && /* @__PURE__ */ (0, j.jsxs)("span", {
1298
+ className: U.selectionCount,
1299
+ "aria-live": "polite",
1300
+ "aria-atomic": "true",
1301
+ children: [
1302
+ e.length,
1303
+ " row",
1304
+ e.length === 1 ? "" : "s",
1305
+ " selected",
1306
+ /* @__PURE__ */ (0, j.jsx)("button", {
1307
+ type: "button",
1308
+ className: U.clearBtn,
1309
+ onClick: i,
1310
+ "aria-label": "Clear selection",
1311
+ children: "×"
1312
+ })
1313
+ ]
1314
+ }),
1315
+ s?.(l),
1316
+ a && /* @__PURE__ */ (0, j.jsx)("button", {
1317
+ type: "button",
1318
+ className: U.exportBtn,
1319
+ onClick: o,
1320
+ "aria-label": "Export to CSV",
1321
+ children: "Export CSV"
1322
+ })
1323
+ ]
1324
+ });
1325
+ }
1326
+ var W = {
1327
+ menu: "_menu_1efgk_1",
1328
+ heading: "_heading_1efgk_12",
1329
+ list: "_list_1efgk_22",
1330
+ item: "_item_1efgk_28",
1331
+ label: "_label_1efgk_32",
1332
+ checkbox: "_checkbox_1efgk_46"
1333
+ };
1334
+ //#endregion
1335
+ //#region src/components/DataGrid/ui/ColumnMenu.tsx
1336
+ function Ce({ columns: e, columnVisibility: t, anchorRect: n, onToggleColumn: i, onClose: a }) {
1337
+ let o = c(null);
1338
+ r(() => {
1339
+ function e(e) {
1340
+ o.current && !o.current.contains(e.target) && a();
1341
+ }
1342
+ function t(e) {
1343
+ e.key === "Escape" && a();
1344
+ }
1345
+ function n() {
1346
+ a();
1347
+ }
1348
+ return document.addEventListener("pointerdown", e), document.addEventListener("keydown", t), window.addEventListener("scroll", n, {
1349
+ capture: !0,
1350
+ passive: !0
1351
+ }), () => {
1352
+ document.removeEventListener("pointerdown", e), document.removeEventListener("keydown", t), window.removeEventListener("scroll", n, { capture: !0 });
1353
+ };
1354
+ }, [a]);
1355
+ let s = e.filter((e) => e.hideable !== !1);
1356
+ return d(/* @__PURE__ */ (0, j.jsxs)("div", {
1357
+ ref: o,
1358
+ className: W.menu,
1359
+ style: {
1360
+ top: n.bottom + 2,
1361
+ left: n.left
1362
+ },
1363
+ role: "dialog",
1364
+ "aria-label": "Column visibility",
1365
+ children: [/* @__PURE__ */ (0, j.jsx)("p", {
1366
+ className: W.heading,
1367
+ children: "Columns"
1368
+ }), /* @__PURE__ */ (0, j.jsx)("ul", {
1369
+ className: W.list,
1370
+ role: "list",
1371
+ children: s.map((e) => {
1372
+ let n = t[e.id] !== !1 && !(e.defaultHidden && t[e.id] === void 0);
1373
+ return /* @__PURE__ */ (0, j.jsx)("li", {
1374
+ className: W.item,
1375
+ children: /* @__PURE__ */ (0, j.jsxs)("label", {
1376
+ className: W.label,
1377
+ children: [/* @__PURE__ */ (0, j.jsx)("input", {
1378
+ type: "checkbox",
1379
+ className: W.checkbox,
1380
+ checked: n,
1381
+ onChange: () => i(e.id, !n)
1382
+ }), e.header]
1383
+ })
1384
+ }, e.id);
1385
+ })
1386
+ })]
1387
+ }), document.body);
1388
+ }
1389
+ //#endregion
1390
+ //#region src/components/DataGrid/ai/schema.ts
1391
+ var G = f.object({
1392
+ sorts: f.array(f.object({
1393
+ columnId: f.string(),
1394
+ direction: f.enum(["asc", "desc"])
1395
+ })).optional(),
1396
+ filters: f.array(f.object({
1397
+ columnId: f.string(),
1398
+ operator: f.enum([
1399
+ "eq",
1400
+ "contains",
1401
+ "gt",
1402
+ "gte",
1403
+ "lt",
1404
+ "lte",
1405
+ "between",
1406
+ "in"
1407
+ ]),
1408
+ value: f.union([
1409
+ f.string(),
1410
+ f.number(),
1411
+ f.array(f.union([f.string(), f.number()]))
1412
+ ])
1413
+ })).optional(),
1414
+ grouping: f.array(f.string()).optional(),
1415
+ reset: f.boolean().optional(),
1416
+ explanation: f.string()
1417
+ });
1418
+ //#endregion
1419
+ //#region src/components/DataGrid/ai/aiClient.ts
1420
+ async function we(e, t, n, r, i) {
1421
+ let a = await fetch(e, {
1422
+ method: "POST",
1423
+ headers: { "Content-Type": "application/json" },
1424
+ body: JSON.stringify({
1425
+ prompt: t,
1426
+ columns: n.map((e) => ({
1427
+ id: e.id,
1428
+ header: e.header,
1429
+ filterType: e.filterType
1430
+ })),
1431
+ currentState: r
1432
+ }),
1433
+ signal: i
1434
+ });
1435
+ if (!a.ok) {
1436
+ let e = await a.text().catch(() => ""), t = e;
1437
+ try {
1438
+ t = JSON.parse(e).error ?? e;
1439
+ } catch {}
1440
+ throw Error(t || `Request failed: ${a.status}`);
1441
+ }
1442
+ let o = await a.json();
1443
+ return G.parse(o);
1444
+ }
1445
+ var K = {
1446
+ aiBar: "_aiBar_13i5a_1",
1447
+ form: "_form_13i5a_10",
1448
+ icon: "_icon_13i5a_16",
1449
+ input: "_input_13i5a_24",
1450
+ submitBtn: "_submitBtn_13i5a_54",
1451
+ spinner: "_spinner_13i5a_82",
1452
+ spin: "_spin_13i5a_82",
1453
+ resultRow: "_resultRow_13i5a_96",
1454
+ explanation: "_explanation_13i5a_103",
1455
+ clearBtn: "_clearBtn_13i5a_111",
1456
+ error: "_error_13i5a_130"
1457
+ };
1458
+ //#endregion
1459
+ //#region src/components/DataGrid/ui/AiBar.tsx
1460
+ function Te({ endpoint: e, placeholder: t, columns: r, gridState: i, onCommand: a, onReset: o }) {
1461
+ let [s, u] = l(""), [d, f] = l("idle"), [p, m] = l(null), [h, g] = l(null), _ = c(null), v = n(async (t) => {
1462
+ t.preventDefault();
1463
+ let n = s.trim();
1464
+ if (!n || d === "loading") return;
1465
+ _.current?.abort();
1466
+ let o = new AbortController();
1467
+ _.current = o, f("loading"), m(null), g(null);
1468
+ try {
1469
+ let t = await we(e, n, r, i, o.signal);
1470
+ a(t), m(t.explanation), f("idle"), u("");
1471
+ } catch (e) {
1472
+ if (e.name === "AbortError") return;
1473
+ g(e.message ?? "Request failed"), f("error");
1474
+ }
1475
+ }, [
1476
+ s,
1477
+ d,
1478
+ e,
1479
+ r,
1480
+ i,
1481
+ a
1482
+ ]);
1483
+ return /* @__PURE__ */ (0, j.jsxs)("div", {
1484
+ className: K.aiBar,
1485
+ children: [
1486
+ /* @__PURE__ */ (0, j.jsxs)("form", {
1487
+ className: K.form,
1488
+ onSubmit: v,
1489
+ role: "search",
1490
+ children: [
1491
+ /* @__PURE__ */ (0, j.jsx)("span", {
1492
+ className: K.icon,
1493
+ "aria-hidden": "true",
1494
+ children: "✦"
1495
+ }),
1496
+ /* @__PURE__ */ (0, j.jsx)("input", {
1497
+ className: K.input,
1498
+ type: "text",
1499
+ value: s,
1500
+ onChange: (e) => u(e.target.value),
1501
+ placeholder: t ?? "Ask the grid… e.g. \"show completed orders over £500\"",
1502
+ disabled: d === "loading",
1503
+ "aria-label": "AI grid command",
1504
+ autoComplete: "off",
1505
+ spellCheck: !1
1506
+ }),
1507
+ /* @__PURE__ */ (0, j.jsx)("button", {
1508
+ type: "submit",
1509
+ className: K.submitBtn,
1510
+ disabled: !s.trim() || d === "loading",
1511
+ "aria-label": "Send AI command",
1512
+ children: d === "loading" ? /* @__PURE__ */ (0, j.jsx)("span", {
1513
+ className: K.spinner,
1514
+ "aria-hidden": "true"
1515
+ }) : "Ask"
1516
+ })
1517
+ ]
1518
+ }),
1519
+ p && d === "idle" && /* @__PURE__ */ (0, j.jsxs)("div", {
1520
+ className: K.resultRow,
1521
+ children: [/* @__PURE__ */ (0, j.jsx)("p", {
1522
+ className: K.explanation,
1523
+ role: "status",
1524
+ "aria-live": "polite",
1525
+ children: p
1526
+ }), /* @__PURE__ */ (0, j.jsx)("button", {
1527
+ type: "button",
1528
+ className: K.clearBtn,
1529
+ onClick: () => {
1530
+ m(null), o();
1531
+ },
1532
+ children: "Clear"
1533
+ })]
1534
+ }),
1535
+ h && d === "error" && /* @__PURE__ */ (0, j.jsx)("p", {
1536
+ className: K.error,
1537
+ role: "alert",
1538
+ children: h
1539
+ })
1540
+ ]
1541
+ });
1542
+ }
1543
+ //#endregion
1544
+ //#region src/components/DataGrid/DataGrid.tsx
1545
+ function Ee({ data: e, columns: t, getRowId: i, onRowClick: s, onCellClick: d, dataMode: f = "server", pageSize: p = 20, rowCount: m, loading: h, onStateChange: g, selectionMode: y = "none", selectAllScope: b = "page", onSelectionChange: x, enableCsvExport: ee, csvFilename: S = "export.csv", enableColumnResize: C, enableColumnVisibility: E, toolbarActions: O, emptyState: k, className: A, initialState: M, fetchFilterOptions: N, ai: P, height: F, estimatedRowHeight: se = 41, onCellEdit: I }, ce) {
1546
+ let { state: L, dispatch: R } = v(o(() => _(M, p), [])), [z, ue] = l(null), [de, B] = l(null), [fe, pe] = l(null), [V, he] = l(null), ge = n((e, t) => {
1547
+ ue((n) => n === e ? (B(null), null) : (B(t), e));
1548
+ }, []), _e = n((e, t) => {
1549
+ pe((n) => n === e ? (he(null), null) : (he(t), e));
1550
+ }, []), be = n((e, t) => {
1551
+ R({
1552
+ type: "SET_COLUMN_VISIBILITY",
1553
+ columnId: e,
1554
+ visible: t
1555
+ });
1556
+ }, [R]), U = n((e, t, n) => {
1557
+ let r = t === null || t === "" || Array.isArray(t) && t.length === 0, i;
1558
+ if (r) i = L.filters.filter((t) => t.columnId !== e);
1559
+ else {
1560
+ let r = {
1561
+ columnId: e,
1562
+ operator: n,
1563
+ value: t
1564
+ }, a = L.filters.findIndex((t) => t.columnId === e);
1565
+ i = a >= 0 ? L.filters.map((e, t) => t === a ? r : e) : [...L.filters, r];
1566
+ }
1567
+ R({
1568
+ type: "SET_FILTER",
1569
+ filters: i
1570
+ });
1571
+ }, [L.filters, R]), W = n((e, t) => {
1572
+ let n = L.sorts.find((t) => t.columnId === e), r;
1573
+ if (n) r = n.direction === "asc" ? L.sorts.map((t) => t.columnId === e ? {
1574
+ ...t,
1575
+ direction: "desc"
1576
+ } : t) : L.sorts.filter((t) => t.columnId !== e);
1577
+ else {
1578
+ let n = {
1579
+ columnId: e,
1580
+ direction: "asc"
1581
+ };
1582
+ r = t ? [...L.sorts, n] : [n];
1583
+ }
1584
+ R({
1585
+ type: "SET_SORT",
1586
+ sorts: r
1587
+ });
1588
+ }, [L.sorts, R]), G = o(() => {
1589
+ let e = /* @__PURE__ */ new Set();
1590
+ for (let n of t) {
1591
+ let t = L.columnVisibility[n.id] === !1, r = n.defaultHidden && L.columnVisibility[n.id] === void 0;
1592
+ !t && !r && e.add(n.id);
1593
+ }
1594
+ return e;
1595
+ }, [t, L.columnVisibility]), we = o(() => {
1596
+ if (f !== "client") return {};
1597
+ let n = {};
1598
+ for (let r of t) if (r.filterType === "select" && !r.filterOptions) {
1599
+ let t = /* @__PURE__ */ new Set();
1600
+ for (let n of e) {
1601
+ let e = r.accessor(n);
1602
+ e != null && e !== "" && t.add(String(e));
1603
+ }
1604
+ n[r.id] = Array.from(t).sort();
1605
+ }
1606
+ return n;
1607
+ }, [
1608
+ e,
1609
+ t,
1610
+ f
1611
+ ]), [K, Ee] = l({});
1612
+ r(() => {
1613
+ if (!N) return;
1614
+ let e = t.filter((e) => e.filterable === !0 && e.filterType === "select" && !e.filterOptions);
1615
+ for (let t of e) N(t.id).then((e) => {
1616
+ Ee((n) => ({
1617
+ ...n,
1618
+ [t.id]: e
1619
+ }));
1620
+ }).catch(() => {});
1621
+ }, [N]);
1622
+ let q = o(() => f === "server" ? e : te(e, t, L.filters), [
1623
+ e,
1624
+ t,
1625
+ L.filters,
1626
+ f
1627
+ ]), J = o(() => f === "server" ? e.map((e) => ({
1628
+ _type: "data",
1629
+ row: e
1630
+ })) : ne(e, t, L), [
1631
+ e,
1632
+ t,
1633
+ L,
1634
+ f
1635
+ ]), Y = o(() => f === "server" ? J : w(J, L.pagination), [
1636
+ J,
1637
+ L.pagination,
1638
+ f
1639
+ ]), De = f === "server" ? m ?? 0 : J.length, Oe = re(De, L.pagination.pageSize), ke = o(() => T(L.selection, e, i), [
1640
+ L.selection,
1641
+ e,
1642
+ i
1643
+ ]), Ae = o(() => y === "none" ? [] : Y.flatMap((e) => e._type === "data" ? [i(e.row)] : []), [
1644
+ Y,
1645
+ y,
1646
+ i
1647
+ ]), je = o(() => y === "none" ? [] : q.map(i), [
1648
+ q,
1649
+ y,
1650
+ i
1651
+ ]), X = b === "filtered" ? je : Ae, Z = X.length > 0 && X.every((e) => L.selection.has(e)), Me = !Z && X.some((e) => L.selection.has(e)), Ne = n(() => {
1652
+ R(Z ? { type: "CLEAR_SELECTION" } : {
1653
+ type: "SELECT_ALL",
1654
+ rowIds: X
1655
+ });
1656
+ }, [
1657
+ Z,
1658
+ X,
1659
+ R
1660
+ ]), Pe = n((e) => {
1661
+ R({
1662
+ type: "TOGGLE_SELECT",
1663
+ rowId: e,
1664
+ mode: y === "single" ? "single" : "multiple"
1665
+ });
1666
+ }, [y, R]), Fe = c(x);
1667
+ r(() => {
1668
+ Fe.current = x;
1669
+ }, [x]);
1670
+ let Ie = c("");
1671
+ r(() => {
1672
+ let t = JSON.stringify(Array.from(L.selection).sort());
1673
+ if (t !== Ie.current && (Ie.current = t, Fe.current)) {
1674
+ let t = T(L.selection, e, i);
1675
+ Fe.current(t, Array.from(L.selection));
1676
+ }
1677
+ }, [
1678
+ L.selection,
1679
+ e,
1680
+ i
1681
+ ]);
1682
+ let Le = c(g);
1683
+ r(() => {
1684
+ Le.current = g;
1685
+ }, [g]);
1686
+ let Re = c(null);
1687
+ r(() => {
1688
+ if (f !== "server") return;
1689
+ let e = JSON.stringify({
1690
+ sorts: L.sorts,
1691
+ filters: L.filters,
1692
+ grouping: L.grouping,
1693
+ pagination: L.pagination
1694
+ });
1695
+ e !== Re.current && (Re.current = e, Le.current?.(L));
1696
+ }, [L, f]);
1697
+ let ze = n((n) => {
1698
+ ae(ie(n?.selectedOnly ? T(L.selection, e, i) : q, t), S);
1699
+ }, [
1700
+ L.selection,
1701
+ e,
1702
+ i,
1703
+ q,
1704
+ t,
1705
+ S
1706
+ ]), Be = o(() => new Set(t.map((e) => e.id)), [t]), Ve = n((e) => {
1707
+ D(e, Be).forEach((e) => R(e));
1708
+ }, [Be, R]), [He, Ue] = l(null), We = n((e, t) => {
1709
+ Ue({
1710
+ rowId: e,
1711
+ columnId: t
1712
+ });
1713
+ }, []), Ge = n((e, t, n) => {
1714
+ I?.(e, t, n), Ue(null);
1715
+ }, [I]), Ke = n(() => {
1716
+ Ue(null);
1717
+ }, []);
1718
+ a(ce, () => ({
1719
+ getSelectedRows: () => T(L.selection, e, i),
1720
+ getProcessedRows: () => q,
1721
+ getGridState: () => L,
1722
+ clearSelection: () => R({ type: "CLEAR_SELECTION" }),
1723
+ exportCsv: ze,
1724
+ setState: (e) => {
1725
+ e.sorts && R({
1726
+ type: "SET_SORT",
1727
+ sorts: e.sorts
1728
+ }), e.filters && R({
1729
+ type: "SET_FILTER",
1730
+ filters: e.filters
1731
+ }), e.grouping && R({
1732
+ type: "SET_GROUPING",
1733
+ grouping: e.grouping
1734
+ });
1735
+ }
1736
+ }));
1737
+ let Q = t.filter((e) => G.has(e.id)), qe = F !== void 0, Je = c(null), Ye = u({
1738
+ count: qe ? Y.length : 0,
1739
+ getScrollElement: () => qe ? Je.current : null,
1740
+ estimateSize: () => se,
1741
+ overscan: 8
1742
+ }), $ = Ye.getVirtualItems(), Xe = o(() => {
1743
+ let e = [];
1744
+ y !== "none" && e.push(40);
1745
+ for (let t of Q) e.push(L.columnSizing[t.id] ?? t.width ?? 150);
1746
+ return e;
1747
+ }, [
1748
+ Q,
1749
+ y,
1750
+ L.columnSizing
1751
+ ]), Ze = o(() => Xe.reduce((e, t) => e + t, 0), [Xe]), Qe = o(() => ({ minWidth: Ze }), [Ze]), $e = /* @__PURE__ */ (0, j.jsxs)("colgroup", { children: [y !== "none" && /* @__PURE__ */ (0, j.jsx)("col", { style: {
1752
+ width: 40,
1753
+ minWidth: 40,
1754
+ maxWidth: 40
1755
+ } }), Q.map((e, t) => {
1756
+ let n = L.columnSizing[e.id] ?? e.width ?? 150;
1757
+ return /* @__PURE__ */ (0, j.jsx)("col", { style: t === Q.length - 1 ? void 0 : { width: n } }, e.id);
1758
+ })] }), et = /* @__PURE__ */ (0, j.jsxs)("tr", { children: [y !== "none" && /* @__PURE__ */ (0, j.jsx)(ve, {
1759
+ checked: Z,
1760
+ indeterminate: Me,
1761
+ onChange: Ne,
1762
+ ariaLabel: Z ? "Deselect all" : "Select all",
1763
+ isHeader: !0
1764
+ }), Q.map((e) => {
1765
+ let n = L.sorts.findIndex((t) => t.columnId === e.id), r = fe === e.id, i = L.filters.some((t) => t.columnId === e.id), a = z === e.id;
1766
+ return /* @__PURE__ */ (0, j.jsx)(oe, {
1767
+ column: e,
1768
+ sortEntry: n >= 0 ? L.sorts[n] : void 0,
1769
+ sortIndex: n,
1770
+ totalSorts: L.sorts.length,
1771
+ width: L.columnSizing[e.id],
1772
+ onSort: W,
1773
+ enableResize: C,
1774
+ onResize: (e, t) => R({
1775
+ type: "SET_COLUMN_SIZE",
1776
+ columnId: e,
1777
+ width: t
1778
+ }),
1779
+ enableMenu: E,
1780
+ menuOpen: r,
1781
+ onToggleMenu: _e,
1782
+ filterActive: i,
1783
+ filterPanelOpen: a,
1784
+ onToggleFilter: e.filterable === !0 ? ge : void 0,
1785
+ columnMenuSlot: E && r && V ? /* @__PURE__ */ (0, j.jsx)(Ce, {
1786
+ columns: t,
1787
+ columnVisibility: L.columnVisibility,
1788
+ anchorRect: V,
1789
+ onToggleColumn: be,
1790
+ onClose: () => pe(null)
1791
+ }) : null
1792
+ }, e.id);
1793
+ })] }), tt = () => {
1794
+ if (Y.length === 0) return /* @__PURE__ */ (0, j.jsx)("tr", { children: /* @__PURE__ */ (0, j.jsx)("td", {
1795
+ colSpan: Q.length + (y === "none" ? 0 : 1),
1796
+ children: /* @__PURE__ */ (0, j.jsx)("div", {
1797
+ className: H.emptyState,
1798
+ children: k ?? "No data"
1799
+ })
1800
+ }) });
1801
+ if (!qe) return Y.map((e, n) => {
1802
+ if (e._type === "group") return /* @__PURE__ */ (0, j.jsx)(me, {
1803
+ row: e,
1804
+ columns: t,
1805
+ visibleColumnIds: G,
1806
+ onToggle: () => R({
1807
+ type: "TOGGLE_EXPAND",
1808
+ groupId: e.id
1809
+ })
1810
+ }, e.id);
1811
+ let r = i(e.row);
1812
+ return /* @__PURE__ */ (0, j.jsx)(ye, {
1813
+ row: e.row,
1814
+ rowIndex: n,
1815
+ rowId: r,
1816
+ columns: t,
1817
+ visibleColumnIds: G,
1818
+ selectionMode: y,
1819
+ isSelected: L.selection.has(r),
1820
+ onToggleSelect: Pe,
1821
+ onRowClick: s,
1822
+ onCellClick: d,
1823
+ editingColumnId: He?.rowId === r ? He.columnId : void 0,
1824
+ onStartEdit: I ? We : void 0,
1825
+ onCommitEdit: I ? Ge : void 0,
1826
+ onCancelEdit: Ke
1827
+ }, r);
1828
+ });
1829
+ let e = $.length > 0 ? $[0]?.start ?? 0 : 0, n = $.length > 0 ? Ye.getTotalSize() - ($[$.length - 1]?.end ?? 0) : 0;
1830
+ return /* @__PURE__ */ (0, j.jsxs)(j.Fragment, { children: [
1831
+ e > 0 && /* @__PURE__ */ (0, j.jsx)("tr", { children: /* @__PURE__ */ (0, j.jsx)("td", {
1832
+ style: {
1833
+ height: e,
1834
+ padding: 0,
1835
+ border: "none"
1836
+ },
1837
+ colSpan: Xe.length
1838
+ }) }),
1839
+ $.map((e) => {
1840
+ let n = Y[e.index];
1841
+ if (n._type === "group") return /* @__PURE__ */ (0, j.jsx)(me, {
1842
+ row: n,
1843
+ columns: t,
1844
+ visibleColumnIds: G,
1845
+ onToggle: () => R({
1846
+ type: "TOGGLE_EXPAND",
1847
+ groupId: n.id
1848
+ })
1849
+ }, n.id);
1850
+ let r = i(n.row);
1851
+ return /* @__PURE__ */ (0, j.jsx)(ye, {
1852
+ row: n.row,
1853
+ rowIndex: e.index,
1854
+ rowId: r,
1855
+ columns: t,
1856
+ visibleColumnIds: G,
1857
+ selectionMode: y,
1858
+ isSelected: L.selection.has(r),
1859
+ onToggleSelect: Pe,
1860
+ onRowClick: s,
1861
+ onCellClick: d,
1862
+ editingColumnId: He?.rowId === r ? He.columnId : void 0,
1863
+ onStartEdit: I ? We : void 0,
1864
+ onCommitEdit: I ? Ge : void 0,
1865
+ onCancelEdit: Ke
1866
+ }, r);
1867
+ }),
1868
+ n > 0 && /* @__PURE__ */ (0, j.jsx)("tr", { children: /* @__PURE__ */ (0, j.jsx)("td", {
1869
+ style: {
1870
+ height: n,
1871
+ padding: 0,
1872
+ border: "none"
1873
+ },
1874
+ colSpan: Xe.length
1875
+ }) })
1876
+ ] });
1877
+ }, nt = typeof F == "number" ? `${F}px` : F;
1878
+ return /* @__PURE__ */ (0, j.jsxs)("div", {
1879
+ className: [H.wrapper, A].filter(Boolean).join(" "),
1880
+ children: [
1881
+ /* @__PURE__ */ (0, j.jsx)(Se, {
1882
+ selectedRows: ke,
1883
+ selectedIds: Array.from(L.selection),
1884
+ processedRows: q,
1885
+ gridState: L,
1886
+ clearSelection: () => R({ type: "CLEAR_SELECTION" }),
1887
+ enableCsvExport: ee,
1888
+ onExport: () => ze(),
1889
+ toolbarActions: O,
1890
+ columns: t
1891
+ }),
1892
+ P && /* @__PURE__ */ (0, j.jsx)(Te, {
1893
+ endpoint: P.endpoint,
1894
+ placeholder: P.placeholder,
1895
+ columns: t,
1896
+ gridState: L,
1897
+ onCommand: Ve,
1898
+ onReset: () => R({ type: "RESET" })
1899
+ }),
1900
+ h && /* @__PURE__ */ (0, j.jsx)("div", {
1901
+ className: H.loadingOverlay,
1902
+ role: "status",
1903
+ "aria-label": "Loading",
1904
+ children: /* @__PURE__ */ (0, j.jsx)("div", { className: H.spinner })
1905
+ }),
1906
+ qe ? /* @__PURE__ */ (0, j.jsxs)("div", {
1907
+ className: H.vsOuter,
1908
+ children: [/* @__PURE__ */ (0, j.jsxs)("table", {
1909
+ className: H.table,
1910
+ style: Qe,
1911
+ children: [$e, /* @__PURE__ */ (0, j.jsx)("thead", { children: et })]
1912
+ }), /* @__PURE__ */ (0, j.jsx)("div", {
1913
+ ref: Je,
1914
+ className: H.vsBody,
1915
+ style: {
1916
+ height: nt,
1917
+ overflowY: "auto",
1918
+ overflowX: "clip",
1919
+ minWidth: Ze
1920
+ },
1921
+ children: /* @__PURE__ */ (0, j.jsxs)("table", {
1922
+ className: H.table,
1923
+ role: "grid",
1924
+ style: Qe,
1925
+ children: [$e, /* @__PURE__ */ (0, j.jsx)("tbody", { children: tt() })]
1926
+ })
1927
+ })]
1928
+ }) : /* @__PURE__ */ (0, j.jsx)("div", {
1929
+ className: H.tableContainer,
1930
+ children: /* @__PURE__ */ (0, j.jsxs)("table", {
1931
+ className: H.table,
1932
+ role: "grid",
1933
+ style: Qe,
1934
+ children: [
1935
+ $e,
1936
+ /* @__PURE__ */ (0, j.jsx)("thead", { children: et }),
1937
+ /* @__PURE__ */ (0, j.jsx)("tbody", { children: tt() })
1938
+ ]
1939
+ })
1940
+ }),
1941
+ z !== null && de !== null && (() => {
1942
+ let e = t.find((e) => e.id === z);
1943
+ return e ? /* @__PURE__ */ (0, j.jsx)(le, {
1944
+ column: e,
1945
+ anchorRect: de,
1946
+ filterEntry: L.filters.find((e) => e.columnId === z),
1947
+ filterOptions: we[z] ?? K[z],
1948
+ onChange: (e, t) => U(z, e, t),
1949
+ onClose: () => {
1950
+ ue(null), B(null);
1951
+ }
1952
+ }) : null;
1953
+ })(),
1954
+ /* @__PURE__ */ (0, j.jsx)(xe, {
1955
+ pageIndex: L.pagination.pageIndex,
1956
+ pageCount: Oe,
1957
+ pageSize: L.pagination.pageSize,
1958
+ totalRows: De,
1959
+ onPageChange: (e) => R({
1960
+ type: "SET_PAGE",
1961
+ pageIndex: e
1962
+ }),
1963
+ onPageSizeChange: (e) => R({
1964
+ type: "SET_PAGE_SIZE",
1965
+ pageSize: e
1966
+ })
1967
+ })
1968
+ ]
1969
+ });
1970
+ }
1971
+ var q = t(Ee);
1972
+ //#endregion
1973
+ export { q as DataGrid };