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