@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.
- package/AGENTS.md +51 -7
- package/CHANGELOG.md +162 -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 +140 -17
- package/components/Table/Table.js +382 -210
- package/components/Table/Table.module.scss.js +68 -46
- package/components/Table/index.d.ts +1 -1
- package/components/Table/useTableSort.d.ts +1 -1
- package/components/ThemeToggle/ThemeToggle.d.ts +40 -0
- package/components/ThemeToggle/ThemeToggle.js +98 -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 +99 -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 +25 -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 +620 -26
- package/manifest.json +1795 -99
- 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 +19 -0
- package/utils/themeScript.js +9 -0
- package/utils/timeAgo.d.ts +33 -0
- package/utils/timeAgo.js +37 -0
|
@@ -1,85 +1,95 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
14
|
-
page:
|
|
15
|
-
pageSize:
|
|
16
|
-
totalRows:
|
|
17
|
-
pageSizeOptions:
|
|
18
|
-
onPageChange:
|
|
19
|
-
paginatorClasses:
|
|
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
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
for (let
|
|
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
|
-
|
|
27
|
-
for (let
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
32
|
-
}, [
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
|
|
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:
|
|
41
|
-
onChange: (
|
|
50
|
+
value: u,
|
|
51
|
+
onChange: (i) => L(1, Number(i.target.value)),
|
|
42
52
|
"aria-label": "Rows per page",
|
|
43
|
-
children:
|
|
44
|
-
|
|
53
|
+
children: D.map((i) => /* @__PURE__ */ v("option", { value: i, children: [
|
|
54
|
+
i,
|
|
45
55
|
" / page"
|
|
46
|
-
] },
|
|
56
|
+
] }, i))
|
|
47
57
|
}
|
|
48
58
|
)
|
|
49
59
|
] }),
|
|
50
|
-
/* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ v("div", { className: n.paginatorNav, children: [
|
|
61
|
+
/* @__PURE__ */ a(
|
|
52
62
|
"button",
|
|
53
63
|
{
|
|
54
64
|
type: "button",
|
|
55
|
-
className:
|
|
56
|
-
disabled:
|
|
57
|
-
onClick: () =>
|
|
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
|
-
|
|
63
|
-
(
|
|
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:
|
|
68
|
-
onClick: () =>
|
|
69
|
-
"aria-label": `Page ${
|
|
70
|
-
"aria-current":
|
|
71
|
-
children:
|
|
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
|
-
|
|
83
|
+
i
|
|
74
84
|
)
|
|
75
85
|
),
|
|
76
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ a(
|
|
77
87
|
"button",
|
|
78
88
|
{
|
|
79
89
|
type: "button",
|
|
80
|
-
className:
|
|
81
|
-
disabled:
|
|
82
|
-
onClick: () =>
|
|
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
|
|
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
|
-
|
|
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
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
|
131
|
-
|
|
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
|
-
|
|
244
|
+
f ? pe(e, r) : he(e, r);
|
|
135
245
|
},
|
|
136
246
|
[
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
247
|
+
W,
|
|
248
|
+
L,
|
|
249
|
+
I,
|
|
250
|
+
D,
|
|
251
|
+
he,
|
|
252
|
+
pe
|
|
143
253
|
]
|
|
144
|
-
),
|
|
145
|
-
const t =
|
|
146
|
-
t && (
|
|
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
|
-
}, []),
|
|
155
|
-
const t =
|
|
156
|
-
if (!t || !
|
|
157
|
-
const
|
|
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
|
-
|
|
270
|
+
X.current = null;
|
|
161
271
|
return;
|
|
162
272
|
}
|
|
163
|
-
if (Math.abs(
|
|
164
|
-
t.dragging = !0,
|
|
273
|
+
if (Math.abs(f) < 5) return;
|
|
274
|
+
t.dragging = !0, be(!0);
|
|
165
275
|
try {
|
|
166
|
-
|
|
276
|
+
r.setPointerCapture(t.pointerId);
|
|
167
277
|
} catch {
|
|
168
278
|
}
|
|
169
279
|
}
|
|
170
|
-
|
|
171
|
-
}, []),
|
|
172
|
-
const t =
|
|
173
|
-
!t || e.pointerId !== t.pointerId || (
|
|
174
|
-
}, []),
|
|
175
|
-
(
|
|
176
|
-
}, []),
|
|
177
|
-
if (
|
|
178
|
-
const t =
|
|
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
|
-
|
|
182
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
n.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
192
|
-
|
|
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__ */
|
|
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",
|
|
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
|
-
|
|
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",
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
...
|
|
273
|
-
totalRows:
|
|
274
|
-
paginatorClasses: { paginator:
|
|
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
|
|
453
|
+
const ut = nt;
|
|
282
454
|
export {
|
|
283
|
-
|
|
455
|
+
ut as Table
|
|
284
456
|
};
|