react-gridix 0.1.0 → 0.1.1

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,99 +1,9 @@
1
- import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
- import { forwardRef as je, useId as Me, useRef as Q, useEffect as be, useState as M, useMemo as $e, createElement as ie } from "react";
3
- import { createPortal as lt } from "react-dom";
4
- const ut = je(function({ variant: s = "primary", size: c = "md", loading: h = !1, disabled: v, className: b, children: _, ...m }, E) {
5
- const x = ["rk-btn", `rk-btn--${s}`, `rk-btn--${c}`, b].filter(Boolean).join(" ");
6
- return /* @__PURE__ */ p("button", { ref: E, className: x, disabled: v || h, "aria-busy": h || void 0, ...m, children: [
7
- h && /* @__PURE__ */ o("span", { className: "rk-spinner", "aria-hidden": "true" }),
8
- _
9
- ] });
10
- }), ft = je(function({ label: s, error: c, hint: h, id: v, className: b, ..._ }, m) {
11
- const E = Me(), x = v ?? E, I = c || h ? `${x}-desc` : void 0;
12
- return /* @__PURE__ */ p("div", { className: ["rk-field", b].filter(Boolean).join(" "), children: [
13
- s && /* @__PURE__ */ o("label", { className: "rk-label", htmlFor: x, children: s }),
14
- /* @__PURE__ */ o(
15
- "input",
16
- {
17
- ref: m,
18
- id: x,
19
- className: `rk-input${c ? " rk-input--error" : ""}`,
20
- "aria-invalid": c ? !0 : void 0,
21
- "aria-describedby": I,
22
- ..._
23
- }
24
- ),
25
- (c || h) && /* @__PURE__ */ o("span", { id: I, className: c ? "rk-error-text" : "rk-hint", children: c ?? h })
26
- ] });
27
- });
28
- function ht({ title: l, footer: s, className: c, children: h, ...v }) {
29
- return /* @__PURE__ */ p("div", { className: ["rk-card", c].filter(Boolean).join(" "), ...v, children: [
30
- l && /* @__PURE__ */ o("div", { className: "rk-card__header", children: l }),
31
- /* @__PURE__ */ o("div", { className: "rk-card__body", children: h }),
32
- s && /* @__PURE__ */ o("div", { className: "rk-card__footer", children: s })
33
- ] });
34
- }
35
- function kt({ tone: l = "neutral", className: s, children: c, ...h }) {
36
- return /* @__PURE__ */ o("span", { className: ["rk-badge", `rk-badge--${l}`, s].filter(Boolean).join(" "), ...h, children: c });
37
- }
38
- function bt({ tone: l = "info", title: s, onClose: c, className: h, children: v, ...b }) {
39
- return /* @__PURE__ */ p(
40
- "div",
41
- {
42
- role: l === "danger" || l === "warning" ? "alert" : "status",
43
- className: ["rk-alert", `rk-alert--${l}`, h].filter(Boolean).join(" "),
44
- ...b,
45
- children: [
46
- /* @__PURE__ */ p("div", { className: "rk-alert__content", children: [
47
- s && /* @__PURE__ */ o("strong", { className: "rk-alert__title", children: s }),
48
- /* @__PURE__ */ o("div", { children: v })
49
- ] }),
50
- c && /* @__PURE__ */ o("button", { type: "button", className: "rk-alert__close", "aria-label": "Dismiss", onClick: c, children: "×" })
51
- ]
52
- }
53
- );
54
- }
55
- function gt({ open: l, onClose: s, title: c, footer: h, children: v }) {
56
- const b = Me(), _ = Q(null);
57
- return be(() => {
58
- var I;
59
- if (!l) return;
60
- const m = document.activeElement;
61
- (I = _.current) == null || I.focus();
62
- const E = (P) => {
63
- P.key === "Escape" && s();
64
- };
65
- document.addEventListener("keydown", E);
66
- const x = document.body.style.overflow;
67
- return document.body.style.overflow = "hidden", () => {
68
- var P;
69
- document.removeEventListener("keydown", E), document.body.style.overflow = x, (P = m == null ? void 0 : m.focus) == null || P.call(m);
70
- };
71
- }, [l, s]), !l || typeof document > "u" ? null : lt(
72
- /* @__PURE__ */ o("div", { className: "rk-overlay", onMouseDown: (m) => m.target === m.currentTarget && s(), children: /* @__PURE__ */ p(
73
- "div",
74
- {
75
- ref: _,
76
- role: "dialog",
77
- "aria-modal": "true",
78
- "aria-labelledby": c ? b : void 0,
79
- tabIndex: -1,
80
- className: "rk-modal",
81
- children: [
82
- c && /* @__PURE__ */ p("div", { className: "rk-modal__header", children: [
83
- /* @__PURE__ */ o("h2", { id: b, className: "rk-modal__title", children: c }),
84
- /* @__PURE__ */ o("button", { type: "button", className: "rk-alert__close", "aria-label": "Close", onClick: s, children: "×" })
85
- ] }),
86
- /* @__PURE__ */ o("div", { className: "rk-modal__body", children: v }),
87
- h && /* @__PURE__ */ o("div", { className: "rk-modal__footer", children: h })
88
- ]
89
- }
90
- ) }),
91
- document.body
92
- );
93
- }
94
- const J = (...l) => l.filter(Boolean).join(" ");
95
- function it() {
96
- return /* @__PURE__ */ o("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ o(
1
+ import { jsxs as $, jsx as d, Fragment as gt } from "react/jsx-runtime";
2
+ import { useState as V, useRef as W, useCallback as kt, useEffect as ae, createElement as se, useLayoutEffect as bt, useMemo as qe } from "react";
3
+ import { createPortal as _t } from "react-dom";
4
+ const le = (...o) => o.filter(Boolean).join(" ");
5
+ function mt() {
6
+ return /* @__PURE__ */ d("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ d(
97
7
  "path",
98
8
  {
99
9
  d: "M3.5 8.5l3 3 6-7",
@@ -105,510 +15,654 @@ function it() {
105
15
  }
106
16
  ) });
107
17
  }
108
- function ot() {
109
- return /* @__PURE__ */ o("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ o("path", { d: "M4 8h8", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round" }) });
18
+ function vt() {
19
+ return /* @__PURE__ */ d("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ d("path", { d: "M4 8h8", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round" }) });
110
20
  }
