@overdoser/react-toolkit 0.18.0 → 0.19.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 (156) hide show
  1. package/AGENTS.md +51 -7
  2. package/CHANGELOG.md +129 -0
  3. package/components/Accordion/Accordion.d.ts +94 -0
  4. package/components/Accordion/Accordion.js +180 -0
  5. package/components/Accordion/Accordion.module.scss.js +36 -0
  6. package/components/Accordion/index.d.ts +2 -0
  7. package/components/Alert/Alert.d.ts +29 -1
  8. package/components/Alert/Alert.js +44 -30
  9. package/components/Alert/Alert.module.scss.js +24 -16
  10. package/components/Alert/index.d.ts +1 -1
  11. package/components/Card/Card.d.ts +86 -0
  12. package/components/Card/Card.js +132 -0
  13. package/components/Card/Card.module.scss.js +60 -0
  14. package/components/Card/index.d.ts +2 -0
  15. package/components/Chip/Chip.d.ts +86 -0
  16. package/components/Chip/Chip.js +141 -0
  17. package/components/Chip/Chip.module.scss.js +59 -0
  18. package/components/Chip/index.d.ts +2 -0
  19. package/components/CodeBlock/CodeBlock.d.ts +78 -0
  20. package/components/CodeBlock/CodeBlock.js +120 -0
  21. package/components/CodeBlock/CodeBlock.module.scss.js +43 -0
  22. package/components/CodeBlock/index.d.ts +2 -0
  23. package/components/CommandPalette/CommandPalette.d.ts +141 -0
  24. package/components/CommandPalette/CommandPalette.js +397 -0
  25. package/components/CommandPalette/CommandPalette.module.scss.js +49 -0
  26. package/components/CommandPalette/index.d.ts +2 -0
  27. package/components/ConfirmDialog/ConfirmDialog.d.ts +119 -0
  28. package/components/ConfirmDialog/ConfirmDialog.js +201 -0
  29. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +21 -0
  30. package/components/ConfirmDialog/index.d.ts +2 -0
  31. package/components/Drawer/Drawer.d.ts +1 -0
  32. package/components/Drawer/Drawer.js +35 -36
  33. package/components/Drawer/Drawer.module.scss.js +20 -18
  34. package/components/Dropdown/Dropdown.d.ts +47 -7
  35. package/components/Dropdown/Dropdown.js +174 -81
  36. package/components/Dropdown/Dropdown.module.scss.js +40 -22
  37. package/components/Dropdown/DropdownItem.d.ts +31 -2
  38. package/components/Dropdown/DropdownItem.js +54 -27
  39. package/components/Dropdown/DropdownLabel.d.ts +11 -0
  40. package/components/Dropdown/DropdownLabel.js +11 -0
  41. package/components/Dropdown/DropdownSeparator.d.ts +12 -0
  42. package/components/Dropdown/DropdownSeparator.js +11 -0
  43. package/components/Dropdown/dropdownContext.d.ts +6 -0
  44. package/components/Dropdown/dropdownContext.js +5 -0
  45. package/components/Dropdown/index.d.ts +8 -2
  46. package/components/Dropdown/useContextMenu.d.ts +32 -0
  47. package/components/Dropdown/useContextMenu.js +18 -0
  48. package/components/EmptyState/EmptyState.d.ts +53 -0
  49. package/components/EmptyState/EmptyState.js +55 -0
  50. package/components/EmptyState/EmptyState.module.scss.js +25 -0
  51. package/components/EmptyState/index.d.ts +2 -0
  52. package/components/Form/FormField.js +25 -24
  53. package/components/ImageViewer/ImageViewer.d.ts +105 -0
  54. package/components/ImageViewer/ImageViewer.js +201 -0
  55. package/components/ImageViewer/ImageViewer.module.scss.js +47 -0
  56. package/components/ImageViewer/index.d.ts +4 -0
  57. package/components/ImageViewer/useZoomPan.d.ts +94 -0
  58. package/components/ImageViewer/useZoomPan.js +141 -0
  59. package/components/Kbd/Kbd.d.ts +26 -0
  60. package/components/Kbd/Kbd.js +22 -0
  61. package/components/Kbd/Kbd.module.scss.js +17 -0
  62. package/components/Kbd/index.d.ts +2 -0
  63. package/components/KeyValueList/KeyValueList.d.ts +84 -0
  64. package/components/KeyValueList/KeyValueList.js +127 -0
  65. package/components/KeyValueList/KeyValueList.module.scss.js +43 -0
  66. package/components/KeyValueList/index.d.ts +2 -0
  67. package/components/Modal/Modal.d.ts +1 -0
  68. package/components/Modal/Modal.js +40 -41
  69. package/components/Modal/Modal.module.scss.js +18 -16
  70. package/components/PageHeader/PageHeader.d.ts +61 -0
  71. package/components/PageHeader/PageHeader.js +73 -0
  72. package/components/PageHeader/PageHeader.module.scss.js +43 -0
  73. package/components/PageHeader/index.d.ts +2 -0
  74. package/components/ProgressBar/ProgressBar.d.ts +74 -0
  75. package/components/ProgressBar/ProgressBar.js +90 -0
  76. package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
  77. package/components/ProgressBar/index.d.ts +2 -0
  78. package/components/RelativeTime/RelativeTime.d.ts +45 -0
  79. package/components/RelativeTime/RelativeTime.js +43 -0
  80. package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
  81. package/components/RelativeTime/index.d.ts +2 -0
  82. package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
  83. package/components/SegmentedControl/SegmentedControl.js +131 -0
  84. package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
  85. package/components/SegmentedControl/index.d.ts +2 -0
  86. package/components/SplitPane/SplitPane.d.ts +61 -0
  87. package/components/SplitPane/SplitPane.js +171 -0
  88. package/components/SplitPane/SplitPane.module.scss.js +25 -0
  89. package/components/SplitPane/index.d.ts +2 -0
  90. package/components/StatCard/StatCard.d.ts +105 -0
  91. package/components/StatCard/StatCard.js +127 -0
  92. package/components/StatCard/StatCard.module.scss.js +72 -0
  93. package/components/StatCard/index.d.ts +2 -0
  94. package/components/StatusDot/StatusDot.d.ts +33 -0
  95. package/components/StatusDot/StatusDot.js +39 -0
  96. package/components/StatusDot/StatusDot.module.scss.js +32 -0
  97. package/components/StatusDot/index.d.ts +2 -0
  98. package/components/Table/Table.d.ts +100 -2
  99. package/components/Table/Table.js +371 -210
  100. package/components/Table/Table.module.scss.js +68 -46
  101. package/components/Table/index.d.ts +1 -1
  102. package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
  103. package/components/ThemeToggle/ThemeToggle.js +97 -0
  104. package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
  105. package/components/ThemeToggle/index.d.ts +2 -0
  106. package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
  107. package/components/inputs/Checkbox/Checkbox.js +29 -28
  108. package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
  109. package/components/inputs/Input/Input.d.ts +33 -1
  110. package/components/inputs/Input/Input.js +94 -35
  111. package/components/inputs/Input/Input.module.scss.js +14 -12
  112. package/components/inputs/Radio/Radio.d.ts +5 -4
  113. package/components/inputs/Radio/Radio.js +55 -50
  114. package/components/inputs/Radio/Radio.module.scss.js +12 -10
  115. package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
  116. package/components/inputs/SearchInput/SearchInput.js +116 -0
  117. package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
  118. package/components/inputs/SearchInput/index.d.ts +2 -0
  119. package/components/inputs/Select/Select.d.ts +52 -0
  120. package/components/inputs/Select/Select.js +494 -385
  121. package/components/inputs/Select/Select.module.scss.js +34 -30
  122. package/components/inputs/Switch/Switch.d.ts +15 -0
  123. package/components/inputs/Switch/Switch.js +8 -0
  124. package/components/inputs/Switch/index.d.ts +2 -0
  125. package/hooks/useDebouncedValue.d.ts +15 -0
  126. package/hooks/useDebouncedValue.js +15 -0
  127. package/hooks/useElementSize.d.ts +20 -0
  128. package/hooks/useElementSize.js +23 -0
  129. package/hooks/useKeyboard.d.ts +49 -5
  130. package/hooks/useKeyboard.js +66 -16
  131. package/hooks/useMediaQuery.d.ts +14 -0
  132. package/hooks/useMediaQuery.js +16 -0
  133. package/hooks/useNow.d.ts +14 -0
  134. package/hooks/useNow.js +35 -0
  135. package/hooks/usePersistedState.d.ts +30 -0
  136. package/hooks/usePersistedState.js +96 -0
  137. package/hooks/useResizable.d.ts +66 -0
  138. package/hooks/useResizable.js +105 -0
  139. package/hooks/useTheme.d.ts +33 -0
  140. package/hooks/useTheme.js +27 -0
  141. package/index.css +1 -1
  142. package/index.d.ts +58 -4
  143. package/index.js +208 -132
  144. package/index.layered.css +1 -1
  145. package/llms.txt +619 -25
  146. package/manifest.json +1739 -91
  147. package/package.json +1 -1
  148. package/recipes/confirm-modal.tsx +65 -53
  149. package/recipes/floating-copy-button.tsx +32 -28
  150. package/utils/formatBytes.d.ts +21 -0
  151. package/utils/formatBytes.js +14 -0
  152. package/utils/index.d.ts +6 -0
  153. package/utils/themeScript.d.ts +17 -0
  154. package/utils/themeScript.js +9 -0
  155. package/utils/timeAgo.d.ts +33 -0
  156. package/utils/timeAgo.js +37 -0
