react-gridix 0.2.4 → 0.2.6

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