@vjdesigns/vjdesigns-ui 2.5.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/ai/llms-full.txt +9 -1
  2. package/dist/ai/registry.json +44 -1
  3. package/dist/components/data-display/DataGrid/DataGrid.cjs.js +1 -1
  4. package/dist/components/data-display/DataGrid/DataGrid.d.ts +46 -1
  5. package/dist/components/data-display/DataGrid/DataGrid.mjs +266 -241
  6. package/dist/components/data-display/DataGrid/DataGrid.module.css.cjs.js +1 -1
  7. package/dist/components/data-display/DataGrid/DataGrid.module.css.mjs +28 -26
  8. package/dist/components/forms/DatePicker/index.d.ts +1 -1
  9. package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.cjs.js +1 -1
  10. package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.mjs +1 -1
  11. package/dist/components/forms/TimePicker/TimePicker.cjs.js +1 -1
  12. package/dist/components/forms/TimePicker/TimePicker.mjs +57 -57
  13. package/dist/components/forms/TimePicker/index.d.ts +1 -0
  14. package/dist/i18n/en.cjs.js +1 -1
  15. package/dist/i18n/en.mjs +428 -2
  16. package/dist/i18n/types.d.ts +495 -0
  17. package/dist/index.cjs.js +1 -1
  18. package/dist/index.mjs +22 -22
  19. package/dist/locales/ar.cjs.js +1 -1
  20. package/dist/locales/ar.mjs +492 -2
  21. package/dist/locales/bn.cjs.js +1 -1
  22. package/dist/locales/bn.mjs +380 -2
  23. package/dist/locales/cs.cjs.js +1 -1
  24. package/dist/locales/cs.mjs +460 -2
  25. package/dist/locales/da.cjs.js +1 -1
  26. package/dist/locales/da.mjs +428 -2
  27. package/dist/locales/de.cjs.js +1 -1
  28. package/dist/locales/de.mjs +428 -2
  29. package/dist/locales/el.cjs.js +1 -1
  30. package/dist/locales/el.mjs +428 -2
  31. package/dist/locales/es.cjs.js +1 -1
  32. package/dist/locales/es.mjs +428 -2
  33. package/dist/locales/fa.cjs.js +1 -1
  34. package/dist/locales/fa.mjs +380 -2
  35. package/dist/locales/fi.cjs.js +1 -1
  36. package/dist/locales/fi.mjs +428 -2
  37. package/dist/locales/fr.cjs.js +1 -1
  38. package/dist/locales/fr.mjs +428 -2
  39. package/dist/locales/he.cjs.js +1 -1
  40. package/dist/locales/he.mjs +444 -2
  41. package/dist/locales/hi.cjs.js +1 -1
  42. package/dist/locales/hi.mjs +428 -2
  43. package/dist/locales/hu.cjs.js +1 -1
  44. package/dist/locales/hu.mjs +380 -2
  45. package/dist/locales/id.cjs.js +1 -1
  46. package/dist/locales/id.mjs +380 -2
  47. package/dist/locales/it.cjs.js +1 -1
  48. package/dist/locales/it.mjs +428 -2
  49. package/dist/locales/ja.cjs.js +1 -1
  50. package/dist/locales/ja.mjs +380 -2
  51. package/dist/locales/ko.cjs.js +1 -1
  52. package/dist/locales/ko.mjs +380 -2
  53. package/dist/locales/nb.cjs.js +1 -1
  54. package/dist/locales/nb.mjs +428 -2
  55. package/dist/locales/nl.cjs.js +1 -1
  56. package/dist/locales/nl.mjs +428 -2
  57. package/dist/locales/pl.cjs.js +1 -1
  58. package/dist/locales/pl.mjs +460 -2
  59. package/dist/locales/pt-BR.cjs.js +1 -1
  60. package/dist/locales/pt-BR.mjs +428 -2
  61. package/dist/locales/ro.cjs.js +1 -1
  62. package/dist/locales/ro.mjs +444 -2
  63. package/dist/locales/ru.cjs.js +1 -1
  64. package/dist/locales/ru.mjs +460 -2
  65. package/dist/locales/sv.cjs.js +1 -1
  66. package/dist/locales/sv.mjs +428 -2
  67. package/dist/locales/th.cjs.js +1 -1
  68. package/dist/locales/th.mjs +380 -2
  69. package/dist/locales/tr.cjs.js +1 -1
  70. package/dist/locales/tr.mjs +380 -2
  71. package/dist/locales/uk.cjs.js +1 -1
  72. package/dist/locales/uk.mjs +460 -2
  73. package/dist/locales/ur.cjs.js +1 -1
  74. package/dist/locales/ur.mjs +428 -2
  75. package/dist/locales/vi.cjs.js +1 -1
  76. package/dist/locales/vi.mjs +380 -2
  77. package/dist/locales/zh-Hans.cjs.js +1 -1
  78. package/dist/locales/zh-Hans.mjs +380 -2
  79. package/dist/locales/zh-Hant.cjs.js +1 -1
  80. package/dist/locales/zh-Hant.mjs +380 -2
  81. package/dist/vjdesigns-ui.css +1 -1
  82. package/package.json +103 -100
@@ -8,31 +8,31 @@ import { CheckBox as o } from "../../forms/CheckBox/CheckBox.mjs";
8
8
  import { Spinner as s } from "../../feedback/Spinner/Spinner.mjs";
9
9
  import { ScrollArea as c } from "../../layout/ScrollArea/ScrollArea.mjs";
10
10
  import { Pagination as l } from "../../navigation/Pagination/Pagination.mjs";
