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