@nice2dev/ui 1.3.9 → 1.3.11

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 (62) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +16 -18
  3. package/dist/NiceColorPicker-BLwYNSXJ.cjs +1 -0
  4. package/dist/NiceColorPicker-DS59tNkP.js +552 -0
  5. package/dist/NiceDataGrid-CL2_7fS7.cjs +10 -0
  6. package/dist/NiceDataGrid-CpJrRN_H.js +2269 -0
  7. package/dist/NiceForm-BQj-K7p7.cjs +1 -0
  8. package/dist/NiceForm-HQ4h7hX_.js +5023 -0
  9. package/dist/NiceGantt-BygumlaY.cjs +1 -0
  10. package/dist/NiceGantt-DTC7OH-v.js +334 -0
  11. package/dist/NiceHtmlEditor-BtpuaLln.js +901 -0
  12. package/dist/NiceHtmlEditor-C1OVtLQ6.cjs +10 -0
  13. package/dist/NiceMention-CVxxCVtQ.js +11668 -0
  14. package/dist/NiceMention-Te66Oid1.cjs +430 -0
  15. package/dist/NiceModuleLifecyclePanel-DCrFyUH8.cjs +1 -0
  16. package/dist/NiceModuleLifecyclePanel-Mt80MdET.js +7441 -0
  17. package/dist/NicePagination-CKsAP38Q.cjs +1 -0
  18. package/dist/NicePagination-zOed5QxG.js +202 -0
  19. package/dist/NicePivotGrid-Clue9FM5.js +1184 -0
  20. package/dist/NicePivotGrid-Cnkr9WkC.cjs +152 -0
  21. package/dist/NicePropertyGrid.doc-BWNyWrWq.cjs +7 -0
  22. package/dist/NicePropertyGrid.doc-C_I3F4w8.js +31 -0
  23. package/dist/NiceSavedQueryPanel-NgG58w6i.js +6226 -0
  24. package/dist/NiceSavedQueryPanel-lTWY2plm.cjs +587 -0
  25. package/dist/NiceScheduler-BWwqFKEc.js +1712 -0
  26. package/dist/NiceScheduler-DqWEJU7g.cjs +5 -0
  27. package/dist/NiceSelect-BNPXs6FQ.cjs +1 -0
  28. package/dist/NiceSelect-DEruWHan.js +495 -0
  29. package/dist/NiceWindow-D3V7A69Q.js +2247 -0
  30. package/dist/NiceWindow-pgR4c-kQ.cjs +1 -0
  31. package/dist/core-lazy-Bjdu111n.js +351 -0
  32. package/dist/core-lazy-Bx_8BOlG.cjs +1 -0
  33. package/dist/data.cjs +1 -1
  34. package/dist/data.d.ts +47 -6
  35. package/dist/data.mjs +3 -3
  36. package/dist/devops-CqhA0rjL.js +9130 -0
  37. package/dist/devops-cgRBnZVX.cjs +18 -0
  38. package/dist/devops.cjs +1 -1
  39. package/dist/devops.mjs +1 -1
  40. package/dist/editors.cjs +1 -1
  41. package/dist/editors.mjs +7 -7
  42. package/dist/feedback.cjs +1 -1
  43. package/dist/feedback.mjs +1 -1
  44. package/dist/index.cjs +137 -151
  45. package/dist/index.css +1 -1
  46. package/dist/index.d.ts +113 -50
  47. package/dist/index.mjs +16556 -16423
  48. package/dist/lazy.cjs +1 -1
  49. package/dist/lazy.mjs +15 -15
  50. package/dist/navigation.cjs +1 -1
  51. package/dist/navigation.d.ts +2 -0
  52. package/dist/navigation.mjs +3 -3
  53. package/dist/no-code-BQqK8mvU.cjs +331 -0
  54. package/dist/no-code-Cppb-xz3.js +8320 -0
  55. package/dist/no-code.cjs +1 -1
  56. package/dist/no-code.mjs +1 -1
  57. package/dist/overlays.cjs +1 -1
  58. package/dist/overlays.mjs +1 -1
  59. package/dist/pickerCommons-BA3-D5RC.js +663 -0
  60. package/dist/pickerCommons-KrBqCBDn.cjs +1 -0
  61. package/dist/style.css +1 -1
  62. package/package.json +4 -4
