react-gridix 0.2.4 → 0.2.5
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 +247 -16
- package/dist/client-40__X0_a.cjs +1 -0
- package/dist/client-DUlru6F3.js +51 -0
- package/dist/index.d.ts +331 -9
- package/dist/react-gridix.cjs +21 -2
- package/dist/react-gridix.js +1871 -1106
- package/dist/style.css +1 -1
- package/package.json +2 -1
package/dist/react-gridix.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
return /* @__PURE__ */
|
|
1
|
+
import { jsxs as I, jsx as h, Fragment as tt } from "react/jsx-runtime";
|
|
2
|
+
import { useState as z, useRef as j, useEffect as ne, useMemo as ke, useCallback as Fe, useLayoutEffect as li, createElement as Ke, useId as si } from "react";
|
|
3
|
+
import { createPortal as ai } from "react-dom";
|
|
4
|
+
const Ft = (...t) => t.filter(Boolean).join(" ");
|
|
5
|
+
function ci() {
|
|
6
|
+
return /* @__PURE__ */ h("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ h(
|
|
7
7
|
"path",
|
|
8
8
|
{
|
|
9
9
|
d: "M3.5 8.5l3 3 6-7",
|
|
@@ -15,1050 +15,1666 @@ function Yn() {
|
|
|
15
15
|
}
|
|
16
16
|
) });
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return /* @__PURE__ */
|
|
18
|
+
function di() {
|
|
19
|
+
return /* @__PURE__ */ h("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ h("path", { d: "M4 8h8", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round" }) });
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
checked:
|
|
21
|
+
function ht({
|
|
22
|
+
checked: t,
|
|
23
23
|
onChange: n,
|
|
24
|
-
indeterminate:
|
|
25
|
-
variant:
|
|
26
|
-
disabled:
|
|
27
|
-
label:
|
|
28
|
-
"aria-label":
|
|
29
|
-
id:
|
|
30
|
-
name:
|
|
31
|
-
indicator:
|
|
32
|
-
className:
|
|
33
|
-
style:
|
|
34
|
-
classNames:
|
|
35
|
-
styles:
|
|
24
|
+
indeterminate: i = !1,
|
|
25
|
+
variant: o = "native",
|
|
26
|
+
disabled: u = !1,
|
|
27
|
+
label: d,
|
|
28
|
+
"aria-label": a,
|
|
29
|
+
id: g,
|
|
30
|
+
name: m,
|
|
31
|
+
indicator: x,
|
|
32
|
+
className: E,
|
|
33
|
+
style: b,
|
|
34
|
+
classNames: v = {},
|
|
35
|
+
styles: p = {}
|
|
36
36
|
}) {
|
|
37
|
-
const
|
|
38
|
-
return /* @__PURE__ */
|
|
37
|
+
const k = i ? "indeterminate" : t ? "checked" : "unchecked";
|
|
38
|
+
return /* @__PURE__ */ I(
|
|
39
39
|
"label",
|
|
40
40
|
{
|
|
41
|
-
className:
|
|
41
|
+
className: Ft(
|
|
42
42
|
"rg-checkbox",
|
|
43
|
-
`rg-checkbox--${
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
`rg-checkbox--${o}`,
|
|
44
|
+
k === "checked" && "rg-checkbox--checked",
|
|
45
|
+
i && "rg-checkbox--indeterminate",
|
|
46
|
+
u && "rg-checkbox--disabled",
|
|
47
|
+
v.root,
|
|
48
|
+
E
|
|
49
49
|
),
|
|
50
|
-
style: { ...
|
|
51
|
-
"data-state":
|
|
50
|
+
style: { ...p.root, ...b },
|
|
51
|
+
"data-state": k,
|
|
52
52
|
children: [
|
|
53
|
-
|
|
53
|
+
o === "native" ? /* @__PURE__ */ h(
|
|
54
54
|
"input",
|
|
55
55
|
{
|
|
56
56
|
type: "checkbox",
|
|
57
|
-
id:
|
|
58
|
-
name:
|
|
59
|
-
ref: (
|
|
60
|
-
|
|
57
|
+
id: g,
|
|
58
|
+
name: m,
|
|
59
|
+
ref: (D) => {
|
|
60
|
+
D && (D.indeterminate = i);
|
|
61
61
|
},
|
|
62
|
-
className:
|
|
63
|
-
style:
|
|
64
|
-
checked:
|
|
65
|
-
disabled:
|
|
66
|
-
"aria-label":
|
|
67
|
-
"data-state":
|
|
68
|
-
onChange: (
|
|
62
|
+
className: Ft("rg-checkbox__control", v.control),
|
|
63
|
+
style: p.control,
|
|
64
|
+
checked: t,
|
|
65
|
+
disabled: u,
|
|
66
|
+
"aria-label": a,
|
|
67
|
+
"data-state": k,
|
|
68
|
+
onChange: (D) => n(D.target.checked)
|
|
69
69
|
}
|
|
70
|
-
) : /* @__PURE__ */
|
|
70
|
+
) : /* @__PURE__ */ h(
|
|
71
71
|
"button",
|
|
72
72
|
{
|
|
73
73
|
type: "button",
|
|
74
74
|
role: "checkbox",
|
|
75
|
-
id:
|
|
76
|
-
className:
|
|
77
|
-
style:
|
|
78
|
-
"aria-checked":
|
|
79
|
-
"aria-label":
|
|
80
|
-
disabled:
|
|
81
|
-
"data-state":
|
|
82
|
-
onClick: () => n(!
|
|
83
|
-
children: /* @__PURE__ */
|
|
75
|
+
id: g,
|
|
76
|
+
className: Ft("rg-checkbox__control", v.control),
|
|
77
|
+
style: p.control,
|
|
78
|
+
"aria-checked": i ? "mixed" : t,
|
|
79
|
+
"aria-label": a,
|
|
80
|
+
disabled: u,
|
|
81
|
+
"data-state": k,
|
|
82
|
+
onClick: () => n(!t),
|
|
83
|
+
children: /* @__PURE__ */ h(
|
|
84
84
|
"span",
|
|
85
85
|
{
|
|
86
|
-
className:
|
|
86
|
+
className: Ft(
|
|
87
87
|
"rg-checkbox__indicator",
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
x !== void 0 && !i && "rg-checkbox__indicator--custom",
|
|
89
|
+
v.indicator
|
|
90
90
|
),
|
|
91
|
-
style:
|
|
92
|
-
"data-state":
|
|
91
|
+
style: p.indicator,
|
|
92
|
+
"data-state": k,
|
|
93
93
|
"aria-hidden": "true",
|
|
94
|
-
children:
|
|
94
|
+
children: i ? o === "tick" ? /* @__PURE__ */ h(di, {}) : null : x !== void 0 ? x : o === "tick" ? /* @__PURE__ */ h(ci, {}) : null
|
|
95
95
|
}
|
|
96
96
|
)
|
|
97
97
|
}
|
|
98
98
|
),
|
|
99
|
-
|
|
99
|
+
d != null && d !== !1 && d !== "" && /* @__PURE__ */ h("span", { className: Ft("rg-checkbox__label", v.label), style: p.label, children: d })
|
|
100
100
|
]
|
|
101
101
|
}
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
|
-
const
|
|
105
|
-
function
|
|
106
|
-
const n =
|
|
104
|
+
const ui = /^(\d{4})-(\d{2})-(\d{2})$/, Br = (t) => String(t).padStart(2, "0");
|
|
105
|
+
function se(t) {
|
|
106
|
+
const n = ui.exec(t);
|
|
107
107
|
if (!n) return null;
|
|
108
|
-
const [
|
|
109
|
-
return
|
|
108
|
+
const [i, o, u] = [Number(n[1]), Number(n[2]), Number(n[3])], d = new Date(i, o - 1, u);
|
|
109
|
+
return d.getFullYear() === i && d.getMonth() === o - 1 && d.getDate() === u ? d : null;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function he(t) {
|
|
112
112
|
var n;
|
|
113
|
-
if (
|
|
114
|
-
return Number.isNaN(
|
|
115
|
-
if (typeof
|
|
116
|
-
if (typeof
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
const
|
|
122
|
-
return Number.isNaN(
|
|
113
|
+
if (t instanceof Date)
|
|
114
|
+
return Number.isNaN(t.getTime()) ? null : `${t.getFullYear()}-${Br(t.getMonth() + 1)}-${Br(t.getDate())}`;
|
|
115
|
+
if (typeof t == "number") return Number.isFinite(t) ? he(new Date(t)) : null;
|
|
116
|
+
if (typeof t == "string") {
|
|
117
|
+
const i = t.trim();
|
|
118
|
+
if (i === "") return null;
|
|
119
|
+
const o = (n = /^\d{4}-\d{2}-\d{2}/.exec(i)) == null ? void 0 : n[0];
|
|
120
|
+
if (o) return se(o) ? o : null;
|
|
121
|
+
const u = Date.parse(i);
|
|
122
|
+
return Number.isNaN(u) ? null : he(new Date(u));
|
|
123
123
|
}
|
|
124
124
|
return null;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
const
|
|
128
|
-
return
|
|
126
|
+
function fi(t, n, i) {
|
|
127
|
+
const o = he(t);
|
|
128
|
+
return o ? se(o).toLocaleDateString(n, i ?? { year: "numeric", month: "short", day: "numeric" }) : t == null ? "" : String(t);
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
var
|
|
132
|
-
return
|
|
130
|
+
function hi(t, n) {
|
|
131
|
+
var i;
|
|
132
|
+
return t === "" ? null : n instanceof Date ? se(t) : typeof n == "number" ? ((i = se(t)) == null ? void 0 : i.getTime()) ?? null : t;
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
function
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
const
|
|
139
|
-
let
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
return new Date(
|
|
134
|
+
const U = (...t) => t.filter(Boolean).join(" "), Mt = (t) => t.headerName ?? (t.type === "boolean" ? "" : t.type === "sequence" ? "#" : t.field), et = (t) => Mt(t) || t.field, Wr = (t) => String(t).padStart(2, "0"), Un = (t, n, i) => `${t}-${Wr(n + 1)}-${Wr(i)}`;
|
|
135
|
+
function jr(t, n, i, o) {
|
|
136
|
+
const u = [t, n == null ? void 0 : n.from, n == null ? void 0 : n.to].map((m) => m ? se(m) : null).find(Boolean);
|
|
137
|
+
if (u) return new Date(u.getFullYear(), u.getMonth(), 1);
|
|
138
|
+
const d = /* @__PURE__ */ new Date();
|
|
139
|
+
let a = he(d);
|
|
140
|
+
i && a < i && (a = i), o && a > o && (a = o);
|
|
141
|
+
const g = se(a) ?? d;
|
|
142
|
+
return new Date(g.getFullYear(), g.getMonth(), 1);
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
var
|
|
146
|
-
const [
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
}, [
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
return Array.from({ length: 7 }, (
|
|
156
|
-
}, [
|
|
157
|
-
const
|
|
158
|
-
return Array.from({ length: 42 }, (
|
|
159
|
-
const
|
|
160
|
-
return { iso:
|
|
144
|
+
function lo({ value: t, range: n, min: i, max: o, onPick: u, locale: d, weekStart: a = 0, hideFooter: g, keepFocus: m, className: x }) {
|
|
145
|
+
var Ie;
|
|
146
|
+
const [E, b] = z(() => jr(t, n, i, o)), [v, p] = z(null), k = j(null), D = j({ value: t, from: n == null ? void 0 : n.from, to: n == null ? void 0 : n.to });
|
|
147
|
+
ne(() => {
|
|
148
|
+
const _ = D.current;
|
|
149
|
+
D.current = { value: t, from: n == null ? void 0 : n.from, to: n == null ? void 0 : n.to };
|
|
150
|
+
const G = t !== _.value ? t : (n == null ? void 0 : n.from) !== _.from ? n == null ? void 0 : n.from : (n == null ? void 0 : n.to) !== _.to ? n == null ? void 0 : n.to : void 0, S = G ? se(G) : null;
|
|
151
|
+
S && b((B) => B.getFullYear() === S.getFullYear() && B.getMonth() === S.getMonth() ? B : new Date(S.getFullYear(), S.getMonth(), 1));
|
|
152
|
+
}, [t, n == null ? void 0 : n.from, n == null ? void 0 : n.to]);
|
|
153
|
+
const C = he(/* @__PURE__ */ new Date()), T = E.getFullYear(), w = E.getMonth(), P = ke(() => {
|
|
154
|
+
const _ = new Intl.DateTimeFormat(d, { weekday: "short" });
|
|
155
|
+
return Array.from({ length: 7 }, (G, S) => _.format(new Date(2023, 0, 1 + (S + a) % 7)));
|
|
156
|
+
}, [d, a]), X = new Intl.DateTimeFormat(d, { month: "long", year: "numeric" }).format(E), q = ke(() => {
|
|
157
|
+
const _ = (new Date(T, w, 1).getDay() - a + 7) % 7;
|
|
158
|
+
return Array.from({ length: 42 }, (G, S) => {
|
|
159
|
+
const B = new Date(T, w, 1 - _ + S);
|
|
160
|
+
return { iso: Un(B.getFullYear(), B.getMonth(), B.getDate()), day: B.getDate(), outside: B.getMonth() !== w };
|
|
161
161
|
});
|
|
162
|
-
}, [
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
var
|
|
166
|
-
return (
|
|
162
|
+
}, [T, w, a]), R = (_) => !!i && _ < i || !!o && _ > o, H = (_) => b(new Date(T, w + _, 1)), Se = (_) => {
|
|
163
|
+
const G = se(_);
|
|
164
|
+
G && ((G.getFullYear() !== T || G.getMonth() !== w) && b(new Date(G.getFullYear(), G.getMonth(), 1)), p(_), requestAnimationFrame(() => {
|
|
165
|
+
var S, B;
|
|
166
|
+
return (B = (S = k.current) == null ? void 0 : S.querySelector(`[data-iso="${_}"]`)) == null ? void 0 : B.focus();
|
|
167
167
|
}));
|
|
168
|
-
},
|
|
169
|
-
const
|
|
170
|
-
|
|
168
|
+
}, Pe = (_, G) => {
|
|
169
|
+
const S = se(G), B = (ce) => {
|
|
170
|
+
_.preventDefault(), Se(Un(S.getFullYear(), S.getMonth(), S.getDate() + ce));
|
|
171
171
|
};
|
|
172
|
-
switch (
|
|
172
|
+
switch (_.key) {
|
|
173
173
|
case "ArrowLeft":
|
|
174
|
-
return
|
|
174
|
+
return B(-1);
|
|
175
175
|
case "ArrowRight":
|
|
176
|
-
return
|
|
176
|
+
return B(1);
|
|
177
177
|
case "ArrowUp":
|
|
178
|
-
return
|
|
178
|
+
return B(-7);
|
|
179
179
|
case "ArrowDown":
|
|
180
|
-
return
|
|
180
|
+
return B(7);
|
|
181
181
|
case "Home":
|
|
182
|
-
return
|
|
182
|
+
return B(-((S.getDay() - a + 7) % 7));
|
|
183
183
|
case "End":
|
|
184
|
-
return
|
|
184
|
+
return B(6 - (S.getDay() - a + 7) % 7);
|
|
185
185
|
case "PageUp":
|
|
186
186
|
case "PageDown": {
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
187
|
+
_.preventDefault();
|
|
188
|
+
const ce = _.key === "PageUp" ? -1 : 1, pe = new Date(S.getFullYear(), S.getMonth() + ce + 1, 0).getDate();
|
|
189
|
+
Se(Un(S.getFullYear(), S.getMonth() + ce, Math.min(S.getDate(), pe)));
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
},
|
|
194
|
-
return /* @__PURE__ */
|
|
193
|
+
}, ze = (_) => !!_ && q.some((G) => G.iso === _ && !G.outside), Ee = [v, t, C].find((_) => ze(_) && !R(_)) ?? ((Ie = q.find((_) => !_.outside && !R(_.iso))) == null ? void 0 : Ie.iso), V = n == null ? void 0 : n.from, ae = n == null ? void 0 : n.to;
|
|
194
|
+
return /* @__PURE__ */ I(
|
|
195
195
|
"div",
|
|
196
196
|
{
|
|
197
|
-
className:
|
|
198
|
-
onMouseDown:
|
|
197
|
+
className: U("rg-cal", x),
|
|
198
|
+
onMouseDown: m ? (_) => _.preventDefault() : void 0,
|
|
199
199
|
role: "group",
|
|
200
|
-
"aria-label": `Calendar, ${
|
|
200
|
+
"aria-label": `Calendar, ${X}`,
|
|
201
201
|
children: [
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
-
/* @__PURE__ */
|
|
207
|
-
/* @__PURE__ */
|
|
202
|
+
/* @__PURE__ */ I("div", { className: "rg-cal__head", children: [
|
|
203
|
+
/* @__PURE__ */ h("button", { type: "button", className: "rg-cal__nav", "aria-label": "Previous year", onClick: () => H(-12), children: "«" }),
|
|
204
|
+
/* @__PURE__ */ h("button", { type: "button", className: "rg-cal__nav", "aria-label": "Previous month", onClick: () => H(-1), children: "‹" }),
|
|
205
|
+
/* @__PURE__ */ h("span", { className: "rg-cal__title", "aria-live": "polite", children: X }),
|
|
206
|
+
/* @__PURE__ */ h("button", { type: "button", className: "rg-cal__nav", "aria-label": "Next month", onClick: () => H(1), children: "›" }),
|
|
207
|
+
/* @__PURE__ */ h("button", { type: "button", className: "rg-cal__nav", "aria-label": "Next year", onClick: () => H(12), children: "»" })
|
|
208
208
|
] }),
|
|
209
|
-
/* @__PURE__ */
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
return /* @__PURE__ */
|
|
209
|
+
/* @__PURE__ */ I("div", { className: "rg-cal__grid", ref: k, children: [
|
|
210
|
+
P.map((_) => /* @__PURE__ */ h("span", { className: "rg-cal__dow", "aria-hidden": "true", children: _.slice(0, 2) }, _)),
|
|
211
|
+
q.map(({ iso: _, day: G, outside: S }) => {
|
|
212
|
+
const B = _ === t, ce = _ === V, pe = _ === ae, qe = !!V && !!ae && _ > V && _ < ae;
|
|
213
|
+
return /* @__PURE__ */ h(
|
|
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(
|
|
222
|
-
className:
|
|
217
|
+
"data-iso": _,
|
|
218
|
+
tabIndex: _ === Ee ? 0 : -1,
|
|
219
|
+
disabled: R(_),
|
|
220
|
+
"aria-pressed": B || ce || pe,
|
|
221
|
+
"aria-label": new Intl.DateTimeFormat(d, { dateStyle: "full" }).format(se(_)),
|
|
222
|
+
className: U(
|
|
223
223
|
"rg-cal__day",
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
224
|
+
S && "rg-cal__day--outside",
|
|
225
|
+
_ === C && "rg-cal__day--today",
|
|
226
|
+
(B || ce || pe) && "rg-cal__day--selected",
|
|
227
|
+
qe && "rg-cal__day--in-range",
|
|
228
|
+
V && ae && ce && V !== ae && "rg-cal__day--range-start",
|
|
229
|
+
V && ae && pe && V !== ae && "rg-cal__day--range-end"
|
|
230
230
|
),
|
|
231
|
-
onClick: () =>
|
|
232
|
-
onKeyDown: (
|
|
233
|
-
onFocus: () => _
|
|
234
|
-
children:
|
|
231
|
+
onClick: () => u(_),
|
|
232
|
+
onKeyDown: (nt) => Pe(nt, _),
|
|
233
|
+
onFocus: () => p(_),
|
|
234
|
+
children: G
|
|
235
235
|
},
|
|
236
|
-
|
|
236
|
+
_
|
|
237
237
|
);
|
|
238
238
|
})
|
|
239
239
|
] }),
|
|
240
|
-
!
|
|
241
|
-
/* @__PURE__ */
|
|
240
|
+
!g && /* @__PURE__ */ I("div", { className: "rg-cal__foot", children: [
|
|
241
|
+
/* @__PURE__ */ h(
|
|
242
242
|
"button",
|
|
243
243
|
{
|
|
244
244
|
type: "button",
|
|
245
245
|
className: "rg-cal__link",
|
|
246
|
-
disabled:
|
|
246
|
+
disabled: R(C),
|
|
247
247
|
onClick: () => {
|
|
248
|
-
|
|
248
|
+
b(jr(C)), u(C);
|
|
249
249
|
},
|
|
250
250
|
children: "Today"
|
|
251
251
|
}
|
|
252
252
|
),
|
|
253
|
-
/* @__PURE__ */
|
|
253
|
+
/* @__PURE__ */ h("button", { type: "button", className: "rg-cal__link", onClick: () => u(""), children: "Clear" })
|
|
254
254
|
] })
|
|
255
255
|
]
|
|
256
256
|
}
|
|
257
257
|
);
|
|
258
258
|
}
|
|
259
|
-
const
|
|
260
|
-
function
|
|
261
|
-
const [
|
|
262
|
-
(
|
|
263
|
-
|
|
259
|
+
const pn = typeof window < "u" ? li : ne;
|
|
260
|
+
function Et(t, n, i) {
|
|
261
|
+
const [o, u] = z(n), d = t !== void 0, a = d ? t : o, g = Fe(
|
|
262
|
+
(m) => {
|
|
263
|
+
d || u(m), i == null || i(m);
|
|
264
264
|
},
|
|
265
|
-
[
|
|
265
|
+
[d, i]
|
|
266
266
|
);
|
|
267
|
-
return [
|
|
267
|
+
return [a, g];
|
|
268
268
|
}
|
|
269
|
-
function
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
}, []),
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
}, []),
|
|
279
|
-
(...
|
|
269
|
+
function so(t, n) {
|
|
270
|
+
const i = j(t);
|
|
271
|
+
i.current = t;
|
|
272
|
+
const o = j(void 0), u = j(null), d = Fe(() => {
|
|
273
|
+
o.current !== void 0 && clearTimeout(o.current), o.current = void 0, u.current = null;
|
|
274
|
+
}, []), a = Fe(() => {
|
|
275
|
+
o.current !== void 0 && clearTimeout(o.current), o.current = void 0;
|
|
276
|
+
const m = u.current;
|
|
277
|
+
u.current = null, m && i.current(...m);
|
|
278
|
+
}, []), g = Fe(
|
|
279
|
+
(...m) => {
|
|
280
280
|
if (n <= 0) {
|
|
281
|
-
|
|
281
|
+
d(), i.current(...m);
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
-
|
|
284
|
+
u.current = m, o.current !== void 0 && clearTimeout(o.current), o.current = setTimeout(a, n);
|
|
285
285
|
},
|
|
286
|
-
[n,
|
|
286
|
+
[n, d, a]
|
|
287
287
|
);
|
|
288
|
-
return
|
|
288
|
+
return ne(() => a, [a]), { call: g, flush: a, cancel: d };
|
|
289
289
|
}
|
|
290
|
-
function
|
|
291
|
-
const
|
|
292
|
-
var
|
|
293
|
-
const
|
|
294
|
-
if (!
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
}, [
|
|
298
|
-
return
|
|
299
|
-
n &&
|
|
300
|
-
}, [n,
|
|
290
|
+
function yn({ anchorRef: t, open: n, onClose: i, label: o, theme: u, className: d, style: a, keepFocus: g, children: m }) {
|
|
291
|
+
const x = j(null), [E, b] = z({ top: 0, left: 0 }), v = Fe(() => {
|
|
292
|
+
var T;
|
|
293
|
+
const p = t.current;
|
|
294
|
+
if (!p) return;
|
|
295
|
+
const k = p.getBoundingClientRect(), D = ((T = x.current) == null ? void 0 : T.offsetWidth) ?? 260, C = Math.max(8, Math.min(k.left, window.innerWidth - D - 8));
|
|
296
|
+
b({ top: k.bottom + 6, left: C });
|
|
297
|
+
}, [t]);
|
|
298
|
+
return pn(() => {
|
|
299
|
+
n && v();
|
|
300
|
+
}, [n, v]), ne(() => {
|
|
301
301
|
if (!n) return;
|
|
302
|
-
const
|
|
303
|
-
var
|
|
304
|
-
const
|
|
305
|
-
(
|
|
306
|
-
},
|
|
307
|
-
var
|
|
308
|
-
|
|
302
|
+
const p = (D) => {
|
|
303
|
+
var T, w;
|
|
304
|
+
const C = D.target;
|
|
305
|
+
(T = x.current) != null && T.contains(C) || (w = t.current) != null && w.contains(C) || i();
|
|
306
|
+
}, k = (D) => {
|
|
307
|
+
var C;
|
|
308
|
+
D.key === "Escape" && (i(), (C = t.current) == null || C.focus());
|
|
309
309
|
};
|
|
310
|
-
return document.addEventListener("mousedown",
|
|
311
|
-
document.removeEventListener("mousedown",
|
|
310
|
+
return document.addEventListener("mousedown", p), document.addEventListener("keydown", k), window.addEventListener("resize", v), window.addEventListener("scroll", v, !0), () => {
|
|
311
|
+
document.removeEventListener("mousedown", p), document.removeEventListener("keydown", k), window.removeEventListener("resize", v), window.removeEventListener("scroll", v, !0);
|
|
312
312
|
};
|
|
313
|
-
}, [n,
|
|
314
|
-
/* @__PURE__ */
|
|
313
|
+
}, [n, i, v, t]), !n || typeof document > "u" ? null : ai(
|
|
314
|
+
/* @__PURE__ */ h(
|
|
315
315
|
"div",
|
|
316
316
|
{
|
|
317
|
-
ref:
|
|
317
|
+
ref: x,
|
|
318
318
|
role: "dialog",
|
|
319
|
-
onMouseDown:
|
|
320
|
-
"aria-label":
|
|
321
|
-
"data-rg-theme":
|
|
322
|
-
className:
|
|
323
|
-
style: { position: "fixed", top:
|
|
324
|
-
children:
|
|
319
|
+
onMouseDown: g ? (p) => p.preventDefault() : void 0,
|
|
320
|
+
"aria-label": o,
|
|
321
|
+
"data-rg-theme": u || void 0,
|
|
322
|
+
className: U("rg-grid-popup", d),
|
|
323
|
+
style: { position: "fixed", top: E.top, left: E.left, ...a },
|
|
324
|
+
children: m
|
|
325
325
|
}
|
|
326
326
|
),
|
|
327
327
|
document.body
|
|
328
328
|
);
|
|
329
329
|
}
|
|
330
|
-
function
|
|
331
|
-
const
|
|
332
|
-
return /* @__PURE__ */
|
|
333
|
-
/* @__PURE__ */
|
|
330
|
+
function pi({ value: t, onChange: n, onPick: i, onBlur: o, onKeyDown: u, min: d, max: a, locale: g, invalid: m, label: x, theme: E, className: b, style: v }) {
|
|
331
|
+
const p = j(null);
|
|
332
|
+
return /* @__PURE__ */ I(tt, { children: [
|
|
333
|
+
/* @__PURE__ */ h(
|
|
334
334
|
"input",
|
|
335
335
|
{
|
|
336
|
-
ref:
|
|
336
|
+
ref: p,
|
|
337
337
|
autoFocus: !0,
|
|
338
338
|
type: "text",
|
|
339
339
|
inputMode: "numeric",
|
|
340
340
|
placeholder: "YYYY-MM-DD",
|
|
341
341
|
autoComplete: "off",
|
|
342
|
-
className:
|
|
343
|
-
style:
|
|
344
|
-
value:
|
|
345
|
-
"aria-label":
|
|
346
|
-
"aria-invalid":
|
|
342
|
+
className: b,
|
|
343
|
+
style: v,
|
|
344
|
+
value: t,
|
|
345
|
+
"aria-label": x,
|
|
346
|
+
"aria-invalid": m || void 0,
|
|
347
347
|
"aria-haspopup": "dialog",
|
|
348
348
|
"aria-expanded": !0,
|
|
349
|
-
onChange: (
|
|
350
|
-
onBlur:
|
|
351
|
-
onKeyDown: (
|
|
352
|
-
const
|
|
353
|
-
if (!
|
|
354
|
-
|
|
355
|
-
const
|
|
356
|
-
let
|
|
357
|
-
|
|
349
|
+
onChange: (D) => n(D.target.value.trim()),
|
|
350
|
+
onBlur: o,
|
|
351
|
+
onKeyDown: (D) => {
|
|
352
|
+
const C = D.ctrlKey || D.altKey || D.metaKey, T = D.key === "ArrowUp" ? { days: -7, months: 0 } : D.key === "ArrowDown" ? { days: 7, months: 0 } : C && D.key === "ArrowLeft" ? { days: -1, months: 0 } : C && D.key === "ArrowRight" ? { days: 1, months: 0 } : D.key === "PageUp" ? { days: 0, months: -1 } : D.key === "PageDown" ? { days: 0, months: 1 } : null;
|
|
353
|
+
if (!T || D.shiftKey) return u(D);
|
|
354
|
+
D.preventDefault();
|
|
355
|
+
const w = se(t) ?? /* @__PURE__ */ new Date(), P = new Date(w.getFullYear(), w.getMonth() + T.months + 1, 0).getDate(), X = new Date(w.getFullYear(), w.getMonth() + T.months, Math.min(w.getDate(), P) + T.days);
|
|
356
|
+
let q = he(X);
|
|
357
|
+
d && q < d && (q = d), a && q > a && (q = a), n(q);
|
|
358
358
|
},
|
|
359
|
-
onFocus: (
|
|
359
|
+
onFocus: (D) => D.currentTarget.setSelectionRange(D.currentTarget.value.length, D.currentTarget.value.length)
|
|
360
360
|
}
|
|
361
361
|
),
|
|
362
|
-
/* @__PURE__ */
|
|
363
|
-
}, label:
|
|
362
|
+
/* @__PURE__ */ h(yn, { anchorRef: p, open: !0, onClose: () => {
|
|
363
|
+
}, label: x, theme: E, className: "rg-date-popup", keepFocus: !0, children: /* @__PURE__ */ h(lo, { value: t, min: d, max: a, locale: g, onPick: i, keepFocus: !0 }) })
|
|
364
364
|
] });
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
return
|
|
366
|
+
function Kr(t) {
|
|
367
|
+
return t.filterType ? t.filterType : t.type === "number" ? "number" : t.type === "date" ? "date" : t.type === "boolean" ? "select" : "text";
|
|
368
|
+
}
|
|
369
|
+
const zr = [
|
|
370
|
+
"contains",
|
|
371
|
+
"notContains",
|
|
372
|
+
"equals",
|
|
373
|
+
"notEquals",
|
|
374
|
+
"startsWith",
|
|
375
|
+
"notStartsWith",
|
|
376
|
+
"endsWith",
|
|
377
|
+
"notEndsWith"
|
|
378
|
+
], qr = {
|
|
379
|
+
contains: "Contains",
|
|
380
|
+
notContains: "Does not contain",
|
|
381
|
+
equals: "Equals",
|
|
382
|
+
notEquals: "Not equal",
|
|
383
|
+
startsWith: "Starts with",
|
|
384
|
+
notStartsWith: "Does not start with",
|
|
385
|
+
endsWith: "Ends with",
|
|
386
|
+
notEndsWith: "Does not end with"
|
|
387
|
+
};
|
|
388
|
+
function ao(t) {
|
|
389
|
+
const n = t.filterOperators;
|
|
390
|
+
if (!n) return null;
|
|
391
|
+
if (n === !0) return zr;
|
|
392
|
+
const i = zr.filter((o) => n.includes(o));
|
|
393
|
+
return i.length > 0 ? i : null;
|
|
394
|
+
}
|
|
395
|
+
function gi(t, n) {
|
|
396
|
+
const i = ao(t), o = t.filterOperator ?? (n === "exact" ? "equals" : "contains");
|
|
397
|
+
return i && !i.includes(o) ? i[0] : o;
|
|
398
|
+
}
|
|
399
|
+
function Yr(t, n, i) {
|
|
400
|
+
const o = n.toLowerCase(), u = i.trim().toLowerCase();
|
|
401
|
+
switch (t) {
|
|
402
|
+
case "contains":
|
|
403
|
+
return o.includes(u);
|
|
404
|
+
case "notContains":
|
|
405
|
+
return !o.includes(u);
|
|
406
|
+
case "equals":
|
|
407
|
+
return o === u;
|
|
408
|
+
case "notEquals":
|
|
409
|
+
return o !== u;
|
|
410
|
+
case "startsWith":
|
|
411
|
+
return o.startsWith(u);
|
|
412
|
+
case "notStartsWith":
|
|
413
|
+
return !o.startsWith(u);
|
|
414
|
+
case "endsWith":
|
|
415
|
+
return o.endsWith(u);
|
|
416
|
+
case "notEndsWith":
|
|
417
|
+
return !o.endsWith(u);
|
|
418
|
+
}
|
|
368
419
|
}
|
|
369
|
-
const
|
|
370
|
-
function
|
|
371
|
-
if (
|
|
372
|
-
if (typeof
|
|
373
|
-
if (Array.isArray(
|
|
374
|
-
if (
|
|
375
|
-
const n =
|
|
376
|
-
return typeof n.min == "number" || typeof n.max == "number" || !!n.from || !!n.to;
|
|
420
|
+
const co = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
|
|
421
|
+
function uo(t) {
|
|
422
|
+
if (t == null) return !1;
|
|
423
|
+
if (typeof t == "string") return t.trim() !== "";
|
|
424
|
+
if (Array.isArray(t)) return t.length > 0;
|
|
425
|
+
if (co(t)) {
|
|
426
|
+
const n = t;
|
|
427
|
+
return typeof n.operator == "string" ? typeof n.value == "string" && n.value.trim() !== "" : typeof n.min == "number" || typeof n.max == "number" || !!n.from || !!n.to;
|
|
377
428
|
}
|
|
378
429
|
return !1;
|
|
379
430
|
}
|
|
380
|
-
function
|
|
381
|
-
switch (
|
|
431
|
+
function mi(t, n, i, o) {
|
|
432
|
+
switch (t) {
|
|
382
433
|
case "text":
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
434
|
+
case "exact": {
|
|
435
|
+
if (co(n)) {
|
|
436
|
+
const u = n;
|
|
437
|
+
return Yr(u.operator, i, String(u.value ?? ""));
|
|
438
|
+
}
|
|
439
|
+
return Yr(t === "exact" ? "equals" : "contains", i, String(n));
|
|
440
|
+
}
|
|
386
441
|
case "number": {
|
|
387
|
-
const { min:
|
|
388
|
-
return Number.isNaN(
|
|
442
|
+
const { min: u, max: d } = n, a = typeof o == "number" ? o : o == null || o === "" ? NaN : Number(o);
|
|
443
|
+
return Number.isNaN(a) ? !1 : (typeof u != "number" || a >= u) && (typeof d != "number" || a <= d);
|
|
389
444
|
}
|
|
390
445
|
case "date": {
|
|
391
|
-
const { from:
|
|
392
|
-
return
|
|
446
|
+
const { from: u, to: d } = n, a = he(o);
|
|
447
|
+
return a ? (!u || a >= u) && (!d || a <= d) : !1;
|
|
393
448
|
}
|
|
394
449
|
case "select":
|
|
395
|
-
return n.includes(String(
|
|
450
|
+
return n.includes(String(o ?? ""));
|
|
396
451
|
}
|
|
397
452
|
}
|
|
398
|
-
function
|
|
399
|
-
if (
|
|
400
|
-
if (
|
|
453
|
+
function bi(t, n, i, o) {
|
|
454
|
+
if (t.filterOptions) return t.filterOptions.map((d) => typeof d == "string" ? { value: d, label: d } : d);
|
|
455
|
+
if (t.type === "boolean")
|
|
401
456
|
return [
|
|
402
457
|
{ value: "true", label: "Yes" },
|
|
403
458
|
{ value: "false", label: "No" }
|
|
404
459
|
];
|
|
405
|
-
const
|
|
406
|
-
for (const
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
409
|
-
const
|
|
410
|
-
|
|
460
|
+
const u = /* @__PURE__ */ new Map();
|
|
461
|
+
for (const d of n) {
|
|
462
|
+
const a = i(d);
|
|
463
|
+
if (a == null || a === "") continue;
|
|
464
|
+
const g = String(a);
|
|
465
|
+
u.has(g) || u.set(g, o(d));
|
|
411
466
|
}
|
|
412
|
-
return [...
|
|
467
|
+
return [...u].map(([d, a]) => ({ value: d, label: a })).sort((d, a) => d.label.localeCompare(a.label, void 0, { numeric: !0 }));
|
|
413
468
|
}
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
416
|
-
const n = Number(
|
|
469
|
+
const Vr = (t) => {
|
|
470
|
+
if (t.trim() === "") return;
|
|
471
|
+
const n = Number(t);
|
|
417
472
|
return Number.isFinite(n) ? n : void 0;
|
|
418
|
-
},
|
|
419
|
-
function
|
|
420
|
-
value:
|
|
473
|
+
}, qn = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
|
|
474
|
+
function yi({
|
|
475
|
+
value: t,
|
|
421
476
|
onChange: n,
|
|
422
|
-
label:
|
|
423
|
-
debounce:
|
|
424
|
-
inputClassName:
|
|
425
|
-
inputStyle:
|
|
477
|
+
label: i,
|
|
478
|
+
debounce: o,
|
|
479
|
+
inputClassName: u,
|
|
480
|
+
inputStyle: d
|
|
426
481
|
}) {
|
|
427
|
-
const
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
},
|
|
431
|
-
return
|
|
432
|
-
|
|
433
|
-
}, [
|
|
434
|
-
/* @__PURE__ */
|
|
435
|
-
/* @__PURE__ */
|
|
436
|
-
/* @__PURE__ */
|
|
482
|
+
const a = qn(t) ? t : {}, [g, m] = z(a.min === void 0 ? "" : String(a.min)), [x, E] = z(a.max === void 0 ? "" : String(a.max)), b = j(a), v = so((p, k) => {
|
|
483
|
+
const D = Vr(p), C = Vr(k);
|
|
484
|
+
b.current = { min: D, max: C }, n(D === void 0 && C === void 0 ? void 0 : { min: D, max: C });
|
|
485
|
+
}, o);
|
|
486
|
+
return ne(() => {
|
|
487
|
+
a.min === b.current.min && a.max === b.current.max || (b.current = a, v.cancel(), m(a.min === void 0 ? "" : String(a.min)), E(a.max === void 0 ? "" : String(a.max)));
|
|
488
|
+
}, [a.min, a.max]), /* @__PURE__ */ I("div", { className: "rg-grid__filter-fields", children: [
|
|
489
|
+
/* @__PURE__ */ I("label", { className: "rg-grid__filter-field", children: [
|
|
490
|
+
/* @__PURE__ */ h("span", { children: "Min" }),
|
|
491
|
+
/* @__PURE__ */ h(
|
|
437
492
|
"input",
|
|
438
493
|
{
|
|
439
494
|
autoFocus: !0,
|
|
440
495
|
type: "number",
|
|
441
|
-
className:
|
|
442
|
-
style:
|
|
443
|
-
value:
|
|
444
|
-
"aria-label": `Minimum ${
|
|
445
|
-
onChange: (
|
|
446
|
-
|
|
496
|
+
className: U("rg-grid__filter-input", u),
|
|
497
|
+
style: d,
|
|
498
|
+
value: g,
|
|
499
|
+
"aria-label": `Minimum ${i}`,
|
|
500
|
+
onChange: (p) => {
|
|
501
|
+
m(p.target.value), v.call(p.target.value, x);
|
|
447
502
|
},
|
|
448
|
-
onKeyDown: (
|
|
503
|
+
onKeyDown: (p) => p.key === "Enter" && v.flush()
|
|
449
504
|
}
|
|
450
505
|
)
|
|
451
506
|
] }),
|
|
452
|
-
/* @__PURE__ */
|
|
453
|
-
/* @__PURE__ */
|
|
454
|
-
/* @__PURE__ */
|
|
507
|
+
/* @__PURE__ */ I("label", { className: "rg-grid__filter-field", children: [
|
|
508
|
+
/* @__PURE__ */ h("span", { children: "Max" }),
|
|
509
|
+
/* @__PURE__ */ h(
|
|
455
510
|
"input",
|
|
456
511
|
{
|
|
457
512
|
type: "number",
|
|
458
|
-
className:
|
|
459
|
-
style:
|
|
460
|
-
value:
|
|
461
|
-
"aria-label": `Maximum ${
|
|
462
|
-
onChange: (
|
|
463
|
-
|
|
513
|
+
className: U("rg-grid__filter-input", u),
|
|
514
|
+
style: d,
|
|
515
|
+
value: x,
|
|
516
|
+
"aria-label": `Maximum ${i}`,
|
|
517
|
+
onChange: (p) => {
|
|
518
|
+
E(p.target.value), v.call(g, p.target.value);
|
|
464
519
|
},
|
|
465
|
-
onKeyDown: (
|
|
520
|
+
onKeyDown: (p) => p.key === "Enter" && v.flush()
|
|
466
521
|
}
|
|
467
522
|
)
|
|
468
523
|
] })
|
|
469
524
|
] });
|
|
470
525
|
}
|
|
471
|
-
function
|
|
472
|
-
value:
|
|
526
|
+
function xi({
|
|
527
|
+
value: t,
|
|
473
528
|
onChange: n,
|
|
474
|
-
onEnter:
|
|
475
|
-
label:
|
|
476
|
-
kind:
|
|
477
|
-
placeholder:
|
|
478
|
-
debounce:
|
|
479
|
-
inputClassName:
|
|
480
|
-
inputStyle:
|
|
529
|
+
onEnter: i,
|
|
530
|
+
label: o,
|
|
531
|
+
kind: u,
|
|
532
|
+
placeholder: d,
|
|
533
|
+
debounce: a,
|
|
534
|
+
inputClassName: g,
|
|
535
|
+
inputStyle: m
|
|
481
536
|
}) {
|
|
482
|
-
const [
|
|
483
|
-
|
|
484
|
-
},
|
|
485
|
-
return
|
|
486
|
-
|
|
487
|
-
}, [
|
|
537
|
+
const [x, E] = z(t), b = j(t), v = so((p) => {
|
|
538
|
+
b.current = p, n(p || void 0);
|
|
539
|
+
}, a);
|
|
540
|
+
return ne(() => {
|
|
541
|
+
t !== b.current && (b.current = t, v.cancel(), E(t));
|
|
542
|
+
}, [t]), /* @__PURE__ */ h(
|
|
488
543
|
"input",
|
|
489
544
|
{
|
|
490
545
|
autoFocus: !0,
|
|
491
546
|
type: "text",
|
|
492
|
-
className:
|
|
493
|
-
style:
|
|
494
|
-
value:
|
|
495
|
-
placeholder:
|
|
496
|
-
"aria-label": `Filter text for ${
|
|
497
|
-
onChange: (
|
|
498
|
-
|
|
547
|
+
className: U("rg-grid__filter-input", g),
|
|
548
|
+
style: m,
|
|
549
|
+
value: x,
|
|
550
|
+
placeholder: d ?? (u === "exact" ? "Exactly…" : `Filter ${o}…`),
|
|
551
|
+
"aria-label": `Filter text for ${o}`,
|
|
552
|
+
onChange: (p) => {
|
|
553
|
+
E(p.target.value), v.call(p.target.value);
|
|
499
554
|
},
|
|
500
|
-
onKeyDown: (
|
|
501
|
-
|
|
555
|
+
onKeyDown: (p) => {
|
|
556
|
+
p.key === "Enter" && (p.preventDefault(), v.flush(), i());
|
|
502
557
|
}
|
|
503
558
|
}
|
|
504
559
|
);
|
|
505
560
|
}
|
|
506
|
-
function
|
|
507
|
-
value:
|
|
561
|
+
function _i({
|
|
562
|
+
value: t,
|
|
508
563
|
onChange: n,
|
|
509
|
-
label:
|
|
510
|
-
inputClassName:
|
|
511
|
-
inputStyle:
|
|
512
|
-
min:
|
|
513
|
-
max:
|
|
514
|
-
locale:
|
|
564
|
+
label: i,
|
|
565
|
+
inputClassName: o,
|
|
566
|
+
inputStyle: u,
|
|
567
|
+
min: d,
|
|
568
|
+
max: a,
|
|
569
|
+
locale: g
|
|
515
570
|
}) {
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
(
|
|
519
|
-
}, [
|
|
520
|
-
const
|
|
521
|
-
if ((
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
},
|
|
525
|
-
|
|
526
|
-
},
|
|
527
|
-
/* @__PURE__ */
|
|
528
|
-
/* @__PURE__ */
|
|
571
|
+
const m = qn(t) ? t : {}, x = (T, w) => n(!T && !w ? void 0 : { from: T || void 0, to: w || void 0 }), [E, b] = z(m.from ?? ""), [v, p] = z(m.to ?? "");
|
|
572
|
+
ne(() => {
|
|
573
|
+
(se(E) ? E : "") !== (m.from ?? "") && b(m.from ?? ""), (se(v) ? v : "") !== (m.to ?? "") && p(m.to ?? "");
|
|
574
|
+
}, [m.from, m.to]);
|
|
575
|
+
const k = (T, w) => {
|
|
576
|
+
if ((T === "from" ? b : p)(w), w !== "" && !se(w)) return;
|
|
577
|
+
const P = w || void 0;
|
|
578
|
+
T === "from" ? x(P, m.to) : x(m.from, P);
|
|
579
|
+
}, D = (T) => {
|
|
580
|
+
T && (!m.from || m.to ? x(T, void 0) : T < m.from ? x(T, m.from) : x(m.from, T));
|
|
581
|
+
}, C = (T, w, P) => /* @__PURE__ */ I("label", { className: "rg-grid__filter-field", children: [
|
|
582
|
+
/* @__PURE__ */ h("span", { children: T === "from" ? "From" : "To" }),
|
|
583
|
+
/* @__PURE__ */ h(
|
|
529
584
|
"input",
|
|
530
585
|
{
|
|
531
|
-
autoFocus:
|
|
586
|
+
autoFocus: P,
|
|
532
587
|
type: "text",
|
|
533
588
|
inputMode: "numeric",
|
|
534
589
|
placeholder: "YYYY-MM-DD",
|
|
535
|
-
className:
|
|
536
|
-
style:
|
|
537
|
-
value:
|
|
538
|
-
"aria-label": `${
|
|
539
|
-
"aria-invalid":
|
|
540
|
-
onChange: (
|
|
590
|
+
className: U("rg-grid__filter-input", w !== "" && !se(w) && "rg-grid__filter-input--invalid", o),
|
|
591
|
+
style: u,
|
|
592
|
+
value: w,
|
|
593
|
+
"aria-label": `${i} ${T}`,
|
|
594
|
+
"aria-invalid": w !== "" && !se(w) || void 0,
|
|
595
|
+
onChange: (X) => k(T, X.target.value.trim())
|
|
541
596
|
}
|
|
542
597
|
)
|
|
543
598
|
] });
|
|
544
|
-
return /* @__PURE__ */
|
|
545
|
-
/* @__PURE__ */
|
|
546
|
-
|
|
547
|
-
|
|
599
|
+
return /* @__PURE__ */ I("div", { className: "rg-grid__filter-fields rg-grid__filter-fields--stack", children: [
|
|
600
|
+
/* @__PURE__ */ I("div", { className: "rg-grid__filter-date-row", children: [
|
|
601
|
+
C("from", E, !0),
|
|
602
|
+
C("to", v, !1)
|
|
548
603
|
] }),
|
|
549
|
-
/* @__PURE__ */
|
|
604
|
+
/* @__PURE__ */ h(lo, { range: m, min: d, max: a, locale: g, onPick: D, hideFooter: !0 })
|
|
550
605
|
] });
|
|
551
606
|
}
|
|
552
|
-
function
|
|
553
|
-
value:
|
|
607
|
+
function wi({
|
|
608
|
+
value: t,
|
|
554
609
|
onChange: n,
|
|
555
|
-
options:
|
|
610
|
+
options: i
|
|
556
611
|
}) {
|
|
557
|
-
const
|
|
558
|
-
const
|
|
559
|
-
n(
|
|
612
|
+
const o = Array.isArray(t) ? t : [], u = (d, a) => {
|
|
613
|
+
const g = a ? [...o, d] : o.filter((m) => m !== d);
|
|
614
|
+
n(g.length ? g : void 0);
|
|
560
615
|
};
|
|
561
|
-
return /* @__PURE__ */
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
616
|
+
return /* @__PURE__ */ I("div", { className: "rg-grid__filter-fields rg-grid__filter-options", role: "group", children: [
|
|
617
|
+
i.length === 0 && /* @__PURE__ */ h("span", { className: "rg-grid__filter-empty", children: "No values" }),
|
|
618
|
+
i.map((d) => /* @__PURE__ */ h(
|
|
619
|
+
ht,
|
|
565
620
|
{
|
|
566
|
-
checked:
|
|
567
|
-
onChange: (
|
|
568
|
-
label:
|
|
621
|
+
checked: o.includes(d.value),
|
|
622
|
+
onChange: (a) => u(d.value, a),
|
|
623
|
+
label: d.label ?? d.value
|
|
569
624
|
},
|
|
570
|
-
|
|
625
|
+
d.value
|
|
571
626
|
))
|
|
572
627
|
] });
|
|
573
628
|
}
|
|
574
|
-
function
|
|
575
|
-
|
|
629
|
+
function vi({
|
|
630
|
+
value: t,
|
|
631
|
+
options: n,
|
|
632
|
+
onChange: i,
|
|
633
|
+
label: o
|
|
634
|
+
}) {
|
|
635
|
+
const [u, d] = z(!1), [a, g] = z(0), m = si(), x = j(null), E = () => {
|
|
636
|
+
g(Math.max(0, n.indexOf(t))), d(!0);
|
|
637
|
+
}, b = (p) => {
|
|
638
|
+
var k;
|
|
639
|
+
i(p), d(!1), (k = x.current) == null || k.focus();
|
|
640
|
+
}, v = (p) => {
|
|
641
|
+
if (!u) {
|
|
642
|
+
(p.key === "ArrowDown" || p.key === "ArrowUp") && (p.preventDefault(), E());
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
switch (p.key) {
|
|
646
|
+
case "ArrowDown":
|
|
647
|
+
p.preventDefault(), g((k) => Math.min(n.length - 1, k + 1));
|
|
648
|
+
break;
|
|
649
|
+
case "ArrowUp":
|
|
650
|
+
p.preventDefault(), g((k) => Math.max(0, k - 1));
|
|
651
|
+
break;
|
|
652
|
+
case "Home":
|
|
653
|
+
p.preventDefault(), g(0);
|
|
654
|
+
break;
|
|
655
|
+
case "End":
|
|
656
|
+
p.preventDefault(), g(n.length - 1);
|
|
657
|
+
break;
|
|
658
|
+
case "Enter":
|
|
659
|
+
case " ":
|
|
660
|
+
p.preventDefault(), b(n[a]);
|
|
661
|
+
break;
|
|
662
|
+
case "Escape":
|
|
663
|
+
p.preventDefault(), p.stopPropagation(), d(!1);
|
|
664
|
+
break;
|
|
665
|
+
case "Tab":
|
|
666
|
+
d(!1);
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
return /* @__PURE__ */ I("div", { className: "rg-op", children: [
|
|
671
|
+
/* @__PURE__ */ I(
|
|
672
|
+
"button",
|
|
673
|
+
{
|
|
674
|
+
ref: x,
|
|
675
|
+
type: "button",
|
|
676
|
+
className: "rg-op__btn",
|
|
677
|
+
role: "combobox",
|
|
678
|
+
"aria-label": `Comparison for ${o}`,
|
|
679
|
+
"aria-haspopup": "listbox",
|
|
680
|
+
"aria-expanded": u,
|
|
681
|
+
"aria-controls": u ? m : void 0,
|
|
682
|
+
"aria-activedescendant": u ? `${m}-${a}` : void 0,
|
|
683
|
+
onClick: () => u ? d(!1) : E(),
|
|
684
|
+
onBlur: () => d(!1),
|
|
685
|
+
onKeyDown: v,
|
|
686
|
+
children: [
|
|
687
|
+
/* @__PURE__ */ h("span", { className: "rg-op__value", children: qr[t] }),
|
|
688
|
+
/* @__PURE__ */ h("svg", { className: "rg-op__chevron", width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ h("path", { d: "M2.5 4.5 6 8l3.5-3.5" }) })
|
|
689
|
+
]
|
|
690
|
+
}
|
|
691
|
+
),
|
|
692
|
+
u && // mousedown must not move focus away from the button, or onBlur would close the list before the click lands
|
|
693
|
+
/* @__PURE__ */ h("ul", { id: m, role: "listbox", className: "rg-op__list", "aria-label": `Comparisons for ${o}`, onMouseDown: (p) => p.preventDefault(), children: n.map((p, k) => /* @__PURE__ */ I(
|
|
694
|
+
"li",
|
|
695
|
+
{
|
|
696
|
+
id: `${m}-${k}`,
|
|
697
|
+
role: "option",
|
|
698
|
+
"aria-selected": p === t,
|
|
699
|
+
"data-op": p,
|
|
700
|
+
className: U("rg-op__option", p === t && "rg-op__option--selected", k === a && "rg-op__option--active"),
|
|
701
|
+
onMouseEnter: () => g(k),
|
|
702
|
+
onClick: () => b(p),
|
|
703
|
+
children: [
|
|
704
|
+
qr[p],
|
|
705
|
+
p === t && /* @__PURE__ */ h("svg", { className: "rg-op__check", width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ h("path", { d: "M2.5 6.5 5 9l4.5-5.5" }) })
|
|
706
|
+
]
|
|
707
|
+
},
|
|
708
|
+
p
|
|
709
|
+
)) })
|
|
710
|
+
] });
|
|
711
|
+
}
|
|
712
|
+
function ki({
|
|
713
|
+
column: t,
|
|
576
714
|
label: n,
|
|
577
|
-
kind:
|
|
578
|
-
value:
|
|
579
|
-
onChange:
|
|
580
|
-
options:
|
|
581
|
-
debounce:
|
|
582
|
-
theme:
|
|
583
|
-
indicatorClassName:
|
|
584
|
-
indicatorStyle:
|
|
585
|
-
popupClassName:
|
|
586
|
-
popupStyle:
|
|
587
|
-
inputClassName:
|
|
588
|
-
inputStyle:
|
|
715
|
+
kind: i,
|
|
716
|
+
value: o,
|
|
717
|
+
onChange: u,
|
|
718
|
+
options: d,
|
|
719
|
+
debounce: a = 300,
|
|
720
|
+
theme: g,
|
|
721
|
+
indicatorClassName: m,
|
|
722
|
+
indicatorStyle: x,
|
|
723
|
+
popupClassName: E,
|
|
724
|
+
popupStyle: b,
|
|
725
|
+
inputClassName: v,
|
|
726
|
+
inputStyle: p
|
|
589
727
|
}) {
|
|
590
|
-
const [
|
|
591
|
-
if (
|
|
592
|
-
|
|
593
|
-
|
|
728
|
+
const [k, D] = z(!1), C = j(null), T = uo(o), w = Fe(() => D(!1), []), P = qn(o) ? o : null, X = typeof o == "string" ? o : typeof (P == null ? void 0 : P.value) == "string" ? P.value : "", q = (i === "text" || i === "exact") && !t.filterRenderer ? ao(t) : null, [R, H] = z(() => gi(t, i)), Se = P && typeof P.operator == "string" ? P.operator : R, Pe = (V) => {
|
|
729
|
+
if (V === void 0) return u(void 0);
|
|
730
|
+
u(q ? { operator: Se, value: String(V) } : V);
|
|
731
|
+
}, ze = (V) => {
|
|
732
|
+
H(V), X.trim() !== "" && u({ operator: V, value: X });
|
|
733
|
+
}, Ee = () => {
|
|
734
|
+
if (t.filterRenderer)
|
|
735
|
+
return Ke(t.filterRenderer, { column: t, value: X, onChange: (V) => u(V || void 0) });
|
|
736
|
+
switch (i) {
|
|
594
737
|
case "number":
|
|
595
|
-
return /* @__PURE__ */
|
|
738
|
+
return /* @__PURE__ */ h(yi, { value: o, onChange: u, label: n, debounce: a, inputClassName: v, inputStyle: p });
|
|
596
739
|
case "date":
|
|
597
|
-
return /* @__PURE__ */
|
|
740
|
+
return /* @__PURE__ */ h(_i, { value: o, onChange: u, label: n, min: t.dateMin, max: t.dateMax, locale: t.dateLocale, inputClassName: v, inputStyle: p });
|
|
598
741
|
case "select":
|
|
599
|
-
return /* @__PURE__ */
|
|
742
|
+
return /* @__PURE__ */ h(wi, { value: o, onChange: u, options: d });
|
|
600
743
|
default:
|
|
601
|
-
return /* @__PURE__ */
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
744
|
+
return /* @__PURE__ */ I("div", { className: "rg-grid__filter-stack", children: [
|
|
745
|
+
q && /* @__PURE__ */ h(vi, { value: Se, options: q, onChange: ze, label: n }),
|
|
746
|
+
/* @__PURE__ */ h(
|
|
747
|
+
xi,
|
|
748
|
+
{
|
|
749
|
+
value: X,
|
|
750
|
+
onChange: Pe,
|
|
751
|
+
onEnter: () => {
|
|
752
|
+
var V;
|
|
753
|
+
D(!1), (V = C.current) == null || V.focus();
|
|
754
|
+
},
|
|
755
|
+
label: n,
|
|
756
|
+
kind: i,
|
|
757
|
+
placeholder: t.filterPlaceholder,
|
|
758
|
+
debounce: a,
|
|
759
|
+
inputClassName: v,
|
|
760
|
+
inputStyle: p
|
|
761
|
+
}
|
|
762
|
+
)
|
|
763
|
+
] });
|
|
618
764
|
}
|
|
619
765
|
};
|
|
620
|
-
return /* @__PURE__ */
|
|
621
|
-
/* @__PURE__ */
|
|
766
|
+
return /* @__PURE__ */ I(tt, { children: [
|
|
767
|
+
/* @__PURE__ */ h(
|
|
622
768
|
"button",
|
|
623
769
|
{
|
|
624
|
-
ref:
|
|
770
|
+
ref: C,
|
|
625
771
|
type: "button",
|
|
626
|
-
className:
|
|
772
|
+
className: U(
|
|
627
773
|
"rg-grid__filter-btn",
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
774
|
+
T && "rg-grid__filter-btn--active",
|
|
775
|
+
k && "rg-grid__filter-btn--open",
|
|
776
|
+
m
|
|
631
777
|
),
|
|
632
|
-
style:
|
|
778
|
+
style: x,
|
|
633
779
|
"aria-label": `Filter ${n}`,
|
|
634
780
|
"aria-haspopup": "dialog",
|
|
635
|
-
"aria-expanded":
|
|
636
|
-
"data-active":
|
|
637
|
-
onClick: (
|
|
638
|
-
|
|
781
|
+
"aria-expanded": k,
|
|
782
|
+
"data-active": T || void 0,
|
|
783
|
+
onClick: (V) => {
|
|
784
|
+
V.stopPropagation(), D((ae) => !ae);
|
|
639
785
|
},
|
|
640
|
-
onKeyDown: (
|
|
641
|
-
children:
|
|
786
|
+
onKeyDown: (V) => V.stopPropagation(),
|
|
787
|
+
children: t.filterIndicator ? Ke(t.filterIndicator, { column: t, active: T, open: k }) : /* @__PURE__ */ h("span", { className: "rg-grid__filter-dot", "aria-hidden": "true" })
|
|
642
788
|
}
|
|
643
789
|
),
|
|
644
|
-
/* @__PURE__ */
|
|
645
|
-
|
|
790
|
+
/* @__PURE__ */ I(
|
|
791
|
+
yn,
|
|
646
792
|
{
|
|
647
|
-
anchorRef:
|
|
648
|
-
open:
|
|
649
|
-
onClose:
|
|
793
|
+
anchorRef: C,
|
|
794
|
+
open: k,
|
|
795
|
+
onClose: w,
|
|
650
796
|
label: `Filter ${n}`,
|
|
651
|
-
theme:
|
|
652
|
-
className:
|
|
653
|
-
style:
|
|
797
|
+
theme: g,
|
|
798
|
+
className: E,
|
|
799
|
+
style: b,
|
|
654
800
|
children: [
|
|
655
|
-
|
|
656
|
-
|
|
801
|
+
Ee(),
|
|
802
|
+
T && /* @__PURE__ */ h("button", { type: "button", className: "rg-grid__filter-clear", onClick: () => u(void 0), children: "Clear" })
|
|
657
803
|
]
|
|
658
804
|
}
|
|
659
805
|
)
|
|
660
806
|
] });
|
|
661
807
|
}
|
|
662
|
-
function
|
|
663
|
-
const [
|
|
664
|
-
return /* @__PURE__ */
|
|
665
|
-
/* @__PURE__ */
|
|
808
|
+
function Si({ columns: t, hidden: n, onToggle: i, theme: o, className: u, style: d }) {
|
|
809
|
+
const [a, g] = z(!1), m = j(null), x = Fe(() => g(!1), []), E = t.filter((b) => !n.has(b.field)).length;
|
|
810
|
+
return /* @__PURE__ */ I(tt, { children: [
|
|
811
|
+
/* @__PURE__ */ h(
|
|
666
812
|
"button",
|
|
667
813
|
{
|
|
668
|
-
ref:
|
|
814
|
+
ref: m,
|
|
669
815
|
type: "button",
|
|
670
|
-
className:
|
|
671
|
-
style:
|
|
816
|
+
className: U("rg-grid__tool-btn", u),
|
|
817
|
+
style: d,
|
|
672
818
|
"aria-haspopup": "dialog",
|
|
673
|
-
"aria-expanded":
|
|
674
|
-
onClick: () =>
|
|
819
|
+
"aria-expanded": a,
|
|
820
|
+
onClick: () => g((b) => !b),
|
|
675
821
|
children: "Columns"
|
|
676
822
|
}
|
|
677
823
|
),
|
|
678
|
-
/* @__PURE__ */
|
|
679
|
-
const
|
|
680
|
-
return /* @__PURE__ */
|
|
681
|
-
|
|
824
|
+
/* @__PURE__ */ h(yn, { anchorRef: m, open: a, onClose: x, label: "Show or hide columns", theme: o, children: /* @__PURE__ */ h("div", { className: "rg-grid__filter-fields rg-grid__filter-options", role: "group", "aria-label": "Columns", children: t.filter((b) => b.hideable !== !1).map((b) => {
|
|
825
|
+
const v = !n.has(b.field);
|
|
826
|
+
return /* @__PURE__ */ h(
|
|
827
|
+
ht,
|
|
682
828
|
{
|
|
683
|
-
checked:
|
|
684
|
-
disabled:
|
|
685
|
-
onChange: (
|
|
686
|
-
label:
|
|
829
|
+
checked: v,
|
|
830
|
+
disabled: v && E <= 1,
|
|
831
|
+
onChange: (p) => i(b.field, !p),
|
|
832
|
+
label: et(b)
|
|
687
833
|
},
|
|
688
|
-
|
|
834
|
+
b.field
|
|
689
835
|
);
|
|
690
836
|
}) }) })
|
|
691
837
|
] });
|
|
692
838
|
}
|
|
693
|
-
const
|
|
694
|
-
function
|
|
695
|
-
if (
|
|
696
|
-
let
|
|
697
|
-
return
|
|
839
|
+
const Ni = /^[=+\-@\t\r]/;
|
|
840
|
+
function Ci(t, n, i) {
|
|
841
|
+
if (t == null) return "";
|
|
842
|
+
let o = String(t);
|
|
843
|
+
return i && typeof t == "string" && Ni.test(o) && !Number.isFinite(Number(o)) && (o = `'${o}`), o.includes(n) || /["\r\n]/.test(o) ? `"${o.replace(/"/g, '""')}"` : o;
|
|
698
844
|
}
|
|
699
|
-
function
|
|
700
|
-
const { delimiter:
|
|
701
|
-
return [
|
|
845
|
+
function Di(t, n, i = {}) {
|
|
846
|
+
const { delimiter: o = ",", sanitize: u = !0 } = i, d = (a) => a.map((g) => Ci(g, o, u)).join(o);
|
|
847
|
+
return [d(t), ...n.map(d)].join(`\r
|
|
702
848
|
`);
|
|
703
849
|
}
|
|
704
|
-
function
|
|
850
|
+
function gn(t, n) {
|
|
705
851
|
if (typeof document > "u") return;
|
|
706
|
-
const
|
|
707
|
-
|
|
852
|
+
const i = URL.createObjectURL(t), o = document.createElement("a");
|
|
853
|
+
o.href = i, o.download = n, o.style.display = "none", document.body.appendChild(o), o.click(), o.remove(), setTimeout(() => URL.revokeObjectURL(i), 1e3);
|
|
854
|
+
}
|
|
855
|
+
function Ti(t, n) {
|
|
856
|
+
gn(new Blob(["\uFEFF", t], { type: "text/csv;charset=utf-8" }), n);
|
|
857
|
+
}
|
|
858
|
+
const fo = {
|
|
859
|
+
csv: "CSV",
|
|
860
|
+
xlsx: "Excel",
|
|
861
|
+
json: "JSON",
|
|
862
|
+
pdf: "PDF"
|
|
863
|
+
}, Fi = { csv: ".csv", xlsx: ".xlsx", json: ".json", pdf: ".pdf" }, Ei = (t) => `Export ${fo[t]}`;
|
|
864
|
+
function Ii({ formats: t, scopes: n, scope: i, onScopeChange: o, onExport: u, theme: d, className: a, style: g, popupClassName: m }) {
|
|
865
|
+
const [x, E] = z(!1), [b, v] = z(null), p = j(null), k = Fe(() => E(!1), []), D = async (C) => {
|
|
866
|
+
var T;
|
|
867
|
+
v(C);
|
|
868
|
+
try {
|
|
869
|
+
await u(C, i);
|
|
870
|
+
} finally {
|
|
871
|
+
v(null), E(!1), (T = p.current) == null || T.focus();
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
return /* @__PURE__ */ I(tt, { children: [
|
|
875
|
+
/* @__PURE__ */ I(
|
|
876
|
+
"button",
|
|
877
|
+
{
|
|
878
|
+
ref: p,
|
|
879
|
+
type: "button",
|
|
880
|
+
className: U("rg-grid__tool-btn", a),
|
|
881
|
+
style: g,
|
|
882
|
+
"aria-haspopup": "dialog",
|
|
883
|
+
"aria-expanded": x,
|
|
884
|
+
onClick: () => E((C) => !C),
|
|
885
|
+
children: [
|
|
886
|
+
"Export",
|
|
887
|
+
/* @__PURE__ */ h("svg", { className: "rg-export__chevron", width: "10", height: "10", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ h("path", { d: "M2.5 4.5 6 8l3.5-3.5" }) })
|
|
888
|
+
]
|
|
889
|
+
}
|
|
890
|
+
),
|
|
891
|
+
/* @__PURE__ */ h(yn, { anchorRef: p, open: x, onClose: k, label: "Export", theme: d, className: U("rg-export-popup", m), children: /* @__PURE__ */ I("div", { className: "rg-export", children: [
|
|
892
|
+
n.length > 1 && /* @__PURE__ */ I("div", { className: "rg-export__group", role: "radiogroup", "aria-label": "Rows to export", children: [
|
|
893
|
+
/* @__PURE__ */ h("div", { className: "rg-export__title", children: "Rows to export" }),
|
|
894
|
+
n.map((C) => {
|
|
895
|
+
const T = C.count === 0;
|
|
896
|
+
return /* @__PURE__ */ I("label", { className: U("rg-export__scope", T && "rg-export__scope--disabled", C.value === i && "rg-export__scope--on"), children: [
|
|
897
|
+
/* @__PURE__ */ h(
|
|
898
|
+
"input",
|
|
899
|
+
{
|
|
900
|
+
type: "radio",
|
|
901
|
+
name: "rg-export-scope",
|
|
902
|
+
value: C.value,
|
|
903
|
+
checked: C.value === i,
|
|
904
|
+
disabled: T,
|
|
905
|
+
onChange: () => o(C.value)
|
|
906
|
+
}
|
|
907
|
+
),
|
|
908
|
+
/* @__PURE__ */ h("span", { className: "rg-export__scope-label", children: C.label }),
|
|
909
|
+
/* @__PURE__ */ h("span", { className: "rg-export__count", children: C.count })
|
|
910
|
+
] }, C.value);
|
|
911
|
+
})
|
|
912
|
+
] }),
|
|
913
|
+
/* @__PURE__ */ I("div", { className: "rg-export__group", children: [
|
|
914
|
+
/* @__PURE__ */ h("div", { className: "rg-export__title", children: "Download as" }),
|
|
915
|
+
t.map((C) => /* @__PURE__ */ I(
|
|
916
|
+
"button",
|
|
917
|
+
{
|
|
918
|
+
type: "button",
|
|
919
|
+
className: "rg-export__format",
|
|
920
|
+
"data-format": C,
|
|
921
|
+
disabled: b !== null,
|
|
922
|
+
onClick: () => D(C),
|
|
923
|
+
children: [
|
|
924
|
+
/* @__PURE__ */ h("span", { children: fo[C] }),
|
|
925
|
+
/* @__PURE__ */ h("span", { className: "rg-export__ext", children: b === C ? "Preparing…" : Fi[C] })
|
|
926
|
+
]
|
|
927
|
+
},
|
|
928
|
+
C
|
|
929
|
+
))
|
|
930
|
+
] })
|
|
931
|
+
] }) })
|
|
932
|
+
] });
|
|
933
|
+
}
|
|
934
|
+
let we;
|
|
935
|
+
function fe(t) {
|
|
936
|
+
const n = (t ?? "").trim();
|
|
937
|
+
if (!n || n === "transparent" || n === "none") return null;
|
|
938
|
+
const i = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(n);
|
|
939
|
+
if (i) {
|
|
940
|
+
let x = i[1];
|
|
941
|
+
return x.length === 3 && (x = x.split("").map((E) => E + E).join("")), [parseInt(x.slice(0, 2), 16), parseInt(x.slice(2, 4), 16), parseInt(x.slice(4, 6), 16)];
|
|
942
|
+
}
|
|
943
|
+
const o = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i.exec(n);
|
|
944
|
+
if (o) return Hr([Number(o[1]), Number(o[2]), Number(o[3])], Mi(o[4]));
|
|
945
|
+
if (typeof document > "u" || (we === void 0 && (we = document.createElement("canvas").getContext("2d", { willReadFrequently: !0 })), !we)) return null;
|
|
946
|
+
we.fillStyle = "#000000", we.fillStyle = n;
|
|
947
|
+
const u = String(we.fillStyle);
|
|
948
|
+
if (we.fillStyle = "#ffffff", we.fillStyle = n, u !== String(we.fillStyle)) return null;
|
|
949
|
+
we.clearRect(0, 0, 1, 1), we.fillRect(0, 0, 1, 1);
|
|
950
|
+
const [d, a, g, m] = we.getImageData(0, 0, 1, 1).data;
|
|
951
|
+
return m === 0 ? null : Hr([d, a, g], m / 255);
|
|
708
952
|
}
|
|
709
|
-
const
|
|
710
|
-
function
|
|
711
|
-
if (
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
953
|
+
const Mi = (t) => t === void 0 ? 1 : t.endsWith("%") ? parseFloat(t) / 100 : parseFloat(t);
|
|
954
|
+
function Hr(t, n) {
|
|
955
|
+
if (!(n > 0)) return null;
|
|
956
|
+
const i = Math.min(1, n);
|
|
957
|
+
return t.map((o) => Math.round(Math.min(255, o) * i + 255 * (1 - i)));
|
|
958
|
+
}
|
|
959
|
+
const $i = ([t, n, i]) => (0.299 * t + 0.587 * n + 0.114 * i) / 255, An = (t) => $i(t) > 0.55 ? [31, 41, 55] : [243, 244, 246], Bn = 72 / 96, $t = "Install them with: npm install jspdf jspdf-autotable (and html2canvas for header / footer elements), then pass them in exportable.pdf.libraries.";
|
|
960
|
+
async function Xr(t, n) {
|
|
961
|
+
try {
|
|
962
|
+
return await n();
|
|
963
|
+
} catch (i) {
|
|
964
|
+
const o = i instanceof Error ? i.message : String(i);
|
|
965
|
+
throw new Error(`PDF export needs the package "${t}", which could not be loaded (${o}). ${$t}`);
|
|
717
966
|
}
|
|
718
|
-
return c;
|
|
719
967
|
}
|
|
720
|
-
function
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
968
|
+
function Gr(t, n, i) {
|
|
969
|
+
return t.replace(/\{page\}/g, String(n)).replace(/\{pages\}/g, String(i)).replace(/\{date\}/g, (/* @__PURE__ */ new Date()).toLocaleDateString());
|
|
970
|
+
}
|
|
971
|
+
async function Pi(t) {
|
|
972
|
+
const n = Array.from(t.querySelectorAll("img")).map(
|
|
973
|
+
(i) => i.complete ? Promise.resolve() : new Promise((o) => {
|
|
974
|
+
i.addEventListener("load", () => o(), { once: !0 }), i.addEventListener("error", () => o(), { once: !0 });
|
|
975
|
+
})
|
|
976
|
+
);
|
|
977
|
+
await Promise.race([Promise.all(n), new Promise((i) => setTimeout(i, 5e3))]);
|
|
978
|
+
}
|
|
979
|
+
async function Li(t, n, i, o, u) {
|
|
980
|
+
const d = i.html2canvas;
|
|
981
|
+
if (typeof d != "function")
|
|
982
|
+
throw new Error(`A PDF header / footer element needs html2canvas. Add it to exportable.pdf.libraries. ${$t}`);
|
|
983
|
+
const [a, g] = await Promise.all([
|
|
984
|
+
Xr("react-dom/client", () => import("./client-DUlru6F3.js").then((b) => b.c)),
|
|
985
|
+
Xr("react-dom", () => import("react-dom"))
|
|
986
|
+
]), m = 2, x = document.createElement("div");
|
|
987
|
+
x.style.cssText = `position:fixed;left:-10000px;top:0;width:${Math.round(n / Bn)}px;background:${o};color:${u};font-family:system-ui,sans-serif;font-size:14px;`, document.body.appendChild(x);
|
|
988
|
+
const E = a.createRoot(x);
|
|
989
|
+
try {
|
|
990
|
+
g.flushSync(() => E.render(t)), await Pi(x), await new Promise((v) => requestAnimationFrame(() => v(void 0)));
|
|
991
|
+
const b = await d(x, { scale: m, backgroundColor: o, useCORS: !0, logging: !1 });
|
|
992
|
+
return { dataUrl: b.toDataURL("image/png"), width: b.width / m * Bn, height: b.height / m * Bn };
|
|
993
|
+
} finally {
|
|
994
|
+
E.unmount(), x.remove();
|
|
724
995
|
}
|
|
725
|
-
return { ...r, [n]: c };
|
|
726
996
|
}
|
|
727
|
-
function
|
|
728
|
-
|
|
729
|
-
if (
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
997
|
+
async function Wn(t, n, i, o, u, d) {
|
|
998
|
+
if (t == null || t === !1 || t === !0 || t === "") return null;
|
|
999
|
+
if (typeof t == "string" || typeof t == "number") return { kind: "text", text: String(t) };
|
|
1000
|
+
const a = await Li(t, n, o, u, d), g = Math.min(1, n / a.width, i / a.height);
|
|
1001
|
+
return { kind: "image", dataUrl: a.dataUrl, width: a.width * g, height: a.height * g };
|
|
1002
|
+
}
|
|
1003
|
+
const Jr = (t) => `rgb(${t[0]},${t[1]},${t[2]})`, Qr = ["normal", "bold", "italic", "bolditalic"];
|
|
1004
|
+
function Zr(t, n) {
|
|
1005
|
+
return typeof t == "number" ? { top: t, right: t, bottom: t, left: t } : { top: (t == null ? void 0 : t.top) ?? n, right: (t == null ? void 0 : t.right) ?? n, bottom: (t == null ? void 0 : t.bottom) ?? n, left: (t == null ? void 0 : t.left) ?? n };
|
|
1006
|
+
}
|
|
1007
|
+
function eo(t) {
|
|
1008
|
+
return Object.fromEntries(Object.entries(t).filter(([, n]) => n !== void 0));
|
|
1009
|
+
}
|
|
1010
|
+
async function Oi(t, n = {}, i = {}) {
|
|
1011
|
+
var it, Me;
|
|
1012
|
+
let o;
|
|
1013
|
+
try {
|
|
1014
|
+
o = typeof n.libraries == "function" ? await n.libraries() : n.libraries;
|
|
1015
|
+
} catch (F) {
|
|
1016
|
+
const Q = F instanceof Error ? F.message : String(F);
|
|
1017
|
+
throw new Error(`PDF export could not load jspdf / jspdf-autotable (${Q}). ${$t}`);
|
|
1018
|
+
}
|
|
1019
|
+
if (!o) throw new Error(`PDF export needs the jspdf and jspdf-autotable libraries. ${$t}`);
|
|
1020
|
+
const u = o.jsPDF, d = o.autoTable;
|
|
1021
|
+
if (typeof u != "function" || typeof d != "function")
|
|
1022
|
+
throw new Error(`exportable.pdf.libraries must contain jsPDF (a class) and autoTable (a function). ${$t}`);
|
|
1023
|
+
const {
|
|
1024
|
+
title: a,
|
|
1025
|
+
header: g,
|
|
1026
|
+
footer: m,
|
|
1027
|
+
headerAlign: x = "left",
|
|
1028
|
+
footerAlign: E = "center",
|
|
1029
|
+
orientation: b = "auto",
|
|
1030
|
+
pageSize: v = "a4",
|
|
1031
|
+
tableTheme: p = "striped",
|
|
1032
|
+
pageNumbers: k = !0,
|
|
1033
|
+
maxImageHeight: D = 90,
|
|
1034
|
+
beforeRender: C,
|
|
1035
|
+
autoTableOptions: T
|
|
1036
|
+
} = n, w = {
|
|
1037
|
+
...i,
|
|
1038
|
+
...eo({
|
|
1039
|
+
headColor: n.headColor,
|
|
1040
|
+
headTextColor: n.headTextColor,
|
|
1041
|
+
fontSize: n.fontSize,
|
|
1042
|
+
fontName: n.fontName,
|
|
1043
|
+
margin: n.margin
|
|
1044
|
+
}),
|
|
1045
|
+
...eo(n.style ?? {})
|
|
1046
|
+
}, P = Zr(w.margin, 36), X = w.fontName ?? "helvetica", q = w.fontSize ?? 9, R = fe(w.pageBackground), H = R ? An(R) : [75, 85, 99], Se = fe(w.textColor) ?? H, Pe = fe(w.titleColor) ?? (R ? An(R) : [17, 24, 39]), ze = fe(w.headColor) ?? [79, 70, 229], Ee = fe(w.headTextColor) ?? [255, 255, 255], V = fe(w.bodyTextColor), ae = fe((it = w.stripeColors) == null ? void 0 : it[0]), Ie = fe((Me = w.stripeColors) == null ? void 0 : Me[1]), _ = fe(w.bodyColor) ?? ae ?? R ?? void 0, G = fe(w.borderColor), S = new u({
|
|
1047
|
+
orientation: b === "auto" ? t.headers.length > 6 ? "landscape" : "portrait" : b,
|
|
1048
|
+
unit: "pt",
|
|
1049
|
+
format: v
|
|
1050
|
+
});
|
|
1051
|
+
C && await C(S);
|
|
1052
|
+
const B = S.internal.pageSize.getWidth(), ce = S.internal.pageSize.getHeight(), pe = B - P.left - P.right, qe = 10, nt = 12, Pt = /* @__PURE__ */ new Set(), pt = (F) => {
|
|
1053
|
+
!R || Pt.has(F) || (Pt.add(F), S.setFillColor(...R), S.rect(0, 0, B, ce, "F"));
|
|
1054
|
+
};
|
|
1055
|
+
pt(1);
|
|
1056
|
+
const Ye = R ? Jr(R) : "#ffffff", Ve = Jr(Se), de = await Wn(g, pe, D, o, Ye, Ve), ge = await Wn(m, pe, D, o, Ye, Ve);
|
|
1057
|
+
S.setFont(X, "normal"), S.setFontSize(qe);
|
|
1058
|
+
const gt = (F) => F ? F.kind === "image" ? F.height : S.splitTextToSize(Gr(F.text, 99, 99), pe).length * nt : 0, He = gt(de), mt = gt(ge), Le = Math.min(18, P.top), bt = ce - 14, yt = ce - (k ? 26 : 18), Lt = de ? Math.max(P.top, Le + He + 12) : P.top, xt = Math.max(P.bottom, ge ? ce - yt + mt + 10 : k ? 34 : 0);
|
|
1059
|
+
let Xe = Lt;
|
|
1060
|
+
if (a && typeof a != "string" && typeof a != "number" && typeof a != "boolean") {
|
|
1061
|
+
const F = await Wn(a, pe, D, o, Ye, Ve);
|
|
1062
|
+
F && F.kind === "image" && (S.addImage(F.dataUrl, "PNG", P.left, Xe, F.width, F.height), Xe += F.height + 12);
|
|
1063
|
+
} else a && (S.setFont(X, "bold"), S.setFontSize(w.titleSize ?? 14), S.setTextColor(...Pe), S.text(String(a), P.left, Xe + (w.titleSize ?? 14)), Xe += (w.titleSize ?? 14) + 12);
|
|
1064
|
+
const Ot = {};
|
|
1065
|
+
t.fields.forEach((F, Q) => {
|
|
1066
|
+
var st;
|
|
1067
|
+
const L = (st = w.columns) == null ? void 0 : st[F], xe = {}, Y = (L == null ? void 0 : L.align) ?? t.aligns[Q];
|
|
1068
|
+
Y && (xe.halign = Y), (L == null ? void 0 : L.width) !== void 0 && (xe.cellWidth = L.width);
|
|
1069
|
+
const A = fe(L == null ? void 0 : L.textColor);
|
|
1070
|
+
A && (xe.textColor = A);
|
|
1071
|
+
const lt = fe(L == null ? void 0 : L.backgroundColor);
|
|
1072
|
+
lt && (xe.fillColor = lt), L != null && L.fontStyle && Qr.includes(L.fontStyle) && (xe.fontStyle = L.fontStyle), L != null && L.fontSize && (xe.fontSize = L.fontSize), Object.keys(xe).length > 0 && (Ot[Q] = xe);
|
|
1073
|
+
});
|
|
1074
|
+
const ye = {
|
|
1075
|
+
font: X,
|
|
1076
|
+
fontSize: q,
|
|
1077
|
+
cellPadding: Zr(w.cellPadding, 4),
|
|
1078
|
+
overflow: "linebreak",
|
|
1079
|
+
valign: "middle"
|
|
1080
|
+
};
|
|
1081
|
+
V ? ye.textColor = V : R && (ye.textColor = An(R)), G && (ye.lineColor = G), w.borderWidth !== void 0 ? ye.lineWidth = w.borderWidth : G && (ye.lineWidth = 0.5), w.minRowHeight && (ye.minCellHeight = w.minRowHeight);
|
|
1082
|
+
const Ce = {
|
|
1083
|
+
head: [t.headers],
|
|
1084
|
+
body: t.rows,
|
|
1085
|
+
startY: Xe,
|
|
1086
|
+
margin: { top: Lt, right: P.right, bottom: xt, left: P.left },
|
|
1087
|
+
theme: p,
|
|
1088
|
+
showHead: "everyPage",
|
|
1089
|
+
styles: ye,
|
|
1090
|
+
headStyles: {
|
|
1091
|
+
fillColor: ze,
|
|
1092
|
+
textColor: Ee,
|
|
1093
|
+
fontStyle: w.headFontStyle && Qr.includes(w.headFontStyle) ? w.headFontStyle : "bold",
|
|
1094
|
+
...w.headFontSize ? { fontSize: w.headFontSize } : null
|
|
1095
|
+
},
|
|
1096
|
+
columnStyles: Ot,
|
|
1097
|
+
// A new page starts blank: paint its background before the table draws on it
|
|
1098
|
+
willDrawPage: () => {
|
|
1099
|
+
var Q, L;
|
|
1100
|
+
const F = typeof S.getCurrentPageInfo == "function" ? S.getCurrentPageInfo() : (L = (Q = S.internal).getCurrentPageInfo) == null ? void 0 : L.call(Q);
|
|
1101
|
+
F != null && F.pageNumber && pt(F.pageNumber);
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
_ && (Ce.bodyStyles = { fillColor: _ }), ae && Ie ? (Ce.bodyStyles = { fillColor: ae }, Ce.alternateRowStyles = { fillColor: Ie }) : (ae || _) && (Ce.alternateRowStyles = { fillColor: _ });
|
|
1105
|
+
const Rt = { ...Ce, ...T };
|
|
1106
|
+
for (const F of ["styles", "headStyles", "bodyStyles", "alternateRowStyles", "margin"]) {
|
|
1107
|
+
const Q = Ce[F], L = T == null ? void 0 : T[F];
|
|
1108
|
+
Q && L && typeof L == "object" && (Rt[F] = { ...Q, ...L });
|
|
1109
|
+
}
|
|
1110
|
+
d(S, Rt);
|
|
1111
|
+
const re = typeof S.getNumberOfPages == "function" ? S.getNumberOfPages() : S.internal.getNumberOfPages(), rt = (F, Q) => F === "center" ? (B - Q) / 2 : F === "right" ? B - P.right - Q : P.left, ot = (F, Q, L, xe) => {
|
|
1112
|
+
if (!F) return;
|
|
1113
|
+
if (F.kind === "image") {
|
|
1114
|
+
S.addImage(F.dataUrl, "PNG", rt(L, F.width), Q, F.width, F.height);
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
S.setFont(X, "normal"), S.setFontSize(qe), S.setTextColor(...Se);
|
|
1118
|
+
const Y = S.splitTextToSize(Gr(F.text, xe, re), pe), A = L === "center" ? B / 2 : L === "right" ? B - P.right : P.left;
|
|
1119
|
+
S.text(Y, A, Q + qe, { align: L });
|
|
1120
|
+
};
|
|
1121
|
+
for (let F = 1; F <= re; F++)
|
|
1122
|
+
S.setPage(F), ot(de, Le, x, F), ot(ge, yt - mt, E, F), k && (S.setFont(X, "normal"), S.setFontSize(8), S.setTextColor(...Se), S.text(`Page ${F} of ${re}`, B - P.right, bt, { align: "right" }));
|
|
1123
|
+
return S.output("blob");
|
|
1124
|
+
}
|
|
1125
|
+
function Ri(t) {
|
|
1126
|
+
var E;
|
|
1127
|
+
if (!t || typeof getComputedStyle > "u") return {};
|
|
1128
|
+
const n = {}, i = (b) => b ? getComputedStyle(b) : null, o = (b) => {
|
|
1129
|
+
var v;
|
|
1130
|
+
for (let p = b; p; p = p.parentElement) {
|
|
1131
|
+
const k = (v = i(p)) == null ? void 0 : v.backgroundColor;
|
|
1132
|
+
if (k && fe(k)) return k;
|
|
1133
|
+
}
|
|
1134
|
+
}, u = (b) => {
|
|
1135
|
+
const v = fe(b);
|
|
1136
|
+
return v ? "#" + v.map((p) => p.toString(16).padStart(2, "0")).join("") : void 0;
|
|
1137
|
+
}, d = (b) => b ? Math.round(parseFloat(b) * 0.75 * 10) / 10 : void 0, a = t.querySelector("thead th");
|
|
1138
|
+
if (a) {
|
|
1139
|
+
const b = i(a);
|
|
1140
|
+
n.headColor = u(o(a)), n.headTextColor = u(b.color), n.headFontStyle = parseInt(b.fontWeight, 10) >= 600 ? "bold" : "normal";
|
|
1141
|
+
}
|
|
1142
|
+
const g = Array.from(t.querySelectorAll("tbody tr.rg-grid__row:not(.rg-grid__row--exit)")).slice(0, 2), m = (E = g[0]) == null ? void 0 : E.querySelector("td");
|
|
1143
|
+
if (m) {
|
|
1144
|
+
const b = i(m);
|
|
1145
|
+
n.bodyTextColor = u(b.color);
|
|
1146
|
+
const v = d(b.fontSize);
|
|
1147
|
+
v && !Number.isNaN(v) && (n.fontSize = Math.min(14, Math.max(6, v)));
|
|
1148
|
+
const p = u(o(g[0].querySelector("td"))), k = u(g[1] ? o(g[1].querySelector("td")) : void 0);
|
|
1149
|
+
n.bodyColor = p, p && k && p !== k && (n.stripeColors = [p, k]);
|
|
1150
|
+
const D = i(m);
|
|
1151
|
+
parseFloat(D.borderBottomWidth) > 0 && D.borderBottomStyle !== "none" && (n.borderColor = u(D.borderBottomColor), n.borderWidth = 0.5);
|
|
1152
|
+
}
|
|
1153
|
+
const x = u(o(t));
|
|
1154
|
+
return x && x !== "#ffffff" && (n.pageBackground = x), n.textColor = u(i(t).color), n.fontName = void 0, Object.keys(n).forEach((b) => n[b] === void 0 && delete n[b]), n;
|
|
1155
|
+
}
|
|
1156
|
+
const Ui = { none: 0, asc: 0, desc: 180 };
|
|
1157
|
+
function Ai({ direction: t, size: n = 14, priority: i, className: o, style: u }) {
|
|
1158
|
+
const d = j(0), g = ((Ui[t ?? "none"] - d.current) % 360 + 360) % 360;
|
|
1159
|
+
return d.current += g, /* @__PURE__ */ I("span", { className: U("rg-sort-arrow", t && "rg-sort-arrow--active", o), style: u, "data-direction": t ?? "none", children: [
|
|
1160
|
+
/* @__PURE__ */ I(
|
|
1161
|
+
"svg",
|
|
1162
|
+
{
|
|
1163
|
+
className: "rg-sort-arrow__icon",
|
|
1164
|
+
width: n,
|
|
1165
|
+
height: n,
|
|
1166
|
+
viewBox: "0 0 16 16",
|
|
1167
|
+
fill: "none",
|
|
1168
|
+
stroke: "currentColor",
|
|
1169
|
+
strokeWidth: "2",
|
|
1170
|
+
strokeLinecap: "round",
|
|
1171
|
+
strokeLinejoin: "round",
|
|
1172
|
+
"aria-hidden": "true",
|
|
1173
|
+
focusable: "false",
|
|
1174
|
+
style: { transform: `rotate(${d.current}deg)` },
|
|
1175
|
+
children: [
|
|
1176
|
+
/* @__PURE__ */ h("path", { d: "M8 13V3" }),
|
|
1177
|
+
/* @__PURE__ */ h("path", { d: "M3.5 7.5 8 3l4.5 4.5" })
|
|
1178
|
+
]
|
|
1179
|
+
}
|
|
1180
|
+
),
|
|
1181
|
+
t && i !== void 0 && /* @__PURE__ */ h("sup", { className: "rg-sort-arrow__order", children: i })
|
|
1182
|
+
] });
|
|
1183
|
+
}
|
|
1184
|
+
const ho = new TextEncoder();
|
|
1185
|
+
let hn = null;
|
|
1186
|
+
function Bi(t) {
|
|
1187
|
+
if (!hn) {
|
|
1188
|
+
hn = new Uint32Array(256);
|
|
1189
|
+
for (let i = 0; i < 256; i++) {
|
|
1190
|
+
let o = i;
|
|
1191
|
+
for (let u = 0; u < 8; u++) o = o & 1 ? 3988292384 ^ o >>> 1 : o >>> 1;
|
|
1192
|
+
hn[i] = o >>> 0;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
let n = 4294967295;
|
|
1196
|
+
for (let i = 0; i < t.length; i++) n = hn[(n ^ t[i]) & 255] ^ n >>> 8;
|
|
1197
|
+
return (n ^ 4294967295) >>> 0;
|
|
1198
|
+
}
|
|
1199
|
+
async function Wi(t) {
|
|
1200
|
+
const n = globalThis.CompressionStream;
|
|
1201
|
+
if (typeof n > "u") return null;
|
|
1202
|
+
try {
|
|
1203
|
+
const i = new Blob([t]).stream().pipeThrough(new n("deflate-raw"));
|
|
1204
|
+
return new Uint8Array(await new Response(i).arrayBuffer());
|
|
1205
|
+
} catch {
|
|
1206
|
+
return null;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
async function ji(t) {
|
|
1210
|
+
const n = /* @__PURE__ */ new Date(), i = n.getHours() << 11 | n.getMinutes() << 5 | n.getSeconds() >> 1, o = n.getFullYear() - 1980 << 9 | n.getMonth() + 1 << 5 | n.getDate(), u = [], d = [];
|
|
1211
|
+
let a = 0;
|
|
1212
|
+
for (const p of t) {
|
|
1213
|
+
const k = ho.encode(p.name), D = Bi(p.data), C = await Wi(p.data), T = C !== null && C.length < p.data.length, w = T ? C : p.data, P = T ? 8 : 0, X = new Uint8Array(30 + k.length), q = new DataView(X.buffer);
|
|
1214
|
+
q.setUint32(0, 67324752, !0), q.setUint16(4, 20, !0), q.setUint16(6, 2048, !0), q.setUint16(8, P, !0), q.setUint16(10, i, !0), q.setUint16(12, o, !0), q.setUint32(14, D, !0), q.setUint32(18, w.length, !0), q.setUint32(22, p.data.length, !0), q.setUint16(26, k.length, !0), q.setUint16(28, 0, !0), X.set(k, 30);
|
|
1215
|
+
const R = new Uint8Array(46 + k.length), H = new DataView(R.buffer);
|
|
1216
|
+
H.setUint32(0, 33639248, !0), H.setUint16(4, 20, !0), H.setUint16(6, 20, !0), H.setUint16(8, 2048, !0), H.setUint16(10, P, !0), H.setUint16(12, i, !0), H.setUint16(14, o, !0), H.setUint32(16, D, !0), H.setUint32(20, w.length, !0), H.setUint32(24, p.data.length, !0), H.setUint16(28, k.length, !0), H.setUint32(42, a, !0), R.set(k, 46), u.push(X, w), d.push(R), a += X.length + w.length;
|
|
1217
|
+
}
|
|
1218
|
+
const g = d.reduce((p, k) => p + k.length, 0), m = new Uint8Array(22), x = new DataView(m.buffer);
|
|
1219
|
+
x.setUint32(0, 101010256, !0), x.setUint16(8, t.length, !0), x.setUint16(10, t.length, !0), x.setUint32(12, g, !0), x.setUint32(16, a, !0);
|
|
1220
|
+
const E = [...u, ...d, m], b = new Uint8Array(E.reduce((p, k) => p + k.length, 0));
|
|
1221
|
+
let v = 0;
|
|
1222
|
+
for (const p of E)
|
|
1223
|
+
b.set(p, v), v += p.length;
|
|
1224
|
+
return b;
|
|
735
1225
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
const c = te(n, r.field);
|
|
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);
|
|
1226
|
+
function bn(t) {
|
|
1227
|
+
return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
740
1228
|
}
|
|
741
|
-
function
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
1229
|
+
function mn(t) {
|
|
1230
|
+
let n = t + 1, i = "";
|
|
1231
|
+
for (; n > 0; ) {
|
|
1232
|
+
const o = (n - 1) % 26;
|
|
1233
|
+
i = String.fromCharCode(65 + o) + i, n = Math.floor((n - 1) / 26);
|
|
745
1234
|
}
|
|
746
|
-
return
|
|
1235
|
+
return i;
|
|
747
1236
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
1237
|
+
function Ki(t) {
|
|
1238
|
+
const n = /^(\d{4})-(\d{2})-(\d{2})$/.exec(t);
|
|
1239
|
+
if (!n) return null;
|
|
1240
|
+
const [i, o, u] = [Number(n[1]), Number(n[2]), Number(n[3])], d = new Date(Date.UTC(i, o - 1, u));
|
|
1241
|
+
return d.getUTCFullYear() !== i || d.getUTCMonth() !== o - 1 || d.getUTCDate() !== u ? null : Math.round((d.getTime() - Date.UTC(1899, 11, 30)) / 864e5);
|
|
1242
|
+
}
|
|
1243
|
+
function zi(t) {
|
|
1244
|
+
return (t ?? "").replace(/[\[\]:*?/\\]/g, " ").trim().slice(0, 31) || "Sheet1";
|
|
1245
|
+
}
|
|
1246
|
+
const qi = 1, Yi = 2, Vi = 3, Hi = 4, Xi = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
1247
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
|
1248
|
+
<numFmts count="1"><numFmt numFmtId="164" formatCode="yyyy\\-mm\\-dd"/></numFmts>
|
|
1249
|
+
<fonts count="2"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><color rgb="FFFFFFFF"/><name val="Calibri"/></font></fonts>
|
|
1250
|
+
<fills count="3"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill><fill><patternFill patternType="solid"><fgColor rgb="FF4F46E5"/><bgColor indexed="64"/></patternFill></fill></fills>
|
|
1251
|
+
<borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>
|
|
1252
|
+
<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>
|
|
1253
|
+
<cellXfs count="5">
|
|
1254
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
|
1255
|
+
<xf numFmtId="0" fontId="1" fillId="2" borderId="0" xfId="0" applyFont="1" applyFill="1" applyAlignment="1"><alignment vertical="center"/></xf>
|
|
1256
|
+
<xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" applyAlignment="1"><alignment horizontal="right"/></xf>
|
|
1257
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment horizontal="right"/></xf>
|
|
1258
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment horizontal="center"/></xf>
|
|
1259
|
+
</cellXfs>
|
|
1260
|
+
<cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>
|
|
1261
|
+
</styleSheet>`;
|
|
1262
|
+
function Gi(t, n, i) {
|
|
1263
|
+
if (n == null || n === "") return "";
|
|
1264
|
+
const o = i.align === "right" ? Vi : i.align === "center" ? Hi : 0;
|
|
1265
|
+
if (typeof n == "boolean") return `<c r="${t}" t="b"${o ? ` s="${o}"` : ""}><v>${n ? 1 : 0}</v></c>`;
|
|
1266
|
+
if (typeof n == "number")
|
|
1267
|
+
return Number.isFinite(n) ? `<c r="${t}"${o ? ` s="${o}"` : ""}><v>${n}</v></c>` : "";
|
|
1268
|
+
if (i.kind === "date") {
|
|
1269
|
+
const d = Ki(n);
|
|
1270
|
+
if (d !== null) return `<c r="${t}" s="${Yi}"><v>${d}</v></c>`;
|
|
1271
|
+
}
|
|
1272
|
+
if (i.kind === "number" && n.trim() !== "" && Number.isFinite(Number(n)))
|
|
1273
|
+
return `<c r="${t}"${o ? ` s="${o}"` : ""}><v>${Number(n)}</v></c>`;
|
|
1274
|
+
const u = bn(n.slice(0, 32767));
|
|
1275
|
+
return `<c r="${t}" t="inlineStr"${o ? ` s="${o}"` : ""}><is><t xml:space="preserve">${u}</t></is></c>`;
|
|
1276
|
+
}
|
|
1277
|
+
const to = (t) => t == null ? 0 : typeof t == "boolean" ? 5 : String(t).length;
|
|
1278
|
+
function Ji(t, n) {
|
|
1279
|
+
const i = mn(Math.max(0, t.length - 1)), o = n.length + 1, u = t.map((a, g) => {
|
|
1280
|
+
let m = to(a.header) + 3;
|
|
1281
|
+
for (let x = 0; x < Math.min(n.length, 500); x++) m = Math.max(m, a.kind === "date" ? 11 : to(n[x][g]));
|
|
1282
|
+
return Math.min(60, Math.max(8, m + 2));
|
|
1283
|
+
}), d = [];
|
|
1284
|
+
return d.push('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'), d.push('<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">'), d.push(`<dimension ref="A1:${i}${o}"/>`), d.push('<sheetViews><sheetView workbookViewId="0"><pane ySplit="1" topLeftCell="A2" activePane="bottomLeft" state="frozen"/><selection pane="bottomLeft"/></sheetView></sheetViews>'), d.push('<sheetFormatPr defaultRowHeight="15"/>'), d.push("<cols>" + u.map((a, g) => `<col min="${g + 1}" max="${g + 1}" width="${a}" customWidth="1"/>`).join("") + "</cols>"), d.push("<sheetData>"), d.push(
|
|
1285
|
+
'<row r="1" ht="22" customHeight="1">' + t.map((a, g) => `<c r="${mn(g)}1" s="${qi}" t="inlineStr"><is><t xml:space="preserve">${bn(a.header)}</t></is></c>`).join("") + "</row>"
|
|
1286
|
+
), n.forEach((a, g) => {
|
|
1287
|
+
const m = g + 2, x = t.map((E, b) => Gi(`${mn(b)}${m}`, a[b], E)).join("");
|
|
1288
|
+
d.push(`<row r="${m}">${x}</row>`);
|
|
1289
|
+
}), d.push("</sheetData>"), d.push(`<autoFilter ref="A1:${i}${o}"/>`), d.push("</worksheet>"), d.join("");
|
|
1290
|
+
}
|
|
1291
|
+
async function Qi(t, n, i = {}) {
|
|
1292
|
+
const o = zi(i.sheetName), u = `'${o.replace(/'/g, "''")}'`, d = mn(Math.max(0, t.length - 1)), a = {
|
|
1293
|
+
"[Content_Types].xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
1294
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>`,
|
|
1295
|
+
"_rels/.rels": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
1296
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>`,
|
|
1297
|
+
"xl/workbook.xml": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
1298
|
+
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="${bn(o)}" sheetId="1" r:id="rId1"/></sheets><definedNames><definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">${bn(u)}!$A$1:$${d}$${n.length + 1}</definedName></definedNames></workbook>`,
|
|
1299
|
+
"xl/_rels/workbook.xml.rels": `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
1300
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>`,
|
|
1301
|
+
"xl/styles.xml": Xi,
|
|
1302
|
+
"xl/worksheets/sheet1.xml": Ji(t, n)
|
|
1303
|
+
}, g = await ji(Object.entries(a).map(([m, x]) => ({ name: m, data: ho.encode(x) })));
|
|
1304
|
+
return new Blob([g], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
|
|
1305
|
+
}
|
|
1306
|
+
const Kn = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), po = (t, n) => Object.prototype.hasOwnProperty.call(t, n);
|
|
1307
|
+
function ve(t, n) {
|
|
1308
|
+
if (t === null || typeof t != "object") return;
|
|
1309
|
+
if (po(t, n)) return t[n];
|
|
1310
|
+
let i = t;
|
|
1311
|
+
for (const o of n.split(".")) {
|
|
1312
|
+
if (i == null || typeof i != "object" || Kn.has(o)) return;
|
|
1313
|
+
i = i[o];
|
|
1314
|
+
}
|
|
1315
|
+
return i;
|
|
1316
|
+
}
|
|
1317
|
+
function no(t, n, i) {
|
|
1318
|
+
if (Array.isArray(t)) {
|
|
1319
|
+
const o = [...t];
|
|
1320
|
+
return o[n] = i, o;
|
|
1321
|
+
}
|
|
1322
|
+
return { ...t, [n]: i };
|
|
1323
|
+
}
|
|
1324
|
+
function zn(t, n, i) {
|
|
1325
|
+
const o = t ?? {};
|
|
1326
|
+
if (po(o, n) || !n.includes("."))
|
|
1327
|
+
return Kn.has(n) ? t : no(o, n, i);
|
|
1328
|
+
const [u, ...d] = n.split(".");
|
|
1329
|
+
if (Kn.has(u)) return t;
|
|
1330
|
+
const a = o[u];
|
|
1331
|
+
return no(o, u, zn(a !== null && typeof a == "object" ? a : {}, d.join("."), i));
|
|
1332
|
+
}
|
|
1333
|
+
function ro(t, n) {
|
|
1334
|
+
if (n.length === 0) return t.map((a, g) => ({ kind: "row", entry: a, i: g }));
|
|
1335
|
+
const i = /* @__PURE__ */ new Map();
|
|
1336
|
+
for (const a of n) i.set(a.afterId, [...i.get(a.afterId) ?? [], a]);
|
|
1337
|
+
const o = [], u = /* @__PURE__ */ new Set(), d = (a) => {
|
|
1338
|
+
for (const g of i.get(a) ?? [])
|
|
1339
|
+
u.has(g.id) || (u.add(g.id), o.push({ kind: "ghost", ghost: g }), d(g.id));
|
|
1340
|
+
};
|
|
1341
|
+
return d(null), t.forEach((a, g) => {
|
|
1342
|
+
o.push({ kind: "row", entry: a, i: g }), d(a.id);
|
|
1343
|
+
}), n.forEach((a) => !u.has(a.id) && o.push({ kind: "ghost", ghost: a })), o;
|
|
1344
|
+
}
|
|
1345
|
+
const Zi = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, je = 38, el = 150, oo = 10, jn = (t, n) => `${typeof t}:${t}\0${n}`;
|
|
1346
|
+
function It(t, n) {
|
|
1347
|
+
const i = ve(n, t.field);
|
|
1348
|
+
return t.valueFormatter ? t.valueFormatter(i, n) : t.type === "boolean" && typeof i == "boolean" ? i ? "Yes" : "No" : t.type === "date" ? fi(i, t.dateLocale, t.dateFormat) : i == null ? "" : i instanceof Date ? i.toLocaleDateString() : String(i);
|
|
1349
|
+
}
|
|
1350
|
+
function tl(t, n, i) {
|
|
1351
|
+
if (i.type === "date") {
|
|
1352
|
+
const o = he(t) ?? "", u = he(n) ?? "";
|
|
1353
|
+
return o < u ? -1 : o > u ? 1 : 0;
|
|
1354
|
+
}
|
|
1355
|
+
return typeof t == "number" && typeof n == "number" ? t - n : t instanceof Date && n instanceof Date ? t.getTime() - n.getTime() : typeof t == "boolean" && typeof n == "boolean" ? Number(t) - Number(n) : String(t).localeCompare(String(n), void 0, { numeric: !0, sensitivity: "base" });
|
|
1356
|
+
}
|
|
1357
|
+
const nl = (t) => t ? Array.isArray(t) ? t : [t] : [], io = (t) => t.type === "date" && t.validity.badInput;
|
|
1358
|
+
function sl({
|
|
1359
|
+
columns: t,
|
|
751
1360
|
rows: n,
|
|
752
|
-
getRowId:
|
|
753
|
-
editable:
|
|
754
|
-
enterMovesDown:
|
|
755
|
-
onCellEdit:
|
|
756
|
-
onRowsChange:
|
|
757
|
-
rowSelection:
|
|
758
|
-
selectedRowIds:
|
|
759
|
-
defaultSelectedRowIds:
|
|
760
|
-
onSelectionChange:
|
|
761
|
-
isRowSelectable:
|
|
762
|
-
sort:
|
|
763
|
-
defaultSort:
|
|
764
|
-
onSortChange:
|
|
765
|
-
multiSort:
|
|
766
|
-
searchable:
|
|
767
|
-
searchPlaceholder:
|
|
768
|
-
search:
|
|
769
|
-
onSearchChange:
|
|
770
|
-
filters:
|
|
771
|
-
onFiltersChange:
|
|
772
|
-
pagination:
|
|
773
|
-
paginationPosition:
|
|
774
|
-
showToolbar:
|
|
775
|
-
showFooter:
|
|
776
|
-
pageSize:
|
|
777
|
-
pageSizeOptions:
|
|
778
|
-
page:
|
|
779
|
-
onPageChange:
|
|
780
|
-
onPageSizeChange:
|
|
781
|
-
serverSide:
|
|
782
|
-
rowCount:
|
|
783
|
-
onQueryChange:
|
|
784
|
-
queryDebounce:
|
|
785
|
-
filterDebounce:
|
|
786
|
-
loading:
|
|
787
|
-
loadingRows:
|
|
788
|
-
skeletonRow:
|
|
789
|
-
errorMessage:
|
|
790
|
-
columnMenu:
|
|
791
|
-
onColumnVisibilityChange:
|
|
792
|
-
keyboardNavigation:
|
|
793
|
-
virtualize:
|
|
794
|
-
rowHeight:
|
|
795
|
-
overscan:
|
|
1361
|
+
getRowId: i,
|
|
1362
|
+
editable: o = !1,
|
|
1363
|
+
enterMovesDown: u = !0,
|
|
1364
|
+
onCellEdit: d,
|
|
1365
|
+
onRowsChange: a,
|
|
1366
|
+
rowSelection: g = !1,
|
|
1367
|
+
selectedRowIds: m,
|
|
1368
|
+
defaultSelectedRowIds: x,
|
|
1369
|
+
onSelectionChange: E,
|
|
1370
|
+
isRowSelectable: b,
|
|
1371
|
+
sort: v,
|
|
1372
|
+
defaultSort: p = null,
|
|
1373
|
+
onSortChange: k,
|
|
1374
|
+
multiSort: D = !1,
|
|
1375
|
+
searchable: C = !1,
|
|
1376
|
+
searchPlaceholder: T = "Search…",
|
|
1377
|
+
search: w,
|
|
1378
|
+
onSearchChange: P,
|
|
1379
|
+
filters: X,
|
|
1380
|
+
onFiltersChange: q,
|
|
1381
|
+
pagination: R = !1,
|
|
1382
|
+
paginationPosition: H = "bottom",
|
|
1383
|
+
showToolbar: Se = !0,
|
|
1384
|
+
showFooter: Pe = !0,
|
|
1385
|
+
pageSize: ze = 10,
|
|
1386
|
+
pageSizeOptions: Ee = [5, 10, 25, 50],
|
|
1387
|
+
page: V,
|
|
1388
|
+
onPageChange: ae,
|
|
1389
|
+
onPageSizeChange: Ie,
|
|
1390
|
+
serverSide: _ = !1,
|
|
1391
|
+
rowCount: G,
|
|
1392
|
+
onQueryChange: S,
|
|
1393
|
+
queryDebounce: B = 250,
|
|
1394
|
+
filterDebounce: ce = 300,
|
|
1395
|
+
loading: pe,
|
|
1396
|
+
loadingRows: qe,
|
|
1397
|
+
skeletonRow: nt,
|
|
1398
|
+
errorMessage: Pt = "Could not load the data.",
|
|
1399
|
+
columnMenu: pt = !1,
|
|
1400
|
+
onColumnVisibilityChange: Ye,
|
|
1401
|
+
keyboardNavigation: Ve = !1,
|
|
1402
|
+
virtualize: de = !1,
|
|
1403
|
+
rowHeight: ge = 40,
|
|
1404
|
+
overscan: gt = 6,
|
|
796
1405
|
exportable: He = !1,
|
|
1406
|
+
onExportError: mt,
|
|
797
1407
|
apiRef: Le,
|
|
798
|
-
onRowClick:
|
|
799
|
-
toolbar:
|
|
800
|
-
emptyMessage:
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
1408
|
+
onRowClick: bt,
|
|
1409
|
+
toolbar: yt,
|
|
1410
|
+
emptyMessage: Lt = "No rows to show",
|
|
1411
|
+
emptyComponent: xt,
|
|
1412
|
+
sortIndicator: Xe = "default",
|
|
1413
|
+
striped: Ot = !1,
|
|
1414
|
+
stripeColors: ye,
|
|
1415
|
+
checkboxVariant: Ce = "native",
|
|
1416
|
+
animateRows: Rt = !0,
|
|
1417
|
+
rowAnimation: re,
|
|
1418
|
+
rowAnimationDuration: rt,
|
|
1419
|
+
rowAnimationStagger: ot,
|
|
1420
|
+
rowAnimationClassName: it,
|
|
1421
|
+
rowExitAnimationClassName: Me,
|
|
1422
|
+
theme: F,
|
|
1423
|
+
maxHeight: Q,
|
|
1424
|
+
className: L,
|
|
1425
|
+
style: xe,
|
|
1426
|
+
classNames: Y = {},
|
|
1427
|
+
styles: A = {},
|
|
1428
|
+
rowClassName: lt,
|
|
1429
|
+
rowStyle: st
|
|
814
1430
|
}) {
|
|
815
|
-
const
|
|
816
|
-
className:
|
|
817
|
-
style:
|
|
818
|
-
}), [
|
|
819
|
-
|
|
820
|
-
|
|
1431
|
+
const Z = (e, r) => ({
|
|
1432
|
+
className: U(r, Y[e]),
|
|
1433
|
+
style: A[e]
|
|
1434
|
+
}), [Ut, Yn] = z(n), at = j(n);
|
|
1435
|
+
ne(() => {
|
|
1436
|
+
at.current = n, Yn(n);
|
|
821
1437
|
}, [n]);
|
|
822
|
-
const
|
|
823
|
-
|
|
824
|
-
}, [
|
|
825
|
-
|
|
826
|
-
}, [
|
|
827
|
-
const
|
|
828
|
-
|
|
829
|
-
}, [
|
|
830
|
-
const e =
|
|
1438
|
+
const Vn = (e) => {
|
|
1439
|
+
at.current = e, Yn(e);
|
|
1440
|
+
}, [_t, Hn] = Et(w, "", P), [ct, Xn] = Et(X, {}, q), [me, go] = Et(v, nl(p), k), [xn, dt] = Et(V, 0, ae), [oe, mo] = z(ze), bo = (e) => {
|
|
1441
|
+
mo(e), Ie == null || Ie(e);
|
|
1442
|
+
}, [At, yo] = z(() => new Set(t.filter((e) => e.hidden).map((e) => e.field))), xo = (e, r) => {
|
|
1443
|
+
const l = new Set(At);
|
|
1444
|
+
r ? l.add(e) : l.delete(e), yo(l), Ye == null || Ye([...l]);
|
|
1445
|
+
}, [_n, Gn] = z({}), [Bt, _o] = z({}), [rl, wo] = z(0), wt = j(/* @__PURE__ */ new Map()), [vt, Ge] = z(null), Oe = j(0), Wt = j(null), jt = j(/* @__PURE__ */ new Map()), [wn, Jn] = z(null), vn = j(null), Qn = j(null), kt = j(null), [kn, Zn] = z({ top: 0, height: 0 }), W = ke(() => {
|
|
1446
|
+
const e = t.filter((r) => !At.has(r.field)).map((r) => r.type === "sequence" ? { ...r, sortable: !1, filterable: !1, editable: !1, filterRenderer: void 0 } : r);
|
|
831
1447
|
return [
|
|
832
|
-
...e.filter((
|
|
833
|
-
...e.filter((
|
|
834
|
-
...e.filter((
|
|
1448
|
+
...e.filter((r) => r.pinned === "left"),
|
|
1449
|
+
...e.filter((r) => r.pinned !== "left" && r.pinned !== "right"),
|
|
1450
|
+
...e.filter((r) => r.pinned === "right")
|
|
835
1451
|
];
|
|
836
|
-
}, [
|
|
837
|
-
() =>
|
|
838
|
-
[
|
|
839
|
-
),
|
|
840
|
-
|
|
841
|
-
const
|
|
842
|
-
() => Object.entries(
|
|
843
|
-
const
|
|
844
|
-
return !!
|
|
1452
|
+
}, [t, At]), Sn = (e) => e.sortable === !0, ue = g === "single" ? "single" : g ? "multiple" : null, St = W.length + (ue ? 1 : 0), Je = ke(
|
|
1453
|
+
() => Ut.map((e, r) => ({ row: e, index: r, id: i ? i(e, r) : r })),
|
|
1454
|
+
[Ut, i]
|
|
1455
|
+
), er = j(/* @__PURE__ */ new Map());
|
|
1456
|
+
Je.forEach((e) => er.current.set(e.id, e.row));
|
|
1457
|
+
const ut = ke(
|
|
1458
|
+
() => Object.entries(ct).filter(([e, r]) => {
|
|
1459
|
+
const l = W.find((s) => s.field === e);
|
|
1460
|
+
return !!l && !!l.filterable && uo(r);
|
|
845
1461
|
}),
|
|
846
|
-
[
|
|
847
|
-
), [
|
|
848
|
-
|
|
849
|
-
if (!
|
|
850
|
-
const e = setTimeout(() =>
|
|
1462
|
+
[ct, W]
|
|
1463
|
+
), [vo, ko] = z(_t);
|
|
1464
|
+
ne(() => {
|
|
1465
|
+
if (!_) return;
|
|
1466
|
+
const e = setTimeout(() => ko(_t), B);
|
|
851
1467
|
return () => clearTimeout(e);
|
|
852
|
-
}, [
|
|
853
|
-
const
|
|
854
|
-
if (
|
|
855
|
-
const e =
|
|
856
|
-
let
|
|
857
|
-
const
|
|
858
|
-
return
|
|
1468
|
+
}, [_t, _, B]);
|
|
1469
|
+
const Re = _ ? vo : _t, tr = (e) => e.filterRenderer ? "text" : Kr(e), $e = ke(() => {
|
|
1470
|
+
if (_) return Je;
|
|
1471
|
+
const e = Re.trim().toLowerCase();
|
|
1472
|
+
let r = Je.filter(({ row: s }) => e && !W.some((c) => It(c, s).toLowerCase().includes(e)) ? !1 : ut.every(([c, f]) => {
|
|
1473
|
+
const y = W.find((N) => N.field === c);
|
|
1474
|
+
return mi(tr(y), f, It(y, s), ve(s, c));
|
|
859
1475
|
}));
|
|
860
|
-
const
|
|
861
|
-
return
|
|
862
|
-
for (const { col:
|
|
863
|
-
const
|
|
864
|
-
if (
|
|
865
|
-
if (
|
|
1476
|
+
const l = me.map((s) => ({ col: W.find((c) => c.field === s.field), dir: s.direction === "asc" ? 1 : -1 })).filter((s) => !!s.col);
|
|
1477
|
+
return l.length && (r = [...r].sort((s, c) => {
|
|
1478
|
+
for (const { col: f, dir: y } of l) {
|
|
1479
|
+
const N = ve(s.row, f.field), M = ve(c.row, f.field), O = N == null || N === "", ee = M == null || M === "";
|
|
1480
|
+
if (O || ee) {
|
|
1481
|
+
if (O !== ee) return O ? 1 : -1;
|
|
866
1482
|
continue;
|
|
867
1483
|
}
|
|
868
|
-
const
|
|
869
|
-
if (
|
|
1484
|
+
const be = f.comparator ? f.comparator(N, M, s.row, c.row) : tl(N, M, f);
|
|
1485
|
+
if (be !== 0) return be * y;
|
|
870
1486
|
}
|
|
871
1487
|
return 0;
|
|
872
|
-
})),
|
|
873
|
-
}, [
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
}, [
|
|
877
|
-
const
|
|
1488
|
+
})), r;
|
|
1489
|
+
}, [Je, W, Re, ut, me, _]), Kt = JSON.stringify([Re, ct, me, oe]), nr = j(Kt);
|
|
1490
|
+
ne(() => {
|
|
1491
|
+
nr.current !== Kt && (nr.current = Kt, dt(0));
|
|
1492
|
+
}, [Kt]);
|
|
1493
|
+
const ft = _ ? G ?? Je.length : $e.length, Ue = R ? Math.max(1, Math.ceil(ft / oe)) : 1, ie = Math.min(xn, Ue - 1), K = R && !_ ? $e.slice(ie * oe, ie * oe + oe) : $e, So = ft === 0 ? 0 : R ? ie * oe + 1 : 1, No = R ? Math.min(ft, (ie + 1) * oe) : ft, Nn = ke(
|
|
878
1494
|
() => ({
|
|
879
|
-
sort:
|
|
880
|
-
const
|
|
881
|
-
return !!
|
|
1495
|
+
sort: me.filter((e) => {
|
|
1496
|
+
const r = t.find((l) => l.field === e.field);
|
|
1497
|
+
return !!r && Sn(r);
|
|
882
1498
|
}),
|
|
883
|
-
filters: Object.fromEntries(
|
|
884
|
-
search:
|
|
885
|
-
page:
|
|
886
|
-
pageSize:
|
|
1499
|
+
filters: Object.fromEntries(ut),
|
|
1500
|
+
search: Re.trim(),
|
|
1501
|
+
page: ie,
|
|
1502
|
+
pageSize: oe
|
|
887
1503
|
}),
|
|
888
1504
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
889
|
-
[
|
|
890
|
-
),
|
|
891
|
-
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
const [
|
|
1505
|
+
[me, t, ut, Re, ie, oe]
|
|
1506
|
+
), Co = JSON.stringify(Nn), zt = j(Nn);
|
|
1507
|
+
zt.current = Nn;
|
|
1508
|
+
const qt = j(S);
|
|
1509
|
+
qt.current = S;
|
|
1510
|
+
const [Do, Yt] = z(!1), [Cn, Dn] = z(!1), Tn = j(0), Vt = Fe((e) => {
|
|
895
1511
|
var s;
|
|
896
|
-
const
|
|
897
|
-
|
|
1512
|
+
const r = ++Tn.current, l = (s = qt.current) == null ? void 0 : s.call(qt, e);
|
|
1513
|
+
l && typeof l.then == "function" ? (Yt(!0), Dn(!1), l.then(
|
|
898
1514
|
() => {
|
|
899
|
-
|
|
1515
|
+
r === Tn.current && Yt(!1);
|
|
900
1516
|
},
|
|
901
1517
|
() => {
|
|
902
|
-
|
|
1518
|
+
r === Tn.current && (Yt(!1), Dn(!0));
|
|
903
1519
|
}
|
|
904
|
-
)) : (
|
|
1520
|
+
)) : (Yt(!1), Dn(!1));
|
|
905
1521
|
}, []);
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
}, [
|
|
909
|
-
|
|
910
|
-
}, [
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
(e) =>
|
|
915
|
-
),
|
|
916
|
-
if (!
|
|
917
|
-
if (
|
|
918
|
-
|
|
1522
|
+
ne(() => {
|
|
1523
|
+
_ && Vt(zt.current);
|
|
1524
|
+
}, [_, Co, Vt]), ne(() => {
|
|
1525
|
+
_ && R && xn > Ue - 1 && dt(Ue - 1);
|
|
1526
|
+
}, [_, R, xn, Ue]);
|
|
1527
|
+
const Nt = pe ?? Do, rr = (e) => e.map((r) => er.current.get(r)).filter((r) => r !== void 0), [De, Ht] = Et(
|
|
1528
|
+
m,
|
|
1529
|
+
x ?? [],
|
|
1530
|
+
(e) => E == null ? void 0 : E({ ids: e, rows: rr(e) })
|
|
1531
|
+
), Xt = ke(() => new Set(De), [De]), Gt = (e) => b ? b(e) : !0, Jt = j(null), or = j(!1), To = (e, r) => {
|
|
1532
|
+
if (!ue || !Gt(e.row)) return;
|
|
1533
|
+
if (ue === "single") {
|
|
1534
|
+
Ht(r ? [e.id] : []), Jt.current = e.id;
|
|
919
1535
|
return;
|
|
920
1536
|
}
|
|
921
|
-
const
|
|
922
|
-
if (s >= 0 &&
|
|
923
|
-
for (let
|
|
924
|
-
|
|
925
|
-
else
|
|
926
|
-
|
|
927
|
-
},
|
|
928
|
-
const
|
|
929
|
-
|
|
930
|
-
},
|
|
931
|
-
value:
|
|
932
|
-
formattedValue:
|
|
933
|
-
row:
|
|
934
|
-
rowIndex:
|
|
1537
|
+
const l = new Set(De), s = or.current && Jt.current !== null ? K.findIndex((f) => f.id === Jt.current) : -1, c = K.findIndex((f) => f.id === e.id);
|
|
1538
|
+
if (s >= 0 && c >= 0)
|
|
1539
|
+
for (let f = Math.min(s, c); f <= Math.max(s, c); f++)
|
|
1540
|
+
Gt(K[f].row) && (r ? l.add(K[f].id) : l.delete(K[f].id));
|
|
1541
|
+
else r ? l.add(e.id) : l.delete(e.id);
|
|
1542
|
+
Jt.current = e.id, Ht([...l]);
|
|
1543
|
+
}, Ct = ke(() => $e.filter((e) => Gt(e.row)), [$e, b]), ir = Ct.filter((e) => Xt.has(e.id)).length, lr = Ct.length > 0 && ir === Ct.length, sr = (e) => {
|
|
1544
|
+
const r = new Set(De);
|
|
1545
|
+
Ct.forEach((l) => e ? r.add(l.id) : r.delete(l.id)), Ht([...r]);
|
|
1546
|
+
}, Qt = (e, r, l) => ({
|
|
1547
|
+
value: ve(r, e.field),
|
|
1548
|
+
formattedValue: It(e, r),
|
|
1549
|
+
row: r,
|
|
1550
|
+
rowIndex: l,
|
|
935
1551
|
field: e.field,
|
|
936
1552
|
column: e
|
|
937
|
-
}),
|
|
938
|
-
const
|
|
939
|
-
return typeof
|
|
940
|
-
},
|
|
941
|
-
const
|
|
1553
|
+
}), Fn = (e, r) => {
|
|
1554
|
+
const l = e.editable ?? o;
|
|
1555
|
+
return typeof l == "function" ? l(r) : !!l;
|
|
1556
|
+
}, Zt = (e, r) => Fn(e, r) && !(e.type === "boolean" && !e.cellEditor), Fo = (e, r) => {
|
|
1557
|
+
const l = Qt(e, r.row, r.index), s = Fn(e, l);
|
|
942
1558
|
return {
|
|
943
|
-
...
|
|
1559
|
+
...l,
|
|
944
1560
|
editable: s,
|
|
945
|
-
updateValue: (
|
|
1561
|
+
updateValue: (c) => s && cr(r, e, { value: c })
|
|
946
1562
|
};
|
|
947
|
-
},
|
|
948
|
-
if (
|
|
949
|
-
const
|
|
950
|
-
let
|
|
951
|
-
|
|
952
|
-
},
|
|
953
|
-
var
|
|
954
|
-
return (
|
|
955
|
-
},
|
|
956
|
-
|
|
957
|
-
},
|
|
958
|
-
for (const
|
|
959
|
-
const
|
|
960
|
-
if (
|
|
1563
|
+
}, ar = (e, r) => {
|
|
1564
|
+
if (!Sn(e)) return;
|
|
1565
|
+
const l = me.find((f) => f.field === e.field), s = l ? l.direction === "asc" ? "desc" : null : "asc";
|
|
1566
|
+
let c;
|
|
1567
|
+
r && D ? s ? l ? c = me.map((f) => f.field === e.field ? { ...f, direction: s } : f) : c = [...me, { field: e.field, direction: s }] : c = me.filter((f) => f.field !== e.field) : c = s ? [{ field: e.field, direction: s }] : [], go(c);
|
|
1568
|
+
}, en = (e, r) => {
|
|
1569
|
+
var l;
|
|
1570
|
+
return (l = jt.current.get(jn(e, r))) == null ? void 0 : l.focus();
|
|
1571
|
+
}, Ae = () => {
|
|
1572
|
+
Oe.current += 1, Ge(null);
|
|
1573
|
+
}, Eo = (e) => {
|
|
1574
|
+
for (const r of at.current) {
|
|
1575
|
+
const l = ve(r, e.field);
|
|
1576
|
+
if (l != null && l !== "") return l;
|
|
961
1577
|
}
|
|
962
|
-
},
|
|
963
|
-
if (!
|
|
964
|
-
const s =
|
|
965
|
-
let
|
|
966
|
-
return
|
|
1578
|
+
}, tn = (e, r, l = {}) => {
|
|
1579
|
+
if (!Zt(r, Qt(r, e.row, e.index))) return !1;
|
|
1580
|
+
const s = ve(e.row, r.field);
|
|
1581
|
+
let c;
|
|
1582
|
+
return r.cellEditor ? c = s : r.type === "date" ? c = he(s) ?? "" : c = l.text ?? (s == null ? "" : String(s)), Wt.current = c, Oe.current += 1, Ge({
|
|
967
1583
|
id: e.id,
|
|
968
|
-
field:
|
|
969
|
-
draft:
|
|
970
|
-
session:
|
|
971
|
-
select:
|
|
1584
|
+
field: r.field,
|
|
1585
|
+
draft: c,
|
|
1586
|
+
session: Oe.current,
|
|
1587
|
+
select: l.select ?? "end",
|
|
972
1588
|
invalid: !1
|
|
973
1589
|
}), !0;
|
|
974
|
-
},
|
|
975
|
-
const s =
|
|
976
|
-
let
|
|
977
|
-
if ("value" in
|
|
978
|
-
|
|
979
|
-
else if (
|
|
980
|
-
|
|
981
|
-
else if (
|
|
982
|
-
if (
|
|
983
|
-
|
|
984
|
-
} else if (
|
|
985
|
-
if (
|
|
1590
|
+
}, cr = (e, r, l) => {
|
|
1591
|
+
const s = at.current[e.index] ?? e.row, c = ve(s, r.field);
|
|
1592
|
+
let f;
|
|
1593
|
+
if ("value" in l)
|
|
1594
|
+
f = l.value;
|
|
1595
|
+
else if (r.valueParser)
|
|
1596
|
+
f = r.valueParser(l.text, s);
|
|
1597
|
+
else if (r.type === "date") {
|
|
1598
|
+
if (l.text !== "" && !se(l.text)) return !1;
|
|
1599
|
+
f = hi(l.text, c ?? Eo(r));
|
|
1600
|
+
} else if (r.type === "number")
|
|
1601
|
+
if (l.text.trim() === "") f = null;
|
|
986
1602
|
else {
|
|
987
|
-
const
|
|
988
|
-
if (!Number.isFinite(
|
|
989
|
-
|
|
1603
|
+
const M = Number(l.text);
|
|
1604
|
+
if (!Number.isFinite(M)) return !1;
|
|
1605
|
+
f = M;
|
|
990
1606
|
}
|
|
991
1607
|
else
|
|
992
|
-
|
|
993
|
-
if (
|
|
994
|
-
if (
|
|
995
|
-
const
|
|
996
|
-
if (
|
|
997
|
-
} else if (Object.is(
|
|
1608
|
+
f = l.text;
|
|
1609
|
+
if (r.type === "date") {
|
|
1610
|
+
if (he(f) === he(c)) return !0;
|
|
1611
|
+
const M = he(f);
|
|
1612
|
+
if (M && (r.dateMin && M < r.dateMin || r.dateMax && M > r.dateMax)) return !1;
|
|
1613
|
+
} else if (Object.is(f, c))
|
|
998
1614
|
return !0;
|
|
999
|
-
if (
|
|
1000
|
-
const
|
|
1001
|
-
return
|
|
1002
|
-
},
|
|
1003
|
-
const s = K.findIndex((
|
|
1004
|
-
if (s < 0 ||
|
|
1005
|
-
const
|
|
1006
|
-
if (
|
|
1007
|
-
const
|
|
1008
|
-
for (let
|
|
1009
|
-
if (
|
|
1615
|
+
if (r.validate && !r.validate(f, s)) return !1;
|
|
1616
|
+
const y = zn(s, r.field, f), N = at.current.map((M, O) => O === e.index ? y : M);
|
|
1617
|
+
return Vn(N), d == null || d({ rowId: e.id, rowIndex: e.index, field: r.field, oldValue: c, newValue: f, row: y }), a == null || a(N), !0;
|
|
1618
|
+
}, dr = (e, r, l) => {
|
|
1619
|
+
const s = K.findIndex((O) => O.id === e.id), c = W.findIndex((O) => O.field === r);
|
|
1620
|
+
if (s < 0 || c < 0) return null;
|
|
1621
|
+
const f = (O, ee) => Zt(ee, Qt(ee, O.row, O.index));
|
|
1622
|
+
if (l === "down" || l === "up") {
|
|
1623
|
+
const O = l === "down" ? 1 : -1;
|
|
1624
|
+
for (let ee = s + O; ee >= 0 && ee < K.length; ee += O)
|
|
1625
|
+
if (f(K[ee], W[c])) return { entry: K[ee], col: W[c] };
|
|
1010
1626
|
return null;
|
|
1011
1627
|
}
|
|
1012
|
-
const
|
|
1013
|
-
let
|
|
1014
|
-
for (;
|
|
1015
|
-
for (;
|
|
1016
|
-
if (
|
|
1017
|
-
|
|
1628
|
+
const y = l === "right" ? 1 : -1;
|
|
1629
|
+
let N = s, M = c + y;
|
|
1630
|
+
for (; N >= 0 && N < K.length; ) {
|
|
1631
|
+
for (; M >= 0 && M < W.length; ) {
|
|
1632
|
+
if (f(K[N], W[M])) return { entry: K[N], col: W[M] };
|
|
1633
|
+
M += y;
|
|
1018
1634
|
}
|
|
1019
|
-
|
|
1635
|
+
N += y, M = y > 0 ? 0 : W.length - 1;
|
|
1020
1636
|
}
|
|
1021
1637
|
return null;
|
|
1022
|
-
},
|
|
1023
|
-
const { move:
|
|
1024
|
-
if (!
|
|
1025
|
-
return
|
|
1026
|
-
const
|
|
1027
|
-
return
|
|
1028
|
-
},
|
|
1638
|
+
}, Qe = (e, r, l, s = {}) => {
|
|
1639
|
+
const { move: c = "none", focus: f = !0 } = s;
|
|
1640
|
+
if (!cr(e, r, l))
|
|
1641
|
+
return Ge((N) => N && { ...N, invalid: !0 }), !1;
|
|
1642
|
+
const y = c === "none" ? null : dr(e, r.field, c);
|
|
1643
|
+
return y ? tn(y.entry, y.col, { select: "all" }) : (Ae(), f && en(e.id, r.field)), !0;
|
|
1644
|
+
}, ur = (e, r, l) => {
|
|
1029
1645
|
if (e.nativeEvent.isComposing) return;
|
|
1030
|
-
const s = e.currentTarget.value,
|
|
1646
|
+
const s = e.currentTarget.value, c = io(e.currentTarget);
|
|
1031
1647
|
if (e.key === "Enter") {
|
|
1032
|
-
if (e.preventDefault(),
|
|
1033
|
-
const
|
|
1034
|
-
|
|
1648
|
+
if (e.preventDefault(), c) return Ge((y) => y && { ...y, invalid: !0 });
|
|
1649
|
+
const f = u ? e.shiftKey ? "up" : "down" : "none";
|
|
1650
|
+
Qe(r, l, { text: s }, { move: f });
|
|
1035
1651
|
} else if (e.key === "Escape")
|
|
1036
|
-
e.preventDefault(),
|
|
1037
|
-
else if (e.key === "Tab" && !
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1652
|
+
e.preventDefault(), Ae(), en(r.id, l.field);
|
|
1653
|
+
else if (e.key === "Tab" && !c) {
|
|
1654
|
+
const f = e.shiftKey ? "left" : "right";
|
|
1655
|
+
dr(r, l.field, f) && (e.preventDefault(), Qe(r, l, { text: s }, { move: f }));
|
|
1040
1656
|
}
|
|
1041
|
-
},
|
|
1042
|
-
var
|
|
1043
|
-
const
|
|
1044
|
-
if (!
|
|
1045
|
-
|
|
1046
|
-
const
|
|
1047
|
-
if (
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1657
|
+
}, Io = (e, r) => {
|
|
1658
|
+
var f;
|
|
1659
|
+
const l = K[e], s = W[r];
|
|
1660
|
+
if (!l || !s) return;
|
|
1661
|
+
Jn({ id: l.id, field: s.field }), vn.current = jn(l.id, s.field);
|
|
1662
|
+
const c = kt.current;
|
|
1663
|
+
if (de && c) {
|
|
1664
|
+
const y = ((f = c.querySelector("thead")) == null ? void 0 : f.clientHeight) ?? 0, N = e * ge;
|
|
1665
|
+
N < c.scrollTop ? c.scrollTo({ top: N, behavior: "auto" }) : N + ge > c.scrollTop + c.clientHeight - y && c.scrollTo({ top: N + ge - c.clientHeight + y, behavior: "auto" });
|
|
1050
1666
|
}
|
|
1051
1667
|
};
|
|
1052
|
-
|
|
1053
|
-
const e =
|
|
1668
|
+
ne(() => {
|
|
1669
|
+
const e = vn.current;
|
|
1054
1670
|
if (!e) return;
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1671
|
+
const r = jt.current.get(e);
|
|
1672
|
+
r && (vn.current = null, r.focus());
|
|
1057
1673
|
});
|
|
1058
|
-
const
|
|
1059
|
-
if (!
|
|
1060
|
-
let s = K.findIndex((
|
|
1061
|
-
if (s < 0 ||
|
|
1674
|
+
const Mo = (e, r, l) => {
|
|
1675
|
+
if (!Ve) return !1;
|
|
1676
|
+
let s = K.findIndex((f) => f.id === r.id), c = W.findIndex((f) => f.field === l.field);
|
|
1677
|
+
if (s < 0 || c < 0) return !1;
|
|
1062
1678
|
switch (e.key) {
|
|
1063
1679
|
case "ArrowDown":
|
|
1064
1680
|
s += 1;
|
|
@@ -1067,517 +1683,657 @@ function ho({
|
|
|
1067
1683
|
s -= 1;
|
|
1068
1684
|
break;
|
|
1069
1685
|
case "ArrowRight":
|
|
1070
|
-
|
|
1686
|
+
c += 1;
|
|
1071
1687
|
break;
|
|
1072
1688
|
case "ArrowLeft":
|
|
1073
|
-
|
|
1689
|
+
c -= 1;
|
|
1074
1690
|
break;
|
|
1075
1691
|
case "PageDown":
|
|
1076
|
-
s +=
|
|
1692
|
+
s += oo;
|
|
1077
1693
|
break;
|
|
1078
1694
|
case "PageUp":
|
|
1079
|
-
s -=
|
|
1695
|
+
s -= oo;
|
|
1080
1696
|
break;
|
|
1081
1697
|
case "Home":
|
|
1082
|
-
|
|
1698
|
+
c = 0, (e.ctrlKey || e.metaKey) && (s = 0);
|
|
1083
1699
|
break;
|
|
1084
1700
|
case "End":
|
|
1085
|
-
|
|
1701
|
+
c = W.length - 1, (e.ctrlKey || e.metaKey) && (s = K.length - 1);
|
|
1086
1702
|
break;
|
|
1087
1703
|
default:
|
|
1088
1704
|
return !1;
|
|
1089
1705
|
}
|
|
1090
|
-
return e.preventDefault(),
|
|
1091
|
-
},
|
|
1092
|
-
e.target === e.currentTarget && (
|
|
1706
|
+
return e.preventDefault(), Io(Math.max(0, Math.min(K.length - 1, s)), Math.max(0, Math.min(W.length - 1, c))), !0;
|
|
1707
|
+
}, $o = (e, r, l, s) => {
|
|
1708
|
+
e.target === e.currentTarget && (Mo(e, r, l) || Zt(l, s) && (e.key === "Enter" || e.key === "F2" ? (e.preventDefault(), tn(r, l)) : !l.cellEditor && l.type !== "date" && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), tn(r, l, { text: e.key }))));
|
|
1093
1709
|
};
|
|
1094
|
-
|
|
1095
|
-
if (!
|
|
1096
|
-
const e =
|
|
1097
|
-
if (
|
|
1098
|
-
const
|
|
1099
|
-
return
|
|
1100
|
-
}, [
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
if (
|
|
1104
|
-
|
|
1710
|
+
pn(() => {
|
|
1711
|
+
if (!de || !kt.current) return;
|
|
1712
|
+
const e = kt.current, r = () => Zn((s) => s.height === e.clientHeight ? s : { ...s, height: e.clientHeight });
|
|
1713
|
+
if (r(), typeof ResizeObserver > "u") return;
|
|
1714
|
+
const l = new ResizeObserver(r);
|
|
1715
|
+
return l.observe(e), () => l.disconnect();
|
|
1716
|
+
}, [de]);
|
|
1717
|
+
const Dt = de && !Nt && K.length > 0, Po = kn.height || (typeof Q == "number" ? Q : 400), nn = Dt ? Math.max(0, Math.floor(kn.top / ge) - gt) : 0, En = Dt ? Math.min(K.length, Math.ceil((kn.top + Po) / ge) + gt) : K.length, fr = Dt ? K.slice(nn, En) : K, Lo = `${ie}|${oe}|${JSON.stringify(me)}|${Re}|${JSON.stringify(ct)}`, hr = j(!0);
|
|
1718
|
+
ne(() => {
|
|
1719
|
+
if (hr.current) {
|
|
1720
|
+
hr.current = !1;
|
|
1105
1721
|
return;
|
|
1106
1722
|
}
|
|
1107
|
-
const e =
|
|
1723
|
+
const e = kt.current;
|
|
1108
1724
|
e && typeof e.scrollTo == "function" && e.scrollTop > 0 && e.scrollTo({ top: 0, behavior: "smooth" });
|
|
1109
|
-
}, [
|
|
1110
|
-
const
|
|
1725
|
+
}, [Lo]);
|
|
1726
|
+
const pr = (typeof re == "string" ? re : re == null ? void 0 : re.enter) ?? "slide-up", In = (typeof re == "string" ? re : (re == null ? void 0 : re.exit) ?? (re == null ? void 0 : re.enter)) ?? "slide-up", Mn = Rt && !de, gr = Mn && (In !== "none" || !!Me), mr = rt ?? 380, br = ot ?? 28, rn = j(/* @__PURE__ */ new Map());
|
|
1727
|
+
let Oo = 0;
|
|
1728
|
+
const Ro = (e) => {
|
|
1729
|
+
let r = rn.current.get(e);
|
|
1730
|
+
return r === void 0 && (r = Oo++, rn.current.set(e, r)), Math.min(r, 24);
|
|
1731
|
+
}, [Te, yr] = z([]), xr = j({ rows: [], order: [], pageKey: "" }), Be = j(/* @__PURE__ */ new Map()), $n = `${ie}|${oe}|${_}`, Pn = Fe((e) => {
|
|
1732
|
+
const r = Be.current.get(e);
|
|
1733
|
+
r !== void 0 && clearTimeout(r), Be.current.delete(e), yr((l) => {
|
|
1734
|
+
const s = l.find((c) => c.id === e);
|
|
1735
|
+
return s ? l.filter((c) => c.id !== e).map((c) => c.afterId === e ? { ...c, afterId: s.afterId } : c) : l;
|
|
1736
|
+
});
|
|
1737
|
+
}, []);
|
|
1738
|
+
pn(() => {
|
|
1739
|
+
const e = xr.current, r = new Set(K.map((c) => c.id));
|
|
1740
|
+
rn.current.forEach((c, f) => !r.has(f) && rn.current.delete(f));
|
|
1741
|
+
const l = !gr || Nt || Cn || e.pageKey !== $n || Zi();
|
|
1742
|
+
let s = Te;
|
|
1743
|
+
if (l)
|
|
1744
|
+
s = [];
|
|
1745
|
+
else {
|
|
1746
|
+
s = s.filter((f) => !r.has(f.id));
|
|
1747
|
+
const c = e.rows.filter((f) => !r.has(f.id) && !s.some((y) => y.id === f.id));
|
|
1748
|
+
if (c.length > 0) {
|
|
1749
|
+
const f = c.map((y, N) => {
|
|
1750
|
+
const M = e.order.indexOf(y.id);
|
|
1751
|
+
return { id: y.id, entry: y, afterId: M > 0 ? e.order[M - 1] : null, batch: N };
|
|
1752
|
+
});
|
|
1753
|
+
s = [...s, ...f];
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
(s.length !== Te.length || s.some((c, f) => c !== Te[f])) && yr(s), xr.current = { rows: K, order: ro(K, s).map((c) => c.kind === "row" ? c.entry.id : c.ghost.id), pageKey: $n };
|
|
1757
|
+
}, [K, Te, Nt, Cn, $n, gr]), ne(() => {
|
|
1758
|
+
const e = !!Me;
|
|
1759
|
+
Te.forEach((r) => {
|
|
1760
|
+
if (Be.current.has(r.id)) return;
|
|
1761
|
+
const l = e ? 2500 : mr * 0.8 + br * Math.min(r.batch, 24) + 250;
|
|
1762
|
+
Be.current.set(r.id, setTimeout(() => Pn(r.id), l));
|
|
1763
|
+
}), Be.current.forEach((r, l) => {
|
|
1764
|
+
Te.some((s) => s.id === l) || (clearTimeout(r), Be.current.delete(l));
|
|
1765
|
+
});
|
|
1766
|
+
}, [Te, mr, br, Me, Pn]), ne(
|
|
1767
|
+
() => () => {
|
|
1768
|
+
Be.current.forEach((e) => clearTimeout(e)), Be.current.clear();
|
|
1769
|
+
},
|
|
1770
|
+
[]
|
|
1771
|
+
);
|
|
1772
|
+
const Uo = ke(() => ro(fr, Te), [fr, Te]), Ln = Object.keys(_n).length > 0, on = (e) => _n[e.field] ?? (typeof e.width == "number" ? e.width : el), Ao = (e) => Math.max(40, typeof e.minWidth == "number" ? e.minWidth : 60), Bo = (e, r) => {
|
|
1111
1773
|
e.preventDefault(), e.stopPropagation();
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
-
var
|
|
1115
|
-
return
|
|
1774
|
+
const l = { ..._n };
|
|
1775
|
+
Ln || W.forEach((O) => {
|
|
1776
|
+
var ee;
|
|
1777
|
+
return l[O.field] = ((ee = wt.current.get(O.field)) == null ? void 0 : ee.offsetWidth) ?? on(O);
|
|
1116
1778
|
});
|
|
1117
|
-
const s = e.clientX,
|
|
1118
|
-
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1779
|
+
const s = e.clientX, c = l[r.field] ?? on(r), f = e.currentTarget;
|
|
1780
|
+
f.setPointerCapture(e.pointerId), Gn(l);
|
|
1781
|
+
const y = (O) => Math.min(r.maxWidth ?? 1 / 0, Math.max(Ao(r), Math.round(O))), N = (O) => Gn((ee) => ({ ...ee, [r.field]: y(c + O.clientX - s) })), M = () => {
|
|
1782
|
+
f.removeEventListener("pointermove", N), f.removeEventListener("pointerup", M), f.removeEventListener("pointercancel", M);
|
|
1121
1783
|
};
|
|
1122
|
-
|
|
1784
|
+
f.addEventListener("pointermove", N), f.addEventListener("pointerup", M), f.addEventListener("pointercancel", M);
|
|
1123
1785
|
};
|
|
1124
|
-
|
|
1125
|
-
var
|
|
1786
|
+
pn(() => {
|
|
1787
|
+
var c, f;
|
|
1126
1788
|
const e = {};
|
|
1127
|
-
let
|
|
1128
|
-
for (const
|
|
1129
|
-
|
|
1130
|
-
let
|
|
1131
|
-
for (const
|
|
1132
|
-
|
|
1789
|
+
let r = ue && W.some((y) => y.pinned === "left") ? je : 0;
|
|
1790
|
+
for (const y of W)
|
|
1791
|
+
y.pinned === "left" && (e[y.field] = r, r += ((c = wt.current.get(y.field)) == null ? void 0 : c.offsetWidth) ?? 0);
|
|
1792
|
+
let l = 0;
|
|
1793
|
+
for (const y of [...W].reverse())
|
|
1794
|
+
y.pinned === "right" && (e[y.field] = l, l += ((f = wt.current.get(y.field)) == null ? void 0 : f.offsetWidth) ?? 0);
|
|
1133
1795
|
const s = Object.keys(e);
|
|
1134
|
-
(s.length !== Object.keys(
|
|
1135
|
-
}),
|
|
1136
|
-
const e = () =>
|
|
1796
|
+
(s.length !== Object.keys(Bt).length || s.some((y) => e[y] !== Bt[y])) && _o(e);
|
|
1797
|
+
}), ne(() => {
|
|
1798
|
+
const e = () => wo((r) => r + 1);
|
|
1137
1799
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
1138
1800
|
}, []);
|
|
1139
|
-
const
|
|
1140
|
-
className: e.pinned ?
|
|
1141
|
-
style: e.pinned === "left" ? { left:
|
|
1142
|
-
}),
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1801
|
+
const _r = W.map((e) => e.pinned).lastIndexOf("left"), Wo = W.findIndex((e) => e.pinned === "right"), ln = _r >= 0, wr = (e, r) => ({
|
|
1802
|
+
className: e.pinned ? U("rg-grid__pinned", `rg-grid__pinned--${e.pinned}`, r === _r && "rg-grid__pinned--edge", r === Wo && "rg-grid__pinned--edge") : void 0,
|
|
1803
|
+
style: e.pinned === "left" ? { left: Bt[e.field] ?? 0 } : e.pinned === "right" ? { right: Bt[e.field] ?? 0 } : void 0
|
|
1804
|
+
}), We = typeof He == "object" ? He : {}, sn = ke(() => {
|
|
1805
|
+
var r;
|
|
1806
|
+
const e = (r = We.formats) != null && r.length ? We.formats : ["csv"];
|
|
1807
|
+
return e.filter((l, s) => e.indexOf(l) === s);
|
|
1808
|
+
}, [He]), an = (e = {}) => {
|
|
1809
|
+
const r = { ...We, ...e, pdf: { ...We.pdf, ...e.pdf } }, l = r.scope ?? "filtered", s = l === "page" || l === "visible", c = s ? K : l === "selected" ? Je.filter((be) => Xt.has(be.id)) : $e, f = r.includeHidden ? t : W, y = s && R ? ie * oe : 0, N = f.map((be) => Mt(be) || be.field), M = [], O = [], ee = [];
|
|
1810
|
+
return c.forEach(({ row: be }, On) => {
|
|
1811
|
+
const dn = [], $ = [], Tt = {};
|
|
1812
|
+
f.forEach((J, Rn) => {
|
|
1813
|
+
const te = ve(be, J.field);
|
|
1814
|
+
let _e, le;
|
|
1815
|
+
if (J.type === "sequence") {
|
|
1816
|
+
const fn = Rr(J, On, J.sequenceRestartEachPage ? 0 : y);
|
|
1817
|
+
_e = fn, le = fn;
|
|
1818
|
+
} else J.exportValue ? (_e = J.exportValue(te, be), le = _e ?? null) : J.type === "date" ? (_e = he(te) ?? "", le = _e) : (_e = It(J, be), J.type === "number" && typeof te == "number" && Number.isFinite(te) || J.type === "boolean" && typeof te == "boolean" ? le = te : J.valueFormatter ? le = _e : te == null ? le = null : typeof te == "string" || typeof te == "boolean" || typeof te == "number" && Number.isFinite(te) ? le = te : te instanceof Date ? le = Number.isNaN(te.getTime()) ? null : te.toISOString() : le = _e);
|
|
1819
|
+
dn.push(_e), $.push(le);
|
|
1820
|
+
const un = r.jsonKeys === "header" ? N[Rn] : J.field;
|
|
1821
|
+
Tt[un] = J.type === "date" && le === "" ? null : le ?? null;
|
|
1822
|
+
}), M.push(dn), O.push($), ee.push(Tt);
|
|
1823
|
+
}), { opts: r, cols: f, headers: N, display: M, typed: O, records: ee };
|
|
1824
|
+
}, cn = (e, r) => `${e.filename ?? "export"}.${r}`, vr = (e = {}) => {
|
|
1825
|
+
const r = an(e);
|
|
1826
|
+
return Di(r.headers, r.display, { sanitize: r.opts.sanitize });
|
|
1151
1827
|
}, kr = (e = {}) => {
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1828
|
+
const r = { ...We, ...e };
|
|
1829
|
+
Ti(vr(e), cn(r, "csv"));
|
|
1830
|
+
}, Sr = (e = {}) => {
|
|
1831
|
+
const r = an(e);
|
|
1832
|
+
return JSON.stringify(r.records, null, r.opts.jsonIndent ?? 2);
|
|
1833
|
+
}, Nr = (e = {}) => {
|
|
1834
|
+
const r = { ...We, ...e };
|
|
1835
|
+
gn(new Blob([Sr(e)], { type: "application/json;charset=utf-8" }), cn(r, "json"));
|
|
1836
|
+
}, Cr = async (e = {}) => {
|
|
1837
|
+
const r = an(e), l = r.cols.map((s) => ({
|
|
1838
|
+
header: Mt(s) || s.field,
|
|
1839
|
+
kind: s.type === "number" || s.type === "sequence" ? "number" : s.type === "date" ? "date" : s.type === "boolean" ? "boolean" : "text",
|
|
1840
|
+
align: s.align ?? (s.type === "number" || s.type === "sequence" ? "right" : void 0)
|
|
1841
|
+
}));
|
|
1842
|
+
return Qi(l, r.typed, { sheetName: r.opts.sheetName });
|
|
1843
|
+
}, Dr = async (e = {}) => {
|
|
1844
|
+
const r = { ...We, ...e };
|
|
1845
|
+
gn(await Cr(e), cn(r, "xlsx"));
|
|
1846
|
+
}, Tr = async (e = {}) => {
|
|
1847
|
+
var l;
|
|
1848
|
+
const r = an(e);
|
|
1849
|
+
return Oi(
|
|
1850
|
+
{
|
|
1851
|
+
headers: r.headers,
|
|
1852
|
+
rows: r.display.map((s) => s.map((c) => c == null ? "" : String(c))),
|
|
1853
|
+
aligns: r.cols.map((s) => s.align ?? (s.type === "number" || s.type === "sequence" ? "right" : void 0)),
|
|
1854
|
+
fields: r.cols.map((s) => s.field)
|
|
1855
|
+
},
|
|
1856
|
+
r.opts.pdf,
|
|
1857
|
+
// Only when asked: read the grid's colours, stripes and borders from the page
|
|
1858
|
+
(l = r.opts.pdf) != null && l.matchGridStyle ? Ri(Qn.current) : void 0
|
|
1859
|
+
);
|
|
1860
|
+
}, Fr = async (e = {}) => {
|
|
1861
|
+
const r = { ...We, ...e };
|
|
1862
|
+
gn(await Tr(e), cn(r, "pdf"));
|
|
1863
|
+
}, Er = async (e, r = {}) => e === "csv" ? kr(r) : e === "json" ? Nr(r) : e === "xlsx" ? Dr(r) : Fr(r), Ir = async (e, r = {}) => {
|
|
1864
|
+
try {
|
|
1865
|
+
await Er(e, r);
|
|
1866
|
+
} catch (l) {
|
|
1867
|
+
const s = l instanceof Error ? l : new Error(String(l));
|
|
1868
|
+
mt ? mt(s, e) : console.error(`[react-gridix] ${e.toUpperCase()} export failed:`, s);
|
|
1869
|
+
}
|
|
1870
|
+
}, [Mr, jo] = z("visible"), Ko = Je.filter((e) => Xt.has(e.id)).length, $r = [
|
|
1871
|
+
{ value: "visible", label: "Visible rows", count: K.length },
|
|
1872
|
+
// Without pagination the visible rows already are every matching row
|
|
1873
|
+
...R ? [{ value: "filtered", label: "All matching rows", count: $e.length }] : [],
|
|
1874
|
+
...ue ? [{ value: "selected", label: "Selected rows", count: Ko }] : []
|
|
1875
|
+
], zo = $r.some((e) => e.value === Mr && e.count > 0) ? Mr : "visible";
|
|
1876
|
+
ne(() => {
|
|
1156
1877
|
Le && (Le.current = {
|
|
1157
|
-
getCsv:
|
|
1878
|
+
getCsv: vr,
|
|
1158
1879
|
exportCsv: kr,
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1880
|
+
getJson: Sr,
|
|
1881
|
+
exportJson: Nr,
|
|
1882
|
+
getXlsx: Cr,
|
|
1883
|
+
exportXlsx: Dr,
|
|
1884
|
+
getPdf: Tr,
|
|
1885
|
+
exportPdf: Fr,
|
|
1886
|
+
exportAs: Er,
|
|
1887
|
+
getSelectedRows: () => rr(De),
|
|
1888
|
+
getSelectedRowIds: () => De,
|
|
1889
|
+
selectAll: () => sr(!0),
|
|
1890
|
+
clearSelection: () => Ht([]),
|
|
1163
1891
|
refresh: () => {
|
|
1164
|
-
|
|
1892
|
+
_ && Vt(zt.current);
|
|
1165
1893
|
}
|
|
1166
1894
|
});
|
|
1167
|
-
}),
|
|
1895
|
+
}), ne(
|
|
1168
1896
|
() => () => {
|
|
1169
1897
|
Le && (Le.current = null);
|
|
1170
1898
|
},
|
|
1171
1899
|
[Le]
|
|
1172
1900
|
);
|
|
1173
|
-
const
|
|
1174
|
-
var
|
|
1175
|
-
const
|
|
1901
|
+
const Pr = (e) => {
|
|
1902
|
+
var l, s, c, f, y, N, M, O;
|
|
1903
|
+
const r = e.checkbox ?? {};
|
|
1176
1904
|
return {
|
|
1177
|
-
variant:
|
|
1178
|
-
indicator:
|
|
1179
|
-
className:
|
|
1180
|
-
style:
|
|
1905
|
+
variant: r.variant ?? Ce,
|
|
1906
|
+
indicator: r.indicator,
|
|
1907
|
+
className: r.className,
|
|
1908
|
+
style: r.style,
|
|
1181
1909
|
classNames: {
|
|
1182
|
-
root:
|
|
1183
|
-
control:
|
|
1184
|
-
indicator:
|
|
1185
|
-
label: (
|
|
1910
|
+
root: U(Y.checkbox, (l = r.classNames) == null ? void 0 : l.root),
|
|
1911
|
+
control: U(Y.checkboxControl, (s = r.classNames) == null ? void 0 : s.control),
|
|
1912
|
+
indicator: U(Y.checkboxIndicator, (c = r.classNames) == null ? void 0 : c.indicator),
|
|
1913
|
+
label: (f = r.classNames) == null ? void 0 : f.label
|
|
1186
1914
|
},
|
|
1187
1915
|
styles: {
|
|
1188
|
-
root: { ...
|
|
1189
|
-
control: { ...
|
|
1190
|
-
indicator: { ...
|
|
1191
|
-
label: (
|
|
1916
|
+
root: { ...A.checkbox, ...(y = r.styles) == null ? void 0 : y.root },
|
|
1917
|
+
control: { ...A.checkboxControl, ...(N = r.styles) == null ? void 0 : N.control },
|
|
1918
|
+
indicator: { ...A.checkboxIndicator, ...(M = r.styles) == null ? void 0 : M.indicator },
|
|
1919
|
+
label: (O = r.styles) == null ? void 0 : O.label
|
|
1192
1920
|
}
|
|
1193
1921
|
};
|
|
1194
|
-
},
|
|
1195
|
-
|
|
1922
|
+
}, Ze = (e) => e.stopPropagation(), qo = (e, r) => /* @__PURE__ */ h("span", { className: "rg-grid__checkbox-cell", onClick: Ze, onDoubleClick: Ze, children: /* @__PURE__ */ h(
|
|
1923
|
+
ht,
|
|
1196
1924
|
{
|
|
1197
|
-
...
|
|
1198
|
-
checked: !!
|
|
1199
|
-
disabled: !
|
|
1200
|
-
"aria-label": `Toggle ${
|
|
1201
|
-
onChange: (
|
|
1925
|
+
...Pr(e),
|
|
1926
|
+
checked: !!r.value,
|
|
1927
|
+
disabled: !r.editable,
|
|
1928
|
+
"aria-label": `Toggle ${et(e)}`,
|
|
1929
|
+
onChange: (l) => r.updateValue(l)
|
|
1202
1930
|
}
|
|
1203
|
-
) }),
|
|
1204
|
-
const
|
|
1205
|
-
const
|
|
1206
|
-
if (!
|
|
1207
|
-
const
|
|
1208
|
-
if (!!
|
|
1209
|
-
const
|
|
1210
|
-
return s.push({ rowId:
|
|
1931
|
+
) }), Lr = (e) => $e.filter((r) => Fn(e, Qt(e, r.row, r.index))), Yo = (e, r) => {
|
|
1932
|
+
const l = new Map(Lr(e).map((f) => [f.index, f])), s = [], c = at.current.map((f, y) => {
|
|
1933
|
+
const N = l.get(y);
|
|
1934
|
+
if (!N) return f;
|
|
1935
|
+
const M = ve(f, e.field);
|
|
1936
|
+
if (!!M === r || e.validate && !e.validate(r, f)) return f;
|
|
1937
|
+
const O = zn(f, e.field, r);
|
|
1938
|
+
return s.push({ rowId: N.id, rowIndex: y, field: e.field, oldValue: M, newValue: r, row: O }), O;
|
|
1211
1939
|
});
|
|
1212
|
-
s.length !== 0 && (
|
|
1213
|
-
},
|
|
1214
|
-
const
|
|
1215
|
-
return /* @__PURE__ */
|
|
1216
|
-
|
|
1940
|
+
s.length !== 0 && (Vn(c), s.forEach((f) => d == null ? void 0 : d(f)), a == null || a(c));
|
|
1941
|
+
}, Vo = (e) => {
|
|
1942
|
+
const r = Lr(e), l = r.length > 0 ? r : $e, s = l.filter((f) => !!ve(f.row, e.field)).length, c = l.length > 0 && s === l.length;
|
|
1943
|
+
return /* @__PURE__ */ h("span", { className: "rg-grid__header-checkbox", onClick: Ze, onDoubleClick: Ze, children: /* @__PURE__ */ h(
|
|
1944
|
+
ht,
|
|
1217
1945
|
{
|
|
1218
|
-
...
|
|
1219
|
-
checked:
|
|
1220
|
-
indeterminate: s > 0 && !
|
|
1221
|
-
disabled:
|
|
1222
|
-
label:
|
|
1223
|
-
"aria-label": `Select all ${
|
|
1224
|
-
onChange: (
|
|
1946
|
+
...Pr(e),
|
|
1947
|
+
checked: c,
|
|
1948
|
+
indeterminate: s > 0 && !c,
|
|
1949
|
+
disabled: r.length === 0,
|
|
1950
|
+
label: Mt(e) || void 0,
|
|
1951
|
+
"aria-label": `Select all ${et(e)}`,
|
|
1952
|
+
onChange: (f) => Yo(e, f)
|
|
1225
1953
|
}
|
|
1226
1954
|
) });
|
|
1227
|
-
},
|
|
1228
|
-
if (
|
|
1229
|
-
return /* @__PURE__ */
|
|
1955
|
+
}, Ho = (e, r, l) => {
|
|
1956
|
+
if (r.cellEditor)
|
|
1957
|
+
return /* @__PURE__ */ h(
|
|
1230
1958
|
"div",
|
|
1231
1959
|
{
|
|
1232
1960
|
className: "rg-grid__custom-editor",
|
|
1233
|
-
onBlur: (
|
|
1234
|
-
|
|
1961
|
+
onBlur: (c) => {
|
|
1962
|
+
c.currentTarget.contains(c.relatedTarget) || l.session === Oe.current && (Qe(e, r, { value: Wt.current }, { focus: !1 }) || Ae());
|
|
1235
1963
|
},
|
|
1236
|
-
onKeyDown: (
|
|
1237
|
-
|
|
1964
|
+
onKeyDown: (c) => {
|
|
1965
|
+
c.key === "Escape" && (c.preventDefault(), c.stopPropagation(), Ae(), en(e.id, r.field));
|
|
1238
1966
|
},
|
|
1239
|
-
children:
|
|
1240
|
-
value:
|
|
1967
|
+
children: Ke(r.cellEditor, {
|
|
1968
|
+
value: l.draft,
|
|
1241
1969
|
row: e.row,
|
|
1242
1970
|
rowIndex: e.index,
|
|
1243
|
-
field:
|
|
1244
|
-
column:
|
|
1245
|
-
onChange: (
|
|
1246
|
-
|
|
1971
|
+
field: r.field,
|
|
1972
|
+
column: r,
|
|
1973
|
+
onChange: (c) => {
|
|
1974
|
+
Wt.current = c, Ge((f) => f && f.session === l.session ? { ...f, draft: c, invalid: !1 } : f);
|
|
1247
1975
|
},
|
|
1248
|
-
onCommit: (
|
|
1249
|
-
|
|
1976
|
+
onCommit: (c, f = "none") => {
|
|
1977
|
+
l.session === Oe.current && Qe(e, r, { value: c === void 0 ? Wt.current : c }, { move: f });
|
|
1250
1978
|
},
|
|
1251
1979
|
onCancel: () => {
|
|
1252
|
-
|
|
1980
|
+
Ae(), en(e.id, r.field);
|
|
1253
1981
|
}
|
|
1254
1982
|
})
|
|
1255
1983
|
}
|
|
1256
1984
|
);
|
|
1257
|
-
const s =
|
|
1258
|
-
return s ? /* @__PURE__ */
|
|
1259
|
-
|
|
1985
|
+
const s = r.type === "date";
|
|
1986
|
+
return s ? /* @__PURE__ */ h(
|
|
1987
|
+
pi,
|
|
1260
1988
|
{
|
|
1261
|
-
value:
|
|
1262
|
-
label: `Edit ${
|
|
1263
|
-
invalid:
|
|
1264
|
-
min:
|
|
1265
|
-
max:
|
|
1266
|
-
locale:
|
|
1267
|
-
theme:
|
|
1268
|
-
className:
|
|
1269
|
-
style: { textAlign:
|
|
1270
|
-
onChange: (
|
|
1271
|
-
onPick: (
|
|
1272
|
-
|
|
1989
|
+
value: l.draft === null || l.draft === void 0 ? "" : String(l.draft),
|
|
1990
|
+
label: `Edit ${et(r)}`,
|
|
1991
|
+
invalid: l.invalid,
|
|
1992
|
+
min: r.dateMin,
|
|
1993
|
+
max: r.dateMax,
|
|
1994
|
+
locale: r.dateLocale,
|
|
1995
|
+
theme: F,
|
|
1996
|
+
className: U("rg-grid__editor", l.invalid && "rg-grid__editor--invalid", Y.editor),
|
|
1997
|
+
style: { textAlign: r.align, ...A.editor },
|
|
1998
|
+
onChange: (c) => Ge((f) => f && { ...f, draft: c, invalid: !1 }),
|
|
1999
|
+
onPick: (c) => {
|
|
2000
|
+
l.session === Oe.current && Qe(e, r, { text: c }, { focus: !0 });
|
|
1273
2001
|
},
|
|
1274
|
-
onBlur: (
|
|
1275
|
-
|
|
2002
|
+
onBlur: (c) => {
|
|
2003
|
+
l.session === Oe.current && (Qe(e, r, { text: c.currentTarget.value }, { focus: !1 }) || Ae());
|
|
1276
2004
|
},
|
|
1277
|
-
onKeyDown: (
|
|
2005
|
+
onKeyDown: (c) => ur(c, e, r)
|
|
1278
2006
|
}
|
|
1279
|
-
) : /* @__PURE__ */
|
|
2007
|
+
) : /* @__PURE__ */ h(
|
|
1280
2008
|
"input",
|
|
1281
2009
|
{
|
|
1282
2010
|
autoFocus: !0,
|
|
1283
2011
|
type: s ? "date" : "text",
|
|
1284
|
-
min: s ?
|
|
1285
|
-
max: s ?
|
|
1286
|
-
className:
|
|
1287
|
-
style: { textAlign:
|
|
1288
|
-
value:
|
|
1289
|
-
inputMode:
|
|
1290
|
-
"aria-label": `Edit ${
|
|
1291
|
-
"aria-invalid":
|
|
1292
|
-
onChange: (
|
|
1293
|
-
const
|
|
1294
|
-
|
|
2012
|
+
min: s ? r.dateMin : void 0,
|
|
2013
|
+
max: s ? r.dateMax : void 0,
|
|
2014
|
+
className: U("rg-grid__editor", l.invalid && "rg-grid__editor--invalid", Y.editor),
|
|
2015
|
+
style: { textAlign: r.align, ...A.editor },
|
|
2016
|
+
value: l.draft === null || l.draft === void 0 ? "" : String(l.draft),
|
|
2017
|
+
inputMode: r.type === "number" ? "decimal" : void 0,
|
|
2018
|
+
"aria-label": `Edit ${et(r)}`,
|
|
2019
|
+
"aria-invalid": l.invalid || void 0,
|
|
2020
|
+
onChange: (c) => {
|
|
2021
|
+
const f = c.target.value;
|
|
2022
|
+
Ge((y) => y && { ...y, draft: f, invalid: !1 });
|
|
1295
2023
|
},
|
|
1296
|
-
onFocus: (
|
|
1297
|
-
const
|
|
1298
|
-
s || (
|
|
2024
|
+
onFocus: (c) => {
|
|
2025
|
+
const f = c.currentTarget;
|
|
2026
|
+
s || (l.select === "all" ? f.select() : f.setSelectionRange(f.value.length, f.value.length));
|
|
1299
2027
|
},
|
|
1300
|
-
onBlur: (
|
|
1301
|
-
if (
|
|
1302
|
-
if (
|
|
1303
|
-
|
|
2028
|
+
onBlur: (c) => {
|
|
2029
|
+
if (l.session === Oe.current) {
|
|
2030
|
+
if (io(c.currentTarget)) return Ae();
|
|
2031
|
+
Qe(e, r, { text: c.currentTarget.value }, { focus: !1 }) || Ae();
|
|
1304
2032
|
}
|
|
1305
2033
|
},
|
|
1306
|
-
onKeyDown: (
|
|
2034
|
+
onKeyDown: (c) => ur(c, e, r)
|
|
1307
2035
|
}
|
|
1308
2036
|
);
|
|
1309
|
-
},
|
|
2037
|
+
}, Xo = ke(() => {
|
|
1310
2038
|
const e = /* @__PURE__ */ new Map();
|
|
1311
|
-
for (const
|
|
1312
|
-
|
|
2039
|
+
for (const r of W)
|
|
2040
|
+
r.filterable && !r.filterRenderer && Kr(r) === "select" && e.set(r.field, bi(r, Ut, (l) => ve(l, r.field), (l) => It(r, l)));
|
|
1313
2041
|
return e;
|
|
1314
|
-
}, [
|
|
2042
|
+
}, [W, Ut]), Go = {
|
|
2043
|
+
...rt !== void 0 ? { "--rg-row-duration": `${rt}ms`, "--rg-row-exit-duration": `${Math.round(rt * 0.8)}ms` } : null,
|
|
2044
|
+
...ot !== void 0 ? { "--rg-row-stagger": `${ot}ms` } : null
|
|
2045
|
+
}, Jo = Ot || !!ye, Qo = ye ? { "--rg-stripe-a": ye[0], "--rg-stripe-b": ye[1] } : void 0, Zo = Pe && R && (H === "top" || H === "both"), ei = Pe && R && (H === "bottom" || H === "both"), ti = Se && (C || !!yt || pt || !!He), Or = (e) => /* @__PURE__ */ I(
|
|
1315
2046
|
"div",
|
|
1316
2047
|
{
|
|
1317
|
-
className:
|
|
1318
|
-
style:
|
|
2048
|
+
className: U("rg-grid__footer", e === "top" && "rg-grid__footer--top", Y.footer),
|
|
2049
|
+
style: A.footer,
|
|
1319
2050
|
"data-position": e,
|
|
1320
2051
|
children: [
|
|
1321
|
-
/* @__PURE__ */
|
|
1322
|
-
|
|
1323
|
-
|
|
2052
|
+
/* @__PURE__ */ I("span", { ...Z("rowCount", "rg-grid__count"), children: [
|
|
2053
|
+
ft === 0 ? "0 rows" : `${So}–${No} of ${ft}`,
|
|
2054
|
+
ue && De.length > 0 ? ` · ${De.length} selected` : ""
|
|
1324
2055
|
] }),
|
|
1325
|
-
/* @__PURE__ */
|
|
1326
|
-
/* @__PURE__ */
|
|
2056
|
+
/* @__PURE__ */ I("div", { ...Z("pagination", "rg-grid__pagination"), children: [
|
|
2057
|
+
/* @__PURE__ */ I("label", { className: "rg-grid__page-size-label", children: [
|
|
1327
2058
|
"Rows per page",
|
|
1328
|
-
/* @__PURE__ */
|
|
2059
|
+
/* @__PURE__ */ h("select", { value: oe, onChange: (r) => bo(Number(r.target.value)), ...Z("pageSize", "rg-grid__page-size"), children: (Ee.includes(oe) ? Ee : [...Ee, oe].sort((r, l) => r - l)).map((r) => /* @__PURE__ */ h("option", { value: r, children: r }, r)) })
|
|
1329
2060
|
] }),
|
|
1330
|
-
/* @__PURE__ */
|
|
1331
|
-
/* @__PURE__ */
|
|
1332
|
-
/* @__PURE__ */
|
|
2061
|
+
/* @__PURE__ */ h("button", { type: "button", "aria-label": "First page", disabled: ie === 0, onClick: () => dt(0), ...Z("pageButton", "rg-grid__page-btn"), children: "«" }),
|
|
2062
|
+
/* @__PURE__ */ h("button", { type: "button", "aria-label": "Previous page", disabled: ie === 0, onClick: () => dt(ie - 1), ...Z("pageButton", "rg-grid__page-btn"), children: "‹" }),
|
|
2063
|
+
/* @__PURE__ */ I("span", { ...Z("pageInfo", "rg-grid__page-info"), children: [
|
|
1333
2064
|
"Page ",
|
|
1334
|
-
|
|
2065
|
+
ie + 1,
|
|
1335
2066
|
" of ",
|
|
1336
|
-
|
|
2067
|
+
Ue
|
|
1337
2068
|
] }),
|
|
1338
|
-
/* @__PURE__ */
|
|
1339
|
-
/* @__PURE__ */
|
|
2069
|
+
/* @__PURE__ */ h("button", { type: "button", "aria-label": "Next page", disabled: ie >= Ue - 1, onClick: () => dt(ie + 1), ...Z("pageButton", "rg-grid__page-btn"), children: "›" }),
|
|
2070
|
+
/* @__PURE__ */ h("button", { type: "button", "aria-label": "Last page", disabled: ie >= Ue - 1, onClick: () => dt(Ue - 1), ...Z("pageButton", "rg-grid__page-btn"), children: "»" })
|
|
1340
2071
|
] })
|
|
1341
2072
|
]
|
|
1342
2073
|
}
|
|
1343
|
-
),
|
|
2074
|
+
), ni = (e, r, l) => {
|
|
2075
|
+
const s = e.sortIndicator ?? Xe;
|
|
2076
|
+
return /* @__PURE__ */ h("span", { ...Z("sortIndicator", U("rg-grid__sort", s !== "default" && "rg-grid__sort--custom")), "aria-hidden": "true", "data-direction": r ?? "none", children: s === "arrow" ? /* @__PURE__ */ h(Ai, { direction: r, priority: l }) : s !== "default" ? Ke(s, { column: e, direction: r, priority: l }) : /* @__PURE__ */ I(tt, { children: [
|
|
2077
|
+
r === "asc" ? "▲" : r === "desc" ? "▼" : "↕",
|
|
2078
|
+
l !== void 0 && /* @__PURE__ */ h("sup", { className: "rg-grid__sort-order", children: l })
|
|
2079
|
+
] }) });
|
|
2080
|
+
}, ri = (e) => /* @__PURE__ */ h("tr", { className: "rg-grid__tr rg-grid__skeleton-row", "aria-hidden": "true", style: de ? { height: ge } : void 0, children: nt ? (
|
|
1344
2081
|
// A custom component draws the whole row content inside one wide cell
|
|
1345
|
-
/* @__PURE__ */
|
|
1346
|
-
) : /* @__PURE__ */
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
] }) }, `sk${e}`),
|
|
1350
|
-
const { row:
|
|
1351
|
-
return /* @__PURE__ */
|
|
2082
|
+
/* @__PURE__ */ h("td", { colSpan: St, className: "rg-grid__td rg-grid__skeleton-cell", children: Ke(nt, { rowIndex: e, columns: W }) })
|
|
2083
|
+
) : /* @__PURE__ */ I(tt, { children: [
|
|
2084
|
+
ue && /* @__PURE__ */ h("td", { className: "rg-grid__td", children: /* @__PURE__ */ h("span", { ...Z("skeleton", "rg-grid__skeleton"), style: { ...A.skeleton, width: 18 } }) }),
|
|
2085
|
+
W.map((r, l) => /* @__PURE__ */ h("td", { className: "rg-grid__td", style: { textAlign: r.align }, children: /* @__PURE__ */ h("span", { ...Z("skeleton", "rg-grid__skeleton"), style: { ...A.skeleton, width: `${55 + (e * 7 + l * 13) % 35}%` } }) }, r.field))
|
|
2086
|
+
] }) }, `sk${e}`), Rr = (e, r, l = R && !e.sequenceRestartEachPage ? ie * oe : 0) => (e.sequenceStart ?? 1) + l + r, Ur = (e, r, l) => {
|
|
2087
|
+
const { row: s, id: c, index: f } = e, y = !!l, N = typeof lt == "function" ? lt(s, f) : lt, M = typeof st == "function" ? st(s, f) : st, O = Xt.has(c), ee = typeof it == "function" ? it(s, f) : it, be = typeof Me == "function" ? Me(s, f) : Me, On = ee || (pr === "none" ? void 0 : U("rg-grid__row--enter", `rg-row-in--${pr}`)), dn = be || U("rg-grid__row--exit", In !== "none" && `rg-row-out--${In}`);
|
|
2088
|
+
return /* @__PURE__ */ I(
|
|
1352
2089
|
"tr",
|
|
1353
2090
|
{
|
|
1354
|
-
onClick:
|
|
1355
|
-
"aria-
|
|
1356
|
-
|
|
2091
|
+
onClick: bt && !y ? () => bt(s, f) : void 0,
|
|
2092
|
+
"aria-hidden": y || void 0,
|
|
2093
|
+
onAnimationEnd: l ? ($) => $.target === $.currentTarget && Pn(l.id) : void 0,
|
|
2094
|
+
"aria-selected": ue ? O : void 0,
|
|
2095
|
+
className: U(
|
|
1357
2096
|
"rg-grid__tr",
|
|
1358
2097
|
"rg-grid__row",
|
|
1359
|
-
|
|
1360
|
-
//
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
2098
|
+
Jo && (r % 2 === 0 ? "rg-grid__row--stripe-a" : "rg-grid__row--stripe-b"),
|
|
2099
|
+
// Rows are not animated while virtualizing. New rows play the enter class once, when they are created.
|
|
2100
|
+
Mn && !y && On,
|
|
2101
|
+
y && dn,
|
|
2102
|
+
O && "rg-grid__row--selected",
|
|
2103
|
+
bt && "rg-grid__row--clickable",
|
|
2104
|
+
Y.row,
|
|
2105
|
+
N
|
|
1366
2106
|
),
|
|
1367
2107
|
style: {
|
|
1368
|
-
...
|
|
1369
|
-
...
|
|
1370
|
-
...
|
|
1371
|
-
...
|
|
2108
|
+
...Mn ? { "--rg-i": l ? Math.min(l.batch, 24) : Ro(c) } : null,
|
|
2109
|
+
...de ? { height: ge } : null,
|
|
2110
|
+
...A.row,
|
|
2111
|
+
...M
|
|
1372
2112
|
},
|
|
1373
2113
|
children: [
|
|
1374
|
-
|
|
2114
|
+
ue && /* @__PURE__ */ h(
|
|
1375
2115
|
"td",
|
|
1376
2116
|
{
|
|
1377
|
-
className:
|
|
1378
|
-
style: { width:
|
|
1379
|
-
onClick:
|
|
1380
|
-
children: /* @__PURE__ */
|
|
1381
|
-
|
|
2117
|
+
className: U("rg-grid__td rg-grid__select-cell", ln && "rg-grid__pinned rg-grid__pinned--left"),
|
|
2118
|
+
style: { width: je, minWidth: je, maxWidth: je, ...ln ? { left: 0 } : null },
|
|
2119
|
+
onClick: Ze,
|
|
2120
|
+
children: /* @__PURE__ */ h("span", { className: "rg-grid__checkbox-cell", onClickCapture: ($) => or.current = $.shiftKey, children: /* @__PURE__ */ h(
|
|
2121
|
+
ht,
|
|
1382
2122
|
{
|
|
1383
|
-
variant:
|
|
1384
|
-
checked:
|
|
1385
|
-
disabled: !
|
|
1386
|
-
"aria-label":
|
|
1387
|
-
onChange: (
|
|
1388
|
-
classNames: { root:
|
|
1389
|
-
styles: { root:
|
|
2123
|
+
variant: Ce,
|
|
2124
|
+
checked: O,
|
|
2125
|
+
disabled: y || !Gt(s),
|
|
2126
|
+
"aria-label": ue === "single" ? "Select row" : `Select row ${f + 1}`,
|
|
2127
|
+
onChange: ($) => To(e, $),
|
|
2128
|
+
classNames: { root: Y.checkbox, control: Y.checkboxControl, indicator: Y.checkboxIndicator },
|
|
2129
|
+
styles: { root: A.checkbox, control: A.checkboxControl, indicator: A.checkboxIndicator }
|
|
1390
2130
|
}
|
|
1391
2131
|
) })
|
|
1392
2132
|
}
|
|
1393
2133
|
),
|
|
1394
|
-
|
|
1395
|
-
let
|
|
1396
|
-
if (
|
|
1397
|
-
const
|
|
1398
|
-
|
|
2134
|
+
W.map(($, Tt) => {
|
|
2135
|
+
let J = Fo($, e);
|
|
2136
|
+
if ($.type === "sequence") {
|
|
2137
|
+
const Ne = Rr($, r);
|
|
2138
|
+
J = { ...J, value: Ne, formattedValue: $.valueFormatter ? $.valueFormatter(Ne, s) : String(Ne), editable: !1 };
|
|
1399
2139
|
}
|
|
1400
|
-
const
|
|
1401
|
-
return /* @__PURE__ */
|
|
2140
|
+
const Rn = typeof $.cellClassName == "function" ? $.cellClassName(J) : $.cellClassName, te = typeof $.cellStyle == "function" ? $.cellStyle(J) : $.cellStyle, _e = vt !== null && vt.id === c && vt.field === $.field, le = Zt($, J), un = wr($, Tt), fn = wn ? wn.id === c && wn.field === $.field : r === 0 && Tt === 0;
|
|
2141
|
+
return /* @__PURE__ */ h(
|
|
1402
2142
|
"td",
|
|
1403
2143
|
{
|
|
1404
|
-
ref: (
|
|
1405
|
-
const
|
|
1406
|
-
|
|
2144
|
+
ref: y ? void 0 : (Ne) => {
|
|
2145
|
+
const Ar = jn(c, $.field);
|
|
2146
|
+
Ne ? jt.current.set(Ar, Ne) : jt.current.delete(Ar);
|
|
1407
2147
|
},
|
|
1408
|
-
tabIndex:
|
|
1409
|
-
onFocus:
|
|
1410
|
-
onDoubleClick:
|
|
1411
|
-
onKeyDown: (
|
|
1412
|
-
className:
|
|
2148
|
+
tabIndex: y ? void 0 : Ve ? fn ? 0 : -1 : le ? 0 : void 0,
|
|
2149
|
+
onFocus: Ve && !y ? (Ne) => Ne.target === Ne.currentTarget && Jn({ id: c, field: $.field }) : void 0,
|
|
2150
|
+
onDoubleClick: le && !y ? () => tn(e, $) : void 0,
|
|
2151
|
+
onKeyDown: y ? void 0 : (Ne) => $o(Ne, e, $, J),
|
|
2152
|
+
className: U(
|
|
1413
2153
|
"rg-grid__td",
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
2154
|
+
le && "rg-grid__td--editable",
|
|
2155
|
+
_e && "rg-grid__td--editing",
|
|
2156
|
+
un.className,
|
|
2157
|
+
Y.cell,
|
|
2158
|
+
$.className,
|
|
2159
|
+
Rn
|
|
1420
2160
|
),
|
|
1421
|
-
style: { textAlign:
|
|
1422
|
-
children:
|
|
2161
|
+
style: { textAlign: $.align, ...A.cell, ...$.style, ...te, ...un.style },
|
|
2162
|
+
children: _e && vt && !y ? Ho(e, $, vt) : $.cellRenderer ? Ke($.cellRenderer, J) : $.type === "boolean" && !$.cellEditor ? qo($, J) : J.formattedValue
|
|
1423
2163
|
},
|
|
1424
|
-
|
|
2164
|
+
$.field
|
|
1425
2165
|
);
|
|
1426
2166
|
})
|
|
1427
2167
|
]
|
|
1428
2168
|
},
|
|
1429
|
-
|
|
2169
|
+
y ? `ghost:${c}` : c
|
|
1430
2170
|
);
|
|
1431
|
-
},
|
|
1432
|
-
return /* @__PURE__ */
|
|
2171
|
+
}, oi = Re.trim() !== "" || ut.length > 0 ? "no-results" : "no-data", ii = qe ?? (R ? Math.min(oe, 20) : 5);
|
|
2172
|
+
return /* @__PURE__ */ I(
|
|
1433
2173
|
"div",
|
|
1434
2174
|
{
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
"
|
|
2175
|
+
ref: Qn,
|
|
2176
|
+
className: U("rg-grid", de && "rg-grid--virtual", Y.root, L),
|
|
2177
|
+
style: { ...Qo, ...Go, ...A.root, ...xe },
|
|
2178
|
+
"data-rg-theme": F || void 0,
|
|
2179
|
+
"aria-busy": Nt || void 0,
|
|
1439
2180
|
children: [
|
|
1440
|
-
|
|
1441
|
-
/* @__PURE__ */
|
|
1442
|
-
|
|
2181
|
+
ti && /* @__PURE__ */ I("div", { ...Z("toolbar", "rg-grid__toolbar"), children: [
|
|
2182
|
+
/* @__PURE__ */ I("div", { className: "rg-grid__toolbar-left", children: [
|
|
2183
|
+
C && /* @__PURE__ */ h(
|
|
1443
2184
|
"input",
|
|
1444
2185
|
{
|
|
1445
2186
|
type: "search",
|
|
1446
|
-
value:
|
|
1447
|
-
onChange: (e) =>
|
|
1448
|
-
placeholder:
|
|
2187
|
+
value: _t,
|
|
2188
|
+
onChange: (e) => Hn(e.target.value),
|
|
2189
|
+
placeholder: T,
|
|
1449
2190
|
"aria-label": "Search all columns",
|
|
1450
|
-
...
|
|
2191
|
+
...Z("search", "rg-grid__search")
|
|
1451
2192
|
}
|
|
1452
2193
|
),
|
|
1453
|
-
|
|
1454
|
-
|
|
2194
|
+
ue && De.length > 0 && /* @__PURE__ */ I("span", { className: "rg-grid__selected-count", role: "status", children: [
|
|
2195
|
+
De.length,
|
|
1455
2196
|
" selected"
|
|
1456
2197
|
] })
|
|
1457
2198
|
] }),
|
|
1458
|
-
/* @__PURE__ */
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
2199
|
+
/* @__PURE__ */ I("div", { className: "rg-grid__toolbar-actions", children: [
|
|
2200
|
+
yt,
|
|
2201
|
+
pt && /* @__PURE__ */ h(
|
|
2202
|
+
Si,
|
|
1462
2203
|
{
|
|
1463
|
-
columns:
|
|
1464
|
-
hidden:
|
|
1465
|
-
onToggle:
|
|
1466
|
-
theme:
|
|
1467
|
-
className:
|
|
1468
|
-
style:
|
|
2204
|
+
columns: t,
|
|
2205
|
+
hidden: At,
|
|
2206
|
+
onToggle: xo,
|
|
2207
|
+
theme: F,
|
|
2208
|
+
className: Y.toolButton,
|
|
2209
|
+
style: A.toolButton
|
|
1469
2210
|
}
|
|
1470
2211
|
),
|
|
1471
|
-
He &&
|
|
2212
|
+
He && (sn.length > 1 ? (
|
|
2213
|
+
// Several formats: a menu with "which rows" and one button per format
|
|
2214
|
+
/* @__PURE__ */ h(
|
|
2215
|
+
Ii,
|
|
2216
|
+
{
|
|
2217
|
+
formats: sn,
|
|
2218
|
+
scopes: $r,
|
|
2219
|
+
scope: zo,
|
|
2220
|
+
onScopeChange: jo,
|
|
2221
|
+
onExport: (e, r) => Ir(e, { scope: r }),
|
|
2222
|
+
theme: F,
|
|
2223
|
+
className: U(Y.toolButton, Y.exportMenu),
|
|
2224
|
+
style: { ...A.toolButton, ...A.exportMenu }
|
|
2225
|
+
}
|
|
2226
|
+
)
|
|
2227
|
+
) : (
|
|
2228
|
+
// One format: a plain button ("Export CSV"), using the scope from `exportable` (default: all matching rows)
|
|
2229
|
+
/* @__PURE__ */ h("button", { type: "button", onClick: () => Ir(sn[0]), ...Z("toolButton", "rg-grid__tool-btn"), children: Ei(sn[0]) })
|
|
2230
|
+
))
|
|
1472
2231
|
] })
|
|
1473
2232
|
] }),
|
|
1474
|
-
|
|
1475
|
-
/* @__PURE__ */
|
|
2233
|
+
Zo && Or("top"),
|
|
2234
|
+
/* @__PURE__ */ h(
|
|
1476
2235
|
"div",
|
|
1477
2236
|
{
|
|
1478
|
-
ref:
|
|
1479
|
-
...
|
|
1480
|
-
onScroll:
|
|
1481
|
-
style: { ...
|
|
1482
|
-
children: /* @__PURE__ */
|
|
2237
|
+
ref: kt,
|
|
2238
|
+
...Z("scroll", "rg-grid__scroll"),
|
|
2239
|
+
onScroll: de ? (e) => Zn({ top: e.currentTarget.scrollTop, height: e.currentTarget.clientHeight }) : void 0,
|
|
2240
|
+
style: { ...A.scroll, ...Q !== void 0 ? { maxHeight: Q } : de ? { maxHeight: 400 } : null },
|
|
2241
|
+
children: /* @__PURE__ */ I(
|
|
1483
2242
|
"table",
|
|
1484
2243
|
{
|
|
1485
|
-
...
|
|
2244
|
+
...Z("table", "rg-grid__table"),
|
|
1486
2245
|
role: "grid",
|
|
1487
|
-
style:
|
|
1488
|
-
...
|
|
2246
|
+
style: Ln ? {
|
|
2247
|
+
...A.table,
|
|
1489
2248
|
tableLayout: "fixed",
|
|
1490
|
-
width:
|
|
2249
|
+
width: W.reduce((e, r) => e + on(r), ue ? je : 0),
|
|
1491
2250
|
minWidth: "100%"
|
|
1492
|
-
} :
|
|
2251
|
+
} : A.table,
|
|
1493
2252
|
children: [
|
|
1494
|
-
/* @__PURE__ */
|
|
1495
|
-
|
|
2253
|
+
/* @__PURE__ */ h("thead", { ...Z("thead", "rg-grid__thead"), children: /* @__PURE__ */ I("tr", { ...Z("headerRow", "rg-grid__tr"), children: [
|
|
2254
|
+
ue && /* @__PURE__ */ h(
|
|
1496
2255
|
"th",
|
|
1497
2256
|
{
|
|
1498
2257
|
scope: "col",
|
|
1499
|
-
className:
|
|
1500
|
-
style: { width:
|
|
1501
|
-
children:
|
|
1502
|
-
|
|
2258
|
+
className: U("rg-grid__th rg-grid__select-cell", ln && "rg-grid__pinned rg-grid__pinned--left", Y.headerCell),
|
|
2259
|
+
style: { width: je, minWidth: je, maxWidth: je, ...ln ? { left: 0 } : null, ...A.headerCell },
|
|
2260
|
+
children: ue === "multiple" && /* @__PURE__ */ h("span", { className: "rg-grid__checkbox-cell", children: /* @__PURE__ */ h(
|
|
2261
|
+
ht,
|
|
1503
2262
|
{
|
|
1504
|
-
variant:
|
|
1505
|
-
checked:
|
|
1506
|
-
indeterminate:
|
|
1507
|
-
disabled:
|
|
2263
|
+
variant: Ce,
|
|
2264
|
+
checked: lr,
|
|
2265
|
+
indeterminate: ir > 0 && !lr,
|
|
2266
|
+
disabled: Ct.length === 0,
|
|
1508
2267
|
"aria-label": "Select all rows",
|
|
1509
|
-
onChange:
|
|
1510
|
-
classNames: { root:
|
|
1511
|
-
styles: { root:
|
|
2268
|
+
onChange: sr,
|
|
2269
|
+
classNames: { root: Y.checkbox, control: Y.checkboxControl, indicator: Y.checkboxIndicator },
|
|
2270
|
+
styles: { root: A.checkbox, control: A.checkboxControl, indicator: A.checkboxIndicator }
|
|
1512
2271
|
}
|
|
1513
2272
|
) })
|
|
1514
2273
|
}
|
|
1515
2274
|
),
|
|
1516
|
-
|
|
1517
|
-
const
|
|
1518
|
-
return /* @__PURE__ */
|
|
2275
|
+
W.map((e, r) => {
|
|
2276
|
+
const l = me.findIndex((N) => N.field === e.field), s = l >= 0 ? me[l].direction : null, c = Sn(e), f = tr(e), y = wr(e, r);
|
|
2277
|
+
return /* @__PURE__ */ I(
|
|
1519
2278
|
"th",
|
|
1520
2279
|
{
|
|
1521
|
-
ref: (
|
|
1522
|
-
|
|
2280
|
+
ref: (N) => {
|
|
2281
|
+
N ? wt.current.set(e.field, N) : wt.current.delete(e.field);
|
|
1523
2282
|
},
|
|
1524
2283
|
scope: "col",
|
|
1525
|
-
"aria-sort": s ? s === "asc" ? "ascending" : "descending" :
|
|
1526
|
-
tabIndex:
|
|
1527
|
-
onClick: (
|
|
1528
|
-
onKeyDown: (
|
|
1529
|
-
|
|
2284
|
+
"aria-sort": s ? s === "asc" ? "ascending" : "descending" : c ? "none" : void 0,
|
|
2285
|
+
tabIndex: c ? 0 : void 0,
|
|
2286
|
+
onClick: (N) => ar(e, N.shiftKey),
|
|
2287
|
+
onKeyDown: (N) => {
|
|
2288
|
+
c && N.target === N.currentTarget && (N.key === "Enter" || N.key === " ") && (N.preventDefault(), ar(e, N.shiftKey));
|
|
1530
2289
|
},
|
|
1531
|
-
className:
|
|
2290
|
+
className: U("rg-grid__th", c && "rg-grid__th--sortable", y.className, Y.headerCell, e.className, e.headerClassName),
|
|
1532
2291
|
style: {
|
|
1533
|
-
width:
|
|
2292
|
+
width: Ln ? on(e) : e.width,
|
|
1534
2293
|
minWidth: e.minWidth,
|
|
1535
2294
|
textAlign: e.align,
|
|
1536
|
-
...
|
|
2295
|
+
...A.headerCell,
|
|
1537
2296
|
...e.style,
|
|
1538
2297
|
...e.headerStyle,
|
|
1539
|
-
...
|
|
2298
|
+
...y.style
|
|
1540
2299
|
},
|
|
1541
2300
|
children: [
|
|
1542
|
-
/* @__PURE__ */
|
|
1543
|
-
e.headerRenderer ?
|
|
1544
|
-
e.filterable && /* @__PURE__ */
|
|
1545
|
-
|
|
2301
|
+
/* @__PURE__ */ I("span", { className: "rg-grid__th-content", children: [
|
|
2302
|
+
e.headerRenderer ? Ke(e.headerRenderer, { column: e, sortDirection: s }) : e.headerCheckbox && e.type === "boolean" ? Vo(e) : Mt(e),
|
|
2303
|
+
e.filterable && /* @__PURE__ */ h(
|
|
2304
|
+
ki,
|
|
1546
2305
|
{
|
|
1547
2306
|
column: e,
|
|
1548
|
-
label:
|
|
1549
|
-
kind:
|
|
1550
|
-
value:
|
|
1551
|
-
onChange: (
|
|
1552
|
-
const
|
|
1553
|
-
|
|
2307
|
+
label: et(e),
|
|
2308
|
+
kind: f,
|
|
2309
|
+
value: ct[e.field],
|
|
2310
|
+
onChange: (N) => {
|
|
2311
|
+
const M = { ...ct };
|
|
2312
|
+
N === void 0 ? delete M[e.field] : M[e.field] = N, Xn(M);
|
|
1554
2313
|
},
|
|
1555
|
-
options:
|
|
1556
|
-
debounce: e.filterDebounce ??
|
|
1557
|
-
theme:
|
|
1558
|
-
indicatorClassName:
|
|
1559
|
-
indicatorStyle: { ...
|
|
1560
|
-
popupClassName:
|
|
1561
|
-
popupStyle: { ...
|
|
1562
|
-
inputClassName:
|
|
1563
|
-
inputStyle:
|
|
2314
|
+
options: Xo.get(e.field) ?? [],
|
|
2315
|
+
debounce: e.filterDebounce ?? ce,
|
|
2316
|
+
theme: F,
|
|
2317
|
+
indicatorClassName: U(Y.filterIndicator, e.filterIndicatorClassName),
|
|
2318
|
+
indicatorStyle: { ...A.filterIndicator, ...e.filterIndicatorStyle },
|
|
2319
|
+
popupClassName: U(Y.filterPopup, e.filterPopupClassName),
|
|
2320
|
+
popupStyle: { ...A.filterPopup, ...e.filterPopupStyle },
|
|
2321
|
+
inputClassName: Y.filterInput,
|
|
2322
|
+
inputStyle: A.filterInput
|
|
1564
2323
|
}
|
|
1565
2324
|
),
|
|
1566
|
-
|
|
1567
|
-
s === "asc" ? "▲" : s === "desc" ? "▼" : "↕",
|
|
1568
|
-
s && Q.length > 1 && /* @__PURE__ */ u("sup", { className: "rg-grid__sort-order", children: o + 1 })
|
|
1569
|
-
] })
|
|
2325
|
+
c && ni(e, s, s && me.length > 1 ? l + 1 : void 0)
|
|
1570
2326
|
] }),
|
|
1571
|
-
e.resizable && /* @__PURE__ */
|
|
2327
|
+
e.resizable && /* @__PURE__ */ h(
|
|
1572
2328
|
"span",
|
|
1573
2329
|
{
|
|
1574
2330
|
className: "rg-grid__resizer",
|
|
1575
2331
|
role: "separator",
|
|
1576
2332
|
"aria-orientation": "vertical",
|
|
1577
|
-
"aria-label": `Resize ${
|
|
1578
|
-
onPointerDown: (
|
|
1579
|
-
onClick:
|
|
1580
|
-
onDoubleClick:
|
|
2333
|
+
"aria-label": `Resize ${et(e)}`,
|
|
2334
|
+
onPointerDown: (N) => Bo(N, e),
|
|
2335
|
+
onClick: Ze,
|
|
2336
|
+
onDoubleClick: Ze
|
|
1581
2337
|
}
|
|
1582
2338
|
)
|
|
1583
2339
|
]
|
|
@@ -1586,26 +2342,35 @@ function ho({
|
|
|
1586
2342
|
);
|
|
1587
2343
|
})
|
|
1588
2344
|
] }) }),
|
|
1589
|
-
/* @__PURE__ */
|
|
1590
|
-
|
|
2345
|
+
/* @__PURE__ */ h("tbody", { ...Z("tbody", "rg-grid__tbody"), children: Nt ? Array.from({ length: ii }, (e, r) => ri(r)) : Cn ? /* @__PURE__ */ h("tr", { children: /* @__PURE__ */ I("td", { colSpan: St, ...Z("empty", "rg-grid__empty rg-grid__error"), role: "alert", children: [
|
|
2346
|
+
Pt,
|
|
1591
2347
|
" ",
|
|
1592
|
-
/* @__PURE__ */
|
|
1593
|
-
] }) }) : K.length === 0 ? /* @__PURE__ */
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
2348
|
+
/* @__PURE__ */ h("button", { type: "button", className: "rg-grid__tool-btn", onClick: () => Vt(zt.current), children: "Retry" })
|
|
2349
|
+
] }) }) : K.length === 0 && Te.length === 0 ? /* @__PURE__ */ h("tr", { children: /* @__PURE__ */ h("td", { colSpan: St, ...Z("empty", U("rg-grid__empty", xt && "rg-grid__empty--custom")), children: xt ? Ke(xt, {
|
|
2350
|
+
reason: oi,
|
|
2351
|
+
search: Re.trim(),
|
|
2352
|
+
filters: Object.fromEntries(ut),
|
|
2353
|
+
columns: W,
|
|
2354
|
+
clearAll: () => {
|
|
2355
|
+
Hn(""), Xn({});
|
|
2356
|
+
}
|
|
2357
|
+
}) : Lt }) }) : /* @__PURE__ */ I(tt, { children: [
|
|
2358
|
+
Dt && nn > 0 && /* @__PURE__ */ h("tr", { "aria-hidden": "true", className: "rg-grid__spacer", children: /* @__PURE__ */ h("td", { colSpan: St, style: { height: nn * ge } }) }),
|
|
2359
|
+
Uo.map((e) => e.kind === "row" ? Ur(e.entry, nn + e.i) : Ur(e.ghost.entry, 0, e.ghost)),
|
|
2360
|
+
Dt && En < K.length && /* @__PURE__ */ h("tr", { "aria-hidden": "true", className: "rg-grid__spacer", children: /* @__PURE__ */ h("td", { colSpan: St, style: { height: (K.length - En) * ge } }) })
|
|
2361
|
+
] }) })
|
|
1598
2362
|
]
|
|
1599
2363
|
}
|
|
1600
2364
|
)
|
|
1601
2365
|
}
|
|
1602
2366
|
),
|
|
1603
|
-
|
|
2367
|
+
ei && Or("bottom")
|
|
1604
2368
|
]
|
|
1605
2369
|
}
|
|
1606
2370
|
);
|
|
1607
2371
|
}
|
|
1608
2372
|
export {
|
|
1609
|
-
|
|
1610
|
-
|
|
2373
|
+
ht as Checkbox,
|
|
2374
|
+
sl as DataGrid,
|
|
2375
|
+
Ai as SortArrow
|
|
1611
2376
|
};
|