react-gridix 0.1.1 → 0.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/README.md +1184 -147
- package/dist/index.d.ts +222 -22
- package/dist/react-gridix.cjs +2 -1
- package/dist/react-gridix.js +1206 -521
- package/dist/style.css +1 -1
- package/package.json +3 -2
package/dist/react-gridix.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
return /* @__PURE__ */
|
|
1
|
+
import { jsxs as x, jsx as f, Fragment as lt } from "react/jsx-runtime";
|
|
2
|
+
import { useState as $, useCallback as Te, useLayoutEffect as Dn, useEffect as j, useRef as F, createElement as ge, useMemo as Z } from "react";
|
|
3
|
+
import { createPortal as In } from "react-dom";
|
|
4
|
+
const Se = (...r) => r.filter(Boolean).join(" ");
|
|
5
|
+
function Tn() {
|
|
6
|
+
return /* @__PURE__ */ f("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ f(
|
|
7
7
|
"path",
|
|
8
8
|
{
|
|
9
9
|
d: "M3.5 8.5l3 3 6-7",
|
|
@@ -15,654 +15,1339 @@ function mt() {
|
|
|
15
15
|
}
|
|
16
16
|
) });
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return /* @__PURE__ */
|
|
18
|
+
function Ln() {
|
|
19
|
+
return /* @__PURE__ */ f("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ f("path", { d: "M4 8h8", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round" }) });
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
checked:
|
|
21
|
+
function me({
|
|
22
|
+
checked: r,
|
|
23
23
|
onChange: s,
|
|
24
|
-
indeterminate:
|
|
25
|
-
variant:
|
|
26
|
-
disabled:
|
|
27
|
-
label:
|
|
24
|
+
indeterminate: a = !1,
|
|
25
|
+
variant: d = "native",
|
|
26
|
+
disabled: p = !1,
|
|
27
|
+
label: c,
|
|
28
28
|
"aria-label": m,
|
|
29
|
-
id:
|
|
30
|
-
name:
|
|
31
|
-
indicator:
|
|
32
|
-
className:
|
|
33
|
-
style:
|
|
34
|
-
classNames:
|
|
35
|
-
styles:
|
|
29
|
+
id: _,
|
|
30
|
+
name: N,
|
|
31
|
+
indicator: O,
|
|
32
|
+
className: P,
|
|
33
|
+
style: b,
|
|
34
|
+
classNames: D = {},
|
|
35
|
+
styles: S = {}
|
|
36
36
|
}) {
|
|
37
|
-
const
|
|
38
|
-
return /* @__PURE__ */
|
|
37
|
+
const T = a ? "indeterminate" : r ? "checked" : "unchecked";
|
|
38
|
+
return /* @__PURE__ */ x(
|
|
39
39
|
"label",
|
|
40
40
|
{
|
|
41
|
-
className:
|
|
41
|
+
className: Se(
|
|
42
42
|
"rk-checkbox",
|
|
43
|
-
`rk-checkbox--${
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
`rk-checkbox--${d}`,
|
|
44
|
+
T === "checked" && "rk-checkbox--checked",
|
|
45
|
+
a && "rk-checkbox--indeterminate",
|
|
46
|
+
p && "rk-checkbox--disabled",
|
|
47
|
+
D.root,
|
|
48
|
+
P
|
|
49
49
|
),
|
|
50
|
-
style: { ...
|
|
51
|
-
"data-state":
|
|
50
|
+
style: { ...S.root, ...b },
|
|
51
|
+
"data-state": T,
|
|
52
52
|
children: [
|
|
53
|
-
|
|
53
|
+
d === "native" ? /* @__PURE__ */ f(
|
|
54
54
|
"input",
|
|
55
55
|
{
|
|
56
56
|
type: "checkbox",
|
|
57
|
-
id:
|
|
58
|
-
name:
|
|
59
|
-
ref: (
|
|
60
|
-
|
|
57
|
+
id: _,
|
|
58
|
+
name: N,
|
|
59
|
+
ref: (M) => {
|
|
60
|
+
M && (M.indeterminate = a);
|
|
61
61
|
},
|
|
62
|
-
className:
|
|
63
|
-
style:
|
|
64
|
-
checked:
|
|
65
|
-
disabled:
|
|
62
|
+
className: Se("rk-checkbox__control", D.control),
|
|
63
|
+
style: S.control,
|
|
64
|
+
checked: r,
|
|
65
|
+
disabled: p,
|
|
66
66
|
"aria-label": m,
|
|
67
|
-
"data-state":
|
|
68
|
-
onChange: (
|
|
67
|
+
"data-state": T,
|
|
68
|
+
onChange: (M) => s(M.target.checked)
|
|
69
69
|
}
|
|
70
|
-
) : /* @__PURE__ */
|
|
70
|
+
) : /* @__PURE__ */ f(
|
|
71
71
|
"button",
|
|
72
72
|
{
|
|
73
73
|
type: "button",
|
|
74
74
|
role: "checkbox",
|
|
75
|
-
id:
|
|
76
|
-
className:
|
|
77
|
-
style:
|
|
78
|
-
"aria-checked":
|
|
75
|
+
id: _,
|
|
76
|
+
className: Se("rk-checkbox__control", D.control),
|
|
77
|
+
style: S.control,
|
|
78
|
+
"aria-checked": a ? "mixed" : r,
|
|
79
79
|
"aria-label": m,
|
|
80
|
-
disabled:
|
|
81
|
-
"data-state":
|
|
82
|
-
onClick: () => s(!
|
|
83
|
-
children: /* @__PURE__ */
|
|
80
|
+
disabled: p,
|
|
81
|
+
"data-state": T,
|
|
82
|
+
onClick: () => s(!r),
|
|
83
|
+
children: /* @__PURE__ */ f(
|
|
84
84
|
"span",
|
|
85
85
|
{
|
|
86
|
-
className:
|
|
86
|
+
className: Se(
|
|
87
87
|
"rk-checkbox__indicator",
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
O !== void 0 && !a && "rk-checkbox__indicator--custom",
|
|
89
|
+
D.indicator
|
|
90
90
|
),
|
|
91
|
-
style:
|
|
92
|
-
"data-state":
|
|
91
|
+
style: S.indicator,
|
|
92
|
+
"data-state": T,
|
|
93
93
|
"aria-hidden": "true",
|
|
94
|
-
children:
|
|
94
|
+
children: a ? d === "tick" ? /* @__PURE__ */ f(Ln, {}) : null : O !== void 0 ? O : d === "tick" ? /* @__PURE__ */ f(Tn, {}) : null
|
|
95
95
|
}
|
|
96
96
|
)
|
|
97
97
|
}
|
|
98
98
|
),
|
|
99
|
-
|
|
99
|
+
c != null && c !== !1 && c !== "" && /* @__PURE__ */ f("span", { className: Se("rk-checkbox__label", D.label), style: S.label, children: c })
|
|
100
100
|
]
|
|
101
101
|
}
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
|
-
const
|
|
105
|
-
function
|
|
106
|
-
|
|
104
|
+
const Mn = /^(\d{4})-(\d{2})-(\d{2})$/, kr = (r) => String(r).padStart(2, "0");
|
|
105
|
+
function Ie(r) {
|
|
106
|
+
const s = Mn.exec(r);
|
|
107
|
+
if (!s) return null;
|
|
108
|
+
const [a, d, p] = [Number(s[1]), Number(s[2]), Number(s[3])], c = new Date(a, d - 1, p);
|
|
109
|
+
return c.getFullYear() === a && c.getMonth() === d - 1 && c.getDate() === p ? c : null;
|
|
110
|
+
}
|
|
111
|
+
function H(r) {
|
|
112
|
+
var s;
|
|
113
|
+
if (r instanceof Date)
|
|
114
|
+
return Number.isNaN(r.getTime()) ? null : `${r.getFullYear()}-${kr(r.getMonth() + 1)}-${kr(r.getDate())}`;
|
|
115
|
+
if (typeof r == "number") return Number.isFinite(r) ? H(new Date(r)) : null;
|
|
116
|
+
if (typeof r == "string") {
|
|
117
|
+
const a = r.trim();
|
|
118
|
+
if (a === "") return null;
|
|
119
|
+
const d = (s = /^\d{4}-\d{2}-\d{2}/.exec(a)) == null ? void 0 : s[0];
|
|
120
|
+
if (d) return Ie(d) ? d : null;
|
|
121
|
+
const p = Date.parse(a);
|
|
122
|
+
return Number.isNaN(p) ? null : H(new Date(p));
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
function Fn(r, s, a) {
|
|
127
|
+
const d = H(r);
|
|
128
|
+
return d ? Ie(d).toLocaleDateString(s, a ?? { year: "numeric", month: "short", day: "numeric" }) : r == null ? "" : String(r);
|
|
129
|
+
}
|
|
130
|
+
function $n(r, s) {
|
|
131
|
+
var a;
|
|
132
|
+
return r === "" ? null : s instanceof Date ? Ie(r) : typeof s == "number" ? ((a = Ie(r)) == null ? void 0 : a.getTime()) ?? null : r;
|
|
133
|
+
}
|
|
134
|
+
function _r(r) {
|
|
135
|
+
return r.filterType ? r.filterType : r.type === "number" ? "number" : r.type === "date" ? "date" : r.type === "boolean" ? "select" : "text";
|
|
136
|
+
}
|
|
137
|
+
const On = (r) => typeof r == "object" && r !== null && !Array.isArray(r);
|
|
138
|
+
function wr(r) {
|
|
139
|
+
if (r == null) return !1;
|
|
140
|
+
if (typeof r == "string") return r.trim() !== "";
|
|
141
|
+
if (Array.isArray(r)) return r.length > 0;
|
|
142
|
+
if (On(r)) {
|
|
143
|
+
const s = r;
|
|
144
|
+
return typeof s.min == "number" || typeof s.max == "number" || !!s.from || !!s.to;
|
|
145
|
+
}
|
|
146
|
+
return !1;
|
|
147
|
+
}
|
|
148
|
+
function Pn(r, s, a, d) {
|
|
149
|
+
switch (r) {
|
|
150
|
+
case "text":
|
|
151
|
+
return a.toLowerCase().includes(String(s).trim().toLowerCase());
|
|
152
|
+
case "exact":
|
|
153
|
+
return a.toLowerCase() === String(s).trim().toLowerCase();
|
|
154
|
+
case "number": {
|
|
155
|
+
const { min: p, max: c } = s, m = typeof d == "number" ? d : d == null || d === "" ? NaN : Number(d);
|
|
156
|
+
return Number.isNaN(m) ? !1 : (typeof p != "number" || m >= p) && (typeof c != "number" || m <= c);
|
|
157
|
+
}
|
|
158
|
+
case "date": {
|
|
159
|
+
const { from: p, to: c } = s, m = H(d);
|
|
160
|
+
return m ? (!p || m >= p) && (!c || m <= c) : !1;
|
|
161
|
+
}
|
|
162
|
+
case "select":
|
|
163
|
+
return s.includes(String(d ?? ""));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function An(r, s, a, d) {
|
|
167
|
+
if (r.filterOptions) return r.filterOptions.map((c) => typeof c == "string" ? { value: c, label: c } : c);
|
|
168
|
+
if (r.type === "boolean")
|
|
169
|
+
return [
|
|
170
|
+
{ value: "true", label: "Yes" },
|
|
171
|
+
{ value: "false", label: "No" }
|
|
172
|
+
];
|
|
173
|
+
const p = /* @__PURE__ */ new Map();
|
|
174
|
+
for (const c of s) {
|
|
175
|
+
const m = a(c);
|
|
176
|
+
if (m == null || m === "") continue;
|
|
177
|
+
const _ = String(m);
|
|
178
|
+
p.has(_) || p.set(_, d(c));
|
|
179
|
+
}
|
|
180
|
+
return [...p].map(([c, m]) => ({ value: c, label: m })).sort((c, m) => c.label.localeCompare(m.label, void 0, { numeric: !0 }));
|
|
181
|
+
}
|
|
182
|
+
const Ft = typeof window < "u" ? Dn : j;
|
|
183
|
+
function Ce(r, s, a) {
|
|
184
|
+
const [d, p] = $(s), c = r !== void 0, m = c ? r : d, _ = Te(
|
|
185
|
+
(N) => {
|
|
186
|
+
c || p(N), a == null || a(N);
|
|
187
|
+
},
|
|
188
|
+
[c, a]
|
|
189
|
+
);
|
|
190
|
+
return [m, _];
|
|
191
|
+
}
|
|
192
|
+
const C = (...r) => r.filter(Boolean).join(" "), ot = (r) => r.headerName ?? (r.type === "boolean" ? "" : r.field), pe = (r) => ot(r) || r.field;
|
|
193
|
+
function Nr({ anchorRef: r, open: s, onClose: a, label: d, theme: p, className: c, style: m, children: _ }) {
|
|
194
|
+
const N = F(null), [O, P] = $({ top: 0, left: 0 }), b = Te(() => {
|
|
195
|
+
var B;
|
|
196
|
+
const D = r.current;
|
|
197
|
+
if (!D) return;
|
|
198
|
+
const S = D.getBoundingClientRect(), T = ((B = N.current) == null ? void 0 : B.offsetWidth) ?? 260, M = Math.max(8, Math.min(S.left, window.innerWidth - T - 8));
|
|
199
|
+
P({ top: S.bottom + 6, left: M });
|
|
200
|
+
}, [r]);
|
|
201
|
+
return Ft(() => {
|
|
202
|
+
s && b();
|
|
203
|
+
}, [s, b]), j(() => {
|
|
204
|
+
if (!s) return;
|
|
205
|
+
const D = (T) => {
|
|
206
|
+
var B, ie;
|
|
207
|
+
const M = T.target;
|
|
208
|
+
(B = N.current) != null && B.contains(M) || (ie = r.current) != null && ie.contains(M) || a();
|
|
209
|
+
}, S = (T) => {
|
|
210
|
+
var M;
|
|
211
|
+
T.key === "Escape" && (a(), (M = r.current) == null || M.focus());
|
|
212
|
+
};
|
|
213
|
+
return document.addEventListener("mousedown", D), document.addEventListener("keydown", S), window.addEventListener("resize", b), window.addEventListener("scroll", b, !0), () => {
|
|
214
|
+
document.removeEventListener("mousedown", D), document.removeEventListener("keydown", S), window.removeEventListener("resize", b), window.removeEventListener("scroll", b, !0);
|
|
215
|
+
};
|
|
216
|
+
}, [s, a, b, r]), !s || typeof document > "u" ? null : In(
|
|
217
|
+
/* @__PURE__ */ f(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
ref: N,
|
|
221
|
+
role: "dialog",
|
|
222
|
+
"aria-label": d,
|
|
223
|
+
"data-rk-theme": p || void 0,
|
|
224
|
+
className: C("rk-grid-popup", c),
|
|
225
|
+
style: { position: "fixed", top: O.top, left: O.left, ...m },
|
|
226
|
+
children: _
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
document.body
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
const it = (r) => {
|
|
233
|
+
if (r.trim() === "") return;
|
|
234
|
+
const s = Number(r);
|
|
235
|
+
return Number.isFinite(s) ? s : void 0;
|
|
236
|
+
}, Er = (r) => typeof r == "object" && r !== null && !Array.isArray(r);
|
|
237
|
+
function Kn({
|
|
238
|
+
value: r,
|
|
239
|
+
onChange: s,
|
|
240
|
+
label: a,
|
|
241
|
+
inputClassName: d,
|
|
242
|
+
inputStyle: p
|
|
243
|
+
}) {
|
|
244
|
+
const c = Er(r) ? r : {}, [m, _] = $(c.min === void 0 ? "" : String(c.min)), [N, O] = $(c.max === void 0 ? "" : String(c.max));
|
|
245
|
+
j(() => {
|
|
246
|
+
it(m) !== c.min && _(c.min === void 0 ? "" : String(c.min)), it(N) !== c.max && O(c.max === void 0 ? "" : String(c.max));
|
|
247
|
+
}, [c.min, c.max]);
|
|
248
|
+
const P = (b, D) => {
|
|
249
|
+
const S = it(b), T = it(D);
|
|
250
|
+
s(S === void 0 && T === void 0 ? void 0 : { min: S, max: T });
|
|
251
|
+
};
|
|
252
|
+
return /* @__PURE__ */ x("div", { className: "rk-grid__filter-fields", children: [
|
|
253
|
+
/* @__PURE__ */ x("label", { className: "rk-grid__filter-field", children: [
|
|
254
|
+
/* @__PURE__ */ f("span", { children: "Min" }),
|
|
255
|
+
/* @__PURE__ */ f(
|
|
256
|
+
"input",
|
|
257
|
+
{
|
|
258
|
+
autoFocus: !0,
|
|
259
|
+
type: "number",
|
|
260
|
+
className: C("rk-grid__filter-input", d),
|
|
261
|
+
style: p,
|
|
262
|
+
value: m,
|
|
263
|
+
"aria-label": `Minimum ${a}`,
|
|
264
|
+
onChange: (b) => {
|
|
265
|
+
_(b.target.value), P(b.target.value, N);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
] }),
|
|
270
|
+
/* @__PURE__ */ x("label", { className: "rk-grid__filter-field", children: [
|
|
271
|
+
/* @__PURE__ */ f("span", { children: "Max" }),
|
|
272
|
+
/* @__PURE__ */ f(
|
|
273
|
+
"input",
|
|
274
|
+
{
|
|
275
|
+
type: "number",
|
|
276
|
+
className: C("rk-grid__filter-input", d),
|
|
277
|
+
style: p,
|
|
278
|
+
value: N,
|
|
279
|
+
"aria-label": `Maximum ${a}`,
|
|
280
|
+
onChange: (b) => {
|
|
281
|
+
O(b.target.value), P(m, b.target.value);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
] })
|
|
286
|
+
] });
|
|
287
|
+
}
|
|
288
|
+
function Bn({
|
|
289
|
+
value: r,
|
|
290
|
+
onChange: s,
|
|
291
|
+
label: a,
|
|
292
|
+
inputClassName: d,
|
|
293
|
+
inputStyle: p
|
|
294
|
+
}) {
|
|
295
|
+
const c = Er(r) ? r : {}, m = (_, N) => s(!_ && !N ? void 0 : { from: _ || void 0, to: N || void 0 });
|
|
296
|
+
return /* @__PURE__ */ x("div", { className: "rk-grid__filter-fields", children: [
|
|
297
|
+
/* @__PURE__ */ x("label", { className: "rk-grid__filter-field", children: [
|
|
298
|
+
/* @__PURE__ */ f("span", { children: "From" }),
|
|
299
|
+
/* @__PURE__ */ f(
|
|
300
|
+
"input",
|
|
301
|
+
{
|
|
302
|
+
autoFocus: !0,
|
|
303
|
+
type: "date",
|
|
304
|
+
className: C("rk-grid__filter-input", d),
|
|
305
|
+
style: p,
|
|
306
|
+
value: c.from ?? "",
|
|
307
|
+
"aria-label": `${a} from`,
|
|
308
|
+
onChange: (_) => m(_.target.value, c.to)
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
] }),
|
|
312
|
+
/* @__PURE__ */ x("label", { className: "rk-grid__filter-field", children: [
|
|
313
|
+
/* @__PURE__ */ f("span", { children: "To" }),
|
|
314
|
+
/* @__PURE__ */ f(
|
|
315
|
+
"input",
|
|
316
|
+
{
|
|
317
|
+
type: "date",
|
|
318
|
+
className: C("rk-grid__filter-input", d),
|
|
319
|
+
style: p,
|
|
320
|
+
value: c.to ?? "",
|
|
321
|
+
"aria-label": `${a} to`,
|
|
322
|
+
onChange: (_) => m(c.from, _.target.value)
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
] })
|
|
326
|
+
] });
|
|
327
|
+
}
|
|
328
|
+
function Rn({
|
|
329
|
+
value: r,
|
|
330
|
+
onChange: s,
|
|
331
|
+
options: a
|
|
332
|
+
}) {
|
|
333
|
+
const d = Array.isArray(r) ? r : [], p = (c, m) => {
|
|
334
|
+
const _ = m ? [...d, c] : d.filter((N) => N !== c);
|
|
335
|
+
s(_.length ? _ : void 0);
|
|
336
|
+
};
|
|
337
|
+
return /* @__PURE__ */ x("div", { className: "rk-grid__filter-fields rk-grid__filter-options", role: "group", children: [
|
|
338
|
+
a.length === 0 && /* @__PURE__ */ f("span", { className: "rk-grid__filter-empty", children: "No values" }),
|
|
339
|
+
a.map((c) => /* @__PURE__ */ f(
|
|
340
|
+
me,
|
|
341
|
+
{
|
|
342
|
+
checked: d.includes(c.value),
|
|
343
|
+
onChange: (m) => p(c.value, m),
|
|
344
|
+
label: c.label ?? c.value
|
|
345
|
+
},
|
|
346
|
+
c.value
|
|
347
|
+
))
|
|
348
|
+
] });
|
|
349
|
+
}
|
|
350
|
+
function Wn({
|
|
351
|
+
column: r,
|
|
107
352
|
label: s,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
353
|
+
kind: a,
|
|
354
|
+
value: d,
|
|
355
|
+
onChange: p,
|
|
356
|
+
options: c,
|
|
357
|
+
theme: m,
|
|
358
|
+
indicatorClassName: _,
|
|
359
|
+
indicatorStyle: N,
|
|
113
360
|
popupClassName: O,
|
|
114
|
-
popupStyle:
|
|
115
|
-
inputClassName:
|
|
116
|
-
inputStyle:
|
|
361
|
+
popupStyle: P,
|
|
362
|
+
inputClassName: b,
|
|
363
|
+
inputStyle: D
|
|
117
364
|
}) {
|
|
118
|
-
const [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
365
|
+
const [S, T] = $(!1), M = F(null), B = wr(d), ie = Te(() => T(!1), []), Le = typeof d == "string" ? d : "", st = () => {
|
|
366
|
+
if (r.filterRenderer)
|
|
367
|
+
return ge(r.filterRenderer, { column: r, value: Le, onChange: (z) => p(z || void 0) });
|
|
368
|
+
switch (a) {
|
|
369
|
+
case "number":
|
|
370
|
+
return /* @__PURE__ */ f(Kn, { value: d, onChange: p, label: s, inputClassName: b, inputStyle: D });
|
|
371
|
+
case "date":
|
|
372
|
+
return /* @__PURE__ */ f(Bn, { value: d, onChange: p, label: s, inputClassName: b, inputStyle: D });
|
|
373
|
+
case "select":
|
|
374
|
+
return /* @__PURE__ */ f(Rn, { value: d, onChange: p, options: c });
|
|
375
|
+
default:
|
|
376
|
+
return /* @__PURE__ */ f(
|
|
377
|
+
"input",
|
|
378
|
+
{
|
|
379
|
+
autoFocus: !0,
|
|
380
|
+
type: "text",
|
|
381
|
+
className: C("rk-grid__filter-input", b),
|
|
382
|
+
style: D,
|
|
383
|
+
value: Le,
|
|
384
|
+
placeholder: r.filterPlaceholder ?? (a === "exact" ? "Exactly…" : `Filter ${s}…`),
|
|
385
|
+
"aria-label": `Filter text for ${s}`,
|
|
386
|
+
onChange: (z) => p(z.target.value || void 0),
|
|
387
|
+
onKeyDown: (z) => {
|
|
388
|
+
var oe;
|
|
389
|
+
z.key === "Enter" && (T(!1), (oe = M.current) == null || oe.focus());
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
}
|
|
144
394
|
};
|
|
145
|
-
return /* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */
|
|
395
|
+
return /* @__PURE__ */ x(lt, { children: [
|
|
396
|
+
/* @__PURE__ */ f(
|
|
147
397
|
"button",
|
|
148
398
|
{
|
|
149
|
-
ref:
|
|
399
|
+
ref: M,
|
|
150
400
|
type: "button",
|
|
151
|
-
className:
|
|
401
|
+
className: C(
|
|
152
402
|
"rk-grid__filter-btn",
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
403
|
+
B && "rk-grid__filter-btn--active",
|
|
404
|
+
S && "rk-grid__filter-btn--open",
|
|
405
|
+
_
|
|
156
406
|
),
|
|
157
|
-
style:
|
|
407
|
+
style: N,
|
|
158
408
|
"aria-label": `Filter ${s}`,
|
|
159
409
|
"aria-haspopup": "dialog",
|
|
160
|
-
"aria-expanded":
|
|
161
|
-
"data-active":
|
|
162
|
-
onClick: (
|
|
163
|
-
|
|
410
|
+
"aria-expanded": S,
|
|
411
|
+
"data-active": B || void 0,
|
|
412
|
+
onClick: (z) => {
|
|
413
|
+
z.stopPropagation(), T((oe) => !oe);
|
|
164
414
|
},
|
|
165
|
-
|
|
415
|
+
onKeyDown: (z) => z.stopPropagation(),
|
|
416
|
+
children: r.filterIndicator ? ge(r.filterIndicator, { column: r, active: B, open: S }) : /* @__PURE__ */ f("span", { className: "rk-grid__filter-dot", "aria-hidden": "true" })
|
|
166
417
|
}
|
|
167
418
|
),
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
type: "text",
|
|
184
|
-
className: Ne("rk-grid__filter-input", B),
|
|
185
|
-
style: G,
|
|
186
|
-
value: c,
|
|
187
|
-
placeholder: o.filterPlaceholder ?? `Filter ${s}…`,
|
|
188
|
-
"aria-label": `Filter text for ${s}`,
|
|
189
|
-
onChange: (g) => h(g.target.value),
|
|
190
|
-
onKeyDown: (g) => {
|
|
191
|
-
g.key === "Enter" && _e();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
),
|
|
195
|
-
q && /* @__PURE__ */ d("button", { type: "button", className: "rk-grid__filter-clear", onClick: () => h(""), children: "Clear" })
|
|
196
|
-
]
|
|
197
|
-
}
|
|
198
|
-
),
|
|
199
|
-
document.body
|
|
419
|
+
/* @__PURE__ */ x(
|
|
420
|
+
Nr,
|
|
421
|
+
{
|
|
422
|
+
anchorRef: M,
|
|
423
|
+
open: S,
|
|
424
|
+
onClose: ie,
|
|
425
|
+
label: `Filter ${s}`,
|
|
426
|
+
theme: m,
|
|
427
|
+
className: O,
|
|
428
|
+
style: P,
|
|
429
|
+
children: [
|
|
430
|
+
st(),
|
|
431
|
+
B && /* @__PURE__ */ f("button", { type: "button", className: "rk-grid__filter-clear", onClick: () => p(void 0), children: "Clear" })
|
|
432
|
+
]
|
|
433
|
+
}
|
|
200
434
|
)
|
|
201
435
|
] });
|
|
202
436
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
437
|
+
function jn({ columns: r, hidden: s, onToggle: a, theme: d, className: p, style: c }) {
|
|
438
|
+
const [m, _] = $(!1), N = F(null), O = Te(() => _(!1), []), P = r.filter((b) => !s.has(b.field)).length;
|
|
439
|
+
return /* @__PURE__ */ x(lt, { children: [
|
|
440
|
+
/* @__PURE__ */ f(
|
|
441
|
+
"button",
|
|
442
|
+
{
|
|
443
|
+
ref: N,
|
|
444
|
+
type: "button",
|
|
445
|
+
className: C("rk-grid__tool-btn", p),
|
|
446
|
+
style: c,
|
|
447
|
+
"aria-haspopup": "dialog",
|
|
448
|
+
"aria-expanded": m,
|
|
449
|
+
onClick: () => _((b) => !b),
|
|
450
|
+
children: "Columns"
|
|
451
|
+
}
|
|
452
|
+
),
|
|
453
|
+
/* @__PURE__ */ f(Nr, { anchorRef: N, open: m, onClose: O, label: "Show or hide columns", theme: d, children: /* @__PURE__ */ f("div", { className: "rk-grid__filter-fields rk-grid__filter-options", role: "group", "aria-label": "Columns", children: r.filter((b) => b.hideable !== !1).map((b) => {
|
|
454
|
+
const D = !s.has(b.field);
|
|
455
|
+
return /* @__PURE__ */ f(
|
|
456
|
+
me,
|
|
457
|
+
{
|
|
458
|
+
checked: D,
|
|
459
|
+
disabled: D && P <= 1,
|
|
460
|
+
onChange: (S) => a(b.field, !S),
|
|
461
|
+
label: pe(b)
|
|
462
|
+
},
|
|
463
|
+
b.field
|
|
464
|
+
);
|
|
465
|
+
}) }) })
|
|
466
|
+
] });
|
|
467
|
+
}
|
|
468
|
+
const Vn = /^[=+\-@\t\r]/;
|
|
469
|
+
function Un(r, s, a) {
|
|
470
|
+
if (r == null) return "";
|
|
471
|
+
let d = String(r);
|
|
472
|
+
return a && typeof r == "string" && Vn.test(d) && !Number.isFinite(Number(d)) && (d = `'${d}`), d.includes(s) || /["\r\n]/.test(d) ? `"${d.replace(/"/g, '""')}"` : d;
|
|
473
|
+
}
|
|
474
|
+
function zn(r, s, a = {}) {
|
|
475
|
+
const { delimiter: d = ",", sanitize: p = !0 } = a, c = (m) => m.map((_) => Un(_, d, p)).join(d);
|
|
476
|
+
return [c(r), ...s.map(c)].join(`\r
|
|
477
|
+
`);
|
|
478
|
+
}
|
|
479
|
+
function qn(r, s) {
|
|
480
|
+
if (typeof document > "u") return;
|
|
481
|
+
const a = new Blob(["\uFEFF", r], { type: "text/csv;charset=utf-8" }), d = URL.createObjectURL(a), p = document.createElement("a");
|
|
482
|
+
p.href = d, p.download = s, p.style.display = "none", document.body.appendChild(p), p.click(), p.remove(), setTimeout(() => URL.revokeObjectURL(d), 1e3);
|
|
483
|
+
}
|
|
484
|
+
const $t = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Sr = (r, s) => Object.prototype.hasOwnProperty.call(r, s);
|
|
485
|
+
function U(r, s) {
|
|
486
|
+
if (r === null || typeof r != "object") return;
|
|
487
|
+
if (Sr(r, s)) return r[s];
|
|
488
|
+
let a = r;
|
|
489
|
+
for (const d of s.split(".")) {
|
|
490
|
+
if (a == null || typeof a != "object" || $t.has(d)) return;
|
|
491
|
+
a = a[d];
|
|
211
492
|
}
|
|
212
|
-
return
|
|
493
|
+
return a;
|
|
213
494
|
}
|
|
214
|
-
function
|
|
215
|
-
if (Array.isArray(
|
|
216
|
-
const
|
|
217
|
-
return
|
|
495
|
+
function yr(r, s, a) {
|
|
496
|
+
if (Array.isArray(r)) {
|
|
497
|
+
const d = [...r];
|
|
498
|
+
return d[s] = a, d;
|
|
218
499
|
}
|
|
219
|
-
return { ...
|
|
500
|
+
return { ...r, [s]: a };
|
|
220
501
|
}
|
|
221
|
-
function
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
return
|
|
225
|
-
const [
|
|
226
|
-
if (
|
|
227
|
-
const m =
|
|
228
|
-
return
|
|
502
|
+
function Ot(r, s, a) {
|
|
503
|
+
const d = r ?? {};
|
|
504
|
+
if (Sr(d, s) || !s.includes("."))
|
|
505
|
+
return $t.has(s) ? r : yr(d, s, a);
|
|
506
|
+
const [p, ...c] = s.split(".");
|
|
507
|
+
if ($t.has(p)) return r;
|
|
508
|
+
const m = d[p];
|
|
509
|
+
return yr(d, p, Ot(m !== null && typeof m == "object" ? m : {}, c.join("."), a));
|
|
229
510
|
}
|
|
230
|
-
const
|
|
231
|
-
function
|
|
232
|
-
const
|
|
233
|
-
return
|
|
511
|
+
const ee = 44, Hn = 150, xr = 10, Mt = (r, s) => `${typeof r}:${r}\0${s}`;
|
|
512
|
+
function De(r, s) {
|
|
513
|
+
const a = U(s, r.field);
|
|
514
|
+
return r.valueFormatter ? r.valueFormatter(a, s) : r.type === "boolean" && typeof a == "boolean" ? a ? "Yes" : "No" : r.type === "date" ? Fn(a, r.dateLocale, r.dateFormat) : a == null ? "" : a instanceof Date ? a.toLocaleDateString() : String(a);
|
|
234
515
|
}
|
|
235
|
-
function
|
|
236
|
-
|
|
516
|
+
function Jn(r, s, a) {
|
|
517
|
+
if (a.type === "date") {
|
|
518
|
+
const d = H(r) ?? "", p = H(s) ?? "";
|
|
519
|
+
return d < p ? -1 : d > p ? 1 : 0;
|
|
520
|
+
}
|
|
521
|
+
return typeof r == "number" && typeof s == "number" ? r - s : r instanceof Date && s instanceof Date ? r.getTime() - s.getTime() : typeof r == "boolean" && typeof s == "boolean" ? Number(r) - Number(s) : String(r).localeCompare(String(s), void 0, { numeric: !0, sensitivity: "base" });
|
|
237
522
|
}
|
|
238
|
-
|
|
239
|
-
|
|
523
|
+
const Yn = (r) => r ? Array.isArray(r) ? r : [r] : [], vr = (r) => r.type === "date" && r.validity.badInput;
|
|
524
|
+
function ei({
|
|
525
|
+
columns: r,
|
|
240
526
|
rows: s,
|
|
241
|
-
getRowId:
|
|
242
|
-
editable:
|
|
243
|
-
enterMovesDown:
|
|
244
|
-
onCellEdit:
|
|
527
|
+
getRowId: a,
|
|
528
|
+
editable: d = !1,
|
|
529
|
+
enterMovesDown: p = !0,
|
|
530
|
+
onCellEdit: c,
|
|
245
531
|
onRowsChange: m,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
532
|
+
rowSelection: _ = !1,
|
|
533
|
+
selectedRowIds: N,
|
|
534
|
+
defaultSelectedRowIds: O,
|
|
535
|
+
onSelectionChange: P,
|
|
536
|
+
isRowSelectable: b,
|
|
537
|
+
sort: D,
|
|
538
|
+
defaultSort: S = null,
|
|
539
|
+
onSortChange: T,
|
|
540
|
+
multiSort: M = !1,
|
|
541
|
+
searchable: B = !1,
|
|
542
|
+
searchPlaceholder: ie = "Search…",
|
|
543
|
+
search: Le,
|
|
544
|
+
onSearchChange: st,
|
|
545
|
+
filters: z,
|
|
546
|
+
onFiltersChange: oe,
|
|
547
|
+
pagination: Y = !1,
|
|
548
|
+
paginationPosition: Me = "bottom",
|
|
549
|
+
pageSize: Cr = 10,
|
|
550
|
+
pageSizeOptions: at = [5, 10, 25, 50],
|
|
551
|
+
page: Dr,
|
|
552
|
+
onPageChange: Ir,
|
|
553
|
+
onPageSizeChange: dt,
|
|
554
|
+
serverSide: V = !1,
|
|
555
|
+
rowCount: Tr,
|
|
556
|
+
onQueryChange: Pt,
|
|
557
|
+
queryDebounce: At = 250,
|
|
558
|
+
loading: Lr,
|
|
559
|
+
loadingRows: Mr,
|
|
560
|
+
skeletonRow: Kt,
|
|
561
|
+
errorMessage: Fr = "Could not load the data.",
|
|
562
|
+
columnMenu: Bt = !1,
|
|
563
|
+
onColumnVisibilityChange: ct,
|
|
564
|
+
keyboardNavigation: ft = !1,
|
|
565
|
+
virtualize: q = !1,
|
|
566
|
+
rowHeight: X = 40,
|
|
567
|
+
overscan: Rt = 6,
|
|
568
|
+
exportable: Fe = !1,
|
|
569
|
+
apiRef: be,
|
|
570
|
+
onRowClick: ut,
|
|
571
|
+
toolbar: Wt,
|
|
572
|
+
emptyMessage: $r = "No rows to show",
|
|
573
|
+
striped: Or = !1,
|
|
574
|
+
stripeColors: $e,
|
|
575
|
+
checkboxVariant: ht = "native",
|
|
576
|
+
animateRows: jt = !0,
|
|
577
|
+
theme: pt,
|
|
578
|
+
maxHeight: Oe,
|
|
579
|
+
className: Pr,
|
|
580
|
+
style: Ar,
|
|
581
|
+
classNames: I = {},
|
|
582
|
+
styles: v = {},
|
|
583
|
+
rowClassName: gt,
|
|
584
|
+
rowStyle: mt
|
|
270
585
|
}) {
|
|
271
|
-
const
|
|
272
|
-
className:
|
|
273
|
-
style:
|
|
274
|
-
}), [Pe,
|
|
275
|
-
|
|
276
|
-
|
|
586
|
+
const L = (e, t) => ({
|
|
587
|
+
className: C(t, I[e]),
|
|
588
|
+
style: v[e]
|
|
589
|
+
}), [Pe, Vt] = $(s), le = F(s);
|
|
590
|
+
j(() => {
|
|
591
|
+
le.current = s, Vt(s);
|
|
277
592
|
}, [s]);
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
}, [
|
|
281
|
-
(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
593
|
+
const Ut = (e) => {
|
|
594
|
+
le.current = e, Vt(e);
|
|
595
|
+
}, [ke, Kr] = Ce(Le, "", st), [se, Br] = Ce(z, {}, oe), [R, Rr] = Ce(D, Yn(S), T), [bt, ae] = Ce(Dr, 0, Ir), [A, Wr] = $(Cr), jr = (e) => {
|
|
596
|
+
Wr(e), dt == null || dt(e);
|
|
597
|
+
}, [Ae, Vr] = $(() => new Set(r.filter((e) => e.hidden).map((e) => e.field))), Ur = (e, t) => {
|
|
598
|
+
const n = new Set(Ae);
|
|
599
|
+
t ? n.add(e) : n.delete(e), Vr(n), ct == null || ct([...n]);
|
|
600
|
+
}, [kt, zt] = $({}), [Ke, zr] = $({}), [Xn, qr] = $(0), _e = F(/* @__PURE__ */ new Map()), [ye, de] = $(null), ce = F(0), Be = F(null), Re = F(/* @__PURE__ */ new Map()), [_t, qt] = $(null), yt = F(null), xe = F(null), [xt, Ht] = $({ top: 0, height: 0 }), y = Z(() => {
|
|
601
|
+
const e = r.filter((t) => !Ae.has(t.field));
|
|
602
|
+
return [
|
|
603
|
+
...e.filter((t) => t.pinned === "left"),
|
|
604
|
+
...e.filter((t) => t.pinned !== "left" && t.pinned !== "right"),
|
|
605
|
+
...e.filter((t) => t.pinned === "right")
|
|
606
|
+
];
|
|
607
|
+
}, [r, Ae]), vt = (e) => e.sortable === !0, W = _ === "single" ? "single" : _ ? "multiple" : null, ve = y.length + (W ? 1 : 0), fe = Z(
|
|
608
|
+
() => Pe.map((e, t) => ({ row: e, index: t, id: a ? a(e, t) : t })),
|
|
609
|
+
[Pe, a]
|
|
610
|
+
), Jt = F(/* @__PURE__ */ new Map());
|
|
611
|
+
fe.forEach((e) => Jt.current.set(e.id, e.row));
|
|
612
|
+
const We = Z(
|
|
613
|
+
() => Object.entries(se).filter(([e, t]) => {
|
|
614
|
+
const n = y.find((l) => l.field === e);
|
|
615
|
+
return !!n && !!n.filterable && wr(t);
|
|
616
|
+
}),
|
|
617
|
+
[se, y]
|
|
618
|
+
), [Hr, Jr] = $(ke);
|
|
619
|
+
j(() => {
|
|
620
|
+
if (!V) return;
|
|
621
|
+
const e = setTimeout(() => Jr(ke), At);
|
|
622
|
+
return () => clearTimeout(e);
|
|
623
|
+
}, [ke, V, At]);
|
|
624
|
+
const ue = V ? Hr : ke, Yt = (e) => e.filterRenderer ? "text" : _r(e), G = Z(() => {
|
|
625
|
+
if (V) return fe;
|
|
626
|
+
const e = ue.trim().toLowerCase();
|
|
627
|
+
let t = fe.filter(({ row: l }) => e && !y.some((i) => De(i, l).toLowerCase().includes(e)) ? !1 : We.every(([i, o]) => {
|
|
628
|
+
const g = y.find((h) => h.field === i);
|
|
629
|
+
return Pn(Yt(g), o, De(g, l), U(l, i));
|
|
290
630
|
}));
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
631
|
+
const n = R.map((l) => ({ col: y.find((i) => i.field === l.field), dir: l.direction === "asc" ? 1 : -1 })).filter((l) => !!l.col);
|
|
632
|
+
return n.length && (t = [...t].sort((l, i) => {
|
|
633
|
+
for (const { col: o, dir: g } of n) {
|
|
634
|
+
const h = U(l.row, o.field), u = U(i.row, o.field), k = h == null || h === "", E = u == null || u === "";
|
|
635
|
+
if (k || E) {
|
|
636
|
+
if (k !== E) return k ? 1 : -1;
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
const nt = o.comparator ? o.comparator(h, u, l.row, i.row) : Jn(h, u, o);
|
|
640
|
+
if (nt !== 0) return nt * g;
|
|
299
641
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}, [
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
642
|
+
return 0;
|
|
643
|
+
})), t;
|
|
644
|
+
}, [fe, y, ue, We, R, V]), je = JSON.stringify([ue, se, R, A]), Xt = F(je);
|
|
645
|
+
j(() => {
|
|
646
|
+
Xt.current !== je && (Xt.current = je, ae(0));
|
|
647
|
+
}, [je]);
|
|
648
|
+
const he = V ? Tr ?? fe.length : G.length, Q = Y ? Math.max(1, Math.ceil(he / A)) : 1, K = Math.min(bt, Q - 1), w = Y && !V ? G.slice(K * A, K * A + A) : G, Yr = he === 0 ? 0 : Y ? K * A + 1 : 1, Xr = Y ? Math.min(he, (K + 1) * A) : he, wt = Z(
|
|
649
|
+
() => ({
|
|
650
|
+
sort: R.filter((e) => {
|
|
651
|
+
const t = r.find((n) => n.field === e.field);
|
|
652
|
+
return !!t && vt(t);
|
|
653
|
+
}),
|
|
654
|
+
filters: Object.fromEntries(We),
|
|
655
|
+
search: ue.trim(),
|
|
656
|
+
page: K,
|
|
657
|
+
pageSize: A
|
|
658
|
+
}),
|
|
659
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
660
|
+
[R, r, We, ue, K, A]
|
|
661
|
+
), Gr = JSON.stringify(wt), Ve = F(wt);
|
|
662
|
+
Ve.current = wt;
|
|
663
|
+
const Ue = F(Pt);
|
|
664
|
+
Ue.current = Pt;
|
|
665
|
+
const [Qr, ze] = $(!1), [Zr, Nt] = $(!1), Et = F(0), qe = Te((e) => {
|
|
666
|
+
var l;
|
|
667
|
+
const t = ++Et.current, n = (l = Ue.current) == null ? void 0 : l.call(Ue, e);
|
|
668
|
+
n && typeof n.then == "function" ? (ze(!0), Nt(!1), n.then(
|
|
669
|
+
() => {
|
|
670
|
+
t === Et.current && ze(!1);
|
|
671
|
+
},
|
|
672
|
+
() => {
|
|
673
|
+
t === Et.current && (ze(!1), Nt(!0));
|
|
674
|
+
}
|
|
675
|
+
)) : (ze(!1), Nt(!1));
|
|
676
|
+
}, []);
|
|
677
|
+
j(() => {
|
|
678
|
+
V && qe(Ve.current);
|
|
679
|
+
}, [V, Gr, qe]), j(() => {
|
|
680
|
+
V && Y && bt > Q - 1 && ae(Q - 1);
|
|
681
|
+
}, [V, Y, bt, Q]);
|
|
682
|
+
const St = Lr ?? Qr, Gt = (e) => e.map((t) => Jt.current.get(t)).filter((t) => t !== void 0), [J, He] = Ce(
|
|
683
|
+
N,
|
|
684
|
+
O ?? [],
|
|
685
|
+
(e) => P == null ? void 0 : P({ ids: e, rows: Gt(e) })
|
|
686
|
+
), Ct = Z(() => new Set(J), [J]), Je = (e) => b ? b(e) : !0, Ye = F(null), Qt = F(!1), en = (e, t) => {
|
|
687
|
+
if (!W || !Je(e.row)) return;
|
|
688
|
+
if (W === "single") {
|
|
689
|
+
He(t ? [e.id] : []), Ye.current = e.id;
|
|
308
690
|
return;
|
|
309
691
|
}
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
692
|
+
const n = new Set(J), l = Qt.current && Ye.current !== null ? w.findIndex((o) => o.id === Ye.current) : -1, i = w.findIndex((o) => o.id === e.id);
|
|
693
|
+
if (l >= 0 && i >= 0)
|
|
694
|
+
for (let o = Math.min(l, i); o <= Math.max(l, i); o++)
|
|
695
|
+
Je(w[o].row) && (t ? n.add(w[o].id) : n.delete(w[o].id));
|
|
696
|
+
else t ? n.add(e.id) : n.delete(e.id);
|
|
697
|
+
Ye.current = e.id, He([...n]);
|
|
698
|
+
}, we = Z(() => G.filter((e) => Je(e.row)), [G, b]), Zt = we.filter((e) => Ct.has(e.id)).length, er = we.length > 0 && Zt === we.length, tr = (e) => {
|
|
699
|
+
const t = new Set(J);
|
|
700
|
+
we.forEach((n) => e ? t.add(n.id) : t.delete(n.id)), He([...t]);
|
|
701
|
+
}, Xe = (e, t, n) => ({
|
|
702
|
+
value: U(t, e.field),
|
|
703
|
+
formattedValue: De(e, t),
|
|
316
704
|
row: t,
|
|
317
|
-
rowIndex:
|
|
705
|
+
rowIndex: n,
|
|
318
706
|
field: e.field,
|
|
319
707
|
column: e
|
|
320
|
-
}),
|
|
321
|
-
const
|
|
322
|
-
return typeof
|
|
323
|
-
},
|
|
324
|
-
const
|
|
708
|
+
}), Dt = (e, t) => {
|
|
709
|
+
const n = e.editable ?? d;
|
|
710
|
+
return typeof n == "function" ? n(t) : !!n;
|
|
711
|
+
}, Ge = (e, t) => Dt(e, t) && !(e.type === "boolean" && !e.cellEditor), tn = (e, t) => {
|
|
712
|
+
const n = Xe(e, t.row, t.index), l = Dt(e, n);
|
|
325
713
|
return {
|
|
326
|
-
...
|
|
327
|
-
editable:
|
|
328
|
-
updateValue: (i) =>
|
|
714
|
+
...n,
|
|
715
|
+
editable: l,
|
|
716
|
+
updateValue: (i) => l && nr(t, e, { value: i })
|
|
329
717
|
};
|
|
330
|
-
},
|
|
331
|
-
if (!
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
718
|
+
}, rr = (e, t) => {
|
|
719
|
+
if (!vt(e)) return;
|
|
720
|
+
const n = R.find((o) => o.field === e.field), l = n ? n.direction === "asc" ? "desc" : null : "asc";
|
|
721
|
+
let i;
|
|
722
|
+
t && M ? l ? n ? i = R.map((o) => o.field === e.field ? { ...o, direction: l } : o) : i = [...R, { field: e.field, direction: l }] : i = R.filter((o) => o.field !== e.field) : i = l ? [{ field: e.field, direction: l }] : [], Rr(i);
|
|
723
|
+
}, Qe = (e, t) => {
|
|
724
|
+
var n;
|
|
725
|
+
return (n = Re.current.get(Mt(e, t))) == null ? void 0 : n.focus();
|
|
726
|
+
}, te = () => {
|
|
727
|
+
ce.current += 1, de(null);
|
|
728
|
+
}, rn = (e) => {
|
|
729
|
+
for (const t of le.current) {
|
|
730
|
+
const n = U(t, e.field);
|
|
731
|
+
if (n != null && n !== "") return n;
|
|
732
|
+
}
|
|
733
|
+
}, Ze = (e, t, n = {}) => {
|
|
734
|
+
if (!Ge(t, Xe(t, e.row, e.index))) return !1;
|
|
735
|
+
const l = U(e.row, t.field);
|
|
736
|
+
let i;
|
|
737
|
+
return t.cellEditor ? i = l : t.type === "date" ? i = H(l) ?? "" : i = n.text ?? (l == null ? "" : String(l)), Be.current = i, ce.current += 1, de({
|
|
343
738
|
id: e.id,
|
|
344
739
|
field: t.field,
|
|
345
740
|
draft: i,
|
|
346
|
-
session:
|
|
347
|
-
select:
|
|
741
|
+
session: ce.current,
|
|
742
|
+
select: n.select ?? "end",
|
|
348
743
|
invalid: !1
|
|
349
744
|
}), !0;
|
|
350
|
-
},
|
|
351
|
-
const
|
|
352
|
-
let
|
|
353
|
-
if ("value" in
|
|
354
|
-
|
|
745
|
+
}, nr = (e, t, n) => {
|
|
746
|
+
const l = le.current[e.index] ?? e.row, i = U(l, t.field);
|
|
747
|
+
let o;
|
|
748
|
+
if ("value" in n)
|
|
749
|
+
o = n.value;
|
|
355
750
|
else if (t.valueParser)
|
|
356
|
-
|
|
357
|
-
else if (t.type === "
|
|
358
|
-
if (
|
|
751
|
+
o = t.valueParser(n.text, l);
|
|
752
|
+
else if (t.type === "date") {
|
|
753
|
+
if (n.text !== "" && !Ie(n.text)) return !1;
|
|
754
|
+
o = $n(n.text, i ?? rn(t));
|
|
755
|
+
} else if (t.type === "number")
|
|
756
|
+
if (n.text.trim() === "") o = null;
|
|
359
757
|
else {
|
|
360
|
-
const u = Number(
|
|
758
|
+
const u = Number(n.text);
|
|
361
759
|
if (!Number.isFinite(u)) return !1;
|
|
362
|
-
|
|
760
|
+
o = u;
|
|
363
761
|
}
|
|
364
762
|
else
|
|
365
|
-
|
|
366
|
-
if (
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
763
|
+
o = n.text;
|
|
764
|
+
if (t.type === "date") {
|
|
765
|
+
if (H(o) === H(i)) return !0;
|
|
766
|
+
const u = H(o);
|
|
767
|
+
if (u && (t.dateMin && u < t.dateMin || t.dateMax && u > t.dateMax)) return !1;
|
|
768
|
+
} else if (Object.is(o, i))
|
|
769
|
+
return !0;
|
|
770
|
+
if (t.validate && !t.validate(o, l)) return !1;
|
|
771
|
+
const g = Ot(l, t.field, o), h = le.current.map((u, k) => k === e.index ? g : u);
|
|
772
|
+
return Ut(h), c == null || c({ rowId: e.id, rowIndex: e.index, field: t.field, oldValue: i, newValue: o, row: g }), m == null || m(h), !0;
|
|
773
|
+
}, ir = (e, t, n) => {
|
|
774
|
+
const l = w.findIndex((k) => k.id === e.id), i = y.findIndex((k) => k.field === t);
|
|
775
|
+
if (l < 0 || i < 0) return null;
|
|
776
|
+
const o = (k, E) => Ge(E, Xe(E, k.row, k.index));
|
|
777
|
+
if (n === "down" || n === "up") {
|
|
778
|
+
const k = n === "down" ? 1 : -1;
|
|
779
|
+
for (let E = l + k; E >= 0 && E < w.length; E += k)
|
|
780
|
+
if (o(w[E], y[i])) return { entry: w[E], col: y[i] };
|
|
378
781
|
return null;
|
|
379
782
|
}
|
|
380
|
-
const
|
|
381
|
-
let
|
|
382
|
-
for (;
|
|
383
|
-
for (; u >= 0 && u <
|
|
384
|
-
if (
|
|
385
|
-
u +=
|
|
783
|
+
const g = n === "right" ? 1 : -1;
|
|
784
|
+
let h = l, u = i + g;
|
|
785
|
+
for (; h >= 0 && h < w.length; ) {
|
|
786
|
+
for (; u >= 0 && u < y.length; ) {
|
|
787
|
+
if (o(w[h], y[u])) return { entry: w[h], col: y[u] };
|
|
788
|
+
u += g;
|
|
386
789
|
}
|
|
387
|
-
|
|
790
|
+
h += g, u = g > 0 ? 0 : y.length - 1;
|
|
388
791
|
}
|
|
389
792
|
return null;
|
|
390
|
-
},
|
|
391
|
-
const { move: i = "none", focus:
|
|
392
|
-
if (!
|
|
393
|
-
return
|
|
394
|
-
const
|
|
395
|
-
return
|
|
396
|
-
},
|
|
793
|
+
}, Ne = (e, t, n, l = {}) => {
|
|
794
|
+
const { move: i = "none", focus: o = !0 } = l;
|
|
795
|
+
if (!nr(e, t, n))
|
|
796
|
+
return de((h) => h && { ...h, invalid: !0 }), !1;
|
|
797
|
+
const g = i === "none" ? null : ir(e, t.field, i);
|
|
798
|
+
return g ? Ze(g.entry, g.col, { select: "all" }) : (te(), o && Qe(e.id, t.field)), !0;
|
|
799
|
+
}, nn = (e, t, n) => {
|
|
397
800
|
if (e.nativeEvent.isComposing) return;
|
|
398
|
-
const
|
|
801
|
+
const l = e.currentTarget.value, i = vr(e.currentTarget);
|
|
399
802
|
if (e.key === "Enter") {
|
|
400
|
-
e.preventDefault();
|
|
401
|
-
const
|
|
402
|
-
|
|
803
|
+
if (e.preventDefault(), i) return de((g) => g && { ...g, invalid: !0 });
|
|
804
|
+
const o = p ? e.shiftKey ? "up" : "down" : "none";
|
|
805
|
+
Ne(t, n, { text: l }, { move: o });
|
|
403
806
|
} else if (e.key === "Escape")
|
|
404
|
-
e.preventDefault(),
|
|
405
|
-
else if (e.key === "Tab") {
|
|
406
|
-
const
|
|
407
|
-
|
|
807
|
+
e.preventDefault(), te(), Qe(t.id, n.field);
|
|
808
|
+
else if (e.key === "Tab" && !i) {
|
|
809
|
+
const o = e.shiftKey ? "left" : "right";
|
|
810
|
+
ir(t, n.field, o) && (e.preventDefault(), Ne(t, n, { text: l }, { move: o }));
|
|
408
811
|
}
|
|
409
|
-
},
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
{
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
},
|
|
418
|
-
onKeyDown: (n) => {
|
|
419
|
-
n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), Y(), pe(e.id, t.field));
|
|
420
|
-
},
|
|
421
|
-
children: se(t.cellEditor, {
|
|
422
|
-
value: r.draft,
|
|
423
|
-
row: e.row,
|
|
424
|
-
rowIndex: e.index,
|
|
425
|
-
field: t.field,
|
|
426
|
-
column: t,
|
|
427
|
-
onChange: (n) => {
|
|
428
|
-
ce.current = n, re((i) => i && i.session === r.session ? { ...i, draft: n, invalid: !1 } : i);
|
|
429
|
-
},
|
|
430
|
-
onCommit: (n, i = "none") => {
|
|
431
|
-
r.session === J.current && ie(e, t, { value: n === void 0 ? ce.current : n }, { move: i });
|
|
432
|
-
},
|
|
433
|
-
onCancel: () => {
|
|
434
|
-
Y(), pe(e.id, t.field);
|
|
435
|
-
}
|
|
436
|
-
})
|
|
812
|
+
}, on = (e, t) => {
|
|
813
|
+
var o;
|
|
814
|
+
const n = w[e], l = y[t];
|
|
815
|
+
if (!n || !l) return;
|
|
816
|
+
qt({ id: n.id, field: l.field }), yt.current = Mt(n.id, l.field);
|
|
817
|
+
const i = xe.current;
|
|
818
|
+
if (q && i) {
|
|
819
|
+
const g = ((o = i.querySelector("thead")) == null ? void 0 : o.clientHeight) ?? 0, h = e * X;
|
|
820
|
+
h < i.scrollTop ? i.scrollTo({ top: h, behavior: "auto" }) : h + X > i.scrollTop + i.clientHeight - g && i.scrollTo({ top: h + X - i.clientHeight + g, behavior: "auto" });
|
|
437
821
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
822
|
+
};
|
|
823
|
+
j(() => {
|
|
824
|
+
const e = yt.current;
|
|
825
|
+
if (!e) return;
|
|
826
|
+
const t = Re.current.get(e);
|
|
827
|
+
t && (yt.current = null, t.focus());
|
|
828
|
+
});
|
|
829
|
+
const ln = (e, t, n) => {
|
|
830
|
+
if (!ft) return !1;
|
|
831
|
+
let l = w.findIndex((o) => o.id === t.id), i = y.findIndex((o) => o.field === n.field);
|
|
832
|
+
if (l < 0 || i < 0) return !1;
|
|
833
|
+
switch (e.key) {
|
|
834
|
+
case "ArrowDown":
|
|
835
|
+
l += 1;
|
|
836
|
+
break;
|
|
837
|
+
case "ArrowUp":
|
|
838
|
+
l -= 1;
|
|
839
|
+
break;
|
|
840
|
+
case "ArrowRight":
|
|
841
|
+
i += 1;
|
|
842
|
+
break;
|
|
843
|
+
case "ArrowLeft":
|
|
844
|
+
i -= 1;
|
|
845
|
+
break;
|
|
846
|
+
case "PageDown":
|
|
847
|
+
l += xr;
|
|
848
|
+
break;
|
|
849
|
+
case "PageUp":
|
|
850
|
+
l -= xr;
|
|
851
|
+
break;
|
|
852
|
+
case "Home":
|
|
853
|
+
i = 0, (e.ctrlKey || e.metaKey) && (l = 0);
|
|
854
|
+
break;
|
|
855
|
+
case "End":
|
|
856
|
+
i = y.length - 1, (e.ctrlKey || e.metaKey) && (l = w.length - 1);
|
|
857
|
+
break;
|
|
858
|
+
default:
|
|
859
|
+
return !1;
|
|
860
|
+
}
|
|
861
|
+
return e.preventDefault(), on(Math.max(0, Math.min(w.length - 1, l)), Math.max(0, Math.min(y.length - 1, i))), !0;
|
|
862
|
+
}, sn = (e, t, n, l) => {
|
|
863
|
+
e.target === e.currentTarget && (ln(e, t, n) || Ge(n, l) && (e.key === "Enter" || e.key === "F2" ? (e.preventDefault(), Ze(t, n)) : !n.cellEditor && n.type !== "date" && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), Ze(t, n, { text: e.key }))));
|
|
864
|
+
};
|
|
865
|
+
Ft(() => {
|
|
866
|
+
if (!q || !xe.current) return;
|
|
867
|
+
const e = xe.current, t = () => Ht((l) => l.height === e.clientHeight ? l : { ...l, height: e.clientHeight });
|
|
868
|
+
if (t(), typeof ResizeObserver > "u") return;
|
|
869
|
+
const n = new ResizeObserver(t);
|
|
870
|
+
return n.observe(e), () => n.disconnect();
|
|
871
|
+
}, [q]);
|
|
872
|
+
const Ee = q && !St && w.length > 0, an = xt.height || (typeof Oe == "number" ? Oe : 400), et = Ee ? Math.max(0, Math.floor(xt.top / X) - Rt) : 0, It = Ee ? Math.min(w.length, Math.ceil((xt.top + an) / X) + Rt) : w.length, dn = Ee ? w.slice(et, It) : w, or = `${K}|${A}|${JSON.stringify(R)}|${ue}|${JSON.stringify(se)}`, lr = F(!0);
|
|
873
|
+
j(() => {
|
|
874
|
+
if (lr.current) {
|
|
875
|
+
lr.current = !1;
|
|
876
|
+
return;
|
|
460
877
|
}
|
|
461
|
-
|
|
462
|
-
|
|
878
|
+
const e = xe.current;
|
|
879
|
+
e && typeof e.scrollTo == "function" && e.scrollTop > 0 && e.scrollTo({ top: 0, behavior: "smooth" });
|
|
880
|
+
}, [or]);
|
|
881
|
+
const Tt = Object.keys(kt).length > 0, tt = (e) => kt[e.field] ?? (typeof e.width == "number" ? e.width : Hn), cn = (e) => Math.max(40, typeof e.minWidth == "number" ? e.minWidth : 60), fn = (e, t) => {
|
|
882
|
+
e.preventDefault(), e.stopPropagation();
|
|
883
|
+
const n = { ...kt };
|
|
884
|
+
Tt || y.forEach((k) => {
|
|
885
|
+
var E;
|
|
886
|
+
return n[k.field] = ((E = _e.current.get(k.field)) == null ? void 0 : E.offsetWidth) ?? tt(k);
|
|
887
|
+
});
|
|
888
|
+
const l = e.clientX, i = n[t.field] ?? tt(t), o = e.currentTarget;
|
|
889
|
+
o.setPointerCapture(e.pointerId), zt(n);
|
|
890
|
+
const g = (k) => Math.min(t.maxWidth ?? 1 / 0, Math.max(cn(t), Math.round(k))), h = (k) => zt((E) => ({ ...E, [t.field]: g(i + k.clientX - l) })), u = () => {
|
|
891
|
+
o.removeEventListener("pointermove", h), o.removeEventListener("pointerup", u), o.removeEventListener("pointercancel", u);
|
|
892
|
+
};
|
|
893
|
+
o.addEventListener("pointermove", h), o.addEventListener("pointerup", u), o.addEventListener("pointercancel", u);
|
|
894
|
+
};
|
|
895
|
+
Ft(() => {
|
|
896
|
+
var i, o;
|
|
897
|
+
const e = {};
|
|
898
|
+
let t = W && y.some((g) => g.pinned === "left") ? ee : 0;
|
|
899
|
+
for (const g of y)
|
|
900
|
+
g.pinned === "left" && (e[g.field] = t, t += ((i = _e.current.get(g.field)) == null ? void 0 : i.offsetWidth) ?? 0);
|
|
901
|
+
let n = 0;
|
|
902
|
+
for (const g of [...y].reverse())
|
|
903
|
+
g.pinned === "right" && (e[g.field] = n, n += ((o = _e.current.get(g.field)) == null ? void 0 : o.offsetWidth) ?? 0);
|
|
904
|
+
const l = Object.keys(e);
|
|
905
|
+
(l.length !== Object.keys(Ke).length || l.some((g) => e[g] !== Ke[g])) && zr(e);
|
|
906
|
+
}), j(() => {
|
|
907
|
+
const e = () => qr((t) => t + 1);
|
|
908
|
+
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
909
|
+
}, []);
|
|
910
|
+
const sr = y.map((e) => e.pinned).lastIndexOf("left"), un = y.findIndex((e) => e.pinned === "right"), rt = sr >= 0, ar = (e, t) => ({
|
|
911
|
+
className: e.pinned ? C("rk-grid__pinned", `rk-grid__pinned--${e.pinned}`, t === sr && "rk-grid__pinned--edge", t === un && "rk-grid__pinned--edge") : void 0,
|
|
912
|
+
style: e.pinned === "left" ? { left: Ke[e.field] ?? 0 } : e.pinned === "right" ? { right: Ke[e.field] ?? 0 } : void 0
|
|
913
|
+
}), dr = typeof Fe == "object" ? Fe : {}, cr = (e = {}) => {
|
|
914
|
+
const t = { ...dr, ...e }, n = t.scope ?? "filtered", l = n === "page" ? w : n === "selected" ? fe.filter((h) => Ct.has(h.id)) : G, i = t.includeHidden ? r : y, o = i.map((h) => ot(h) || h.field), g = l.map(
|
|
915
|
+
({ row: h }) => i.map((u) => {
|
|
916
|
+
const k = U(h, u.field);
|
|
917
|
+
return u.exportValue ? u.exportValue(k, h) : u.type === "date" ? H(k) ?? "" : De(u, h);
|
|
918
|
+
})
|
|
919
|
+
);
|
|
920
|
+
return zn(o, g, { sanitize: t.sanitize });
|
|
921
|
+
}, fr = (e = {}) => {
|
|
922
|
+
const t = { ...dr, ...e };
|
|
923
|
+
qn(cr(e), `${t.filename ?? "export"}.csv`);
|
|
924
|
+
};
|
|
925
|
+
j(() => {
|
|
926
|
+
be && (be.current = {
|
|
927
|
+
getCsv: cr,
|
|
928
|
+
exportCsv: fr,
|
|
929
|
+
getSelectedRows: () => Gt(J),
|
|
930
|
+
getSelectedRowIds: () => J,
|
|
931
|
+
selectAll: () => tr(!0),
|
|
932
|
+
clearSelection: () => He([]),
|
|
933
|
+
refresh: () => {
|
|
934
|
+
V && qe(Ve.current);
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
}), j(
|
|
938
|
+
() => () => {
|
|
939
|
+
be && (be.current = null);
|
|
940
|
+
},
|
|
941
|
+
[be]
|
|
942
|
+
);
|
|
943
|
+
const ur = (e) => {
|
|
944
|
+
var n, l, i, o, g, h, u, k;
|
|
463
945
|
const t = e.checkbox ?? {};
|
|
464
946
|
return {
|
|
465
|
-
variant: t.variant ??
|
|
947
|
+
variant: t.variant ?? ht,
|
|
466
948
|
indicator: t.indicator,
|
|
467
949
|
className: t.className,
|
|
468
950
|
style: t.style,
|
|
469
951
|
classNames: {
|
|
470
|
-
root:
|
|
471
|
-
control:
|
|
472
|
-
indicator:
|
|
473
|
-
label: (
|
|
952
|
+
root: C(I.checkbox, (n = t.classNames) == null ? void 0 : n.root),
|
|
953
|
+
control: C(I.checkboxControl, (l = t.classNames) == null ? void 0 : l.control),
|
|
954
|
+
indicator: C(I.checkboxIndicator, (i = t.classNames) == null ? void 0 : i.indicator),
|
|
955
|
+
label: (o = t.classNames) == null ? void 0 : o.label
|
|
474
956
|
},
|
|
475
957
|
styles: {
|
|
476
|
-
root: { ...
|
|
477
|
-
control: { ...
|
|
478
|
-
indicator: { ...
|
|
479
|
-
label: (
|
|
958
|
+
root: { ...v.checkbox, ...(g = t.styles) == null ? void 0 : g.root },
|
|
959
|
+
control: { ...v.checkboxControl, ...(h = t.styles) == null ? void 0 : h.control },
|
|
960
|
+
indicator: { ...v.checkboxIndicator, ...(u = t.styles) == null ? void 0 : u.indicator },
|
|
961
|
+
label: (k = t.styles) == null ? void 0 : k.label
|
|
480
962
|
}
|
|
481
963
|
};
|
|
482
|
-
},
|
|
483
|
-
|
|
964
|
+
}, re = (e) => e.stopPropagation(), hn = (e, t) => /* @__PURE__ */ f("span", { className: "rk-grid__checkbox-cell", onClick: re, onDoubleClick: re, children: /* @__PURE__ */ f(
|
|
965
|
+
me,
|
|
484
966
|
{
|
|
485
|
-
...
|
|
967
|
+
...ur(e),
|
|
486
968
|
checked: !!t.value,
|
|
487
969
|
disabled: !t.editable,
|
|
488
|
-
"aria-label": `Toggle ${
|
|
489
|
-
onChange: (
|
|
970
|
+
"aria-label": `Toggle ${pe(e)}`,
|
|
971
|
+
onChange: (n) => t.updateValue(n)
|
|
490
972
|
}
|
|
491
|
-
) }),
|
|
492
|
-
const
|
|
493
|
-
const
|
|
494
|
-
if (!
|
|
495
|
-
const u =
|
|
496
|
-
if (!!u === t || e.validate && !e.validate(t,
|
|
497
|
-
const
|
|
498
|
-
return
|
|
973
|
+
) }), hr = (e) => G.filter((t) => Dt(e, Xe(e, t.row, t.index))), pn = (e, t) => {
|
|
974
|
+
const n = new Map(hr(e).map((o) => [o.index, o])), l = [], i = le.current.map((o, g) => {
|
|
975
|
+
const h = n.get(g);
|
|
976
|
+
if (!h) return o;
|
|
977
|
+
const u = U(o, e.field);
|
|
978
|
+
if (!!u === t || e.validate && !e.validate(t, o)) return o;
|
|
979
|
+
const k = Ot(o, e.field, t);
|
|
980
|
+
return l.push({ rowId: h.id, rowIndex: g, field: e.field, oldValue: u, newValue: t, row: k }), k;
|
|
499
981
|
});
|
|
500
|
-
|
|
501
|
-
},
|
|
502
|
-
const t =
|
|
503
|
-
return /* @__PURE__ */
|
|
504
|
-
|
|
982
|
+
l.length !== 0 && (Ut(i), l.forEach((o) => c == null ? void 0 : c(o)), m == null || m(i));
|
|
983
|
+
}, gn = (e) => {
|
|
984
|
+
const t = hr(e), n = t.length > 0 ? t : G, l = n.filter((o) => !!U(o.row, e.field)).length, i = n.length > 0 && l === n.length;
|
|
985
|
+
return /* @__PURE__ */ f("span", { className: "rk-grid__header-checkbox", onClick: re, onDoubleClick: re, children: /* @__PURE__ */ f(
|
|
986
|
+
me,
|
|
505
987
|
{
|
|
506
|
-
...
|
|
988
|
+
...ur(e),
|
|
507
989
|
checked: i,
|
|
508
|
-
indeterminate:
|
|
990
|
+
indeterminate: l > 0 && !i,
|
|
509
991
|
disabled: t.length === 0,
|
|
510
|
-
label:
|
|
511
|
-
"aria-label": `Select all ${
|
|
512
|
-
onChange: (
|
|
992
|
+
label: ot(e) || void 0,
|
|
993
|
+
"aria-label": `Select all ${pe(e)}`,
|
|
994
|
+
onChange: (o) => pn(e, o)
|
|
513
995
|
}
|
|
514
996
|
) });
|
|
515
|
-
},
|
|
997
|
+
}, mn = (e, t, n) => {
|
|
998
|
+
if (t.cellEditor)
|
|
999
|
+
return /* @__PURE__ */ f(
|
|
1000
|
+
"div",
|
|
1001
|
+
{
|
|
1002
|
+
className: "rk-grid__custom-editor",
|
|
1003
|
+
onBlur: (i) => {
|
|
1004
|
+
i.currentTarget.contains(i.relatedTarget) || n.session === ce.current && (Ne(e, t, { value: Be.current }, { focus: !1 }) || te());
|
|
1005
|
+
},
|
|
1006
|
+
onKeyDown: (i) => {
|
|
1007
|
+
i.key === "Escape" && (i.preventDefault(), i.stopPropagation(), te(), Qe(e.id, t.field));
|
|
1008
|
+
},
|
|
1009
|
+
children: ge(t.cellEditor, {
|
|
1010
|
+
value: n.draft,
|
|
1011
|
+
row: e.row,
|
|
1012
|
+
rowIndex: e.index,
|
|
1013
|
+
field: t.field,
|
|
1014
|
+
column: t,
|
|
1015
|
+
onChange: (i) => {
|
|
1016
|
+
Be.current = i, de((o) => o && o.session === n.session ? { ...o, draft: i, invalid: !1 } : o);
|
|
1017
|
+
},
|
|
1018
|
+
onCommit: (i, o = "none") => {
|
|
1019
|
+
n.session === ce.current && Ne(e, t, { value: i === void 0 ? Be.current : i }, { move: o });
|
|
1020
|
+
},
|
|
1021
|
+
onCancel: () => {
|
|
1022
|
+
te(), Qe(e.id, t.field);
|
|
1023
|
+
}
|
|
1024
|
+
})
|
|
1025
|
+
}
|
|
1026
|
+
);
|
|
1027
|
+
const l = t.type === "date";
|
|
1028
|
+
return /* @__PURE__ */ f(
|
|
1029
|
+
"input",
|
|
1030
|
+
{
|
|
1031
|
+
autoFocus: !0,
|
|
1032
|
+
type: l ? "date" : "text",
|
|
1033
|
+
min: l ? t.dateMin : void 0,
|
|
1034
|
+
max: l ? t.dateMax : void 0,
|
|
1035
|
+
className: C("rk-grid__editor", n.invalid && "rk-grid__editor--invalid", I.editor),
|
|
1036
|
+
style: { textAlign: t.align, ...v.editor },
|
|
1037
|
+
value: n.draft === null || n.draft === void 0 ? "" : String(n.draft),
|
|
1038
|
+
inputMode: t.type === "number" ? "decimal" : void 0,
|
|
1039
|
+
"aria-label": `Edit ${pe(t)}`,
|
|
1040
|
+
"aria-invalid": n.invalid || void 0,
|
|
1041
|
+
onChange: (i) => {
|
|
1042
|
+
const o = i.target.value;
|
|
1043
|
+
de((g) => g && { ...g, draft: o, invalid: !1 });
|
|
1044
|
+
},
|
|
1045
|
+
onFocus: (i) => {
|
|
1046
|
+
const o = i.currentTarget;
|
|
1047
|
+
l || (n.select === "all" ? o.select() : o.setSelectionRange(o.value.length, o.value.length));
|
|
1048
|
+
},
|
|
1049
|
+
onBlur: (i) => {
|
|
1050
|
+
if (n.session === ce.current) {
|
|
1051
|
+
if (vr(i.currentTarget)) return te();
|
|
1052
|
+
Ne(e, t, { text: i.currentTarget.value }, { focus: !1 }) || te();
|
|
1053
|
+
}
|
|
1054
|
+
},
|
|
1055
|
+
onKeyDown: (i) => nn(i, e, t)
|
|
1056
|
+
}
|
|
1057
|
+
);
|
|
1058
|
+
}, bn = Z(() => {
|
|
1059
|
+
const e = /* @__PURE__ */ new Map();
|
|
1060
|
+
for (const t of y)
|
|
1061
|
+
t.filterable && !t.filterRenderer && _r(t) === "select" && e.set(t.field, An(t, Pe, (n) => U(n, t.field), (n) => De(t, n)));
|
|
1062
|
+
return e;
|
|
1063
|
+
}, [y, Pe]), kn = Or || !!$e, _n = $e ? { "--rk-stripe-a": $e[0], "--rk-stripe-b": $e[1] } : void 0, yn = Y && (Me === "top" || Me === "both"), xn = Y && (Me === "bottom" || Me === "both"), vn = B || !!Wt || Bt || !!Fe, pr = (e) => /* @__PURE__ */ x(
|
|
516
1064
|
"div",
|
|
517
1065
|
{
|
|
518
|
-
className:
|
|
519
|
-
style:
|
|
1066
|
+
className: C("rk-grid__footer", e === "top" && "rk-grid__footer--top", I.footer),
|
|
1067
|
+
style: v.footer,
|
|
520
1068
|
"data-position": e,
|
|
521
1069
|
children: [
|
|
522
|
-
/* @__PURE__ */
|
|
523
|
-
|
|
524
|
-
|
|
1070
|
+
/* @__PURE__ */ x("span", { ...L("rowCount", "rk-grid__count"), children: [
|
|
1071
|
+
he === 0 ? "0 rows" : `${Yr}–${Xr} of ${he}`,
|
|
1072
|
+
W && J.length > 0 ? ` · ${J.length} selected` : ""
|
|
1073
|
+
] }),
|
|
1074
|
+
/* @__PURE__ */ x("div", { ...L("pagination", "rk-grid__pagination"), children: [
|
|
1075
|
+
/* @__PURE__ */ x("label", { className: "rk-grid__page-size-label", children: [
|
|
525
1076
|
"Rows per page",
|
|
526
|
-
/* @__PURE__ */
|
|
527
|
-
"select",
|
|
528
|
-
{
|
|
529
|
-
value: P,
|
|
530
|
-
onChange: (t) => tt(Number(t.target.value)),
|
|
531
|
-
..._("pageSize", "rk-grid__page-size"),
|
|
532
|
-
children: (y.includes(P) ? y : [...y, P].sort((t, r) => t - r)).map(
|
|
533
|
-
(t) => /* @__PURE__ */ d("option", { value: t, children: t }, t)
|
|
534
|
-
)
|
|
535
|
-
}
|
|
536
|
-
)
|
|
1077
|
+
/* @__PURE__ */ f("select", { value: A, onChange: (t) => jr(Number(t.target.value)), ...L("pageSize", "rk-grid__page-size"), children: (at.includes(A) ? at : [...at, A].sort((t, n) => t - n)).map((t) => /* @__PURE__ */ f("option", { value: t, children: t }, t)) })
|
|
537
1078
|
] }),
|
|
538
|
-
/* @__PURE__ */
|
|
539
|
-
/* @__PURE__ */
|
|
540
|
-
/* @__PURE__ */
|
|
1079
|
+
/* @__PURE__ */ f("button", { type: "button", "aria-label": "First page", disabled: K === 0, onClick: () => ae(0), ...L("pageButton", "rk-grid__page-btn"), children: "«" }),
|
|
1080
|
+
/* @__PURE__ */ f("button", { type: "button", "aria-label": "Previous page", disabled: K === 0, onClick: () => ae(K - 1), ...L("pageButton", "rk-grid__page-btn"), children: "‹" }),
|
|
1081
|
+
/* @__PURE__ */ x("span", { ...L("pageInfo", "rk-grid__page-info"), children: [
|
|
541
1082
|
"Page ",
|
|
542
|
-
|
|
1083
|
+
K + 1,
|
|
543
1084
|
" of ",
|
|
544
|
-
|
|
1085
|
+
Q
|
|
545
1086
|
] }),
|
|
546
|
-
/* @__PURE__ */
|
|
547
|
-
/* @__PURE__ */
|
|
1087
|
+
/* @__PURE__ */ f("button", { type: "button", "aria-label": "Next page", disabled: K >= Q - 1, onClick: () => ae(K + 1), ...L("pageButton", "rk-grid__page-btn"), children: "›" }),
|
|
1088
|
+
/* @__PURE__ */ f("button", { type: "button", "aria-label": "Last page", disabled: K >= Q - 1, onClick: () => ae(Q - 1), ...L("pageButton", "rk-grid__page-btn"), children: "»" })
|
|
548
1089
|
] })
|
|
549
1090
|
]
|
|
550
1091
|
}
|
|
551
|
-
)
|
|
552
|
-
|
|
553
|
-
"
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
1092
|
+
), wn = (e) => /* @__PURE__ */ f("tr", { className: "rk-grid__tr rk-grid__skeleton-row", "aria-hidden": "true", style: q ? { height: X } : void 0, children: Kt ? (
|
|
1093
|
+
// A custom component draws the whole row content inside one wide cell
|
|
1094
|
+
/* @__PURE__ */ f("td", { colSpan: ve, className: "rk-grid__td rk-grid__skeleton-cell", children: ge(Kt, { rowIndex: e, columns: y }) })
|
|
1095
|
+
) : /* @__PURE__ */ x(lt, { children: [
|
|
1096
|
+
W && /* @__PURE__ */ f("td", { className: "rk-grid__td", children: /* @__PURE__ */ f("span", { ...L("skeleton", "rk-grid__skeleton"), style: { ...v.skeleton, width: 18 } }) }),
|
|
1097
|
+
y.map((t, n) => /* @__PURE__ */ f("td", { className: "rk-grid__td", style: { textAlign: t.align }, children: /* @__PURE__ */ f("span", { ...L("skeleton", "rk-grid__skeleton"), style: { ...v.skeleton, width: `${55 + (e * 7 + n * 13) % 35}%` } }) }, t.field))
|
|
1098
|
+
] }) }, `sk${e}`), Nn = (e, t) => {
|
|
1099
|
+
const { row: n, id: l, index: i } = e, o = typeof gt == "function" ? gt(n, i) : gt, g = typeof mt == "function" ? mt(n, i) : mt, h = Ct.has(l);
|
|
1100
|
+
return /* @__PURE__ */ x(
|
|
1101
|
+
"tr",
|
|
1102
|
+
{
|
|
1103
|
+
onClick: ut ? () => ut(n, i) : void 0,
|
|
1104
|
+
"aria-selected": W ? h : void 0,
|
|
1105
|
+
className: C(
|
|
1106
|
+
"rk-grid__tr",
|
|
1107
|
+
"rk-grid__row",
|
|
1108
|
+
kn && (t % 2 === 0 ? "rk-grid__row--stripe-a" : "rk-grid__row--stripe-b"),
|
|
1109
|
+
jt && !q && "rk-grid__row--enter",
|
|
1110
|
+
h && "rk-grid__row--selected",
|
|
1111
|
+
ut && "rk-grid__row--clickable",
|
|
1112
|
+
I.row,
|
|
1113
|
+
o
|
|
1114
|
+
),
|
|
1115
|
+
style: {
|
|
1116
|
+
...jt && !q ? { "--rk-i": Math.min(t, 24) } : null,
|
|
1117
|
+
...q ? { height: X } : null,
|
|
1118
|
+
...v.row,
|
|
1119
|
+
...g
|
|
1120
|
+
},
|
|
1121
|
+
children: [
|
|
1122
|
+
W && /* @__PURE__ */ f(
|
|
1123
|
+
"td",
|
|
562
1124
|
{
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
1125
|
+
className: C("rk-grid__td rk-grid__select-cell", rt && "rk-grid__pinned rk-grid__pinned--left"),
|
|
1126
|
+
style: { width: ee, minWidth: ee, maxWidth: ee, ...rt ? { left: 0 } : null },
|
|
1127
|
+
onClick: re,
|
|
1128
|
+
children: /* @__PURE__ */ f("span", { className: "rk-grid__checkbox-cell", onClickCapture: (u) => Qt.current = u.shiftKey, children: /* @__PURE__ */ f(
|
|
1129
|
+
me,
|
|
1130
|
+
{
|
|
1131
|
+
variant: ht,
|
|
1132
|
+
checked: h,
|
|
1133
|
+
disabled: !Je(n),
|
|
1134
|
+
"aria-label": W === "single" ? "Select row" : `Select row ${i + 1}`,
|
|
1135
|
+
onChange: (u) => en(e, u),
|
|
1136
|
+
classNames: { root: I.checkbox, control: I.checkboxControl, indicator: I.checkboxIndicator },
|
|
1137
|
+
styles: { root: v.checkbox, control: v.checkboxControl, indicator: v.checkboxIndicator }
|
|
1138
|
+
}
|
|
1139
|
+
) })
|
|
569
1140
|
}
|
|
570
|
-
)
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
/* @__PURE__ */ d("thead", { ..._("thead", "rk-grid__thead"), children: /* @__PURE__ */ d("tr", { ..._("headerRow", "rk-grid__tr"), children: o.map((e) => {
|
|
576
|
-
const t = (v == null ? void 0 : v.field) === e.field ? v.direction : null, r = Fe(e);
|
|
577
|
-
return /* @__PURE__ */ d(
|
|
578
|
-
"th",
|
|
1141
|
+
),
|
|
1142
|
+
y.map((u, k) => {
|
|
1143
|
+
const E = tn(u, e), nt = typeof u.cellClassName == "function" ? u.cellClassName(E) : u.cellClassName, Sn = typeof u.cellStyle == "function" ? u.cellStyle(E) : u.cellStyle, gr = ye !== null && ye.id === l && ye.field === u.field, Lt = Ge(u, E), mr = ar(u, k), Cn = _t ? _t.id === l && _t.field === u.field : t === 0 && k === 0;
|
|
1144
|
+
return /* @__PURE__ */ f(
|
|
1145
|
+
"td",
|
|
579
1146
|
{
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
onClick: () => Ve(e),
|
|
584
|
-
onKeyDown: (n) => {
|
|
585
|
-
r && n.target === n.currentTarget && (n.key === "Enter" || n.key === " ") && (n.preventDefault(), Ve(e));
|
|
1147
|
+
ref: (ne) => {
|
|
1148
|
+
const br = Mt(l, u.field);
|
|
1149
|
+
ne ? Re.current.set(br, ne) : Re.current.delete(br);
|
|
586
1150
|
},
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
indicatorClassName: D(N.filterIndicator, e.filterIndicatorClassName),
|
|
600
|
-
indicatorStyle: { ...x.filterIndicator, ...e.filterIndicatorStyle },
|
|
601
|
-
popupClassName: D(N.filterPopup, e.filterPopupClassName),
|
|
602
|
-
popupStyle: { ...x.filterPopup, ...e.filterPopupStyle },
|
|
603
|
-
inputClassName: N.filterInput,
|
|
604
|
-
inputStyle: x.filterInput
|
|
605
|
-
}
|
|
606
|
-
),
|
|
607
|
-
r && /* @__PURE__ */ d("span", { className: "rk-grid__sort", "aria-hidden": "true", children: t === "asc" ? "▲" : t === "desc" ? "▼" : "↕" })
|
|
608
|
-
] })
|
|
609
|
-
},
|
|
610
|
-
e.field
|
|
611
|
-
);
|
|
612
|
-
}) }) }),
|
|
613
|
-
/* @__PURE__ */ d("tbody", { ..._("tbody", "rk-grid__tbody"), children: M.length === 0 ? /* @__PURE__ */ d("tr", { children: /* @__PURE__ */ d("td", { colSpan: o.length, ..._("empty", "rk-grid__empty"), children: L }) }) : M.map((e, t) => {
|
|
614
|
-
const { row: r, id: n, index: i } = e, l = typeof me == "function" ? me(r, i) : me, f = typeof ve == "function" ? ve(r, i) : ve;
|
|
615
|
-
return /* @__PURE__ */ d(
|
|
616
|
-
"tr",
|
|
617
|
-
{
|
|
618
|
-
onClick: R ? () => R(r, i) : void 0,
|
|
619
|
-
className: D(
|
|
620
|
-
"rk-grid__tr",
|
|
621
|
-
"rk-grid__row",
|
|
622
|
-
ut && (t % 2 === 0 ? "rk-grid__row--stripe-a" : "rk-grid__row--stripe-b"),
|
|
623
|
-
A && "rk-grid__row--enter",
|
|
624
|
-
R && "rk-grid__row--clickable",
|
|
625
|
-
N.row,
|
|
626
|
-
l
|
|
1151
|
+
tabIndex: ft ? Cn ? 0 : -1 : Lt ? 0 : void 0,
|
|
1152
|
+
onFocus: ft ? (ne) => ne.target === ne.currentTarget && qt({ id: l, field: u.field }) : void 0,
|
|
1153
|
+
onDoubleClick: Lt ? () => Ze(e, u) : void 0,
|
|
1154
|
+
onKeyDown: (ne) => sn(ne, e, u, E),
|
|
1155
|
+
className: C(
|
|
1156
|
+
"rk-grid__td",
|
|
1157
|
+
Lt && "rk-grid__td--editable",
|
|
1158
|
+
gr && "rk-grid__td--editing",
|
|
1159
|
+
mr.className,
|
|
1160
|
+
I.cell,
|
|
1161
|
+
u.className,
|
|
1162
|
+
nt
|
|
627
1163
|
),
|
|
628
|
-
style: {
|
|
629
|
-
children:
|
|
630
|
-
const u = ot(a, e), p = typeof a.cellClassName == "function" ? a.cellClassName(u) : a.cellClassName, C = typeof a.cellStyle == "function" ? a.cellStyle(u) : a.cellStyle, we = te !== null && te.id === n && te.field === a.field, Ee = fe(a, u);
|
|
631
|
-
return /* @__PURE__ */ d(
|
|
632
|
-
"td",
|
|
633
|
-
{
|
|
634
|
-
ref: (ke) => {
|
|
635
|
-
const Re = Ue(n, a.field);
|
|
636
|
-
ke ? ye.current.set(Re, ke) : ye.current.delete(Re);
|
|
637
|
-
},
|
|
638
|
-
tabIndex: Ee ? 0 : void 0,
|
|
639
|
-
onDoubleClick: Ee ? () => he(e, a) : void 0,
|
|
640
|
-
onKeyDown: (ke) => lt(ke, e, a, u),
|
|
641
|
-
className: D(
|
|
642
|
-
"rk-grid__td",
|
|
643
|
-
Ee && "rk-grid__td--editable",
|
|
644
|
-
we && "rk-grid__td--editing",
|
|
645
|
-
N.cell,
|
|
646
|
-
a.className,
|
|
647
|
-
p
|
|
648
|
-
),
|
|
649
|
-
style: { textAlign: a.align, ...x.cell, ...a.style, ...C },
|
|
650
|
-
children: we && te ? at(e, a, te) : a.cellRenderer ? se(a.cellRenderer, u) : a.type === "boolean" && !a.cellEditor ? st(a, u) : u.formattedValue
|
|
651
|
-
},
|
|
652
|
-
a.field
|
|
653
|
-
);
|
|
654
|
-
})
|
|
1164
|
+
style: { textAlign: u.align, ...v.cell, ...u.style, ...Sn, ...mr.style },
|
|
1165
|
+
children: gr && ye ? mn(e, u, ye) : u.cellRenderer ? ge(u.cellRenderer, E) : u.type === "boolean" && !u.cellEditor ? hn(u, E) : E.formattedValue
|
|
655
1166
|
},
|
|
656
|
-
|
|
1167
|
+
u.field
|
|
657
1168
|
);
|
|
658
|
-
})
|
|
659
|
-
]
|
|
660
|
-
|
|
1169
|
+
})
|
|
1170
|
+
]
|
|
1171
|
+
},
|
|
1172
|
+
l
|
|
1173
|
+
);
|
|
1174
|
+
}, En = Mr ?? (Y ? Math.min(A, 20) : 5);
|
|
1175
|
+
return /* @__PURE__ */ x(
|
|
1176
|
+
"div",
|
|
1177
|
+
{
|
|
1178
|
+
className: C("rk-grid", q && "rk-grid--virtual", I.root, Pr),
|
|
1179
|
+
style: { ..._n, ...v.root, ...Ar },
|
|
1180
|
+
"data-rk-theme": pt || void 0,
|
|
1181
|
+
"aria-busy": St || void 0,
|
|
1182
|
+
children: [
|
|
1183
|
+
vn && /* @__PURE__ */ x("div", { ...L("toolbar", "rk-grid__toolbar"), children: [
|
|
1184
|
+
/* @__PURE__ */ x("div", { className: "rk-grid__toolbar-left", children: [
|
|
1185
|
+
B && /* @__PURE__ */ f(
|
|
1186
|
+
"input",
|
|
1187
|
+
{
|
|
1188
|
+
type: "search",
|
|
1189
|
+
value: ke,
|
|
1190
|
+
onChange: (e) => Kr(e.target.value),
|
|
1191
|
+
placeholder: ie,
|
|
1192
|
+
"aria-label": "Search all columns",
|
|
1193
|
+
...L("search", "rk-grid__search")
|
|
1194
|
+
}
|
|
1195
|
+
),
|
|
1196
|
+
W && J.length > 0 && /* @__PURE__ */ x("span", { className: "rk-grid__selected-count", role: "status", children: [
|
|
1197
|
+
J.length,
|
|
1198
|
+
" selected"
|
|
1199
|
+
] })
|
|
1200
|
+
] }),
|
|
1201
|
+
/* @__PURE__ */ x("div", { className: "rk-grid__toolbar-actions", children: [
|
|
1202
|
+
Wt,
|
|
1203
|
+
Bt && /* @__PURE__ */ f(
|
|
1204
|
+
jn,
|
|
1205
|
+
{
|
|
1206
|
+
columns: r,
|
|
1207
|
+
hidden: Ae,
|
|
1208
|
+
onToggle: Ur,
|
|
1209
|
+
theme: pt,
|
|
1210
|
+
className: I.toolButton,
|
|
1211
|
+
style: v.toolButton
|
|
1212
|
+
}
|
|
1213
|
+
),
|
|
1214
|
+
Fe && /* @__PURE__ */ f("button", { type: "button", onClick: () => fr(), ...L("toolButton", "rk-grid__tool-btn"), children: "Export CSV" })
|
|
1215
|
+
] })
|
|
1216
|
+
] }),
|
|
1217
|
+
yn && pr("top"),
|
|
1218
|
+
/* @__PURE__ */ f(
|
|
1219
|
+
"div",
|
|
1220
|
+
{
|
|
1221
|
+
ref: xe,
|
|
1222
|
+
...L("scroll", "rk-grid__scroll"),
|
|
1223
|
+
onScroll: q ? (e) => Ht({ top: e.currentTarget.scrollTop, height: e.currentTarget.clientHeight }) : void 0,
|
|
1224
|
+
style: { ...v.scroll, ...Oe !== void 0 ? { maxHeight: Oe } : q ? { maxHeight: 400 } : null },
|
|
1225
|
+
children: /* @__PURE__ */ x(
|
|
1226
|
+
"table",
|
|
1227
|
+
{
|
|
1228
|
+
...L("table", "rk-grid__table"),
|
|
1229
|
+
role: "grid",
|
|
1230
|
+
style: Tt ? {
|
|
1231
|
+
...v.table,
|
|
1232
|
+
tableLayout: "fixed",
|
|
1233
|
+
width: y.reduce((e, t) => e + tt(t), W ? ee : 0),
|
|
1234
|
+
minWidth: "100%"
|
|
1235
|
+
} : v.table,
|
|
1236
|
+
children: [
|
|
1237
|
+
/* @__PURE__ */ f("thead", { ...L("thead", "rk-grid__thead"), children: /* @__PURE__ */ x("tr", { ...L("headerRow", "rk-grid__tr"), children: [
|
|
1238
|
+
W && /* @__PURE__ */ f(
|
|
1239
|
+
"th",
|
|
1240
|
+
{
|
|
1241
|
+
scope: "col",
|
|
1242
|
+
className: C("rk-grid__th rk-grid__select-cell", rt && "rk-grid__pinned rk-grid__pinned--left", I.headerCell),
|
|
1243
|
+
style: { width: ee, minWidth: ee, maxWidth: ee, ...rt ? { left: 0 } : null, ...v.headerCell },
|
|
1244
|
+
children: W === "multiple" && /* @__PURE__ */ f("span", { className: "rk-grid__checkbox-cell", children: /* @__PURE__ */ f(
|
|
1245
|
+
me,
|
|
1246
|
+
{
|
|
1247
|
+
variant: ht,
|
|
1248
|
+
checked: er,
|
|
1249
|
+
indeterminate: Zt > 0 && !er,
|
|
1250
|
+
disabled: we.length === 0,
|
|
1251
|
+
"aria-label": "Select all rows",
|
|
1252
|
+
onChange: tr,
|
|
1253
|
+
classNames: { root: I.checkbox, control: I.checkboxControl, indicator: I.checkboxIndicator },
|
|
1254
|
+
styles: { root: v.checkbox, control: v.checkboxControl, indicator: v.checkboxIndicator }
|
|
1255
|
+
}
|
|
1256
|
+
) })
|
|
1257
|
+
}
|
|
1258
|
+
),
|
|
1259
|
+
y.map((e, t) => {
|
|
1260
|
+
const n = R.findIndex((h) => h.field === e.field), l = n >= 0 ? R[n].direction : null, i = vt(e), o = Yt(e), g = ar(e, t);
|
|
1261
|
+
return /* @__PURE__ */ x(
|
|
1262
|
+
"th",
|
|
1263
|
+
{
|
|
1264
|
+
ref: (h) => {
|
|
1265
|
+
h ? _e.current.set(e.field, h) : _e.current.delete(e.field);
|
|
1266
|
+
},
|
|
1267
|
+
scope: "col",
|
|
1268
|
+
"aria-sort": l ? l === "asc" ? "ascending" : "descending" : i ? "none" : void 0,
|
|
1269
|
+
tabIndex: i ? 0 : void 0,
|
|
1270
|
+
onClick: (h) => rr(e, h.shiftKey),
|
|
1271
|
+
onKeyDown: (h) => {
|
|
1272
|
+
i && h.target === h.currentTarget && (h.key === "Enter" || h.key === " ") && (h.preventDefault(), rr(e, h.shiftKey));
|
|
1273
|
+
},
|
|
1274
|
+
className: C("rk-grid__th", i && "rk-grid__th--sortable", g.className, I.headerCell, e.className, e.headerClassName),
|
|
1275
|
+
style: {
|
|
1276
|
+
width: Tt ? tt(e) : e.width,
|
|
1277
|
+
minWidth: e.minWidth,
|
|
1278
|
+
textAlign: e.align,
|
|
1279
|
+
...v.headerCell,
|
|
1280
|
+
...e.style,
|
|
1281
|
+
...e.headerStyle,
|
|
1282
|
+
...g.style
|
|
1283
|
+
},
|
|
1284
|
+
children: [
|
|
1285
|
+
/* @__PURE__ */ x("span", { className: "rk-grid__th-content", children: [
|
|
1286
|
+
e.headerRenderer ? ge(e.headerRenderer, { column: e, sortDirection: l }) : e.headerCheckbox && e.type === "boolean" ? gn(e) : ot(e),
|
|
1287
|
+
e.filterable && /* @__PURE__ */ f(
|
|
1288
|
+
Wn,
|
|
1289
|
+
{
|
|
1290
|
+
column: e,
|
|
1291
|
+
label: pe(e),
|
|
1292
|
+
kind: o,
|
|
1293
|
+
value: se[e.field],
|
|
1294
|
+
onChange: (h) => {
|
|
1295
|
+
const u = { ...se };
|
|
1296
|
+
h === void 0 ? delete u[e.field] : u[e.field] = h, Br(u);
|
|
1297
|
+
},
|
|
1298
|
+
options: bn.get(e.field) ?? [],
|
|
1299
|
+
theme: pt,
|
|
1300
|
+
indicatorClassName: C(I.filterIndicator, e.filterIndicatorClassName),
|
|
1301
|
+
indicatorStyle: { ...v.filterIndicator, ...e.filterIndicatorStyle },
|
|
1302
|
+
popupClassName: C(I.filterPopup, e.filterPopupClassName),
|
|
1303
|
+
popupStyle: { ...v.filterPopup, ...e.filterPopupStyle },
|
|
1304
|
+
inputClassName: I.filterInput,
|
|
1305
|
+
inputStyle: v.filterInput
|
|
1306
|
+
}
|
|
1307
|
+
),
|
|
1308
|
+
i && /* @__PURE__ */ x("span", { className: "rk-grid__sort", "aria-hidden": "true", children: [
|
|
1309
|
+
l === "asc" ? "▲" : l === "desc" ? "▼" : "↕",
|
|
1310
|
+
l && R.length > 1 && /* @__PURE__ */ f("sup", { className: "rk-grid__sort-order", children: n + 1 })
|
|
1311
|
+
] })
|
|
1312
|
+
] }),
|
|
1313
|
+
e.resizable && /* @__PURE__ */ f(
|
|
1314
|
+
"span",
|
|
1315
|
+
{
|
|
1316
|
+
className: "rk-grid__resizer",
|
|
1317
|
+
role: "separator",
|
|
1318
|
+
"aria-orientation": "vertical",
|
|
1319
|
+
"aria-label": `Resize ${pe(e)}`,
|
|
1320
|
+
onPointerDown: (h) => fn(h, e),
|
|
1321
|
+
onClick: re,
|
|
1322
|
+
onDoubleClick: re
|
|
1323
|
+
}
|
|
1324
|
+
)
|
|
1325
|
+
]
|
|
1326
|
+
},
|
|
1327
|
+
e.field
|
|
1328
|
+
);
|
|
1329
|
+
})
|
|
1330
|
+
] }) }),
|
|
1331
|
+
/* @__PURE__ */ f("tbody", { ...L("tbody", "rk-grid__tbody"), children: St ? Array.from({ length: En }, (e, t) => wn(t)) : Zr ? /* @__PURE__ */ f("tr", { children: /* @__PURE__ */ x("td", { colSpan: ve, ...L("empty", "rk-grid__empty rk-grid__error"), role: "alert", children: [
|
|
1332
|
+
Fr,
|
|
1333
|
+
" ",
|
|
1334
|
+
/* @__PURE__ */ f("button", { type: "button", className: "rk-grid__tool-btn", onClick: () => qe(Ve.current), children: "Retry" })
|
|
1335
|
+
] }) }) : w.length === 0 ? /* @__PURE__ */ f("tr", { children: /* @__PURE__ */ f("td", { colSpan: ve, ...L("empty", "rk-grid__empty"), children: $r }) }) : /* @__PURE__ */ x(lt, { children: [
|
|
1336
|
+
Ee && et > 0 && /* @__PURE__ */ f("tr", { "aria-hidden": "true", className: "rk-grid__spacer", children: /* @__PURE__ */ f("td", { colSpan: ve, style: { height: et * X } }) }),
|
|
1337
|
+
dn.map((e, t) => Nn(e, et + t)),
|
|
1338
|
+
Ee && It < w.length && /* @__PURE__ */ f("tr", { "aria-hidden": "true", className: "rk-grid__spacer", children: /* @__PURE__ */ f("td", { colSpan: ve, style: { height: (w.length - It) * X } }) })
|
|
1339
|
+
] }) }, or)
|
|
1340
|
+
]
|
|
1341
|
+
}
|
|
1342
|
+
)
|
|
1343
|
+
}
|
|
1344
|
+
),
|
|
1345
|
+
xn && pr("bottom")
|
|
661
1346
|
]
|
|
662
1347
|
}
|
|
663
1348
|
);
|
|
664
1349
|
}
|
|
665
1350
|
export {
|
|
666
|
-
|
|
667
|
-
|
|
1351
|
+
me as Checkbox,
|
|
1352
|
+
ei as DataGrid
|
|
668
1353
|
};
|