@@ -1,85 +1,89 @@
1
- import { jsxs as y, jsx as s } from "react/jsx-runtime";
2
- import { useMemo as _, useCallback as A, useRef as X, useState as ne } from "react";
3
- import d from "clsx";
1
+ import { jsxs as v, jsx as l } from "react/jsx-runtime";
2
+ import { useMemo as W, useCallback as y, useEffect as Ue, useState as ke, useRef as H } from "react";
3
+ import o from "clsx";
4
4
  import n from "./Table.module.scss.js";
5
- import { useTableSort as re } from "./useTableSort.js";
6
- function ae({ direction: i, sortIndex: o }) {
7
- return /* @__PURE__ */ y("span", { className: n.sortIndicator, "aria-hidden": "true", children: [
8
- /* @__PURE__ */ s("span", { className: d(n.sortArrow, i === "asc" && n.sortArrowActive), children: "▲" }),
9
- /* @__PURE__ */ s("span", { className: d(n.sortArrow, i === "desc" && n.sortArrowActive), children: "▼" }),
10
- o !== void 0 && o >= 0 && /* @__PURE__ */ s("span", { className: n.sortIndex, children: o + 1 })
5
+ import { useTableSort as Ge } from "./useTableSort.js";
6
+ import { Loader as Je } from "../Loader/Loader.js";
7
+ import { Skeleton as Qe } from "../Skeleton/Skeleton.js";
8
+ import { Checkbox as Ne } from "../inputs/Checkbox/Checkbox.js";
9
+ const Ye = 'button, a, input, select, textarea, label, [role="button"], [role="checkbox"], [role="menuitem"], [contenteditable]';
10
+ function Ze({ direction: c, sortIndex: f }) {
11
+ return /* @__PURE__ */ v("span", { className: n.sortIndicator, "aria-hidden": "true", children: [
12
+ /* @__PURE__ */ l("span", { className: o(n.sortArrow, c === "asc" && n.sortArrowActive), children: "▲" }),
13
+ /* @__PURE__ */ l("span", { className: o(n.sortArrow, c === "desc" && n.sortArrowActive), children: "▼" }),
14
+ f !== void 0 && f >= 0 && /* @__PURE__ */ l("span", { className: n.sortIndex, children: f + 1 })
11
15
  ] });
12
16
  }
13
- function ie({
14
- page: i,
15
- pageSize: o,
16
- totalRows: b,
17
- pageSizeOptions: h = [10, 25, 50, 100],
18
- onPageChange: v,
19
- paginatorClasses: C
17
+ function ze({
18
+ page: c,
19
+ pageSize: f,
20
+ totalRows: E,
21
+ pageSizeOptions: I = [10, 25, 50, 100],
22
+ onPageChange: P,
23
+ paginatorClasses: R
20
24
  }) {
21
- const c = Math.max(1, Math.ceil(b / o)), P = (i - 1) * o + 1, R = Math.min(i * o, b), S = _(() => {
22
- const r = [];
23
- if (c <= 7)
24
- for (let u = 1; u <= c; u++) r.push(u);
25
+ const p = Math.max(1, Math.ceil(E / f)), J = (c - 1) * f + 1, Q = Math.min(c * f, E), Y = W(() => {
26
+ const i = [];
27
+ if (p <= 7)
28
+ for (let k = 1; k <= p; k++) i.push(k);
25
29
  else {
26
- r.push(1), i > 3 && r.push("ellipsis");
27
- for (let u = Math.max(2, i - 1); u <= Math.min(c - 1, i + 1); u++)
28
- r.push(u);
29
- i < c - 2 && r.push("ellipsis"), r.push(c);
30
+ i.push(1), c > 3 && i.push("ellipsis");
31
+ for (let k = Math.max(2, c - 1); k <= Math.min(p - 1, c + 1); k++)
32
+ i.push(k);
33
+ c < p - 2 && i.push("ellipsis"), i.push(p);
30
34
  }
31
- return r;
32
- }, [i, c]);
33
- return /* @__PURE__ */ y("nav", { className: d(n.paginator, C?.paginator), "aria-label": "Table pagination", children: [
34
- /* @__PURE__ */ y("div", { className: n.paginatorInfo, children: [
35
- /* @__PURE__ */ s("span", { className: n.paginatorText, children: b > 0 ? `${P}–${R} of ${b}` : "No results" }),
36
- h.length > 1 && /* @__PURE__ */ s(
35
+ return i;
36
+ }, [c, p]);
37
+ return /* @__PURE__ */ v("nav", { className: o(n.paginator, R?.paginator), "aria-label": "Table pagination", children: [
38
+ /* @__PURE__ */ v("div", { className: n.paginatorInfo, children: [
39
+ /* @__PURE__ */ l("span", { className: n.paginatorText, children: E > 0 ? `${J}–${Q} of ${E}` : "No results" }),
40
+ I.length > 1 && /* @__PURE__ */ l(
37
41
  "select",
38
42
  {
39
43
  className: n.pageSizeSelect,
40
- value: o,
41
- onChange: (r) => v(1, Number(r.target.value)),
44
+ value: f,
45
+ onChange: (i) => P(1, Number(i.target.value)),
42
46
  "aria-label": "Rows per page",
43
- children: h.map((r) => /* @__PURE__ */ y("option", { value: r, children: [
44
- r,
47
+ children: I.map((i) => /* @__PURE__ */ v("option", { value: i, children: [
48
+ i,
45
49
  " / page"
46
- ] }, r))
50
+ ] }, i))
47
51
  }
48
52
  )
49
53
  ] }),
50
- /* @__PURE__ */ y("div", { className: n.paginatorNav, children: [
51
- /* @__PURE__ */ s(
54
+ /* @__PURE__ */ v("div", { className: n.paginatorNav, children: [
55
+ /* @__PURE__ */ l(
52
56
  "button",
53
57
  {
54
58
  type: "button",
55
- className: d(n.pageButton, C?.pageButton),
56
- disabled: i <= 1,
57
- onClick: () => v(i - 1, o),
59
+ className: o(n.pageButton, R?.pageButton),
60
+ disabled: c <= 1,
61
+ onClick: () => P(c - 1, f),
58
62
  "aria-label": "Previous page",
59
63
  children: "‹"
60
64
  }
61
65
  ),
62
- S.map(
63
- (r, u) => r === "ellipsis" ? /* @__PURE__ */ s("span", { className: n.pageEllipsis, children: "…" }, `ellipsis-${u}`) : /* @__PURE__ */ s(
66
+ Y.map(
67
+ (i, k) => i === "ellipsis" ? /* @__PURE__ */ l("span", { className: n.pageEllipsis, children: "…" }, `ellipsis-${k}`) : /* @__PURE__ */ l(
64
68
  "button",
65
69
  {
66
70
  type: "button",
67
- className: d(n.pageButton, r === i && n.pageButtonActive, C?.pageButton),
68
- onClick: () => v(r, o),
69
- "aria-label": `Page ${r}`,
70
- "aria-current": r === i ? "page" : void 0,
71
- children: r
71
+ className: o(n.pageButton, i === c && n.pageButtonActive, R?.pageButton),
72
+ onClick: () => P(i, f),
73
+ "aria-label": `Page ${i}`,
74
+ "aria-current": i === c ? "page" : void 0,
75
+ children: i
72
76
  },
73
- r
77
+ i
74
78
  )
75
79
  ),
76
- /* @__PURE__ */ s(
80
+ /* @__PURE__ */ l(
77
81
  "button",
78
82
  {
79
83
  type: "button",
80
- className: d(n.pageButton, C?.pageButton),
81
- disabled: i >= c,
82
- onClick: () => v(i + 1, o),
84
+ className: o(n.pageButton, R?.pageButton),
85
+ disabled: c >= p,
86
+ onClick: () => P(c + 1, f),
83
87
  "aria-label": "Next page",
84
88
  children: "›"
85
89
  }
@@ -87,63 +91,163 @@ function ie({
87
91
  ] })
88
92
  ] });
89
93
  }
90
- function se({
91
- data: i,
92
- columns: o,
93
- sortConfig: b,
94
- onSort: h,
95
- multiSort: v = !0,
96
- scrollable: C = !1,
97
- dragScroll: c = !1,
98
- striped: P = !1,
99
- hoverable: R = !1,
100
- compact: S = !1,
101
- className: r,
102
- style: u,
103
- rowKey: j,
104
- rowClassName: T,
105
- rowStyle: $,
106
- emptyMessage: F = "No data",
107
- pagination: m,
108
- classes: g
94
+ function et({
95
+ data: c,
96
+ columns: f,
97
+ sortConfig: E,
98
+ onSort: I,
99
+ multiSort: P = !0,
100
+ scrollable: R = !1,
101
+ dragScroll: p = !1,
102
+ striped: J = !1,
103
+ hoverable: Q = !1,
104
+ compact: Y = !1,
105
+ className: i,
106
+ style: k,
107
+ rowKey: K,
108
+ rowClassName: Z,
109
+ rowStyle: z,
110
+ emptyMessage: Ce = "No data",
111
+ pagination: A,
112
+ loading: $ = !1,
113
+ loadingRows: Se = 3,
114
+ onRowClick: N,
115
+ selectable: m = !1,
116
+ selectedKeys: ce,
117
+ defaultSelectedKeys: xe,
118
+ onSelectionChange: ee,
119
+ isRowSelectable: te,
120
+ bulkActions: _,
121
+ selectionLabel: de,
122
+ columnVisibility: ne,
123
+ layout: Ie = "auto",
124
+ classes: s
109
125
  }) {
110
- const x = h !== void 0, G = C || c, {
111
- sortedData: J,
112
- sortConfig: Q,
113
- requestSort: E,
114
- requestMultiSort: K
115
- } = re(i, b), p = x ? b ?? [] : Q, M = x ? i : J, W = _(() => {
116
- if (!m || x) return M;
117
- const e = (m.page - 1) * m.pageSize;
118
- return M.slice(e, e + m.pageSize);
119
- }, [M, m, x]), V = m?.totalRows ?? M.length, Y = A(
120
- (e, t, l) => {
121
- const N = v && (t.ctrlKey || t.metaKey || t.shiftKey), B = l === "asc" ? "desc" : "asc";
122
- if (x)
123
- if (N) {
124
- const a = p.findIndex((I) => I.key === e);
125
- let f;
126
- a === -1 ? f = [...p, { key: e, direction: l }] : p[a].direction === l ? f = p.map(
127
- (I, w) => w === a ? { key: e, direction: B } : I
128
- ) : f = p.filter((I, w) => w !== a), h(f);
126
+ const q = I !== void 0, Me = R || p, j = W(
127
+ () => ne ? f.filter((e) => ne[e.key] !== !1) : f,
128
+ [f, ne]
129
+ ), {
130
+ sortedData: Te,
131
+ sortConfig: we,
132
+ requestSort: ue,
133
+ requestMultiSort: fe
134
+ } = Ge(c, E), S = q ? E ?? [] : we, M = q ? c : Te, D = W(() => {
135
+ if (!A || q) return M;
136
+ const e = (A.page - 1) * A.pageSize;
137
+ return M.slice(e, e + A.pageSize);
138
+ }, [M, A, q]), Ae = A?.totalRows ?? M.length, x = y(
139
+ (e, t) => {
140
+ if (!K) return t;
141
+ const r = e[K];
142
+ return typeof r == "number" ? r : String(r);
143
+ },
144
+ [K]
145
+ );
146
+ Ue(() => {
147
+ m && !K && console.error(
148
+ "Table: `selectable` needs `rowKey` so selections survive sorting and paging; falling back to the row index."
149
+ );
150
+ }, [m, K]);
151
+ const [De, Be] = ke(
152
+ () => xe ?? []
153
+ ), re = ce !== void 0, d = re ? ce : De, V = W(() => new Set(d), [d]), le = H(null), B = y(
154
+ (e) => {
155
+ if (re || Be(e), ee) {
156
+ const t = new Set(e);
157
+ ee(
158
+ e,
159
+ M.filter((r, h) => t.has(x(r, h)))
160
+ );
161
+ }
162
+ },
163
+ [re, ee, M, x]
164
+ ), X = y(
165
+ (e) => te ? te(e) !== !1 : !0,
166
+ [te]
167
+ ), L = W(
168
+ () => {
169
+ if (!m) return [];
170
+ const e = [];
171
+ return D.forEach((t, r) => {
172
+ X(t) && e.push(x(t, r));
173
+ }), e;
174
+ },
175
+ [m, D, X, x]
176
+ ), he = L.filter((e) => V.has(e)).length, F = L.length > 0 && he === L.length, Ee = he > 0 && !F, Pe = y(() => {
177
+ if (F) {
178
+ const e = new Set(L);
179
+ B(d.filter((t) => !e.has(t)));
180
+ } else {
181
+ const e = [...d], t = new Set(d);
182
+ for (const r of L) t.has(r) || e.push(r);
183
+ B(e);
184
+ }
185
+ }, [F, L, d, B]), Ke = y(
186
+ (e, t, r) => {
187
+ const h = x(e, t), g = r.target.checked, C = r.nativeEvent.shiftKey === !0;
188
+ let b = [h];
189
+ if (C && le.current !== null) {
190
+ const u = D.map((se, oe) => x(se, oe)), T = u.indexOf(le.current), w = u.indexOf(h);
191
+ if (T >= 0 && w >= 0) {
192
+ const [se, oe] = T < w ? [T, w] : [w, T];
193
+ b = [];
194
+ for (let G = se; G <= oe; G++)
195
+ X(D[G]) && b.push(u[G]);
196
+ }
197
+ }
198
+ le.current = h;
199
+ const a = new Set(b);
200
+ if (g) {
201
+ const u = new Set(d), T = [...d];
202
+ for (const w of b) u.has(w) || T.push(w);
203
+ B(T);
204
+ } else
205
+ B(d.filter((u) => !a.has(u)));
206
+ },
207
+ [x, D, X, d, B]
208
+ ), pe = y(() => B([]), [B]), Le = W(
209
+ () => m && d.length ? M.filter((e, t) => V.has(x(e, t))) : [],
210
+ [m, d.length, M, V, x]
211
+ ), Re = y(
212
+ (e, t, r) => {
213
+ if (!N) return;
214
+ const g = r.target?.closest?.(Ye);
215
+ g && g !== r.currentTarget && r.currentTarget.contains(g) || N(e, t, r);
216
+ },
217
+ [N]
218
+ ), $e = y(
219
+ (e, t, r) => {
220
+ !N || r.target !== r.currentTarget || (r.key === "Enter" || r.key === " ") && (r.preventDefault(), N(e, t, r));
221
+ },
222
+ [N]
223
+ ), qe = y(
224
+ (e, t, r) => {
225
+ const h = P && (t.ctrlKey || t.metaKey || t.shiftKey), g = r === "asc" ? "desc" : "asc";
226
+ if (q)
227
+ if (h) {
228
+ const C = S.findIndex((a) => a.key === e);
229
+ let b;
230
+ C === -1 ? b = [...S, { key: e, direction: r }] : S[C].direction === r ? b = S.map(
231
+ (a, u) => u === C ? { key: e, direction: g } : a
232
+ ) : b = S.filter((a, u) => u !== C), I(b);
129
233
  } else {
130
- const a = p.find((f) => f.key === e);
131
- a ? a.direction === l ? h([{ key: e, direction: B }]) : h([]) : h([{ key: e, direction: l }]);
234
+ const C = S.find((b) => b.key === e);
235
+ C ? C.direction === r ? I([{ key: e, direction: g }]) : I([]) : I([{ key: e, direction: r }]);
132
236
  }
133
237
  else
134
- N ? K(e, l) : E(e, l);
238
+ h ? fe(e, r) : ue(e, r);
135
239
  },
136
240
  [
137
- x,
138
- v,
139
- p,
140
- h,
141
- E,
142
- K
241
+ q,
242
+ P,
243
+ S,
244
+ I,
245
+ ue,
246
+ fe
143
247
  ]
144
- ), q = X(null), k = X(null), D = X(!1), [Z, H] = ne(!1), O = A((e) => {
145
- const t = q.current;
146
- t && (D.current = !1, !(e.button !== 1 && e.button !== 2) && (t.scrollWidth <= t.clientWidth || (e.button === 1 && e.preventDefault(), k.current = {
248
+ ), ae = H(null), O = H(null), U = H(!1), [Oe, me] = ke(!1), We = y((e) => {
249
+ const t = ae.current;
250
+ t && (U.current = !1, !(e.button !== 1 && e.button !== 2) && (t.scrollWidth <= t.clientWidth || (e.button === 1 && e.preventDefault(), O.current = {
147
251
  pointerId: e.pointerId,
148
252
  button: e.button,
149
253
  startX: e.clientX,
@@ -151,134 +255,191 @@ function se({
151
255
  downAt: performance.now(),
152
256
  dragging: !1
153
257
  })));
154
- }, []), z = A((e) => {
155
- const t = k.current, l = q.current;
156
- if (!t || !l || e.pointerId !== t.pointerId) return;
157
- const N = e.clientX - t.startX;
258
+ }, []), Xe = y((e) => {
259
+ const t = O.current, r = ae.current;
260
+ if (!t || !r || e.pointerId !== t.pointerId) return;
261
+ const h = e.clientX - t.startX;
158
262
  if (!t.dragging) {
159
263
  if (t.button === 2 && performance.now() - t.downAt > 200) {
160
- k.current = null;
264
+ O.current = null;
161
265
  return;
162
266
  }
163
- if (Math.abs(N) < 5) return;
164
- t.dragging = !0, H(!0);
267
+ if (Math.abs(h) < 5) return;
268
+ t.dragging = !0, me(!0);
165
269
  try {
166
- l.setPointerCapture(t.pointerId);
270
+ r.setPointerCapture(t.pointerId);
167
271
  } catch {
168
272
  }
169
273
  }
170
- l.scrollLeft = t.startScrollLeft - N;
171
- }, []), U = A((e) => {
172
- const t = k.current;
173
- !t || e.pointerId !== t.pointerId || (k.current = null, t.dragging && (t.button === 2 && (D.current = !0), H(!1)));
174
- }, []), ee = A((e) => {
175
- (k.current?.dragging || D.current) && (D.current = !1, e.preventDefault());
176
- }, []), L = (e) => p.find((l) => l.key === e)?.direction, te = (e) => {
177
- if (p.length <= 1) return;
178
- const t = p.findIndex((l) => l.key === e);
274
+ r.scrollLeft = t.startScrollLeft - h;
275
+ }, []), ge = y((e) => {
276
+ const t = O.current;
277
+ !t || e.pointerId !== t.pointerId || (O.current = null, t.dragging && (t.button === 2 && (U.current = !0), me(!1)));
278
+ }, []), He = y((e) => {
279
+ (O.current?.dragging || U.current) && (U.current = !1, e.preventDefault());
280
+ }, []), ie = (e) => S.find((r) => r.key === e)?.direction, _e = (e) => {
281
+ if (S.length <= 1) return;
282
+ const t = S.findIndex((r) => r.key === e);
179
283
  return t >= 0 ? t : void 0;
180
- };
181
- return /* @__PURE__ */ y(
182
- "div",
284
+ }, be = H(!1);
285
+ $ && (be.current = !0);
286
+ const je = j.length + (m ? 1 : 0), ye = $ && D.length === 0, Ve = m && d.length > 0, ve = /* @__PURE__ */ v(
287
+ "table",
183
288
  {
184
- ref: q,
185
- className: d(
186
- n.wrapper,
187
- G && n.scrollable,
188
- Z && n.dragging,
189
- g?.wrapper
289
+ className: o(
290
+ n.root,
291
+ J && n.striped,
292
+ Q && n.hoverable,
293
+ Y && n.compact,
294
+ Ie === "fixed" && n.layoutFixed,
295
+ s?.root,
296
+ i
190
297
  ),
191
- onPointerDown: c ? O : void 0,
192
- onPointerMove: c ? z : void 0,
193
- onPointerUp: c ? U : void 0,
194
- onPointerCancel: c ? U : void 0,
195
- onContextMenu: c ? ee : void 0,
298
+ style: k,
299
+ "aria-busy": $ || void 0,
196
300
  children: [
197
- /* @__PURE__ */ y(
198
- "table",
199
- {
200
- className: d(
201
- n.root,
202
- P && n.striped,
203
- R && n.hoverable,
204
- S && n.compact,
205
- g?.root,
206
- r
207
- ),
208
- style: u,
209
- children: [
210
- /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ s("tr", { children: o.map((e) => /* @__PURE__ */ y(
211
- "th",
301
+ /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ v("tr", { children: [
302
+ m && /* @__PURE__ */ l(
303
+ "th",
304
+ {
305
+ className: o(n.headerCell, n.selectHeaderCell, s?.headerCell, s?.selectHeaderCell),
306
+ children: /* @__PURE__ */ l(
307
+ Ne,
212
308
  {
213
- className: d(
214
- n.headerCell,
215
- e.sortable && n.headerCellSortable,
216
- e.sticky && n.headerCellSticky,
217
- g?.headerCell
218
- ),
219
- style: {
220
- width: e.width,
221
- textAlign: e.align
222
- },
223
- onClick: e.sortable ? (t) => Y(e.key, t, e.defaultSortDirection ?? "asc") : void 0,
224
- "aria-sort": e.sortable ? L(e.key) === "asc" ? "ascending" : L(e.key) === "desc" ? "descending" : "none" : void 0,
225
- children: [
226
- e.header,
227
- e.sortable && /* @__PURE__ */ s(
228
- ae,
229
- {
230
- direction: L(e.key),
231
- sortIndex: te(e.key)
232
- }
233
- )
234
- ]
235
- },
236
- e.key
237
- )) }) }),
238
- /* @__PURE__ */ s("tbody", { children: W.length === 0 ? /* @__PURE__ */ s("tr", { className: n.emptyRow, children: /* @__PURE__ */ s("td", { className: d(n.emptyCell, g?.emptyCell), colSpan: o.length, children: F }) }) : W.map((e, t) => {
239
- const l = j ? String(e[j]) : t, N = typeof T == "function" ? T(e, t) : T, B = typeof $ == "function" ? $(e, t) : $;
240
- return /* @__PURE__ */ s(
241
- "tr",
309
+ "aria-label": "Select all",
310
+ checked: F,
311
+ indeterminate: Ee,
312
+ disabled: L.length === 0,
313
+ onChange: Pe
314
+ }
315
+ )
316
+ }
317
+ ),
318
+ j.map((e) => /* @__PURE__ */ v(
319
+ "th",
320
+ {
321
+ className: o(
322
+ n.headerCell,
323
+ e.sortable && n.headerCellSortable,
324
+ e.sticky && n.headerCellSticky,
325
+ s?.headerCell
326
+ ),
327
+ style: {
328
+ width: e.width,
329
+ textAlign: e.align
330
+ },
331
+ onClick: e.sortable ? (t) => qe(e.key, t, e.defaultSortDirection ?? "asc") : void 0,
332
+ "aria-sort": e.sortable ? ie(e.key) === "asc" ? "ascending" : ie(e.key) === "desc" ? "descending" : "none" : void 0,
333
+ children: [
334
+ e.header,
335
+ e.sortable && /* @__PURE__ */ l(
336
+ Ze,
242
337
  {
243
- className: d(n.row, g?.row, N),
244
- style: B,
245
- children: o.map((a) => {
246
- const f = e[a.key], I = typeof a.cellClassName == "function" ? a.cellClassName(f, e, t) : a.cellClassName, w = typeof a.cellStyle == "function" ? a.cellStyle(f, e, t) : a.cellStyle;
247
- return /* @__PURE__ */ s(
248
- "td",
249
- {
250
- className: d(
251
- n.cell,
252
- a.sticky && n.cellSticky,
253
- g?.cell,
254
- I
255
- ),
256
- style: { textAlign: a.align, ...w },
257
- children: a.render ? a.render(f, e, t) : f
258
- },
259
- a.key
260
- );
261
- })
262
- },
263
- l
264
- );
265
- }) })
266
- ]
267
- }
268
- ),
269
- m && /* @__PURE__ */ s(
270
- ie,
338
+ direction: ie(e.key),
339
+ sortIndex: _e(e.key)
340
+ }
341
+ )
342
+ ]
343
+ },
344
+ e.key
345
+ ))
346
+ ] }) }),
347
+ /* @__PURE__ */ l("tbody", { children: ye ? Array.from({ length: Math.max(1, Se) }, (e, t) => /* @__PURE__ */ v("tr", { className: o(n.row, n.loadingRow, s?.row, s?.loadingRow), "aria-hidden": "true", children: [
348
+ m && /* @__PURE__ */ l("td", { className: o(n.cell, n.selectCell, s?.cell) }),
349
+ j.map((r) => /* @__PURE__ */ l("td", { className: o(n.cell, s?.cell), children: /* @__PURE__ */ l(Qe, { variant: "text" }) }, r.key))
350
+ ] }, `loading-${t}`)) : D.length === 0 ? /* @__PURE__ */ l("tr", { className: n.emptyRow, children: /* @__PURE__ */ l("td", { className: o(n.emptyCell, s?.emptyCell), colSpan: je, children: Ce }) }) : D.map((e, t) => {
351
+ const r = K ? String(e[K]) : t, h = m ? x(e, t) : null, g = h !== null && V.has(h), C = typeof Z == "function" ? Z(e, t) : Z, b = typeof z == "function" ? z(e, t) : z;
352
+ return /* @__PURE__ */ v(
353
+ "tr",
354
+ {
355
+ className: o(
356
+ n.row,
357
+ N && n.rowClickable,
358
+ g && n.rowSelected,
359
+ s?.row,
360
+ N && s?.rowClickable,
361
+ g && s?.rowSelected,
362
+ C
363
+ ),
364
+ style: b,
365
+ tabIndex: N ? 0 : void 0,
366
+ onClick: N ? (a) => Re(e, t, a) : void 0,
367
+ onKeyDown: N ? (a) => $e(e, t, a) : void 0,
368
+ "aria-selected": m ? g : void 0,
369
+ children: [
370
+ m && /* @__PURE__ */ l("td", { className: o(n.cell, n.selectCell, s?.cell, s?.selectCell), children: /* @__PURE__ */ l(
371
+ Ne,
372
+ {
373
+ "aria-label": "Select row",
374
+ checked: g,
375
+ disabled: !X(e),
376
+ onChange: (a) => Ke(e, t, a)
377
+ }
378
+ ) }),
379
+ j.map((a) => {
380
+ const u = e[a.key], T = typeof a.cellClassName == "function" ? a.cellClassName(u, e, t) : a.cellClassName, w = typeof a.cellStyle == "function" ? a.cellStyle(u, e, t) : a.cellStyle;
381
+ return /* @__PURE__ */ l(
382
+ "td",
383
+ {
384
+ className: o(
385
+ n.cell,
386
+ a.sticky && n.cellSticky,
387
+ s?.cell,
388
+ T
389
+ ),
390
+ style: { textAlign: a.align, ...w },
391
+ children: a.render ? a.render(u, e, t) : u
392
+ },
393
+ a.key
394
+ );
395
+ })
396
+ ]
397
+ },
398
+ r
399
+ );
400
+ }) })
401
+ ]
402
+ }
403
+ ), Fe = { selectedKeys: d, selectedRows: Le, clear: pe };
404
+ return /* @__PURE__ */ v(
405
+ "div",
406
+ {
407
+ ref: ae,
408
+ className: o(
409
+ n.wrapper,
410
+ Me && n.scrollable,
411
+ Oe && n.dragging,
412
+ s?.wrapper
413
+ ),
414
+ onPointerDown: p ? We : void 0,
415
+ onPointerMove: p ? Xe : void 0,
416
+ onPointerUp: p ? ge : void 0,
417
+ onPointerCancel: p ? ge : void 0,
418
+ onContextMenu: p ? He : void 0,
419
+ children: [
420
+ Ve && /* @__PURE__ */ v("div", { className: o(n.bulkBar, s?.bulkBar), role: "region", "aria-label": "Selected rows", children: [
421
+ /* @__PURE__ */ l("span", { className: o(n.bulkLabel, s?.bulkLabel), children: de ? de(d.length) : `${d.length} selected` }),
422
+ /* @__PURE__ */ l("button", { type: "button", className: o(n.bulkClear, s?.bulkClear), onClick: pe, children: "Clear" }),
423
+ _ !== void 0 && /* @__PURE__ */ l("div", { className: o(n.bulkActions, s?.bulkActions), children: typeof _ == "function" ? _(Fe) : _ })
424
+ ] }),
425
+ $ !== void 0 && ($ || be.current) ? (
426
+ // Once a consumer has used `loading`, keep the wrapper so toggling it
427
+ // doesn't remount the table (focus, scroll position).
428
+ /* @__PURE__ */ l(Je, { loading: $ && !ye, delay: 150, backdrop: "dim", classes: { root: n.loaderWrap }, children: ve })
429
+ ) : ve,
430
+ A && /* @__PURE__ */ l(
431
+ ze,
271
432
  {
272
- ...m,
273
- totalRows: V,
274
- paginatorClasses: { paginator: g?.paginator, pageButton: g?.pageButton }
433
+ ...A,
434
+ totalRows: Ae,
435
+ paginatorClasses: { paginator: s?.paginator, pageButton: s?.pageButton }
275
436
  }
276
437
  )
277
438
  ]
278
439
  }
279
440
  );
280
441
  }
281
- const fe = se;
442
+ const ct = et;
282
443
  export {
283
- fe as Table
444
+ ct as Table
284
445
  };