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