@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,119 +1,66 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
export {
|
|
66
|
-
r as backdrop,
|
|
67
|
-
c as backdropBare,
|
|
68
|
-
e as backdropClosing,
|
|
69
|
-
x as body,
|
|
70
|
-
M as closeButton,
|
|
71
|
-
t as crkDrawerFadeIn,
|
|
72
|
-
o as crkDrawerFadeOut,
|
|
73
|
-
E as crkDrawerInBottom,
|
|
74
|
-
b as crkDrawerInLeft,
|
|
75
|
-
f as crkDrawerInRight,
|
|
76
|
-
R as crkDrawerInTop,
|
|
77
|
-
S as crkDrawerOutBottom,
|
|
78
|
-
L as crkDrawerOutLeft,
|
|
79
|
-
O as crkDrawerOutRight,
|
|
80
|
-
C as crkDrawerOutTop,
|
|
81
|
-
q as default,
|
|
82
|
-
s as drawer,
|
|
83
|
-
N as drawerClosing,
|
|
84
|
-
G as footer,
|
|
85
|
-
A as header,
|
|
86
|
-
H as headerTitle,
|
|
87
|
-
_ as sideBottom,
|
|
88
|
-
n as sideLeft,
|
|
89
|
-
d as sideRight,
|
|
90
|
-
a as sideTop,
|
|
91
|
-
u as side_bottom,
|
|
92
|
-
k as side_left,
|
|
93
|
-
i as side_right,
|
|
94
|
-
l as side_top,
|
|
95
|
-
K as sizeFull,
|
|
96
|
-
W as sizeLg,
|
|
97
|
-
U as sizeMd,
|
|
98
|
-
Z as sizeSm,
|
|
99
|
-
J as size_full,
|
|
100
|
-
V as size_lg,
|
|
101
|
-
P as size_md,
|
|
102
|
-
X as size_sm,
|
|
103
|
-
Q as slideInBottom,
|
|
104
|
-
h as slideInLeft,
|
|
105
|
-
g as slideInRight,
|
|
106
|
-
T as slideInTop,
|
|
107
|
-
y as slideIn_bottom,
|
|
108
|
-
m as slideIn_left,
|
|
109
|
-
w as slideIn_right,
|
|
110
|
-
B as slideIn_top,
|
|
111
|
-
v as slideOutBottom,
|
|
112
|
-
D as slideOutLeft,
|
|
113
|
-
I as slideOutRight,
|
|
114
|
-
F as slideOutTop,
|
|
115
|
-
j as slideOut_bottom,
|
|
116
|
-
z as slideOut_left,
|
|
117
|
-
p as slideOut_right,
|
|
118
|
-
Y as slideOut_top
|
|
1
|
+
// src/components/Drawer/Drawer.module.scss
|
|
2
|
+
var e = "crk-backdrop-LBGhN", t = "crk-crk-drawer-fade-in-fnZXU", n = "crk-backdropClosing-0aeyJ", r = "crk-crk-drawer-fade-out-iDYoX", i = "crk-backdropBare-7fB4W", a = "crk-drawer-IKoOm", o = "crk-side_right-sYQoY", s = "crk-side_right-sYQoY", c = "crk-side_left-gAeYL", l = "crk-side_left-gAeYL", u = "crk-side_top-QFjZz", d = "crk-side_top-QFjZz", f = "crk-side_bottom-Y1t6g", p = "crk-side_bottom-Y1t6g", m = "crk-slideIn_right-HORcg", h = "crk-slideIn_right-HORcg", g = "crk-crk-drawer-in-right-lit2r", _ = "crk-slideOut_right-lbnQY", v = "crk-slideOut_right-lbnQY", y = "crk-crk-drawer-out-right-lrub3", b = "crk-slideIn_left-VvJeV", x = "crk-slideIn_left-VvJeV", S = "crk-crk-drawer-in-left-98vE7", C = "crk-slideOut_left-4pc01", w = "crk-slideOut_left-4pc01", T = "crk-crk-drawer-out-left-EI6P3", E = "crk-slideIn_top-ULcWL", D = "crk-slideIn_top-ULcWL", O = "crk-crk-drawer-in-top-8ZkO6", k = "crk-slideOut_top-00Tue", A = "crk-slideOut_top-00Tue", j = "crk-crk-drawer-out-top-KDkv7", M = "crk-slideIn_bottom-uBTzu", N = "crk-slideIn_bottom-uBTzu", P = "crk-crk-drawer-in-bottom-b9y67", F = "crk-slideOut_bottom-g6ELp", I = "crk-slideOut_bottom-g6ELp", L = "crk-crk-drawer-out-bottom-IShFs", R = "crk-size_sm-o8tw7", z = "crk-size_sm-o8tw7", B = "crk-size_md-akgTC", V = "crk-size_md-akgTC", H = "crk-size_lg-Yjulz", U = "crk-size_lg-Yjulz", W = "crk-size_full-DIjPg", G = "crk-size_full-DIjPg", K = "crk-header--OScS", q = "crk-headerTitle-LQr32", J = "crk-closeButton-WdXyR", Y = "crk-body-CXRcE", X = "crk-footer-0kQ83", Z = "crk-drawerClosing-9hrsd", Q = {
|
|
3
|
+
backdrop: e,
|
|
4
|
+
"crk-drawer-fade-in": "crk-crk-drawer-fade-in-fnZXU",
|
|
5
|
+
crkDrawerFadeIn: t,
|
|
6
|
+
backdropClosing: n,
|
|
7
|
+
"crk-drawer-fade-out": "crk-crk-drawer-fade-out-iDYoX",
|
|
8
|
+
crkDrawerFadeOut: r,
|
|
9
|
+
backdropBare: i,
|
|
10
|
+
drawer: a,
|
|
11
|
+
side_right: o,
|
|
12
|
+
sideRight: s,
|
|
13
|
+
side_left: c,
|
|
14
|
+
sideLeft: l,
|
|
15
|
+
side_top: u,
|
|
16
|
+
sideTop: d,
|
|
17
|
+
side_bottom: f,
|
|
18
|
+
sideBottom: p,
|
|
19
|
+
slideIn_right: m,
|
|
20
|
+
slideInRight: h,
|
|
21
|
+
"crk-drawer-in-right": "crk-crk-drawer-in-right-lit2r",
|
|
22
|
+
crkDrawerInRight: g,
|
|
23
|
+
slideOut_right: _,
|
|
24
|
+
slideOutRight: v,
|
|
25
|
+
"crk-drawer-out-right": "crk-crk-drawer-out-right-lrub3",
|
|
26
|
+
crkDrawerOutRight: y,
|
|
27
|
+
slideIn_left: b,
|
|
28
|
+
slideInLeft: x,
|
|
29
|
+
"crk-drawer-in-left": "crk-crk-drawer-in-left-98vE7",
|
|
30
|
+
crkDrawerInLeft: S,
|
|
31
|
+
slideOut_left: C,
|
|
32
|
+
slideOutLeft: w,
|
|
33
|
+
"crk-drawer-out-left": "crk-crk-drawer-out-left-EI6P3",
|
|
34
|
+
crkDrawerOutLeft: T,
|
|
35
|
+
slideIn_top: E,
|
|
36
|
+
slideInTop: D,
|
|
37
|
+
"crk-drawer-in-top": "crk-crk-drawer-in-top-8ZkO6",
|
|
38
|
+
crkDrawerInTop: O,
|
|
39
|
+
slideOut_top: k,
|
|
40
|
+
slideOutTop: A,
|
|
41
|
+
"crk-drawer-out-top": "crk-crk-drawer-out-top-KDkv7",
|
|
42
|
+
crkDrawerOutTop: j,
|
|
43
|
+
slideIn_bottom: M,
|
|
44
|
+
slideInBottom: N,
|
|
45
|
+
"crk-drawer-in-bottom": "crk-crk-drawer-in-bottom-b9y67",
|
|
46
|
+
crkDrawerInBottom: P,
|
|
47
|
+
slideOut_bottom: F,
|
|
48
|
+
slideOutBottom: I,
|
|
49
|
+
"crk-drawer-out-bottom": "crk-crk-drawer-out-bottom-IShFs",
|
|
50
|
+
crkDrawerOutBottom: L,
|
|
51
|
+
size_sm: R,
|
|
52
|
+
sizeSm: z,
|
|
53
|
+
size_md: B,
|
|
54
|
+
sizeMd: V,
|
|
55
|
+
size_lg: H,
|
|
56
|
+
sizeLg: U,
|
|
57
|
+
size_full: W,
|
|
58
|
+
sizeFull: G,
|
|
59
|
+
header: K,
|
|
60
|
+
headerTitle: q,
|
|
61
|
+
closeButton: J,
|
|
62
|
+
body: Y,
|
|
63
|
+
footer: X,
|
|
64
|
+
drawerClosing: Z
|
|
119
65
|
};
|
|
66
|
+
export { e as backdrop, i as backdropBare, n as backdropClosing, Y as body, J as closeButton, t as crkDrawerFadeIn, r as crkDrawerFadeOut, P as crkDrawerInBottom, S as crkDrawerInLeft, g as crkDrawerInRight, O as crkDrawerInTop, L as crkDrawerOutBottom, T as crkDrawerOutLeft, y as crkDrawerOutRight, j as crkDrawerOutTop, Q as default, a as drawer, Z as drawerClosing, X as footer, K as header, q as headerTitle, p as sideBottom, l as sideLeft, s as sideRight, d as sideTop, f as side_bottom, c as side_left, o as side_right, u as side_top, G as sizeFull, U as sizeLg, V as sizeMd, z as sizeSm, W as size_full, H as size_lg, B as size_md, R as size_sm, N as slideInBottom, x as slideInLeft, h as slideInRight, D as slideInTop, M as slideIn_bottom, b as slideIn_left, m as slideIn_right, E as slideIn_top, I as slideOutBottom, w as slideOutLeft, v as slideOutRight, A as slideOutTop, F as slideOut_bottom, C as slideOut_left, _ as slideOut_right, k as slideOut_top };
|
|
@@ -1,234 +1,175 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import l from "
|
|
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 { forwardRef as e, useCallback as t, useEffect as n, useId as r, useLayoutEffect 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 "./Dropdown.module.scss.js";
|
|
5
|
+
import { EscapeLayerProvider as u, useEscapeLayer as ee } from "../../hooks/useEscapeLayer.js";
|
|
6
|
+
import { usePortalPosition as te } from "../../hooks/usePortalPosition.js";
|
|
7
|
+
import { DropdownMenuContext as ne } from "./dropdownContext.js";
|
|
8
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
|
+
// src/components/Dropdown/Dropdown.tsx
|
|
10
|
+
var p = "[role=\"menuitem\"]:not(:disabled), [role=\"menuitemcheckbox\"]:not(:disabled)", m = 8, h = e(({ trigger: e, children: h, align: g = "left", className: _, style: v, id: y, onOpen: b, onClose: x, options: S, placeholder: re = "Select...", value: C, onChange: w, error: T = !1, fullWidth: E = !0, portal: D = !0, open: O, onOpenChange: k, anchor: A, classes: j }, M) => {
|
|
11
|
+
let [N, ie] = o(!1), P = O !== void 0, F = P ? O : N, I = a(F);
|
|
12
|
+
I.current = F;
|
|
13
|
+
let L = a(null), R = a(null), z = a(null), B = r(), V = A !== void 0, H = V && A !== null, U = !!S || e !== void 0 || !V, W = t((e) => {
|
|
14
|
+
e !== I.current && (P || ie(e), k?.(e), e ? b?.() : x?.());
|
|
15
|
+
}, [
|
|
16
|
+
P,
|
|
17
|
+
k,
|
|
18
|
+
b,
|
|
19
|
+
x
|
|
20
|
+
]);
|
|
21
|
+
n(() => {
|
|
22
|
+
F && R.current && R.current.querySelector(p)?.focus();
|
|
23
|
+
}, [F]);
|
|
24
|
+
let G = t(() => {
|
|
25
|
+
W(!1), z.current?.focus();
|
|
26
|
+
}, [W]), K = t(() => {
|
|
27
|
+
W(!I.current);
|
|
28
|
+
}, [W]), ae = t((e) => {
|
|
29
|
+
let t = R.current;
|
|
30
|
+
if (!t) return;
|
|
31
|
+
let n = Array.from(t.querySelectorAll(p));
|
|
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] = o(null);
|
|
61
|
+
i(() => {
|
|
62
|
+
if (!F || !A || !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 = A.x, i = A.y;
|
|
67
|
+
r + e.width > t - m && (r = A.x - e.width), i + e.height > n - m && (i = A.y - e.height), r = Math.max(m, Math.min(r, t - m - e.width)), i = Math.max(m, Math.min(i, n - m - e.height)), J({
|
|
68
|
+
top: Math.round(i),
|
|
69
|
+
left: Math.round(r)
|
|
70
|
+
});
|
|
71
|
+
}, [
|
|
72
|
+
F,
|
|
73
|
+
A?.x,
|
|
74
|
+
A?.y
|
|
75
|
+
]);
|
|
76
|
+
let oe = t((e) => {
|
|
77
|
+
w?.(e), G();
|
|
78
|
+
}, [w, G]);
|
|
79
|
+
n(() => {
|
|
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 = ee(G, F), Y = te(z, F && D && !H), ce = { close: G }, X = S?.find((e) => e.value === C)?.label, Z = S ? X || re : e, Q = S && !X, le = S ? S.map((e) => /* @__PURE__ */ d("button", {
|
|
88
|
+
type: "button",
|
|
89
|
+
role: "menuitem",
|
|
90
|
+
className: c(l.item, e.disabled && l.itemDisabled, e.value === C && l.itemSelected, j?.item),
|
|
91
|
+
disabled: e.disabled,
|
|
92
|
+
onClick: () => oe(e.value),
|
|
93
|
+
children: e.label
|
|
94
|
+
}, e.value)) : h, $ = (e) => /* @__PURE__ */ d("div", {
|
|
95
|
+
ref: R,
|
|
96
|
+
id: B,
|
|
97
|
+
className: c(l.menu, F && l.menuOpen, g === "left" ? l.alignLeft : l.alignRight, !D && E && l.fullWidth, j?.menu),
|
|
98
|
+
style: e,
|
|
99
|
+
role: "menu",
|
|
100
|
+
onKeyDown: ae,
|
|
101
|
+
children: /* @__PURE__ */ d(u, {
|
|
102
|
+
value: se,
|
|
103
|
+
children: /* @__PURE__ */ d(ne.Provider, {
|
|
104
|
+
value: ce,
|
|
105
|
+
children: le
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
return V ? /* @__PURE__ */ f("div", {
|
|
110
|
+
ref: M,
|
|
111
|
+
className: c(l.root, U && E && l.fullWidth, j?.root, _),
|
|
112
|
+
style: v,
|
|
113
|
+
children: [U && /* @__PURE__ */ d("div", {
|
|
114
|
+
ref: L,
|
|
115
|
+
style: E ? { width: "100%" } : void 0,
|
|
116
|
+
children: /* @__PURE__ */ f("button", {
|
|
117
|
+
ref: z,
|
|
118
|
+
id: y,
|
|
119
|
+
type: "button",
|
|
120
|
+
className: c(l.trigger, F && l.triggerOpen, T && l.triggerError, E && l.fullWidth, j?.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: c(l.triggerLabel, Q && l.placeholder, j?.triggerLabel),
|
|
127
|
+
children: Z
|
|
128
|
+
}), /* @__PURE__ */ d("span", {
|
|
129
|
+
className: c(l.chevron, j?.chevron),
|
|
130
|
+
"aria-hidden": "true"
|
|
131
|
+
})]
|
|
132
|
+
})
|
|
133
|
+
}), F && H && typeof document < "u" && s($({
|
|
134
|
+
position: "fixed",
|
|
135
|
+
top: q?.top ?? A.y,
|
|
136
|
+
left: q?.left ?? A.x,
|
|
137
|
+
visibility: q ? void 0 : "hidden",
|
|
138
|
+
zIndex: "var(--crk-z-floating)"
|
|
139
|
+
}), document.body)]
|
|
140
|
+
}) : /* @__PURE__ */ f("div", {
|
|
141
|
+
ref: M,
|
|
142
|
+
className: c(l.root, E && l.fullWidth, j?.root, _),
|
|
143
|
+
style: v,
|
|
144
|
+
children: [/* @__PURE__ */ f("div", {
|
|
145
|
+
ref: L,
|
|
146
|
+
style: E ? { width: "100%" } : void 0,
|
|
147
|
+
children: [/* @__PURE__ */ f("button", {
|
|
148
|
+
ref: z,
|
|
149
|
+
id: y,
|
|
150
|
+
type: "button",
|
|
151
|
+
className: c(l.trigger, F && l.triggerOpen, T && l.triggerError, E && l.fullWidth, j?.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: c(l.triggerLabel, Q && l.placeholder, j?.triggerLabel),
|
|
158
|
+
children: Z
|
|
159
|
+
}), /* @__PURE__ */ d("span", {
|
|
160
|
+
className: c(l.chevron, j?.chevron),
|
|
161
|
+
"aria-hidden": "true"
|
|
162
|
+
})]
|
|
163
|
+
}), !D && $()]
|
|
164
|
+
}), D && F && typeof document < "u" && s($({
|
|
165
|
+
position: "fixed",
|
|
166
|
+
top: Y.top + 4,
|
|
167
|
+
left: g === "right" ? void 0 : Y.left,
|
|
168
|
+
right: g === "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
|
+
h.displayName = "Dropdown";
|
|
175
|
+
export { h as Dropdown };
|