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