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