111
- function Ke({
112
- checked: l,
21
+ function Ge({
22
+ checked: o,
113
23
  onChange: s,
114
24
  indeterminate: c = !1,
115
25
  variant: h = "native",
116
- disabled: v = !1,
26
+ disabled: I = !1,
117
27
  label: b,
118
- "aria-label": _,
119
- id: m,
120
- name: E,
121
- indicator: x,
122
- className: I,
123
- style: P,
124
- classNames: j = {},
125
- styles: y = {}
28
+ "aria-label": m,
29
+ id: O,
30
+ name: H,
31
+ indicator: B,
32
+ className: G,
33
+ style: w,
34
+ classNames: k = {},
35
+ styles: E = {}
126
36
  }) {
127
- const B = c ? "indeterminate" : l ? "checked" : "unchecked";
128
- return /* @__PURE__ */ p(
37
+ const F = c ? "indeterminate" : o ? "checked" : "unchecked";
38
+ return /* @__PURE__ */ $(
129
39
  "label",
130
40
  {
131
- className: J(
41
+ className: le(
132
42
  "rk-checkbox",
133
43
  `rk-checkbox--${h}`,
134
- B === "checked" && "rk-checkbox--checked",
44
+ F === "checked" && "rk-checkbox--checked",
135
45
  c && "rk-checkbox--indeterminate",
136
- v && "rk-checkbox--disabled",
137
- j.root,
138
- I
46
+ I && "rk-checkbox--disabled",
47
+ k.root,
48
+ G
139
49
  ),
140
- style: { ...y.root, ...P },
141
- "data-state": B,
50
+ style: { ...E.root, ...w },
51
+ "data-state": F,
142
52
  children: [
143
- h === "native" ? /* @__PURE__ */ o(
53
+ h === "native" ? /* @__PURE__ */ d(
144
54
  "input",
145
55
  {
146
56
  type: "checkbox",
147
- id: m,
148
- name: E,
149
- ref: (F) => {
150
- F && (F.indeterminate = c);
57
+ id: O,
58
+ name: H,
59
+ ref: (y) => {
60
+ y && (y.indeterminate = c);
151
61
  },
152
- className: J("rk-checkbox__control", j.control),
153
- style: y.control,
154
- checked: l,
155
- disabled: v,
156
- "aria-label": _,
157
- "data-state": B,
158
- onChange: (F) => s(F.target.checked)
62
+ className: le("rk-checkbox__control", k.control),
63
+ style: E.control,
64
+ checked: o,
65
+ disabled: I,
66
+ "aria-label": m,
67
+ "data-state": F,
68
+ onChange: (y) => s(y.target.checked)
159
69
  }
160
- ) : /* @__PURE__ */ o(
70
+ ) : /* @__PURE__ */ d(
161
71
  "button",
162
72
  {
163
73
  type: "button",
164
74
  role: "checkbox",
165
- id: m,
166
- className: J("rk-checkbox__control", j.control),
167
- style: y.control,
168
- "aria-checked": c ? "mixed" : l,
169
- "aria-label": _,
170
- disabled: v,
171
- "data-state": B,
172
- onClick: () => s(!l),
173
- children: /* @__PURE__ */ o(
75
+ id: O,
76
+ className: le("rk-checkbox__control", k.control),
77
+ style: E.control,
78
+ "aria-checked": c ? "mixed" : o,
79
+ "aria-label": m,
80
+ disabled: I,
81
+ "data-state": F,
82
+ onClick: () => s(!o),
83
+ children: /* @__PURE__ */ d(
174
84
  "span",
175
85
  {
176
- className: J(
86
+ className: le(
177
87
  "rk-checkbox__indicator",
178
- x !== void 0 && !c && "rk-checkbox__indicator--custom",
179
- j.indicator
88
+ B !== void 0 && !c && "rk-checkbox__indicator--custom",
89
+ k.indicator
180
90
  ),
181
- style: y.indicator,
182
- "data-state": B,
91
+ style: E.indicator,
92
+ "data-state": F,
183
93
  "aria-hidden": "true",
184
- children: c ? h === "tick" ? /* @__PURE__ */ o(ot, {}) : null : x !== void 0 ? x : h === "tick" ? /* @__PURE__ */ o(it, {}) : null
94
+ children: c ? h === "tick" ? /* @__PURE__ */ d(vt, {}) : null : B !== void 0 ? B : h === "tick" ? /* @__PURE__ */ d(mt, {}) : null
185
95
  }
186
96
  )
187
97
  }
188
98
  ),
189
- b != null && /* @__PURE__ */ o("span", { className: J("rk-checkbox__label", j.label), style: y.label, children: b })
99
+ b != null && b !== !1 && b !== "" && /* @__PURE__ */ d("span", { className: le("rk-checkbox__label", k.label), style: E.label, children: b })
190
100
  ]
191
101
  }
192
102
  );
193
103
  }
194
- const $ = (...l) => l.filter(Boolean).join(" "), Pe = (l, s) => `${typeof l}:${l}\0${s}`;
195
- function ke(l, s) {
196
- const c = s[l.field];
197
- return l.valueFormatter ? l.valueFormatter(c, s) : l.type === "boolean" && typeof c == "boolean" ? c ? "Yes" : "No" : c == null ? "" : c instanceof Date ? c.toLocaleDateString() : String(c);
104
+ const Ne = (...o) => o.filter(Boolean).join(" "), yt = typeof window < "u" ? bt : ae;
105
+ function xt({
106
+ column: o,
107
+ label: s,
108
+ value: c,
109
+ onChange: h,
110
+ theme: I,
111
+ indicatorClassName: b,
112
+ indicatorStyle: m,
113
+ popupClassName: O,
114
+ popupStyle: H,
115
+ inputClassName: B,
116
+ inputStyle: G
117
+ }) {
118
+ const [w, k] = V(!1), [E, F] = V({ top: 0, left: 0 }), y = W(null), R = W(null), q = c.trim() !== "", L = kt(() => {
119
+ var j;
120
+ const g = y.current;
121
+ if (!g) return;
122
+ const K = g.getBoundingClientRect(), A = ((j = R.current) == null ? void 0 : j.offsetWidth) ?? 260, T = Math.max(8, Math.min(K.left, window.innerWidth - A - 8));
123
+ F({ top: K.bottom + 6, left: T });
124
+ }, []);
125
+ yt(() => {
126
+ w && L();
127
+ }, [w, L]), ae(() => {
128
+ if (!w) return;
129
+ const g = (A) => {
130
+ var j, de;
131
+ const T = A.target;
132
+ (j = R.current) != null && j.contains(T) || (de = y.current) != null && de.contains(T) || k(!1);
133
+ }, K = (A) => {
134
+ var T;
135
+ A.key === "Escape" && (k(!1), (T = y.current) == null || T.focus());
136
+ };
137
+ return document.addEventListener("mousedown", g), document.addEventListener("keydown", K), window.addEventListener("resize", L), window.addEventListener("scroll", L, !0), () => {
138
+ document.removeEventListener("mousedown", g), document.removeEventListener("keydown", K), window.removeEventListener("resize", L), window.removeEventListener("scroll", L, !0);
139
+ };
140
+ }, [w, L]);
141
+ const _e = () => {
142
+ var g;
143
+ k(!1), (g = y.current) == null || g.focus();
144
+ };
145
+ return /* @__PURE__ */ $(gt, { children: [
146
+ /* @__PURE__ */ d(
147
+ "button",
148
+ {
149
+ ref: y,
150
+ type: "button",
151
+ className: Ne(
152
+ "rk-grid__filter-btn",
153
+ q && "rk-grid__filter-btn--active",
154
+ w && "rk-grid__filter-btn--open",
155
+ b
156
+ ),
157
+ style: m,
158
+ "aria-label": `Filter ${s}`,
159
+ "aria-haspopup": "dialog",
160
+ "aria-expanded": w,
161
+ "data-active": q || void 0,
162
+ onClick: (g) => {
163
+ g.stopPropagation(), w || L(), k((K) => !K);
164
+ },
165
+ children: o.filterIndicator ? se(o.filterIndicator, { column: o, active: q, open: w }) : /* @__PURE__ */ d("span", { className: "rk-grid__filter-dot", "aria-hidden": "true" })
166
+ }
167
+ ),
168
+ w && typeof document < "u" && _t(
169
+ /* @__PURE__ */ $(
170
+ "div",
171
+ {
172
+ ref: R,
173
+ role: "dialog",
174
+ "aria-label": `Filter ${s}`,
175
+ "data-rk-theme": I || void 0,
176
+ className: Ne("rk-grid-popup", O),
177
+ style: { position: "fixed", top: E.top, left: E.left, ...H },
178
+ children: [
179
+ o.filterRenderer ? se(o.filterRenderer, { column: o, value: c, onChange: h }) : /* @__PURE__ */ d(
180
+ "input",
181
+ {
182
+ autoFocus: !0,
183
+ type: "text",
184
+ className: Ne("rk-grid__filter-input", B),
185
+ style: G,
186
+ value: c,
187
+ placeholder: o.filterPlaceholder ?? `Filter ${s}…`,
188
+ "aria-label": `Filter text for ${s}`,
189
+ onChange: (g) => h(g.target.value),
190
+ onKeyDown: (g) => {
191
+ g.key === "Enter" && _e();
192
+ }
193
+ }
194
+ ),
195
+ q && /* @__PURE__ */ d("button", { type: "button", className: "rk-grid__filter-clear", onClick: () => h(""), children: "Clear" })
196
+ ]
197
+ }
198
+ ),
199
+ document.body
200
+ )
201
+ ] });
202
+ }
203
+ const Se = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Ye = (o, s) => Object.prototype.hasOwnProperty.call(o, s);
204
+ function z(o, s) {
205
+ if (o === null || typeof o != "object") return;
206
+ if (Ye(o, s)) return o[s];
207
+ let c = o;
208
+ for (const h of s.split(".")) {
209
+ if (c == null || typeof c != "object" || Se.has(h)) return;
210
+ c = c[h];
211
+ }
212
+ return c;
198
213
  }
199
- function at(l, s) {
200
- return typeof l == "number" && typeof s == "number" ? l - s : l instanceof Date && s instanceof Date ? l.getTime() - s.getTime() : typeof l == "boolean" && typeof s == "boolean" ? Number(l) - Number(s) : String(l).localeCompare(String(s), void 0, { numeric: !0, sensitivity: "base" });
214
+ function Je(o, s, c) {
215
+ if (Array.isArray(o)) {
216
+ const h = [...o];
217
+ return h[s] = c, h;
218
+ }
219
+ return { ...o, [s]: c };
201
220
  }
202
- function mt({
203
- columns: l,
221
+ function De(o, s, c) {
222
+ const h = o ?? {};
223
+ if (Ye(h, s) || !s.includes("."))
224
+ return Se.has(s) ? o : Je(h, s, c);
225
+ const [I, ...b] = s.split(".");
226
+ if (Se.has(I)) return o;
227
+ const m = h[I];
228
+ return Je(h, I, De(m !== null && typeof m == "object" ? m : {}, b.join("."), c));
229
+ }
230
+ const D = (...o) => o.filter(Boolean).join(" "), Ue = (o, s) => `${typeof o}:${o}\0${s}`, Ie = (o) => o.headerName ?? (o.type === "boolean" ? "" : o.field), be = (o) => Ie(o) || o.field;
231
+ function Ce(o, s) {
232
+ const c = z(s, o.field);
233
+ return o.valueFormatter ? o.valueFormatter(c, s) : o.type === "boolean" && typeof c == "boolean" ? c ? "Yes" : "No" : c == null ? "" : c instanceof Date ? c.toLocaleDateString() : String(c);
234
+ }
235
+ function wt(o, s) {
236
+ return typeof o == "number" && typeof s == "number" ? o - s : o instanceof Date && s instanceof Date ? o.getTime() - s.getTime() : typeof o == "boolean" && typeof s == "boolean" ? Number(o) - Number(s) : String(o).localeCompare(String(s), void 0, { numeric: !0, sensitivity: "base" });
237
+ }
238
+ function St({
239
+ columns: o,
204
240
  rows: s,
205
241
  getRowId: c,
206
242
  editable: h = !1,
207
- enterMovesDown: v = !0,
243
+ enterMovesDown: I = !0,
208
244
  onCellEdit: b,
209
- onRowsChange: _,
210
- sortable: m = !0,
211
- defaultSort: E = null,
212
- onSortChange: x,
213
- searchable: I = !0,
214
- searchPlaceholder: P = "Search…",
215
- columnFilters: j = !0,
216
- pagination: y = !0,
217
- paginationPosition: B = "bottom",
245
+ onRowsChange: m,
246
+ sortable: O = !0,
247
+ defaultSort: H = null,
248
+ onSortChange: B,
249
+ searchable: G = !0,
250
+ searchPlaceholder: w = "Search…",
251
+ pagination: k = !0,
252
+ paginationPosition: E = "bottom",
218
253
  pageSize: F = 10,
219
- pageSizeOptions: oe = [5, 10, 25, 50],
220
- onRowClick: ae,
221
- toolbar: ge,
222
- emptyMessage: Fe = "No rows to show",
223
- striped: Le = !1,
224
- checkboxVariant: Ve = "native",
225
- maxHeight: me,
226
- className: Re,
227
- style: Ae,
228
- classNames: S = {},
229
- styles: D = {},
230
- rowClassName: de,
231
- rowStyle: se
254
+ pageSizeOptions: y = [5, 10, 25, 50],
255
+ onRowClick: R,
256
+ toolbar: q,
257
+ emptyMessage: L = "No rows to show",
258
+ striped: _e = !1,
259
+ stripeColors: g,
260
+ checkboxVariant: K = "native",
261
+ animateRows: A = !0,
262
+ theme: T,
263
+ maxHeight: j,
264
+ className: de,
265
+ style: He,
266
+ classNames: N = {},
267
+ styles: x = {},
268
+ rowClassName: me,
269
+ rowStyle: ve
232
270
  }) {
233
- const g = (e, t) => ({
234
- className: $(t, S[e]),
235
- style: D[e]
236
- }), [pe, _e] = M(s), A = Q(s);
237
- be(() => {
238
- A.current = s, _e(s);
271
+ const _ = (e, t) => ({
272
+ className: D(t, N[e]),
273
+ style: x[e]
274
+ }), [Pe, $e] = V(s), Q = W(s);
275
+ ae(() => {
276
+ Q.current = s, $e(s);
239
277
  }, [s]);
240
- const ve = (e) => {
241
- A.current = e, _e(e);
242
- }, [U, ze] = M(""), [z, xe] = M({}), [w, We] = M(E), [qe, W] = M(0), [T, Ge] = M(F), [q, G] = M(null), L = Q(0), X = Q(null), ce = Q(/* @__PURE__ */ new Map()), ye = $e(
243
- () => pe.map((e, t) => ({ row: e, index: t, id: c ? c(e, t) : t })),
244
- [pe, c]
245
- ), O = $e(() => {
246
- const e = U.trim().toLowerCase(), t = Object.entries(z).filter(([, n]) => n.trim() !== "");
247
- let r = ye.filter(({ row: n }) => e && !l.some((d) => ke(d, n).toLowerCase().includes(e)) ? !1 : t.every(([i, d]) => {
248
- const f = l.find((a) => a.field === i);
249
- return f ? ke(f, n).toLowerCase().includes(d.trim().toLowerCase()) : !0;
278
+ const Le = (e) => {
279
+ Q.current = e, $e(e);
280
+ }, [X, Qe] = V(""), [Z, Xe] = V({}), [v, Ze] = V(H), [et, ee] = V(0), [P, tt] = V(F), [te, re] = V(null), J = W(0), ce = W(null), ye = W(/* @__PURE__ */ new Map()), Te = qe(
281
+ () => Pe.map((e, t) => ({ row: e, index: t, id: c ? c(e, t) : t })),
282
+ [Pe, c]
283
+ ), ne = qe(() => {
284
+ const e = X.trim().toLowerCase(), t = Object.entries(Z).filter(
285
+ ([n, i]) => i.trim() !== "" && o.some((l) => l.field === n && l.filterable)
286
+ );
287
+ let r = Te.filter(({ row: n }) => e && !o.some((l) => Ce(l, n).toLowerCase().includes(e)) ? !1 : t.every(([i, l]) => {
288
+ const f = o.find((a) => a.field === i);
289
+ return f ? Ce(f, n).toLowerCase().includes(l.trim().toLowerCase()) : !0;
250
290
  }));
251
- if (w) {
252
- const n = l.find((i) => i.field === w.field);
291
+ if (v) {
292
+ const n = o.find((i) => i.field === v.field);
253
293
  if (n) {
254
- const i = w.direction === "asc" ? 1 : -1;
255
- r = [...r].sort((d, f) => {
256
- const a = d.row[n.field], u = f.row[n.field], k = a == null || a === "", N = u == null || u === "";
257
- return k || N ? k === N ? 0 : k ? 1 : -1 : (n.comparator ? n.comparator(a, u, d.row, f.row) : at(a, u)) * i;
294
+ const i = v.direction === "asc" ? 1 : -1;
295
+ r = [...r].sort((l, f) => {
296
+ const a = z(l.row, n.field), u = z(f.row, n.field), p = a == null || a === "", C = u == null || u === "";
297
+ return p || C ? p === C ? 0 : p ? 1 : -1 : (n.comparator ? n.comparator(a, u, l.row, f.row) : wt(a, u)) * i;
258
298
  });
259
299
  }
260
300
  }
261
301
  return r;
262
- }, [ye, l, U, z, w]);
263
- be(() => W(0), [U, z, w, T]);
264
- const V = O.length, Y = y ? Math.max(1, Math.ceil(V / T)) : 1, C = Math.min(qe, Y - 1), K = y ? O.slice(C * T, C * T + T) : O, Oe = V === 0 ? 0 : y ? C * T + 1 : 1, Ye = y ? Math.min(V, (C + 1) * T) : V, Ne = (e) => e.sortable ?? m, we = (e) => e.filterable ?? j, Z = (e, t, r) => ({
265
- value: t[e.field],
266
- formattedValue: ke(e, t),
302
+ }, [Te, o, X, Z, v]);
303
+ ae(() => ee(0), [X, Z, v, P]);
304
+ const Be = W(null), U = ne.length, oe = k ? Math.max(1, Math.ceil(U / P)) : 1, S = Math.min(et, oe - 1), M = k ? ne.slice(S * P, S * P + P) : ne, rt = U === 0 ? 0 : k ? S * P + 1 : 1, nt = k ? Math.min(U, (S + 1) * P) : U, Fe = (e) => e.sortable ?? O, Ke = `${S}|${P}|${v ? `${v.field}:${v.direction}` : ""}|${X}|${JSON.stringify(Z)}`, Me = W(!0);
305
+ ae(() => {
306
+ if (Me.current) {
307
+ Me.current = !1;
308
+ return;
309
+ }
310
+ const e = Be.current;
311
+ e && typeof e.scrollTo == "function" && e.scrollTop > 0 && e.scrollTo({ top: 0, behavior: "smooth" });
312
+ }, [Ke]);
313
+ const ue = (e, t, r) => ({
314
+ value: z(t, e.field),
315
+ formattedValue: Ce(e, t),
267
316
  row: t,
268
317
  rowIndex: r,
269
318
  field: e.field,
270
319
  column: e
271
- }), ue = (e, t) => {
320
+ }), xe = (e, t) => {
272
321
  const r = e.editable ?? h;
273
322
  return typeof r == "function" ? r(t) : !!r;
274
- }, ee = (e, t) => ue(e, t) && !(e.type === "boolean" && !e.cellEditor), He = (e, t) => {
275
- const r = Z(e, t.row, t.index), n = ue(e, r);
323
+ }, fe = (e, t) => xe(e, t) && !(e.type === "boolean" && !e.cellEditor), ot = (e, t) => {
324
+ const r = ue(e, t.row, t.index), n = xe(e, r);
276
325
  return {
277
326
  ...r,
278
327
  editable: n,
279
- updateValue: (i) => n && Ce(t, e, { value: i })
328
+ updateValue: (i) => n && Ae(t, e, { value: i })
280
329
  };
281
- }, De = (e) => {
282
- if (!Ne(e)) return;
330
+ }, Ve = (e) => {
331
+ if (!Fe(e)) return;
283
332
  let t;
284
- !w || w.field !== e.field ? t = { field: e.field, direction: "asc" } : w.direction === "asc" ? t = { field: e.field, direction: "desc" } : t = null, We(t), x == null || x(t);
285
- }, te = (e, t) => {
333
+ !v || v.field !== e.field ? t = { field: e.field, direction: "asc" } : v.direction === "asc" ? t = { field: e.field, direction: "desc" } : t = null, Ze(t), B == null || B(t);
334
+ }, pe = (e, t) => {
286
335
  var r;
287
- return (r = ce.current.get(Pe(e, t))) == null ? void 0 : r.focus();
288
- }, R = () => {
289
- L.current += 1, G(null);
290
- }, re = (e, t, r = {}) => {
291
- if (!ee(t, Z(t, e.row, e.index))) return !1;
292
- const n = e.row[t.field], i = t.cellEditor ? n : r.text ?? (n == null ? "" : String(n));
293
- return X.current = i, L.current += 1, G({
336
+ return (r = ye.current.get(Ue(e, t))) == null ? void 0 : r.focus();
337
+ }, Y = () => {
338
+ J.current += 1, re(null);
339
+ }, he = (e, t, r = {}) => {
340
+ if (!fe(t, ue(t, e.row, e.index))) return !1;
341
+ const n = z(e.row, t.field), i = t.cellEditor ? n : r.text ?? (n == null ? "" : String(n));
342
+ return ce.current = i, J.current += 1, re({
294
343
  id: e.id,
295
344
  field: t.field,
296
345
  draft: i,
297
- session: L.current,
346
+ session: J.current,
298
347
  select: r.select ?? "end",
299
348
  invalid: !1
300
349
  }), !0;
301
- }, Ce = (e, t, r) => {
302
- const n = A.current[e.index] ?? e.row, i = n[t.field];
303
- let d;
350
+ }, Ae = (e, t, r) => {
351
+ const n = Q.current[e.index] ?? e.row, i = z(n, t.field);
352
+ let l;
304
353
  if ("value" in r)
305
- d = r.value;
354
+ l = r.value;
306
355
  else if (t.valueParser)
307
- d = t.valueParser(r.text, n);
356
+ l = t.valueParser(r.text, n);
308
357
  else if (t.type === "number")
309
- if (r.text.trim() === "") d = null;
358
+ if (r.text.trim() === "") l = null;
310
359
  else {
311
360
  const u = Number(r.text);
312
361
  if (!Number.isFinite(u)) return !1;
313
- d = u;
362
+ l = u;
314
363
  }
315
364
  else
316
- d = r.text;
317
- if (Object.is(d, i)) return !0;
318
- if (t.validate && !t.validate(d, n)) return !1;
319
- const f = { ...n, [t.field]: d }, a = A.current.map((u, k) => k === e.index ? f : u);
320
- return ve(a), b == null || b({ rowId: e.id, rowIndex: e.index, field: t.field, oldValue: i, newValue: d, row: f }), _ == null || _(a), !0;
321
- }, Ee = (e, t, r) => {
322
- const n = K.findIndex((k) => k.id === e.id), i = l.findIndex((k) => k.field === t);
365
+ l = r.text;
366
+ if (Object.is(l, i)) return !0;
367
+ if (t.validate && !t.validate(l, n)) return !1;
368
+ const f = De(n, t.field, l), a = Q.current.map((u, p) => p === e.index ? f : u);
369
+ return Le(a), b == null || b({ rowId: e.id, rowIndex: e.index, field: t.field, oldValue: i, newValue: l, row: f }), m == null || m(a), !0;
370
+ }, je = (e, t, r) => {
371
+ const n = M.findIndex((p) => p.id === e.id), i = o.findIndex((p) => p.field === t);
323
372
  if (n < 0 || i < 0) return null;
324
- const d = (k, N) => ee(N, Z(N, k.row, k.index));
373
+ const l = (p, C) => fe(C, ue(C, p.row, p.index));
325
374
  if (r === "down" || r === "up") {
326
- const k = r === "down" ? 1 : -1;
327
- for (let N = n + k; N >= 0 && N < K.length; N += k)
328
- if (d(K[N], l[i])) return { entry: K[N], col: l[i] };
375
+ const p = r === "down" ? 1 : -1;
376
+ for (let C = n + p; C >= 0 && C < M.length; C += p)
377
+ if (l(M[C], o[i])) return { entry: M[C], col: o[i] };
329
378
  return null;
330
379
  }
331
380
  const f = r === "right" ? 1 : -1;
332
381
  let a = n, u = i + f;
333
- for (; a >= 0 && a < K.length; ) {
334
- for (; u >= 0 && u < l.length; ) {
335
- if (d(K[a], l[u])) return { entry: K[a], col: l[u] };
382
+ for (; a >= 0 && a < M.length; ) {
383
+ for (; u >= 0 && u < o.length; ) {
384
+ if (l(M[a], o[u])) return { entry: M[a], col: o[u] };
336
385
  u += f;
337
386
  }
338
- a += f, u = f > 0 ? 0 : l.length - 1;
387
+ a += f, u = f > 0 ? 0 : o.length - 1;
339
388
  }
340
389
  return null;
341
- }, H = (e, t, r, n = {}) => {
342
- const { move: i = "none", focus: d = !0 } = n;
343
- if (!Ce(e, t, r))
344
- return G((a) => a && { ...a, invalid: !0 }), !1;
345
- const f = i === "none" ? null : Ee(e, t.field, i);
346
- return f ? re(f.entry, f.col, { select: "all" }) : (R(), d && te(e.id, t.field)), !0;
347
- }, Je = (e, t, r) => {
390
+ }, ie = (e, t, r, n = {}) => {
391
+ const { move: i = "none", focus: l = !0 } = n;
392
+ if (!Ae(e, t, r))
393
+ return re((a) => a && { ...a, invalid: !0 }), !1;
394
+ const f = i === "none" ? null : je(e, t.field, i);
395
+ return f ? he(f.entry, f.col, { select: "all" }) : (Y(), l && pe(e.id, t.field)), !0;
396
+ }, it = (e, t, r) => {
348
397
  if (e.nativeEvent.isComposing) return;
349
398
  const n = e.currentTarget.value;
350
399
  if (e.key === "Enter") {
351
400
  e.preventDefault();
352
- const i = v ? e.shiftKey ? "up" : "down" : "none";
353
- H(t, r, { text: n }, { move: i });
401
+ const i = I ? e.shiftKey ? "up" : "down" : "none";
402
+ ie(t, r, { text: n }, { move: i });
354
403
  } else if (e.key === "Escape")
355
- e.preventDefault(), R(), te(t.id, r.field);
404
+ e.preventDefault(), Y(), pe(t.id, r.field);
356
405
  else if (e.key === "Tab") {
357
406
  const i = e.shiftKey ? "left" : "right";
358
- Ee(t, r.field, i) && (e.preventDefault(), H(t, r, { text: n }, { move: i }));
407
+ je(t, r.field, i) && (e.preventDefault(), ie(t, r, { text: n }, { move: i }));
359
408
  }
360
- }, Qe = (e, t, r, n) => {
361
- e.target !== e.currentTarget || !ee(r, n) || (e.key === "Enter" || e.key === "F2" ? (e.preventDefault(), re(t, r)) : !r.cellEditor && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), re(t, r, { text: e.key })));
362
- }, Ue = (e, t, r) => t.cellEditor ? /* @__PURE__ */ o(
409
+ }, lt = (e, t, r, n) => {
410
+ e.target !== e.currentTarget || !fe(r, n) || (e.key === "Enter" || e.key === "F2" ? (e.preventDefault(), he(t, r)) : !r.cellEditor && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), he(t, r, { text: e.key })));
411
+ }, at = (e, t, r) => t.cellEditor ? /* @__PURE__ */ d(
363
412
  "div",
364
413
  {
365
414
  className: "rk-grid__custom-editor",
366
415
  onBlur: (n) => {
367
- n.currentTarget.contains(n.relatedTarget) || r.session === L.current && (H(e, t, { value: X.current }, { focus: !1 }) || R());
416
+ n.currentTarget.contains(n.relatedTarget) || r.session === J.current && (ie(e, t, { value: ce.current }, { focus: !1 }) || Y());
368
417
  },
369
418
  onKeyDown: (n) => {
370
- n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), R(), te(e.id, t.field));
419
+ n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), Y(), pe(e.id, t.field));
371
420
  },
372
- children: ie(t.cellEditor, {
421
+ children: se(t.cellEditor, {
373
422
  value: r.draft,
374
423
  row: e.row,
375
424
  rowIndex: e.index,
376
425
  field: t.field,
377
426
  column: t,
378
427
  onChange: (n) => {
379
- X.current = n, G((i) => i && i.session === r.session ? { ...i, draft: n, invalid: !1 } : i);
428
+ ce.current = n, re((i) => i && i.session === r.session ? { ...i, draft: n, invalid: !1 } : i);
380
429
  },
381
430
  onCommit: (n, i = "none") => {
382
- r.session === L.current && H(e, t, { value: n === void 0 ? X.current : n }, { move: i });
431
+ r.session === J.current && ie(e, t, { value: n === void 0 ? ce.current : n }, { move: i });
383
432
  },
384
433
  onCancel: () => {
385
- R(), te(e.id, t.field);
434
+ Y(), pe(e.id, t.field);
386
435
  }
387
436
  })
388
437
  }
389
- ) : /* @__PURE__ */ o(
438
+ ) : /* @__PURE__ */ d(
390
439
  "input",
391
440
  {
392
441
  autoFocus: !0,
393
- className: $("rk-grid__editor", r.invalid && "rk-grid__editor--invalid", S.editor),
394
- style: { textAlign: t.align, ...D.editor },
442
+ className: D("rk-grid__editor", r.invalid && "rk-grid__editor--invalid", N.editor),
443
+ style: { textAlign: t.align, ...x.editor },
395
444
  value: r.draft === null || r.draft === void 0 ? "" : String(r.draft),
396
445
  inputMode: t.type === "number" ? "decimal" : void 0,
397
- "aria-label": `Edit ${t.headerName ?? t.field}`,
446
+ "aria-label": `Edit ${be(t)}`,
398
447
  "aria-invalid": r.invalid || void 0,
399
448
  onChange: (n) => {
400
449
  const i = n.target.value;
401
- G((d) => d && { ...d, draft: i, invalid: !1 });
450
+ re((l) => l && { ...l, draft: i, invalid: !1 });
402
451
  },
403
452
  onFocus: (n) => {
404
453
  const i = n.currentTarget;
405
454
  r.select === "all" ? i.select() : i.setSelectionRange(i.value.length, i.value.length);
406
455
  },
407
456
  onBlur: (n) => {
408
- r.session === L.current && (H(e, t, { text: n.currentTarget.value }, { focus: !1 }) || R());
457
+ r.session === J.current && (ie(e, t, { text: n.currentTarget.value }, { focus: !1 }) || Y());
409
458
  },
410
- onKeyDown: (n) => Je(n, e, t)
459
+ onKeyDown: (n) => it(n, e, t)
411
460
  }
412
- ), Ie = (e) => {
413
- var r, n, i, d, f, a, u, k;
461
+ ), ze = (e) => {
462
+ var r, n, i, l, f, a, u, p;
414
463
  const t = e.checkbox ?? {};
415
464
  return {
416
- variant: t.variant ?? Ve,
465
+ variant: t.variant ?? K,
417
466
  indicator: t.indicator,
418
467
  className: t.className,
419
468
  style: t.style,
420
469
  classNames: {
421
- root: $(S.checkbox, (r = t.classNames) == null ? void 0 : r.root),
422
- control: $(S.checkboxControl, (n = t.classNames) == null ? void 0 : n.control),
423
- indicator: $(S.checkboxIndicator, (i = t.classNames) == null ? void 0 : i.indicator),
424
- label: (d = t.classNames) == null ? void 0 : d.label
470
+ root: D(N.checkbox, (r = t.classNames) == null ? void 0 : r.root),
471
+ control: D(N.checkboxControl, (n = t.classNames) == null ? void 0 : n.control),
472
+ indicator: D(N.checkboxIndicator, (i = t.classNames) == null ? void 0 : i.indicator),
473
+ label: (l = t.classNames) == null ? void 0 : l.label
425
474
  },
426
475
  styles: {
427
- root: { ...D.checkbox, ...(f = t.styles) == null ? void 0 : f.root },
428
- control: { ...D.checkboxControl, ...(a = t.styles) == null ? void 0 : a.control },
429
- indicator: { ...D.checkboxIndicator, ...(u = t.styles) == null ? void 0 : u.indicator },
430
- label: (k = t.styles) == null ? void 0 : k.label
476
+ root: { ...x.checkbox, ...(f = t.styles) == null ? void 0 : f.root },
477
+ control: { ...x.checkboxControl, ...(a = t.styles) == null ? void 0 : a.control },
478
+ indicator: { ...x.checkboxIndicator, ...(u = t.styles) == null ? void 0 : u.indicator },
479
+ label: (p = t.styles) == null ? void 0 : p.label
431
480
  }
432
481
  };
433
- }, ne = (e) => e.stopPropagation(), Xe = (e, t) => /* @__PURE__ */ o("span", { className: "rk-grid__checkbox-cell", onClick: ne, onDoubleClick: ne, children: /* @__PURE__ */ o(
434
- Ke,
482
+ }, ge = (e) => e.stopPropagation(), st = (e, t) => /* @__PURE__ */ d("span", { className: "rk-grid__checkbox-cell", onClick: ge, onDoubleClick: ge, children: /* @__PURE__ */ d(
483
+ Ge,
435
484
  {
436
- ...Ie(e),
485
+ ...ze(e),
437
486
  checked: !!t.value,
438
487
  disabled: !t.editable,
439
- "aria-label": `Toggle ${e.headerName ?? e.field}`,
488
+ "aria-label": `Toggle ${be(e)}`,
440
489
  onChange: (r) => t.updateValue(r)
441
490
  }
442
- ) }), Be = (e) => O.filter((t) => ue(e, Z(e, t.row, t.index))), Ze = (e, t) => {
443
- const r = new Map(Be(e).map((d) => [d.index, d])), n = [], i = A.current.map((d, f) => {
491
+ ) }), We = (e) => ne.filter((t) => xe(e, ue(e, t.row, t.index))), dt = (e, t) => {
492
+ const r = new Map(We(e).map((l) => [l.index, l])), n = [], i = Q.current.map((l, f) => {
444
493
  const a = r.get(f);
445
- if (!a) return d;
446
- const u = d[e.field];
447
- if (!!u === t || e.validate && !e.validate(t, d)) return d;
448
- const k = { ...d, [e.field]: t };
449
- return n.push({ rowId: a.id, rowIndex: f, field: e.field, oldValue: u, newValue: t, row: k }), k;
494
+ if (!a) return l;
495
+ const u = z(l, e.field);
496
+ if (!!u === t || e.validate && !e.validate(t, l)) return l;
497
+ const p = De(l, e.field, t);
498
+ return n.push({ rowId: a.id, rowIndex: f, field: e.field, oldValue: u, newValue: t, row: p }), p;
450
499
  });
451
- n.length !== 0 && (ve(i), n.forEach((d) => b == null ? void 0 : b(d)), _ == null || _(i));
452
- }, et = (e) => {
453
- const t = Be(e), r = t.length > 0 ? t : O, n = r.filter((d) => !!d.row[e.field]).length, i = r.length > 0 && n === r.length;
454
- return /* @__PURE__ */ o("span", { className: "rk-grid__header-checkbox", onClick: ne, onDoubleClick: ne, children: /* @__PURE__ */ o(
455
- Ke,
500
+ n.length !== 0 && (Le(i), n.forEach((l) => b == null ? void 0 : b(l)), m == null || m(i));
501
+ }, ct = (e) => {
502
+ const t = We(e), r = t.length > 0 ? t : ne, n = r.filter((l) => !!z(l.row, e.field)).length, i = r.length > 0 && n === r.length;
503
+ return /* @__PURE__ */ d("span", { className: "rk-grid__header-checkbox", onClick: ge, onDoubleClick: ge, children: /* @__PURE__ */ d(
504
+ Ge,
456
505
  {
457
- ...Ie(e),
506
+ ...ze(e),
458
507
  checked: i,
459
508
  indeterminate: n > 0 && !i,
460
509
  disabled: t.length === 0,
461
- label: e.headerName ?? e.field,
462
- onChange: (d) => Ze(e, d)
510
+ label: Ie(e) || void 0,
511
+ "aria-label": `Select all ${be(e)}`,
512
+ onChange: (l) => dt(e, l)
463
513
  }
464
514
  ) });
465
- }, tt = y && (B === "top" || B === "both"), rt = !y || B === "bottom" || B === "both", Se = (e) => /* @__PURE__ */ p(
515
+ }, ut = _e || !!g, ft = g ? { "--rk-stripe-a": g[0], "--rk-stripe-b": g[1] } : void 0, pt = k && (E === "top" || E === "both"), ht = !k || E === "bottom" || E === "both", Oe = (e) => /* @__PURE__ */ $(
466
516
  "div",
467
517
  {
468
- className: $("rk-grid__footer", e === "top" && "rk-grid__footer--top", S.footer),
469
- style: D.footer,
518
+ className: D("rk-grid__footer", e === "top" && "rk-grid__footer--top", N.footer),
519
+ style: x.footer,
470
520
  "data-position": e,
471
521
  children: [
472
- /* @__PURE__ */ o("span", { ...g("rowCount", "rk-grid__count"), children: V === 0 ? "0 rows" : `${Oe}–${Ye} of ${V}` }),
473
- y && /* @__PURE__ */ p("div", { ...g("pagination", "rk-grid__pagination"), children: [
474
- /* @__PURE__ */ p("label", { className: "rk-grid__page-size-label", children: [
522
+ /* @__PURE__ */ d("span", { ..._("rowCount", "rk-grid__count"), children: U === 0 ? "0 rows" : `${rt}–${nt} of ${U}` }),
523
+ k && /* @__PURE__ */ $("div", { ..._("pagination", "rk-grid__pagination"), children: [
524
+ /* @__PURE__ */ $("label", { className: "rk-grid__page-size-label", children: [
475
525
  "Rows per page",
476
- /* @__PURE__ */ o(
526
+ /* @__PURE__ */ d(
477
527
  "select",
478
528
  {
479
- value: T,
480
- onChange: (t) => Ge(Number(t.target.value)),
481
- ...g("pageSize", "rk-grid__page-size"),
482
- children: (oe.includes(T) ? oe : [...oe, T].sort((t, r) => t - r)).map(
483
- (t) => /* @__PURE__ */ o("option", { value: t, children: t }, t)
529
+ value: P,
530
+ onChange: (t) => tt(Number(t.target.value)),
531
+ ..._("pageSize", "rk-grid__page-size"),
532
+ children: (y.includes(P) ? y : [...y, P].sort((t, r) => t - r)).map(
533
+ (t) => /* @__PURE__ */ d("option", { value: t, children: t }, t)
484
534
  )
485
535
  }
486
536
  )
487
537
  ] }),
488
- /* @__PURE__ */ o("button", { type: "button", "aria-label": "First page", disabled: C === 0, onClick: () => W(0), ...g("pageButton", "rk-grid__page-btn"), children: "«" }),
489
- /* @__PURE__ */ o("button", { type: "button", "aria-label": "Previous page", disabled: C === 0, onClick: () => W(C - 1), ...g("pageButton", "rk-grid__page-btn"), children: "‹" }),
490
- /* @__PURE__ */ p("span", { ...g("pageInfo", "rk-grid__page-info"), children: [
538
+ /* @__PURE__ */ d("button", { type: "button", "aria-label": "First page", disabled: S === 0, onClick: () => ee(0), ..._("pageButton", "rk-grid__page-btn"), children: "«" }),
539
+ /* @__PURE__ */ d("button", { type: "button", "aria-label": "Previous page", disabled: S === 0, onClick: () => ee(S - 1), ..._("pageButton", "rk-grid__page-btn"), children: "‹" }),
540
+ /* @__PURE__ */ $("span", { ..._("pageInfo", "rk-grid__page-info"), children: [
491
541
  "Page ",
492
- C + 1,
542
+ S + 1,
493
543
  " of ",
494
- Y
544
+ oe
495
545
  ] }),
496
- /* @__PURE__ */ o("button", { type: "button", "aria-label": "Next page", disabled: C >= Y - 1, onClick: () => W(C + 1), ...g("pageButton", "rk-grid__page-btn"), children: "›" }),
497
- /* @__PURE__ */ o("button", { type: "button", "aria-label": "Last page", disabled: C >= Y - 1, onClick: () => W(Y - 1), ...g("pageButton", "rk-grid__page-btn"), children: "»" })
546
+ /* @__PURE__ */ d("button", { type: "button", "aria-label": "Next page", disabled: S >= oe - 1, onClick: () => ee(S + 1), ..._("pageButton", "rk-grid__page-btn"), children: "›" }),
547
+ /* @__PURE__ */ d("button", { type: "button", "aria-label": "Last page", disabled: S >= oe - 1, onClick: () => ee(oe - 1), ..._("pageButton", "rk-grid__page-btn"), children: "»" })
498
548
  ] })
499
549
  ]
500
550
  }
501
- ), nt = l.some(we);
502
- return /* @__PURE__ */ p("div", { className: $("rk-grid", S.root, Re), style: { ...D.root, ...Ae }, children: [
503
- (I || ge) && /* @__PURE__ */ p("div", { ...g("toolbar", "rk-grid__toolbar"), children: [
504
- I ? /* @__PURE__ */ o(
505
- "input",
506
- {
507
- type: "search",
508
- value: U,
509
- onChange: (e) => ze(e.target.value),
510
- placeholder: P,
511
- "aria-label": "Search all columns",
512
- ...g("search", "rk-grid__search")
513
- }
514
- ) : /* @__PURE__ */ o("span", {}),
515
- ge
516
- ] }),
517
- tt && Se("top"),
518
- /* @__PURE__ */ o("div", { ...g("scroll", "rk-grid__scroll"), style: { ...D.scroll, ...me !== void 0 ? { maxHeight: me } : null }, children: /* @__PURE__ */ p("table", { ...g("table", "rk-grid__table"), role: "grid", children: [
519
- /* @__PURE__ */ p("thead", { ...g("thead", "rk-grid__thead"), children: [
520
- /* @__PURE__ */ o("tr", { ...g("headerRow", "rk-grid__tr"), children: l.map((e) => {
521
- const t = (w == null ? void 0 : w.field) === e.field ? w.direction : null, r = Ne(e);
522
- return /* @__PURE__ */ o(
523
- "th",
551
+ );
552
+ return /* @__PURE__ */ $(
553
+ "div",
554
+ {
555
+ className: D("rk-grid", N.root, de),
556
+ style: { ...ft, ...x.root, ...He },
557
+ "data-rk-theme": T || void 0,
558
+ children: [
559
+ (G || q) && /* @__PURE__ */ $("div", { ..._("toolbar", "rk-grid__toolbar"), children: [
560
+ G ? /* @__PURE__ */ d(
561
+ "input",
524
562
  {
525
- scope: "col",
526
- "aria-sort": t ? t === "asc" ? "ascending" : "descending" : r ? "none" : void 0,
527
- tabIndex: r ? 0 : void 0,
528
- onClick: () => De(e),
529
- onKeyDown: (n) => {
530
- r && n.target === n.currentTarget && (n.key === "Enter" || n.key === " ") && (n.preventDefault(), De(e));
531
- },
532
- className: $("rk-grid__th", r && "rk-grid__th--sortable", S.headerCell, e.headerClassName),
533
- style: { width: e.width, minWidth: e.minWidth, textAlign: e.align, ...D.headerCell, ...e.headerStyle },
534
- children: /* @__PURE__ */ p("span", { className: "rk-grid__th-content", children: [
535
- e.headerRenderer ? ie(e.headerRenderer, { column: e, sortDirection: t }) : e.headerCheckbox && e.type === "boolean" ? et(e) : e.headerName ?? e.field,
536
- r && /* @__PURE__ */ o("span", { className: "rk-grid__sort", "aria-hidden": "true", children: t === "asc" ? "▲" : t === "desc" ? "▼" : "↕" })
537
- ] })
538
- },
539
- e.field
540
- );
541
- }) }),
542
- nt && /* @__PURE__ */ o("tr", { ...g("filterRow", "rk-grid__tr"), children: l.map((e) => /* @__PURE__ */ o("th", { ...g("filterCell", "rk-grid__filter-cell"), children: we(e) && (e.filterRenderer ? ie(e.filterRenderer, {
543
- column: e,
544
- value: z[e.field] ?? "",
545
- onChange: (t) => xe((r) => ({ ...r, [e.field]: t }))
546
- }) : /* @__PURE__ */ o(
547
- "input",
548
- {
549
- value: z[e.field] ?? "",
550
- onChange: (t) => xe((r) => ({ ...r, [e.field]: t.target.value })),
551
- placeholder: "Filter",
552
- "aria-label": `Filter ${e.headerName ?? e.field}`,
553
- ...g("filterInput", "rk-grid__filter-input")
554
- }
555
- )) }, e.field)) })
556
- ] }),
557
- /* @__PURE__ */ o("tbody", { ...g("tbody", "rk-grid__tbody"), children: K.length === 0 ? /* @__PURE__ */ o("tr", { children: /* @__PURE__ */ o("td", { colSpan: l.length, ...g("empty", "rk-grid__empty"), children: Fe }) }) : K.map((e, t) => {
558
- const { row: r, id: n, index: i } = e, d = typeof de == "function" ? de(r, i) : de, f = typeof se == "function" ? se(r, i) : se;
559
- return /* @__PURE__ */ o(
560
- "tr",
561
- {
562
- onClick: ae ? () => ae(r, i) : void 0,
563
- className: $(
564
- "rk-grid__tr",
565
- "rk-grid__row",
566
- Le && t % 2 === 1 && "rk-grid__row--striped",
567
- ae && "rk-grid__row--clickable",
568
- S.row,
569
- d
570
- ),
571
- style: { ...D.row, ...f },
572
- children: l.map((a) => {
573
- const u = He(a, e), k = typeof a.cellClassName == "function" ? a.cellClassName(u) : a.cellClassName, N = typeof a.cellStyle == "function" ? a.cellStyle(u) : a.cellStyle, fe = q !== null && q.id === n && q.field === a.field, he = ee(a, u);
574
- return /* @__PURE__ */ o(
575
- "td",
576
- {
577
- ref: (le) => {
578
- const Te = Pe(n, a.field);
579
- le ? ce.current.set(Te, le) : ce.current.delete(Te);
580
- },
581
- tabIndex: he ? 0 : void 0,
582
- onDoubleClick: he ? () => re(e, a) : void 0,
583
- onKeyDown: (le) => Qe(le, e, a, u),
584
- className: $(
585
- "rk-grid__td",
586
- he && "rk-grid__td--editable",
587
- fe && "rk-grid__td--editing",
588
- S.cell,
589
- k
590
- ),
591
- style: { textAlign: a.align, ...D.cell, ...N },
592
- children: fe && q ? Ue(e, a, q) : a.cellRenderer ? ie(a.cellRenderer, u) : a.type === "boolean" && !a.cellEditor ? Xe(a, u) : u.formattedValue
563
+ type: "search",
564
+ value: X,
565
+ onChange: (e) => Qe(e.target.value),
566
+ placeholder: w,
567
+ "aria-label": "Search all columns",
568
+ ..._("search", "rk-grid__search")
569
+ }
570
+ ) : /* @__PURE__ */ d("span", {}),
571
+ q
572
+ ] }),
573
+ pt && Oe("top"),
574
+ /* @__PURE__ */ d("div", { ref: Be, ..._("scroll", "rk-grid__scroll"), style: { ...x.scroll, ...j !== void 0 ? { maxHeight: j } : null }, children: /* @__PURE__ */ $("table", { ..._("table", "rk-grid__table"), role: "grid", children: [
575
+ /* @__PURE__ */ d("thead", { ..._("thead", "rk-grid__thead"), children: /* @__PURE__ */ d("tr", { ..._("headerRow", "rk-grid__tr"), children: o.map((e) => {
576
+ const t = (v == null ? void 0 : v.field) === e.field ? v.direction : null, r = Fe(e);
577
+ return /* @__PURE__ */ d(
578
+ "th",
579
+ {
580
+ scope: "col",
581
+ "aria-sort": t ? t === "asc" ? "ascending" : "descending" : r ? "none" : void 0,
582
+ tabIndex: r ? 0 : void 0,
583
+ onClick: () => Ve(e),
584
+ onKeyDown: (n) => {
585
+ r && n.target === n.currentTarget && (n.key === "Enter" || n.key === " ") && (n.preventDefault(), Ve(e));
593
586
  },
594
- a.field
595
- );
596
- })
597
- },
598
- n
599
- );
600
- }) })
601
- ] }) }),
602
- rt && Se("bottom")
603
- ] });
587
+ className: D("rk-grid__th", r && "rk-grid__th--sortable", N.headerCell, e.className, e.headerClassName),
588
+ style: { width: e.width, minWidth: e.minWidth, textAlign: e.align, ...x.headerCell, ...e.style, ...e.headerStyle },
589
+ children: /* @__PURE__ */ $("span", { className: "rk-grid__th-content", children: [
590
+ e.headerRenderer ? se(e.headerRenderer, { column: e, sortDirection: t }) : e.headerCheckbox && e.type === "boolean" ? ct(e) : Ie(e),
591
+ e.filterable && /* @__PURE__ */ d(
592
+ xt,
593
+ {
594
+ column: e,
595
+ label: be(e),
596
+ value: Z[e.field] ?? "",
597
+ onChange: (n) => Xe((i) => ({ ...i, [e.field]: n })),
598
+ theme: T,
599
+ indicatorClassName: D(N.filterIndicator, e.filterIndicatorClassName),
600
+ indicatorStyle: { ...x.filterIndicator, ...e.filterIndicatorStyle },
601
+ popupClassName: D(N.filterPopup, e.filterPopupClassName),
602
+ popupStyle: { ...x.filterPopup, ...e.filterPopupStyle },
603
+ inputClassName: N.filterInput,
604
+ inputStyle: x.filterInput
605
+ }
606
+ ),
607
+ r && /* @__PURE__ */ d("span", { className: "rk-grid__sort", "aria-hidden": "true", children: t === "asc" ? "▲" : t === "desc" ? "▼" : "↕" })
608
+ ] })
609
+ },
610
+ e.field
611
+ );
612
+ }) }) }),
613
+ /* @__PURE__ */ d("tbody", { ..._("tbody", "rk-grid__tbody"), children: M.length === 0 ? /* @__PURE__ */ d("tr", { children: /* @__PURE__ */ d("td", { colSpan: o.length, ..._("empty", "rk-grid__empty"), children: L }) }) : M.map((e, t) => {
614
+ const { row: r, id: n, index: i } = e, l = typeof me == "function" ? me(r, i) : me, f = typeof ve == "function" ? ve(r, i) : ve;
615
+ return /* @__PURE__ */ d(
616
+ "tr",
617
+ {
618
+ onClick: R ? () => R(r, i) : void 0,
619
+ className: D(
620
+ "rk-grid__tr",
621
+ "rk-grid__row",
622
+ ut && (t % 2 === 0 ? "rk-grid__row--stripe-a" : "rk-grid__row--stripe-b"),
623
+ A && "rk-grid__row--enter",
624
+ R && "rk-grid__row--clickable",
625
+ N.row,
626
+ l
627
+ ),
628
+ style: { ...A ? { "--rk-i": Math.min(t, 24) } : null, ...x.row, ...f },
629
+ children: o.map((a) => {
630
+ const u = ot(a, e), p = typeof a.cellClassName == "function" ? a.cellClassName(u) : a.cellClassName, C = typeof a.cellStyle == "function" ? a.cellStyle(u) : a.cellStyle, we = te !== null && te.id === n && te.field === a.field, Ee = fe(a, u);
631
+ return /* @__PURE__ */ d(
632
+ "td",
633
+ {
634
+ ref: (ke) => {
635
+ const Re = Ue(n, a.field);
636
+ ke ? ye.current.set(Re, ke) : ye.current.delete(Re);
637
+ },
638
+ tabIndex: Ee ? 0 : void 0,
639
+ onDoubleClick: Ee ? () => he(e, a) : void 0,
640
+ onKeyDown: (ke) => lt(ke, e, a, u),
641
+ className: D(
642
+ "rk-grid__td",
643
+ Ee && "rk-grid__td--editable",
644
+ we && "rk-grid__td--editing",
645
+ N.cell,
646
+ a.className,
647
+ p
648
+ ),
649
+ style: { textAlign: a.align, ...x.cell, ...a.style, ...C },
650
+ children: we && te ? at(e, a, te) : a.cellRenderer ? se(a.cellRenderer, u) : a.type === "boolean" && !a.cellEditor ? st(a, u) : u.formattedValue
651
+ },
652
+ a.field
653
+ );
654
+ })
655
+ },
656
+ n
657
+ );
658
+ }) }, Ke)
659
+ ] }) }),
660
+ ht && Oe("bottom")
661
+ ]
662
+ }
663
+ );
604
664
  }
605
665
  export {
606
- bt as Alert,
607
- kt as Badge,
608
- ut as Button,
609
- ht as Card,
610
- Ke as Checkbox,
611
- mt as DataGrid,
612
- ft as Input,
613
- gt as Modal
666
+ Ge as Checkbox,
667
+ St as DataGrid
614
668
  };