@@ -0,0 +1,2269 @@
1
+ import { jsxs as p, jsx as i, Fragment as Dt } from "react/jsx-runtime";
2
+ import { useNiceTranslation as Mt, useControllableState as Jr, NiceTutorialButton as Xr, resolveTutorial as Yr, NiceIcon as $, useNiceAccessMode as Qr, useComponentDisplayStyle as Zr, useComponentDisplayClass as ea, useNiceDataSource as ta, matchesFilterGroup as na, useIntent as ia, useInputHints as ra, clickOnActivationKey as xn } from "@nice2dev/ui-core";
3
+ import zt, { useState as x, useCallback as b, useMemo as R, useRef as Z, useEffect as ee, useId as aa, useLayoutEffect as wi } from "react";
4
+ import { createPortal as Nn } from "react-dom";
5
+ import { d as la } from "./NiceForm-HQ4h7hX_.js";
6
+ import { a as sa } from "./devops-CqhA0rjL.js";
7
+ import { N as oa } from "./NiceModal-CU9FqzIH.js";
8
+ import { N as ca } from "./NicePagination-zOed5QxG.js";
9
+ import { u as Ci } from "./NiceSelect-DEruWHan.js";
10
+ const da = [], ua = [
11
+ {
12
+ target: ".nice-filterbuilder",
13
+ titleKey: "tutorial.filterBuilder.intro.title",
14
+ title: "Filter builder",
15
+ contentKey: "tutorial.filterBuilder.intro.content",
16
+ content: "Build complex AND/OR filter trees: add conditions and nested groups, choose fields and operators, and save reusable presets.",
17
+ placement: "auto"
18
+ }
19
+ ], fa = [
20
+ { value: "=", label: "Equals" },
21
+ { value: "<>", label: "Not Equals" },
22
+ { value: "<", label: "Less Than" },
23
+ { value: "<=", label: "Less or Equal" },
24
+ { value: ">", label: "Greater Than" },
25
+ { value: ">=", label: "Greater or Equal" },
26
+ { value: "contains", label: "Contains" },
27
+ { value: "notcontains", label: "Not Contains" },
28
+ { value: "startswith", label: "Starts With" },
29
+ { value: "endswith", label: "Ends With" },
30
+ { value: "isblank", label: "Is Blank" },
31
+ { value: "isnotblank", label: "Is Not Blank" }
32
+ ], pa = ({ condition: l, fields: y, onChange: m, onRemove: w }) => {
33
+ const { t: v } = Mt(), h = y.find((g) => g.field === l.field), C = l.operator === "isblank" || l.operator === "isnotblank", k = h?.operators || fa;
34
+ return /* @__PURE__ */ p("div", { className: "nice-filterbuilder__condition", children: [
35
+ /* @__PURE__ */ i(
36
+ "select",
37
+ {
38
+ className: "nice-filterbuilder__select",
39
+ value: l.field,
40
+ onChange: (g) => m({ ...l, field: g.target.value, value: "" }),
41
+ children: y.map((g) => /* @__PURE__ */ i("option", { value: g.field, children: g.label }, g.field))
42
+ }
43
+ ),
44
+ /* @__PURE__ */ i(
45
+ "select",
46
+ {
47
+ className: "nice-filterbuilder__select",
48
+ value: l.operator,
49
+ onChange: (g) => m({ ...l, operator: g.target.value }),
50
+ children: k.map((g) => /* @__PURE__ */ i("option", { value: g.value, children: g.label }, g.value))
51
+ }
52
+ ),
53
+ !C && (h?.options ? /* @__PURE__ */ p(
54
+ "select",
55
+ {
56
+ className: "nice-filterbuilder__select",
57
+ value: String(l.value ?? ""),
58
+ onChange: (g) => m({ ...l, value: g.target.value }),
59
+ children: [
60
+ /* @__PURE__ */ i("option", { value: "", children: "--" }),
61
+ h.options.map((g) => /* @__PURE__ */ i("option", { value: g.value, children: g.label }, g.value))
62
+ ]
63
+ }
64
+ ) : h?.type === "boolean" ? /* @__PURE__ */ p(
65
+ "select",
66
+ {
67
+ className: "nice-filterbuilder__select",
68
+ value: String(l.value ?? ""),
69
+ onChange: (g) => m({ ...l, value: g.target.value === "true" }),
70
+ children: [
71
+ /* @__PURE__ */ i("option", { value: "true", children: v("filterBuilder.true", "True") }),
72
+ /* @__PURE__ */ i("option", { value: "false", children: v("filterBuilder.false", "False") })
73
+ ]
74
+ }
75
+ ) : /* @__PURE__ */ i(
76
+ "input",
77
+ {
78
+ className: "nice-filterbuilder__input",
79
+ type: h?.type === "number" ? "number" : h?.type === "date" ? "date" : "text",
80
+ value: String(l.value ?? ""),
81
+ onChange: (g) => m({
82
+ ...l,
83
+ value: h?.type === "number" ? Number(g.target.value) : g.target.value
84
+ })
85
+ }
86
+ )),
87
+ /* @__PURE__ */ i(
88
+ "button",
89
+ {
90
+ "aria-label": v("filterBuilder.close", "Close"),
91
+ className: "nice-filterbuilder__remove",
92
+ onClick: w,
93
+ children: /* @__PURE__ */ i($, { name: "close", size: 14 })
94
+ }
95
+ )
96
+ ] });
97
+ }, zi = ({ group: l, fields: y, onChange: m, onRemove: w, depth: v, maxDepth: h }) => {
98
+ const { t: C } = Mt(), [k, g] = x(!1), re = () => m({ ...l, logic: l.logic === "and" ? "or" : "and" }), U = l.items.filter((S) => S.type === "condition").length, ae = l.items.length - U, ge = [
99
+ U ? `${U} condition${U > 1 ? "s" : ""}` : "",
100
+ ae ? `${ae} group${ae > 1 ? "s" : ""}` : ""
101
+ ].filter(Boolean).join(" · ") || "empty", he = () => {
102
+ const S = {
103
+ type: "condition",
104
+ field: y[0]?.field || "",
105
+ operator: "=",
106
+ value: ""
107
+ };
108
+ m({ ...l, items: [...l.items, S] });
109
+ }, ye = () => {
110
+ if (v >= h)
111
+ return;
112
+ const S = { type: "group", logic: "and", items: [] };
113
+ m({ ...l, items: [...l.items, S] });
114
+ }, M = (S, O) => {
115
+ const D = [...l.items];
116
+ D[S] = O, m({ ...l, items: D });
117
+ }, le = (S) => {
118
+ m({ ...l, items: l.items.filter((O, D) => D !== S) });
119
+ };
120
+ return /* @__PURE__ */ p(
121
+ "div",
122
+ {
123
+ className: `nice-filterbuilder__group nice-filterbuilder__group--depth-${Math.min(v, 3)}`,
124
+ children: [
125
+ /* @__PURE__ */ p("div", { className: "nice-filterbuilder__group-header", children: [
126
+ /* @__PURE__ */ i(
127
+ "button",
128
+ {
129
+ type: "button",
130
+ className: "nice-filterbuilder__collapse",
131
+ onClick: () => g((S) => !S),
132
+ "aria-expanded": !k,
133
+ title: k ? C("filterBuilder.expandGroup", "Expand group") : C("filterBuilder.collapseGroup", "Collapse group"),
134
+ children: /* @__PURE__ */ i($, { name: k ? "chevron-right" : "chevron-down", size: "sm" })
135
+ }
136
+ ),
137
+ /* @__PURE__ */ i(
138
+ "button",
139
+ {
140
+ className: "nice-filterbuilder__logic",
141
+ onClick: re,
142
+ title: C("filterBuilder.matchClickToSwitch", "Match {mode} — click to switch to {other}").replace(
143
+ "{mode}",
144
+ l.logic === "and" ? C("filterBuilder.matchAll", "ALL") : C("filterBuilder.matchAny", "ANY")
145
+ ).replace("{other}", l.logic === "and" ? "OR" : "AND"),
146
+ children: l.logic.toUpperCase()
147
+ }
148
+ ),
149
+ k ? /* @__PURE__ */ i("span", { className: "nice-filterbuilder__summary", children: ge }) : /* @__PURE__ */ p(Dt, { children: [
150
+ /* @__PURE__ */ i("button", { className: "nice-btn nice-btn--sm", onClick: he, children: C("filterBuilder.condition", "+ Condition") }),
151
+ v < h && /* @__PURE__ */ i("button", { className: "nice-btn nice-btn--sm", onClick: ye, children: C("filterBuilder.group", "+ Group") })
152
+ ] }),
153
+ w && /* @__PURE__ */ i(
154
+ "button",
155
+ {
156
+ "aria-label": C("filterBuilder.close", "Close"),
157
+ className: "nice-filterbuilder__remove",
158
+ onClick: w,
159
+ children: /* @__PURE__ */ i($, { name: "close", size: 14 })
160
+ }
161
+ )
162
+ ] }),
163
+ !k && /* @__PURE__ */ i("div", { className: "nice-filterbuilder__group-body", children: l.items.map((S, O) => /* @__PURE__ */ i(zt.Fragment, { children: S.type === "condition" ? /* @__PURE__ */ i(
164
+ pa,
165
+ {
166
+ condition: S,
167
+ fields: y,
168
+ onChange: (D) => M(O, D),
169
+ onRemove: () => le(O)
170
+ }
171
+ ) : /* @__PURE__ */ i(
172
+ zi,
173
+ {
174
+ group: S,
175
+ fields: y,
176
+ onChange: (D) => M(O, D),
177
+ onRemove: () => le(O),
178
+ depth: v + 1,
179
+ maxDepth: h
180
+ }
181
+ ) }, O)) })
182
+ ]
183
+ }
184
+ );
185
+ }, Mi = ({
186
+ fields: l = da,
187
+ value: y,
188
+ defaultValue: m,
189
+ onChange: w,
190
+ maxDepth: v = 3,
191
+ presets: h,
192
+ onSavePreset: C,
193
+ onDeletePreset: k,
194
+ tutorial: g,
195
+ className: re,
196
+ style: U,
197
+ "data-testid": ae
198
+ }) => {
199
+ const { t: ge } = Mt(), [he, ye] = Jr({
200
+ value: y,
201
+ defaultValue: m,
202
+ fallbackValue: { type: "group", logic: "and", items: [] },
203
+ onChange: w,
204
+ componentName: "NiceFilterBuilder"
205
+ }), [M, le] = x(""), S = b(
206
+ (D) => {
207
+ const nt = h?.find((Ee) => Ee.name === D);
208
+ nt && ye(structuredClone(nt.filter));
209
+ },
210
+ [h, ye]
211
+ ), O = b(() => {
212
+ !M.trim() || !C || (C({ name: M.trim(), filter: structuredClone(he) }), le(""));
213
+ }, [M, he, C]);
214
+ return /* @__PURE__ */ p(
215
+ "div",
216
+ {
217
+ className: `nice-filterbuilder ${re || ""}`,
218
+ style: { position: "relative", ...U },
219
+ "data-testid": ae,
220
+ children: [
221
+ /* @__PURE__ */ i("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 20 }, children: /* @__PURE__ */ i(Xr, { steps: Yr(g, ua) }) }),
222
+ (h?.length || C) && /* @__PURE__ */ p("div", { className: "nice-filterbuilder__presets", children: [
223
+ h && h.length > 0 && /* @__PURE__ */ i("div", { className: "nice-filterbuilder__preset-list", children: h.map((D) => /* @__PURE__ */ p("span", { className: "nice-filterbuilder__preset-tag", children: [
224
+ /* @__PURE__ */ i(
225
+ "button",
226
+ {
227
+ type: "button",
228
+ className: "nice-filterbuilder__preset-btn",
229
+ onClick: () => S(D.name),
230
+ children: D.name
231
+ }
232
+ ),
233
+ k && /* @__PURE__ */ i(
234
+ "button",
235
+ {
236
+ "aria-label": ge("filterBuilder.close", "Close"),
237
+ type: "button",
238
+ className: "nice-filterbuilder__preset-del",
239
+ onClick: () => k(D.name),
240
+ children: /* @__PURE__ */ i($, { name: "close", size: 14 })
241
+ }
242
+ )
243
+ ] }, D.name)) }),
244
+ C && /* @__PURE__ */ p("div", { className: "nice-filterbuilder__preset-save", children: [
245
+ /* @__PURE__ */ i(
246
+ "input",
247
+ {
248
+ className: "nice-filterbuilder__input",
249
+ value: M,
250
+ onChange: (D) => le(D.target.value),
251
+ placeholder: ge("filterBuilder.presetName", "Preset name...")
252
+ }
253
+ ),
254
+ /* @__PURE__ */ i(
255
+ "button",
256
+ {
257
+ className: "nice-btn nice-btn--sm",
258
+ onClick: O,
259
+ disabled: !M.trim(),
260
+ children: ge("filterBuilder.save", "Save")
261
+ }
262
+ )
263
+ ] })
264
+ ] }),
265
+ /* @__PURE__ */ i(
266
+ zi,
267
+ {
268
+ group: he,
269
+ fields: l,
270
+ onChange: ye,
271
+ depth: 0,
272
+ maxDepth: v
273
+ }
274
+ )
275
+ ]
276
+ }
277
+ );
278
+ };
279
+ process.env.NODE_ENV !== "production" && (Mi.displayName = "NiceFilterBuilder");
280
+ const Ii = "nice-datagrid-";
281
+ function Si(l) {
282
+ if (typeof window > "u")
283
+ return null;
284
+ try {
285
+ const y = window.localStorage.getItem(Ii + l);
286
+ return y ? JSON.parse(y) : null;
287
+ } catch {
288
+ return null;
289
+ }
290
+ }
291
+ function ma(l, y) {
292
+ if (!(typeof window > "u"))
293
+ try {
294
+ window.localStorage.setItem(Ii + l, y);
295
+ } catch {
296
+ }
297
+ }
298
+ function ga(l) {
299
+ const y = {};
300
+ return Object.keys(l.columnWidths).length > 0 && (y.columnWidths = l.columnWidths), l.columnOrder && l.columnOrder.length > 0 && (y.columnOrder = l.columnOrder), l.hiddenColumns && l.hiddenColumns.length > 0 && (y.hiddenColumns = l.hiddenColumns), l.sortField && l.sortDirection && (y.sortField = l.sortField, y.sortDirection = l.sortDirection), l.pageSize !== void 0 && (y.pageSize = l.pageSize), l.expandedGroups.size > 0 && (y.expandedGroups = Array.from(l.expandedGroups)), y;
301
+ }
302
+ function ha(l, y, m) {
303
+ const w = l.map((v) => v[y]).filter((v) => typeof v == "number");
304
+ if (w.length === 0)
305
+ return m === "count" ? "0" : "";
306
+ switch (m) {
307
+ case "sum":
308
+ return w.reduce((v, h) => v + h, 0).toLocaleString();
309
+ case "avg":
310
+ return (w.reduce((v, h) => v + h, 0) / w.length).toLocaleString(void 0, {
311
+ maximumFractionDigits: 2
312
+ });
313
+ case "count":
314
+ return String(l.length);
315
+ case "min":
316
+ return Math.min(...w).toLocaleString();
317
+ case "max":
318
+ return Math.max(...w).toLocaleString();
319
+ }
320
+ }
321
+ function ya(l, y) {
322
+ const m = /^([^#0,.]*)([#0,]+(?:\.[#0]+)?)(.*)$/.exec(y);
323
+ if (!m)
324
+ return String(l);
325
+ const [, w, v, h] = m, [C, k = ""] = v.split("."), g = new Intl.NumberFormat(void 0, {
326
+ useGrouping: C.includes(","),
327
+ minimumIntegerDigits: Math.min(21, Math.max(1, (C.match(/0/g) ?? []).length)),
328
+ minimumFractionDigits: (k.match(/0/g) ?? []).length,
329
+ maximumFractionDigits: k.length
330
+ }).format(l);
331
+ return `${w}${g}${h}`;
332
+ }
333
+ function ki(l, y, m = 40) {
334
+ let w = m;
335
+ return l.querySelectorAll(
336
+ `[data-field="${y.replace(/["\\]/g, "\\$&")}"]`
337
+ ).forEach((h) => {
338
+ let C = h.scrollWidth;
339
+ const k = typeof document.createRange == "function" ? document.createRange() : null;
340
+ if (k && typeof k.getBoundingClientRect == "function") {
341
+ k.selectNodeContents(h);
342
+ const g = k.getBoundingClientRect().width;
343
+ if (g > 0) {
344
+ const re = window.getComputedStyle(h), U = (parseFloat(re.paddingLeft) || 0) + (parseFloat(re.paddingRight) || 0);
345
+ C = Math.ceil(g + U);
346
+ }
347
+ }
348
+ w = Math.max(w, C);
349
+ }), w;
350
+ }
351
+ function Di(l, y) {
352
+ const m = new Map(l.map((v) => [v.field, v])), w = [];
353
+ for (const v of y) {
354
+ const h = m.get(v);
355
+ h && (w.push(h), m.delete(v));
356
+ }
357
+ return [...w, ...l.filter((v) => m.has(v.field))];
358
+ }
359
+ function va(l, y) {
360
+ const m = [];
361
+ for (const w of l) {
362
+ const v = y.find((C) => C.columns.includes(w)) ?? null, h = m[m.length - 1];
363
+ h && h.group === v ? h.span += 1 : m.push({ group: v, span: 1 });
364
+ }
365
+ return m;
366
+ }
367
+ function St(l) {
368
+ return l.includes(",") || l.includes('"') || l.includes(`
369
+ `) ? `"${l.replace(/"/g, '""')}"` : l;
370
+ }
371
+ const Ce = {
372
+ width: 12,
373
+ height: 12,
374
+ viewBox: "0 0 24 24",
375
+ fill: "none",
376
+ stroke: "currentColor",
377
+ strokeWidth: 2.4,
378
+ strokeLinecap: "round",
379
+ strokeLinejoin: "round",
380
+ "aria-hidden": !0
381
+ }, ba = () => /* @__PURE__ */ i("svg", { ...Ce, children: /* @__PURE__ */ i("polyline", { points: "6 15 12 9 18 15" }) }), et = () => /* @__PURE__ */ i("svg", { ...Ce, children: /* @__PURE__ */ i("polyline", { points: "6 9 12 15 18 9" }) }), _a = () => /* @__PURE__ */ p("svg", { ...Ce, style: { opacity: 0.55 }, children: [
382
+ /* @__PURE__ */ i("polyline", { points: "6 10 12 5 18 10" }),
383
+ /* @__PURE__ */ i("polyline", { points: "6 14 12 19 18 14" })
384
+ ] }), kt = () => /* @__PURE__ */ i("svg", { ...Ce, children: /* @__PURE__ */ i("polyline", { points: "9 6 15 12 9 18" }) }), xa = () => /* @__PURE__ */ p("svg", { ...Ce, children: [
385
+ /* @__PURE__ */ i("polyline", { points: "3 17 9 11 13 15 21 7" }),
386
+ /* @__PURE__ */ i("polyline", { points: "14 7 21 7 21 14" })
387
+ ] }), Na = () => /* @__PURE__ */ p("svg", { ...Ce, children: [
388
+ /* @__PURE__ */ i("polyline", { points: "3 7 9 13 13 9 21 17" }),
389
+ /* @__PURE__ */ i("polyline", { points: "14 17 21 17 21 10" })
390
+ ] }), wa = () => /* @__PURE__ */ i("svg", { ...Ce, children: /* @__PURE__ */ i("line", { x1: "4", y1: "12", x2: "20", y2: "12" }) }), Ca = 40, tt = (l) => l.stopPropagation(), Sa = [];
391
+ function ka(l) {
392
+ return typeof l == "boolean" ? l ? /* @__PURE__ */ i(
393
+ $,
394
+ {
395
+ name: "check",
396
+ size: 16,
397
+ className: "nice-datagrid__bool-icon nice-datagrid__bool-icon--true",
398
+ title: "true"
399
+ }
400
+ ) : /* @__PURE__ */ i(
401
+ $,
402
+ {
403
+ name: "close",
404
+ size: 16,
405
+ className: "nice-datagrid__bool-icon nice-datagrid__bool-icon--false",
406
+ title: "false"
407
+ }
408
+ ) : String(l ?? "");
409
+ }
410
+ function Ai({
411
+ columns: l = Sa,
412
+ data: y,
413
+ keyField: m = "id",
414
+ dataSource: w,
415
+ sortable: v = !0,
416
+ sortField: h,
417
+ sortDirection: C,
418
+ onSort: k,
419
+ showAdvancedFilter: g,
420
+ advancedFilter: re,
421
+ onAdvancedFilterChange: U,
422
+ filterFields: ae,
423
+ filterPresets: ge,
424
+ onSaveFilterPreset: he,
425
+ onDeleteFilterPreset: ye,
426
+ selectable: M,
427
+ selectedKeys: le,
428
+ onSelectionChange: S,
429
+ pagination: O,
430
+ pageSize: D = 10,
431
+ page: nt,
432
+ onPageChange: Ee,
433
+ totalRows: wn,
434
+ autoPagination: se = !1,
435
+ stickyHeader: It = !0,
436
+ stickyFooter: Ri = !0,
437
+ searchable: Cn,
438
+ searchPlaceholder: Ti,
439
+ virtualScroll: te,
440
+ rowHeight: H = 40,
441
+ groupBy: At,
442
+ groupRender: it,
443
+ onCellEdit: B,
444
+ editMode: Le = "inline",
445
+ formItems: $i,
446
+ formColumns: Oi = 2,
447
+ editFormTitle: Ei,
448
+ formProps: Li,
449
+ onRowEdit: rt,
450
+ onRowAdd: at,
451
+ onRowDelete: Se,
452
+ confirmDelete: lt,
453
+ bulkActions: Rt,
454
+ onBulkDelete: Tt,
455
+ exportCsv: Sn,
456
+ exportFilename: kn = "export",
457
+ detailRow: q,
458
+ expandedRowKeys: Fi,
459
+ onExpandedRowChange: $t,
460
+ columnReorder: Pi,
461
+ onColumnReorder: Dn,
462
+ columnResize: Ot,
463
+ rowDraggable: T,
464
+ onRowReorder: st,
465
+ striped: Bi,
466
+ compact: ji,
467
+ size: Et,
468
+ loading: Gi,
469
+ emptyText: Ki,
470
+ toolbar: zn,
471
+ onRowClick: ve,
472
+ pinnedTopKeys: Lt,
473
+ pinnedBottomKeys: Ft,
474
+ colSpan: Mn,
475
+ showStatusBar: Wi,
476
+ contextMenuItems: ot,
477
+ onContextMenuAction: Vi,
478
+ printFriendly: Ui,
479
+ // P3 features
480
+ keyboardNavigation: Fe,
481
+ focusedCell: Hi,
482
+ onFocusedCellChange: Pt,
483
+ cellRangeSelection: In,
484
+ selectedCellRange: qi,
485
+ onCellRangeChange: Bt,
486
+ clipboard: be,
487
+ clipboardFormat: jt = "text",
488
+ onBeforeCopy: An,
489
+ onCopy: Rn,
490
+ onPaste: Gt,
491
+ quickFilters: oe,
492
+ activeQuickFilters: Ji,
493
+ onQuickFilterChange: Kt,
494
+ columnGroups: Wt,
495
+ stateStorageKey: X,
496
+ initialState: Xi,
497
+ onStateChange: Tn,
498
+ flashRowKeys: Vt,
499
+ flashDuration: $n = 500,
500
+ autoFitColumns: Ut,
501
+ showColumnStats: Pe,
502
+ rowIndicator: Be,
503
+ frozenRows: Yi,
504
+ className: Qi,
505
+ style: Zi,
506
+ accessMode: er,
507
+ id: tr,
508
+ displayStyle: On,
509
+ disabled: nr,
510
+ readOnly: En,
511
+ error: Ht
512
+ }) {
513
+ const qt = Qr(er, tr), ir = qt === "hidden", ke = nr || qt === "disabled", je = En || ke || qt === "readOnly", ce = !!Se && !je, _e = Math.max(0, Math.floor(Yi ?? 0)), { t: d } = Mt();
514
+ Zr("table", On), ea("table", On);
515
+ const I = ta(w ?? null, {
516
+ autoLoad: !!w,
517
+ defaultPageSize: D
518
+ }), z = !!w, Jt = R(() => z ? I.data : y ?? [], [z, I.data, y]), ct = z ? I.loading : Gi, [F] = x(
519
+ () => Xi ?? (X ? Si(X) : null)
520
+ ), [Ln, Fn] = x(() => ({
521
+ field: F?.sortField ?? "",
522
+ dir: F?.sortDirection ?? null
523
+ })), [rr, ar] = x(1), [lr, Xt] = x(/* @__PURE__ */ new Set()), [dt, sr] = x(""), [or, cr] = x({
524
+ type: "group",
525
+ logic: "and",
526
+ items: []
527
+ }), [Pn, Bn] = x(!1), de = re ?? or, jn = (e) => {
528
+ U ? U(e) : cr(e);
529
+ }, dr = R(
530
+ () => ae ?? l.filter((e) => e.filterable !== !1 && e.field).map((e) => ({ field: String(e.field), label: String(e.header ?? e.field) })),
531
+ [ae, l]
532
+ ), xe = de.items.length, [ut, Gn] = x(F?.pageSize ?? D), [ue, Yt] = x(null), [ft, Ge] = x(null), [De, Ne] = x(null), [Qt, Kn] = x(
533
+ () => new Set(F?.expandedGroups ?? [])
534
+ ), [Zt, ur] = x(0), pt = Z(null), [fr, pr] = x(/* @__PURE__ */ new Set()), mt = Fi ?? fr, [Ke, en] = x(
535
+ () => F?.columnWidths ?? {}
536
+ ), [ze, Me] = x(null), [Ie, tn] = x(null), [nn, rn] = x(null), [mr, gr] = x(null), [hr, yr] = x(null), [vr, br] = x([]), [Ae, an] = x(null), ln = Z(null), [gt, sn] = x(
537
+ () => F?.hiddenColumns ?? []
538
+ ), [We, Wn] = x(
539
+ () => F?.columnOrder ?? null
540
+ ), [on, cn] = x(null), [Vn, ht] = x(null), dn = Z(null), [_r, Un] = x(/* @__PURE__ */ new Set()), [Ve, un] = x(null), Hn = Z(null), [xr, Nr] = x({}), fe = Z(null), [wr, Cr] = x(D);
541
+ ee(() => {
542
+ if (!se)
543
+ return;
544
+ const e = pt.current;
545
+ if (!e || typeof ResizeObserver > "u")
546
+ return;
547
+ const t = () => {
548
+ const r = e.clientHeight;
549
+ if (r <= 0)
550
+ return;
551
+ const a = Math.max(1, Math.floor(r / H) - 1);
552
+ Cr((s) => s === a ? s : a), z && I.setPageSize(a);
553
+ };
554
+ t();
555
+ const n = new ResizeObserver(t);
556
+ return n.observe(e), () => n.disconnect();
557
+ }, [se, H, z]);
558
+ const W = Hi ?? mr, j = qi ?? hr, Y = Ji ?? vr, qn = Z(X);
559
+ ee(() => {
560
+ if (qn.current === X)
561
+ return;
562
+ qn.current = X;
563
+ const e = X ? Si(X) : null;
564
+ e && (en(e.columnWidths ?? {}), Kn(new Set(e.expandedGroups ?? [])), sn(e.hiddenColumns ?? []), Wn(e.columnOrder ?? null), Fn({ field: e.sortField ?? "", dir: e.sortDirection ?? null }), e.pageSize !== void 0 && Gn(e.pageSize));
565
+ }, [X]), ee(() => {
566
+ !z || !F || (F.sortField && F.sortDirection && I.setSortField(F.sortField, F.sortDirection), F.pageSize !== void 0 && !se && I.setPageSize(F.pageSize));
567
+ }, []), ee(() => {
568
+ if (!Vt?.size)
569
+ return;
570
+ Un(new Set(Vt));
571
+ const e = setTimeout(() => Un(/* @__PURE__ */ new Set()), $n);
572
+ return () => clearTimeout(e);
573
+ }, [Vt, $n]), ee(() => {
574
+ if (!Ie)
575
+ return;
576
+ const e = () => tn(null);
577
+ return document.addEventListener("click", e), () => document.removeEventListener("click", e);
578
+ }, [Ie]);
579
+ const Sr = b(
580
+ (e, t) => {
581
+ ot?.length && (e.preventDefault(), tn({ x: e.clientX, y: e.clientY, row: t }));
582
+ },
583
+ [ot]
584
+ ), Jn = b(
585
+ (e) => {
586
+ const t = new Set(mt);
587
+ t.has(e) ? t.delete(e) : t.add(e), $t ? $t(t) : pr(t);
588
+ },
589
+ [mt, $t]
590
+ ), kr = b(
591
+ (e, t) => {
592
+ if (!Ot)
593
+ return;
594
+ t.preventDefault();
595
+ const n = t.clientX, a = t.target.closest("th")?.offsetWidth ?? 100, s = (u) => {
596
+ const c = Math.max(40, a + u.clientX - n);
597
+ en((N) => ({ ...N, [e]: c }));
598
+ }, o = () => {
599
+ document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", o);
600
+ };
601
+ document.addEventListener("mousemove", s), document.addEventListener("mouseup", o);
602
+ },
603
+ [Ot]
604
+ ), Q = z ? I.sort[0]?.field ?? "" : h ?? Ln.field, V = z ? I.sort[0]?.direction ?? null : C ?? Ln.dir, Re = z ? I.page : nt ?? rr, A = le ?? lr, ne = R(
605
+ () => We ? Di(l, We) : l,
606
+ [l, We]
607
+ ), P = R(
608
+ () => ne.filter((e) => !e.hidden && !gt.includes(e.field)),
609
+ [ne, gt]
610
+ ), fn = R(
611
+ () => P.filter((e) => e.pinned === "left"),
612
+ [P]
613
+ ), yt = R(
614
+ () => P.filter((e) => e.pinned === "right"),
615
+ [P]
616
+ ), Xn = R(() => P.filter((e) => !e.pinned), [P]), _ = R(
617
+ () => [...fn, ...Xn, ...yt],
618
+ [fn, Xn, yt]
619
+ ), Dr = R(() => P.some((e) => e.aggregate), [P]), Ue = fn.length > 0 || yt.length > 0, pn = R(() => {
620
+ if (!Wt?.length)
621
+ return null;
622
+ const e = va(
623
+ _.map((t) => t.field),
624
+ Wt
625
+ );
626
+ return e.some((t) => t.group) ? e : null;
627
+ }, [Wt, _]), He = b(
628
+ (e, t) => {
629
+ z ? t ? I.setSortField(e, t) : I.setSort([]) : k ? k(e, t) : Fn({ field: e, dir: t });
630
+ },
631
+ [z, I, k]
632
+ ), Yn = b(
633
+ (e) => {
634
+ He(e, Q === e ? V === "asc" ? "desc" : V === "desc" ? null : "asc" : "asc");
635
+ },
636
+ [Q, V, He]
637
+ ), G = R(() => {
638
+ if (z)
639
+ return Jt;
640
+ let e = [...Jt];
641
+ if (dt) {
642
+ const t = dt.toLowerCase();
643
+ e = e.filter(
644
+ (n) => P.some(
645
+ (r) => String(n[r.field] ?? "").toLowerCase().includes(t)
646
+ )
647
+ );
648
+ }
649
+ return de.items.length > 0 && (e = e.filter(
650
+ (t) => na(t, de)
651
+ )), !k && Q && V && e.sort((t, n) => {
652
+ const r = t[Q] ?? "", a = n[Q] ?? "", s = typeof r == "number" ? r - a : String(r).localeCompare(String(a));
653
+ return V === "desc" ? -s : s;
654
+ }), e;
655
+ }, [Jt, dt, de, P, Q, V, k, z]), vt = z ? I.totalCount : wn ?? G.length, pe = se ? wr : z ? I.pageSize : ut, mn = Math.max(1, Math.ceil(vt / pe)), J = z ? G : O && !wn ? G.slice((Re - 1) * pe, Re * pe) : G, qe = b(
656
+ (e) => {
657
+ z ? I.setPage(e) : Ee ? Ee(e) : ar(e);
658
+ },
659
+ [z, I, Ee]
660
+ );
661
+ ia(
662
+ ["pagePrev", "pageNext"],
663
+ (e) => {
664
+ const t = Re + (e.intent === "pageNext" ? 1 : -1);
665
+ if (e.source === "keyboard" || t < 1 || t > mn)
666
+ return !1;
667
+ qe(t);
668
+ },
669
+ { ref: fe, enabled: !!O }
670
+ ), ra(
671
+ fe,
672
+ [
673
+ { intent: "pagePrev", label: d("input.intent.pagePrev", "Previous page") },
674
+ { intent: "pageNext", label: d("input.intent.pageNext", "Next page") }
675
+ ],
676
+ { enabled: !!O && mn > 1 }
677
+ );
678
+ const Je = JSON.stringify(
679
+ ga({
680
+ columnWidths: Ke,
681
+ sortField: Q,
682
+ sortDirection: V,
683
+ pageSize: se ? void 0 : pe,
684
+ expandedGroups: Qt,
685
+ hiddenColumns: gt,
686
+ columnOrder: We ?? void 0
687
+ })
688
+ ), Qn = Z(Tn);
689
+ Qn.current = Tn;
690
+ const gn = Z(X);
691
+ gn.current = X;
692
+ const bt = Z(null), Xe = Z(null), _t = b((e) => {
693
+ bt.current = e, Xe.current = null, gn.current && ma(gn.current, e), Qn.current?.(JSON.parse(e));
694
+ }, []);
695
+ ee(() => {
696
+ if (bt.current === null) {
697
+ bt.current = Je;
698
+ return;
699
+ }
700
+ if (Je === bt.current) {
701
+ Xe.current = null;
702
+ return;
703
+ }
704
+ Xe.current = Je;
705
+ const e = setTimeout(() => _t(Je), 300);
706
+ return () => clearTimeout(e);
707
+ }, [Je, _t]), ee(
708
+ () => () => {
709
+ Xe.current !== null && _t(Xe.current);
710
+ },
711
+ [_t]
712
+ );
713
+ const hn = b(() => {
714
+ an(null), ln.current?.focus();
715
+ }, []), ie = Ci(
716
+ Ae !== null,
717
+ ln,
718
+ hn
719
+ ), Zn = ie.popupRef, ei = ie.ready;
720
+ ee(() => {
721
+ Ae === null || !ei || Zn.current?.querySelector('[role="menuitem"]:not(:disabled)')?.focus();
722
+ }, [Ae, ei, Zn]);
723
+ const zr = b(
724
+ (e) => {
725
+ const t = fe.current;
726
+ if (!t)
727
+ return;
728
+ const n = l.find((a) => a.field === e), r = ki(t, e, n?.minWidth ?? 40);
729
+ en((a) => ({ ...a, [e]: r }));
730
+ },
731
+ [l]
732
+ ), ti = aa(), Mr = b(() => un(null), []), we = Ci(
733
+ Ve !== null,
734
+ Hn,
735
+ Mr,
736
+ { anchorKey: Ve }
737
+ ), ni = (e, t) => {
738
+ Hn.current = e.currentTarget, un(t);
739
+ }, ii = (e) => un((t) => t === e ? null : t), ri = b(
740
+ (e, t) => {
741
+ const n = ne.findIndex((o) => o.field === e), r = ne.findIndex((o) => o.field === t);
742
+ if (n < 0 || r < 0 || n === r || (ne[n].pinned ?? null) !== (ne[r].pinned ?? null))
743
+ return;
744
+ const a = ne.map((o) => o.field).filter((o) => o !== e), s = a.indexOf(t) + (n < r ? 1 : 0);
745
+ a.splice(s, 0, e), Wn(a), Dn?.(Di(l, a));
746
+ },
747
+ [ne, l, Dn]
748
+ );
749
+ ee(() => {
750
+ const e = dn.current;
751
+ e && (dn.current = null, fe.current?.querySelector(`thead th[data-field="${e.replace(/["\\]/g, "\\$&")}"]`)?.focus());
752
+ }, [We]);
753
+ const Ir = (e) => {
754
+ de.items.some(
755
+ (n) => n.type === "condition" && n.field === e
756
+ ) || jn({
757
+ ...de,
758
+ items: [
759
+ ...de.items,
760
+ { type: "condition", field: e, operator: "contains", value: "" }
761
+ ]
762
+ }), Bn(!0);
763
+ }, Ar = (e) => {
764
+ e(), hn();
765
+ }, Rr = (e) => {
766
+ const t = Array.from(
767
+ e.currentTarget.querySelectorAll('[role="menuitem"]:not(:disabled)')
768
+ );
769
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
770
+ e.preventDefault();
771
+ const n = e.key === "ArrowDown" ? 1 : -1, r = t.indexOf(document.activeElement), a = r < 0 ? n > 0 ? 0 : t.length - 1 : (r + n + t.length) % t.length;
772
+ t[a]?.focus();
773
+ } else e.key === "Tab" && an(null);
774
+ }, Te = R(() => J.map((e) => String(e[m])), [J, m]), $e = Te.length > 0 && Te.every((e) => A.has(e)), ai = Te.some((e) => A.has(e)), li = b(() => {
775
+ const e = new Set(A);
776
+ $e ? Te.forEach((t) => e.delete(t)) : Te.forEach((t) => e.add(t)), S ? S(e) : Xt(e);
777
+ }, [$e, Te, A, S]), si = b(
778
+ (e) => {
779
+ const t = new Set(A);
780
+ t.has(e) ? t.delete(e) : t.add(e), S ? S(t) : Xt(t);
781
+ },
782
+ [A, S]
783
+ ), Tr = ({ field: e }) => Q !== e || !V ? /* @__PURE__ */ i("span", { className: "nice-table__sort-icon", children: /* @__PURE__ */ i(_a, {}) }) : /* @__PURE__ */ i("span", { className: "nice-table__sort-icon", children: V === "asc" ? /* @__PURE__ */ i(ba, {}) : /* @__PURE__ */ i(et, {}) }), E = R(() => {
784
+ if (!At)
785
+ return J.map((n, r) => ({
786
+ type: "data",
787
+ row: n,
788
+ key: String(n[m] ?? r)
789
+ }));
790
+ const e = /* @__PURE__ */ new Map();
791
+ J.forEach((n) => {
792
+ const r = n[At];
793
+ e.has(r) || e.set(r, []), e.get(r).push(n);
794
+ });
795
+ const t = [];
796
+ return e.forEach((n, r) => {
797
+ const a = `__group_${String(r)}`, s = Qt.has(a);
798
+ t.push({ type: "group", value: r, rows: n, expanded: s, key: a }), s && n.forEach(
799
+ (o, u) => t.push({ type: "data", row: o, key: String(o[m] ?? `${a}_${u}`) })
800
+ );
801
+ }), t;
802
+ }, [J, At, m, Qt]), { pinnedTopRows: yn, pinnedBottomRows: $r, normalRows: vn } = R(() => {
803
+ if (!Lt?.size && !Ft?.size)
804
+ return {
805
+ pinnedTopRows: [],
806
+ pinnedBottomRows: [],
807
+ normalRows: E
808
+ };
809
+ const e = [], t = [], n = [];
810
+ for (const r of E) {
811
+ if (r.type === "data") {
812
+ const a = r.key;
813
+ if (Lt?.has(a)) {
814
+ e.push(r);
815
+ continue;
816
+ }
817
+ if (Ft?.has(a)) {
818
+ t.push(r);
819
+ continue;
820
+ }
821
+ }
822
+ n.push(r);
823
+ }
824
+ return { pinnedTopRows: e, pinnedBottomRows: t, normalRows: n };
825
+ }, [E, Lt, Ft]), oi = b((e) => {
826
+ Kn((t) => {
827
+ const n = new Set(t);
828
+ return n.has(e) ? n.delete(e) : n.add(e), n;
829
+ });
830
+ }, []), ci = R(() => {
831
+ if (!te)
832
+ return E;
833
+ const e = pt.current?.clientHeight ?? 400, t = Math.ceil(e / H), n = Math.max(0, Math.floor(Zt / H) - 3), r = Math.min(E.length - 1, n + t + 6), a = E.slice(n, r + 1).map((o, u) => ({ ...o, _vIdx: n + u }));
834
+ return [...E.slice(0, Math.min(_e, n)).map((o, u) => ({ ...o, _vIdx: u })), ...a];
835
+ }, [te, E, Zt, H, _e]), Ye = R(
836
+ () => _e > 0 ? [...yn, ...vn].slice(0, _e).map((e) => e.key) : [],
837
+ [_e, yn, vn]
838
+ ), [Or, Er] = x([]);
839
+ wi(() => {
840
+ if (te || Ye.length === 0)
841
+ return;
842
+ const e = pt.current?.querySelector("table");
843
+ if (!e)
844
+ return;
845
+ const t = Array.from(e.tBodies[0]?.rows ?? []);
846
+ let n = It ? e.tHead?.offsetHeight ?? 0 : 0;
847
+ const r = Ye.map((a) => {
848
+ const s = n;
849
+ return n += t.find((o) => o.dataset.rowKey === a)?.offsetHeight ?? 0, s;
850
+ });
851
+ Er(
852
+ (a) => a.length === r.length && a.every((s, o) => s === r[o]) ? a : r
853
+ );
854
+ }, [te, Ye, It, Ke, _, pn]);
855
+ const di = (e) => {
856
+ const t = Ye.indexOf(e);
857
+ return t < 0 ? { className: "" } : {
858
+ className: t === Ye.length - 1 ? "nice-datagrid__row--frozen nice-datagrid__row--frozen-last" : "nice-datagrid__row--frozen",
859
+ style: { position: "sticky", top: Or[t] ?? 0, zIndex: 2 }
860
+ };
861
+ };
862
+ wi(() => {
863
+ const e = fe.current;
864
+ if (!Ut || !e)
865
+ return;
866
+ const t = {};
867
+ for (const n of _)
868
+ n.width === void 0 && Ke[n.field] === void 0 && (t[n.field] = ki(e, n.field, n.minWidth ?? 40));
869
+ Nr((n) => {
870
+ const r = Object.keys(t);
871
+ return r.length === Object.keys(n).length && r.every((s) => Math.abs((n[s] ?? -1 / 0) - t[s]) <= 1) ? n : t;
872
+ });
873
+ }, [Ut, _, Ke, ci]);
874
+ const Oe = (e) => Ke[e.field] || e.width || (Ut ? xr[e.field] : void 0), xt = b(
875
+ (e, t, n) => {
876
+ !B || je || (Yt({ rowKey: e, field: t }), Ge(n));
877
+ },
878
+ [B, je]
879
+ ), ui = b(() => {
880
+ ue && B && B(ue.rowKey, ue.field, ft), Yt(null), Ge(null);
881
+ }, [ue, ft, B]), Lr = b(() => {
882
+ Yt(null), Ge(null);
883
+ }, []), Fr = b(
884
+ (e, t) => {
885
+ !Se || je || (lt ? rn({ key: e, row: t }) : Se(e, t));
886
+ },
887
+ [Se, je, lt]
888
+ ), Pr = b(() => {
889
+ const e = nn;
890
+ rn(null), e && Se?.(e.key, e.row);
891
+ }, [nn, Se]), Br = b(() => rn(null), []), Qe = `nice-datagrid__actions-col${yt.length > 0 ? " nice-datagrid__actions-col--sticky" : ""}`, fi = (e, t) => /* @__PURE__ */ i(
892
+ "button",
893
+ {
894
+ type: "button",
895
+ className: "nice-btn nice-btn--xs nice-btn--ghost nice-datagrid__row-delete",
896
+ "aria-label": d("controls.delete", "Delete"),
897
+ title: d("controls.delete", "Delete"),
898
+ onClick: (n) => {
899
+ n.stopPropagation(), Fr(e, t);
900
+ },
901
+ onDoubleClick: tt,
902
+ onKeyDown: tt,
903
+ children: /* @__PURE__ */ i($, { name: "trash", size: 14 })
904
+ }
905
+ ), jr = b(() => {
906
+ const e = P, t = e.map((u) => St(u.header)).join(","), n = G.map(
907
+ (u) => e.map((c) => St(String(u[c.field] ?? ""))).join(",")
908
+ ), r = [t, ...n].join(`
909
+ `), a = new Blob(["\uFEFF" + r], { type: "text/csv;charset=utf-8;" }), s = URL.createObjectURL(a), o = document.createElement("a");
910
+ o.href = s, o.download = `${kn}.csv`, o.click(), URL.revokeObjectURL(s);
911
+ }, [P, G, kn]), Nt = b(
912
+ (e) => {
913
+ Pt ? Pt(e) : gr(e);
914
+ },
915
+ [Pt]
916
+ ), wt = b(
917
+ (e) => {
918
+ Bt ? Bt(e) : yr(e);
919
+ },
920
+ [Bt]
921
+ ), K = R(() => E.filter((e) => e.type === "data").map((e) => e.key), [E]), Gr = b(
922
+ (e) => {
923
+ if (e.target !== e.currentTarget || !Fe || ue || !W)
924
+ return;
925
+ const t = K.indexOf(W.rowKey), n = _.findIndex((o) => o.field === W.field);
926
+ if (t < 0 || n < 0)
927
+ return;
928
+ let r = t, a = n;
929
+ switch (e.key) {
930
+ case "ArrowUp":
931
+ r = Math.max(0, t - 1);
932
+ break;
933
+ case "ArrowDown":
934
+ r = Math.min(K.length - 1, t + 1);
935
+ break;
936
+ case "ArrowLeft":
937
+ a = Math.max(0, n - 1);
938
+ break;
939
+ case "ArrowRight":
940
+ a = Math.min(_.length - 1, n + 1);
941
+ break;
942
+ case "Tab": {
943
+ const o = n + (e.shiftKey ? -1 : 1);
944
+ if (o < 0 || o >= _.length)
945
+ return;
946
+ a = o;
947
+ break;
948
+ }
949
+ case "Enter": {
950
+ const o = _[n];
951
+ if (o.editable && B) {
952
+ const u = J.find((c) => String(c[m]) === W.rowKey);
953
+ u && xt(W.rowKey, o.field, u[o.field]);
954
+ }
955
+ return;
956
+ }
957
+ case "Escape":
958
+ Nt(null), wt(null);
959
+ return;
960
+ case "Home":
961
+ e.ctrlKey && (r = 0), a = 0;
962
+ break;
963
+ case "End":
964
+ e.ctrlKey && (r = K.length - 1), a = _.length - 1;
965
+ break;
966
+ case "PageUp":
967
+ r = Math.max(0, t - ut);
968
+ break;
969
+ case "PageDown":
970
+ r = Math.min(K.length - 1, t + ut);
971
+ break;
972
+ default:
973
+ return;
974
+ }
975
+ e.preventDefault();
976
+ const s = {
977
+ rowKey: K[r],
978
+ field: _[a].field
979
+ };
980
+ if (Nt(s), e.shiftKey && In) {
981
+ const o = j?.start ?? W;
982
+ wt({ start: o, end: s });
983
+ } else
984
+ wt(null);
985
+ },
986
+ [
987
+ Fe,
988
+ ue,
989
+ W,
990
+ K,
991
+ _,
992
+ In,
993
+ j,
994
+ Nt,
995
+ wt,
996
+ B,
997
+ J,
998
+ m,
999
+ xt,
1000
+ ut
1001
+ ]
1002
+ ), pi = b(() => {
1003
+ let e = [], t = [];
1004
+ if (j) {
1005
+ const n = K.indexOf(j.start.rowKey), r = K.indexOf(j.end.rowKey), a = Math.min(n, r), s = Math.max(n, r), o = _.findIndex((f) => f.field === j.start.field), u = _.findIndex((f) => f.field === j.end.field), c = Math.min(o, u), N = Math.max(o, u);
1006
+ t = _.slice(c, N + 1).map((f) => f.field), e = J.filter((f) => {
1007
+ const L = K.indexOf(String(f[m]));
1008
+ return L >= a && L <= s;
1009
+ });
1010
+ } else A.size > 0 && (e = J.filter((n) => A.has(String(n[m]))), t = _.map((n) => n.field));
1011
+ return { rows: e, fields: t };
1012
+ }, [j, K, _, J, m, A]), mi = b(
1013
+ (e, t, n) => {
1014
+ const r = _.filter((a) => t.includes(a.field));
1015
+ switch (n) {
1016
+ case "json":
1017
+ return JSON.stringify(
1018
+ e.map((a) => Object.fromEntries(t.map((s) => [s, a[s]]))),
1019
+ null,
1020
+ 2
1021
+ );
1022
+ case "csv": {
1023
+ const a = r.map((o) => St(o.header)).join(","), s = e.map((o) => r.map((u) => St(String(o[u.field] ?? ""))).join(",")).join(`
1024
+ `);
1025
+ return a + `
1026
+ ` + s;
1027
+ }
1028
+ case "html": {
1029
+ const a = r.map((o) => `<th>${o.header}</th>`).join(""), s = e.map((o) => `<tr>${r.map((u) => `<td>${o[u.field] ?? ""}</td>`).join("")}</tr>`).join("");
1030
+ return `<table><thead><tr>${a}</tr></thead><tbody>${s}</tbody></table>`;
1031
+ }
1032
+ case "markdown": {
1033
+ const a = "| " + r.map((u) => u.header).join(" | ") + " |", s = "| " + r.map(() => "---").join(" | ") + " |", o = e.map((u) => "| " + r.map((c) => u[c.field] ?? "").join(" | ") + " |").join(`
1034
+ `);
1035
+ return a + `
1036
+ ` + s + `
1037
+ ` + o;
1038
+ }
1039
+ default:
1040
+ return e.map((a) => r.map((s) => a[s.field] ?? "").join(" ")).join(`
1041
+ `);
1042
+ }
1043
+ },
1044
+ [_]
1045
+ ), bn = b(async () => {
1046
+ if (!be)
1047
+ return;
1048
+ const { rows: e, fields: t } = pi();
1049
+ if (!e.length || An?.(e, t) === !1)
1050
+ return;
1051
+ const n = mi(e, t, jt);
1052
+ await navigator.clipboard.writeText(n), Rn?.(e, t, jt);
1053
+ }, [be, pi, An, mi, jt, Rn]), gi = b(async () => {
1054
+ if (!be || !W || !Gt)
1055
+ return;
1056
+ const t = (await navigator.clipboard.readText()).split(`
1057
+ `).map((n) => n.split(" "));
1058
+ Gt(t, W);
1059
+ }, [be, W, Gt]);
1060
+ ee(() => {
1061
+ if (!be || !fe.current)
1062
+ return;
1063
+ const e = (t) => {
1064
+ fe.current?.contains(document.activeElement) && (t.type === "copy" && (t.preventDefault(), bn()), t.type === "paste" && (t.preventDefault(), gi()));
1065
+ };
1066
+ return document.addEventListener("copy", e), document.addEventListener("paste", e), () => {
1067
+ document.removeEventListener("copy", e), document.removeEventListener("paste", e);
1068
+ };
1069
+ }, [be, bn, gi]);
1070
+ const Kr = b(
1071
+ (e) => {
1072
+ const t = Y.includes(e) ? Y.filter((n) => n !== e) : [...Y, e];
1073
+ Kt ? Kt(t) : br(t);
1074
+ },
1075
+ [Y, Kt]
1076
+ ), Wr = R(() => {
1077
+ if (!oe?.length || !Y.length)
1078
+ return G;
1079
+ const e = oe.filter((t) => Y.includes(t.key));
1080
+ return G.filter((t) => e.every((n) => n.filter(t)));
1081
+ }, [G, oe, Y]), hi = oe?.length ? Wr : G, Vr = b(
1082
+ (e) => {
1083
+ const t = G.map((c) => c[e]).filter((c) => c != null), n = t.filter((c) => typeof c == "number");
1084
+ if (n.length === 0) {
1085
+ const c = new Set(t).size;
1086
+ return { count: t.length, unique: c, type: "text" };
1087
+ }
1088
+ let r = 0, a = 1 / 0, s = -1 / 0;
1089
+ for (const c of n)
1090
+ r += c, a = Math.min(a, c), s = Math.max(s, c);
1091
+ const o = r / n.length, u = Math.sqrt(
1092
+ n.reduce((c, N) => c + (N - o) ** 2, 0) / n.length
1093
+ );
1094
+ return { count: n.length, sum: r, avg: o, min: a, max: s, stdDev: u, type: "numeric" };
1095
+ },
1096
+ [G]
1097
+ ), Ur = b(
1098
+ (e, t, n) => {
1099
+ if (!e.cellVisualization)
1100
+ return null;
1101
+ const r = Number(t);
1102
+ if (isNaN(r))
1103
+ return null;
1104
+ const a = e.visualMin ?? 0, s = e.visualMax ?? 100, o = Math.max(0, Math.min(100, (r - a) / (s - a) * 100));
1105
+ switch (e.cellVisualization) {
1106
+ case "progress":
1107
+ return /* @__PURE__ */ p(
1108
+ "div",
1109
+ {
1110
+ className: "nice-datagrid__cell-progress",
1111
+ style: { display: "flex", alignItems: "center", gap: 8 },
1112
+ children: [
1113
+ /* @__PURE__ */ i(
1114
+ "div",
1115
+ {
1116
+ style: {
1117
+ flex: 1,
1118
+ height: 6,
1119
+ background: "var(--nice-border-color)",
1120
+ borderRadius: 3,
1121
+ overflow: "hidden"
1122
+ },
1123
+ children: /* @__PURE__ */ i(
1124
+ "div",
1125
+ {
1126
+ style: {
1127
+ width: `${o}%`,
1128
+ height: "100%",
1129
+ background: o > 80 ? "var(--nice-color-success)" : o > 50 ? "var(--nice-color-primary)" : "var(--nice-color-warning)",
1130
+ transition: "width 0.3s ease"
1131
+ }
1132
+ }
1133
+ )
1134
+ }
1135
+ ),
1136
+ /* @__PURE__ */ p("span", { style: { fontSize: "0.75rem", minWidth: 32, textAlign: "right" }, children: [
1137
+ Math.round(o),
1138
+ "%"
1139
+ ] })
1140
+ ]
1141
+ }
1142
+ );
1143
+ case "rating": {
1144
+ const u = Math.round(r / s * 5);
1145
+ return /* @__PURE__ */ i("div", { className: "nice-datagrid__cell-rating", children: [1, 2, 3, 4, 5].map((c) => /* @__PURE__ */ i(
1146
+ "span",
1147
+ {
1148
+ style: {
1149
+ color: c <= u ? "var(--nice-color-warning)" : "var(--nice-text-muted)",
1150
+ fontSize: "0.95rem",
1151
+ lineHeight: 1
1152
+ },
1153
+ "aria-hidden": "true",
1154
+ children: /* @__PURE__ */ i($, { name: "star", size: 14 })
1155
+ },
1156
+ c
1157
+ )) });
1158
+ }
1159
+ case "trend": {
1160
+ const u = e.visualMin ?? r, c = r - u, N = c > 0 ? xa : c < 0 ? Na : wa, f = c > 0 ? "var(--nice-color-success)" : c < 0 ? "var(--nice-color-danger)" : "var(--nice-text-muted)";
1161
+ return /* @__PURE__ */ p(
1162
+ "span",
1163
+ {
1164
+ style: {
1165
+ color: f,
1166
+ fontWeight: 500,
1167
+ display: "inline-flex",
1168
+ alignItems: "center",
1169
+ gap: 4
1170
+ },
1171
+ children: [
1172
+ /* @__PURE__ */ i(N, {}),
1173
+ " ",
1174
+ Math.abs(c).toFixed(1),
1175
+ "%"
1176
+ ]
1177
+ }
1178
+ );
1179
+ }
1180
+ case "heatmap": {
1181
+ const u = o / 100, c = `rgba(${Math.round(255 * u)}, ${Math.round(100 * (1 - u))}, ${Math.round(50 * (1 - u))}, 0.6)`;
1182
+ return /* @__PURE__ */ i("span", { style: { background: c, padding: "2px 8px", borderRadius: 4 }, children: r });
1183
+ }
1184
+ default:
1185
+ return null;
1186
+ }
1187
+ },
1188
+ []
1189
+ ), Hr = b(
1190
+ (e, t, n) => {
1191
+ if (!e.conditionalFormats?.length)
1192
+ return {};
1193
+ for (const r of e.conditionalFormats)
1194
+ if (r.when(t, n, e.field))
1195
+ return {
1196
+ className: r.className,
1197
+ style: {
1198
+ ...r.style,
1199
+ backgroundColor: r.backgroundColor,
1200
+ color: r.color
1201
+ }
1202
+ };
1203
+ return {};
1204
+ },
1205
+ []
1206
+ ), yi = b(
1207
+ (e, t) => {
1208
+ if (!Ue || !e.pinned)
1209
+ return {};
1210
+ const n = {
1211
+ position: "sticky",
1212
+ zIndex: 2,
1213
+ background: "var(--nice-bg-primary, #fff)"
1214
+ };
1215
+ if (e.pinned === "left") {
1216
+ let r = 0;
1217
+ for (let a = 0; a < t; a++) {
1218
+ const s = _[a];
1219
+ s.pinned === "left" && (r += typeof s.width == "number" ? s.width : parseInt(String(s.width) || "100", 10));
1220
+ }
1221
+ M && t === 0 && (r = 36), n.left = r;
1222
+ } else {
1223
+ let r = 0;
1224
+ for (let a = _.length - 1; a > t; a--) {
1225
+ const s = _[a];
1226
+ s.pinned === "right" && (r += typeof s.width == "number" ? s.width : parseInt(String(s.width) || "100", 10));
1227
+ }
1228
+ n.right = r + (ce ? Ca : 0);
1229
+ }
1230
+ return n;
1231
+ },
1232
+ [Ue, _, M, ce]
1233
+ ), vi = (e, t, n, r) => {
1234
+ if (ue?.rowKey === n && ue?.field === e.field)
1235
+ return e.editor ? e.editor(ft, t, (u) => Ge(u)) : /* @__PURE__ */ i(
1236
+ "input",
1237
+ {
1238
+ className: "nice-datagrid__edit-input",
1239
+ autoFocus: !0,
1240
+ value: ft ?? "",
1241
+ onChange: (u) => Ge(u.target.value),
1242
+ onBlur: ui,
1243
+ onKeyDown: (u) => {
1244
+ u.key === "Enter" && ui(), u.key === "Escape" && Lr();
1245
+ }
1246
+ }
1247
+ );
1248
+ const s = Ur(e, t[e.field], t);
1249
+ if (s)
1250
+ return s;
1251
+ const o = t[e.field];
1252
+ return e.render ? e.render(o, t, r) : e.format && typeof o == "number" && Number.isFinite(o) ? ya(o, e.format) : ka(o);
1253
+ }, qr = (e, t, n, r) => {
1254
+ const a = W?.rowKey === n && W?.field === e.field, s = j && (() => {
1255
+ const c = K.indexOf(j.start.rowKey), N = K.indexOf(j.end.rowKey), f = K.indexOf(n), L = _.findIndex((me) => me.field === j.start.field), Ze = _.findIndex((me) => me.field === j.end.field);
1256
+ return f >= Math.min(c, N) && f <= Math.max(c, N) && r >= Math.min(L, Ze) && r <= Math.max(L, Ze);
1257
+ })(), o = Hr(e, t[e.field], t);
1258
+ return {
1259
+ className: [
1260
+ o.className,
1261
+ a && "nice-datagrid__cell--focused",
1262
+ s && "nice-datagrid__cell--in-range"
1263
+ ].filter(Boolean).join(" "),
1264
+ style: {
1265
+ ...yi(e, r),
1266
+ textAlign: e.align,
1267
+ ...o.style,
1268
+ ...a ? { outline: "2px solid var(--nice-color-primary)", outlineOffset: -2 } : {},
1269
+ ...s ? { background: "var(--nice-color-primary-light, rgba(59,130,246,0.15))" } : {}
1270
+ }
1271
+ };
1272
+ }, bi = [
1273
+ "nice-table",
1274
+ Bi ? "nice-table--striped" : "",
1275
+ ji ? "nice-table--compact" : "",
1276
+ Et && Et !== "md" ? `nice-table--${Et}` : ""
1277
+ ].filter(Boolean).join(" "), Ct = _.length + (M ? 1 : 0) + (q ? 1 : 0) + (T ? 1 : 0) + (Be ? 1 : 0) + (ce ? 1 : 0), _i = (e) => pn && /* @__PURE__ */ p("tr", { className: "nice-datagrid__column-group-row", children: [
1278
+ e > 0 && /* @__PURE__ */ i("th", { colSpan: e }),
1279
+ pn.map(
1280
+ (t, n) => t.group ? /* @__PURE__ */ i(
1281
+ "th",
1282
+ {
1283
+ colSpan: t.span,
1284
+ scope: "colgroup",
1285
+ className: "nice-datagrid__column-group",
1286
+ style: { textAlign: t.group.align ?? "center" },
1287
+ children: t.group.header
1288
+ },
1289
+ n
1290
+ ) : /* @__PURE__ */ i("th", { colSpan: t.span }, n)
1291
+ ),
1292
+ ce && /* @__PURE__ */ i("th", { className: Qe })
1293
+ ] }), xi = (e, t) => {
1294
+ const n = v && e.sortable !== !1, r = n ? Q === e.field ? V === "asc" ? "ascending" : V === "desc" ? "descending" : "none" : "none" : void 0, a = Ae === e.field, s = !!Pi && !ke, o = (c) => {
1295
+ const N = c ? ne.find((f) => f.field === c) : void 0;
1296
+ return !!N && (N.pinned ?? null) === (e.pinned ?? null);
1297
+ }, u = [
1298
+ n && "nice-datagrid__th--sortable",
1299
+ Vn === e.field && "nice-datagrid__th--drop-target"
1300
+ ].filter(Boolean).join(" ");
1301
+ return /* @__PURE__ */ p(
1302
+ "th",
1303
+ {
1304
+ "data-field": e.field,
1305
+ title: e.headerTooltip,
1306
+ style: {
1307
+ width: Oe(e),
1308
+ minWidth: e.minWidth,
1309
+ textAlign: e.align,
1310
+ position: "relative",
1311
+ ...yi(e, t)
1312
+ },
1313
+ className: u || void 0,
1314
+ onClick: () => n && Yn(e.field),
1315
+ "aria-sort": r,
1316
+ scope: "col",
1317
+ "aria-describedby": Ve === e.field ? ti : void 0,
1318
+ onMouseEnter: Pe ? (c) => ni(c, e.field) : void 0,
1319
+ onMouseLeave: Pe ? () => ii(e.field) : void 0,
1320
+ onFocus: Pe ? (c) => ni(c, e.field) : void 0,
1321
+ onBlur: Pe ? () => ii(e.field) : void 0,
1322
+ draggable: s || void 0,
1323
+ tabIndex: s || n ? 0 : void 0,
1324
+ "aria-keyshortcuts": s ? "Alt+ArrowLeft Alt+ArrowRight" : void 0,
1325
+ onDragStart: s ? (c) => {
1326
+ if (c.target.closest?.(".nice-datagrid__resize-handle, .nice-datagrid__header-menu-btn")) {
1327
+ c.preventDefault();
1328
+ return;
1329
+ }
1330
+ c.dataTransfer?.setData("text/plain", e.field), cn(e.field);
1331
+ } : void 0,
1332
+ onDragOver: s ? (c) => {
1333
+ o(on) && (c.preventDefault(), Vn !== e.field && ht(e.field));
1334
+ } : void 0,
1335
+ onDragLeave: s ? () => ht((c) => c === e.field ? null : c) : void 0,
1336
+ onDrop: s ? (c) => {
1337
+ c.preventDefault(), on && ri(on, e.field), cn(null), ht(null);
1338
+ } : void 0,
1339
+ onDragEnd: s ? () => {
1340
+ cn(null), ht(null);
1341
+ } : void 0,
1342
+ onKeyDown: s || n ? (c) => {
1343
+ if (n && (c.key === "Enter" || c.key === " ") && c.target === c.currentTarget) {
1344
+ c.preventDefault(), c.stopPropagation(), Yn(e.field);
1345
+ return;
1346
+ }
1347
+ if (!s || !c.altKey || c.key !== "ArrowLeft" && c.key !== "ArrowRight")
1348
+ return;
1349
+ c.preventDefault(), c.stopPropagation();
1350
+ const N = _[t + (c.key === "ArrowLeft" ? -1 : 1)];
1351
+ !N || !o(N.field) || (dn.current = e.field, ri(e.field, N.field));
1352
+ } : void 0,
1353
+ children: [
1354
+ e.header,
1355
+ n && /* @__PURE__ */ i(Tr, { field: e.field }),
1356
+ e.headerMenu && !ke && /* @__PURE__ */ i(
1357
+ "button",
1358
+ {
1359
+ type: "button",
1360
+ className: "nice-datagrid__header-menu-btn",
1361
+ "aria-label": d("datagrid.columnMenu", "Column menu"),
1362
+ "aria-haspopup": "menu",
1363
+ "aria-expanded": a,
1364
+ onClick: (c) => {
1365
+ c.stopPropagation(), a ? hn() : (ln.current = c.currentTarget, an(e.field));
1366
+ },
1367
+ onKeyDown: tt,
1368
+ children: /* @__PURE__ */ i($, { name: "more-vertical", size: 14 })
1369
+ }
1370
+ ),
1371
+ Ot && /* @__PURE__ */ i(
1372
+ "span",
1373
+ {
1374
+ className: "nice-datagrid__resize-handle",
1375
+ onMouseDown: (c) => {
1376
+ c.stopPropagation(), kr(e.field, c);
1377
+ }
1378
+ }
1379
+ )
1380
+ ]
1381
+ },
1382
+ e.field
1383
+ );
1384
+ }, _n = (e, t, n) => {
1385
+ const { row: r, key: a } = e, s = A.has(a), o = mt.has(a), u = _r.has(a), c = di(a), N = [
1386
+ s && "nice-datagrid__row--selected",
1387
+ ze === t && "nice-datagrid__row--dragging",
1388
+ n && "nice-datagrid__row--pinned",
1389
+ u && "nice-datagrid__row--flash",
1390
+ c.className
1391
+ ].filter(Boolean).join(" ");
1392
+ return /* @__PURE__ */ p(zt.Fragment, { children: [
1393
+ /* @__PURE__ */ p(
1394
+ "tr",
1395
+ {
1396
+ "data-row-key": a,
1397
+ className: N,
1398
+ onClick: () => ve?.(r),
1399
+ onDoubleClick: Le === "popup" && (rt || B) ? () => Ne({ key: a, data: { ...r } }) : void 0,
1400
+ onContextMenu: (f) => Sr(f, r),
1401
+ style: ve || Le === "popup" || c.style ? {
1402
+ ...ve || Le === "popup" ? { cursor: "pointer" } : {},
1403
+ ...c.style
1404
+ } : void 0,
1405
+ draggable: T,
1406
+ onDragStart: T ? () => Me(t) : void 0,
1407
+ onDragOver: T ? (f) => f.preventDefault() : void 0,
1408
+ onDrop: T && st && ze != null ? () => {
1409
+ st(ze, t), Me(null);
1410
+ } : void 0,
1411
+ onDragEnd: T ? () => Me(null) : void 0,
1412
+ children: [
1413
+ Be && /* @__PURE__ */ i("td", { className: "nice-datagrid__row-indicator", style: { width: 32, padding: "0 4px" }, children: Be(r) }),
1414
+ q && /* @__PURE__ */ i(
1415
+ "td",
1416
+ {
1417
+ className: "nice-datagrid__expand-col",
1418
+ onClick: (f) => {
1419
+ f.stopPropagation(), Jn(a);
1420
+ },
1421
+ children: /* @__PURE__ */ i("span", { className: "nice-datagrid__expand-btn", "data-expanded": o, children: o ? /* @__PURE__ */ i(et, {}) : /* @__PURE__ */ i(kt, {}) })
1422
+ }
1423
+ ),
1424
+ T && /* @__PURE__ */ i(
1425
+ "td",
1426
+ {
1427
+ className: "nice-datagrid__drag-handle",
1428
+ style: { cursor: "grab", textAlign: "center", color: "var(--nice-text-muted)" },
1429
+ "aria-label": d("datagrid.dragRow", "Drag to reorder"),
1430
+ children: /* @__PURE__ */ i($, { name: "more-vertical", size: 14 })
1431
+ }
1432
+ ),
1433
+ M && /* @__PURE__ */ i(
1434
+ "td",
1435
+ {
1436
+ className: "nice-datagrid__checkbox",
1437
+ onClick: (f) => f.stopPropagation(),
1438
+ style: Ue ? {
1439
+ position: "sticky",
1440
+ left: 0,
1441
+ zIndex: 1,
1442
+ background: "var(--nice-bg-primary, #fff)"
1443
+ } : void 0,
1444
+ children: /* @__PURE__ */ i(
1445
+ "input",
1446
+ {
1447
+ type: "checkbox",
1448
+ checked: s,
1449
+ onChange: () => si(a),
1450
+ "aria-label": d("datagrid.selectRow", "Select row {rowKey}").replace(
1451
+ "{rowKey}",
1452
+ String(a)
1453
+ )
1454
+ }
1455
+ )
1456
+ }
1457
+ ),
1458
+ (() => {
1459
+ let f = 0;
1460
+ return _.map((L, Ze) => {
1461
+ if (f > 0)
1462
+ return f--, null;
1463
+ const me = Mn ? Mn(r, L, Ze) : void 0;
1464
+ me && me > 1 && (f = me - 1);
1465
+ const Ni = qr(L, r, a, Ze);
1466
+ return /* @__PURE__ */ i(
1467
+ "td",
1468
+ {
1469
+ "data-field": L.field,
1470
+ colSpan: me,
1471
+ className: Ni.className,
1472
+ style: Ni.style,
1473
+ onClick: Fe ? () => Nt({ rowKey: a, field: L.field }) : void 0,
1474
+ onDoubleClick: L.editable && B ? () => xt(a, L.field, r[L.field]) : void 0,
1475
+ children: vi(L, r, a, t)
1476
+ },
1477
+ L.field
1478
+ );
1479
+ });
1480
+ })(),
1481
+ ce && /* @__PURE__ */ i("td", { className: Qe, onClick: tt, children: fi(a, r) })
1482
+ ]
1483
+ }
1484
+ ),
1485
+ q && o && /* @__PURE__ */ i("tr", { className: "nice-datagrid__detail-row", children: /* @__PURE__ */ i("td", { colSpan: Ct, children: q(r) }) })
1486
+ ] }, a);
1487
+ };
1488
+ return ir ? null : /* @__PURE__ */ p(
1489
+ "div",
1490
+ {
1491
+ ref: fe,
1492
+ className: `nice-datagrid ${Ui ? "nice-datagrid--print" : ""} ${It ? "nice-datagrid--sticky-header" : ""} ${Ri ? "nice-datagrid--sticky-footer" : ""} ${se ? "nice-datagrid--auto-pagination" : ""} ${ke ? "nice-datagrid--disabled" : ""} ${En && !ke ? "nice-datagrid--readonly" : ""} ${Ht ? "nice-datagrid--error" : ""} ${Qi || ""}`,
1493
+ "aria-disabled": ke || void 0,
1494
+ style: Zi,
1495
+ role: "grid",
1496
+ "aria-label": d("datagrid.title", "Data Grid"),
1497
+ "aria-rowcount": E.length,
1498
+ "aria-colcount": P.length,
1499
+ "aria-busy": ct || void 0,
1500
+ tabIndex: Fe ? 0 : void 0,
1501
+ onKeyDown: Fe ? Gr : void 0,
1502
+ children: [
1503
+ Ht && /* @__PURE__ */ i("div", { className: "nice-datagrid__error", role: "alert", children: Ht }),
1504
+ (Cn || zn || Sn || oe?.length || at || g) && /* @__PURE__ */ p("div", { className: "nice-datagrid__toolbar", children: [
1505
+ Cn && /* @__PURE__ */ i("div", { className: "nice-datagrid__search", children: /* @__PURE__ */ i(
1506
+ "input",
1507
+ {
1508
+ type: "text",
1509
+ value: z ? I.search : dt,
1510
+ "aria-label": d("controls.search", "Search"),
1511
+ onChange: (e) => {
1512
+ z ? I.setSearch(e.target.value) : (sr(e.target.value), qe(1));
1513
+ },
1514
+ placeholder: Ti || d("controls.search", "Search...")
1515
+ }
1516
+ ) }),
1517
+ g && /* @__PURE__ */ p(
1518
+ "button",
1519
+ {
1520
+ type: "button",
1521
+ className: `nice-btn nice-btn--sm nice-btn--icon-only ${xe > 0 ? "nice-btn--primary" : "nice-btn--secondary"}`,
1522
+ "aria-expanded": Pn,
1523
+ "aria-label": `${d("controls.filter", "Filter")}${xe > 0 ? ` (${xe})` : ""}`,
1524
+ title: `${d("controls.filter", "Filter")}${xe > 0 ? ` (${xe})` : ""}`,
1525
+ onClick: () => Bn((e) => !e),
1526
+ style: { position: "relative" },
1527
+ children: [
1528
+ /* @__PURE__ */ i($, { name: "filter", size: 14 }),
1529
+ xe > 0 && /* @__PURE__ */ i("span", { className: "nice-datagrid__filter-badge", children: xe })
1530
+ ]
1531
+ }
1532
+ ),
1533
+ oe && oe.length > 0 && /* @__PURE__ */ i(
1534
+ "div",
1535
+ {
1536
+ className: "nice-datagrid__quick-filters",
1537
+ style: { display: "flex", gap: 6, flexWrap: "wrap" },
1538
+ children: oe.map((e) => /* @__PURE__ */ p(
1539
+ "button",
1540
+ {
1541
+ className: `nice-datagrid__quick-filter ${Y.includes(e.key) ? "nice-datagrid__quick-filter--active" : ""}`,
1542
+ onClick: () => Kr(e.key),
1543
+ style: {
1544
+ display: "inline-flex",
1545
+ alignItems: "center",
1546
+ gap: 4,
1547
+ padding: "3px 10px",
1548
+ fontSize: "0.75rem",
1549
+ border: "1px solid var(--nice-border-color)",
1550
+ borderRadius: 12,
1551
+ background: Y.includes(e.key) ? `var(--color-${e.color || "primary"})` : "var(--nice-bg-primary)",
1552
+ color: Y.includes(e.key) ? "var(--nice-text-primary, #fff)" : "inherit",
1553
+ cursor: "pointer",
1554
+ transition: "all 0.15s ease"
1555
+ },
1556
+ children: [
1557
+ e.icon && /* @__PURE__ */ i("span", { children: e.icon }),
1558
+ e.label
1559
+ ]
1560
+ },
1561
+ e.key
1562
+ ))
1563
+ }
1564
+ ),
1565
+ be && /* @__PURE__ */ i(
1566
+ "button",
1567
+ {
1568
+ className: "nice-btn nice-btn--sm nice-btn--ghost",
1569
+ onClick: bn,
1570
+ "aria-label": d("controls.copy", "Copy selected"),
1571
+ title: d("controls.copy", "Copy selected"),
1572
+ style: { marginLeft: 4 },
1573
+ children: /* @__PURE__ */ i($, { name: "copy", size: 14 })
1574
+ }
1575
+ ),
1576
+ Sn && /* @__PURE__ */ p(
1577
+ "button",
1578
+ {
1579
+ className: "nice-btn nice-btn--sm nice-btn--secondary",
1580
+ onClick: jr,
1581
+ title: d("controls.exportCsv", "Export CSV"),
1582
+ children: [
1583
+ /* @__PURE__ */ i($, { name: "download", size: 14 }),
1584
+ d("controls.exportCsv", "Export CSV")
1585
+ ]
1586
+ }
1587
+ ),
1588
+ at && /* @__PURE__ */ p(
1589
+ "button",
1590
+ {
1591
+ type: "button",
1592
+ className: "nice-btn nice-btn--sm nice-btn--primary",
1593
+ onClick: () => Ne({ key: null, data: {} }),
1594
+ title: d("datagrid.addRow", "Add row"),
1595
+ children: [
1596
+ /* @__PURE__ */ i($, { name: "plus", size: 14 }),
1597
+ d("datagrid.add", "Add")
1598
+ ]
1599
+ }
1600
+ ),
1601
+ zn
1602
+ ] }),
1603
+ g && Pn && /* @__PURE__ */ i(
1604
+ "div",
1605
+ {
1606
+ className: "nice-datagrid__filter-panel",
1607
+ style: { padding: "8px 12px", borderBottom: "1px solid var(--nice-border-color)" },
1608
+ children: /* @__PURE__ */ i(
1609
+ Mi,
1610
+ {
1611
+ fields: dr,
1612
+ value: de,
1613
+ onChange: (e) => {
1614
+ jn(e), qe(1);
1615
+ },
1616
+ presets: ge,
1617
+ onSavePreset: he,
1618
+ onDeletePreset: ye
1619
+ }
1620
+ )
1621
+ }
1622
+ ),
1623
+ M && A.size > 0 && (Rt?.length || Tt) && /* @__PURE__ */ p(
1624
+ "div",
1625
+ {
1626
+ className: "nice-datagrid__bulk-toolbar",
1627
+ role: "toolbar",
1628
+ "aria-label": d("datagrid.bulkActions", "Bulk actions"),
1629
+ style: {
1630
+ display: "flex",
1631
+ alignItems: "center",
1632
+ gap: 8,
1633
+ padding: "6px 12px",
1634
+ background: "var(--nice-bg-tertiary, #f1f5f9)",
1635
+ borderBottom: "1px solid var(--nice-border-color)",
1636
+ flexWrap: "wrap"
1637
+ },
1638
+ children: [
1639
+ /* @__PURE__ */ i("span", { style: { fontSize: "0.85rem", color: "var(--nice-text-secondary)" }, children: d("datagrid.selectedCount", "{count} selected").replace(
1640
+ "{count}",
1641
+ String(A.size)
1642
+ ) }),
1643
+ (Rt || []).map((e) => {
1644
+ const t = Array.from(A), n = hi.filter((a) => A.has(String(a[m]))), r = e.disabled?.(t, n) || !1;
1645
+ return /* @__PURE__ */ p(
1646
+ "button",
1647
+ {
1648
+ type: "button",
1649
+ className: `nice-btn nice-btn--sm nice-btn--${e.variant || "secondary"}`,
1650
+ disabled: r,
1651
+ onClick: () => e.onClick(t, n),
1652
+ children: [
1653
+ e.icon,
1654
+ e.icon && " ",
1655
+ e.label
1656
+ ]
1657
+ },
1658
+ e.key
1659
+ );
1660
+ }),
1661
+ Tt && !Rt?.length && /* @__PURE__ */ p(
1662
+ "button",
1663
+ {
1664
+ type: "button",
1665
+ className: "nice-btn nice-btn--sm nice-btn--danger",
1666
+ onClick: () => {
1667
+ const e = Array.from(A), t = hi.filter(
1668
+ (n) => A.has(String(n[m]))
1669
+ );
1670
+ Tt(e, t);
1671
+ },
1672
+ children: [
1673
+ /* @__PURE__ */ i($, { name: "trash", size: 14 }),
1674
+ d("datagrid.deleteSelected", "Delete selected")
1675
+ ]
1676
+ }
1677
+ ),
1678
+ /* @__PURE__ */ i(
1679
+ "button",
1680
+ {
1681
+ type: "button",
1682
+ className: "nice-btn nice-btn--xs nice-btn--ghost",
1683
+ onClick: () => {
1684
+ const e = /* @__PURE__ */ new Set();
1685
+ le === void 0 && Xt(e), S?.(e);
1686
+ },
1687
+ style: { marginLeft: "auto" },
1688
+ children: d("datagrid.clearSelection", "Clear")
1689
+ }
1690
+ )
1691
+ ]
1692
+ }
1693
+ ),
1694
+ /* @__PURE__ */ p(
1695
+ "div",
1696
+ {
1697
+ ref: pt,
1698
+ className: `nice-datagrid__table-wrap ${te ? "nice-datagrid__table-wrap--virtual" : ""}`,
1699
+ style: te ? { maxHeight: Math.min(E.length * H, 600), overflowY: "auto" } : void 0,
1700
+ onScroll: te ? (e) => ur(e.currentTarget.scrollTop) : void 0,
1701
+ children: [
1702
+ te && /* @__PURE__ */ p("div", { style: { height: E.length * H, position: "relative" }, children: [
1703
+ /* @__PURE__ */ i("table", { className: bi, style: { position: "sticky", top: 0, zIndex: 3 }, children: /* @__PURE__ */ p("thead", { children: [
1704
+ _i(
1705
+ (q ? 1 : 0) + (T ? 1 : 0) + (M ? 1 : 0)
1706
+ ),
1707
+ /* @__PURE__ */ p("tr", { children: [
1708
+ q && /* @__PURE__ */ i("th", { className: "nice-datagrid__expand-col", style: { width: 36 } }),
1709
+ T && /* @__PURE__ */ i("th", { style: { width: 28 } }),
1710
+ M && /* @__PURE__ */ i(
1711
+ "th",
1712
+ {
1713
+ className: "nice-datagrid__checkbox",
1714
+ style: Ue ? {
1715
+ position: "sticky",
1716
+ left: 0,
1717
+ zIndex: 3,
1718
+ background: "var(--nice-bg-primary, #fff)"
1719
+ } : void 0,
1720
+ children: /* @__PURE__ */ i(
1721
+ "input",
1722
+ {
1723
+ type: "checkbox",
1724
+ checked: $e,
1725
+ ref: (e) => {
1726
+ e && (e.indeterminate = ai && !$e);
1727
+ },
1728
+ onChange: li,
1729
+ "aria-label": d("controls.selectAll", "Select all")
1730
+ }
1731
+ )
1732
+ }
1733
+ ),
1734
+ _.map((e, t) => xi(e, t)),
1735
+ ce && /* @__PURE__ */ i(
1736
+ "th",
1737
+ {
1738
+ className: Qe,
1739
+ scope: "col",
1740
+ "aria-label": d("controls.delete", "Delete")
1741
+ }
1742
+ )
1743
+ ] })
1744
+ ] }) }),
1745
+ ci.map((e, t) => {
1746
+ const n = e._vIdx ?? 0, r = n < _e, a = (r ? Zt : 0) + n * H, s = r ? ` nice-datagrid__row--frozen${n === Math.min(_e, E.length) - 1 ? " nice-datagrid__row--frozen-last" : ""}` : "";
1747
+ if (e.type === "group") {
1748
+ const f = e;
1749
+ return /* @__PURE__ */ p(
1750
+ "div",
1751
+ {
1752
+ role: "button",
1753
+ tabIndex: 0,
1754
+ "aria-expanded": f.expanded,
1755
+ onKeyDown: xn,
1756
+ className: `nice-datagrid__group-row${s}`,
1757
+ style: {
1758
+ position: "absolute",
1759
+ top: a,
1760
+ zIndex: r ? 2 : void 0,
1761
+ height: H,
1762
+ left: 0,
1763
+ right: 0
1764
+ },
1765
+ onClick: () => oi(f.key),
1766
+ children: [
1767
+ /* @__PURE__ */ i("span", { className: "nice-datagrid__group-toggle", children: f.expanded ? /* @__PURE__ */ i(et, {}) : /* @__PURE__ */ i(kt, {}) }),
1768
+ it ? it(f.value, f.rows) : /* @__PURE__ */ p(Dt, { children: [
1769
+ String(f.value),
1770
+ " (",
1771
+ f.rows.length,
1772
+ ")"
1773
+ ] })
1774
+ ]
1775
+ },
1776
+ f.key
1777
+ );
1778
+ }
1779
+ const { row: o, key: u } = e, c = A.has(u), N = mt.has(u);
1780
+ return /* @__PURE__ */ p(zt.Fragment, { children: [
1781
+ /* @__PURE__ */ p(
1782
+ "div",
1783
+ {
1784
+ role: ve ? "button" : void 0,
1785
+ tabIndex: ve ? 0 : void 0,
1786
+ onKeyDown: ve ? xn : void 0,
1787
+ className: `nice-datagrid__vrow ${c ? "nice-datagrid__row--selected" : ""} ${ze === t ? "nice-datagrid__row--dragging" : ""}${s}`,
1788
+ style: {
1789
+ position: "absolute",
1790
+ top: a,
1791
+ zIndex: r ? 2 : void 0,
1792
+ height: H,
1793
+ left: 0,
1794
+ right: 0,
1795
+ display: "flex",
1796
+ alignItems: "center"
1797
+ },
1798
+ onClick: () => ve?.(o),
1799
+ onDoubleClick: Le === "popup" && (rt || B) ? () => Ne({ key: u, data: { ...o } }) : void 0,
1800
+ draggable: T,
1801
+ onDragStart: T ? () => Me(t) : void 0,
1802
+ onDragOver: T ? (f) => f.preventDefault() : void 0,
1803
+ onDrop: T && st && ze != null ? () => {
1804
+ st(ze, t), Me(null);
1805
+ } : void 0,
1806
+ onDragEnd: T ? () => Me(null) : void 0,
1807
+ children: [
1808
+ q && /* @__PURE__ */ i(
1809
+ "div",
1810
+ {
1811
+ role: "button",
1812
+ tabIndex: 0,
1813
+ "aria-expanded": N,
1814
+ "aria-label": d(
1815
+ N ? "controls.collapse" : "controls.expand",
1816
+ N ? "Collapse" : "Expand"
1817
+ ),
1818
+ onKeyDown: xn,
1819
+ className: "nice-datagrid__expand-col",
1820
+ style: { width: 36, flexShrink: 0, textAlign: "center", cursor: "pointer" },
1821
+ onClick: (f) => {
1822
+ f.stopPropagation(), Jn(u);
1823
+ },
1824
+ children: /* @__PURE__ */ i("span", { className: "nice-datagrid__expand-btn", "data-expanded": N, children: N ? /* @__PURE__ */ i(et, {}) : /* @__PURE__ */ i(kt, {}) })
1825
+ }
1826
+ ),
1827
+ T && /* @__PURE__ */ i(
1828
+ "div",
1829
+ {
1830
+ "aria-label": d("datagrid.dragRow", "Drag to reorder"),
1831
+ style: {
1832
+ width: 28,
1833
+ flexShrink: 0,
1834
+ cursor: "grab",
1835
+ textAlign: "center",
1836
+ color: "var(--nice-text-muted)",
1837
+ display: "inline-flex",
1838
+ alignItems: "center",
1839
+ justifyContent: "center"
1840
+ },
1841
+ children: /* @__PURE__ */ i($, { name: "more-vertical", size: 14 })
1842
+ }
1843
+ ),
1844
+ M && /* @__PURE__ */ i(
1845
+ "div",
1846
+ {
1847
+ role: "presentation",
1848
+ className: "nice-datagrid__checkbox",
1849
+ style: { width: 36, flexShrink: 0 },
1850
+ onClick: (f) => f.stopPropagation(),
1851
+ children: /* @__PURE__ */ i(
1852
+ "input",
1853
+ {
1854
+ type: "checkbox",
1855
+ checked: c,
1856
+ onChange: () => si(u)
1857
+ }
1858
+ )
1859
+ }
1860
+ ),
1861
+ _.map((f) => /* @__PURE__ */ i(
1862
+ "div",
1863
+ {
1864
+ "data-field": f.field,
1865
+ className: "nice-datagrid__vcell",
1866
+ style: {
1867
+ width: Oe(f) || "auto",
1868
+ flex: Oe(f) ? `0 0 ${typeof Oe(f) == "number" ? `${Oe(f)}px` : Oe(f)}` : 1,
1869
+ textAlign: f.align,
1870
+ overflow: "hidden",
1871
+ textOverflow: "ellipsis",
1872
+ whiteSpace: "nowrap",
1873
+ padding: "0 8px"
1874
+ },
1875
+ onDoubleClick: f.editable && B ? () => xt(u, f.field, o[f.field]) : void 0,
1876
+ children: vi(f, o, u, n)
1877
+ },
1878
+ f.field
1879
+ )),
1880
+ ce && /* @__PURE__ */ i("div", { role: "presentation", className: Qe, onClick: tt, children: fi(u, o) })
1881
+ ]
1882
+ }
1883
+ ),
1884
+ q && N && /* @__PURE__ */ i(
1885
+ "div",
1886
+ {
1887
+ className: "nice-datagrid__detail-row",
1888
+ style: {
1889
+ position: "absolute",
1890
+ top: (n + 1) * H,
1891
+ left: 0,
1892
+ right: 0,
1893
+ padding: "8px 12px",
1894
+ background: "var(--nice-bg-secondary, #f8f8f8)"
1895
+ },
1896
+ children: q(o)
1897
+ }
1898
+ )
1899
+ ] }, u);
1900
+ })
1901
+ ] }),
1902
+ !te && /* @__PURE__ */ p("table", { className: bi, children: [
1903
+ /* @__PURE__ */ p("thead", { children: [
1904
+ _i(
1905
+ (Be ? 1 : 0) + (q ? 1 : 0) + (T ? 1 : 0) + (M ? 1 : 0)
1906
+ ),
1907
+ /* @__PURE__ */ p("tr", { children: [
1908
+ Be && /* @__PURE__ */ i("th", { className: "nice-datagrid__row-indicator" }),
1909
+ q && /* @__PURE__ */ i("th", { className: "nice-datagrid__expand-col", style: { width: 36 } }),
1910
+ T && /* @__PURE__ */ i("th", { style: { width: 28 } }),
1911
+ M && /* @__PURE__ */ i(
1912
+ "th",
1913
+ {
1914
+ className: "nice-datagrid__checkbox",
1915
+ style: Ue ? {
1916
+ position: "sticky",
1917
+ left: 0,
1918
+ zIndex: 3,
1919
+ background: "var(--nice-bg-primary, #fff)"
1920
+ } : void 0,
1921
+ children: /* @__PURE__ */ i(
1922
+ "input",
1923
+ {
1924
+ type: "checkbox",
1925
+ checked: $e,
1926
+ ref: (e) => {
1927
+ e && (e.indeterminate = ai && !$e);
1928
+ },
1929
+ onChange: li,
1930
+ "aria-label": d("controls.selectAll", "Select all")
1931
+ }
1932
+ )
1933
+ }
1934
+ ),
1935
+ _.map((e, t) => xi(e, t)),
1936
+ ce && /* @__PURE__ */ i(
1937
+ "th",
1938
+ {
1939
+ className: Qe,
1940
+ scope: "col",
1941
+ "aria-label": d("controls.delete", "Delete")
1942
+ }
1943
+ )
1944
+ ] })
1945
+ ] }),
1946
+ /* @__PURE__ */ i("tbody", { children: ct ? /* @__PURE__ */ i("tr", { children: /* @__PURE__ */ i("td", { colSpan: Ct, className: "nice-datagrid__empty", children: /* @__PURE__ */ i("div", { className: "nice-spinner nice-spinner--md", style: { margin: "0 auto" } }) }) }) : E.length === 0 ? /* @__PURE__ */ i("tr", { children: /* @__PURE__ */ i("td", { colSpan: Ct, className: "nice-datagrid__empty", children: Ki || d("controls.noData", "No data available") }) }) : /* @__PURE__ */ p(Dt, { children: [
1947
+ yn.map(
1948
+ (e, t) => e.type === "data" && _n(e, t, "top")
1949
+ ),
1950
+ vn.map((e, t) => {
1951
+ if (e.type === "group") {
1952
+ const n = e, r = di(n.key);
1953
+ return /* @__PURE__ */ i(
1954
+ "tr",
1955
+ {
1956
+ "data-row-key": n.key,
1957
+ className: `nice-datagrid__group-row ${r.className}`.trim(),
1958
+ style: r.style,
1959
+ onClick: () => oi(n.key),
1960
+ children: /* @__PURE__ */ p("td", { colSpan: Ct, className: "nice-datagrid__group-cell", children: [
1961
+ /* @__PURE__ */ i("span", { className: "nice-datagrid__group-toggle", children: n.expanded ? /* @__PURE__ */ i(et, {}) : /* @__PURE__ */ i(kt, {}) }),
1962
+ it ? it(n.value, n.rows) : /* @__PURE__ */ p(Dt, { children: [
1963
+ String(n.value),
1964
+ " (",
1965
+ n.rows.length,
1966
+ ")"
1967
+ ] })
1968
+ ] })
1969
+ },
1970
+ n.key
1971
+ );
1972
+ }
1973
+ return _n(e, t);
1974
+ }),
1975
+ $r.map(
1976
+ (e, t) => e.type === "data" && _n(e, t, "bottom")
1977
+ )
1978
+ ] }) })
1979
+ ] })
1980
+ ]
1981
+ }
1982
+ ),
1983
+ Dr && !ct && J.length > 0 && /* @__PURE__ */ i(
1984
+ "div",
1985
+ {
1986
+ className: "nice-datagrid__summary",
1987
+ role: "row",
1988
+ "aria-label": d("datagrid.summary", "Summary"),
1989
+ children: _.map((e) => /* @__PURE__ */ i(
1990
+ "div",
1991
+ {
1992
+ className: "nice-datagrid__summary-cell",
1993
+ style: { textAlign: e.align },
1994
+ children: e.aggregate ? (e.aggregateLabel || e.aggregate.toUpperCase()) + ": " + ha(G, e.field, e.aggregate) : ""
1995
+ },
1996
+ e.field
1997
+ ))
1998
+ }
1999
+ ),
2000
+ O && /* @__PURE__ */ p("div", { className: "nice-datagrid__footer", children: [
2001
+ /* @__PURE__ */ p("span", { className: "nice-datagrid__footer-info", children: [
2002
+ d("controls.showing", "Showing"),
2003
+ " ",
2004
+ (Re - 1) * pe + 1,
2005
+ "–",
2006
+ Math.min(Re * pe, vt),
2007
+ " ",
2008
+ d("controls.of", "of"),
2009
+ " ",
2010
+ vt,
2011
+ se && /* @__PURE__ */ p("span", { className: "nice-datagrid__page-size-label", children: [
2012
+ " · ",
2013
+ pe,
2014
+ " ",
2015
+ d("controls.perPage", "/ page")
2016
+ ] })
2017
+ ] }),
2018
+ /* @__PURE__ */ i(
2019
+ ca,
2020
+ {
2021
+ page: Re,
2022
+ totalPages: mn,
2023
+ onChange: qe,
2024
+ showInfo: !0,
2025
+ pageSize: pe,
2026
+ showPageSize: !se,
2027
+ pageSizeOptions: [5, 10, 25, 50, 100],
2028
+ onPageSizeChange: (e) => {
2029
+ z ? I.setPageSize(e) : (Gn(e), qe(1));
2030
+ },
2031
+ showFirstLast: !0
2032
+ }
2033
+ )
2034
+ ] }),
2035
+ Wi && !ct && /* @__PURE__ */ p("div", { className: "nice-datagrid__status-bar", children: [
2036
+ /* @__PURE__ */ p("span", { children: [
2037
+ d("controls.totalRows", "Total rows"),
2038
+ ": ",
2039
+ vt
2040
+ ] }),
2041
+ M && A.size > 0 && /* @__PURE__ */ p("span", { children: [
2042
+ d("controls.selected", "Selected"),
2043
+ ": ",
2044
+ A.size
2045
+ ] })
2046
+ ] }),
2047
+ Ie && ot && /* @__PURE__ */ i(
2048
+ "div",
2049
+ {
2050
+ role: "presentation",
2051
+ className: "nice-datagrid__context-menu",
2052
+ style: { position: "fixed", left: Ie.x, top: Ie.y, zIndex: 9999 },
2053
+ onClick: (e) => e.stopPropagation(),
2054
+ children: ot.map((e) => /* @__PURE__ */ p(
2055
+ "button",
2056
+ {
2057
+ className: "nice-datagrid__context-item",
2058
+ disabled: e.disabled,
2059
+ onClick: () => {
2060
+ Vi?.(e.key, Ie.row), tn(null);
2061
+ },
2062
+ children: [
2063
+ e.icon && /* @__PURE__ */ i("span", { className: "nice-datagrid__context-icon", children: e.icon }),
2064
+ e.label
2065
+ ]
2066
+ },
2067
+ e.key
2068
+ ))
2069
+ }
2070
+ ),
2071
+ Pe && Ve !== null && we.portalTarget && (() => {
2072
+ const e = l.find((a) => a.field === Ve);
2073
+ if (!e)
2074
+ return null;
2075
+ const t = Vr(e.field), n = (a) => a.toLocaleString(void 0, { maximumFractionDigits: 2 }), r = t.type === "numeric" ? [
2076
+ [d("datagrid.stats.count", "Count"), n(t.count)],
2077
+ [d("datagrid.stats.sum", "Sum"), n(t.sum)],
2078
+ [d("datagrid.stats.average", "Average"), n(t.avg)],
2079
+ [d("datagrid.stats.min", "Min"), n(t.min)],
2080
+ [d("datagrid.stats.max", "Max"), n(t.max)],
2081
+ [d("datagrid.stats.stdDev", "Std. deviation"), n(t.stdDev)]
2082
+ ] : [
2083
+ [d("datagrid.stats.count", "Count"), n(t.count)],
2084
+ [d("datagrid.stats.unique", "Unique values"), n(t.unique)]
2085
+ ];
2086
+ return Nn(
2087
+ /* @__PURE__ */ i(
2088
+ "dl",
2089
+ {
2090
+ ref: we.popupRef,
2091
+ id: ti,
2092
+ role: "tooltip",
2093
+ className: `nice-datagrid__column-stats ${we.themeClass}`,
2094
+ style: {
2095
+ left: we.coords?.left ?? 0,
2096
+ top: we.coords?.top ?? 0,
2097
+ opacity: we.ready ? 1 : 0
2098
+ },
2099
+ children: r.map(([a, s]) => /* @__PURE__ */ p(zt.Fragment, { children: [
2100
+ /* @__PURE__ */ i("dt", { children: a }),
2101
+ /* @__PURE__ */ i("dd", { children: s })
2102
+ ] }, a))
2103
+ }
2104
+ ),
2105
+ we.portalTarget
2106
+ );
2107
+ })(),
2108
+ Ae !== null && ie.portalTarget && (() => {
2109
+ const e = l.find((s) => s.field === Ae);
2110
+ if (!e)
2111
+ return null;
2112
+ const t = v && e.sortable !== !1, n = Q === e.field && !!V, r = !!g && e.filterable !== !1, a = (s, o, u, c, N = !1) => /* @__PURE__ */ p(
2113
+ "button",
2114
+ {
2115
+ type: "button",
2116
+ role: "menuitem",
2117
+ className: "nice-datagrid__context-item",
2118
+ disabled: N,
2119
+ onClick: () => Ar(c),
2120
+ children: [
2121
+ /* @__PURE__ */ i("span", { className: "nice-datagrid__context-icon", children: /* @__PURE__ */ i($, { name: o, size: 14 }) }),
2122
+ u
2123
+ ]
2124
+ },
2125
+ s
2126
+ );
2127
+ return Nn(
2128
+ /* @__PURE__ */ p(
2129
+ "div",
2130
+ {
2131
+ ref: ie.popupRef,
2132
+ role: "menu",
2133
+ "aria-label": d("datagrid.columnMenu", "Column menu"),
2134
+ className: `nice-datagrid__context-menu ${ie.themeClass}`,
2135
+ style: {
2136
+ position: "fixed",
2137
+ left: ie.coords?.left ?? 0,
2138
+ top: ie.coords?.top ?? 0,
2139
+ zIndex: 9999,
2140
+ opacity: ie.ready ? 1 : 0
2141
+ },
2142
+ onKeyDown: Rr,
2143
+ children: [
2144
+ t && a(
2145
+ "sort-asc",
2146
+ "sort-asc",
2147
+ d("datagrid.sortAsc", "Sort ascending"),
2148
+ () => He(e.field, "asc")
2149
+ ),
2150
+ t && a(
2151
+ "sort-desc",
2152
+ "sort-desc",
2153
+ d("datagrid.sortDesc", "Sort descending"),
2154
+ () => He(e.field, "desc")
2155
+ ),
2156
+ t && n && a(
2157
+ "sort-clear",
2158
+ "sort",
2159
+ d("datagrid.clearSort", "Clear sort"),
2160
+ () => He(e.field, null)
2161
+ ),
2162
+ r && a(
2163
+ "filter",
2164
+ "filter",
2165
+ d("controls.filter", "Filter"),
2166
+ () => Ir(e.field)
2167
+ ),
2168
+ a(
2169
+ "hide",
2170
+ "eye-off",
2171
+ d("datagrid.hideColumn", "Hide column"),
2172
+ () => sn((s) => [...s, e.field]),
2173
+ P.length <= 1
2174
+ ),
2175
+ gt.length > 0 && a(
2176
+ "show-all",
2177
+ "eye",
2178
+ d("datagrid.showAllColumns", "Show all columns"),
2179
+ () => sn([])
2180
+ ),
2181
+ a(
2182
+ "auto-fit",
2183
+ "columns",
2184
+ d("datagrid.autoFit", "Auto-fit width"),
2185
+ () => zr(e.field)
2186
+ )
2187
+ ]
2188
+ }
2189
+ ),
2190
+ ie.portalTarget
2191
+ );
2192
+ })(),
2193
+ (Le === "popup" || at) && De && (() => {
2194
+ const e = De.key === null, t = $i ?? l.filter((n) => !n.hidden && n.field !== m).map((n) => {
2195
+ let r = "text";
2196
+ return n.dataType === "number" || n.dataType === "currency" || n.dataType === "percent" ? r = "number" : n.dataType === "boolean" ? r = "checkbox" : n.dataType === "date" && (r = "date"), {
2197
+ field: n.field,
2198
+ label: n.header,
2199
+ type: r,
2200
+ required: n.validation?.required
2201
+ };
2202
+ });
2203
+ return /* @__PURE__ */ i(
2204
+ oa,
2205
+ {
2206
+ open: !0,
2207
+ onClose: () => Ne(null),
2208
+ title: Ei ?? (e ? d("datagrid.addRow", "Add row") : d("datagrid.editRow", "Edit row")),
2209
+ size: "lg",
2210
+ children: /* @__PURE__ */ i(
2211
+ la,
2212
+ {
2213
+ items: t,
2214
+ data: De.data,
2215
+ columns: Oi,
2216
+ showActions: !0,
2217
+ submitLabel: e ? d("controls.add", "Add") : d("controls.save", "Save"),
2218
+ cancelLabel: d("controls.cancel", "Cancel"),
2219
+ onCancel: () => Ne(null),
2220
+ ...Li,
2221
+ onFieldChange: (n, r) => Ne((a) => a && { ...a, data: { ...a.data, [n]: r } }),
2222
+ onSubmit: (n) => {
2223
+ e ? at?.(n) : De.key && (rt ? rt(De.key, n) : B && Object.keys(n).forEach((r) => {
2224
+ B(De.key, r, n[r]);
2225
+ })), Ne(null);
2226
+ }
2227
+ }
2228
+ )
2229
+ }
2230
+ );
2231
+ })(),
2232
+ nn && typeof document < "u" && Nn(
2233
+ /* @__PURE__ */ i(
2234
+ sa,
2235
+ {
2236
+ visible: !0,
2237
+ header: d("confirm.title", "Confirmation"),
2238
+ message: typeof lt == "string" ? lt : d("confirm.deleteMessage", "Are you sure you want to delete this?"),
2239
+ acceptLabel: d("controls.delete", "Delete"),
2240
+ rejectLabel: d("controls.cancel", "Cancel"),
2241
+ onAccept: Pr,
2242
+ onReject: Br
2243
+ }
2244
+ ),
2245
+ document.body
2246
+ )
2247
+ ]
2248
+ }
2249
+ );
2250
+ }
2251
+ process.env.NODE_ENV !== "production" && (Ai.displayName = "NiceDataGrid");
2252
+ const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2253
+ __proto__: null,
2254
+ NiceDataGrid: Ai
2255
+ }, Symbol.toStringTag, { value: "Module" }));
2256
+ export {
2257
+ Ai as N,
2258
+ Di as a,
2259
+ va as b,
2260
+ ga as c,
2261
+ ha as d,
2262
+ St as e,
2263
+ ya as f,
2264
+ Mi as g,
2265
+ La as h,
2266
+ ki as m,
2267
+ Si as r,
2268
+ ma as w
2269
+ };