react-gridix 0.2.0 → 0.2.2

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