@nice2dev/ui 1.3.0 → 1.3.2

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