react-gridix 0.1.1 → 0.2.0

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