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