@nice2dev/ui 1.1.5 → 1.1.7

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 (164) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/README.md +50 -29
  3. package/css/legacy-bg-text-aliases.css +65 -61
  4. package/dist/NiceCodeEditor-Bc81wiaN.js +1134 -0
  5. package/dist/NiceCodeEditor-D6f8KdHN.js +1134 -0
  6. package/dist/NiceCodeEditor-DE3saxyt.cjs +260 -0
  7. package/dist/NiceCodeEditor-DZM16My5.cjs +260 -0
  8. package/dist/NiceCodeEditor-HqmcJjmZ.js +1179 -0
  9. package/dist/NiceColorPicker-6EqXaDj0.cjs +1 -0
  10. package/dist/NiceColorPicker-BiEWqWnd.js +596 -0
  11. package/dist/NiceColorPicker-Cuc6YXqz.cjs +1 -0
  12. package/dist/NiceColorPicker-DMATcNWG.js +596 -0
  13. package/dist/NiceColorPicker-R3O1nemp.js +596 -0
  14. package/dist/NiceConfirmDialog-B0e10fRL.cjs +1 -0
  15. package/dist/NiceConfirmDialog-BBDgEMHv.js +81 -0
  16. package/dist/NiceConfirmDialog-C7kdr8jJ.js +81 -0
  17. package/dist/NiceConfirmDialog-DMHqPfFM.js +81 -0
  18. package/dist/NiceConfirmDialog-ZJpQLQQS.cjs +1 -0
  19. package/dist/NiceDataGrid-BzUw4dSu.cjs +10 -0
  20. package/dist/NiceDataGrid-CPKcVOVz.js +1743 -0
  21. package/dist/NiceDataGrid-DJr33WMy.cjs +10 -0
  22. package/dist/NiceDataGrid-D_4gZ1Hu.js +1736 -0
  23. package/dist/NiceDataGrid-DlUAaXhD.js +1736 -0
  24. package/dist/NiceDocumentViewer-8ghRVtfO.js +672 -0
  25. package/dist/NiceDocumentViewer-ChWtA_Ry.cjs +180 -0
  26. package/dist/NiceDocumentViewer-DwLUV7Tc.js +672 -0
  27. package/dist/NiceDocumentViewer-goMzF1w3.cjs +180 -0
  28. package/dist/NiceDocumentViewer-gt1mxzP8.js +672 -0
  29. package/dist/NiceForm-CHEAHxDw.js +4805 -0
  30. package/dist/NiceForm-CJUp1CL0.cjs +1 -0
  31. package/dist/NiceForm-Cp_RH3Yj.js +4805 -0
  32. package/dist/NiceForm-a6tGr6ss.js +4819 -0
  33. package/dist/NiceForm-jU89oe2S.cjs +1 -0
  34. package/dist/NiceGantt-BnQwyTfG.cjs +1 -0
  35. package/dist/NiceGantt-D8coFAvK.js +328 -0
  36. package/dist/NiceGantt-DOZfT6r5.js +328 -0
  37. package/dist/NiceGantt-DQzH1V-R.js +328 -0
  38. package/dist/NiceGantt-jQ8ZpXko.cjs +1 -0
  39. package/dist/NiceHtmlEditor-B1nlXJNW.cjs +10 -0
  40. package/dist/NiceHtmlEditor-Bv3VqJPG.js +862 -0
  41. package/dist/NiceHtmlEditor-CKsGj-Ei.cjs +10 -0
  42. package/dist/NiceHtmlEditor-CloMgyzg.js +841 -0
  43. package/dist/NiceHtmlEditor-DUAHmkWI.js +841 -0
  44. package/dist/NiceLoginForm-Ce_QLnLf.js +736 -0
  45. package/dist/NiceLoginForm-DLpNTQlR.cjs +1 -0
  46. package/dist/NiceLoginForm-Dg0286Cc.js +736 -0
  47. package/dist/NiceLoginForm-X05Vadeg.js +708 -0
  48. package/dist/NiceLoginForm-f_dBCnUi.cjs +1 -0
  49. package/dist/NiceMention-BByI4nFG.js +11120 -0
  50. package/dist/NiceMention-BjeLN4Jx.cjs +430 -0
  51. package/dist/NiceMention-C2TPiMph.cjs +430 -0
  52. package/dist/NiceMention-C67vT6m0.js +11145 -0
  53. package/dist/NiceMention-D1cdy63w.cjs +430 -0
  54. package/dist/NiceMention-OaCi-GNO.js +11094 -0
  55. package/dist/NiceMention-QIuggb9Y.js +11122 -0
  56. package/dist/NiceMention.css +1 -1
  57. package/dist/NiceModal-CHaan9al.js +95 -0
  58. package/dist/NiceModal-Czq6OEAT.js +95 -0
  59. package/dist/NiceModal-D-HFwawr.js +95 -0
  60. package/dist/NiceModal-DOy2XTzc.cjs +1 -0
  61. package/dist/NiceModal-DkawKzEE.cjs +1 -0
  62. package/dist/NiceModuleLifecyclePanel-1CsP8Zst.js +6997 -0
  63. package/dist/NiceModuleLifecyclePanel-Bkx4Yg-3.cjs +1 -0
  64. package/dist/NiceModuleLifecyclePanel-C5oYtczk.js +6999 -0
  65. package/dist/NiceModuleLifecyclePanel-DCcy2yYi.cjs +1 -0
  66. package/dist/NiceModuleLifecyclePanel-DqdgW-0s.js +7004 -0
  67. package/dist/NiceModuleLifecyclePanel.css +1 -1
  68. package/dist/NicePagination-7od5KUa3.cjs +1 -0
  69. package/dist/NicePagination-DMrkR8hH.cjs +1 -0
  70. package/dist/NicePagination-DQmZpsSQ.js +179 -0
  71. package/dist/NicePagination-DipQRjPq.js +172 -0
  72. package/dist/NicePagination-KhlVXYaT.js +172 -0
  73. package/dist/NicePivotGrid-B-KthuqL.cjs +152 -0
  74. package/dist/NicePivotGrid-CLCTHkKO.cjs +152 -0
  75. package/dist/NicePivotGrid-DV54FCsH.js +1174 -0
  76. package/dist/NicePivotGrid-DoWLUPUs.js +1167 -0
  77. package/dist/NicePivotGrid-etwpfccz.js +1167 -0
  78. package/dist/NiceSavedQueryPanel-BABkTNc5.js +5129 -0
  79. package/dist/NiceSavedQueryPanel-Cfeig83P.cjs +586 -0
  80. package/dist/NiceSavedQueryPanel-DTWRLseb.cjs +586 -0
  81. package/dist/NiceSavedQueryPanel-Dy154sxE.js +5129 -0
  82. package/dist/NiceSavedQueryPanel-v7AffOOe.js +5129 -0
  83. package/dist/NiceSavedQueryPanel.css +1 -1
  84. package/dist/NiceScheduler-BEgB7ZgF.cjs +5 -0
  85. package/dist/NiceScheduler-C9JprsEI.cjs +5 -0
  86. package/dist/NiceScheduler-DSP-PPh0.js +1645 -0
  87. package/dist/NiceScheduler-DuPnaA3t.js +1652 -0
  88. package/dist/NiceScheduler-Oa89YZx9.js +1645 -0
  89. package/dist/NiceSelect-A336yeLZ.js +433 -0
  90. package/dist/NiceSelect-B5hTbqi2.js +433 -0
  91. package/dist/NiceSelect-BYSgDYzq.cjs +1 -0
  92. package/dist/NiceSelect-Dudf2T5T.js +433 -0
  93. package/dist/NiceSelect-DwBAIrX7.cjs +1 -0
  94. package/dist/NiceWindow-B6zjBTl9.cjs +1 -0
  95. package/dist/NiceWindow-BKQEx7Vf.js +1623 -0
  96. package/dist/NiceWindow-BnTH7Gy0.js +1623 -0
  97. package/dist/NiceWindow-CZN9NVZw.cjs +1 -0
  98. package/dist/NiceWindow-lxtPR7yZ.js +1623 -0
  99. package/dist/NiceWindow.css +1 -1
  100. package/dist/charts-B8_V3_nq.cjs +882 -0
  101. package/dist/charts-BZgyyybE.js +31933 -0
  102. package/dist/charts-FuDk5-r6.js +31958 -0
  103. package/dist/charts-INj3yFo5.js +31946 -0
  104. package/dist/charts-NolNXKUL.cjs +882 -0
  105. package/dist/charts.cjs +1 -1
  106. package/dist/charts.css +1 -1
  107. package/dist/charts.mjs +1 -1
  108. package/dist/core-A_A6c7an.js +795 -0
  109. package/dist/core-B2iH2J_X.js +795 -0
  110. package/dist/core-BmspZEfD.js +795 -0
  111. package/dist/core-DAfLOet6.cjs +1 -0
  112. package/dist/core-ZG3bgnBR.cjs +1 -0
  113. package/dist/data-branching-B3TOqXAO.cjs +1 -0
  114. package/dist/data-branching-BUGiICDZ.js +6275 -0
  115. package/dist/data-branching-DMXmcocj.js +6275 -0
  116. package/dist/data-branching-YE8P9M5P.js +6275 -0
  117. package/dist/data-branching-t6uhAwIm.cjs +1 -0
  118. package/dist/data-branching.cjs +1 -1
  119. package/dist/data-branching.mjs +1 -1
  120. package/dist/data.cjs +1 -1
  121. package/dist/data.d.ts +7 -2
  122. package/dist/data.mjs +3 -3
  123. package/dist/devops-BhV3OmF7.js +8285 -0
  124. package/dist/devops-BqUxnbRi.cjs +17 -0
  125. package/dist/devops-Bx-Qwj9w.cjs +17 -0
  126. package/dist/devops-DYZatW45.js +8251 -0
  127. package/dist/devops-R98k2zpd.js +8251 -0
  128. package/dist/devops.cjs +1 -1
  129. package/dist/devops.d.ts +29 -16
  130. package/dist/devops.mjs +1 -1
  131. package/dist/editors.cjs +1 -1
  132. package/dist/editors.d.ts +59 -28
  133. package/dist/editors.mjs +7 -7
  134. package/dist/feedback.cjs +1 -1
  135. package/dist/feedback.mjs +3 -3
  136. package/dist/index.cjs +445 -445
  137. package/dist/index.css +1 -1
  138. package/dist/index.d.ts +214 -119
  139. package/dist/index.mjs +16635 -16351
  140. package/dist/lazy.cjs +1 -1
  141. package/dist/lazy.d.ts +31 -18
  142. package/dist/lazy.mjs +24 -24
  143. package/dist/navigation.cjs +1 -1
  144. package/dist/navigation.d.ts +17 -14
  145. package/dist/navigation.mjs +130 -130
  146. package/dist/no-code-BPaAS4wW.cjs +332 -0
  147. package/dist/no-code-CBwUVL1i.js +7447 -0
  148. package/dist/no-code-CjktkQ50.js +7447 -0
  149. package/dist/no-code-DW2NrRba.js +7447 -0
  150. package/dist/no-code-DmFxrZ5T.cjs +332 -0
  151. package/dist/no-code.cjs +1 -1
  152. package/dist/no-code.d.ts +2 -2
  153. package/dist/no-code.mjs +1 -1
  154. package/dist/overlays.cjs +1 -1
  155. package/dist/overlays.d.ts +4 -4
  156. package/dist/overlays.mjs +2 -2
  157. package/dist/pickerCommons-C4XWRUvH.cjs +1 -0
  158. package/dist/pickerCommons-C_BpYs_m.cjs +1 -0
  159. package/dist/pickerCommons-DAOXH_u5.js +1122 -0
  160. package/dist/pickerCommons-Dn4wnDco.js +1122 -0
  161. package/dist/pickerCommons-DskswPS5.js +1122 -0
  162. package/dist/pickerCommons.css +1 -1
  163. package/dist/style.css +7 -7
  164. package/package.json +3 -3
