@nice2dev/ui 1.3.9 → 1.3.10

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 (59) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/NiceColorPicker-BLwYNSXJ.cjs +1 -0
  3. package/dist/NiceColorPicker-DS59tNkP.js +552 -0
  4. package/dist/NiceDataGrid-CL2_7fS7.cjs +10 -0
  5. package/dist/NiceDataGrid-CpJrRN_H.js +2269 -0
  6. package/dist/NiceForm-BQj-K7p7.cjs +1 -0
  7. package/dist/NiceForm-HQ4h7hX_.js +5023 -0
  8. package/dist/NiceGantt-BygumlaY.cjs +1 -0
  9. package/dist/NiceGantt-DTC7OH-v.js +334 -0
  10. package/dist/NiceHtmlEditor-BtpuaLln.js +901 -0
  11. package/dist/NiceHtmlEditor-C1OVtLQ6.cjs +10 -0
  12. package/dist/NiceMention-CVxxCVtQ.js +11668 -0
  13. package/dist/NiceMention-Te66Oid1.cjs +430 -0
  14. package/dist/NiceModuleLifecyclePanel-DCrFyUH8.cjs +1 -0
  15. package/dist/NiceModuleLifecyclePanel-Mt80MdET.js +7441 -0
  16. package/dist/NicePagination-CKsAP38Q.cjs +1 -0
  17. package/dist/NicePagination-zOed5QxG.js +202 -0
  18. package/dist/NicePivotGrid-Clue9FM5.js +1184 -0
  19. package/dist/NicePivotGrid-Cnkr9WkC.cjs +152 -0
  20. package/dist/NiceSavedQueryPanel-NgG58w6i.js +6226 -0
  21. package/dist/NiceSavedQueryPanel-lTWY2plm.cjs +587 -0
  22. package/dist/NiceScheduler-BWwqFKEc.js +1712 -0
  23. package/dist/NiceScheduler-DqWEJU7g.cjs +5 -0
  24. package/dist/NiceSelect-BNPXs6FQ.cjs +1 -0
  25. package/dist/NiceSelect-DEruWHan.js +495 -0
  26. package/dist/NiceWindow-D3V7A69Q.js +2247 -0
  27. package/dist/NiceWindow-pgR4c-kQ.cjs +1 -0
  28. package/dist/core-lazy-Bjdu111n.js +351 -0
  29. package/dist/core-lazy-Bx_8BOlG.cjs +1 -0
  30. package/dist/data.cjs +1 -1
  31. package/dist/data.d.ts +46 -5
  32. package/dist/data.mjs +3 -3
  33. package/dist/devops-CqhA0rjL.js +9130 -0
  34. package/dist/devops-cgRBnZVX.cjs +18 -0
  35. package/dist/devops.cjs +1 -1
  36. package/dist/devops.mjs +1 -1
  37. package/dist/editors.cjs +1 -1
  38. package/dist/editors.mjs +7 -7
  39. package/dist/feedback.cjs +1 -1
  40. package/dist/feedback.mjs +1 -1
  41. package/dist/index.cjs +108 -108
  42. package/dist/index.css +1 -1
  43. package/dist/index.d.ts +51 -8
  44. package/dist/index.mjs +13739 -13579
  45. package/dist/lazy.cjs +1 -1
  46. package/dist/lazy.mjs +15 -15
  47. package/dist/navigation.cjs +1 -1
  48. package/dist/navigation.d.ts +2 -0
  49. package/dist/navigation.mjs +3 -3
  50. package/dist/no-code-BQqK8mvU.cjs +331 -0
  51. package/dist/no-code-Cppb-xz3.js +8320 -0
  52. package/dist/no-code.cjs +1 -1
  53. package/dist/no-code.mjs +1 -1
  54. package/dist/overlays.cjs +1 -1
  55. package/dist/overlays.mjs +1 -1
  56. package/dist/pickerCommons-BA3-D5RC.js +663 -0
  57. package/dist/pickerCommons-KrBqCBDn.cjs +1 -0
  58. package/dist/style.css +1 -1
  59. package/package.json +4 -4
