@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.
- package/AGENTS.md +51 -7
- package/CHANGELOG.md +129 -0
- package/components/Accordion/Accordion.d.ts +94 -0
- package/components/Accordion/Accordion.js +180 -0
- package/components/Accordion/Accordion.module.scss.js +36 -0
- package/components/Accordion/index.d.ts +2 -0
- package/components/Alert/Alert.d.ts +29 -1
- package/components/Alert/Alert.js +44 -30
- package/components/Alert/Alert.module.scss.js +24 -16
- package/components/Alert/index.d.ts +1 -1
- package/components/Card/Card.d.ts +86 -0
- package/components/Card/Card.js +132 -0
- package/components/Card/Card.module.scss.js +60 -0
- package/components/Card/index.d.ts +2 -0
- package/components/Chip/Chip.d.ts +86 -0
- package/components/Chip/Chip.js +141 -0
- package/components/Chip/Chip.module.scss.js +59 -0
- package/components/Chip/index.d.ts +2 -0
- package/components/CodeBlock/CodeBlock.d.ts +78 -0
- package/components/CodeBlock/CodeBlock.js +120 -0
- package/components/CodeBlock/CodeBlock.module.scss.js +43 -0
- package/components/CodeBlock/index.d.ts +2 -0
- package/components/CommandPalette/CommandPalette.d.ts +141 -0
- package/components/CommandPalette/CommandPalette.js +397 -0
- package/components/CommandPalette/CommandPalette.module.scss.js +49 -0
- package/components/CommandPalette/index.d.ts +2 -0
- package/components/ConfirmDialog/ConfirmDialog.d.ts +119 -0
- package/components/ConfirmDialog/ConfirmDialog.js +201 -0
- package/components/ConfirmDialog/ConfirmDialog.module.scss.js +21 -0
- package/components/ConfirmDialog/index.d.ts +2 -0
- package/components/Drawer/Drawer.d.ts +1 -0
- package/components/Drawer/Drawer.js +35 -36
- package/components/Drawer/Drawer.module.scss.js +20 -18
- package/components/Dropdown/Dropdown.d.ts +47 -7
- package/components/Dropdown/Dropdown.js +174 -81
- package/components/Dropdown/Dropdown.module.scss.js +40 -22
- package/components/Dropdown/DropdownItem.d.ts +31 -2
- package/components/Dropdown/DropdownItem.js +54 -27
- package/components/Dropdown/DropdownLabel.d.ts +11 -0
- package/components/Dropdown/DropdownLabel.js +11 -0
- package/components/Dropdown/DropdownSeparator.d.ts +12 -0
- package/components/Dropdown/DropdownSeparator.js +11 -0
- package/components/Dropdown/dropdownContext.d.ts +6 -0
- package/components/Dropdown/dropdownContext.js +5 -0
- package/components/Dropdown/index.d.ts +8 -2
- package/components/Dropdown/useContextMenu.d.ts +32 -0
- package/components/Dropdown/useContextMenu.js +18 -0
- package/components/EmptyState/EmptyState.d.ts +53 -0
- package/components/EmptyState/EmptyState.js +55 -0
- package/components/EmptyState/EmptyState.module.scss.js +25 -0
- package/components/EmptyState/index.d.ts +2 -0
- package/components/Form/FormField.js +25 -24
- package/components/ImageViewer/ImageViewer.d.ts +105 -0
- package/components/ImageViewer/ImageViewer.js +201 -0
- package/components/ImageViewer/ImageViewer.module.scss.js +47 -0
- package/components/ImageViewer/index.d.ts +4 -0
- package/components/ImageViewer/useZoomPan.d.ts +94 -0
- package/components/ImageViewer/useZoomPan.js +141 -0
- package/components/Kbd/Kbd.d.ts +26 -0
- package/components/Kbd/Kbd.js +22 -0
- package/components/Kbd/Kbd.module.scss.js +17 -0
- package/components/Kbd/index.d.ts +2 -0
- package/components/KeyValueList/KeyValueList.d.ts +84 -0
- package/components/KeyValueList/KeyValueList.js +127 -0
- package/components/KeyValueList/KeyValueList.module.scss.js +43 -0
- package/components/KeyValueList/index.d.ts +2 -0
- package/components/Modal/Modal.d.ts +1 -0
- package/components/Modal/Modal.js +40 -41
- package/components/Modal/Modal.module.scss.js +18 -16
- package/components/PageHeader/PageHeader.d.ts +61 -0
- package/components/PageHeader/PageHeader.js +73 -0
- package/components/PageHeader/PageHeader.module.scss.js +43 -0
- package/components/PageHeader/index.d.ts +2 -0
- package/components/ProgressBar/ProgressBar.d.ts +74 -0
- package/components/ProgressBar/ProgressBar.js +90 -0
- package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
- package/components/ProgressBar/index.d.ts +2 -0
- package/components/RelativeTime/RelativeTime.d.ts +45 -0
- package/components/RelativeTime/RelativeTime.js +43 -0
- package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
- package/components/RelativeTime/index.d.ts +2 -0
- package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
- package/components/SegmentedControl/SegmentedControl.js +131 -0
- package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
- package/components/SegmentedControl/index.d.ts +2 -0
- package/components/SplitPane/SplitPane.d.ts +61 -0
- package/components/SplitPane/SplitPane.js +171 -0
- package/components/SplitPane/SplitPane.module.scss.js +25 -0
- package/components/SplitPane/index.d.ts +2 -0
- package/components/StatCard/StatCard.d.ts +105 -0
- package/components/StatCard/StatCard.js +127 -0
- package/components/StatCard/StatCard.module.scss.js +72 -0
- package/components/StatCard/index.d.ts +2 -0
- package/components/StatusDot/StatusDot.d.ts +33 -0
- package/components/StatusDot/StatusDot.js +39 -0
- package/components/StatusDot/StatusDot.module.scss.js +32 -0
- package/components/StatusDot/index.d.ts +2 -0
- package/components/Table/Table.d.ts +100 -2
- package/components/Table/Table.js +371 -210
- package/components/Table/Table.module.scss.js +68 -46
- package/components/Table/index.d.ts +1 -1
- package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
- package/components/ThemeToggle/ThemeToggle.js +97 -0
- package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
- package/components/ThemeToggle/index.d.ts +2 -0
- package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
- package/components/inputs/Checkbox/Checkbox.js +29 -28
- package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
- package/components/inputs/Input/Input.d.ts +33 -1
- package/components/inputs/Input/Input.js +94 -35
- package/components/inputs/Input/Input.module.scss.js +14 -12
- package/components/inputs/Radio/Radio.d.ts +5 -4
- package/components/inputs/Radio/Radio.js +55 -50
- package/components/inputs/Radio/Radio.module.scss.js +12 -10
- package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
- package/components/inputs/SearchInput/SearchInput.js +116 -0
- package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
- package/components/inputs/SearchInput/index.d.ts +2 -0
- package/components/inputs/Select/Select.d.ts +52 -0
- package/components/inputs/Select/Select.js +494 -385
- package/components/inputs/Select/Select.module.scss.js +34 -30
- package/components/inputs/Switch/Switch.d.ts +15 -0
- package/components/inputs/Switch/Switch.js +8 -0
- package/components/inputs/Switch/index.d.ts +2 -0
- package/hooks/useDebouncedValue.d.ts +15 -0
- package/hooks/useDebouncedValue.js +15 -0
- package/hooks/useElementSize.d.ts +20 -0
- package/hooks/useElementSize.js +23 -0
- package/hooks/useKeyboard.d.ts +49 -5
- package/hooks/useKeyboard.js +66 -16
- package/hooks/useMediaQuery.d.ts +14 -0
- package/hooks/useMediaQuery.js +16 -0
- package/hooks/useNow.d.ts +14 -0
- package/hooks/useNow.js +35 -0
- package/hooks/usePersistedState.d.ts +30 -0
- package/hooks/usePersistedState.js +96 -0
- package/hooks/useResizable.d.ts +66 -0
- package/hooks/useResizable.js +105 -0
- package/hooks/useTheme.d.ts +33 -0
- package/hooks/useTheme.js +27 -0
- package/index.css +1 -1
- package/index.d.ts +58 -4
- package/index.js +208 -132
- package/index.layered.css +1 -1
- package/llms.txt +619 -25
- package/manifest.json +1739 -91
- package/package.json +1 -1
- package/recipes/confirm-modal.tsx +65 -53
- package/recipes/floating-copy-button.tsx +32 -28
- package/utils/formatBytes.d.ts +21 -0
- package/utils/formatBytes.js +14 -0
- package/utils/index.d.ts +6 -0
- package/utils/themeScript.d.ts +17 -0
- package/utils/themeScript.js +9 -0
- package/utils/timeAgo.d.ts +33 -0
- package/utils/timeAgo.js +37 -0
|
@@ -1,85 +1,89 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
14
|
-
page:
|
|
15
|
-
pageSize:
|
|
16
|
-
totalRows:
|
|
17
|
-
pageSizeOptions:
|
|
18
|
-
onPageChange:
|
|
19
|
-
paginatorClasses:
|
|
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
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
for (let
|
|
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
|
-
|
|
27
|
-
for (let
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
32
|
-
}, [
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
|
|
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:
|
|
41
|
-
onChange: (
|
|
44
|
+
value: f,
|
|
45
|
+
onChange: (i) => P(1, Number(i.target.value)),
|
|
42
46
|
"aria-label": "Rows per page",
|
|
43
|
-
children:
|
|
44
|
-
|
|
47
|
+
children: I.map((i) => /* @__PURE__ */ v("option", { value: i, children: [
|
|
48
|
+
i,
|
|
45
49
|
" / page"
|
|
46
|
-
] },
|
|
50
|
+
] }, i))
|
|
47
51
|
}
|
|
48
52
|
)
|
|
49
53
|
] }),
|
|
50
|
-
/* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ v("div", { className: n.paginatorNav, children: [
|
|
55
|
+
/* @__PURE__ */ l(
|
|
52
56
|
"button",
|
|
53
57
|
{
|
|
54
58
|
type: "button",
|
|
55
|
-
className:
|
|
56
|
-
disabled:
|
|
57
|
-
onClick: () =>
|
|
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
|
-
|
|
63
|
-
(
|
|
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:
|
|
68
|
-
onClick: () =>
|
|
69
|
-
"aria-label": `Page ${
|
|
70
|
-
"aria-current":
|
|
71
|
-
children:
|
|
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
|
-
|
|
77
|
+
i
|
|
74
78
|
)
|
|
75
79
|
),
|
|
76
|
-
/* @__PURE__ */
|
|
80
|
+
/* @__PURE__ */ l(
|
|
77
81
|
"button",
|
|
78
82
|
{
|
|
79
83
|
type: "button",
|
|
80
|
-
className:
|
|
81
|
-
disabled:
|
|
82
|
-
onClick: () =>
|
|
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
|
|
91
|
-
data:
|
|
92
|
-
columns:
|
|
93
|
-
sortConfig:
|
|
94
|
-
onSort:
|
|
95
|
-
multiSort:
|
|
96
|
-
scrollable:
|
|
97
|
-
dragScroll:
|
|
98
|
-
striped:
|
|
99
|
-
hoverable:
|
|
100
|
-
compact:
|
|
101
|
-
className:
|
|
102
|
-
style:
|
|
103
|
-
rowKey:
|
|
104
|
-
rowClassName:
|
|
105
|
-
rowStyle:
|
|
106
|
-
emptyMessage:
|
|
107
|
-
pagination:
|
|
108
|
-
|
|
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
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
|
131
|
-
|
|
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
|
-
|
|
238
|
+
h ? fe(e, r) : ue(e, r);
|
|
135
239
|
},
|
|
136
240
|
[
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
241
|
+
q,
|
|
242
|
+
P,
|
|
243
|
+
S,
|
|
244
|
+
I,
|
|
245
|
+
ue,
|
|
246
|
+
fe
|
|
143
247
|
]
|
|
144
|
-
),
|
|
145
|
-
const t =
|
|
146
|
-
t && (
|
|
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
|
-
}, []),
|
|
155
|
-
const t =
|
|
156
|
-
if (!t || !
|
|
157
|
-
const
|
|
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
|
-
|
|
264
|
+
O.current = null;
|
|
161
265
|
return;
|
|
162
266
|
}
|
|
163
|
-
if (Math.abs(
|
|
164
|
-
t.dragging = !0,
|
|
267
|
+
if (Math.abs(h) < 5) return;
|
|
268
|
+
t.dragging = !0, me(!0);
|
|
165
269
|
try {
|
|
166
|
-
|
|
270
|
+
r.setPointerCapture(t.pointerId);
|
|
167
271
|
} catch {
|
|
168
272
|
}
|
|
169
273
|
}
|
|
170
|
-
|
|
171
|
-
}, []),
|
|
172
|
-
const t =
|
|
173
|
-
!t || e.pointerId !== t.pointerId || (
|
|
174
|
-
}, []),
|
|
175
|
-
(
|
|
176
|
-
}, []),
|
|
177
|
-
if (
|
|
178
|
-
const t =
|
|
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
|
-
|
|
182
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
n.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
192
|
-
|
|
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__ */
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
n.
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
-
...
|
|
273
|
-
totalRows:
|
|
274
|
-
paginatorClasses: { paginator:
|
|
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
|
|
442
|
+
const ct = et;
|
|
282
443
|
export {
|
|
283
|
-
|
|
444
|
+
ct as Table
|
|
284
445
|
};
|