11
- import { ArrowDownIcon as u, ArrowUpIcon as ee, SortIcon as te } from "../../primitives/Icon/icons.mjs";
12
- import { useLocale as ne } from "../../utilities/LocaleProvider/LocaleProvider.mjs";
13
- import { compareValues as d, createSearchIndex as re, filterRows as f, getCellValue as ie, matchesWords as ae, searchWords as oe, sortIndices as se, sortRows as p } from "./dataGridUtils.mjs";
14
- import m from "./DataGrid.module.css.mjs";
15
- import { Fragment as ce, useDeferredValue as le, useEffect as ue, useId as de, useLayoutEffect as h, useMemo as g, useRef as _, useState as v } from "react";
16
- import { Fragment as fe, jsx as y, jsxs as b } from "react/jsx-runtime";
11
+ import { ArrowDownIcon as u, ArrowUpIcon as d, SortIcon as ee } from "../../primitives/Icon/icons.mjs";
12
+ import { useLocale as te } from "../../utilities/LocaleProvider/LocaleProvider.mjs";
13
+ import { compareValues as f, createSearchIndex as ne, filterRows as p, getCellValue as re, matchesWords as ie, searchWords as ae, sortIndices as oe, sortRows as m } from "./dataGridUtils.mjs";
14
+ import h from "./DataGrid.module.css.mjs";
15
+ import { Fragment as se, useDeferredValue as ce, useEffect as g, useId as le, useLayoutEffect as _, useMemo as v, useRef as y, useState as b } from "react";
16
+ import { Fragment as ue, jsx as x, jsxs as S } from "react/jsx-runtime";
17
17
  // src/components/data-display/DataGrid/DataGrid.tsx