@@ -0,0 +1,1184 @@
1
+ import { jsxs as E, Fragment as xe, jsx as p } from "react/jsx-runtime";
2
+ import { useNiceTranslation as se, useComponentDisplayStyle as we, useComponentDisplayClass as ve, useNiceAccessMode as ge, normalizeVariant as $e, useMenuButton as _e, NiceIcon as J, useControllableState as ke } from "@nice2dev/ui-core";
3
+ import { useState as G, useRef as ne, useLayoutEffect as ae, useCallback as P, useEffect as Ne, useMemo as Z } from "react";
4
+ import { createPortal as Ce } from "react-dom";
5
+ import { s as Se, u as Te } from "./devops-CqhA0rjL.js";
6
+ import { N as Ue } from "./NiceSelect-DEruWHan.js";
7
+ const De = [], Fe = ({
8
+ text: e,
9
+ label: n,
10
+ icon: o,
11
+ items: r = De,
12
+ variant: u = "primary",
13
+ size: m = "md",
14
+ disabled: c,
15
+ readOnly: f,
16
+ loading: s,
17
+ onItemClick: d,
18
+ splitButton: a,
19
+ onClick: v,
20
+ className: _,
21
+ style: g,
22
+ id: l,
23
+ title: t,
24
+ "data-testid": i,
25
+ accessMode: w,
26
+ displayStyle: D,
27
+ error: N,
28
+ errorPlacement: $ = "bottom"
29
+ }) => {
30
+ const { t: b } = se(), M = we("button", D), U = ve("button", D), y = ge(w, l), k = y === "hidden";
31
+ y === "disabled" && (c = !0), s && (c = !0);
32
+ const C = !c && (f || y === "readOnly"), j = $e(u), O = e || n, [A, W] = G(!1), Y = ne(null), X = ne(null), I = ne(null), Q = ne(null);
33
+ _e(a ? I : X, Q, {
34
+ open: A,
35
+ onOpenChange: (x) => {
36
+ (!x || !C) && W(x);
37
+ }
38
+ });
39
+ const [te, h] = G(void 0), [S, T] = G(null), [F, z] = G("");
40
+ ae(() => {
41
+ h(void 0);
42
+ }, [m, u]), ae(() => {
43
+ if (X.current) {
44
+ const x = X.current.offsetWidth;
45
+ h((B) => B == null || x > B ? x : B);
46
+ }
47
+ }, [O, s]);
48
+ let R = M;
49
+ if (j !== "primary") {
50
+ const x = { ...M };
51
+ delete x.background, delete x.color, (j === "outline" || j === "ghost") && (delete x.border, delete x.borderColor, delete x.borderWidth, delete x.borderStyle, delete x.boxShadow), R = x;
52
+ }
53
+ const L = {
54
+ ...R,
55
+ ...te ? { minWidth: te } : {}
56
+ }, H = P(() => {
57
+ const x = Y.current;
58
+ if (!x)
59
+ return;
60
+ const B = x.getBoundingClientRect();
61
+ T({ top: B.bottom, left: B.left, width: B.width }), z(Se(x));
62
+ }, []);
63
+ ae(() => {
64
+ if (A)
65
+ return H(), window.addEventListener("scroll", H, !0), window.addEventListener("resize", H), () => {
66
+ window.removeEventListener("scroll", H, !0), window.removeEventListener("resize", H);
67
+ };
68
+ }, [A, H]), Ne(() => {
69
+ if (!A)
70
+ return;
71
+ const x = (B) => {
72
+ const fe = B.target;
73
+ Y.current?.contains(fe) || Q.current?.contains(fe) || W(!1);
74
+ };
75
+ return document.addEventListener("mousedown", x), document.addEventListener("touchstart", x), () => {
76
+ document.removeEventListener("mousedown", x), document.removeEventListener("touchstart", x);
77
+ };
78
+ }, [A]);
79
+ const ie = /* @__PURE__ */ E(
80
+ "div",
81
+ {
82
+ className: `nice-dropdown-btn ${_ || ""}`,
83
+ style: { position: "relative", display: "inline-flex", ...g },
84
+ ref: Y,
85
+ "data-testid": i,
86
+ "aria-busy": s || void 0,
87
+ children: [
88
+ a ? /* @__PURE__ */ E(xe, { children: [
89
+ /* @__PURE__ */ E(
90
+ "button",
91
+ {
92
+ ref: X,
93
+ type: "button",
94
+ className: `nice-btn nice-btn--${j} nice-btn--${m} nice-btn--ds-${U} ${s ? "nice-btn--loading" : ""} ${C ? "nice-btn--readonly" : ""}`,
95
+ style: L,
96
+ disabled: c,
97
+ "aria-readonly": C || void 0,
98
+ onClick: () => {
99
+ C || v?.();
100
+ },
101
+ children: [
102
+ s && /* @__PURE__ */ p(
103
+ "svg",
104
+ {
105
+ className: "nice-btn__spinner",
106
+ viewBox: "0 0 24 24",
107
+ fill: "none",
108
+ stroke: "currentColor",
109
+ strokeWidth: "3",
110
+ "aria-hidden": "true",
111
+ children: /* @__PURE__ */ p("circle", { cx: "12", cy: "12", r: "10", strokeDasharray: "31.4 31.4", strokeLinecap: "round" })
112
+ }
113
+ ),
114
+ o && /* @__PURE__ */ p(
115
+ "span",
116
+ {
117
+ className: "nice-btn__icon",
118
+ style: s ? { visibility: "hidden" } : void 0,
119
+ children: o
120
+ }
121
+ ),
122
+ /* @__PURE__ */ p("span", { style: s ? { visibility: "hidden" } : void 0, children: O })
123
+ ]
124
+ }
125
+ ),
126
+ /* @__PURE__ */ p(
127
+ "button",
128
+ {
129
+ ref: I,
130
+ type: "button",
131
+ className: `nice-btn nice-btn--${j} nice-btn--${m} nice-btn--ds-${U} nice-dropdown-btn__caret ${C ? "nice-btn--readonly" : ""}`,
132
+ style: R,
133
+ disabled: c,
134
+ "aria-readonly": C || void 0,
135
+ "aria-haspopup": "menu",
136
+ "aria-expanded": A,
137
+ onClick: () => {
138
+ C || W(!A);
139
+ },
140
+ "aria-label": b("dropDownButton.toggleDropdown", "Toggle dropdown"),
141
+ children: /* @__PURE__ */ p(J, { name: "chevron-down", size: "xs" })
142
+ }
143
+ )
144
+ ] }) : /* @__PURE__ */ E(
145
+ "button",
146
+ {
147
+ ref: X,
148
+ type: "button",
149
+ className: `nice-btn nice-btn--${j} nice-btn--${m} nice-btn--ds-${U} ${s ? "nice-btn--loading" : ""} ${C ? "nice-btn--readonly" : ""}`,
150
+ style: L,
151
+ disabled: c,
152
+ "aria-readonly": C || void 0,
153
+ title: t,
154
+ "aria-label": !O && t ? t : void 0,
155
+ "aria-haspopup": "menu",
156
+ "aria-expanded": A,
157
+ onClick: () => {
158
+ C || W(!A);
159
+ },
160
+ children: [
161
+ s && /* @__PURE__ */ p(
162
+ "svg",
163
+ {
164
+ className: "nice-btn__spinner",
165
+ viewBox: "0 0 24 24",
166
+ fill: "none",
167
+ stroke: "currentColor",
168
+ strokeWidth: "3",
169
+ "aria-hidden": "true",
170
+ children: /* @__PURE__ */ p("circle", { cx: "12", cy: "12", r: "10", strokeDasharray: "31.4 31.4", strokeLinecap: "round" })
171
+ }
172
+ ),
173
+ o && /* @__PURE__ */ p("span", { className: "nice-btn__icon", style: s ? { visibility: "hidden" } : void 0, children: o }),
174
+ /* @__PURE__ */ p("span", { style: s ? { visibility: "hidden" } : void 0, children: O }),
175
+ /* @__PURE__ */ p(
176
+ "span",
177
+ {
178
+ style: {
179
+ marginLeft: "auto",
180
+ paddingLeft: 4,
181
+ display: "inline-flex",
182
+ ...s ? { visibility: "hidden" } : {}
183
+ },
184
+ children: /* @__PURE__ */ p(J, { name: "chevron-down", size: "xs" })
185
+ }
186
+ )
187
+ ]
188
+ }
189
+ ),
190
+ A && S && typeof document < "u" && Ce(
191
+ /* @__PURE__ */ p(
192
+ "ul",
193
+ {
194
+ ref: Q,
195
+ className: `nice-dropdown__list nice-dropdown-btn__menu nice-dropdown-btn__menu--${m} ${F}`,
196
+ "data-theme": F === "nice-dark" ? "dark" : F === "nice-light" ? "light" : void 0,
197
+ role: "menu",
198
+ style: {
199
+ position: "fixed",
200
+ top: S.top,
201
+ left: S.left,
202
+ minWidth: S.width,
203
+ marginTop: 0,
204
+ zIndex: 1e3
205
+ },
206
+ children: r.map((x) => (
207
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- Enter / Space / A pick the item: useMenuButton
208
+ /* @__PURE__ */ E(
209
+ "li",
210
+ {
211
+ role: "menuitem",
212
+ "aria-disabled": x.disabled || void 0,
213
+ className: `nice-dropdown__option ${x.disabled ? "nice-dropdown__option--disabled" : ""} ${x.danger ? "nice-dropdown__option--danger" : ""}`,
214
+ onClick: () => {
215
+ x.disabled || (x.onClick?.(), d?.(x), W(!1));
216
+ },
217
+ children: [
218
+ x.icon && /* @__PURE__ */ p("span", { className: "nice-dropdown-btn__item-icon", children: x.icon }),
219
+ x.text
220
+ ]
221
+ },
222
+ x.key
223
+ )
224
+ ))
225
+ }
226
+ ),
227
+ document.body
228
+ )
229
+ ]
230
+ }
231
+ );
232
+ if (!N)
233
+ return ie;
234
+ const ue = /* @__PURE__ */ p("div", { className: "nice-field__error", role: "alert", children: N });
235
+ return $ === "right" ? /* @__PURE__ */ E("span", { className: `nice-btn-field nice-btn-field--right nice-field--${m}`, children: [
236
+ ie,
237
+ ue
238
+ ] }) : k ? null : /* @__PURE__ */ E("span", { className: `nice-btn-field nice-btn-field--bottom nice-field--${m}`, children: [
239
+ ie,
240
+ ue
241
+ ] });
242
+ };
243
+ function Ee(e, n, o = {}) {
244
+ const {
245
+ delimiter: r = ",",
246
+ lineEnding: u = `
247
+ `,
248
+ quoteChar: m = '"',
249
+ alwaysQuote: c = !1,
250
+ includeHeaders: f = !0,
251
+ includeRowNumbers: s = !1,
252
+ locale: d = "en-US",
253
+ dateTimeFormat: a = "yyyy-MM-dd HH:mm:ss"
254
+ } = o, v = n.filter((t) => t.visible !== !1), _ = [], g = (t) => {
255
+ if (c || t.includes(r) || t.includes(m) || t.includes(`
256
+ `) || t.includes("\r")) {
257
+ const w = t.replace(new RegExp(m, "g"), m + m);
258
+ return `${m}${w}${m}`;
259
+ }
260
+ return t;
261
+ }, l = (t, i, w) => {
262
+ if (t == null)
263
+ return "";
264
+ if (i.format)
265
+ return i.format(t, w);
266
+ switch (i.dataType) {
267
+ case "date":
268
+ return le(t, i.dateFormat ?? a);
269
+ case "number":
270
+ return ce(t, i.numberFormat, d);
271
+ case "currency":
272
+ return de(t, i.currencyCode ?? "USD", d);
273
+ case "boolean":
274
+ return t ? "Yes" : "No";
275
+ default:
276
+ return String(t);
277
+ }
278
+ };
279
+ if (f) {
280
+ const t = [];
281
+ s && t.push(g("#"));
282
+ for (const i of v)
283
+ t.push(g(i.header));
284
+ _.push(t.join(r));
285
+ }
286
+ return e.forEach((t, i) => {
287
+ const w = [];
288
+ s && w.push(String(i + 1));
289
+ for (const D of v) {
290
+ const N = t[D.field], $ = l(N, D, t);
291
+ w.push(g($));
292
+ }
293
+ _.push(w.join(r));
294
+ }), _.join(u);
295
+ }
296
+ function Me(e, n, o = {}) {
297
+ const {
298
+ fileName: r = "export",
299
+ includeTimestamp: u = !1,
300
+ includeBOM: m = !0,
301
+ encoding: c = "utf-8"
302
+ } = o, f = Ee(e, n, o), s = u ? `_${re()}` : "", d = `${r}${s}.csv`;
303
+ let a = f;
304
+ m && c === "utf-8" && (a = "\uFEFF" + f);
305
+ const v = new Blob([a], { type: `text/csv;charset=${c}` });
306
+ oe(v, d);
307
+ }
308
+ function Le() {
309
+ return {
310
+ sheets: /* @__PURE__ */ new Map(),
311
+ activeSheet: ""
312
+ };
313
+ }
314
+ function Re(e, n) {
315
+ const o = {
316
+ name: n,
317
+ cells: /* @__PURE__ */ new Map(),
318
+ columns: [],
319
+ merges: []
320
+ };
321
+ return e.sheets.set(n, o), e.activeSheet || (e.activeSheet = n), o;
322
+ }
323
+ function q(e, n, o, r) {
324
+ const u = ee(n, o);
325
+ e.cells.set(u, r);
326
+ }
327
+ function ee(e, n) {
328
+ let o = "", r = n;
329
+ for (; r >= 0; )
330
+ o = String.fromCharCode(65 + r % 26) + o, r = Math.floor(r / 26) - 1;
331
+ return `${o}${e + 1}`;
332
+ }
333
+ function Ae(e) {
334
+ const n = new TextEncoder(), o = Array.from(e.sheets.entries()), r = o.map(([s, d], a) => {
335
+ const v = [];
336
+ let _ = 0, g = 0;
337
+ d.cells.forEach((t, i) => {
338
+ const w = i.match(/([A-Z]+)(\d+)/);
339
+ if (w) {
340
+ const D = je(w[1]), N = parseInt(w[2], 10);
341
+ _ = Math.max(_, N), g = Math.max(g, D);
342
+ }
343
+ });
344
+ for (let t = 1; t <= _; t++) {
345
+ const i = [];
346
+ for (let w = 0; w <= g; w++) {
347
+ const D = ee(t - 1, w), N = d.cells.get(D);
348
+ if (N) {
349
+ const $ = N.type === "s" ? ' t="inlineStr"' : N.type === "b" ? ' t="b"' : "";
350
+ let b;
351
+ N.type === "s" ? b = `<is><t>${me(String(N.value))}</t></is>` : N.type === "b" ? b = `<v>${N.value ? 1 : 0}</v>` : b = `<v>${N.value}</v>`, i.push(`<c r="${D}"${$}>${b}</c>`);
352
+ }
353
+ }
354
+ i.length > 0 && v.push(`<row r="${t}">${i.join("")}</row>`);
355
+ }
356
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
357
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
358
+ <dimension ref="${_ > 0 ? `A1:${ee(_ - 1, g)}` : "A1"}"/>
359
+ <sheetData>${v.join("")}</sheetData>
360
+ </worksheet>`;
361
+ }), u = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
362
+ <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
363
+ <sheets>${o.map(([s], d) => `<sheet name="${me(s)}" sheetId="${d + 1}" r:id="rId${d + 1}"/>`).join("")}</sheets>
364
+ </workbook>`, m = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
365
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
366
+ ${o.map((s, d) => `<Relationship Id="rId${d + 1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${d + 1}.xml"/>`).join(`
367
+ `)}
368
+ </Relationships>`, c = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
369
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
370
+ <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
371
+ <Default Extension="xml" ContentType="application/xml"/>
372
+ <Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>
373
+ ${o.map((s, d) => `<Override PartName="/xl/worksheets/sheet${d + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join(`
374
+ `)}
375
+ </Types>`;
376
+ return Oe([
377
+ { path: "[Content_Types].xml", content: n.encode(c) },
378
+ { path: "_rels/.rels", content: n.encode(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
379
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
380
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
381
+ </Relationships>`) },
382
+ { path: "xl/workbook.xml", content: n.encode(u) },
383
+ { path: "xl/_rels/workbook.xml.rels", content: n.encode(m) },
384
+ ...r.map((s, d) => ({
385
+ path: `xl/worksheets/sheet${d + 1}.xml`,
386
+ content: n.encode(s)
387
+ }))
388
+ ]);
389
+ }
390
+ function je(e) {
391
+ let n = 0;
392
+ for (let o = 0; o < e.length; o++)
393
+ n = n * 26 + (e.charCodeAt(o) - 64);
394
+ return n - 1;
395
+ }
396
+ function me(e) {
397
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
398
+ }
399
+ function Oe(e) {
400
+ const n = [], o = [];
401
+ let r = 0;
402
+ for (const a of e) {
403
+ const v = new TextEncoder().encode(a.path), _ = new Uint8Array(30 + v.length), g = new DataView(_.buffer);
404
+ g.setUint32(0, 67324752, !0), g.setUint16(4, 20, !0), g.setUint16(6, 0, !0), g.setUint16(8, 0, !0), g.setUint16(10, 0, !0), g.setUint16(12, 0, !0), g.setUint32(14, pe(a.content), !0), g.setUint32(18, a.content.length, !0), g.setUint32(22, a.content.length, !0), g.setUint16(26, v.length, !0), g.setUint16(28, 0, !0), _.set(v, 30), n.push(_), n.push(a.content);
405
+ const l = new Uint8Array(46 + v.length), t = new DataView(l.buffer);
406
+ t.setUint32(0, 33639248, !0), t.setUint16(4, 20, !0), t.setUint16(6, 20, !0), t.setUint16(8, 0, !0), t.setUint16(10, 0, !0), t.setUint16(12, 0, !0), t.setUint16(14, 0, !0), t.setUint32(16, pe(a.content), !0), t.setUint32(20, a.content.length, !0), t.setUint32(24, a.content.length, !0), t.setUint16(28, v.length, !0), t.setUint16(30, 0, !0), t.setUint16(32, 0, !0), t.setUint16(34, 0, !0), t.setUint16(36, 0, !0), t.setUint32(38, 0, !0), t.setUint32(42, r, !0), l.set(v, 46), o.push(l), r += _.length + a.content.length;
407
+ }
408
+ const u = o.reduce((a, v) => a + v.length, 0), m = new Uint8Array(22), c = new DataView(m.buffer);
409
+ c.setUint32(0, 101010256, !0), c.setUint16(4, 0, !0), c.setUint16(6, 0, !0), c.setUint16(8, e.length, !0), c.setUint16(10, e.length, !0), c.setUint32(12, u, !0), c.setUint32(16, r, !0), c.setUint16(20, 0, !0);
410
+ const f = r + u + m.length, s = new Uint8Array(f);
411
+ let d = 0;
412
+ for (const a of n)
413
+ s.set(a, d), d += a.length;
414
+ for (const a of o)
415
+ s.set(a, d), d += a.length;
416
+ return s.set(m, d), s.buffer;
417
+ }
418
+ function pe(e) {
419
+ let n = 4294967295;
420
+ const o = He();
421
+ for (let r = 0; r < e.length; r++)
422
+ n = n >>> 8 ^ o[(n ^ e[r]) & 255];
423
+ return (n ^ 4294967295) >>> 0;
424
+ }
425
+ let K = null;
426
+ function He() {
427
+ if (K)
428
+ return K;
429
+ K = new Uint32Array(256);
430
+ for (let e = 0; e < 256; e++) {
431
+ let n = e;
432
+ for (let o = 0; o < 8; o++)
433
+ n = n & 1 ? 3988292384 ^ n >>> 1 : n >>> 1;
434
+ K[e] = n;
435
+ }
436
+ return K;
437
+ }
438
+ function ze(e, n, o = {}) {
439
+ const {
440
+ sheetName: r = "Sheet1",
441
+ title: u,
442
+ subtitle: m,
443
+ includeHeaders: c = !0,
444
+ includeRowNumbers: f = !1,
445
+ freezeHeader: s = !0,
446
+ autoFilter: d = !0,
447
+ styles: a = {},
448
+ locale: v = "en-US",
449
+ dateTimeFormat: _ = "yyyy-MM-dd HH:mm:ss"
450
+ } = o, g = n.filter(($) => $.visible !== !1), l = Le(), t = Re(l, r);
451
+ let i = 0;
452
+ const w = f ? 1 : 0;
453
+ u && (q(t, i, 0, {
454
+ value: u,
455
+ type: "s",
456
+ style: { font: { bold: !0, size: 16 } }
457
+ }), i++), m && (q(t, i, 0, {
458
+ value: m,
459
+ type: "s",
460
+ style: { font: { italic: !0, size: 12 } }
461
+ }), i++);
462
+ const D = i;
463
+ c && (f && q(t, i, 0, {
464
+ value: "#",
465
+ type: "s",
466
+ style: {
467
+ font: { bold: a.headerFontWeight === "bold", color: a.headerColor },
468
+ fill: { color: a.headerBackground },
469
+ alignment: { horizontal: "center" }
470
+ }
471
+ }), g.forEach(($, b) => {
472
+ q(t, i, b + w, {
473
+ value: $.header,
474
+ type: "s",
475
+ style: {
476
+ font: { bold: a.headerFontWeight === "bold", color: a.headerColor },
477
+ fill: { color: a.headerBackground },
478
+ alignment: { horizontal: $.align ?? "left" }
479
+ }
480
+ });
481
+ }), i++), e.forEach(($, b) => {
482
+ f && q(t, i, 0, {
483
+ value: b + 1,
484
+ type: "n"
485
+ }), g.forEach((M, U) => {
486
+ const y = $[M.field];
487
+ let k;
488
+ if (y == null)
489
+ k = { value: "", type: "s" };
490
+ else if (M.format)
491
+ k = { value: M.format(y, $), type: "s" };
492
+ else
493
+ switch (M.dataType) {
494
+ case "number":
495
+ case "currency":
496
+ k = {
497
+ value: Number(y),
498
+ type: "n",
499
+ numberFormat: M.numberFormat
500
+ };
501
+ break;
502
+ case "date": {
503
+ k = {
504
+ value: Ge(y),
505
+ type: "n",
506
+ numberFormat: M.dateFormat ?? "yyyy-mm-dd"
507
+ };
508
+ break;
509
+ }
510
+ case "boolean":
511
+ k = { value: y, type: "b" };
512
+ break;
513
+ default:
514
+ k = { value: String(y), type: "s" };
515
+ }
516
+ a.alternateRows && b % 2 === 1 && (k.style = {
517
+ ...k.style,
518
+ fill: { color: a.alternateBackground ?? "var(--nice-text-primary, #f5f5f5)" }
519
+ }), q(t, i, U + w, k);
520
+ }), i++;
521
+ });
522
+ const N = g.map(($) => $.width ?? 100);
523
+ if (f && N.unshift(40), t.columns = N.map(($) => ({ width: $ / 7 })), s && c && (t.freezePane = { row: D + 1, col: 0 }), d && c && e.length > 0) {
524
+ const $ = ee(D, 0), b = ee(i - 1, g.length - 1 + w);
525
+ t.autoFilter = { start: $, end: b };
526
+ }
527
+ return Ae(l);
528
+ }
529
+ function ye(e, n, o = {}) {
530
+ const { fileName: r = "export", includeTimestamp: u = !1 } = o, m = ze(e, n, o), c = u ? `_${re()}` : "", f = `${r}${c}.xlsx`, s = new Blob([m], {
531
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
532
+ });
533
+ oe(s, f);
534
+ }
535
+ function Ve(e, n, o = {}) {
536
+ const {
537
+ title: r,
538
+ subtitle: u,
539
+ orientation: m = "portrait",
540
+ pageSize: c = "A4",
541
+ margins: f = { top: 20, right: 20, bottom: 20, left: 20 },
542
+ header: s,
543
+ footer: d,
544
+ logo: a,
545
+ logoWidth: v = 100,
546
+ logoHeight: _,
547
+ watermark: g,
548
+ includeHeaders: l = !0,
549
+ includeRowNumbers: t = !1,
550
+ styles: i = {},
551
+ locale: w = "en-US",
552
+ dateTimeFormat: D = "yyyy-MM-dd HH:mm:ss"
553
+ } = o, N = n.filter((U) => U.visible !== !1), $ = (U, y, k) => {
554
+ if (U == null)
555
+ return "";
556
+ if (y.format)
557
+ return y.format(U, k);
558
+ switch (y.dataType) {
559
+ case "date":
560
+ return le(U, y.dateFormat ?? D);
561
+ case "number":
562
+ return ce(U, y.numberFormat, w);
563
+ case "currency":
564
+ return de(U, y.currencyCode ?? "USD", w);
565
+ case "boolean":
566
+ return U ? "✓" : "✗";
567
+ default:
568
+ return String(U);
569
+ }
570
+ };
571
+ let b = `
572
+ <!DOCTYPE html>
573
+ <html>
574
+ <head>
575
+ <meta charset="utf-8">
576
+ <title>${V(r ?? "Export")}</title>
577
+ <style>
578
+ @page {
579
+ size: ${c} ${m};
580
+ margin: ${f.top}mm ${f.right}mm ${f.bottom}mm ${f.left}mm;
581
+ }
582
+
583
+ body {
584
+ font-family: ${i.fontFamily ?? "Arial, sans-serif"};
585
+ font-size: ${i.fontSize ?? 10}pt;
586
+ margin: 0;
587
+ padding: 0;
588
+ }
589
+
590
+ .header {
591
+ text-align: center;
592
+ margin-bottom: var(--nice-space-5, 20px);
593
+ }
594
+
595
+ .title {
596
+ font-size: 18pt;
597
+ font-weight: bold;
598
+ margin: 0 0 var(--nice-space-1-25, 5px) 0;
599
+ }
600
+
601
+ .subtitle {
602
+ font-size: 12pt;
603
+ color: var(--nice-text-secondary, #666);
604
+ margin: 0;
605
+ }
606
+
607
+ .logo {
608
+ max-width: ${v}px;
609
+ ${_ ? `max-height: ${_}px;` : ""}
610
+ margin-bottom: var(--nice-space-2-5, 10px);
611
+ }
612
+
613
+ table {
614
+ width: 100%;
615
+ border-collapse: collapse;
616
+ page-break-inside: auto;
617
+ }
618
+
619
+ tr {
620
+ page-break-inside: avoid;
621
+ page-break-after: auto;
622
+ }
623
+
624
+ th, td {
625
+ border: 1px solid ${i.borderColor ?? "var(--nice-border, #ddd)"};
626
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2, 8px);
627
+ text-align: left;
628
+ }
629
+
630
+ th {
631
+ background-color: ${i.headerBackground ?? "var(--nice-bg-secondary, #f5f5f5)"};
632
+ color: ${i.headerColor ?? "var(--nice-text, #333)"};
633
+ font-weight: ${i.headerFontWeight ?? "bold"};
634
+ }
635
+
636
+ tr:nth-child(even) {
637
+ background-color: ${i.alternateRows !== !1 ? i.alternateBackground ?? "var(--nice-bg-secondary, #fafafa)" : "transparent"};
638
+ }
639
+
640
+ .text-left { text-align: left; }
641
+ .text-center { text-align: center; }
642
+ .text-right { text-align: right; }
643
+
644
+ .watermark {
645
+ position: fixed;
646
+ top: 50%;
647
+ left: 50%;
648
+ transform: translate(-50%, -50%) rotate(-45deg);
649
+ font-size: 72pt;
650
+ color: var(--nice-overlay-10, rgba(0, 0, 0, 0.1));
651
+ pointer-events: none;
652
+ z-index: -1;
653
+ }
654
+
655
+ .page-footer {
656
+ position: fixed;
657
+ bottom: 0;
658
+ width: 100%;
659
+ text-align: center;
660
+ font-size: 9pt;
661
+ color: var(--nice-text-secondary, #666);
662
+ }
663
+
664
+ @media print {
665
+ .no-print { display: none; }
666
+ }
667
+ </style>
668
+ </head>
669
+ <body>
670
+ `;
671
+ if (g && (b += `<div class="watermark">${V(g)}</div>`), b += '<div class="header">', a && (b += `<img src="${a}" class="logo" alt="Logo">`), r && (b += `<h1 class="title">${V(r)}</h1>`), u && (b += `<p class="subtitle">${V(u)}</p>`), b += "</div>", b += "<table>", l) {
672
+ b += "<thead><tr>", t && (b += '<th class="text-center">#</th>');
673
+ for (const U of N) {
674
+ const y = U.align ?? "left";
675
+ b += `<th class="text-${y}" style="width: ${U.width ?? "auto"}px">${V(U.header)}</th>`;
676
+ }
677
+ b += "</tr></thead>";
678
+ }
679
+ b += "<tbody>", e.forEach((U, y) => {
680
+ b += "<tr>", t && (b += `<td class="text-center">${y + 1}</td>`);
681
+ for (const k of N) {
682
+ const C = $(U[k.field], k, U), j = k.align ?? "left";
683
+ b += `<td class="text-${j}">${V(C)}</td>`;
684
+ }
685
+ b += "</tr>";
686
+ }), b += "</tbody>", b += "</table>", b += "</body></html>";
687
+ const M = window.open("", "_blank");
688
+ M && (M.document.write(b), M.document.close(), M.onload = () => {
689
+ M.print();
690
+ });
691
+ }
692
+ function Be(e, n, o = {}) {
693
+ Ve(e, n, o);
694
+ }
695
+ function Pe(e, n = {}) {
696
+ const { pretty: o = !0, indent: r = 2, fields: u, transform: m } = n;
697
+ let c = e;
698
+ return m && (c = e.map((f, s) => m(f, s))), u?.length && (c = c.map((f) => {
699
+ const s = {};
700
+ for (const d of u)
701
+ d in f && (s[d] = f[d]);
702
+ return s;
703
+ })), JSON.stringify(c, null, o ? r : void 0);
704
+ }
705
+ function We(e, n = {}) {
706
+ const { fileName: o = "export", includeTimestamp: r = !1 } = n, u = Pe(e, n), m = r ? `_${re()}` : "", c = `${o}${m}.json`, f = new Blob([u], { type: "application/json;charset=utf-8" });
707
+ oe(f, c);
708
+ }
709
+ function Xe(e, n, o = {}) {
710
+ const {
711
+ title: r,
712
+ includeHeaders: u = !0,
713
+ includeRowNumbers: m = !1,
714
+ inlineStyles: c = !0,
715
+ tableClass: f = "nice-export-table",
716
+ standalone: s = !0,
717
+ styles: d = {},
718
+ locale: a = "en-US",
719
+ dateTimeFormat: v = "yyyy-MM-dd HH:mm:ss"
720
+ } = o, _ = n.filter((t) => t.visible !== !1), g = (t, i, w) => {
721
+ if (t == null)
722
+ return "";
723
+ if (i.format)
724
+ return i.format(t, w);
725
+ switch (i.dataType) {
726
+ case "date":
727
+ return le(t, i.dateFormat ?? v);
728
+ case "number":
729
+ return ce(t, i.numberFormat, a);
730
+ case "currency":
731
+ return de(t, i.currencyCode ?? "USD", a);
732
+ case "boolean":
733
+ return t ? "Yes" : "No";
734
+ default:
735
+ return String(t);
736
+ }
737
+ };
738
+ let l = "";
739
+ if (s && (l += `<!DOCTYPE html>
740
+ <html>
741
+ <head>
742
+ <meta charset="utf-8">
743
+ <title>${V(r ?? "Export")}</title>
744
+ <style>
745
+ .${f} {
746
+ border-collapse: collapse;
747
+ width: 100%;
748
+ font-family: ${d.fontFamily ?? "Arial, sans-serif"};
749
+ font-size: ${d.fontSize ?? 12}px;
750
+ }
751
+ .${f} th, .${f} td {
752
+ border: 1px solid ${d.borderColor ?? "var(--nice-border, #ddd)"};
753
+ padding: var(--nice-space-2, 8px);
754
+ text-align: left;
755
+ }
756
+ .${f} th {
757
+ background-color: ${d.headerBackground ?? "var(--nice-bg-secondary, #f5f5f5)"};
758
+ color: ${d.headerColor ?? "var(--nice-text, #333)"};
759
+ font-weight: ${d.headerFontWeight ?? "bold"};
760
+ }
761
+ .${f} tr:nth-child(even) {
762
+ background-color: ${d.alternateRows !== !1 ? d.alternateBackground ?? "var(--nice-bg-secondary, #fafafa)" : "transparent"};
763
+ }
764
+ </style>
765
+ </head>
766
+ <body>
767
+ `, r && (l += `<h1>${V(r)}</h1>`)), l += `<table class="${f}"${!s && c ? ' style="border-collapse:collapse;width:100%"' : ""}>`, u) {
768
+ l += "<thead><tr>", m && (l += "<th>#</th>");
769
+ for (const t of _)
770
+ l += `<th>${V(t.header)}</th>`;
771
+ l += "</tr></thead>";
772
+ }
773
+ return l += "<tbody>", e.forEach((t, i) => {
774
+ l += "<tr>", m && (l += `<td>${i + 1}</td>`);
775
+ for (const w of _) {
776
+ const D = g(t[w.field], w, t);
777
+ l += `<td>${V(D)}</td>`;
778
+ }
779
+ l += "</tr>";
780
+ }), l += "</tbody></table>", s && (l += "</body></html>"), l;
781
+ }
782
+ function Ie(e, n, o = {}) {
783
+ const { fileName: r = "export", includeTimestamp: u = !1 } = o, m = Xe(e, n, { ...o, standalone: !0 }), c = u ? `_${re()}` : "", f = `${r}${c}.html`, s = new Blob([m], { type: "text/html;charset=utf-8" });
784
+ oe(s, f);
785
+ }
786
+ function oe(e, n) {
787
+ const o = URL.createObjectURL(e), r = document.createElement("a");
788
+ r.href = o, r.download = n, document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(o);
789
+ }
790
+ function re() {
791
+ return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/[T:]/g, "-");
792
+ }
793
+ function le(e, n, o) {
794
+ const r = e instanceof Date ? e : new Date(e);
795
+ if (isNaN(r.getTime()))
796
+ return String(e);
797
+ const u = (m) => String(m).padStart(2, "0");
798
+ return n.replace("yyyy", String(r.getFullYear())).replace("MM", u(r.getMonth() + 1)).replace("dd", u(r.getDate())).replace("HH", u(r.getHours())).replace("mm", u(r.getMinutes())).replace("ss", u(r.getSeconds()));
799
+ }
800
+ function ce(e, n, o) {
801
+ if (n) {
802
+ const r = n.match(/0+$/)?.[0]?.length ?? 0;
803
+ return e.toLocaleString(o, {
804
+ minimumFractionDigits: r,
805
+ maximumFractionDigits: r
806
+ });
807
+ }
808
+ return e.toLocaleString(o);
809
+ }
810
+ function de(e, n, o) {
811
+ return e.toLocaleString(o, {
812
+ style: "currency",
813
+ currency: n
814
+ });
815
+ }
816
+ function Ge(e) {
817
+ const n = e instanceof Date ? e : new Date(e), o = new Date(1899, 11, 30), r = 1440 * 60 * 1e3;
818
+ return (n.getTime() - o.getTime()) / r;
819
+ }
820
+ function V(e) {
821
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
822
+ }
823
+ function lt(e) {
824
+ const { data: n, columns: o, format: r, options: u = {} } = e;
825
+ switch (r) {
826
+ case "csv":
827
+ Me(n, o, u);
828
+ break;
829
+ case "xlsx":
830
+ ye(n, o, u);
831
+ break;
832
+ case "pdf":
833
+ Be(n, o, u);
834
+ break;
835
+ case "json":
836
+ We(n, u);
837
+ break;
838
+ case "html":
839
+ Ie(n, o, u);
840
+ break;
841
+ default:
842
+ throw new Error(`Unsupported export format: ${r}`);
843
+ }
844
+ }
845
+ function ct(e, n = {}) {
846
+ const { maxSample: o = 100, exclude: r = [] } = n;
847
+ if (e.length === 0)
848
+ return [];
849
+ const u = e.slice(0, o), m = e[0], c = [];
850
+ for (const f of Object.keys(m)) {
851
+ if (r.includes(f))
852
+ continue;
853
+ let s = "string";
854
+ for (const d of u) {
855
+ const a = d[f];
856
+ if (a != null) {
857
+ if (typeof a == "number") {
858
+ s = "number";
859
+ break;
860
+ }
861
+ if (typeof a == "boolean") {
862
+ s = "boolean";
863
+ break;
864
+ }
865
+ if (a instanceof Date) {
866
+ s = "date";
867
+ break;
868
+ }
869
+ if (typeof a == "string" && /^\d{4}-\d{2}-\d{2}/.test(a) && !isNaN(Date.parse(a))) {
870
+ s = "date";
871
+ break;
872
+ }
873
+ }
874
+ }
875
+ c.push({
876
+ field: f,
877
+ header: Ye(f),
878
+ dataType: s
879
+ });
880
+ }
881
+ return c;
882
+ }
883
+ function Ye(e) {
884
+ return e.replace(/([A-Z])/g, " $1").replace(/_/g, " ").replace(/^\s+/, "").split(" ").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
885
+ }
886
+ const qe = [], Je = [
887
+ { key: void 0, label: "Available Fields" },
888
+ { key: "row", label: "Rows" },
889
+ { key: "column", label: "Columns" },
890
+ { key: "data", label: "Values" },
891
+ { key: "filter", label: "Filters" }
892
+ ], Qe = [
893
+ { value: "", label: "Available" },
894
+ { value: "row", label: "Rows" },
895
+ { value: "column", label: "Columns" },
896
+ { value: "data", label: "Values" },
897
+ { value: "filter", label: "Filters" }
898
+ ], Ze = ({
899
+ fields: e = qe,
900
+ onChange: n,
901
+ showAreaSelect: o = !1,
902
+ className: r,
903
+ style: u,
904
+ "data-testid": m
905
+ }) => {
906
+ const { t: c } = se(), [f, s] = G(null), [d, a] = G("none"), v = (l, t) => {
907
+ n(e.map((i) => i.field === l ? { ...i, area: t } : i));
908
+ }, _ = (l) => (t) => {
909
+ t.preventDefault();
910
+ const i = t.dataTransfer.getData("text/plain") || f;
911
+ i && v(i, l), s(null), a("none");
912
+ }, g = (l) => /* @__PURE__ */ E(
913
+ "li",
914
+ {
915
+ className: "nice-field-chooser__item",
916
+ draggable: !0,
917
+ onDragStart: (t) => {
918
+ t.dataTransfer.setData("text/plain", l.field), t.dataTransfer.effectAllowed = "move", s(l.field);
919
+ },
920
+ onDragEnd: () => {
921
+ s(null), a("none");
922
+ },
923
+ children: [
924
+ /* @__PURE__ */ p("span", { className: "nice-field-chooser__grip", "aria-hidden": "true", children: /* @__PURE__ */ p(J, { name: "menu", size: 14 }) }),
925
+ /* @__PURE__ */ E("span", { className: "nice-field-chooser__label", children: [
926
+ l.caption,
927
+ l.dataType && /* @__PURE__ */ E("small", { className: "nice-field-chooser__type", children: [
928
+ " (",
929
+ l.dataType,
930
+ ")"
931
+ ] })
932
+ ] }),
933
+ o && /* @__PURE__ */ p(
934
+ Ue,
935
+ {
936
+ size: "sm",
937
+ value: l.area ?? "",
938
+ options: Qe,
939
+ onChange: (t) => v(l.field, t || void 0),
940
+ "aria-label": c("pivotGridFieldChooser.assignToArea", "Assign {caption} to area").replace(
941
+ "{caption}",
942
+ String(l.caption)
943
+ )
944
+ }
945
+ ),
946
+ l.area && /* @__PURE__ */ p(
947
+ "button",
948
+ {
949
+ type: "button",
950
+ className: "nice-field-chooser__remove",
951
+ onClick: () => v(l.field, void 0),
952
+ "aria-label": c("pivotGridFieldChooser.remove", "Remove {caption}").replace(
953
+ "{caption}",
954
+ String(l.caption)
955
+ ),
956
+ children: /* @__PURE__ */ p(J, { name: "close", size: 14 })
957
+ }
958
+ )
959
+ ]
960
+ },
961
+ l.field
962
+ );
963
+ return /* @__PURE__ */ p("div", { className: `nice-field-chooser ${r || ""}`, style: u, "data-testid": m, children: /* @__PURE__ */ p("div", { className: "nice-field-chooser__panel", children: Je.map((l) => {
964
+ const t = e.filter((i) => l.key ? i.area === l.key : !i.area);
965
+ return /* @__PURE__ */ E(
966
+ "div",
967
+ {
968
+ className: `nice-field-chooser__section${d === l.key && f ? " nice-field-chooser__section--over" : ""}`,
969
+ onDragOver: (i) => {
970
+ i.preventDefault(), a(l.key);
971
+ },
972
+ onDragLeave: () => a("none"),
973
+ onDrop: _(l.key),
974
+ children: [
975
+ /* @__PURE__ */ p("h4", { children: l.label }),
976
+ /* @__PURE__ */ E("ul", { children: [
977
+ t.map(g),
978
+ t.length === 0 && /* @__PURE__ */ p("li", { className: "nice-field-chooser__empty", "aria-hidden": "true", children: c("pivotGridFieldChooser.dropFieldsHere", "Drop fields here") })
979
+ ] })
980
+ ]
981
+ },
982
+ l.label
983
+ );
984
+ }) }) });
985
+ }, Ke = [], he = "__row";
986
+ function et(e, n) {
987
+ if (e.length === 0)
988
+ return 0;
989
+ switch (n) {
990
+ case "sum":
991
+ return e.reduce((o, r) => o + r, 0);
992
+ case "count":
993
+ return e.length;
994
+ case "avg":
995
+ return e.reduce((o, r) => o + r, 0) / e.length;
996
+ case "min":
997
+ return Math.min(...e);
998
+ case "max":
999
+ return Math.max(...e);
1000
+ default:
1001
+ return e.reduce((o, r) => o + r, 0);
1002
+ }
1003
+ }
1004
+ function be(e, n) {
1005
+ return [...new Set(e.map((o) => String(o[n] ?? "")))].sort();
1006
+ }
1007
+ const tt = ({
1008
+ data: e = Ke,
1009
+ fields: n,
1010
+ defaultFields: o,
1011
+ onFieldsChange: r,
1012
+ showFieldChooser: u,
1013
+ loading: m,
1014
+ emptyText: c,
1015
+ headerText: f,
1016
+ exportCsv: s,
1017
+ exportFilename: d = "pivot-export",
1018
+ onDrillThrough: a,
1019
+ className: v,
1020
+ style: _,
1021
+ accessMode: g,
1022
+ id: l,
1023
+ "data-testid": t
1024
+ }) => {
1025
+ const w = ge(g, l) === "hidden", { t: D } = se(), N = n !== void 0 && r !== void 0, [$, b] = ke({
1026
+ value: N ? n : void 0,
1027
+ defaultValue: N ? o : o ?? n,
1028
+ fallbackValue: [],
1029
+ onChange: r,
1030
+ componentName: "NicePivotGrid"
1031
+ });
1032
+ Te(
1033
+ "NicePivotGrid",
1034
+ "fields",
1035
+ "onFieldsChange",
1036
+ n,
1037
+ N
1038
+ );
1039
+ const [M, U] = G(!1), y = Z(() => $.filter((h) => h.area === "row"), [$]), k = Z(() => $.filter((h) => h.area === "column"), [$]), C = Z(() => $.filter((h) => h.area === "data"), [$]), j = Z(() => y.length === 0 ? ["Total"] : be(e, y[0].field), [e, y]), O = Z(() => k.length === 0 ? ["Total"] : be(e, k[0].field), [e, k]), A = P(
1040
+ (h, S, T) => {
1041
+ let F = e;
1042
+ y.length > 0 && (F = F.filter((L) => String(L[y[0].field]) === h)), k.length > 0 && (F = F.filter((L) => String(L[k[0].field]) === S));
1043
+ const z = F.map((L) => Number(L[T.field]) || 0), R = et(z, T.summaryType || "sum");
1044
+ return T.format ? T.format(R) : R;
1045
+ },
1046
+ [e, y, k]
1047
+ ), W = P(
1048
+ (h) => {
1049
+ b(h);
1050
+ },
1051
+ [b]
1052
+ ), Y = P(
1053
+ (h, S) => {
1054
+ let T = e;
1055
+ return y.length > 0 && (T = T.filter((F) => String(F[y[0].field]) === h)), k.length > 0 && (T = T.filter((F) => String(F[k[0].field]) === S)), T;
1056
+ },
1057
+ [e, y, k]
1058
+ ), X = P(
1059
+ (h, S) => {
1060
+ a && a(h, S, Y(h, S));
1061
+ },
1062
+ [a, Y]
1063
+ ), I = P(() => {
1064
+ const h = [
1065
+ { field: he, header: y.map((T) => T.caption).join(" / ") || "" }
1066
+ ];
1067
+ O.forEach((T, F) => {
1068
+ C.length > 0 ? C.forEach(
1069
+ (z, R) => h.push({ field: `c${F}d${R}`, header: `${T} - ${z.caption}` })
1070
+ ) : h.push({ field: `c${F}`, header: T });
1071
+ });
1072
+ const S = j.map((T) => {
1073
+ const F = { [he]: T };
1074
+ return O.forEach((z, R) => {
1075
+ C.length > 0 ? C.forEach((L, H) => {
1076
+ F[`c${R}d${H}`] = A(T, z, L);
1077
+ }) : F[`c${R}`] = "—";
1078
+ }), F;
1079
+ });
1080
+ return { columns: h, rows: S };
1081
+ }, [O, j, C, y, A]), Q = P(() => {
1082
+ const { columns: h, rows: S } = I(), T = [
1083
+ h.map((L) => L.header),
1084
+ ...S.map((L) => h.map((H) => String(L[H.field] ?? "")))
1085
+ ].map((L) => L.map((H) => `"${String(H).replace(/"/g, '""')}"`).join(",")).join(`
1086
+ `), F = new Blob(["\uFEFF" + T], { type: "text/csv;charset=utf-8;" }), z = URL.createObjectURL(F), R = document.createElement("a");
1087
+ R.href = z, R.download = `${d}.csv`, R.click(), URL.revokeObjectURL(z);
1088
+ }, [I, d]), te = P(() => {
1089
+ const { columns: h, rows: S } = I();
1090
+ ye(S, h, { fileName: d, sheetName: "Pivot" });
1091
+ }, [I, d]);
1092
+ return w ? null : /* @__PURE__ */ E("div", { className: `nice-pivotgrid ${v || ""}`, style: _, "data-testid": t, children: [
1093
+ (u || s || f) && /* @__PURE__ */ E("div", { className: "nice-pivotgrid__toolbar", children: [
1094
+ f && /* @__PURE__ */ p("span", { className: "nice-pivotgrid__header-text", children: f }),
1095
+ /* @__PURE__ */ E("div", { className: "nice-pivotgrid__toolbar-actions", children: [
1096
+ u && // Icon-only on purpose: a "Field Chooser" caption needed translating
1097
+ // and stretched the bar. The label survives as tooltip + a11y name.
1098
+ /* @__PURE__ */ p(
1099
+ "button",
1100
+ {
1101
+ type: "button",
1102
+ className: "nice-btn nice-btn--outline nice-btn--sm nice-btn--icon-only",
1103
+ onClick: () => U(!M),
1104
+ title: D("controls.fieldChooser", "Field Chooser"),
1105
+ "aria-label": D("controls.fieldChooser", "Field Chooser"),
1106
+ "aria-pressed": M,
1107
+ children: /* @__PURE__ */ p(J, { name: "filter", size: 16 })
1108
+ }
1109
+ ),
1110
+ s && /* @__PURE__ */ p(
1111
+ Fe,
1112
+ {
1113
+ size: "sm",
1114
+ variant: "outline",
1115
+ icon: /* @__PURE__ */ p(J, { name: "download", size: 16 }),
1116
+ title: D("controls.export", "Export"),
1117
+ items: [
1118
+ { key: "csv", text: "CSV", onClick: Q },
1119
+ { key: "xlsx", text: "XLSX", onClick: te }
1120
+ ]
1121
+ }
1122
+ )
1123
+ ] })
1124
+ ] }),
1125
+ M && /* @__PURE__ */ p(Ze, { fields: $, onChange: W }),
1126
+ m ? /* @__PURE__ */ p("div", { className: "nice-pivotgrid__loading", children: /* @__PURE__ */ p("div", { className: "nice-spinner nice-spinner--md" }) }) : /* @__PURE__ */ p("div", { className: "nice-pivotgrid__table-wrap", children: /* @__PURE__ */ E("table", { className: "nice-pivotgrid__table", children: [
1127
+ /* @__PURE__ */ E("thead", { children: [
1128
+ /* @__PURE__ */ E("tr", { children: [
1129
+ /* @__PURE__ */ p("th", { children: y.map((h) => h.caption).join(" / ") || "" }),
1130
+ O.map((h) => /* @__PURE__ */ p("th", { colSpan: C.length || 1, children: h }, h))
1131
+ ] }),
1132
+ C.length > 1 && /* @__PURE__ */ E("tr", { children: [
1133
+ /* @__PURE__ */ p("th", {}),
1134
+ O.map(
1135
+ (h) => C.map((S) => /* @__PURE__ */ p("th", { children: S.caption }, `${h}-${S.field}`))
1136
+ )
1137
+ ] })
1138
+ ] }),
1139
+ /* @__PURE__ */ p("tbody", { children: j.length === 0 ? /* @__PURE__ */ p("tr", { children: /* @__PURE__ */ p(
1140
+ "td",
1141
+ {
1142
+ colSpan: 1 + O.length * Math.max(C.length, 1),
1143
+ className: "nice-pivotgrid__empty",
1144
+ children: c || D("controls.noData", "No data available")
1145
+ }
1146
+ ) }) : j.map((h) => /* @__PURE__ */ E("tr", { children: [
1147
+ /* @__PURE__ */ p("td", { className: "nice-pivotgrid__row-header", children: h }),
1148
+ O.map(
1149
+ (S) => C.length > 0 ? C.map((T) => /* @__PURE__ */ p(
1150
+ "td",
1151
+ {
1152
+ className: `nice-pivotgrid__cell ${a ? "nice-pivotgrid__cell--clickable" : ""}`,
1153
+ onClick: a ? () => X(h, S) : void 0,
1154
+ children: A(h, S, T)
1155
+ },
1156
+ `${S}-${T.field}`
1157
+ )) : /* @__PURE__ */ p("td", { className: "nice-pivotgrid__cell", children: "—" }, S)
1158
+ )
1159
+ ] }, h)) })
1160
+ ] }) })
1161
+ ] });
1162
+ }, dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1163
+ __proto__: null,
1164
+ NicePivotGrid: tt
1165
+ }, Symbol.toStringTag, { value: "Module" }));
1166
+ export {
1167
+ tt as N,
1168
+ Ze as a,
1169
+ ye as b,
1170
+ Me as c,
1171
+ oe as d,
1172
+ Ve as e,
1173
+ Fe as f,
1174
+ ct as g,
1175
+ Ie as h,
1176
+ We as i,
1177
+ Be as j,
1178
+ Ee as k,
1179
+ Xe as l,
1180
+ Pe as m,
1181
+ ze as n,
1182
+ lt as o,
1183
+ dt as p
1184
+ };