@@ -0,0 +1,1743 @@
1
+ import { jsxs as d, jsx as n, Fragment as Ze } from "react/jsx-runtime";
2
+ import { V as Ci, Q as Si, Y as Mi, o as X, D as Ii, G as zi, r as $i, g as Ri, k as Di, C as Li } from "./charts-FuDk5-r6.js";
3
+ import Mt, { useState as y, useCallback as b, useMemo as D, useRef as un, useEffect as Ie } from "react";
4
+ import { d as Ei } from "./NiceForm-a6tGr6ss.js";
5
+ import { N as Oi } from "./NiceModal-CHaan9al.js";
6
+ import { N as ji } from "./NicePagination-DQmZpsSQ.js";
7
+ const Ai = [
8
+ {
9
+ target: ".nice-filterbuilder",
10
+ titleKey: "tutorial.filterBuilder.intro.title",
11
+ title: "Filter builder",
12
+ contentKey: "tutorial.filterBuilder.intro.content",
13
+ content: "Build complex AND/OR filter trees: add conditions and nested groups, choose fields and operators, and save reusable presets.",
14
+ placement: "auto"
15
+ }
16
+ ], Ti = [
17
+ { value: "=", label: "Equals" },
18
+ { value: "<>", label: "Not Equals" },
19
+ { value: "<", label: "Less Than" },
20
+ { value: "<=", label: "Less or Equal" },
21
+ { value: ">", label: "Greater Than" },
22
+ { value: ">=", label: "Greater or Equal" },
23
+ { value: "contains", label: "Contains" },
24
+ { value: "notcontains", label: "Not Contains" },
25
+ { value: "startswith", label: "Starts With" },
26
+ { value: "endswith", label: "Ends With" },
27
+ { value: "isblank", label: "Is Blank" },
28
+ { value: "isnotblank", label: "Is Not Blank" }
29
+ ], Fi = ({ condition: o, fields: F, onChange: f, onRemove: S }) => {
30
+ const m = F.find((p) => p.field === o.field), C = o.operator === "isblank" || o.operator === "isnotblank", I = m?.operators || Ti;
31
+ return /* @__PURE__ */ d("div", { className: "nice-filterbuilder__condition", children: [
32
+ /* @__PURE__ */ n(
33
+ "select",
34
+ {
35
+ className: "nice-filterbuilder__select",
36
+ value: o.field,
37
+ onChange: (p) => f({ ...o, field: p.target.value, value: "" }),
38
+ children: F.map((p) => /* @__PURE__ */ n("option", { value: p.field, children: p.label }, p.field))
39
+ }
40
+ ),
41
+ /* @__PURE__ */ n(
42
+ "select",
43
+ {
44
+ className: "nice-filterbuilder__select",
45
+ value: o.operator,
46
+ onChange: (p) => f({ ...o, operator: p.target.value }),
47
+ children: I.map((p) => /* @__PURE__ */ n("option", { value: p.value, children: p.label }, p.value))
48
+ }
49
+ ),
50
+ !C && (m?.options ? /* @__PURE__ */ d(
51
+ "select",
52
+ {
53
+ className: "nice-filterbuilder__select",
54
+ value: String(o.value ?? ""),
55
+ onChange: (p) => f({ ...o, value: p.target.value }),
56
+ children: [
57
+ /* @__PURE__ */ n("option", { value: "", children: "--" }),
58
+ m.options.map((p) => /* @__PURE__ */ n("option", { value: p.value, children: p.label }, p.value))
59
+ ]
60
+ }
61
+ ) : m?.type === "boolean" ? /* @__PURE__ */ d(
62
+ "select",
63
+ {
64
+ className: "nice-filterbuilder__select",
65
+ value: String(o.value ?? ""),
66
+ onChange: (p) => f({ ...o, value: p.target.value === "true" }),
67
+ children: [
68
+ /* @__PURE__ */ n("option", { value: "true", children: "True" }),
69
+ /* @__PURE__ */ n("option", { value: "false", children: "False" })
70
+ ]
71
+ }
72
+ ) : /* @__PURE__ */ n(
73
+ "input",
74
+ {
75
+ className: "nice-filterbuilder__input",
76
+ type: m?.type === "number" ? "number" : m?.type === "date" ? "date" : "text",
77
+ value: String(o.value ?? ""),
78
+ onChange: (p) => f({
79
+ ...o,
80
+ value: m?.type === "number" ? Number(p.target.value) : p.target.value
81
+ })
82
+ }
83
+ )),
84
+ /* @__PURE__ */ n("button", { className: "nice-filterbuilder__remove", onClick: S, children: "×" })
85
+ ] });
86
+ }, pn = ({ group: o, fields: F, onChange: f, onRemove: S, depth: m, maxDepth: C }) => {
87
+ const [I, p] = y(!1), ne = () => f({ ...o, logic: o.logic === "and" ? "or" : "and" }), J = o.items.filter((w) => w.type === "condition").length, Z = o.items.length - J, q = [
88
+ J ? `${J} condition${J > 1 ? "s" : ""}` : "",
89
+ Z ? `${Z} group${Z > 1 ? "s" : ""}` : ""
90
+ ].filter(Boolean).join(" · ") || "empty", ie = () => {
91
+ const w = {
92
+ type: "condition",
93
+ field: F[0]?.field || "",
94
+ operator: "=",
95
+ value: ""
96
+ };
97
+ f({ ...o, items: [...o.items, w] });
98
+ }, U = () => {
99
+ if (m >= C)
100
+ return;
101
+ const w = { type: "group", logic: "and", items: [] };
102
+ f({ ...o, items: [...o.items, w] });
103
+ }, ae = (w, v) => {
104
+ const R = [...o.items];
105
+ R[w] = v, f({ ...o, items: R });
106
+ }, $ = (w) => {
107
+ f({ ...o, items: o.items.filter((v, R) => R !== w) });
108
+ };
109
+ return /* @__PURE__ */ d(
110
+ "div",
111
+ {
112
+ className: `nice-filterbuilder__group nice-filterbuilder__group--depth-${Math.min(m, 3)}`,
113
+ children: [
114
+ /* @__PURE__ */ d("div", { className: "nice-filterbuilder__group-header", children: [
115
+ /* @__PURE__ */ n(
116
+ "button",
117
+ {
118
+ type: "button",
119
+ className: "nice-filterbuilder__collapse",
120
+ onClick: () => p((w) => !w),
121
+ "aria-expanded": !I,
122
+ title: I ? "Expand group" : "Collapse group",
123
+ children: /* @__PURE__ */ n(X, { name: I ? "chevron-right" : "chevron-down", size: "sm" })
124
+ }
125
+ ),
126
+ /* @__PURE__ */ n(
127
+ "button",
128
+ {
129
+ className: "nice-filterbuilder__logic",
130
+ onClick: ne,
131
+ title: `Match ${o.logic === "and" ? "ALL" : "ANY"} — click to switch to ${o.logic === "and" ? "OR" : "AND"}`,
132
+ children: o.logic.toUpperCase()
133
+ }
134
+ ),
135
+ I ? /* @__PURE__ */ n("span", { className: "nice-filterbuilder__summary", children: q }) : /* @__PURE__ */ d(Ze, { children: [
136
+ /* @__PURE__ */ n("button", { className: "nice-btn nice-btn--sm", onClick: ie, children: "+ Condition" }),
137
+ m < C && /* @__PURE__ */ n("button", { className: "nice-btn nice-btn--sm", onClick: U, children: "+ Group" })
138
+ ] }),
139
+ S && /* @__PURE__ */ n("button", { className: "nice-filterbuilder__remove", onClick: S, children: "×" })
140
+ ] }),
141
+ !I && /* @__PURE__ */ n("div", { className: "nice-filterbuilder__group-body", children: o.items.map((w, v) => /* @__PURE__ */ n(Mt.Fragment, { children: w.type === "condition" ? /* @__PURE__ */ n(
142
+ Fi,
143
+ {
144
+ condition: w,
145
+ fields: F,
146
+ onChange: (R) => ae(v, R),
147
+ onRemove: () => $(v)
148
+ }
149
+ ) : /* @__PURE__ */ n(
150
+ pn,
151
+ {
152
+ group: w,
153
+ fields: F,
154
+ onChange: (R) => ae(v, R),
155
+ onRemove: () => $(v),
156
+ depth: m + 1,
157
+ maxDepth: C
158
+ }
159
+ ) }, v)) })
160
+ ]
161
+ }
162
+ );
163
+ }, hn = ({
164
+ fields: o,
165
+ value: F,
166
+ defaultValue: f,
167
+ onChange: S,
168
+ maxDepth: m = 3,
169
+ presets: C,
170
+ onSavePreset: I,
171
+ onDeletePreset: p,
172
+ tutorial: ne,
173
+ className: J,
174
+ style: Z
175
+ }) => {
176
+ const [q, ie] = Ci({
177
+ value: F,
178
+ defaultValue: f,
179
+ fallbackValue: { type: "group", logic: "and", items: [] },
180
+ onChange: S,
181
+ componentName: "NiceFilterBuilder"
182
+ }), [U, ae] = y(""), $ = b(
183
+ (v) => {
184
+ const R = C?.find((we) => we.name === v);
185
+ R && ie(structuredClone(R.filter));
186
+ },
187
+ [C, ie]
188
+ ), w = b(() => {
189
+ !U.trim() || !I || (I({ name: U.trim(), filter: structuredClone(q) }), ae(""));
190
+ }, [U, q, I]);
191
+ return /* @__PURE__ */ d(
192
+ "div",
193
+ {
194
+ className: `nice-filterbuilder ${J || ""}`,
195
+ style: { position: "relative", ...Z },
196
+ children: [
197
+ /* @__PURE__ */ n("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 20 }, children: /* @__PURE__ */ n(Si, { steps: Mi(ne, Ai) }) }),
198
+ (C?.length || I) && /* @__PURE__ */ d("div", { className: "nice-filterbuilder__presets", children: [
199
+ C && C.length > 0 && /* @__PURE__ */ n("div", { className: "nice-filterbuilder__preset-list", children: C.map((v) => /* @__PURE__ */ d("span", { className: "nice-filterbuilder__preset-tag", children: [
200
+ /* @__PURE__ */ n(
201
+ "button",
202
+ {
203
+ type: "button",
204
+ className: "nice-filterbuilder__preset-btn",
205
+ onClick: () => $(v.name),
206
+ children: v.name
207
+ }
208
+ ),
209
+ p && /* @__PURE__ */ n(
210
+ "button",
211
+ {
212
+ type: "button",
213
+ className: "nice-filterbuilder__preset-del",
214
+ onClick: () => p(v.name),
215
+ children: "×"
216
+ }
217
+ )
218
+ ] }, v.name)) }),
219
+ I && /* @__PURE__ */ d("div", { className: "nice-filterbuilder__preset-save", children: [
220
+ /* @__PURE__ */ n(
221
+ "input",
222
+ {
223
+ className: "nice-filterbuilder__input",
224
+ value: U,
225
+ onChange: (v) => ae(v.target.value),
226
+ placeholder: "Preset name..."
227
+ }
228
+ ),
229
+ /* @__PURE__ */ n(
230
+ "button",
231
+ {
232
+ className: "nice-btn nice-btn--sm",
233
+ onClick: w,
234
+ disabled: !U.trim(),
235
+ children: "Save"
236
+ }
237
+ )
238
+ ] })
239
+ ] }),
240
+ /* @__PURE__ */ n(
241
+ pn,
242
+ {
243
+ group: q,
244
+ fields: o,
245
+ onChange: ie,
246
+ depth: 0,
247
+ maxDepth: m
248
+ }
249
+ )
250
+ ]
251
+ }
252
+ );
253
+ };
254
+ hn.displayName = "NiceFilterBuilder";
255
+ function Pi(o, F, f) {
256
+ const S = o.map((m) => m[F]).filter((m) => typeof m == "number");
257
+ if (S.length === 0)
258
+ return f === "count" ? "0" : "";
259
+ switch (f) {
260
+ case "sum":
261
+ return S.reduce((m, C) => m + C, 0).toLocaleString();
262
+ case "avg":
263
+ return (S.reduce((m, C) => m + C, 0) / S.length).toLocaleString(void 0, {
264
+ maximumFractionDigits: 2
265
+ });
266
+ case "count":
267
+ return String(o.length);
268
+ case "min":
269
+ return Math.min(...S).toLocaleString();
270
+ case "max":
271
+ return Math.max(...S).toLocaleString();
272
+ }
273
+ }
274
+ function Xe(o) {
275
+ return o.includes(",") || o.includes('"') || o.includes(`
276
+ `) ? `"${o.replace(/"/g, '""')}"` : o;
277
+ }
278
+ const ue = {
279
+ width: 12,
280
+ height: 12,
281
+ viewBox: "0 0 24 24",
282
+ fill: "none",
283
+ stroke: "currentColor",
284
+ strokeWidth: 2.4,
285
+ strokeLinecap: "round",
286
+ strokeLinejoin: "round",
287
+ "aria-hidden": !0
288
+ }, Gi = () => /* @__PURE__ */ n("svg", { ...ue, children: /* @__PURE__ */ n("polyline", { points: "6 15 12 9 18 15" }) }), ze = () => /* @__PURE__ */ n("svg", { ...ue, children: /* @__PURE__ */ n("polyline", { points: "6 9 12 15 18 9" }) }), Wi = () => /* @__PURE__ */ d("svg", { ...ue, style: { opacity: 0.55 }, children: [
289
+ /* @__PURE__ */ n("polyline", { points: "6 10 12 5 18 10" }),
290
+ /* @__PURE__ */ n("polyline", { points: "6 14 12 19 18 14" })
291
+ ] }), Je = () => /* @__PURE__ */ n("svg", { ...ue, children: /* @__PURE__ */ n("polyline", { points: "9 6 15 12 9 18" }) }), Bi = () => /* @__PURE__ */ d("svg", { ...ue, children: [
292
+ /* @__PURE__ */ n("polyline", { points: "3 17 9 11 13 15 21 7" }),
293
+ /* @__PURE__ */ n("polyline", { points: "14 7 21 7 21 14" })
294
+ ] }), Vi = () => /* @__PURE__ */ d("svg", { ...ue, children: [
295
+ /* @__PURE__ */ n("polyline", { points: "3 7 9 13 13 9 21 17" }),
296
+ /* @__PURE__ */ n("polyline", { points: "14 17 21 17 21 10" })
297
+ ] }), Ki = () => /* @__PURE__ */ n("svg", { ...ue, children: /* @__PURE__ */ n("line", { x1: "4", y1: "12", x2: "20", y2: "12" }) });
298
+ function Ui(o) {
299
+ return typeof o == "boolean" ? o ? /* @__PURE__ */ n(
300
+ "svg",
301
+ {
302
+ className: "nice-datagrid__bool-icon nice-datagrid__bool-icon--true",
303
+ width: "16",
304
+ height: "16",
305
+ viewBox: "0 0 20 20",
306
+ fill: "none",
307
+ stroke: "currentColor",
308
+ strokeWidth: "2.5",
309
+ strokeLinecap: "round",
310
+ strokeLinejoin: "round",
311
+ "aria-label": "true",
312
+ role: "img",
313
+ children: /* @__PURE__ */ n("path", { d: "M4 10.5l4 4L16 6" })
314
+ }
315
+ ) : /* @__PURE__ */ n(
316
+ "svg",
317
+ {
318
+ className: "nice-datagrid__bool-icon nice-datagrid__bool-icon--false",
319
+ width: "16",
320
+ height: "16",
321
+ viewBox: "0 0 20 20",
322
+ fill: "none",
323
+ stroke: "currentColor",
324
+ strokeWidth: "2.5",
325
+ strokeLinecap: "round",
326
+ strokeLinejoin: "round",
327
+ "aria-label": "false",
328
+ role: "img",
329
+ children: /* @__PURE__ */ n("path", { d: "M5 5l10 10M15 5L5 15" })
330
+ }
331
+ ) : String(o ?? "");
332
+ }
333
+ function fn({
334
+ columns: o,
335
+ data: F,
336
+ keyField: f = "id",
337
+ dataSource: S,
338
+ sortable: m = !0,
339
+ sortField: C,
340
+ sortDirection: I,
341
+ onSort: p,
342
+ showAdvancedFilter: ne,
343
+ advancedFilter: J,
344
+ onAdvancedFilterChange: Z,
345
+ filterFields: q,
346
+ filterPresets: ie,
347
+ onSaveFilterPreset: U,
348
+ onDeleteFilterPreset: ae,
349
+ selectable: $,
350
+ selectedKeys: w,
351
+ onSelectionChange: v,
352
+ pagination: R,
353
+ pageSize: we = 10,
354
+ page: mn,
355
+ onPageChange: qe,
356
+ totalRows: It,
357
+ autoPagination: pe = !1,
358
+ stickyHeader: gn = !0,
359
+ stickyFooter: bn = !0,
360
+ searchable: zt,
361
+ searchPlaceholder: vn,
362
+ virtualScroll: re,
363
+ rowHeight: P = 40,
364
+ groupBy: He,
365
+ groupRender: $e,
366
+ onCellEdit: L,
367
+ editMode: Re = "inline",
368
+ formItems: yn,
369
+ formColumns: _n = 2,
370
+ editFormTitle: xn,
371
+ formProps: wn,
372
+ onRowEdit: De,
373
+ onRowAdd: Le,
374
+ onRowDelete: Yi,
375
+ bulkActions: et,
376
+ onBulkDelete: tt,
377
+ exportCsv: $t,
378
+ exportFilename: Rt = "export",
379
+ detailRow: Y,
380
+ expandedRowKeys: Nn,
381
+ onExpandedRowChange: nt,
382
+ columnReorder: Qi,
383
+ onColumnReorder: Xi,
384
+ columnResize: Ee,
385
+ rowDraggable: z,
386
+ onRowReorder: Oe,
387
+ striped: kn,
388
+ compact: Cn,
389
+ size: it,
390
+ loading: Sn,
391
+ emptyText: Mn,
392
+ toolbar: Dt,
393
+ onRowClick: at,
394
+ pinnedTopKeys: rt,
395
+ pinnedBottomKeys: lt,
396
+ colSpan: Lt,
397
+ showStatusBar: In,
398
+ contextMenuItems: je,
399
+ onContextMenuAction: zn,
400
+ printFriendly: $n,
401
+ // P3 features
402
+ keyboardNavigation: Ne,
403
+ focusedCell: Rn,
404
+ onFocusedCellChange: st,
405
+ cellRangeSelection: Et,
406
+ selectedCellRange: Dn,
407
+ onCellRangeChange: ot,
408
+ clipboard: le,
409
+ clipboardFormat: ct = "text",
410
+ onBeforeCopy: Ot,
411
+ onCopy: jt,
412
+ onPaste: dt,
413
+ quickFilters: H,
414
+ activeQuickFilters: Ln,
415
+ onQuickFilterChange: ut,
416
+ columnGroups: Ji,
417
+ stateStorageKey: he,
418
+ initialState: At,
419
+ onStateChange: Tt,
420
+ flashRowKeys: pt,
421
+ flashDuration: Ft = 500,
422
+ autoFitColumns: Zi,
423
+ showColumnStats: qi,
424
+ rowIndicator: ht,
425
+ frozenRows: Hi,
426
+ className: En,
427
+ style: On,
428
+ accessMode: jn,
429
+ id: An,
430
+ displayStyle: Pt,
431
+ disabled: Tn,
432
+ readOnly: Gt,
433
+ error: ft
434
+ }) {
435
+ const mt = Ii(jn, An), Fn = mt === "hidden", Ae = Tn || mt === "disabled", Pn = Gt || Ae || mt === "readOnly", { t: h } = zi();
436
+ $i("table", Pt), Ri("table", Pt);
437
+ const M = Di(S ?? null, {
438
+ autoLoad: !!S,
439
+ defaultPageSize: we
440
+ }), N = !!S, gt = N ? M.data : F ?? [], Te = N ? M.loading : Sn, [Wt, Gn] = y({
441
+ field: "",
442
+ dir: null
443
+ }), [Wn, Bn] = y(1), [Vn, bt] = y(/* @__PURE__ */ new Set()), [Fe, Kn] = y(""), [Un, Yn] = y({
444
+ type: "group",
445
+ logic: "and",
446
+ items: []
447
+ }), [Bt, Qn] = y(!1), ke = J ?? Un, Xn = (e) => {
448
+ Z ? Z(e) : Yn(e);
449
+ }, Jn = D(
450
+ () => q ?? o.filter((e) => e.filterable !== !1 && e.field).map((e) => ({ field: String(e.field), label: String(e.header ?? e.field) })),
451
+ [q, o]
452
+ ), se = ke.items.length, [fe, Zn] = y(we), [ee, vt] = y(null), [Pe, Ce] = y(null), [me, oe] = y(null), [Ge, Vt] = y(/* @__PURE__ */ new Set()), [Kt, qn] = y(0), yt = un(null), [Hn, ei] = y(/* @__PURE__ */ new Set()), We = Nn ?? Hn, [Q, Ut] = y({}), [ge, be] = y(null), [ve, _t] = y(null), [ti, ni] = y(null), [ii, ai] = y(null), [ri, li] = y([]), [ea, ta] = y(null), [si, Yt] = y(/* @__PURE__ */ new Set()), [na, ia] = y(null), xt = un(null), [oi, ci] = y(we);
453
+ Ie(() => {
454
+ if (!pe)
455
+ return;
456
+ const e = yt.current;
457
+ if (!e || typeof ResizeObserver > "u")
458
+ return;
459
+ const t = () => {
460
+ const a = e.clientHeight;
461
+ if (a <= 0)
462
+ return;
463
+ const r = Math.max(1, Math.floor(a / P) - 1);
464
+ ci((s) => s === r ? s : r), N && M.setPageSize(r);
465
+ };
466
+ t();
467
+ const i = new ResizeObserver(t);
468
+ return i.observe(e), () => i.disconnect();
469
+ }, [pe, P, N]);
470
+ const G = Rn ?? ti, E = Dn ?? ii, V = Ln ?? ri;
471
+ Ie(() => {
472
+ if (!he)
473
+ return;
474
+ const e = localStorage.getItem(`nice-datagrid-${he}`);
475
+ if (e && !At)
476
+ try {
477
+ const t = JSON.parse(e);
478
+ t.columnWidths && Ut(t.columnWidths), t.expandedGroups && Vt(new Set(t.expandedGroups));
479
+ } catch {
480
+ }
481
+ }, [he, At]), Ie(() => {
482
+ if (!pt?.size)
483
+ return;
484
+ Yt(new Set(pt));
485
+ const e = setTimeout(() => Yt(/* @__PURE__ */ new Set()), Ft);
486
+ return () => clearTimeout(e);
487
+ }, [pt, Ft]), Ie(() => {
488
+ if (!ve)
489
+ return;
490
+ const e = () => _t(null);
491
+ return document.addEventListener("click", e), () => document.removeEventListener("click", e);
492
+ }, [ve]);
493
+ const di = b(
494
+ (e, t) => {
495
+ je?.length && (e.preventDefault(), _t({ x: e.clientX, y: e.clientY, row: t }));
496
+ },
497
+ [je]
498
+ ), Qt = b(
499
+ (e) => {
500
+ const t = new Set(We);
501
+ t.has(e) ? t.delete(e) : t.add(e), nt ? nt(t) : ei(t);
502
+ },
503
+ [We, nt]
504
+ ), Xt = b(
505
+ (e, t) => {
506
+ if (!Ee)
507
+ return;
508
+ t.preventDefault();
509
+ const i = t.clientX, r = t.target.closest("th")?.offsetWidth ?? 100, s = (l) => {
510
+ const u = Math.max(40, r + l.clientX - i);
511
+ Ut((_) => ({ ..._, [e]: u }));
512
+ }, c = () => {
513
+ document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", c);
514
+ };
515
+ document.addEventListener("mousemove", s), document.addEventListener("mouseup", c);
516
+ },
517
+ [Ee]
518
+ ), K = N ? M.sort[0]?.field ?? "" : C ?? Wt.field, W = N ? M.sort[0]?.direction ?? null : I ?? Wt.dir, Se = N ? M.page : mn ?? Wn, k = w ?? Vn;
519
+ b(() => {
520
+ if (!he)
521
+ return;
522
+ const e = {
523
+ columnWidths: Q,
524
+ sortField: K || void 0,
525
+ sortDirection: W,
526
+ pageSize: fe,
527
+ expandedGroups: Array.from(Ge)
528
+ };
529
+ localStorage.setItem(`nice-datagrid-${he}`, JSON.stringify(e)), Tt?.(e);
530
+ }, [he, Q, K, W, fe, Ge, Tt]);
531
+ const O = D(() => o.filter((e) => !e.hidden), [o]), wt = D(
532
+ () => O.filter((e) => e.pinned === "left"),
533
+ [O]
534
+ ), Nt = D(
535
+ () => O.filter((e) => e.pinned === "right"),
536
+ [O]
537
+ ), Jt = D(() => O.filter((e) => !e.pinned), [O]), g = D(
538
+ () => [...wt, ...Jt, ...Nt],
539
+ [wt, Jt, Nt]
540
+ ), ui = D(() => O.some((e) => e.aggregate), [O]), Me = wt.length > 0 || Nt.length > 0, Zt = b(
541
+ (e) => {
542
+ const t = K === e ? W === "asc" ? "desc" : W === "desc" ? null : "asc" : "asc";
543
+ N ? t ? M.setSortField(e, t) : M.setSort([]) : p ? p(e, t) : Gn({ field: e, dir: t });
544
+ },
545
+ [K, W, N, M, p]
546
+ ), j = D(() => {
547
+ if (N)
548
+ return gt;
549
+ let e = [...gt];
550
+ if (Fe) {
551
+ const t = Fe.toLowerCase();
552
+ e = e.filter(
553
+ (i) => O.some(
554
+ (a) => String(i[a.field] ?? "").toLowerCase().includes(t)
555
+ )
556
+ );
557
+ }
558
+ return ke.items.length > 0 && (e = e.filter(
559
+ (t) => Li(t, ke)
560
+ )), !p && K && W && e.sort((t, i) => {
561
+ const a = t[K] ?? "", r = i[K] ?? "", s = typeof a == "number" ? a - r : String(a).localeCompare(String(r));
562
+ return W === "desc" ? -s : s;
563
+ }), e;
564
+ }, [gt, Fe, ke, O, K, W, p, N]), Be = N ? M.totalCount : It ?? j.length, ce = pe ? oi : N ? M.pageSize : fe, pi = Math.max(1, Math.ceil(Be / ce)), B = N ? j : R && !It ? j.slice((Se - 1) * ce, Se * ce) : j, Ve = b(
565
+ (e) => {
566
+ N ? M.setPage(e) : qe ? qe(e) : Bn(e);
567
+ },
568
+ [N, M, qe]
569
+ ), ye = D(() => B.map((e) => String(e[f])), [B, f]), _e = ye.length > 0 && ye.every((e) => k.has(e)), qt = ye.some((e) => k.has(e)), Ht = b(() => {
570
+ const e = new Set(k);
571
+ _e ? ye.forEach((t) => e.delete(t)) : ye.forEach((t) => e.add(t)), v ? v(e) : bt(e);
572
+ }, [_e, ye, k, v]), en = b(
573
+ (e) => {
574
+ const t = new Set(k);
575
+ t.has(e) ? t.delete(e) : t.add(e), v ? v(t) : bt(t);
576
+ },
577
+ [k, v]
578
+ ), tn = ({ field: e }) => K !== e || !W ? /* @__PURE__ */ n("span", { className: "nice-table__sort-icon", children: /* @__PURE__ */ n(Wi, {}) }) : /* @__PURE__ */ n("span", { className: "nice-table__sort-icon", children: W === "asc" ? /* @__PURE__ */ n(Gi, {}) : /* @__PURE__ */ n(ze, {}) }), A = D(() => {
579
+ if (!He)
580
+ return B.map((i, a) => ({
581
+ type: "data",
582
+ row: i,
583
+ key: String(i[f] ?? a)
584
+ }));
585
+ const e = /* @__PURE__ */ new Map();
586
+ B.forEach((i) => {
587
+ const a = i[He];
588
+ e.has(a) || e.set(a, []), e.get(a).push(i);
589
+ });
590
+ const t = [];
591
+ return e.forEach((i, a) => {
592
+ const r = `__group_${String(a)}`, s = Ge.has(r);
593
+ t.push({ type: "group", value: a, rows: i, expanded: s, key: r }), s && i.forEach(
594
+ (c, l) => t.push({ type: "data", row: c, key: String(c[f] ?? `${r}_${l}`) })
595
+ );
596
+ }), t;
597
+ }, [B, He, f, Ge]), { pinnedTopRows: hi, pinnedBottomRows: fi, normalRows: mi } = D(() => {
598
+ if (!rt?.size && !lt?.size)
599
+ return {
600
+ pinnedTopRows: [],
601
+ pinnedBottomRows: [],
602
+ normalRows: A
603
+ };
604
+ const e = [], t = [], i = [];
605
+ for (const a of A) {
606
+ if (a.type === "data") {
607
+ const r = a.key;
608
+ if (rt?.has(r)) {
609
+ e.push(a);
610
+ continue;
611
+ }
612
+ if (lt?.has(r)) {
613
+ t.push(a);
614
+ continue;
615
+ }
616
+ }
617
+ i.push(a);
618
+ }
619
+ return { pinnedTopRows: e, pinnedBottomRows: t, normalRows: i };
620
+ }, [A, rt, lt]), nn = b((e) => {
621
+ Vt((t) => {
622
+ const i = new Set(t);
623
+ return i.has(e) ? i.delete(e) : i.add(e), i;
624
+ });
625
+ }, []), gi = D(() => {
626
+ if (!re)
627
+ return A;
628
+ const e = yt.current?.clientHeight ?? 400, t = Math.ceil(e / P), i = Math.max(0, Math.floor(Kt / P) - 3), a = Math.min(A.length - 1, i + t + 6);
629
+ return A.slice(i, a + 1).map((r, s) => ({ ...r, _vIdx: i + s }));
630
+ }, [re, A, Kt, P]), Ke = b(
631
+ (e, t, i) => {
632
+ !L || Pn || (vt({ rowKey: e, field: t }), Ce(i));
633
+ },
634
+ [L]
635
+ ), an = b(() => {
636
+ ee && L && L(ee.rowKey, ee.field, Pe), vt(null), Ce(null);
637
+ }, [ee, Pe, L]), bi = b(() => {
638
+ vt(null), Ce(null);
639
+ }, []), vi = b(() => {
640
+ const e = O, t = e.map((l) => Xe(l.header)).join(","), i = j.map(
641
+ (l) => e.map((u) => Xe(String(l[u.field] ?? ""))).join(",")
642
+ ), a = [t, ...i].join(`
643
+ `), r = new Blob(["\uFEFF" + a], { type: "text/csv;charset=utf-8;" }), s = URL.createObjectURL(r), c = document.createElement("a");
644
+ c.href = s, c.download = `${Rt}.csv`, c.click(), URL.revokeObjectURL(s);
645
+ }, [O, j, Rt]), Ue = b(
646
+ (e) => {
647
+ st ? st(e) : ni(e);
648
+ },
649
+ [st]
650
+ ), Ye = b(
651
+ (e) => {
652
+ ot ? ot(e) : ai(e);
653
+ },
654
+ [ot]
655
+ ), T = D(() => A.filter((e) => e.type === "data").map((e) => e.key), [A]), yi = b(
656
+ (e) => {
657
+ if (!Ne || ee || !G)
658
+ return;
659
+ const t = T.indexOf(G.rowKey), i = g.findIndex((c) => c.field === G.field);
660
+ if (t < 0 || i < 0)
661
+ return;
662
+ let a = t, r = i;
663
+ switch (e.key) {
664
+ case "ArrowUp":
665
+ a = Math.max(0, t - 1);
666
+ break;
667
+ case "ArrowDown":
668
+ a = Math.min(T.length - 1, t + 1);
669
+ break;
670
+ case "ArrowLeft":
671
+ r = Math.max(0, i - 1);
672
+ break;
673
+ case "ArrowRight":
674
+ r = Math.min(g.length - 1, i + 1);
675
+ break;
676
+ case "Tab":
677
+ e.preventDefault(), e.shiftKey ? r = Math.max(0, i - 1) : r = Math.min(g.length - 1, i + 1);
678
+ break;
679
+ case "Enter": {
680
+ const c = g[i];
681
+ if (c.editable && L) {
682
+ const l = B.find((u) => String(u[f]) === G.rowKey);
683
+ l && Ke(G.rowKey, c.field, l[c.field]);
684
+ }
685
+ return;
686
+ }
687
+ case "Escape":
688
+ Ue(null), Ye(null);
689
+ return;
690
+ case "Home":
691
+ e.ctrlKey && (a = 0), r = 0;
692
+ break;
693
+ case "End":
694
+ e.ctrlKey && (a = T.length - 1), r = g.length - 1;
695
+ break;
696
+ case "PageUp":
697
+ a = Math.max(0, t - fe);
698
+ break;
699
+ case "PageDown":
700
+ a = Math.min(T.length - 1, t + fe);
701
+ break;
702
+ default:
703
+ return;
704
+ }
705
+ e.preventDefault();
706
+ const s = {
707
+ rowKey: T[a],
708
+ field: g[r].field
709
+ };
710
+ if (Ue(s), e.shiftKey && Et) {
711
+ const c = E?.start ?? G;
712
+ Ye({ start: c, end: s });
713
+ } else
714
+ Ye(null);
715
+ },
716
+ [
717
+ Ne,
718
+ ee,
719
+ G,
720
+ T,
721
+ g,
722
+ Et,
723
+ E,
724
+ Ue,
725
+ Ye,
726
+ L,
727
+ B,
728
+ f,
729
+ Ke,
730
+ fe
731
+ ]
732
+ ), rn = b(() => {
733
+ let e = [], t = [];
734
+ if (E) {
735
+ const i = T.indexOf(E.start.rowKey), a = T.indexOf(E.end.rowKey), r = Math.min(i, a), s = Math.max(i, a), c = g.findIndex((x) => x.field === E.start.field), l = g.findIndex((x) => x.field === E.end.field), u = Math.min(c, l), _ = Math.max(c, l);
736
+ t = g.slice(u, _ + 1).map((x) => x.field), e = B.filter((x) => {
737
+ const te = T.indexOf(String(x[f]));
738
+ return te >= r && te <= s;
739
+ });
740
+ } else k.size > 0 && (e = B.filter((i) => k.has(String(i[f]))), t = g.map((i) => i.field));
741
+ return { rows: e, fields: t };
742
+ }, [E, T, g, B, f, k]), ln = b(
743
+ (e, t, i) => {
744
+ const a = g.filter((r) => t.includes(r.field));
745
+ switch (i) {
746
+ case "json":
747
+ return JSON.stringify(
748
+ e.map((r) => Object.fromEntries(t.map((s) => [s, r[s]]))),
749
+ null,
750
+ 2
751
+ );
752
+ case "csv": {
753
+ const r = a.map((c) => Xe(c.header)).join(","), s = e.map((c) => a.map((l) => Xe(String(c[l.field] ?? ""))).join(",")).join(`
754
+ `);
755
+ return r + `
756
+ ` + s;
757
+ }
758
+ case "html": {
759
+ const r = a.map((c) => `<th>${c.header}</th>`).join(""), s = e.map((c) => `<tr>${a.map((l) => `<td>${c[l.field] ?? ""}</td>`).join("")}</tr>`).join("");
760
+ return `<table><thead><tr>${r}</tr></thead><tbody>${s}</tbody></table>`;
761
+ }
762
+ case "markdown": {
763
+ const r = "| " + a.map((l) => l.header).join(" | ") + " |", s = "| " + a.map(() => "---").join(" | ") + " |", c = e.map((l) => "| " + a.map((u) => l[u.field] ?? "").join(" | ") + " |").join(`
764
+ `);
765
+ return r + `
766
+ ` + s + `
767
+ ` + c;
768
+ }
769
+ default:
770
+ return e.map((r) => a.map((s) => r[s.field] ?? "").join(" ")).join(`
771
+ `);
772
+ }
773
+ },
774
+ [g]
775
+ ), kt = b(async () => {
776
+ if (!le)
777
+ return;
778
+ const { rows: e, fields: t } = rn();
779
+ if (!e.length || Ot?.(e, t) === !1)
780
+ return;
781
+ const i = ln(e, t, ct);
782
+ await navigator.clipboard.writeText(i), jt?.(e, t, ct);
783
+ }, [le, rn, Ot, ln, ct, jt]), sn = b(async () => {
784
+ if (!le || !G || !dt)
785
+ return;
786
+ const t = (await navigator.clipboard.readText()).split(`
787
+ `).map((i) => i.split(" "));
788
+ dt(t, G);
789
+ }, [le, G, dt]);
790
+ Ie(() => {
791
+ if (!le || !xt.current)
792
+ return;
793
+ const e = (t) => {
794
+ xt.current?.contains(document.activeElement) && (t.type === "copy" && (t.preventDefault(), kt()), t.type === "paste" && (t.preventDefault(), sn()));
795
+ };
796
+ return document.addEventListener("copy", e), document.addEventListener("paste", e), () => {
797
+ document.removeEventListener("copy", e), document.removeEventListener("paste", e);
798
+ };
799
+ }, [le, kt, sn]);
800
+ const _i = b(
801
+ (e) => {
802
+ const t = V.includes(e) ? V.filter((i) => i !== e) : [...V, e];
803
+ ut ? ut(t) : li(t);
804
+ },
805
+ [V, ut]
806
+ ), xi = D(() => {
807
+ if (!H?.length || !V.length)
808
+ return j;
809
+ const e = H.filter((t) => V.includes(t.key));
810
+ return j.filter((t) => e.every((i) => i.filter(t)));
811
+ }, [j, H, V]), on = H?.length ? xi : j;
812
+ b(
813
+ (e) => {
814
+ const t = j.map((u) => u[e]).filter((u) => u != null), i = t.filter((u) => typeof u == "number");
815
+ if (i.length === 0) {
816
+ const u = new Set(t).size;
817
+ return { count: t.length, unique: u, type: "text" };
818
+ }
819
+ const a = i.reduce((u, _) => u + _, 0), r = a / i.length, s = Math.min(...i), c = Math.max(...i), l = Math.sqrt(
820
+ i.reduce((u, _) => u + (_ - r) ** 2, 0) / i.length
821
+ );
822
+ return { count: i.length, sum: a, avg: r, min: s, max: c, stdDev: l, type: "numeric" };
823
+ },
824
+ [j]
825
+ );
826
+ const wi = b(
827
+ (e, t, i) => {
828
+ if (!e.cellVisualization)
829
+ return null;
830
+ const a = Number(t);
831
+ if (isNaN(a))
832
+ return null;
833
+ const r = e.visualMin ?? 0, s = e.visualMax ?? 100, c = Math.max(0, Math.min(100, (a - r) / (s - r) * 100));
834
+ switch (e.cellVisualization) {
835
+ case "progress":
836
+ return /* @__PURE__ */ d(
837
+ "div",
838
+ {
839
+ className: "nice-datagrid__cell-progress",
840
+ style: { display: "flex", alignItems: "center", gap: 8 },
841
+ children: [
842
+ /* @__PURE__ */ n(
843
+ "div",
844
+ {
845
+ style: {
846
+ flex: 1,
847
+ height: 6,
848
+ background: "var(--nice-border-color)",
849
+ borderRadius: 3,
850
+ overflow: "hidden"
851
+ },
852
+ children: /* @__PURE__ */ n(
853
+ "div",
854
+ {
855
+ style: {
856
+ width: `${c}%`,
857
+ height: "100%",
858
+ background: c > 80 ? "var(--nice-color-success)" : c > 50 ? "var(--nice-color-primary)" : "var(--nice-color-warning)",
859
+ transition: "width 0.3s ease"
860
+ }
861
+ }
862
+ )
863
+ }
864
+ ),
865
+ /* @__PURE__ */ d("span", { style: { fontSize: "0.75rem", minWidth: 32, textAlign: "right" }, children: [
866
+ Math.round(c),
867
+ "%"
868
+ ] })
869
+ ]
870
+ }
871
+ );
872
+ case "rating": {
873
+ const l = Math.round(a / s * 5);
874
+ return /* @__PURE__ */ n("div", { className: "nice-datagrid__cell-rating", children: [1, 2, 3, 4, 5].map((u) => /* @__PURE__ */ n(
875
+ "span",
876
+ {
877
+ style: {
878
+ color: u <= l ? "var(--nice-color-warning)" : "var(--nice-text-muted)",
879
+ fontSize: "0.95rem",
880
+ lineHeight: 1
881
+ },
882
+ "aria-hidden": "true",
883
+ children: /* @__PURE__ */ n(X, { name: "star", size: 14 })
884
+ },
885
+ u
886
+ )) });
887
+ }
888
+ case "trend": {
889
+ const l = e.visualMin ?? a, u = a - l, _ = u > 0 ? Bi : u < 0 ? Vi : Ki, x = u > 0 ? "var(--nice-color-success)" : u < 0 ? "var(--nice-color-danger)" : "var(--nice-text-muted)";
890
+ return /* @__PURE__ */ d(
891
+ "span",
892
+ {
893
+ style: {
894
+ color: x,
895
+ fontWeight: 500,
896
+ display: "inline-flex",
897
+ alignItems: "center",
898
+ gap: 4
899
+ },
900
+ children: [
901
+ /* @__PURE__ */ n(_, {}),
902
+ " ",
903
+ Math.abs(u).toFixed(1),
904
+ "%"
905
+ ]
906
+ }
907
+ );
908
+ }
909
+ case "heatmap": {
910
+ const l = c / 100, u = `rgba(${Math.round(255 * l)}, ${Math.round(100 * (1 - l))}, ${Math.round(50 * (1 - l))}, 0.6)`;
911
+ return /* @__PURE__ */ n("span", { style: { background: u, padding: "2px 8px", borderRadius: 4 }, children: a });
912
+ }
913
+ default:
914
+ return null;
915
+ }
916
+ },
917
+ []
918
+ ), Ni = b(
919
+ (e, t, i) => {
920
+ if (!e.conditionalFormats?.length)
921
+ return {};
922
+ for (const a of e.conditionalFormats)
923
+ if (a.when(t, i, e.field))
924
+ return {
925
+ className: a.className,
926
+ style: {
927
+ ...a.style,
928
+ backgroundColor: a.backgroundColor,
929
+ color: a.color
930
+ }
931
+ };
932
+ return {};
933
+ },
934
+ []
935
+ ), Ct = b(
936
+ (e, t) => {
937
+ if (!Me || !e.pinned)
938
+ return {};
939
+ const i = {
940
+ position: "sticky",
941
+ zIndex: 2,
942
+ background: "var(--nice-bg-primary, #fff)"
943
+ };
944
+ if (e.pinned === "left") {
945
+ let a = 0;
946
+ for (let r = 0; r < t; r++) {
947
+ const s = g[r];
948
+ s.pinned === "left" && (a += typeof s.width == "number" ? s.width : parseInt(String(s.width) || "100", 10));
949
+ }
950
+ $ && t === 0 && (a = 36), i.left = a;
951
+ } else {
952
+ let a = 0;
953
+ for (let r = g.length - 1; r > t; r--) {
954
+ const s = g[r];
955
+ s.pinned === "right" && (a += typeof s.width == "number" ? s.width : parseInt(String(s.width) || "100", 10));
956
+ }
957
+ i.right = a;
958
+ }
959
+ return i;
960
+ },
961
+ [Me, g, $]
962
+ ), cn = (e, t, i, a) => {
963
+ if (ee?.rowKey === i && ee?.field === e.field)
964
+ return e.editor ? e.editor(Pe, t, (l) => Ce(l)) : /* @__PURE__ */ n(
965
+ "input",
966
+ {
967
+ className: "nice-datagrid__edit-input",
968
+ autoFocus: !0,
969
+ value: Pe ?? "",
970
+ onChange: (l) => Ce(l.target.value),
971
+ onBlur: an,
972
+ onKeyDown: (l) => {
973
+ l.key === "Enter" && an(), l.key === "Escape" && bi();
974
+ }
975
+ }
976
+ );
977
+ const s = wi(e, t[e.field], t);
978
+ return s || (e.render ? e.render(t[e.field], t, a) : Ui(t[e.field]));
979
+ }, ki = (e, t, i, a) => {
980
+ const r = G?.rowKey === i && G?.field === e.field, s = E && (() => {
981
+ const u = T.indexOf(E.start.rowKey), _ = T.indexOf(E.end.rowKey), x = T.indexOf(i), te = g.findIndex((xe) => xe.field === E.start.field), de = g.findIndex((xe) => xe.field === E.end.field);
982
+ return x >= Math.min(u, _) && x <= Math.max(u, _) && a >= Math.min(te, de) && a <= Math.max(te, de);
983
+ })(), c = Ni(e, t[e.field], t);
984
+ return {
985
+ className: [
986
+ c.className,
987
+ r && "nice-datagrid__cell--focused",
988
+ s && "nice-datagrid__cell--in-range"
989
+ ].filter(Boolean).join(" "),
990
+ style: {
991
+ ...Ct(e, a),
992
+ textAlign: e.align,
993
+ ...c.style,
994
+ ...r ? { outline: "2px solid var(--nice-color-primary)", outlineOffset: -2 } : {},
995
+ ...s ? { background: "var(--nice-color-primary-light, rgba(59,130,246,0.15))" } : {}
996
+ }
997
+ };
998
+ }, dn = [
999
+ "nice-table",
1000
+ kn ? "nice-table--striped" : "",
1001
+ Cn ? "nice-table--compact" : "",
1002
+ it && it !== "md" ? `nice-table--${it}` : ""
1003
+ ].filter(Boolean).join(" "), Qe = g.length + ($ ? 1 : 0) + (Y ? 1 : 0) + (z ? 1 : 0) + (ht ? 1 : 0), St = (e, t, i) => {
1004
+ const { row: a, key: r } = e, s = k.has(r), c = We.has(r), l = si.has(r), u = [
1005
+ s && "nice-datagrid__row--selected",
1006
+ ge === t && "nice-datagrid__row--dragging",
1007
+ i && "nice-datagrid__row--pinned",
1008
+ l && "nice-datagrid__row--flash"
1009
+ ].filter(Boolean).join(" ");
1010
+ return /* @__PURE__ */ d(Mt.Fragment, { children: [
1011
+ /* @__PURE__ */ d(
1012
+ "tr",
1013
+ {
1014
+ className: u,
1015
+ onClick: () => at?.(a),
1016
+ onDoubleClick: Re === "popup" && (De || L) ? () => oe({ key: r, data: { ...a } }) : void 0,
1017
+ onContextMenu: (_) => di(_, a),
1018
+ style: at || Re === "popup" ? { cursor: "pointer" } : void 0,
1019
+ draggable: z,
1020
+ onDragStart: z ? () => be(t) : void 0,
1021
+ onDragOver: z ? (_) => _.preventDefault() : void 0,
1022
+ onDrop: z && Oe && ge != null ? () => {
1023
+ Oe(ge, t), be(null);
1024
+ } : void 0,
1025
+ onDragEnd: z ? () => be(null) : void 0,
1026
+ children: [
1027
+ ht && /* @__PURE__ */ n("td", { className: "nice-datagrid__row-indicator", style: { width: 32, padding: "0 4px" }, children: ht(a) }),
1028
+ Y && /* @__PURE__ */ n(
1029
+ "td",
1030
+ {
1031
+ className: "nice-datagrid__expand-col",
1032
+ onClick: (_) => {
1033
+ _.stopPropagation(), Qt(r);
1034
+ },
1035
+ children: /* @__PURE__ */ n("span", { className: "nice-datagrid__expand-btn", "data-expanded": c, children: c ? /* @__PURE__ */ n(ze, {}) : /* @__PURE__ */ n(Je, {}) })
1036
+ }
1037
+ ),
1038
+ z && /* @__PURE__ */ n(
1039
+ "td",
1040
+ {
1041
+ className: "nice-datagrid__drag-handle",
1042
+ style: { cursor: "grab", textAlign: "center", color: "var(--nice-text-muted)" },
1043
+ "aria-label": h("datagrid.dragRow", "Drag to reorder"),
1044
+ children: /* @__PURE__ */ n(X, { name: "more-vertical", size: 14 })
1045
+ }
1046
+ ),
1047
+ $ && /* @__PURE__ */ n(
1048
+ "td",
1049
+ {
1050
+ className: "nice-datagrid__checkbox",
1051
+ onClick: (_) => _.stopPropagation(),
1052
+ style: Me ? {
1053
+ position: "sticky",
1054
+ left: 0,
1055
+ zIndex: 1,
1056
+ background: "var(--nice-bg-primary, #fff)"
1057
+ } : void 0,
1058
+ children: /* @__PURE__ */ n(
1059
+ "input",
1060
+ {
1061
+ type: "checkbox",
1062
+ checked: s,
1063
+ onChange: () => en(r),
1064
+ "aria-label": `Select row ${r}`
1065
+ }
1066
+ )
1067
+ }
1068
+ ),
1069
+ (() => {
1070
+ let _ = 0;
1071
+ return g.map((x, te) => {
1072
+ if (_ > 0)
1073
+ return _--, null;
1074
+ const de = Lt ? Lt(a, x, te) : void 0;
1075
+ de && de > 1 && (_ = de - 1);
1076
+ const xe = ki(x, a, r, te);
1077
+ return /* @__PURE__ */ n(
1078
+ "td",
1079
+ {
1080
+ colSpan: de,
1081
+ className: xe.className,
1082
+ style: xe.style,
1083
+ onClick: Ne ? () => Ue({ rowKey: r, field: x.field }) : void 0,
1084
+ onDoubleClick: x.editable && L ? () => Ke(r, x.field, a[x.field]) : void 0,
1085
+ children: cn(x, a, r, t)
1086
+ },
1087
+ x.field
1088
+ );
1089
+ });
1090
+ })()
1091
+ ]
1092
+ }
1093
+ ),
1094
+ Y && c && /* @__PURE__ */ n("tr", { className: "nice-datagrid__detail-row", children: /* @__PURE__ */ n("td", { colSpan: Qe, children: Y(a) }) })
1095
+ ] }, r);
1096
+ };
1097
+ return Fn ? null : /* @__PURE__ */ d(
1098
+ "div",
1099
+ {
1100
+ ref: xt,
1101
+ className: `nice-datagrid ${$n ? "nice-datagrid--print" : ""} ${gn ? "nice-datagrid--sticky-header" : ""} ${bn ? "nice-datagrid--sticky-footer" : ""} ${pe ? "nice-datagrid--auto-pagination" : ""} ${Ae ? "nice-datagrid--disabled" : ""} ${Gt && !Ae ? "nice-datagrid--readonly" : ""} ${ft ? "nice-datagrid--error" : ""} ${En || ""}`,
1102
+ "aria-disabled": Ae || void 0,
1103
+ style: On,
1104
+ role: "grid",
1105
+ "aria-label": h("datagrid.title", "Data Grid"),
1106
+ "aria-rowcount": A.length,
1107
+ "aria-colcount": O.length,
1108
+ "aria-busy": Te || void 0,
1109
+ tabIndex: Ne ? 0 : void 0,
1110
+ onKeyDown: Ne ? yi : void 0,
1111
+ children: [
1112
+ ft && /* @__PURE__ */ n("div", { className: "nice-datagrid__error", role: "alert", children: ft }),
1113
+ (zt || Dt || $t || H?.length || Le || ne) && /* @__PURE__ */ d("div", { className: "nice-datagrid__toolbar", children: [
1114
+ zt && /* @__PURE__ */ n("div", { className: "nice-datagrid__search", children: /* @__PURE__ */ n(
1115
+ "input",
1116
+ {
1117
+ type: "text",
1118
+ value: N ? M.search : Fe,
1119
+ "aria-label": h("controls.search", "Search"),
1120
+ onChange: (e) => {
1121
+ N ? M.setSearch(e.target.value) : (Kn(e.target.value), Ve(1));
1122
+ },
1123
+ placeholder: vn || h("controls.search", "Search...")
1124
+ }
1125
+ ) }),
1126
+ ne && /* @__PURE__ */ d(
1127
+ "button",
1128
+ {
1129
+ type: "button",
1130
+ className: `nice-btn nice-btn--sm nice-btn--icon-only ${se > 0 ? "nice-btn--primary" : "nice-btn--secondary"}`,
1131
+ "aria-expanded": Bt,
1132
+ "aria-label": `${h("controls.filter", "Filter")}${se > 0 ? ` (${se})` : ""}`,
1133
+ title: `${h("controls.filter", "Filter")}${se > 0 ? ` (${se})` : ""}`,
1134
+ onClick: () => Qn((e) => !e),
1135
+ style: { position: "relative" },
1136
+ children: [
1137
+ /* @__PURE__ */ n(X, { name: "filter", size: 14 }),
1138
+ se > 0 && /* @__PURE__ */ n("span", { className: "nice-datagrid__filter-badge", children: se })
1139
+ ]
1140
+ }
1141
+ ),
1142
+ H && H.length > 0 && /* @__PURE__ */ n(
1143
+ "div",
1144
+ {
1145
+ className: "nice-datagrid__quick-filters",
1146
+ style: { display: "flex", gap: 6, flexWrap: "wrap" },
1147
+ children: H.map((e) => /* @__PURE__ */ d(
1148
+ "button",
1149
+ {
1150
+ className: `nice-datagrid__quick-filter ${V.includes(e.key) ? "nice-datagrid__quick-filter--active" : ""}`,
1151
+ onClick: () => _i(e.key),
1152
+ style: {
1153
+ display: "inline-flex",
1154
+ alignItems: "center",
1155
+ gap: 4,
1156
+ padding: "3px 10px",
1157
+ fontSize: "0.75rem",
1158
+ border: "1px solid var(--nice-border-color)",
1159
+ borderRadius: 12,
1160
+ background: V.includes(e.key) ? `var(--color-${e.color || "primary"})` : "var(--nice-bg-primary)",
1161
+ color: V.includes(e.key) ? "var(--nice-bg-primary, #fff)" : "inherit",
1162
+ cursor: "pointer",
1163
+ transition: "all 0.15s ease"
1164
+ },
1165
+ children: [
1166
+ e.icon && /* @__PURE__ */ n("span", { children: e.icon }),
1167
+ e.label
1168
+ ]
1169
+ },
1170
+ e.key
1171
+ ))
1172
+ }
1173
+ ),
1174
+ le && /* @__PURE__ */ n(
1175
+ "button",
1176
+ {
1177
+ className: "nice-btn nice-btn--sm nice-btn--ghost",
1178
+ onClick: kt,
1179
+ "aria-label": h("controls.copy", "Copy selected"),
1180
+ title: h("controls.copy", "Copy selected"),
1181
+ style: { marginLeft: 4 },
1182
+ children: /* @__PURE__ */ n(X, { name: "copy", size: 14 })
1183
+ }
1184
+ ),
1185
+ $t && /* @__PURE__ */ d(
1186
+ "button",
1187
+ {
1188
+ className: "nice-btn nice-btn--sm nice-btn--secondary",
1189
+ onClick: vi,
1190
+ title: h("controls.exportCsv", "Export CSV"),
1191
+ children: [
1192
+ /* @__PURE__ */ n(X, { name: "download", size: 14 }),
1193
+ h("controls.exportCsv", "Export CSV")
1194
+ ]
1195
+ }
1196
+ ),
1197
+ Le && /* @__PURE__ */ d(
1198
+ "button",
1199
+ {
1200
+ type: "button",
1201
+ className: "nice-btn nice-btn--sm nice-btn--primary",
1202
+ onClick: () => oe({ key: null, data: {} }),
1203
+ title: h("datagrid.addRow", "Add row"),
1204
+ children: [
1205
+ /* @__PURE__ */ n(X, { name: "plus", size: 14 }),
1206
+ h("datagrid.add", "Add")
1207
+ ]
1208
+ }
1209
+ ),
1210
+ Dt
1211
+ ] }),
1212
+ ne && Bt && /* @__PURE__ */ n(
1213
+ "div",
1214
+ {
1215
+ className: "nice-datagrid__filter-panel",
1216
+ style: { padding: "8px 12px", borderBottom: "1px solid var(--nice-border-color)" },
1217
+ children: /* @__PURE__ */ n(
1218
+ hn,
1219
+ {
1220
+ fields: Jn,
1221
+ value: ke,
1222
+ onChange: (e) => {
1223
+ Xn(e), Ve(1);
1224
+ },
1225
+ presets: ie,
1226
+ onSavePreset: U,
1227
+ onDeletePreset: ae
1228
+ }
1229
+ )
1230
+ }
1231
+ ),
1232
+ $ && k.size > 0 && (et?.length || tt) && /* @__PURE__ */ d(
1233
+ "div",
1234
+ {
1235
+ className: "nice-datagrid__bulk-toolbar",
1236
+ role: "toolbar",
1237
+ "aria-label": h("datagrid.bulkActions", "Bulk actions"),
1238
+ style: {
1239
+ display: "flex",
1240
+ alignItems: "center",
1241
+ gap: 8,
1242
+ padding: "6px 12px",
1243
+ background: "var(--nice-bg-tertiary, #f1f5f9)",
1244
+ borderBottom: "1px solid var(--nice-border-color)",
1245
+ flexWrap: "wrap"
1246
+ },
1247
+ children: [
1248
+ /* @__PURE__ */ n("span", { style: { fontSize: "0.85rem", color: "var(--nice-text-secondary)" }, children: h("datagrid.selectedCount", "{count} selected").replace(
1249
+ "{count}",
1250
+ String(k.size)
1251
+ ) }),
1252
+ (et || []).map((e) => {
1253
+ const t = Array.from(k), i = on.filter((r) => k.has(String(r[f]))), a = e.disabled?.(t, i) || !1;
1254
+ return /* @__PURE__ */ d(
1255
+ "button",
1256
+ {
1257
+ type: "button",
1258
+ className: `nice-btn nice-btn--sm nice-btn--${e.variant || "secondary"}`,
1259
+ disabled: a,
1260
+ onClick: () => e.onClick(t, i),
1261
+ children: [
1262
+ e.icon,
1263
+ e.icon && " ",
1264
+ e.label
1265
+ ]
1266
+ },
1267
+ e.key
1268
+ );
1269
+ }),
1270
+ tt && !et?.length && /* @__PURE__ */ d(
1271
+ "button",
1272
+ {
1273
+ type: "button",
1274
+ className: "nice-btn nice-btn--sm nice-btn--danger",
1275
+ onClick: () => {
1276
+ const e = Array.from(k), t = on.filter(
1277
+ (i) => k.has(String(i[f]))
1278
+ );
1279
+ tt(e, t);
1280
+ },
1281
+ children: [
1282
+ /* @__PURE__ */ n(X, { name: "trash", size: 14 }),
1283
+ h("datagrid.deleteSelected", "Delete selected")
1284
+ ]
1285
+ }
1286
+ ),
1287
+ /* @__PURE__ */ n(
1288
+ "button",
1289
+ {
1290
+ type: "button",
1291
+ className: "nice-btn nice-btn--xs nice-btn--ghost",
1292
+ onClick: () => {
1293
+ const e = /* @__PURE__ */ new Set();
1294
+ w === void 0 && bt(e), v?.(e);
1295
+ },
1296
+ style: { marginLeft: "auto" },
1297
+ children: h("datagrid.clearSelection", "Clear")
1298
+ }
1299
+ )
1300
+ ]
1301
+ }
1302
+ ),
1303
+ /* @__PURE__ */ d(
1304
+ "div",
1305
+ {
1306
+ ref: yt,
1307
+ className: `nice-datagrid__table-wrap ${re ? "nice-datagrid__table-wrap--virtual" : ""}`,
1308
+ style: re ? { maxHeight: Math.min(A.length * P, 600), overflowY: "auto" } : void 0,
1309
+ onScroll: re ? (e) => qn(e.currentTarget.scrollTop) : void 0,
1310
+ children: [
1311
+ re && /* @__PURE__ */ d("div", { style: { height: A.length * P, position: "relative" }, children: [
1312
+ /* @__PURE__ */ n("table", { className: dn, style: { position: "sticky", top: 0, zIndex: 3 }, children: /* @__PURE__ */ n("thead", { children: /* @__PURE__ */ d("tr", { children: [
1313
+ Y && /* @__PURE__ */ n("th", { className: "nice-datagrid__expand-col", style: { width: 36 } }),
1314
+ z && /* @__PURE__ */ n("th", { style: { width: 28 } }),
1315
+ $ && /* @__PURE__ */ n(
1316
+ "th",
1317
+ {
1318
+ className: "nice-datagrid__checkbox",
1319
+ style: Me ? {
1320
+ position: "sticky",
1321
+ left: 0,
1322
+ zIndex: 3,
1323
+ background: "var(--nice-bg-primary, #fff)"
1324
+ } : void 0,
1325
+ children: /* @__PURE__ */ n(
1326
+ "input",
1327
+ {
1328
+ type: "checkbox",
1329
+ checked: _e,
1330
+ ref: (e) => {
1331
+ e && (e.indeterminate = qt && !_e);
1332
+ },
1333
+ onChange: Ht,
1334
+ "aria-label": h("controls.selectAll", "Select all")
1335
+ }
1336
+ )
1337
+ }
1338
+ ),
1339
+ g.map((e, t) => /* @__PURE__ */ d(
1340
+ "th",
1341
+ {
1342
+ style: {
1343
+ width: Q[e.field] || e.width,
1344
+ minWidth: e.minWidth,
1345
+ textAlign: e.align,
1346
+ position: "relative",
1347
+ ...Ct(e, t)
1348
+ },
1349
+ className: m && e.sortable !== !1 ? "nice-datagrid__th--sortable" : void 0,
1350
+ onClick: () => m && e.sortable !== !1 && Zt(e.field),
1351
+ children: [
1352
+ e.header,
1353
+ m && e.sortable !== !1 && /* @__PURE__ */ n(tn, { field: e.field }),
1354
+ Ee && /* @__PURE__ */ n(
1355
+ "span",
1356
+ {
1357
+ className: "nice-datagrid__resize-handle",
1358
+ onMouseDown: (i) => {
1359
+ i.stopPropagation(), Xt(e.field, i);
1360
+ }
1361
+ }
1362
+ )
1363
+ ]
1364
+ },
1365
+ e.field
1366
+ ))
1367
+ ] }) }) }),
1368
+ gi.map((e, t) => {
1369
+ const i = e._vIdx ?? 0;
1370
+ if (e.type === "group") {
1371
+ const l = e;
1372
+ return /* @__PURE__ */ d(
1373
+ "div",
1374
+ {
1375
+ className: "nice-datagrid__group-row",
1376
+ style: {
1377
+ position: "absolute",
1378
+ top: i * P,
1379
+ height: P,
1380
+ left: 0,
1381
+ right: 0
1382
+ },
1383
+ onClick: () => nn(l.key),
1384
+ children: [
1385
+ /* @__PURE__ */ n("span", { className: "nice-datagrid__group-toggle", children: l.expanded ? /* @__PURE__ */ n(ze, {}) : /* @__PURE__ */ n(Je, {}) }),
1386
+ $e ? $e(l.value, l.rows) : /* @__PURE__ */ d(Ze, { children: [
1387
+ String(l.value),
1388
+ " (",
1389
+ l.rows.length,
1390
+ ")"
1391
+ ] })
1392
+ ]
1393
+ },
1394
+ l.key
1395
+ );
1396
+ }
1397
+ const { row: a, key: r } = e, s = k.has(r), c = We.has(r);
1398
+ return /* @__PURE__ */ d(Mt.Fragment, { children: [
1399
+ /* @__PURE__ */ d(
1400
+ "div",
1401
+ {
1402
+ className: `nice-datagrid__vrow ${s ? "nice-datagrid__row--selected" : ""} ${ge === t ? "nice-datagrid__row--dragging" : ""}`,
1403
+ style: {
1404
+ position: "absolute",
1405
+ top: i * P,
1406
+ height: P,
1407
+ left: 0,
1408
+ right: 0,
1409
+ display: "flex",
1410
+ alignItems: "center"
1411
+ },
1412
+ onClick: () => at?.(a),
1413
+ onDoubleClick: Re === "popup" && (De || L) ? () => oe({ key: r, data: { ...a } }) : void 0,
1414
+ draggable: z,
1415
+ onDragStart: z ? () => be(t) : void 0,
1416
+ onDragOver: z ? (l) => l.preventDefault() : void 0,
1417
+ onDrop: z && Oe && ge != null ? () => {
1418
+ Oe(ge, t), be(null);
1419
+ } : void 0,
1420
+ onDragEnd: z ? () => be(null) : void 0,
1421
+ children: [
1422
+ Y && /* @__PURE__ */ n(
1423
+ "div",
1424
+ {
1425
+ className: "nice-datagrid__expand-col",
1426
+ style: { width: 36, flexShrink: 0, textAlign: "center", cursor: "pointer" },
1427
+ onClick: (l) => {
1428
+ l.stopPropagation(), Qt(r);
1429
+ },
1430
+ children: /* @__PURE__ */ n("span", { className: "nice-datagrid__expand-btn", "data-expanded": c, children: c ? /* @__PURE__ */ n(ze, {}) : /* @__PURE__ */ n(Je, {}) })
1431
+ }
1432
+ ),
1433
+ z && /* @__PURE__ */ n(
1434
+ "div",
1435
+ {
1436
+ "aria-label": h("datagrid.dragRow", "Drag to reorder"),
1437
+ style: {
1438
+ width: 28,
1439
+ flexShrink: 0,
1440
+ cursor: "grab",
1441
+ textAlign: "center",
1442
+ color: "var(--nice-text-muted)",
1443
+ display: "inline-flex",
1444
+ alignItems: "center",
1445
+ justifyContent: "center"
1446
+ },
1447
+ children: /* @__PURE__ */ n(X, { name: "more-vertical", size: 14 })
1448
+ }
1449
+ ),
1450
+ $ && /* @__PURE__ */ n(
1451
+ "div",
1452
+ {
1453
+ className: "nice-datagrid__checkbox",
1454
+ style: { width: 36, flexShrink: 0 },
1455
+ onClick: (l) => l.stopPropagation(),
1456
+ children: /* @__PURE__ */ n(
1457
+ "input",
1458
+ {
1459
+ type: "checkbox",
1460
+ checked: s,
1461
+ onChange: () => en(r)
1462
+ }
1463
+ )
1464
+ }
1465
+ ),
1466
+ g.map((l) => /* @__PURE__ */ n(
1467
+ "div",
1468
+ {
1469
+ className: "nice-datagrid__vcell",
1470
+ style: {
1471
+ width: Q[l.field] || l.width || "auto",
1472
+ flex: Q[l.field] || l.width ? `0 0 ${typeof (Q[l.field] || l.width) == "number" ? (Q[l.field] || l.width) + "px" : Q[l.field] || l.width}` : 1,
1473
+ textAlign: l.align,
1474
+ overflow: "hidden",
1475
+ textOverflow: "ellipsis",
1476
+ whiteSpace: "nowrap",
1477
+ padding: "0 8px"
1478
+ },
1479
+ onDoubleClick: l.editable && L ? () => Ke(r, l.field, a[l.field]) : void 0,
1480
+ children: cn(l, a, r, i)
1481
+ },
1482
+ l.field
1483
+ ))
1484
+ ]
1485
+ }
1486
+ ),
1487
+ Y && c && /* @__PURE__ */ n(
1488
+ "div",
1489
+ {
1490
+ className: "nice-datagrid__detail-row",
1491
+ style: {
1492
+ position: "absolute",
1493
+ top: (i + 1) * P,
1494
+ left: 0,
1495
+ right: 0,
1496
+ padding: "8px 12px",
1497
+ background: "var(--nice-bg-secondary, #f8f8f8)"
1498
+ },
1499
+ children: Y(a)
1500
+ }
1501
+ )
1502
+ ] }, r);
1503
+ })
1504
+ ] }),
1505
+ !re && /* @__PURE__ */ d("table", { className: dn, children: [
1506
+ /* @__PURE__ */ n("thead", { children: /* @__PURE__ */ d("tr", { children: [
1507
+ Y && /* @__PURE__ */ n("th", { className: "nice-datagrid__expand-col", style: { width: 36 } }),
1508
+ z && /* @__PURE__ */ n("th", { style: { width: 28 } }),
1509
+ $ && /* @__PURE__ */ n(
1510
+ "th",
1511
+ {
1512
+ className: "nice-datagrid__checkbox",
1513
+ style: Me ? {
1514
+ position: "sticky",
1515
+ left: 0,
1516
+ zIndex: 3,
1517
+ background: "var(--nice-bg-primary, #fff)"
1518
+ } : void 0,
1519
+ children: /* @__PURE__ */ n(
1520
+ "input",
1521
+ {
1522
+ type: "checkbox",
1523
+ checked: _e,
1524
+ ref: (e) => {
1525
+ e && (e.indeterminate = qt && !_e);
1526
+ },
1527
+ onChange: Ht,
1528
+ "aria-label": h("controls.selectAll", "Select all")
1529
+ }
1530
+ )
1531
+ }
1532
+ ),
1533
+ g.map((e, t) => {
1534
+ const i = m && e.sortable !== !1, a = i ? K === e.field ? W === "asc" ? "ascending" : W === "desc" ? "descending" : "none" : "none" : void 0;
1535
+ return /* @__PURE__ */ d(
1536
+ "th",
1537
+ {
1538
+ style: {
1539
+ width: Q[e.field] || e.width,
1540
+ minWidth: e.minWidth,
1541
+ textAlign: e.align,
1542
+ position: "relative",
1543
+ ...Ct(e, t)
1544
+ },
1545
+ className: i ? "nice-datagrid__th--sortable" : void 0,
1546
+ onClick: () => i && Zt(e.field),
1547
+ "aria-sort": a,
1548
+ scope: "col",
1549
+ children: [
1550
+ e.header,
1551
+ i && /* @__PURE__ */ n(tn, { field: e.field }),
1552
+ Ee && /* @__PURE__ */ n(
1553
+ "span",
1554
+ {
1555
+ className: "nice-datagrid__resize-handle",
1556
+ onMouseDown: (r) => {
1557
+ r.stopPropagation(), Xt(e.field, r);
1558
+ }
1559
+ }
1560
+ )
1561
+ ]
1562
+ },
1563
+ e.field
1564
+ );
1565
+ })
1566
+ ] }) }),
1567
+ /* @__PURE__ */ n("tbody", { children: Te ? /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n("td", { colSpan: Qe, className: "nice-datagrid__empty", children: /* @__PURE__ */ n("div", { className: "nice-spinner nice-spinner--md", style: { margin: "0 auto" } }) }) }) : A.length === 0 ? /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n("td", { colSpan: Qe, className: "nice-datagrid__empty", children: Mn || h("controls.noData", "No data available") }) }) : /* @__PURE__ */ d(Ze, { children: [
1568
+ hi.map(
1569
+ (e, t) => e.type === "data" && St(e, t, "top")
1570
+ ),
1571
+ mi.map((e, t) => {
1572
+ if (e.type === "group") {
1573
+ const i = e;
1574
+ return /* @__PURE__ */ n(
1575
+ "tr",
1576
+ {
1577
+ className: "nice-datagrid__group-row",
1578
+ onClick: () => nn(i.key),
1579
+ children: /* @__PURE__ */ d("td", { colSpan: Qe, className: "nice-datagrid__group-cell", children: [
1580
+ /* @__PURE__ */ n("span", { className: "nice-datagrid__group-toggle", children: i.expanded ? /* @__PURE__ */ n(ze, {}) : /* @__PURE__ */ n(Je, {}) }),
1581
+ $e ? $e(i.value, i.rows) : /* @__PURE__ */ d(Ze, { children: [
1582
+ String(i.value),
1583
+ " (",
1584
+ i.rows.length,
1585
+ ")"
1586
+ ] })
1587
+ ] })
1588
+ },
1589
+ i.key
1590
+ );
1591
+ }
1592
+ return St(e, t);
1593
+ }),
1594
+ fi.map(
1595
+ (e, t) => e.type === "data" && St(e, t, "bottom")
1596
+ )
1597
+ ] }) })
1598
+ ] })
1599
+ ]
1600
+ }
1601
+ ),
1602
+ ui && !Te && B.length > 0 && /* @__PURE__ */ n(
1603
+ "div",
1604
+ {
1605
+ className: "nice-datagrid__summary",
1606
+ role: "row",
1607
+ "aria-label": h("datagrid.summary", "Summary"),
1608
+ children: g.map((e) => /* @__PURE__ */ n(
1609
+ "div",
1610
+ {
1611
+ className: "nice-datagrid__summary-cell",
1612
+ style: { textAlign: e.align },
1613
+ children: e.aggregate ? (e.aggregateLabel || e.aggregate.toUpperCase()) + ": " + Pi(j, e.field, e.aggregate) : ""
1614
+ },
1615
+ e.field
1616
+ ))
1617
+ }
1618
+ ),
1619
+ R && /* @__PURE__ */ d("div", { className: "nice-datagrid__footer", children: [
1620
+ /* @__PURE__ */ d("span", { className: "nice-datagrid__footer-info", children: [
1621
+ h("controls.showing", "Showing"),
1622
+ " ",
1623
+ (Se - 1) * ce + 1,
1624
+ "–",
1625
+ Math.min(Se * ce, Be),
1626
+ " ",
1627
+ h("controls.of", "of"),
1628
+ " ",
1629
+ Be,
1630
+ pe && /* @__PURE__ */ d("span", { className: "nice-datagrid__page-size-label", children: [
1631
+ " · ",
1632
+ ce,
1633
+ " ",
1634
+ h("controls.perPage", "/ page")
1635
+ ] })
1636
+ ] }),
1637
+ /* @__PURE__ */ n(
1638
+ ji,
1639
+ {
1640
+ page: Se,
1641
+ totalPages: pi,
1642
+ onChange: Ve,
1643
+ showInfo: !0,
1644
+ pageSize: ce,
1645
+ showPageSize: !pe,
1646
+ pageSizeOptions: [5, 10, 25, 50, 100],
1647
+ onPageSizeChange: (e) => {
1648
+ N ? M.setPageSize(e) : (Zn(e), Ve(1));
1649
+ },
1650
+ showFirstLast: !0
1651
+ }
1652
+ )
1653
+ ] }),
1654
+ In && !Te && /* @__PURE__ */ d("div", { className: "nice-datagrid__status-bar", children: [
1655
+ /* @__PURE__ */ d("span", { children: [
1656
+ h("controls.totalRows", "Total rows"),
1657
+ ": ",
1658
+ Be
1659
+ ] }),
1660
+ $ && k.size > 0 && /* @__PURE__ */ d("span", { children: [
1661
+ h("controls.selected", "Selected"),
1662
+ ": ",
1663
+ k.size
1664
+ ] })
1665
+ ] }),
1666
+ ve && je && /* @__PURE__ */ n(
1667
+ "div",
1668
+ {
1669
+ className: "nice-datagrid__context-menu",
1670
+ style: { position: "fixed", left: ve.x, top: ve.y, zIndex: 9999 },
1671
+ onClick: (e) => e.stopPropagation(),
1672
+ children: je.map((e) => /* @__PURE__ */ d(
1673
+ "button",
1674
+ {
1675
+ className: "nice-datagrid__context-item",
1676
+ disabled: e.disabled,
1677
+ onClick: () => {
1678
+ zn?.(e.key, ve.row), _t(null);
1679
+ },
1680
+ children: [
1681
+ e.icon && /* @__PURE__ */ n("span", { className: "nice-datagrid__context-icon", children: e.icon }),
1682
+ e.label
1683
+ ]
1684
+ },
1685
+ e.key
1686
+ ))
1687
+ }
1688
+ ),
1689
+ (Re === "popup" || Le) && me && (() => {
1690
+ const e = me.key === null, t = yn ?? o.filter((i) => !i.hidden && i.field !== f).map((i) => {
1691
+ let a = "text";
1692
+ return i.dataType === "number" || i.dataType === "currency" || i.dataType === "percent" ? a = "number" : i.dataType === "boolean" ? a = "checkbox" : i.dataType === "date" && (a = "date"), {
1693
+ field: i.field,
1694
+ label: i.header,
1695
+ type: a,
1696
+ required: i.validation?.required
1697
+ };
1698
+ });
1699
+ return /* @__PURE__ */ n(
1700
+ Oi,
1701
+ {
1702
+ open: !0,
1703
+ onClose: () => oe(null),
1704
+ title: xn ?? (e ? h("datagrid.addRow", "Add row") : h("datagrid.editRow", "Edit row")),
1705
+ size: "lg",
1706
+ children: /* @__PURE__ */ n(
1707
+ Ei,
1708
+ {
1709
+ items: t,
1710
+ data: me.data,
1711
+ columns: _n,
1712
+ showActions: !0,
1713
+ submitLabel: e ? h("controls.add", "Add") : h("controls.save", "Save"),
1714
+ cancelLabel: h("controls.cancel", "Cancel"),
1715
+ onCancel: () => oe(null),
1716
+ ...wn,
1717
+ onFieldChange: (i, a) => oe((r) => r && { ...r, data: { ...r.data, [i]: a } }),
1718
+ onSubmit: (i) => {
1719
+ e ? Le?.(i) : me.key && (De ? De(me.key, i) : L && Object.keys(i).forEach((a) => {
1720
+ L(me.key, a, i[a]);
1721
+ })), oe(null);
1722
+ }
1723
+ }
1724
+ )
1725
+ }
1726
+ );
1727
+ })()
1728
+ ]
1729
+ }
1730
+ );
1731
+ }
1732
+ fn.displayName = "NiceDataGrid";
1733
+ const ua = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1734
+ __proto__: null,
1735
+ NiceDataGrid: fn
1736
+ }, Symbol.toStringTag, { value: "Module" }));
1737
+ export {
1738
+ fn as N,
1739
+ hn as a,
1740
+ ua as b,
1741
+ Pi as c,
1742
+ Xe as e
1743
+ };