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