18
- var pe = {
19
- compact: m.compact,
20
- comfortable: m.comfortable,
21
- spacious: m.spacious
22
- }, me = {
23
- plain: m.plain,
24
- striped: m.striped,
25
- outline: m.outline
26
- }, he = {
27
- start: m.alignStart,
28
- center: m.alignCenter,
29
- end: m.alignEnd
30
- }, ge = 10, _e = 100, ve = 2e3, ye = {
18
+ var de = {
19
+ compact: h.compact,
20
+ comfortable: h.comfortable,
21
+ spacious: h.spacious
22
+ }, fe = {
23
+ plain: h.plain,
24
+ striped: h.striped,
25
+ outline: h.outline
26
+ }, pe = {
27
+ start: h.alignStart,
28
+ center: h.alignCenter,
29
+ end: h.alignEnd
30
+ }, me = 10, he = 100, ge = 2e3, _e = {
31
31
  compact: 37,
32
32
  comfortable: 49,
33
33
  spacious: 65
34
- }, be = "a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[contenteditable='true'],[data-grid-widget]", x = (e) => Array.from(e.querySelectorAll(be)), xe = `[data-cell], [data-cell] :is(${be})`;
35
- function Se(e) {
34
+ }, ve = "a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[contenteditable='true'],[data-grid-widget]", C = (e) => Array.from(e.querySelectorAll(ve)), ye = `[data-cell], [data-cell] :is(${ve})`;
35
+ function be(e) {
36
36
  return e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? !0 : e instanceof HTMLInputElement ? ![
37
37
  "checkbox",
38
38
  "radio",
@@ -44,92 +44,92 @@ function Se(e) {
44
44
  "image"
45
45
  ].includes(e.type) : e.getAttribute("contenteditable") === "true";
46
46
  }
47
- function S(e) {
48
- let t = x(e).filter((e) => !e.hasAttribute("data-grid-secondary"));
49
- return t.length === 1 && !Se(t[0]) ? t[0] : e;
47
+ function xe(e) {
48
+ let t = C(e).filter((e) => !e.hasAttribute("data-grid-secondary"));
49
+ return t.length === 1 && !be(t[0]) ? t[0] : e;
50
50
  }
51
- var Ce = (e) => {
51
+ var Se = (e) => {
52
52
  let [t, n] = (e.getAttribute("data-cell") ?? "0:0").split(":").map(Number);
53
53
  return [t, n];
54
- }, we = (e) => typeof e == "number" ? `${e}px` : e, Te = (e) => e.id;
55
- function C({ rows: d, columns: f, getRowId: p = Te, getRowLabel: Se, "aria-label": C, "aria-labelledby": Ee, "aria-describedby": De, sort: Oe, defaultSort: ke, onSortChange: Ae, multiSort: je = !0, filter: Me, selectionMode: w = "none", selected: Ne, defaultSelected: Pe, onSelectedChange: Fe, isRowSelectable: Ie, pageSize: T, virtualize: Le = "auto", page: Re, defaultPage: ze = 1, onPageChange: Be, manual: E = !1, rowCount: Ve, onRowActivate: D, loading: He = !1, emptyState: Ue, density: We = "comfortable", variant: Ge = "outline", hoverable: Ke = !0, stickyHeader: qe = !0, maxHeight: Je, layout: Ye, tableStyle: Xe, className: Ze, style: Qe, ref: $e }) {
56
- let { messages: O, locale: k } = ne(), A = O.dataGrid, j = _(null), et = de(), tt = `${et}-pages`, nt = `${et}-name`, rt = t(j, $e), [M, it] = e({
54
+ }, Ce = (e) => typeof e == "number" ? `${e}px` : e, we = (e) => e.id;
55
+ function Te({ rows: f, columns: p, getRowId: m = we, getRowLabel: be, "aria-label": Te, "aria-labelledby": Ee, "aria-describedby": De, sort: Oe, defaultSort: ke, onSortChange: Ae, multiSort: je = !0, filter: Me, selectionMode: w = "none", selected: Ne, defaultSelected: Pe, onSelectedChange: Fe, isRowSelectable: Ie, pageSize: T, virtualize: Le = "auto", page: Re, defaultPage: ze = 1, onPageChange: Be, manual: E = !1, rowCount: Ve, onRowActivate: D, loading: He = !1, emptyState: Ue, density: We = "comfortable", variant: Ge = "outline", hoverable: Ke = !0, stickyHeader: qe = !0, maxHeight: Je, layout: Ye, tableStyle: Xe, treegrid: Ze = !1, getRowProps: Qe, renderRowDetail: $e, onRowsShown: et, onVisibleRangeChange: tt, className: nt, style: rt, ref: it }) {
56
+ let { messages: O, locale: k } = te(), A = O.dataGrid, j = y(null), at = le(), ot = `${at}-pages`, st = `${at}-name`, ct = t(j, it), [M, lt] = e({
57
57
  value: Oe,
58
58
  defaultValue: ke ?? [],
59
59
  onChange: Ae
60
- }), [N, at] = e({
60
+ }), [N, ut] = e({
61
61
  value: Ne,
62
62
  defaultValue: Pe ?? [],
63
63
  onChange: Fe
64
- }), [ot, st] = e({
64
+ }), [dt, ft] = e({
65
65
  value: Re,
66
66
  defaultValue: ze,
67
67
  onChange: Be
68
- }), P = g(() => E ? null : se(d, M, f, k), [
68
+ }), P = v(() => E ? null : oe(f, M, p, k), [
69
69
  E,
70
- d,
71
- M,
72
70
  f,
71
+ M,
72
+ p,
73
73
  k
74
- ]), F = g(() => re(d, f), [d, f]), I = Me ?? "", ct = le(I), lt = Me !== void 0 && !E;
75
- ue(() => {
76
- if (!lt || d.length < ve || typeof window > "u") return;
74
+ ]), F = v(() => ne(f, p), [f, p]), I = Me ?? "", pt = ce(I), mt = Me !== void 0 && !E;
75
+ g(() => {
76
+ if (!mt || f.length < ge || typeof window > "u") return;
77
77
  let e = window.requestIdleCallback ?? ((e) => window.setTimeout(() => e({
78
78
  didTimeout: !1,
79
79
  timeRemaining: () => 8
80
80
  }), 50)), t = window.cancelIdleCallback ?? window.clearTimeout, n = 0, r = 0, i = (t) => {
81
- for (; n < d.length && t.timeRemaining() > 2;) for (let e = Math.min(d.length, n + 1e3); n < e; n++) F.text(n);
82
- n < d.length && (r = e(i));
81
+ for (; n < f.length && t.timeRemaining() > 2;) for (let e = Math.min(f.length, n + 1e3); n < e; n++) F.text(n);
82
+ n < f.length && (r = e(i));
83
83
  };
84
84
  return r = e(i), () => t(r);
85
85
  }, [
86
- lt,
87
- d,
86
+ mt,
87
+ f,
88
88
  F
89
89
  ]);
90
- let L = g(() => {
91
- if (E || !P) return d;
92
- let e = oe(ct);
93
- if (e.length === 0) return P.map((e) => d[e]);
90
+ let L = v(() => {
91
+ if (E || !P) return f;
92
+ let e = ae(pt);
93
+ if (e.length === 0) return P.map((e) => f[e]);
94
94
  let t = [];
95
- for (let n of P) ae(F.text(n), e) && t.push(d[n]);
95
+ for (let n of P) ie(F.text(n), e) && t.push(f[n]);
96
96
  return t;
97
97
  }, [
98
98
  E,
99
99
  P,
100
- d,
101
- ct,
100
+ f,
101
+ pt,
102
102
  F
103
- ]), R = E ? Ve ?? d.length : L.length, ut = T ? Math.max(1, Math.ceil(R / T)) : 1, z = Math.min(Math.max(1, ot), ut), dt = T && !E ? (z - 1) * T : 0, B = T && !E ? L.slice(dt, dt + T) : L, V = T ? (z - 1) * T : 0, H = Le === "auto" ? B.length > _e : Le, ft = _(null), pt = _(null), [mt, ht] = v(0);
104
- h(() => {
105
- let e = pt.current;
103
+ ]), R = E ? Ve ?? f.length : L.length, ht = T ? Math.max(1, Math.ceil(R / T)) : 1, z = Math.min(Math.max(1, dt), ht), gt = T && !E ? (z - 1) * T : 0, B = T && !E ? L.slice(gt, gt + T) : L, V = T ? (z - 1) * T : 0, H = !$e && (Le === "auto" ? B.length > he : Le), _t = y(null), vt = y(null), [yt, bt] = b(0);
104
+ _(() => {
105
+ let e = vt.current;
106
106
  if (!H || !e) return;
107
- let t = () => ht(e.offsetHeight);
107
+ let t = () => bt(e.offsetHeight);
108
108
  if (t(), typeof ResizeObserver > "u") return;
109
109
  let n = new ResizeObserver(t);
110
110
  return n.observe(e), () => n.disconnect();
111
111
  }, [H]);
112
112
  let U = n({
113
113
  count: H ? B.length : 0,
114
- scrollElement: ft,
115
- estimateSize: ye[We],
116
- paddingStart: mt,
114
+ scrollElement: _t,
115
+ estimateSize: _e[We],
116
+ paddingStart: yt,
117
117
  overscan: 10,
118
118
  initialCount: 30
119
- }), gt = Je ?? (H ? "70vh" : void 0), _t = Ye ?? (H ? "fixed" : "auto"), W = `${I}|${JSON.stringify(M)}`, vt = _(W);
120
- ue(() => {
121
- vt.current !== W && (vt.current = W, T && z !== 1 && st(1));
119
+ }), xt = Je ?? (H ? "70vh" : void 0), St = Ye ?? (H ? "fixed" : "auto"), W = `${I}|${JSON.stringify(M)}`, Ct = y(W);
120
+ g(() => {
121
+ Ct.current !== W && (Ct.current = W, T && z !== 1 && ft(1));
122
122
  }, [
123
123
  W,
124
124
  T,
125
125
  z,
126
- st
126
+ ft
127
127
  ]);
128
- let yt = _(I);
129
- ue(() => {
130
- if (yt.current === I) return;
128
+ let wt = y(I);
129
+ g(() => {
130
+ if (wt.current === I) return;
131
131
  let e = window.setTimeout(() => {
132
- yt.current = I, a(R === 0 ? A.noResults : A.rowCount(R));
132
+ wt.current = I, a(R === 0 ? A.noResults : A.rowCount(R));
133
133
  }, 600);
134
134
  return () => window.clearTimeout(e);
135
135
  }, [
@@ -137,35 +137,35 @@ function C({ rows: d, columns: f, getRowId: p = Te, getRowLabel: Se, "aria-label
137
137
  R,
138
138
  A
139
139
  ]);
140
- let G = w === "multiple", bt = w !== "none", xt = +!!G, K = f.length + xt, St = f.find((e) => e.rowHeader) ?? f[0], Ct = (e) => Se?.(e) ?? String((St && ie(e, St)) ?? p(e)), wt = (e) => e.headerLabel ?? (typeof e.header == "string" ? e.header : e.key), q = g(() => new Set(N), [N]), Tt = (e) => Ie?.(e) ?? !0, J = g(() => L.filter((e) => Ie?.(e) ?? !0).map(p), [
140
+ let G = w === "multiple", Tt = w !== "none", Et = +!!G, K = p.length + Et, Dt = p.find((e) => e.rowHeader) ?? p[0], Ot = (e) => be?.(e) ?? String((Dt && re(e, Dt)) ?? m(e)), kt = (e) => e.headerLabel ?? (typeof e.header == "string" ? e.header : e.key), q = v(() => new Set(N), [N]), At = (e) => Ie?.(e) ?? !0, J = v(() => L.filter((e) => Ie?.(e) ?? !0).map(m), [
141
141
  L,
142
142
  Ie,
143
- p
144
- ]), Y = g(() => {
143
+ m
144
+ ]), Y = v(() => {
145
145
  let e = 0;
146
146
  for (let t of J) q.has(t) && e++;
147
147
  return e;
148
- }, [J, q]), Et = J.length > 0 && Y === J.length, Dt = Y > 0 && !Et, Ot = _(null), kt = _(!1), At = (e, t, n) => {
148
+ }, [J, q]), jt = J.length > 0 && Y === J.length, Mt = Y > 0 && !jt, Nt = y(null), Pt = y(!1), Ft = (e, t, n) => {
149
149
  let r = B[e];
150
- if (!r || !Tt(r)) return;
151
- let i = p(r);
150
+ if (!r || !At(r)) return;
151
+ let i = m(r);
152
152
  if (w === "single") {
153
- at(q.has(i) && n !== !0 ? [] : [i]), Ot.current = e;
153
+ ut(q.has(i) && n !== !0 ? [] : [i]), Nt.current = e;
154
154
  return;
155
155
  }
156
- let a = n ?? !q.has(i), o = Ot.current, s = [i];
156
+ let a = n ?? !q.has(i), o = Nt.current, s = [i];
157
157
  if (t && o !== null && o !== e) {
158
158
  let [t, n] = o < e ? [o, e] : [e, o];
159
- s = B.slice(t, n + 1).filter(Tt).map(p);
159
+ s = B.slice(t, n + 1).filter(At).map(m);
160
160
  }
161
161
  let c = new Set(N);
162
162
  for (let e of s) a ? c.add(e) : c.delete(e);
163
- Ot.current = e, at(Array.from(c));
164
- }, jt = (e) => {
163
+ Nt.current = e, ut(Array.from(c));
164
+ }, It = (e) => {
165
165
  let t = new Set(N);
166
166
  for (let n of J) e ? t.add(n) : t.delete(n);
167
- at(Array.from(t));
168
- }, Mt = (e, t) => {
167
+ ut(Array.from(t));
168
+ }, Lt = (e, t) => {
169
169
  let n = M.find((t) => t.key === e.key), r = n ? n.direction === "ascending" ? "descending" : null : "ascending", i;
170
170
  i = t && je ? n ? r ? M.map((t) => t.key === e.key ? {
171
171
  key: t.key,
@@ -176,66 +176,66 @@ function C({ rows: d, columns: f, getRowId: p = Te, getRowLabel: Se, "aria-label
176
176
  }] : r ? [{
177
177
  key: e.key,
178
178
  direction: r
179
- }] : [], it(i), a(r ? A.sorted(wt(e), r === "ascending" ? A.ascending : A.descending) : A.sortCleared);
180
- }, Nt = B.length, [Pt, Ft] = v({
179
+ }] : [], lt(i), a(r ? A.sorted(kt(e), r === "ascending" ? A.ascending : A.descending) : A.sortCleared);
180
+ }, Rt = B.length, [zt, Bt] = b({
181
181
  r: 0,
182
182
  c: 0
183
- }), X = Math.min(Pt.r, Nt), It = Math.min(Pt.c, K - 1), [Lt, Z] = v(!1), [Rt, zt] = v(0), Bt = (e, t) => j.current?.querySelector(`[data-cell="${e}:${t}"]`) ?? null;
184
- h(() => {
183
+ }), X = Math.min(zt.r, Rt), Vt = Math.min(zt.c, K - 1), [Ht, Z] = b(!1), [Ut, Wt] = b(0), Gt = (e, t) => j.current?.querySelector(`[data-cell="${e}:${t}"]`) ?? null;
184
+ _(() => {
185
185
  let e = j.current;
186
186
  if (!e) return;
187
- let t = Bt(X, It);
188
- !t && X > 0 && (t = e.querySelector(`tbody [data-cell$=":${It}"]`));
187
+ let t = Gt(X, Vt);
188
+ !t && X > 0 && (t = e.querySelector(`tbody [data-cell$=":${Vt}"]`));
189
189
  let n = /* @__PURE__ */ new Set();
190
190
  if (t) {
191
- if (Lt) for (let e of x(t)) n.add(e);
192
- else n.add(S(t));
191
+ if (Ht) for (let e of C(t)) n.add(e);
192
+ else n.add(xe(t));
193
193
  }
194
- for (let t of e.querySelectorAll(xe)) {
194
+ for (let t of e.querySelectorAll(ye)) {
195
195
  let e = n.has(t) ? "0" : "-1";
196
196
  t.getAttribute("tabindex") !== e && t.setAttribute("tabindex", e);
197
197
  }
198
198
  });
199
- let Vt = _(!1), Ht = () => {
200
- let e = Bt(X, It);
199
+ let Kt = y(!1), qt = () => {
200
+ let e = Gt(X, Vt);
201
201
  if (!e) return !1;
202
- let t = S(e);
202
+ let t = xe(e);
203
203
  return t.focus({ preventScroll: !0 }), (t === e ? e : t).scrollIntoView?.({
204
204
  block: "nearest",
205
205
  inline: "nearest"
206
206
  }), !0;
207
207
  };
208
- h(() => {
209
- Rt !== 0 && (Vt.current = !Ht());
210
- }, [Rt]), h(() => {
211
- Vt.current && (Ht() ? Vt.current = !1 : H && X > 0 && U.scrollToIndex(X - 1));
208
+ _(() => {
209
+ Ut !== 0 && (Kt.current = !qt());
210
+ }, [Ut]), _(() => {
211
+ Kt.current && (qt() ? Kt.current = !1 : H && X > 0 && U.scrollToIndex(X - 1));
212
212
  });
213
213
  let Q = (e, t) => {
214
- let n = Math.max(0, Math.min(e, Nt));
215
- Z(!1), Ft({
214
+ let n = Math.max(0, Math.min(e, Rt));
215
+ Z(!1), Bt({
216
216
  r: n,
217
217
  c: Math.max(0, Math.min(t, K - 1))
218
- }), H && n > 0 && U.scrollToIndex(n - 1), zt((e) => e + 1);
219
- }, Ut = (e) => {
218
+ }), H && n > 0 && U.scrollToIndex(n - 1), Wt((e) => e + 1);
219
+ }, Jt = (e) => {
220
220
  let t = e.target, n = t.closest("[data-cell]");
221
221
  if (!n || !j.current?.contains(n)) return;
222
- let [r, i] = Ce(n);
223
- (r !== X || i !== It) && Ft({
222
+ let [r, i] = Se(n);
223
+ (r !== X || i !== Vt) && Bt({
224
224
  r,
225
225
  c: i
226
- }), Z(t !== n && t !== S(n));
227
- }, Wt = (e) => {
226
+ }), Z(t !== n && t !== xe(n));
227
+ }, Yt = (e) => {
228
228
  let t = e.relatedTarget;
229
229
  t && j.current?.contains(t) || Z(!1);
230
- }, Gt = (e) => {
231
- if (kt.current = e.shiftKey, e.defaultPrevented || e.nativeEvent.isComposing) return;
230
+ }, Xt = (e) => {
231
+ if (Pt.current = e.shiftKey, e.defaultPrevented || e.nativeEvent.isComposing) return;
232
232
  let t = e.target, n = t.closest("[data-cell]");
233
233
  if (!n || !j.current?.contains(n)) return;
234
- let [r, i] = Ce(n);
235
- if (Lt || t !== n && t !== S(n)) {
234
+ let [r, i] = Se(n);
235
+ if (Ht || t !== n && t !== xe(n)) {
236
236
  if (e.key === "Escape") e.preventDefault(), Z(!1), n.focus();
237
237
  else if (e.key === "Tab") {
238
- let r = x(n);
238
+ let r = C(n);
239
239
  if (r.length === 0) return;
240
240
  e.preventDefault(), r[(r.indexOf(t) + (e.shiftKey ? -1 : 1) + r.length) % r.length].focus();
241
241
  }
@@ -259,116 +259,128 @@ function C({ rows: d, columns: f, getRowId: p = Te, getRowLabel: Se, "aria-label
259
259
  e.preventDefault(), Q(o ? 0 : r, 0);
260
260
  return;
261
261
  case "End":
262
- e.preventDefault(), Q(o ? Nt : r, K - 1);
262
+ e.preventDefault(), Q(o ? Rt : r, K - 1);
263
263
  return;
264
264
  case "PageDown":
265
- e.preventDefault(), Q(Math.max(1, r + ge), i);
265
+ e.preventDefault(), Q(Math.max(1, r + me), i);
266
266
  return;
267
267
  case "PageUp":
268
- e.preventDefault(), Q(Math.max(+(r > 0), r - ge), i);
268
+ e.preventDefault(), Q(Math.max(+(r > 0), r - me), i);
269
269
  return;
270
270
  case "Enter":
271
271
  case "F2": {
272
- let r = x(n);
272
+ let r = C(n);
273
273
  r.length > 0 && (t === n || e.key === "F2") ? (e.preventDefault(), Z(!0), r[0].focus()) : e.key === "Enter" && t === n && s && D && (e.preventDefault(), D(s));
274
274
  return;
275
275
  }
276
276
  case " ":
277
- s && bt && t === n && (e.preventDefault(), At(r - 1, e.shiftKey));
277
+ s && Tt && t === n && (e.preventDefault(), Ft(r - 1, e.shiftKey));
278
278
  return;
279
- default: o && e.key.toLowerCase() === "a" && G && (e.preventDefault(), jt(!Et));
279
+ default: o && e.key.toLowerCase() === "a" && G && (e.preventDefault(), It(!jt));
280
280
  }
281
- }, Kt = g(() => new Intl.NumberFormat(k), [k]), qt = g(() => new Intl.DateTimeFormat(k, { dateStyle: "medium" }), [k]), Jt = (e) => e == null ? "" : typeof e == "number" ? Kt.format(e) : e instanceof Date ? qt.format(e) : String(e), Yt = (e, t) => {
282
- if (e.target.closest(be)) return;
281
+ }, Zt = v(() => new Intl.NumberFormat(k), [k]), Qt = v(() => new Intl.DateTimeFormat(k, { dateStyle: "medium" }), [k]), $t = (e) => e == null ? "" : typeof e == "number" ? Zt.format(e) : e instanceof Date ? Qt.format(e) : String(e), en = (e, t) => {
282
+ if (e.target.closest(ve)) return;
283
283
  let n = B[t];
284
- w === "single" && At(t, !1, !0), n && D && D(n);
284
+ w === "single" && Ft(t, !1, !0), n && D && D(n);
285
285
  }, $ = H ? r(U, X > 0 ? [X - 1] : []) : B.map((e, t) => ({
286
286
  index: t,
287
287
  start: 0,
288
288
  end: 0,
289
289
  size: 0
290
- })), Xt = $[$.length - 1], Zt = H && Xt ? U.totalSize - Xt.end : 0, Qt = M[0], $t = !E && ct.trim() !== "", en = !!T || G && Y > 0, tn = R === 0 ? 0 : V + 1, nn = Math.min(R, V + B.length);
291
- return /* @__PURE__ */ b("div", {
292
- className: i(m.frame, me[Ge], pe[We], Ke && m.hoverable, qe && m.sticky, Ze),
290
+ })), tn = $[$.length - 1], nn = y({});
291
+ nn.current.fn = et, g(() => {
292
+ let e = nn.current, t = e.last;
293
+ t === B || t && t.length === B.length && t.every((e, t) => e === B[t]) || (e.last = B, e.fn?.(B));
294
+ });
295
+ let rn = H ? U.virtualItems : $, an = rn[0]?.index ?? 0, on = rn[rn.length - 1]?.index ?? -1, sn = y(tt);
296
+ sn.current = tt, g(() => {
297
+ sn.current?.({
298
+ start: an,
299
+ end: on
300
+ });
301
+ }, [an, on]);
302
+ let cn = H && tn ? U.totalSize - tn.end : 0, ln = M[0], un = !E && pt.trim() !== "", dn = !!T || G && Y > 0, fn = R === 0 ? 0 : V + 1, pn = Math.min(R, V + B.length);
303
+ return /* @__PURE__ */ S("div", {
304
+ className: i(h.frame, fe[Ge], de[We], Ke && h.hoverable, qe && h.sticky, nt),
293
305
  style: H ? {
294
- ...Qe,
295
- "--_head-h": `${mt}px`
296
- } : Qe,
306
+ ...rt,
307
+ "--_head-h": `${yt}px`
308
+ } : rt,
297
309
  children: [
298
- /* @__PURE__ */ y(c, {
310
+ /* @__PURE__ */ x(c, {
299
311
  scrollbars: "both",
300
- maxHeight: gt,
312
+ maxHeight: xt,
301
313
  shadows: !1,
302
314
  tabIndex: -1,
303
- className: m.scroll,
304
- viewportRef: ft,
305
- viewportClassName: H ? m.virtualViewport : void 0,
306
- children: /* @__PURE__ */ b("table", {
307
- ref: rt,
308
- role: "grid",
309
- className: i(m.table, _t === "fixed" && m.fixed),
315
+ className: h.scroll,
316
+ viewportRef: _t,
317
+ viewportClassName: H ? h.virtualViewport : void 0,
318
+ children: /* @__PURE__ */ S("table", {
319
+ ref: ct,
320
+ role: Ze ? "treegrid" : "grid",
321
+ className: i(h.table, St === "fixed" && h.fixed),
310
322
  style: Xe,
311
- "aria-label": C,
323
+ "aria-label": Te,
312
324
  "aria-labelledby": Ee,
313
325
  "aria-describedby": De,
314
326
  "aria-rowcount": R + 1,
315
327
  "aria-colcount": K,
316
328
  "aria-multiselectable": G || void 0,
317
329
  "aria-busy": He || void 0,
318
- onKeyDown: Gt,
319
- onFocus: Ut,
320
- onBlur: Wt,
330
+ onKeyDown: Xt,
331
+ onFocus: Jt,
332
+ onBlur: Yt,
321
333
  onPointerDown: (e) => {
322
- kt.current = e.shiftKey;
334
+ Pt.current = e.shiftKey;
323
335
  },
324
- children: [/* @__PURE__ */ y("thead", {
325
- ref: pt,
326
- className: m.head,
327
- children: /* @__PURE__ */ b("tr", {
336
+ children: [/* @__PURE__ */ x("thead", {
337
+ ref: vt,
338
+ className: h.head,
339
+ children: /* @__PURE__ */ S("tr", {
328
340
  "aria-rowindex": 1,
329
- children: [G && /* @__PURE__ */ y("th", {
341
+ children: [G && /* @__PURE__ */ x("th", {
330
342
  role: "columnheader",
331
343
  "data-cell": "0:0",
332
344
  "data-select-column": "",
333
345
  "aria-colindex": 1,
334
- className: i(m.cell, m.selectCell),
335
- children: /* @__PURE__ */ y(o, {
336
- checked: Et,
337
- indeterminate: Dt,
346
+ className: i(h.cell, h.selectCell),
347
+ children: /* @__PURE__ */ x(o, {
348
+ checked: jt,
349
+ indeterminate: Mt,
338
350
  disabled: J.length === 0,
339
- onCheckedChange: (e) => jt(Dt ? !0 : e),
351
+ onCheckedChange: (e) => It(Mt ? !0 : e),
340
352
  "aria-label": O.table.selectAll
341
353
  })
342
- }), f.map((e, t) => {
343
- let n = t + xt, r = M.findIndex((t) => t.key === e.key), a = r >= 0 ? M[r].direction : null, o = a === "ascending" ? ee : a === "descending" ? u : te, s = e.align ?? (e.numeric ? "end" : "start");
344
- return /* @__PURE__ */ b("th", {
354
+ }), p.map((e, t) => {
355
+ let n = t + Et, r = M.findIndex((t) => t.key === e.key), a = r >= 0 ? M[r].direction : null, o = a === "ascending" ? d : a === "descending" ? u : ee, s = e.align ?? (e.numeric ? "end" : "start");
356
+ return /* @__PURE__ */ S("th", {
345
357
  role: "columnheader",
346
358
  "data-cell": `0:${n}`,
347
359
  "aria-colindex": n + 1,
348
360
  scope: "col",
349
- "aria-sort": Qt?.key === e.key ? Qt.direction : void 0,
361
+ "aria-sort": ln?.key === e.key ? ln.direction : void 0,
350
362
  "data-sorted": a ?? void 0,
351
- className: i(m.cell, m.headerCell, e.sortable && m.sortableCell, he[s], e.numeric && m.numeric, e.headerEnd != null && m.hasHeaderEnd, e.className),
363
+ className: i(h.cell, h.headerCell, e.sortable && h.sortableCell, pe[s], e.numeric && h.numeric, e.headerEnd != null && h.hasHeaderEnd, e.className),
352
364
  style: {
353
- inlineSize: we(e.width),
354
- minInlineSize: we(e.minWidth),
365
+ inlineSize: Ce(e.width),
366
+ minInlineSize: Ce(e.minWidth),
355
367
  ...e.style
356
368
  },
357
- children: [e.sortable ? /* @__PURE__ */ b("button", {
369
+ children: [e.sortable ? /* @__PURE__ */ S("button", {
358
370
  type: "button",
359
- className: m.sortButton,
360
- onClick: (t) => Mt(e, t.shiftKey || kt.current),
361
- children: [/* @__PURE__ */ y("span", {
362
- className: m.sortLabel,
371
+ className: h.sortButton,
372
+ onClick: (t) => Lt(e, t.shiftKey || Pt.current),
373
+ children: [/* @__PURE__ */ x("span", {
374
+ className: h.sortLabel,
363
375
  children: e.header
364
- }), /* @__PURE__ */ b("span", {
365
- className: m.sortIcon,
376
+ }), /* @__PURE__ */ S("span", {
377
+ className: h.sortIcon,
366
378
  "aria-hidden": "true",
367
- children: [/* @__PURE__ */ y(o, {
379
+ children: [/* @__PURE__ */ x(o, {
368
380
  size: "sm",
369
381
  strokeWidth: 2.5
370
- }), M.length > 1 && r >= 0 && /* @__PURE__ */ y("span", {
371
- className: m.sortPriority,
382
+ }), M.length > 1 && r >= 0 && /* @__PURE__ */ x("span", {
383
+ className: h.sortPriority,
372
384
  children: r + 1
373
385
  })]
374
386
  })]
@@ -376,113 +388,126 @@ function C({ rows: d, columns: f, getRowId: p = Te, getRowLabel: Se, "aria-label
376
388
  }, e.key);
377
389
  })]
378
390
  })
379
- }), /* @__PURE__ */ y("tbody", {
380
- className: m.body,
381
- children: B.length === 0 ? /* @__PURE__ */ y("tr", {
382
- className: m.emptyRow,
383
- children: /* @__PURE__ */ y("td", {
391
+ }), /* @__PURE__ */ x("tbody", {
392
+ className: h.body,
393
+ children: B.length === 0 ? /* @__PURE__ */ x("tr", {
394
+ className: h.emptyRow,
395
+ children: /* @__PURE__ */ x("td", {
384
396
  role: "gridcell",
385
397
  colSpan: K,
386
- className: i(m.cell, m.emptyCell),
387
- children: He ? /* @__PURE__ */ b("span", {
388
- className: m.loadingInline,
389
- children: [/* @__PURE__ */ y(s, {
398
+ className: i(h.cell, h.emptyCell),
399
+ children: He ? /* @__PURE__ */ S("span", {
400
+ className: h.loadingInline,
401
+ children: [/* @__PURE__ */ x(s, {
390
402
  size: "sm",
391
403
  decorative: !0
392
404
  }), O.table.loading]
393
- }) : Ue ?? ($t ? A.noResults : A.empty)
405
+ }) : Ue ?? (un ? A.noResults : A.empty)
394
406
  })
395
- }) : /* @__PURE__ */ b(fe, { children: [$.map((e, t) => {
396
- let n = e.index, r = B[n], a = p(r), s = n + 1, c = q.has(a), l = Tt(r), u = H ? e.start - (t === 0 ? mt : $[t - 1].end) : 0;
397
- return /* @__PURE__ */ b(ce, { children: [u > .5 && /* @__PURE__ */ y("tr", {
398
- "aria-hidden": "true",
399
- className: m.spacer,
400
- style: { blockSize: u },
401
- children: /* @__PURE__ */ y("td", { colSpan: K })
402
- }), /* @__PURE__ */ b("tr", {
403
- ref: H ? U.measureElement : void 0,
404
- "data-index": H ? n : void 0,
405
- "data-even": (V + n) % 2 == 1 || void 0,
406
- "aria-rowindex": V + n + 2,
407
- "aria-selected": bt ? c : void 0,
408
- "aria-disabled": bt && !l ? !0 : void 0,
409
- "data-selected": c || void 0,
410
- className: i(m.row, (D || w === "single") && m.clickable),
411
- onClick: (e) => Yt(e, n),
412
- children: [G && /* @__PURE__ */ y("td", {
413
- role: "gridcell",
414
- "data-cell": `${s}:0`,
415
- "data-select-column": "",
416
- "aria-colindex": 1,
417
- className: i(m.cell, m.selectCell),
418
- children: /* @__PURE__ */ y(o, {
419
- checked: c,
420
- disabled: !l,
421
- onCheckedChange: (e) => At(n, kt.current, e),
422
- "aria-label": O.table.selectRowNamed(Ct(r))
407
+ }) : /* @__PURE__ */ S(ue, { children: [$.map((e, t) => {
408
+ let n = e.index, r = B[n], a = m(r), s = n + 1, c = q.has(a), l = Qe?.(r), u = $e?.(r), d = At(r), ee = H ? e.start - (t === 0 ? yt : $[t - 1].end) : 0;
409
+ return /* @__PURE__ */ S(se, { children: [
410
+ ee > .5 && /* @__PURE__ */ x("tr", {
411
+ "aria-hidden": "true",
412
+ className: h.spacer,
413
+ style: { blockSize: ee },
414
+ children: /* @__PURE__ */ x("td", { colSpan: K })
415
+ }),
416
+ /* @__PURE__ */ S("tr", {
417
+ ref: H ? U.measureElement : void 0,
418
+ "data-index": H ? n : void 0,
419
+ "data-even": (V + n) % 2 == 1 || void 0,
420
+ "aria-rowindex": V + n + 2,
421
+ "aria-selected": Tt && l?.selectable !== !1 ? c : void 0,
422
+ "aria-disabled": Tt && !d && l?.selectable !== !1 ? !0 : void 0,
423
+ "data-selected": c || void 0,
424
+ "aria-level": l?.level,
425
+ "aria-expanded": l?.expanded,
426
+ className: i(h.row, (D || w === "single") && h.clickable, l?.className),
427
+ onClick: (e) => en(e, n),
428
+ children: [G && /* @__PURE__ */ x("td", {
429
+ role: "gridcell",
430
+ "data-cell": `${s}:0`,
431
+ "data-select-column": "",
432
+ "aria-colindex": 1,
433
+ className: i(h.cell, h.selectCell),
434
+ children: l?.selectable !== !1 && /* @__PURE__ */ x(o, {
435
+ checked: c,
436
+ disabled: !d,
437
+ onCheckedChange: (e) => Ft(n, Pt.current, e),
438
+ "aria-label": O.table.selectRowNamed(Ot(r))
439
+ })
440
+ }), p.map((e, t) => {
441
+ let a = t + Et, o = re(r, e), l = e.cell ? e.cell(r, {
442
+ value: o,
443
+ rowIndex: gt + n,
444
+ selected: c
445
+ }) : $t(o), u = e.align ?? (e.numeric ? "end" : "start"), d = e.rowHeader ? "th" : "td";
446
+ return /* @__PURE__ */ x(d, {
447
+ role: e.rowHeader ? "rowheader" : "gridcell",
448
+ "data-cell": `${s}:${a}`,
449
+ "aria-colindex": a + 1,
450
+ scope: e.rowHeader ? "row" : void 0,
451
+ className: i(h.cell, e.rowHeader && h.rowHeader, pe[u], e.numeric && h.numeric, e.className),
452
+ style: e.style,
453
+ children: l
454
+ }, e.key);
455
+ })]
456
+ }),
457
+ u != null && u !== !1 && /* @__PURE__ */ x("tr", {
458
+ className: h.detailRow,
459
+ children: /* @__PURE__ */ x("td", {
460
+ colSpan: K,
461
+ className: i(h.cell, h.detailCell),
462
+ children: u
423
463
  })
424
- }), f.map((e, t) => {
425
- let a = t + xt, o = ie(r, e), l = e.cell ? e.cell(r, {
426
- value: o,
427
- rowIndex: dt + n,
428
- selected: c
429
- }) : Jt(o), u = e.align ?? (e.numeric ? "end" : "start"), ee = e.rowHeader ? "th" : "td";
430
- return /* @__PURE__ */ y(ee, {
431
- role: e.rowHeader ? "rowheader" : "gridcell",
432
- "data-cell": `${s}:${a}`,
433
- "aria-colindex": a + 1,
434
- scope: e.rowHeader ? "row" : void 0,
435
- className: i(m.cell, e.rowHeader && m.rowHeader, he[u], e.numeric && m.numeric, e.className),
436
- style: e.style,
437
- children: l
438
- }, e.key);
439
- })]
440
- })] }, a);
441
- }), Zt > .5 && /* @__PURE__ */ y("tr", {
464
+ })
465
+ ] }, a);
466
+ }), cn > .5 && /* @__PURE__ */ x("tr", {
442
467
  "aria-hidden": "true",
443
- className: m.spacer,
444
- style: { blockSize: Zt },
445
- children: /* @__PURE__ */ y("td", { colSpan: K })
468
+ className: h.spacer,
469
+ style: { blockSize: cn },
470
+ children: /* @__PURE__ */ x("td", { colSpan: K })
446
471
  })] })
447
472
  })]
448
473
  })
449
474
  }),
450
- He && B.length > 0 && /* @__PURE__ */ y("div", {
451
- className: m.loadingOverlay,
452
- children: /* @__PURE__ */ y(s, { label: O.table.loading })
475
+ He && B.length > 0 && /* @__PURE__ */ x("div", {
476
+ className: h.loadingOverlay,
477
+ children: /* @__PURE__ */ x(s, { label: O.table.loading })
453
478
  }),
454
- /* @__PURE__ */ y("span", {
479
+ /* @__PURE__ */ x("span", {
455
480
  hidden: !0,
456
- id: tt,
481
+ id: ot,
457
482
  children: O.pagination.nav
458
483
  }),
459
- C && !Ee && /* @__PURE__ */ y("span", {
484
+ Te && !Ee && /* @__PURE__ */ x("span", {
460
485
  hidden: !0,
461
- id: nt,
462
- children: C
486
+ id: st,
487
+ children: Te
463
488
  }),
464
- en && /* @__PURE__ */ b("div", {
465
- className: m.footer,
466
- children: [/* @__PURE__ */ y("span", {
489
+ dn && /* @__PURE__ */ S("div", {
490
+ className: h.footer,
491
+ children: [/* @__PURE__ */ x("span", {
467
492
  role: "status",
468
- className: m.status,
493
+ className: h.status,
469
494
  children: G && Y > 0 ? A.selectedCount(Y) : null
470
- }), T ? /* @__PURE__ */ b("div", {
471
- className: m.paging,
472
- children: [/* @__PURE__ */ y("span", {
473
- className: m.range,
474
- children: A.range(tn, nn, R)
475
- }), ut > 1 && /* @__PURE__ */ y(l, {
495
+ }), T ? /* @__PURE__ */ S("div", {
496
+ className: h.paging,
497
+ children: [/* @__PURE__ */ x("span", {
498
+ className: h.range,
499
+ children: A.range(fn, pn, R)
500
+ }), ht > 1 && /* @__PURE__ */ x(l, {
476
501
  size: "sm",
477
502
  compact: !0,
478
- pageCount: ut,
503
+ pageCount: ht,
479
504
  page: z,
480
- onPageChange: st,
481
- "aria-labelledby": `${tt} ${Ee ?? nt}`
505
+ onPageChange: ft,
506
+ "aria-labelledby": `${ot} ${Ee ?? st}`
482
507
  })]
483
508
  }) : null]
484
509
  })
485
510
  ]
486
511
  });
487
512
  }
488
- export { C as DataGrid, d as compareValues, re as createSearchIndex, f as filterRows, ie as getCellValue, se as sortIndices, p as sortRows };
513
+ export { Te as DataGrid, f as compareValues, ne as createSearchIndex, p as filterRows, re as getCellValue, oe as sortIndices, m as sortRows };