@overdoser/react-toolkit 0.20.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 +1 -1
- package/CHANGELOG.md +14 -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 +1 -1
- package/components/Table/Table.js +381 -451
- package/components/Table/Table.module.js +42 -0
- 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.js +122 -98
- 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 -94
- package/hooks/usePortalPosition.js +25 -19
- package/hooks/useResizable.js +106 -104
- package/hooks/useTheme.js +28 -23
- package/index.css +2 -1
- package/index.js +97 -215
- package/index.layered.css +2 -3
- package/llms.txt +3 -0
- package/manifest.json +8 -0
- package/package.json +1 -1
- package/utils/formatBytes.js +29 -13
- 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
package/hooks/useFocusTrap.js
CHANGED
|
@@ -1,39 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
f(() => {
|
|
28
|
-
if (!u || !t.current)
|
|
29
|
-
return;
|
|
30
|
-
o.current = document.activeElement;
|
|
31
|
-
const e = t.current.querySelectorAll(s);
|
|
32
|
-
return e.length > 0 && e[0].focus(), document.addEventListener("keydown", r), () => {
|
|
33
|
-
document.removeEventListener("keydown", r), o.current instanceof HTMLElement && o.current.focus();
|
|
34
|
-
};
|
|
35
|
-
}, [u, t, r]);
|
|
1
|
+
import { useCallback as e, useEffect as t, useRef as n } from "react";
|
|
2
|
+
// src/hooks/useFocusTrap.ts
|
|
3
|
+
var r = "input:not([disabled]):not([type=\"hidden\"]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex=\"-1\"])";
|
|
4
|
+
function i(i, a) {
|
|
5
|
+
let o = n(null), s = e((e) => {
|
|
6
|
+
if (e.key !== "Tab" || !i.current) return;
|
|
7
|
+
let t = Array.from(i.current.querySelectorAll(r));
|
|
8
|
+
if (t.length === 0) {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
let n = t[0], a = t[t.length - 1];
|
|
13
|
+
e.shiftKey ? document.activeElement === n && (e.preventDefault(), a.focus()) : document.activeElement === a && (e.preventDefault(), n.focus());
|
|
14
|
+
}, [i]);
|
|
15
|
+
t(() => {
|
|
16
|
+
if (!a || !i.current) return;
|
|
17
|
+
o.current = document.activeElement;
|
|
18
|
+
let e = i.current.querySelectorAll(r);
|
|
19
|
+
return e.length > 0 && e[0].focus(), document.addEventListener("keydown", s), () => {
|
|
20
|
+
document.removeEventListener("keydown", s), o.current instanceof HTMLElement && o.current.focus();
|
|
21
|
+
};
|
|
22
|
+
}, [
|
|
23
|
+
a,
|
|
24
|
+
i,
|
|
25
|
+
s
|
|
26
|
+
]);
|
|
36
27
|
}
|
|
37
|
-
export {
|
|
38
|
-
m as useFocusTrap
|
|
39
|
-
};
|
|
28
|
+
export { i as useFocusTrap };
|
package/hooks/useKeyboard.js
CHANGED
|
@@ -1,69 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { useEffect as e, useRef as t } from "react";
|
|
2
|
+
// src/hooks/useKeyboard.ts
|
|
3
|
+
var n = () => typeof navigator < "u" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform ?? ""), r = {
|
|
4
|
+
esc: "Escape",
|
|
5
|
+
escape: "Escape",
|
|
6
|
+
enter: "Enter",
|
|
7
|
+
return: "Enter",
|
|
8
|
+
space: " ",
|
|
9
|
+
tab: "Tab",
|
|
10
|
+
backspace: "Backspace",
|
|
11
|
+
delete: "Delete",
|
|
12
|
+
del: "Delete",
|
|
13
|
+
up: "ArrowUp",
|
|
14
|
+
down: "ArrowDown",
|
|
15
|
+
left: "ArrowLeft",
|
|
16
|
+
right: "ArrowRight",
|
|
17
|
+
arrowup: "ArrowUp",
|
|
18
|
+
arrowdown: "ArrowDown",
|
|
19
|
+
arrowleft: "ArrowLeft",
|
|
20
|
+
arrowright: "ArrowRight",
|
|
21
|
+
home: "Home",
|
|
22
|
+
end: "End",
|
|
23
|
+
pageup: "PageUp",
|
|
24
|
+
pagedown: "PageDown",
|
|
25
|
+
plus: "+"
|
|
25
26
|
};
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
function i(e) {
|
|
28
|
+
let t = e.split("+").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
29
|
+
(t.length === 0 || e.endsWith("+")) && t.push("+");
|
|
30
|
+
let i = {
|
|
31
|
+
key: "",
|
|
32
|
+
ctrl: !1,
|
|
33
|
+
alt: !1,
|
|
34
|
+
shift: !1,
|
|
35
|
+
meta: !1,
|
|
36
|
+
hasModifier: !1
|
|
37
|
+
};
|
|
38
|
+
for (let e of t) {
|
|
39
|
+
let t = e.toLowerCase();
|
|
40
|
+
t === "mod" ? n() ? i.meta = !0 : i.ctrl = !0 : t === "ctrl" || t === "control" ? i.ctrl = !0 : t === "alt" || t === "option" ? i.alt = !0 : t === "shift" ? i.shift = !0 : t === "meta" || t === "cmd" || t === "command" || t === "super" || t === "win" ? i.meta = !0 : i.key = r[t] ?? (e.length === 1 ? e.toLowerCase() : e);
|
|
41
|
+
}
|
|
42
|
+
return i.hasModifier = i.ctrl || i.alt || i.meta, i;
|
|
35
43
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
44
|
+
function a(e, t) {
|
|
45
|
+
return (t.key.length === 1 ? t.key.toLowerCase() : t.key) === e.key ? e.hasModifier || e.shift ? t.ctrlKey === e.ctrl && t.altKey === e.alt && t.metaKey === e.meta && t.shiftKey === e.shift : !t.ctrlKey && !t.altKey && !t.metaKey : !1;
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
var o = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])";
|
|
48
|
+
function s(e) {
|
|
49
|
+
let t = e.target;
|
|
50
|
+
return !t || typeof t.closest != "function" ? !1 : t.isContentEditable ? !0 : t.closest(o) !== null;
|
|
43
51
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
function c(n, r = !0) {
|
|
53
|
+
let { active: o = !0, ignoreEditable: c = !0, preventDefault: l, target: u = null } = typeof r == "boolean" ? { active: r } : r, d = t(n);
|
|
54
|
+
d.current = n;
|
|
55
|
+
let f = t({
|
|
56
|
+
ignoreEditable: c,
|
|
57
|
+
preventDefault: l
|
|
58
|
+
});
|
|
59
|
+
f.current = {
|
|
60
|
+
ignoreEditable: c,
|
|
61
|
+
preventDefault: l
|
|
62
|
+
}, e(() => {
|
|
63
|
+
if (!o) return;
|
|
64
|
+
let e = u ? u.current : document;
|
|
65
|
+
if (!e) return;
|
|
66
|
+
let t = (e) => {
|
|
67
|
+
let t = e, n = d.current, r = f.current.ignoreEditable && s(t);
|
|
68
|
+
for (let e of Object.keys(n)) {
|
|
69
|
+
let o = i(e);
|
|
70
|
+
if (!a(o, t)) continue;
|
|
71
|
+
let s = o.key.length === 1 && !o.hasModifier;
|
|
72
|
+
if (!(r && s)) {
|
|
73
|
+
(f.current.preventDefault ?? o.hasModifier) && t.preventDefault(), n[e](t);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return e.addEventListener("keydown", t), () => e.removeEventListener("keydown", t);
|
|
79
|
+
}, [o, u]);
|
|
65
80
|
}
|
|
66
|
-
export {
|
|
67
|
-
v as parseChord,
|
|
68
|
-
C as useKeyboard
|
|
69
|
-
};
|
|
81
|
+
export { i as parseChord, c as useKeyboard };
|
package/hooks/useMediaQuery.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
[n]
|
|
11
|
-
), c = o(() => typeof window > "u" || typeof window.matchMedia != "function" ? t : window.matchMedia(n).matches, [n, t]);
|
|
12
|
-
return a(d, c, () => t);
|
|
1
|
+
import { useCallback as e, useSyncExternalStore as t } from "react";
|
|
2
|
+
// src/hooks/useMediaQuery.ts
|
|
3
|
+
function n(n, r = !1) {
|
|
4
|
+
let i = e((e) => {
|
|
5
|
+
if (typeof window > "u" || typeof window.matchMedia != "function") return () => {};
|
|
6
|
+
let t = window.matchMedia(n);
|
|
7
|
+
return t.addEventListener("change", e), () => t.removeEventListener("change", e);
|
|
8
|
+
}, [n]), a = e(() => typeof window > "u" || typeof window.matchMedia != "function" ? r : window.matchMedia(n).matches, [n, r]);
|
|
9
|
+
return t(i, a, () => r);
|
|
13
10
|
}
|
|
14
|
-
export {
|
|
15
|
-
r as useMediaQuery
|
|
16
|
-
};
|
|
11
|
+
export { n as useMediaQuery };
|
package/hooks/useNow.js
CHANGED
|
@@ -1,35 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { useCallback as e, useRef as t, useSyncExternalStore as n } from "react";
|
|
2
|
+
// src/hooks/useNow.ts
|
|
3
|
+
var r = /* @__PURE__ */ new Map();
|
|
4
|
+
function i(e, t) {
|
|
5
|
+
let n = r.get(e);
|
|
6
|
+
if (!n) {
|
|
7
|
+
let t = {
|
|
8
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
9
|
+
now: Date.now(),
|
|
10
|
+
timer: setInterval(() => {
|
|
11
|
+
t.now = Date.now(), t.listeners.forEach((e) => e());
|
|
12
|
+
}, e)
|
|
13
|
+
};
|
|
14
|
+
r.set(e, t), n = t;
|
|
15
|
+
}
|
|
16
|
+
return n.listeners.add(t), () => {
|
|
17
|
+
n.listeners.delete(t), n.listeners.size === 0 && (clearInterval(n.timer), r.delete(e));
|
|
18
|
+
};
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
return n.current;
|
|
30
|
-
}, [e, t]);
|
|
31
|
-
return i(c, l, l);
|
|
20
|
+
function a(a = 1e3, o = !0) {
|
|
21
|
+
let s = Math.max(16, Math.floor(a)), c = t(Date.now()), l = e((e) => o ? i(s, e) : () => {}, [s, o]), u = e(() => {
|
|
22
|
+
if (o) {
|
|
23
|
+
let e = r.get(s);
|
|
24
|
+
e && (c.current = e.now);
|
|
25
|
+
}
|
|
26
|
+
return c.current;
|
|
27
|
+
}, [s, o]);
|
|
28
|
+
return n(l, u, u);
|
|
32
29
|
}
|
|
33
|
-
export {
|
|
34
|
-
d as useNow
|
|
35
|
-
};
|
|
30
|
+
export { a as useNow };
|
|
@@ -1,99 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { useCallback as e, useMemo as t, useSyncExternalStore as n } from "react";
|
|
2
|
+
// src/hooks/usePersistedState.ts
|
|
3
|
+
var r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
4
|
+
function a(e, t) {
|
|
5
|
+
return `${e}:${t}`;
|
|
5
6
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
function o(e) {
|
|
8
|
+
try {
|
|
9
|
+
return typeof window > "u" ? null : e === "local" ? window.localStorage : window.sessionStorage;
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
14
|
+
function s(e, t) {
|
|
15
|
+
r.get(a(e, t))?.forEach((e) => e());
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const s = e.storageArea === window.sessionStorage ? "session" : "local";
|
|
24
|
-
v(s, e.key);
|
|
25
|
-
}));
|
|
17
|
+
var c = !1;
|
|
18
|
+
function l() {
|
|
19
|
+
c || typeof window > "u" || (c = !0, window.addEventListener("storage", (e) => {
|
|
20
|
+
e.key === null ? r.forEach((e) => e.forEach((e) => e())) : s(e.storageArea === window.sessionStorage ? "session" : "local", e.key);
|
|
21
|
+
}));
|
|
26
22
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
23
|
+
function u(c, u, d = {}) {
|
|
24
|
+
let { storage: f = "local", serialize: p = JSON.stringify, deserialize: m = JSON.parse, sync: h = !0 } = d, g = a(f, c), _ = t(() => typeof u == "function" ? u() : u, []), v = e(() => {
|
|
25
|
+
let e = o(f), t = null;
|
|
26
|
+
try {
|
|
27
|
+
t = e ? e.getItem(c) : null;
|
|
28
|
+
} catch {
|
|
29
|
+
t = null;
|
|
30
|
+
}
|
|
31
|
+
if (t === null) {
|
|
32
|
+
let e = i.get(g);
|
|
33
|
+
return e && e.raw === null ? e.value : _;
|
|
34
|
+
}
|
|
35
|
+
let n = i.get(g);
|
|
36
|
+
if (n && n.raw === t) return n.value;
|
|
37
|
+
let r;
|
|
38
|
+
try {
|
|
39
|
+
r = m(t);
|
|
40
|
+
} catch {
|
|
41
|
+
return _;
|
|
42
|
+
}
|
|
43
|
+
return i.set(g, {
|
|
44
|
+
raw: t,
|
|
45
|
+
value: r
|
|
46
|
+
}), r;
|
|
47
|
+
}, [
|
|
48
|
+
f,
|
|
49
|
+
c,
|
|
50
|
+
g,
|
|
51
|
+
_,
|
|
52
|
+
m
|
|
53
|
+
]), y = e((e) => {
|
|
54
|
+
let t = r.get(g);
|
|
55
|
+
return t || (t = /* @__PURE__ */ new Set(), r.set(g, t)), t.add(e), h && l(), () => {
|
|
56
|
+
t.delete(e), t.size === 0 && r.delete(g);
|
|
57
|
+
};
|
|
58
|
+
}, [g, h]);
|
|
59
|
+
return [
|
|
60
|
+
n(y, v, () => _),
|
|
61
|
+
e((e) => {
|
|
62
|
+
let t = v(), n = typeof e == "function" ? e(t) : e, r = null;
|
|
63
|
+
try {
|
|
64
|
+
r = p(n);
|
|
65
|
+
} catch {
|
|
66
|
+
r = null;
|
|
67
|
+
}
|
|
68
|
+
let a = o(f), l = null;
|
|
69
|
+
if (a) {
|
|
70
|
+
try {
|
|
71
|
+
r !== null && a.setItem(c, r);
|
|
72
|
+
} catch {}
|
|
73
|
+
try {
|
|
74
|
+
l = a.getItem(c);
|
|
75
|
+
} catch {
|
|
76
|
+
l = null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
i.set(g, {
|
|
80
|
+
raw: l,
|
|
81
|
+
value: n
|
|
82
|
+
}), s(f, c);
|
|
83
|
+
}, [
|
|
84
|
+
v,
|
|
85
|
+
p,
|
|
86
|
+
f,
|
|
87
|
+
c,
|
|
88
|
+
g
|
|
89
|
+
]),
|
|
90
|
+
e(() => {
|
|
91
|
+
let e = o(f);
|
|
92
|
+
try {
|
|
93
|
+
e?.removeItem(c);
|
|
94
|
+
} catch {}
|
|
95
|
+
i.delete(g), s(f, c);
|
|
96
|
+
}, [
|
|
97
|
+
f,
|
|
98
|
+
c,
|
|
99
|
+
g
|
|
100
|
+
])
|
|
101
|
+
];
|
|
96
102
|
}
|
|
97
|
-
export {
|
|
98
|
-
$ as usePersistedState
|
|
99
|
-
};
|
|
103
|
+
export { u as usePersistedState };
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { useLayoutEffect as e, useState as t } from "react";
|
|
2
|
+
// src/hooks/usePortalPosition.ts
|
|
3
|
+
function n(n, r) {
|
|
4
|
+
let [i, a] = t({
|
|
5
|
+
top: 0,
|
|
6
|
+
left: 0,
|
|
7
|
+
width: 0
|
|
8
|
+
});
|
|
9
|
+
return e(() => {
|
|
10
|
+
if (!r) return;
|
|
11
|
+
let e = () => {
|
|
12
|
+
let e = n.current;
|
|
13
|
+
if (!e) return;
|
|
14
|
+
let t = e.getBoundingClientRect();
|
|
15
|
+
a({
|
|
16
|
+
top: t.bottom,
|
|
17
|
+
left: t.left,
|
|
18
|
+
width: t.width
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
if (e(), typeof window < "u") return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
22
|
+
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
23
|
+
};
|
|
24
|
+
}, [r, n]), i;
|
|
17
25
|
}
|
|
18
|
-
export {
|
|
19
|
-
f as usePortalPosition
|
|
20
|
-
};
|
|
26
|
+
export { n as usePortalPosition };
|