@overdoser/react-toolkit 0.20.0 → 0.22.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 -1
- package/CHANGELOG.md +41 -0
- package/components/Accordion/Accordion.js +160 -177
- package/components/Accordion/Accordion.module.scss.js +19 -35
- package/components/ActionButton/ActionButton.js +155 -209
- package/components/ActionButton/ActionButton.module.scss.js +24 -46
- package/components/ActionButton/CopyButton.js +52 -64
- package/components/Alert/Alert.js +93 -96
- package/components/Alert/Alert.module.scss.js +17 -32
- package/components/Avatar/Avatar.js +44 -55
- package/components/Avatar/Avatar.module.scss.js +22 -42
- package/components/Badge/Badge.js +15 -37
- package/components/Badge/Badge.module.scss.js +16 -30
- package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/components/Breadcrumbs/Breadcrumbs.js +52 -48
- package/components/Breadcrumbs/Breadcrumbs.module.scss.js +9 -16
- package/components/Button/Button.js +35 -57
- package/components/Button/Button.module.scss.js +24 -46
- package/components/Card/Card.js +94 -131
- package/components/Card/Card.module.scss.js +34 -59
- 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.scss.js +31 -60
- 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 +45 -40
- 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.scss.js +31 -58
- package/components/CodeBlock/CodeBlock.js +111 -119
- package/components/CodeBlock/CodeBlock.module.scss.js +22 -42
- package/components/CommandPalette/CommandPalette.js +387 -392
- package/components/CommandPalette/CommandPalette.module.scss.js +27 -48
- package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
- package/components/ConfirmDialog/ConfirmDialog.js +184 -199
- package/components/ConfirmDialog/ConfirmDialog.module.scss.js +11 -20
- package/components/Divider/Divider.js +25 -36
- package/components/Divider/Divider.module.scss.js +16 -30
- package/components/Draggable/Draggable.d.ts +1 -1
- package/components/Draggable/Draggable.js +157 -164
- package/components/Draggable/Draggable.module.scss.js +9 -16
- package/components/Drawer/Drawer.js +104 -126
- package/components/Drawer/Drawer.module.scss.js +65 -118
- package/components/Dropdown/Dropdown.js +175 -234
- package/components/Dropdown/Dropdown.module.scss.js +28 -52
- package/components/Dropdown/DropdownItem.js +55 -58
- package/components/Dropdown/DropdownLabel.js +14 -11
- package/components/Dropdown/DropdownSeparator.js +13 -11
- 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.scss.js +11 -20
- package/components/EmptyState/EmptyState.js +57 -54
- package/components/EmptyState/EmptyState.module.scss.js +13 -24
- package/components/Form/Form.d.ts +1 -1
- package/components/Form/Form.js +31 -34
- package/components/Form/Form.module.scss.js +15 -28
- 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.scss.js +25 -46
- package/components/ImageViewer/useZoomPan.js +206 -137
- package/components/Kbd/Kbd.js +24 -21
- package/components/Kbd/Kbd.module.scss.js +9 -16
- package/components/KeyValueList/KeyValueList.js +119 -123
- package/components/KeyValueList/KeyValueList.module.scss.js +22 -42
- package/components/Link/Link.js +45 -59
- package/components/Link/Link.module.scss.js +9 -15
- package/components/List/List.js +22 -46
- package/components/List/List.module.scss.js +11 -20
- package/components/Loader/Loader.js +152 -182
- package/components/Loader/Loader.module.scss.js +39 -69
- package/components/Modal/Modal.js +93 -105
- package/components/Modal/Modal.module.scss.js +17 -32
- package/components/PageHeader/PageHeader.js +79 -73
- package/components/PageHeader/PageHeader.module.scss.js +22 -42
- package/components/Pagination/Pagination.js +62 -83
- package/components/Pagination/Pagination.module.scss.js +12 -22
- package/components/Pagination/paginationRange.js +15 -22
- package/components/Popover/Popover.js +110 -134
- package/components/Popover/Popover.module.scss.js +11 -20
- package/components/ProgressBar/ProgressBar.d.ts +15 -1
- package/components/ProgressBar/ProgressBar.js +56 -89
- package/components/ProgressBar/ProgressBar.module.scss.js +28 -50
- package/components/RelativeTime/RelativeTime.js +36 -43
- package/components/RelativeTime/RelativeTime.module.scss.js +3 -7
- package/components/SegmentedControl/SegmentedControl.js +93 -129
- package/components/SegmentedControl/SegmentedControl.module.scss.js +20 -38
- package/components/Skeleton/Skeleton.js +36 -50
- package/components/Skeleton/Skeleton.module.scss.js +14 -24
- package/components/Spinner/Spinner.js +25 -25
- package/components/Spinner/Spinner.module.scss.js +11 -19
- package/components/SplitButton/SplitButton.js +149 -196
- package/components/SplitButton/SplitButton.module.scss.js +30 -56
- package/components/SplitPane/SplitPane.js +134 -170
- package/components/SplitPane/SplitPane.module.scss.js +13 -24
- package/components/StatCard/StatCard.js +132 -125
- package/components/StatCard/StatCard.module.scss.js +41 -71
- package/components/StatusDot/StatusDot.js +28 -39
- package/components/StatusDot/StatusDot.module.scss.js +17 -31
- package/components/Table/Table.d.ts +1 -1
- package/components/Table/Table.js +381 -451
- package/components/Table/Table.module.scss.js +41 -80
- package/components/Table/useTableSort.js +51 -42
- package/components/Tabs/Tabs.js +109 -161
- package/components/Tabs/Tabs.module.scss.js +27 -52
- package/components/ThemeToggle/ThemeToggle.js +122 -98
- package/components/ThemeToggle/ThemeToggle.module.scss.js +12 -22
- package/components/Timeline/GanttTimeline.js +357 -318
- package/components/Timeline/GanttTimeline.module.scss.js +28 -54
- package/components/Timeline/HistoryTimeline.js +486 -450
- package/components/Timeline/HistoryTimeline.module.scss.js +30 -58
- package/components/Timeline/Timeline.module.scss.js +75 -140
- 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 +244 -177
- package/components/Timeline/TraceTimeline.js +823 -783
- package/components/Timeline/TraceTimeline.module.scss.js +97 -188
- 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.scss.js +28 -54
- package/components/Toast/Toast.d.ts +1 -1
- package/components/Toast/Toast.js +128 -128
- package/components/Toast/Toast.module.scss.js +36 -61
- package/components/Toast/toastStore.js +58 -62
- package/components/ToggleIconButton/ToggleIconButton.js +36 -58
- package/components/ToggleIconButton/ToggleIconButton.module.scss.js +14 -26
- package/components/Tooltip/Tooltip.d.ts +1 -1
- package/components/Tooltip/Tooltip.js +76 -85
- package/components/Tooltip/Tooltip.module.scss.js +16 -29
- package/components/Typography/Typography.js +10 -35
- package/components/Typography/Typography.module.scss.js +29 -52
- package/components/inputs/Checkbox/Checkbox.js +27 -51
- package/components/inputs/Checkbox/Checkbox.module.scss.js +9 -16
- package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
- package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +16 -30
- package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
- package/components/inputs/DatePicker/CalendarPanel.js +263 -286
- package/components/inputs/DatePicker/CalendarPanel.module.scss.js +22 -40
- package/components/inputs/DatePicker/DatePicker.js +115 -142
- package/components/inputs/DatePicker/DatePicker.module.scss.js +13 -24
- package/components/inputs/DatePicker/dateUtils.js +32 -41
- package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
- package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +19 -36
- 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.scss.js +14 -26
- package/components/inputs/NumberInput/NumberInput.js +112 -132
- package/components/inputs/NumberInput/NumberInput.module.scss.js +13 -24
- package/components/inputs/Radio/Radio.js +50 -73
- package/components/inputs/Radio/Radio.module.scss.js +8 -14
- package/components/inputs/SearchInput/SearchInput.js +98 -115
- package/components/inputs/SearchInput/SearchInput.module.scss.js +7 -12
- package/components/inputs/Select/Select.d.ts +55 -3
- package/components/inputs/Select/Select.js +696 -682
- package/components/inputs/Select/Select.module.scss.js +49 -72
- package/components/inputs/Slider/Slider.js +97 -128
- package/components/inputs/Slider/Slider.module.scss.js +8 -14
- package/components/inputs/Switch/Switch.js +11 -8
- package/components/inputs/Textarea/Textarea.js +42 -58
- package/components/inputs/Textarea/Textarea.module.scss.js +13 -24
- 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.d.ts +2 -1
- package/hooks/usePortalPosition.js +28 -19
- package/hooks/useResizable.js +106 -104
- package/hooks/useTheme.js +28 -23
- package/index.css +2 -1
- package/index.js +96 -214
- package/index.layered.css +2 -3
- package/llms.txt +28 -4
- package/manifest.json +41 -4
- package/package.json +1 -1
- package/utils/formatBytes.js +29 -13
- package/utils/themeScript.js +6 -8
- package/utils/timeAgo.js +59 -32
|
@@ -1,397 +1,392 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { forwardRef as e, useCallback as t, useEffect as n, useId as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import { createPortal as s } from "react-dom";
|
|
3
|
+
import c from "clsx";
|
|
4
|
+
import l from "./CommandPalette.module.scss.js";
|
|
5
|
+
import { useFocusTrap as ee } from "../../hooks/useFocusTrap.js";
|
|
6
|
+
import { EscapeLayerProvider as te, useEscapeLayer as ne } from "../../hooks/useEscapeLayer.js";
|
|
7
|
+
import { useKeyboard as re } from "../../hooks/useKeyboard.js";
|
|
8
|
+
import { Kbd as u } from "../Kbd/Kbd.js";
|
|
9
|
+
import { Spinner as d } from "../Spinner/Spinner.js";
|
|
10
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
11
|
+
// src/components/CommandPalette/CommandPalette.tsx
|
|
12
|
+
function h(e, t) {
|
|
13
|
+
let n = t.trim().toLowerCase();
|
|
14
|
+
if (!n) return [];
|
|
15
|
+
let r = e.toLowerCase(), i = r.indexOf(n);
|
|
16
|
+
if (i >= 0) return Array.from({ length: n.length }, (e, t) => i + t);
|
|
17
|
+
let a = [], o = 0;
|
|
18
|
+
for (let e of n) {
|
|
19
|
+
if (e === " ") continue;
|
|
20
|
+
let t = r.indexOf(e, o);
|
|
21
|
+
if (t < 0) return null;
|
|
22
|
+
a.push(t), o = t + 1;
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return Math.max(1, 50 - w - p);
|
|
26
|
+
function g(e, t) {
|
|
27
|
+
let n = h(e, t);
|
|
28
|
+
if (n === null) return !1;
|
|
29
|
+
if (n.length === 0) return 1;
|
|
30
|
+
let r = e.toLowerCase(), i = t.trim().toLowerCase(), a = n[0];
|
|
31
|
+
if (r.indexOf(i) === a) return 100 + (a === 0 || /\s/.test(r[a - 1]) ? 20 : 0) - Math.min(a, 30);
|
|
32
|
+
let o = n[n.length - 1] - n[0] - (n.length - 1);
|
|
33
|
+
return Math.max(1, 50 - o - a);
|
|
35
34
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
function _(e, t) {
|
|
36
|
+
if (!t.trim()) return 1;
|
|
37
|
+
let n = !1;
|
|
38
|
+
typeof e.label == "string" && (n = g(e.label, t));
|
|
39
|
+
for (let r of e.keywords ?? []) {
|
|
40
|
+
let e = g(r, t);
|
|
41
|
+
e !== !1 && (n = Math.max(n === !1 ? 0 : n, e - 10));
|
|
42
|
+
}
|
|
43
|
+
return n;
|
|
45
44
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
function ie(e, t, n, r) {
|
|
46
|
+
if (!n || typeof e != "string" || !t.trim()) return e;
|
|
47
|
+
let i = h(e, t);
|
|
48
|
+
if (!i || i.length === 0) return e;
|
|
49
|
+
let a = new Set(i), o = [], s = "", c = !1, l = () => {
|
|
50
|
+
s &&= (o.push(c ? /* @__PURE__ */ p("mark", {
|
|
51
|
+
className: r,
|
|
52
|
+
children: s
|
|
53
|
+
}, o.length) : s), "");
|
|
54
|
+
};
|
|
55
|
+
for (let t = 0; t < e.length; t++) {
|
|
56
|
+
let n = a.has(t);
|
|
57
|
+
n !== c && (l(), c = n), s += e[t];
|
|
58
|
+
}
|
|
59
|
+
return l(), o;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
function v(e = !1) {
|
|
62
|
+
let [n, r] = o(e), a = t(() => r((e) => !e), []);
|
|
63
|
+
return i(() => ({
|
|
64
|
+
open: n,
|
|
65
|
+
setOpen: r,
|
|
66
|
+
toggle: a,
|
|
67
|
+
paletteProps: {
|
|
68
|
+
open: n,
|
|
69
|
+
onOpenChange: r
|
|
70
|
+
}
|
|
71
|
+
}), [n, a]);
|
|
67
72
|
}
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
242
|
-
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
);
|
|
391
|
-
je.displayName = "CommandPalette";
|
|
392
|
-
export {
|
|
393
|
-
je as CommandPalette,
|
|
394
|
-
Ke as defaultFilter,
|
|
395
|
-
ue as matchIndices,
|
|
396
|
-
Oe as useCommandPalette
|
|
397
|
-
};
|
|
73
|
+
var y = e(({ open: e, onOpenChange: h, items: g, onSelect: v, closeOnSelect: y = !0, query: b, defaultQuery: ae = "", onQueryChange: x, filter: S = _, loading: C = !1, loadingMessage: oe = "Searching…", emptyMessage: se = "No results", placeholder: ce = "Type a command or search…", hotkey: w = "mod+k", recentIds: T, recentLabel: E = "Recent", maxResults: D = 50, groupOrder: O, footer: k, escapeClearsQuery: A = !1, highlightMatches: le = !0, renderItem: j, "aria-label": ue = "Command palette", classes: M, className: de, style: fe }, N) => {
|
|
74
|
+
let P = r(), F = a(null), I = a(null), pe = a(null), me = (e) => {
|
|
75
|
+
F.current = e, typeof N == "function" ? N(e) : N && (N.current = e);
|
|
76
|
+
}, [he, L] = o(ae), R = b ?? he, z = t((e) => {
|
|
77
|
+
b === void 0 && L(e), x?.(e);
|
|
78
|
+
}, [b, x]), [B, V] = o([]), H = B.length ? B[B.length - 1].children ?? [] : g, [U, W] = o(0);
|
|
79
|
+
n(() => {
|
|
80
|
+
e && (V([]), W(0));
|
|
81
|
+
}, [e]);
|
|
82
|
+
let { sections: ge, flat: G } = i(() => {
|
|
83
|
+
let e = R.trim(), t = [];
|
|
84
|
+
H.forEach((e, n) => {
|
|
85
|
+
let r = !0;
|
|
86
|
+
S && (r = S(e, R)), r !== !1 && t.push({
|
|
87
|
+
item: e,
|
|
88
|
+
score: (r === !0 ? 1 : r) * 1e6 - n
|
|
89
|
+
});
|
|
90
|
+
}), S && e && t.sort((e, t) => t.score - e.score);
|
|
91
|
+
let n = t.map((e) => e.item), r = [];
|
|
92
|
+
if (!e && T?.length && B.length === 0) {
|
|
93
|
+
for (let e of T) {
|
|
94
|
+
let t = n.find((t) => t.id === e);
|
|
95
|
+
t && r.push(t);
|
|
96
|
+
}
|
|
97
|
+
let e = new Set(r.map((e) => e.id));
|
|
98
|
+
n = n.filter((t) => !e.has(t.id));
|
|
99
|
+
}
|
|
100
|
+
let i = D, a = (e) => {
|
|
101
|
+
let t = e.slice(0, Math.max(0, i));
|
|
102
|
+
return i -= t.length, t;
|
|
103
|
+
}, o = [];
|
|
104
|
+
r.length && o.push({
|
|
105
|
+
key: "__recent",
|
|
106
|
+
label: E,
|
|
107
|
+
items: a(r)
|
|
108
|
+
});
|
|
109
|
+
let s = /* @__PURE__ */ new Map(), c = [];
|
|
110
|
+
for (let e of n) e.group ? (s.has(e.group) || s.set(e.group, []), s.get(e.group).push(e)) : c.push(e);
|
|
111
|
+
c.length && o.push({
|
|
112
|
+
key: "__ungrouped",
|
|
113
|
+
label: null,
|
|
114
|
+
items: a(c)
|
|
115
|
+
});
|
|
116
|
+
let l = [...(O ?? []).filter((e) => s.has(e)), ...[...s.keys()].filter((e) => !O?.includes(e))];
|
|
117
|
+
for (let e of l) {
|
|
118
|
+
let t = a(s.get(e));
|
|
119
|
+
t.length && o.push({
|
|
120
|
+
key: e,
|
|
121
|
+
label: e,
|
|
122
|
+
items: t
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
sections: o,
|
|
127
|
+
flat: o.flatMap((e) => e.items)
|
|
128
|
+
};
|
|
129
|
+
}, [
|
|
130
|
+
H,
|
|
131
|
+
R,
|
|
132
|
+
S,
|
|
133
|
+
T,
|
|
134
|
+
E,
|
|
135
|
+
D,
|
|
136
|
+
O,
|
|
137
|
+
B.length
|
|
138
|
+
]);
|
|
139
|
+
n(() => {
|
|
140
|
+
let e = G.findIndex((e) => !e.disabled);
|
|
141
|
+
W((t) => G[t] && !G[t].disabled ? t : e < 0 ? 0 : e);
|
|
142
|
+
}, [G]), n(() => {
|
|
143
|
+
(I.current?.querySelector(`[data-index="${U}"]`))?.scrollIntoView?.({ block: "nearest" });
|
|
144
|
+
}, [U]);
|
|
145
|
+
let K = t((e, t = !0) => {
|
|
146
|
+
if (!G.length) return;
|
|
147
|
+
let n = U;
|
|
148
|
+
for (let r = 0; r < G.length && (n += e, n = t ? (n + G.length) % G.length : Math.max(0, Math.min(G.length - 1, n)), G[n].disabled); r++);
|
|
149
|
+
W(n);
|
|
150
|
+
}, [G, U]), q = t((e) => {
|
|
151
|
+
if (!G.length) return;
|
|
152
|
+
let t = Math.max(0, Math.min(G.length - 1, e)), n = e >= U ? -1 : 1;
|
|
153
|
+
for (; G[t]?.disabled;) if (t += n, t < 0 || t >= G.length) return;
|
|
154
|
+
W(t);
|
|
155
|
+
}, [G, U]), J = t((e) => {
|
|
156
|
+
e.disabled || (e.children?.length ? (V((t) => [...t, e]), z(""), W(0)) : (e.onSelect?.(), v?.(e), y && h(!1)));
|
|
157
|
+
}, [
|
|
158
|
+
v,
|
|
159
|
+
y,
|
|
160
|
+
h,
|
|
161
|
+
z
|
|
162
|
+
]), Y = t((e) => {
|
|
163
|
+
V((t) => t.slice(0, e)), W(0);
|
|
164
|
+
}, []), _e = i(() => w ? { [w]: () => h(!e) } : {}, [
|
|
165
|
+
w,
|
|
166
|
+
e,
|
|
167
|
+
h
|
|
168
|
+
]);
|
|
169
|
+
re(_e, { active: w !== !1 }), ee(F, e);
|
|
170
|
+
let ve = ne(() => {
|
|
171
|
+
A && R ? z("") : h(!1);
|
|
172
|
+
}, e);
|
|
173
|
+
n(() => {
|
|
174
|
+
if (!e) return;
|
|
175
|
+
let t = document.body.style.overflow;
|
|
176
|
+
return document.body.style.overflow = "hidden", () => {
|
|
177
|
+
document.body.style.overflow = t;
|
|
178
|
+
};
|
|
179
|
+
}, [e]);
|
|
180
|
+
let X = a(!1), ye = (e) => {
|
|
181
|
+
X.current = e.target === e.currentTarget;
|
|
182
|
+
}, be = (e) => {
|
|
183
|
+
X.current && e.target === e.currentTarget && h(!1), X.current = !1;
|
|
184
|
+
}, xe = (e) => {
|
|
185
|
+
switch (e.key) {
|
|
186
|
+
case "ArrowDown":
|
|
187
|
+
e.preventDefault(), K(1);
|
|
188
|
+
break;
|
|
189
|
+
case "ArrowUp":
|
|
190
|
+
e.preventDefault(), K(-1);
|
|
191
|
+
break;
|
|
192
|
+
case "Home":
|
|
193
|
+
e.preventDefault(), q(0);
|
|
194
|
+
break;
|
|
195
|
+
case "End":
|
|
196
|
+
e.preventDefault(), q(G.length - 1);
|
|
197
|
+
break;
|
|
198
|
+
case "PageDown":
|
|
199
|
+
e.preventDefault(), q(U + 10);
|
|
200
|
+
break;
|
|
201
|
+
case "PageUp":
|
|
202
|
+
e.preventDefault(), q(U - 10);
|
|
203
|
+
break;
|
|
204
|
+
case "Enter": {
|
|
205
|
+
if (C) return;
|
|
206
|
+
let t = G[U];
|
|
207
|
+
if (!t) return;
|
|
208
|
+
if (e.preventDefault(), t.href) {
|
|
209
|
+
(I.current?.querySelector(`[data-index="${U}"]`))?.click();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
J(t);
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
case "Backspace": !R && B.length && (e.preventDefault(), Y(B.length - 1));
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
if (!e) return null;
|
|
219
|
+
let Z = `${P}-list`, Q = (e) => `${P}-opt-${e}`, Se = G[U], Ce = /* @__PURE__ */ m(f, { children: [
|
|
220
|
+
/* @__PURE__ */ m("span", { children: [
|
|
221
|
+
/* @__PURE__ */ p(u, {
|
|
222
|
+
size: "sm",
|
|
223
|
+
children: "↑"
|
|
224
|
+
}),
|
|
225
|
+
/* @__PURE__ */ p(u, {
|
|
226
|
+
size: "sm",
|
|
227
|
+
children: "↓"
|
|
228
|
+
}),
|
|
229
|
+
" navigate"
|
|
230
|
+
] }),
|
|
231
|
+
/* @__PURE__ */ m("span", { children: [/* @__PURE__ */ p(u, {
|
|
232
|
+
size: "sm",
|
|
233
|
+
children: "↵"
|
|
234
|
+
}), " select"] }),
|
|
235
|
+
/* @__PURE__ */ m("span", { children: [/* @__PURE__ */ p(u, {
|
|
236
|
+
size: "sm",
|
|
237
|
+
children: "esc"
|
|
238
|
+
}), " close"] })
|
|
239
|
+
] }), $ = -1;
|
|
240
|
+
return s(/* @__PURE__ */ p("div", {
|
|
241
|
+
className: c(l.backdrop, M?.backdrop),
|
|
242
|
+
onMouseDown: ye,
|
|
243
|
+
onMouseUp: be,
|
|
244
|
+
role: "presentation",
|
|
245
|
+
children: /* @__PURE__ */ p("div", {
|
|
246
|
+
ref: me,
|
|
247
|
+
className: c(l.panel, M?.panel, de),
|
|
248
|
+
style: fe,
|
|
249
|
+
role: "dialog",
|
|
250
|
+
"aria-modal": "true",
|
|
251
|
+
"aria-label": ue,
|
|
252
|
+
children: /* @__PURE__ */ m(te, {
|
|
253
|
+
value: ve,
|
|
254
|
+
children: [
|
|
255
|
+
/* @__PURE__ */ m("div", {
|
|
256
|
+
className: c(l.header, M?.header),
|
|
257
|
+
children: [
|
|
258
|
+
B.map((e, t) => /* @__PURE__ */ p("button", {
|
|
259
|
+
type: "button",
|
|
260
|
+
className: c(l.breadcrumb, M?.breadcrumb),
|
|
261
|
+
onClick: () => Y(t + 1 === B.length ? t : t + 1),
|
|
262
|
+
"aria-label": typeof e.label == "string" ? `Back to ${e.label}` : void 0,
|
|
263
|
+
children: e.label
|
|
264
|
+
}, e.id)),
|
|
265
|
+
/* @__PURE__ */ p("input", {
|
|
266
|
+
ref: pe,
|
|
267
|
+
className: c(l.input, M?.input),
|
|
268
|
+
type: "text",
|
|
269
|
+
role: "combobox",
|
|
270
|
+
"aria-expanded": "true",
|
|
271
|
+
"aria-controls": Z,
|
|
272
|
+
"aria-activedescendant": Se ? Q(U) : void 0,
|
|
273
|
+
"aria-autocomplete": "list",
|
|
274
|
+
autoComplete: "off",
|
|
275
|
+
spellCheck: !1,
|
|
276
|
+
placeholder: ce,
|
|
277
|
+
value: R,
|
|
278
|
+
onChange: (e) => z(e.target.value),
|
|
279
|
+
onKeyDown: xe
|
|
280
|
+
}),
|
|
281
|
+
C && /* @__PURE__ */ p(d, {
|
|
282
|
+
size: "sm",
|
|
283
|
+
label: "Searching",
|
|
284
|
+
className: l.headerSpinner
|
|
285
|
+
})
|
|
286
|
+
]
|
|
287
|
+
}),
|
|
288
|
+
/* @__PURE__ */ m("div", {
|
|
289
|
+
ref: I,
|
|
290
|
+
id: Z,
|
|
291
|
+
role: "listbox",
|
|
292
|
+
className: c(l.list, M?.list),
|
|
293
|
+
children: [
|
|
294
|
+
C && /* @__PURE__ */ m("div", {
|
|
295
|
+
className: c(l.message, l.loading, M?.loading),
|
|
296
|
+
role: "status",
|
|
297
|
+
children: [
|
|
298
|
+
/* @__PURE__ */ p(d, {
|
|
299
|
+
size: "sm",
|
|
300
|
+
label: ""
|
|
301
|
+
}),
|
|
302
|
+
" ",
|
|
303
|
+
oe
|
|
304
|
+
]
|
|
305
|
+
}),
|
|
306
|
+
!C && G.length === 0 && /* @__PURE__ */ p("div", {
|
|
307
|
+
className: c(l.message, l.empty, M?.empty),
|
|
308
|
+
role: "status",
|
|
309
|
+
children: se
|
|
310
|
+
}),
|
|
311
|
+
!C && ge.map((e) => {
|
|
312
|
+
let t = `${P}-group-${e.key.replace(/\s+/g, "-")}`;
|
|
313
|
+
return /* @__PURE__ */ m("div", {
|
|
314
|
+
role: e.label === null ? void 0 : "group",
|
|
315
|
+
"aria-labelledby": e.label === null ? void 0 : t,
|
|
316
|
+
className: c(l.group, M?.group),
|
|
317
|
+
children: [e.label !== null && /* @__PURE__ */ p("div", {
|
|
318
|
+
id: t,
|
|
319
|
+
className: c(l.groupLabel, M?.groupLabel),
|
|
320
|
+
children: e.label
|
|
321
|
+
}), e.items.map((e) => {
|
|
322
|
+
$ += 1;
|
|
323
|
+
let t = $, n = t === U, r = e.href ? "a" : "div", i = j ? j(e, {
|
|
324
|
+
active: n,
|
|
325
|
+
query: R
|
|
326
|
+
}) : /* @__PURE__ */ m(f, { children: [
|
|
327
|
+
e.icon && /* @__PURE__ */ p("span", {
|
|
328
|
+
className: c(l.itemIcon, M?.itemIcon),
|
|
329
|
+
"aria-hidden": "true",
|
|
330
|
+
children: e.icon
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ m("span", {
|
|
333
|
+
className: l.itemText,
|
|
334
|
+
children: [/* @__PURE__ */ p("span", {
|
|
335
|
+
className: c(l.itemLabel, M?.itemLabel),
|
|
336
|
+
children: ie(e.label, R, le, c(l.match, M?.match))
|
|
337
|
+
}), e.description && /* @__PURE__ */ p("span", {
|
|
338
|
+
className: c(l.itemDescription, M?.itemDescription),
|
|
339
|
+
children: e.description
|
|
340
|
+
})]
|
|
341
|
+
}),
|
|
342
|
+
e.children?.length ? /* @__PURE__ */ p("span", {
|
|
343
|
+
className: l.itemChevron,
|
|
344
|
+
"aria-hidden": "true",
|
|
345
|
+
children: "›"
|
|
346
|
+
}) : null,
|
|
347
|
+
e.shortcut && /* @__PURE__ */ p("span", {
|
|
348
|
+
className: c(l.itemShortcut, M?.itemShortcut),
|
|
349
|
+
"aria-hidden": "true",
|
|
350
|
+
children: Array.isArray(e.shortcut) ? /* @__PURE__ */ p(u, {
|
|
351
|
+
size: "sm",
|
|
352
|
+
keys: e.shortcut
|
|
353
|
+
}) : /* @__PURE__ */ p(u, {
|
|
354
|
+
size: "sm",
|
|
355
|
+
children: e.shortcut
|
|
356
|
+
})
|
|
357
|
+
})
|
|
358
|
+
] });
|
|
359
|
+
return /* @__PURE__ */ p(r, {
|
|
360
|
+
id: Q(t),
|
|
361
|
+
"data-index": t,
|
|
362
|
+
role: "option",
|
|
363
|
+
"aria-selected": n,
|
|
364
|
+
"aria-disabled": e.disabled || void 0,
|
|
365
|
+
href: e.href,
|
|
366
|
+
tabIndex: -1,
|
|
367
|
+
className: c(l.item, n && l.itemActive, e.disabled && l.itemDisabled, M?.item, n && M?.itemActive),
|
|
368
|
+
onMouseMove: () => {
|
|
369
|
+
!e.disabled && U !== t && W(t);
|
|
370
|
+
},
|
|
371
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
372
|
+
onClick: (t) => {
|
|
373
|
+
e.disabled ? t.preventDefault() : e.href ? (e.onSelect?.(), v?.(e), y && h(!1)) : J(e);
|
|
374
|
+
},
|
|
375
|
+
children: i
|
|
376
|
+
}, e.id);
|
|
377
|
+
})]
|
|
378
|
+
}, e.key);
|
|
379
|
+
})
|
|
380
|
+
]
|
|
381
|
+
}),
|
|
382
|
+
k !== null && /* @__PURE__ */ p("div", {
|
|
383
|
+
className: c(l.footer, M?.footer),
|
|
384
|
+
children: k === void 0 ? Ce : k
|
|
385
|
+
})
|
|
386
|
+
]
|
|
387
|
+
})
|
|
388
|
+
})
|
|
389
|
+
}), document.body);
|
|
390
|
+
});
|
|
391
|
+
y.displayName = "CommandPalette";
|
|
392
|
+
export { y as CommandPalette, _ as defaultFilter, h as matchIndices, v as useCommandPalette };
|