@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
|
@@ -1,234 +1,175 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
) : /* @__PURE__ */ v(
|
|
179
|
-
"div",
|
|
180
|
-
{
|
|
181
|
-
ref: G,
|
|
182
|
-
className: l(t.root, a && t.fullWidth, i?.root, O),
|
|
183
|
-
style: K,
|
|
184
|
-
children: [
|
|
185
|
-
/* @__PURE__ */ v("div", { ref: k, style: a ? { width: "100%" } : void 0, children: [
|
|
186
|
-
/* @__PURE__ */ v(
|
|
187
|
-
"button",
|
|
188
|
-
{
|
|
189
|
-
ref: b,
|
|
190
|
-
id: W,
|
|
191
|
-
type: "button",
|
|
192
|
-
className: l(
|
|
193
|
-
t.trigger,
|
|
194
|
-
n && t.triggerOpen,
|
|
195
|
-
q && t.triggerError,
|
|
196
|
-
a && t.fullWidth,
|
|
197
|
-
i?.trigger
|
|
198
|
-
),
|
|
199
|
-
onClick: F,
|
|
200
|
-
"aria-expanded": n,
|
|
201
|
-
"aria-haspopup": "menu",
|
|
202
|
-
"aria-controls": n ? I : void 0,
|
|
203
|
-
children: [
|
|
204
|
-
/* @__PURE__ */ u("span", { className: l(t.triggerLabel, Y && t.placeholder, i?.triggerLabel), children: X }),
|
|
205
|
-
/* @__PURE__ */ u("span", { className: l(t.chevron, i?.chevron), "aria-hidden": "true" })
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
),
|
|
209
|
-
!w && C()
|
|
210
|
-
] }),
|
|
211
|
-
w && n && typeof document < "u" && te(
|
|
212
|
-
C({
|
|
213
|
-
position: "fixed",
|
|
214
|
-
top: p.top + 4,
|
|
215
|
-
left: L === "right" ? void 0 : p.left,
|
|
216
|
-
// clientWidth, not innerWidth: `right` on a fixed element is
|
|
217
|
-
// measured from the viewport edge inside the scrollbar, while
|
|
218
|
-
// innerWidth includes it — the menu would shift left by the
|
|
219
|
-
// scrollbar width whenever the page scrolls.
|
|
220
|
-
right: L === "right" ? document.documentElement.clientWidth - (p.left + p.width) : void 0,
|
|
221
|
-
minWidth: p.width,
|
|
222
|
-
zIndex: "var(--crk-z-floating)"
|
|
223
|
-
}),
|
|
224
|
-
document.body
|
|
225
|
-
)
|
|
226
|
-
]
|
|
227
|
-
}
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
);
|
|
231
|
-
we.displayName = "Dropdown";
|
|
232
|
-
export {
|
|
233
|
-
we as Dropdown
|
|
234
|
-
};
|
|
1
|
+
import e from "./Dropdown.module.js";
|
|
2
|
+
import { EscapeLayerProvider as t, useEscapeLayer as n } from "../../hooks/useEscapeLayer.js";
|
|
3
|
+
import { usePortalPosition as r } from "../../hooks/usePortalPosition.js";
|
|
4
|
+
import { DropdownMenuContext as i } from "./dropdownContext.js";
|
|
5
|
+
import { forwardRef as a, useCallback as o, useEffect as s, useId as ee, useLayoutEffect as te, useRef as c, useState as l } from "react";
|
|
6
|
+
import u from "clsx";
|
|
7
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
|
+
import { createPortal as p } from "react-dom";
|
|
9
|
+
// src/components/Dropdown/Dropdown.tsx
|
|
10
|
+
var m = "[role=\"menuitem\"]:not(:disabled), [role=\"menuitemcheckbox\"]:not(:disabled)", h = 8, g = a(({ trigger: a, children: g, align: _ = "left", className: v, style: y, id: b, onOpen: x, onClose: S, options: C, placeholder: ne = "Select...", value: w, onChange: T, error: E = !1, fullWidth: D = !0, portal: O = !0, open: k, onOpenChange: A, anchor: j, classes: M }, N) => {
|
|
11
|
+
let [re, ie] = l(!1), P = k !== void 0, F = P ? k : re, I = c(F);
|
|
12
|
+
I.current = F;
|
|
13
|
+
let L = c(null), R = c(null), z = c(null), B = ee(), V = j !== void 0, H = V && j !== null, U = !!C || a !== void 0 || !V, W = o((e) => {
|
|
14
|
+
e !== I.current && (P || ie(e), A?.(e), e ? x?.() : S?.());
|
|
15
|
+
}, [
|
|
16
|
+
P,
|
|
17
|
+
A,
|
|
18
|
+
x,
|
|
19
|
+
S
|
|
20
|
+
]);
|
|
21
|
+
s(() => {
|
|
22
|
+
F && R.current && R.current.querySelector(m)?.focus();
|
|
23
|
+
}, [F]);
|
|
24
|
+
let G = o(() => {
|
|
25
|
+
W(!1), z.current?.focus();
|
|
26
|
+
}, [W]), K = o(() => {
|
|
27
|
+
W(!I.current);
|
|
28
|
+
}, [W]), ae = o((e) => {
|
|
29
|
+
let t = R.current;
|
|
30
|
+
if (!t) return;
|
|
31
|
+
let n = Array.from(t.querySelectorAll(m));
|
|
32
|
+
if (n.length === 0) return;
|
|
33
|
+
let r = n.indexOf(document.activeElement), i = (e) => {
|
|
34
|
+
n[(e + n.length) % n.length]?.focus();
|
|
35
|
+
};
|
|
36
|
+
switch (e.key) {
|
|
37
|
+
case "ArrowDown":
|
|
38
|
+
e.preventDefault(), i(r + 1);
|
|
39
|
+
return;
|
|
40
|
+
case "ArrowUp":
|
|
41
|
+
e.preventDefault(), i(r - 1);
|
|
42
|
+
return;
|
|
43
|
+
case "Home":
|
|
44
|
+
e.preventDefault(), i(0);
|
|
45
|
+
return;
|
|
46
|
+
case "End":
|
|
47
|
+
e.preventDefault(), i(n.length - 1);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && e.key !== " ") {
|
|
51
|
+
let t = e.key.toLowerCase();
|
|
52
|
+
for (let i = 1; i <= n.length; i++) {
|
|
53
|
+
let a = n[(r + i) % n.length];
|
|
54
|
+
if ((a.textContent ?? "").trim().toLowerCase().startsWith(t)) {
|
|
55
|
+
e.preventDefault(), a.focus();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, []), [q, J] = l(null);
|
|
61
|
+
te(() => {
|
|
62
|
+
if (!F || !j || !R.current || typeof window > "u") {
|
|
63
|
+
J(null);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
let e = R.current.getBoundingClientRect(), t = document.documentElement.clientWidth || window.innerWidth, n = document.documentElement.clientHeight || window.innerHeight, r = j.x, i = j.y;
|
|
67
|
+
r + e.width > t - h && (r = j.x - e.width), i + e.height > n - h && (i = j.y - e.height), r = Math.max(h, Math.min(r, t - h - e.width)), i = Math.max(h, Math.min(i, n - h - e.height)), J({
|
|
68
|
+
top: Math.round(i),
|
|
69
|
+
left: Math.round(r)
|
|
70
|
+
});
|
|
71
|
+
}, [
|
|
72
|
+
F,
|
|
73
|
+
j?.x,
|
|
74
|
+
j?.y
|
|
75
|
+
]);
|
|
76
|
+
let oe = o((e) => {
|
|
77
|
+
T?.(e), G();
|
|
78
|
+
}, [T, G]);
|
|
79
|
+
s(() => {
|
|
80
|
+
if (!F) return;
|
|
81
|
+
let e = (e) => {
|
|
82
|
+
let t = e.target;
|
|
83
|
+
L.current?.contains(t) || R.current?.contains(t) || G();
|
|
84
|
+
};
|
|
85
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
86
|
+
}, [F, G]);
|
|
87
|
+
let se = n(G, F), Y = r(z, F && O && !H), ce = { close: G }, X = C?.find((e) => e.value === w)?.label, Z = C ? X || ne : a, Q = C && !X, le = C ? C.map((t) => /* @__PURE__ */ d("button", {
|
|
88
|
+
type: "button",
|
|
89
|
+
role: "menuitem",
|
|
90
|
+
className: u(e.item, t.disabled && e.itemDisabled, t.value === w && e.itemSelected, M?.item),
|
|
91
|
+
disabled: t.disabled,
|
|
92
|
+
onClick: () => oe(t.value),
|
|
93
|
+
children: t.label
|
|
94
|
+
}, t.value)) : g, $ = (n) => /* @__PURE__ */ d("div", {
|
|
95
|
+
ref: R,
|
|
96
|
+
id: B,
|
|
97
|
+
className: u(e.menu, F && e.menuOpen, _ === "left" ? e.alignLeft : e.alignRight, !O && D && e.fullWidth, M?.menu),
|
|
98
|
+
style: n,
|
|
99
|
+
role: "menu",
|
|
100
|
+
onKeyDown: ae,
|
|
101
|
+
children: /* @__PURE__ */ d(t, {
|
|
102
|
+
value: se,
|
|
103
|
+
children: /* @__PURE__ */ d(i.Provider, {
|
|
104
|
+
value: ce,
|
|
105
|
+
children: le
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
return V ? /* @__PURE__ */ f("div", {
|
|
110
|
+
ref: N,
|
|
111
|
+
className: u(e.root, U && D && e.fullWidth, M?.root, v),
|
|
112
|
+
style: y,
|
|
113
|
+
children: [U && /* @__PURE__ */ d("div", {
|
|
114
|
+
ref: L,
|
|
115
|
+
style: D ? { width: "100%" } : void 0,
|
|
116
|
+
children: /* @__PURE__ */ f("button", {
|
|
117
|
+
ref: z,
|
|
118
|
+
id: b,
|
|
119
|
+
type: "button",
|
|
120
|
+
className: u(e.trigger, F && e.triggerOpen, E && e.triggerError, D && e.fullWidth, M?.trigger),
|
|
121
|
+
onClick: K,
|
|
122
|
+
"aria-expanded": F,
|
|
123
|
+
"aria-haspopup": "menu",
|
|
124
|
+
"aria-controls": F ? B : void 0,
|
|
125
|
+
children: [/* @__PURE__ */ d("span", {
|
|
126
|
+
className: u(e.triggerLabel, Q && e.placeholder, M?.triggerLabel),
|
|
127
|
+
children: Z
|
|
128
|
+
}), /* @__PURE__ */ d("span", {
|
|
129
|
+
className: u(e.chevron, M?.chevron),
|
|
130
|
+
"aria-hidden": "true"
|
|
131
|
+
})]
|
|
132
|
+
})
|
|
133
|
+
}), F && H && typeof document < "u" && p($({
|
|
134
|
+
position: "fixed",
|
|
135
|
+
top: q?.top ?? j.y,
|
|
136
|
+
left: q?.left ?? j.x,
|
|
137
|
+
visibility: q ? void 0 : "hidden",
|
|
138
|
+
zIndex: "var(--crk-z-floating)"
|
|
139
|
+
}), document.body)]
|
|
140
|
+
}) : /* @__PURE__ */ f("div", {
|
|
141
|
+
ref: N,
|
|
142
|
+
className: u(e.root, D && e.fullWidth, M?.root, v),
|
|
143
|
+
style: y,
|
|
144
|
+
children: [/* @__PURE__ */ f("div", {
|
|
145
|
+
ref: L,
|
|
146
|
+
style: D ? { width: "100%" } : void 0,
|
|
147
|
+
children: [/* @__PURE__ */ f("button", {
|
|
148
|
+
ref: z,
|
|
149
|
+
id: b,
|
|
150
|
+
type: "button",
|
|
151
|
+
className: u(e.trigger, F && e.triggerOpen, E && e.triggerError, D && e.fullWidth, M?.trigger),
|
|
152
|
+
onClick: K,
|
|
153
|
+
"aria-expanded": F,
|
|
154
|
+
"aria-haspopup": "menu",
|
|
155
|
+
"aria-controls": F ? B : void 0,
|
|
156
|
+
children: [/* @__PURE__ */ d("span", {
|
|
157
|
+
className: u(e.triggerLabel, Q && e.placeholder, M?.triggerLabel),
|
|
158
|
+
children: Z
|
|
159
|
+
}), /* @__PURE__ */ d("span", {
|
|
160
|
+
className: u(e.chevron, M?.chevron),
|
|
161
|
+
"aria-hidden": "true"
|
|
162
|
+
})]
|
|
163
|
+
}), !O && $()]
|
|
164
|
+
}), O && F && typeof document < "u" && p($({
|
|
165
|
+
position: "fixed",
|
|
166
|
+
top: Y.top + 4,
|
|
167
|
+
left: _ === "right" ? void 0 : Y.left,
|
|
168
|
+
right: _ === "right" ? document.documentElement.clientWidth - (Y.left + Y.width) : void 0,
|
|
169
|
+
minWidth: Y.width,
|
|
170
|
+
zIndex: "var(--crk-z-floating)"
|
|
171
|
+
}), document.body)]
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
g.displayName = "Dropdown";
|
|
175
|
+
export { g as Dropdown };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/components/Dropdown/Dropdown.module.scss
|
|
2
|
+
var e = "crk-root-an8Cf", t = "crk-fullWidth-S-uVk", n = "crk-trigger-LwPaD", r = "crk-triggerOpen-U4pa9", i = "crk-triggerLabel-QLITs", a = "crk-triggerError-3jlu1", o = "crk-placeholder-fWdch", s = "crk-chevron-jmDNe", c = "crk-menu-fxnKL", l = "crk-menuOpen-HF-Y1", u = "crk-menuEnter-F0Yyt", d = "crk-alignLeft-buCDJ", f = "crk-alignRight-05P9w", p = "crk-item-f-Rhh", m = "crk-itemDisabled-L-d6i", h = "crk-itemSelected-Fwmuo", g = "crk-itemDanger-b1A4e", _ = "crk-itemChecked-xY5Cf", v = "crk-itemCheck-IZYaJ", y = "crk-itemIcon-3Gh8c", b = "crk-itemLabel-YdjzN", x = "crk-itemDescription-eM-fw", S = "crk-itemShortcut-33qnD", C = "crk-separator-C0jdb", w = "crk-label-Rd7NT", T = {
|
|
3
|
+
root: e,
|
|
4
|
+
fullWidth: t,
|
|
5
|
+
trigger: n,
|
|
6
|
+
triggerOpen: r,
|
|
7
|
+
triggerLabel: i,
|
|
8
|
+
triggerError: a,
|
|
9
|
+
placeholder: o,
|
|
10
|
+
chevron: s,
|
|
11
|
+
menu: c,
|
|
12
|
+
menuOpen: l,
|
|
13
|
+
menuEnter: u,
|
|
14
|
+
alignLeft: d,
|
|
15
|
+
alignRight: f,
|
|
16
|
+
item: p,
|
|
17
|
+
itemDisabled: m,
|
|
18
|
+
itemSelected: h,
|
|
19
|
+
itemDanger: g,
|
|
20
|
+
itemChecked: _,
|
|
21
|
+
itemCheck: v,
|
|
22
|
+
itemIcon: y,
|
|
23
|
+
itemLabel: b,
|
|
24
|
+
itemDescription: x,
|
|
25
|
+
itemShortcut: S,
|
|
26
|
+
separator: C,
|
|
27
|
+
label: w
|
|
28
|
+
};
|
|
29
|
+
export { d as alignLeft, f as alignRight, s as chevron, T as default, t as fullWidth, p as item, v as itemCheck, _ as itemChecked, g as itemDanger, x as itemDescription, m as itemDisabled, y as itemIcon, b as itemLabel, h as itemSelected, S as itemShortcut, w as label, c as menu, u as menuEnter, l as menuOpen, o as placeholder, e as root, C as separator, n as trigger, a as triggerError, i as triggerLabel, r as triggerOpen };
|
|
@@ -1,58 +1,55 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
export {
|
|
57
|
-
I as DropdownItem
|
|
58
|
-
};
|
|
1
|
+
import e from "./Dropdown.module.js";
|
|
2
|
+
import { DropdownMenuContext as t } from "./dropdownContext.js";
|
|
3
|
+
import { forwardRef as n, useContext as r } from "react";
|
|
4
|
+
import i from "clsx";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
// src/components/Dropdown/DropdownItem.tsx
|
|
7
|
+
var s = n(({ disabled: n = !1, danger: s = !1, icon: c, shortcut: l, checked: u, description: d, closeOnSelect: f, classes: p, className: m, children: h, onClick: g, ..._ }, v) => {
|
|
8
|
+
let y = r(t), b = u !== void 0, x = f ?? !b;
|
|
9
|
+
return /* @__PURE__ */ o("button", {
|
|
10
|
+
ref: v,
|
|
11
|
+
type: "button",
|
|
12
|
+
role: b ? "menuitemcheckbox" : "menuitem",
|
|
13
|
+
"aria-checked": b ? u : void 0,
|
|
14
|
+
className: i(e.item, n && e.itemDisabled, s && e.itemDanger, b && u && e.itemChecked, p?.item, m),
|
|
15
|
+
disabled: n,
|
|
16
|
+
onClick: (e) => {
|
|
17
|
+
g?.(e), x && !e.defaultPrevented && y?.close();
|
|
18
|
+
},
|
|
19
|
+
..._,
|
|
20
|
+
children: [
|
|
21
|
+
b && /* @__PURE__ */ a("span", {
|
|
22
|
+
className: i(e.itemCheck, p?.itemCheck),
|
|
23
|
+
"aria-hidden": "true",
|
|
24
|
+
children: u && /* @__PURE__ */ a("svg", {
|
|
25
|
+
viewBox: "0 0 16 16",
|
|
26
|
+
fill: "none",
|
|
27
|
+
stroke: "currentColor",
|
|
28
|
+
strokeWidth: "2",
|
|
29
|
+
strokeLinecap: "round",
|
|
30
|
+
strokeLinejoin: "round",
|
|
31
|
+
children: /* @__PURE__ */ a("path", { d: "M3 8.5l3 3 7-7" })
|
|
32
|
+
})
|
|
33
|
+
}),
|
|
34
|
+
c != null && /* @__PURE__ */ a("span", {
|
|
35
|
+
className: i(e.itemIcon, p?.itemIcon),
|
|
36
|
+
"aria-hidden": "true",
|
|
37
|
+
children: c
|
|
38
|
+
}),
|
|
39
|
+
/* @__PURE__ */ o("span", {
|
|
40
|
+
className: i(e.itemLabel, p?.itemLabel),
|
|
41
|
+
children: [h, d != null && /* @__PURE__ */ a("span", {
|
|
42
|
+
className: i(e.itemDescription, p?.itemDescription),
|
|
43
|
+
children: d
|
|
44
|
+
})]
|
|
45
|
+
}),
|
|
46
|
+
l != null && /* @__PURE__ */ a("span", {
|
|
47
|
+
className: i(e.itemShortcut, p?.itemShortcut),
|
|
48
|
+
"aria-hidden": "true",
|
|
49
|
+
children: l
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
s.displayName = "DropdownItem";
|
|
55
|
+
export { s as DropdownItem };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import e from "./Dropdown.module.js";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import n from "clsx";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
// src/components/Dropdown/DropdownLabel.tsx
|
|
6
|
+
var i = t(({ className: t, children: i, ...a }, o) => /* @__PURE__ */ r("div", {
|
|
7
|
+
ref: o,
|
|
8
|
+
role: "presentation",
|
|
9
|
+
className: n(e.label, t),
|
|
10
|
+
...a,
|
|
11
|
+
children: i
|
|
12
|
+
}));
|
|
13
|
+
i.displayName = "DropdownLabel";
|
|
14
|
+
export { i as DropdownLabel };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from "./Dropdown.module.js";
|
|
2
2
|
import { forwardRef as t } from "react";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
3
|
+
import n from "clsx";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
// src/components/Dropdown/DropdownSeparator.tsx
|
|
6
|
+
var i = t(({ className: t, ...i }, a) => /* @__PURE__ */ r("div", {
|
|
7
|
+
ref: a,
|
|
8
|
+
role: "separator",
|
|
9
|
+
className: n(e.separator, t),
|
|
10
|
+
...i
|
|
11
|
+
}));
|
|
12
|
+
i.displayName = "DropdownSeparator";
|
|
13
|
+
export { i as DropdownSeparator };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createContext as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
1
|
+
import { createContext as e } from "react";
|
|
2
|
+
// src/components/Dropdown/dropdownContext.ts
|
|
3
|
+
var t = e(null);
|
|
4
|
+
export { t as DropdownMenuContext };
|