@overdoser/react-toolkit 0.21.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 +1 -0
- package/CHANGELOG.md +27 -0
- package/components/Accordion/Accordion.js +48 -48
- package/components/ActionButton/ActionButton.js +23 -23
- package/components/ActionButton/CopyButton.js +5 -5
- package/components/Alert/Alert.js +13 -13
- package/components/Avatar/Avatar.js +12 -12
- package/components/Badge/Badge.js +6 -6
- package/components/Breadcrumbs/Breadcrumbs.js +15 -15
- package/components/Button/Button.js +14 -14
- package/components/Card/Card.js +26 -26
- package/components/Chart/AreaChart.js +103 -103
- package/components/Chart/Axis.js +7 -7
- package/components/Chart/BarChart.js +62 -62
- package/components/Chart/ChartContainer.js +11 -11
- package/components/Chart/ChartLegend.js +7 -7
- package/components/Chart/ChartTooltip.js +13 -13
- package/components/Chart/LineChart.js +88 -88
- package/components/Chart/PieChart.js +25 -25
- package/components/Chart/RadarChart.js +42 -42
- package/components/Chart/Sparkline.js +11 -11
- package/components/Chart/TradingChart.js +126 -126
- package/components/Chart/trading/period.js +3 -3
- package/components/Chip/Chip.js +24 -24
- package/components/CodeBlock/CodeBlock.js +31 -31
- package/components/CommandPalette/CommandPalette.js +166 -166
- package/components/ConfirmDialog/ConfirmDialog.js +60 -60
- package/components/Divider/Divider.js +10 -10
- package/components/Draggable/Draggable.js +29 -29
- package/components/Drawer/Drawer.js +53 -53
- package/components/Dropdown/Dropdown.js +66 -66
- package/components/Dropdown/DropdownItem.js +13 -13
- package/components/Dropdown/DropdownLabel.js +5 -5
- package/components/Dropdown/DropdownSeparator.js +5 -5
- package/components/Dropzone/Dropzone.js +15 -15
- package/components/EmptyState/EmptyState.js +11 -11
- package/components/Form/Form.js +17 -17
- package/components/Form/FormField.js +21 -21
- package/components/Form/FormRow.js +3 -3
- package/components/ImageViewer/ImageViewer.js +118 -118
- package/components/Kbd/Kbd.js +11 -11
- package/components/KeyValueList/KeyValueList.js +32 -32
- package/components/Link/Link.js +7 -7
- package/components/List/List.js +7 -7
- package/components/Loader/Loader.js +39 -39
- package/components/Modal/Modal.js +48 -48
- package/components/PageHeader/PageHeader.js +18 -18
- package/components/Pagination/Pagination.js +23 -23
- package/components/Popover/Popover.js +25 -25
- package/components/ProgressBar/ProgressBar.js +17 -17
- package/components/RelativeTime/RelativeTime.js +10 -10
- package/components/SegmentedControl/SegmentedControl.js +38 -38
- package/components/Skeleton/Skeleton.js +10 -10
- package/components/Spinner/Spinner.js +7 -7
- package/components/SplitButton/SplitButton.js +63 -63
- package/components/SplitPane/SplitPane.js +50 -50
- package/components/StatCard/StatCard.js +32 -32
- package/components/StatusDot/StatusDot.js +7 -7
- package/components/Table/Table.js +174 -174
- package/components/Tabs/Tabs.js +47 -47
- package/components/ThemeToggle/ThemeToggle.js +31 -31
- package/components/Timeline/GanttTimeline.js +213 -213
- package/components/Timeline/HistoryTimeline.js +306 -306
- package/components/Timeline/TimelineShared.js +103 -103
- package/components/Timeline/TraceEventDetails.js +103 -103
- package/components/Timeline/TraceTimeline.js +546 -546
- package/components/Timeline/historyLayout.js +2 -2
- package/components/Timer/Timer.js +39 -39
- package/components/Toast/Toast.js +59 -59
- package/components/ToggleIconButton/ToggleIconButton.js +9 -9
- package/components/Tooltip/Tooltip.js +16 -16
- package/components/Typography/Typography.js +5 -5
- package/components/inputs/Checkbox/Checkbox.js +11 -11
- package/components/inputs/Checkbox/CheckboxGroup.js +21 -21
- package/components/inputs/DatePicker/CalendarPanel.js +113 -113
- package/components/inputs/DatePicker/DatePicker.js +39 -39
- package/components/inputs/DateTimePicker/DateTimePicker.js +119 -119
- package/components/inputs/DateTimePicker/DateTimeSegments.js +40 -40
- package/components/inputs/DateTimePicker/TimeField.js +34 -34
- package/components/inputs/Input/Input.js +13 -13
- package/components/inputs/NumberInput/NumberInput.js +16 -16
- package/components/inputs/Radio/Radio.js +17 -17
- package/components/inputs/SearchInput/SearchInput.js +25 -25
- package/components/inputs/Select/Select.d.ts +55 -3
- package/components/inputs/Select/Select.js +485 -344
- package/components/inputs/Select/{Select.module.js → Select.module.scss.js} +15 -3
- package/components/inputs/Slider/Slider.js +21 -21
- package/components/inputs/Switch/Switch.js +4 -4
- package/components/inputs/Textarea/Textarea.js +8 -8
- package/hooks/usePortalPosition.d.ts +2 -1
- package/hooks/usePortalPosition.js +6 -3
- package/hooks/useResizable.js +1 -1
- package/hooks/useTheme.js +7 -7
- package/index.css +1 -1
- package/index.js +1 -1
- package/index.layered.css +1 -1
- package/llms.txt +25 -4
- package/manifest.json +33 -4
- package/package.json +1 -1
- /package/components/Accordion/{Accordion.module.js → Accordion.module.scss.js} +0 -0
- /package/components/ActionButton/{ActionButton.module.js → ActionButton.module.scss.js} +0 -0
- /package/components/Alert/{Alert.module.js → Alert.module.scss.js} +0 -0
- /package/components/Avatar/{Avatar.module.js → Avatar.module.scss.js} +0 -0
- /package/components/Badge/{Badge.module.js → Badge.module.scss.js} +0 -0
- /package/components/Breadcrumbs/{Breadcrumbs.module.js → Breadcrumbs.module.scss.js} +0 -0
- /package/components/Button/{Button.module.js → Button.module.scss.js} +0 -0
- /package/components/Card/{Card.module.js → Card.module.scss.js} +0 -0
- /package/components/Chart/{Chart.module.js → Chart.module.scss.js} +0 -0
- /package/components/Chip/{Chip.module.js → Chip.module.scss.js} +0 -0
- /package/components/CodeBlock/{CodeBlock.module.js → CodeBlock.module.scss.js} +0 -0
- /package/components/CommandPalette/{CommandPalette.module.js → CommandPalette.module.scss.js} +0 -0
- /package/components/ConfirmDialog/{ConfirmDialog.module.js → ConfirmDialog.module.scss.js} +0 -0
- /package/components/Divider/{Divider.module.js → Divider.module.scss.js} +0 -0
- /package/components/Draggable/{Draggable.module.js → Draggable.module.scss.js} +0 -0
- /package/components/Drawer/{Drawer.module.js → Drawer.module.scss.js} +0 -0
- /package/components/Dropdown/{Dropdown.module.js → Dropdown.module.scss.js} +0 -0
- /package/components/Dropzone/{Dropzone.module.js → Dropzone.module.scss.js} +0 -0
- /package/components/EmptyState/{EmptyState.module.js → EmptyState.module.scss.js} +0 -0
- /package/components/Form/{Form.module.js → Form.module.scss.js} +0 -0
- /package/components/ImageViewer/{ImageViewer.module.js → ImageViewer.module.scss.js} +0 -0
- /package/components/Kbd/{Kbd.module.js → Kbd.module.scss.js} +0 -0
- /package/components/KeyValueList/{KeyValueList.module.js → KeyValueList.module.scss.js} +0 -0
- /package/components/Link/{Link.module.js → Link.module.scss.js} +0 -0
- /package/components/List/{List.module.js → List.module.scss.js} +0 -0
- /package/components/Loader/{Loader.module.js → Loader.module.scss.js} +0 -0
- /package/components/Modal/{Modal.module.js → Modal.module.scss.js} +0 -0
- /package/components/PageHeader/{PageHeader.module.js → PageHeader.module.scss.js} +0 -0
- /package/components/Pagination/{Pagination.module.js → Pagination.module.scss.js} +0 -0
- /package/components/Popover/{Popover.module.js → Popover.module.scss.js} +0 -0
- /package/components/ProgressBar/{ProgressBar.module.js → ProgressBar.module.scss.js} +0 -0
- /package/components/RelativeTime/{RelativeTime.module.js → RelativeTime.module.scss.js} +0 -0
- /package/components/SegmentedControl/{SegmentedControl.module.js → SegmentedControl.module.scss.js} +0 -0
- /package/components/Skeleton/{Skeleton.module.js → Skeleton.module.scss.js} +0 -0
- /package/components/Spinner/{Spinner.module.js → Spinner.module.scss.js} +0 -0
- /package/components/SplitButton/{SplitButton.module.js → SplitButton.module.scss.js} +0 -0
- /package/components/SplitPane/{SplitPane.module.js → SplitPane.module.scss.js} +0 -0
- /package/components/StatCard/{StatCard.module.js → StatCard.module.scss.js} +0 -0
- /package/components/StatusDot/{StatusDot.module.js → StatusDot.module.scss.js} +0 -0
- /package/components/Table/{Table.module.js → Table.module.scss.js} +0 -0
- /package/components/Tabs/{Tabs.module.js → Tabs.module.scss.js} +0 -0
- /package/components/ThemeToggle/{ThemeToggle.module.js → ThemeToggle.module.scss.js} +0 -0
- /package/components/Timeline/{GanttTimeline.module.js → GanttTimeline.module.scss.js} +0 -0
- /package/components/Timeline/{HistoryTimeline.module.js → HistoryTimeline.module.scss.js} +0 -0
- /package/components/Timeline/{Timeline.module.js → Timeline.module.scss.js} +0 -0
- /package/components/Timeline/{TraceTimeline.module.js → TraceTimeline.module.scss.js} +0 -0
- /package/components/Timer/{Timer.module.js → Timer.module.scss.js} +0 -0
- /package/components/Toast/{Toast.module.js → Toast.module.scss.js} +0 -0
- /package/components/ToggleIconButton/{ToggleIconButton.module.js → ToggleIconButton.module.scss.js} +0 -0
- /package/components/Tooltip/{Tooltip.module.js → Tooltip.module.scss.js} +0 -0
- /package/components/Typography/{Typography.module.js → Typography.module.scss.js} +0 -0
- /package/components/inputs/Checkbox/{Checkbox.module.js → Checkbox.module.scss.js} +0 -0
- /package/components/inputs/Checkbox/{CheckboxGroup.module.js → CheckboxGroup.module.scss.js} +0 -0
- /package/components/inputs/DatePicker/{CalendarPanel.module.js → CalendarPanel.module.scss.js} +0 -0
- /package/components/inputs/DatePicker/{DatePicker.module.js → DatePicker.module.scss.js} +0 -0
- /package/components/inputs/DateTimePicker/{DateTimePicker.module.js → DateTimePicker.module.scss.js} +0 -0
- /package/components/inputs/Input/{Input.module.js → Input.module.scss.js} +0 -0
- /package/components/inputs/NumberInput/{NumberInput.module.js → NumberInput.module.scss.js} +0 -0
- /package/components/inputs/Radio/{Radio.module.js → Radio.module.scss.js} +0 -0
- /package/components/inputs/SearchInput/{SearchInput.module.js → SearchInput.module.scss.js} +0 -0
- /package/components/inputs/Slider/{Slider.module.js → Slider.module.scss.js} +0 -0
- /package/components/inputs/Textarea/{Textarea.module.js → Textarea.module.scss.js} +0 -0
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
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";
|
|
7
8
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
|
-
import { createPortal as p } from "react-dom";
|
|
9
9
|
// src/components/Dropdown/Dropdown.tsx
|
|
10
|
-
var
|
|
11
|
-
let [
|
|
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
12
|
I.current = F;
|
|
13
|
-
let L =
|
|
14
|
-
e !== I.current && (P || ie(e),
|
|
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
15
|
}, [
|
|
16
16
|
P,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
k,
|
|
18
|
+
b,
|
|
19
|
+
x
|
|
20
20
|
]);
|
|
21
|
-
|
|
22
|
-
F && R.current && R.current.querySelector(
|
|
21
|
+
n(() => {
|
|
22
|
+
F && R.current && R.current.querySelector(p)?.focus();
|
|
23
23
|
}, [F]);
|
|
24
|
-
let G =
|
|
24
|
+
let G = t(() => {
|
|
25
25
|
W(!1), z.current?.focus();
|
|
26
|
-
}, [W]), K =
|
|
26
|
+
}, [W]), K = t(() => {
|
|
27
27
|
W(!I.current);
|
|
28
|
-
}, [W]), ae =
|
|
28
|
+
}, [W]), ae = t((e) => {
|
|
29
29
|
let t = R.current;
|
|
30
30
|
if (!t) return;
|
|
31
|
-
let n = Array.from(t.querySelectorAll(
|
|
31
|
+
let n = Array.from(t.querySelectorAll(p));
|
|
32
32
|
if (n.length === 0) return;
|
|
33
33
|
let r = n.indexOf(document.activeElement), i = (e) => {
|
|
34
34
|
n[(e + n.length) % n.length]?.focus();
|
|
@@ -57,26 +57,26 @@ var m = "[role=\"menuitem\"]:not(:disabled), [role=\"menuitemcheckbox\"]:not(:di
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
}, []), [q, J] =
|
|
61
|
-
|
|
62
|
-
if (!F || !
|
|
60
|
+
}, []), [q, J] = o(null);
|
|
61
|
+
i(() => {
|
|
62
|
+
if (!F || !A || !R.current || typeof window > "u") {
|
|
63
63
|
J(null);
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
let e = R.current.getBoundingClientRect(), t = document.documentElement.clientWidth || window.innerWidth, n = document.documentElement.clientHeight || window.innerHeight, r =
|
|
67
|
-
r + e.width > t -
|
|
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
68
|
top: Math.round(i),
|
|
69
69
|
left: Math.round(r)
|
|
70
70
|
});
|
|
71
71
|
}, [
|
|
72
72
|
F,
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
A?.x,
|
|
74
|
+
A?.y
|
|
75
75
|
]);
|
|
76
|
-
let oe =
|
|
77
|
-
|
|
78
|
-
}, [
|
|
79
|
-
|
|
76
|
+
let oe = t((e) => {
|
|
77
|
+
w?.(e), G();
|
|
78
|
+
}, [w, G]);
|
|
79
|
+
n(() => {
|
|
80
80
|
if (!F) return;
|
|
81
81
|
let e = (e) => {
|
|
82
82
|
let t = e.target;
|
|
@@ -84,92 +84,92 @@ var m = "[role=\"menuitem\"]:not(:disabled), [role=\"menuitemcheckbox\"]:not(:di
|
|
|
84
84
|
};
|
|
85
85
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
86
86
|
}, [F, G]);
|
|
87
|
-
let se =
|
|
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
88
|
type: "button",
|
|
89
89
|
role: "menuitem",
|
|
90
|
-
className:
|
|
91
|
-
disabled:
|
|
92
|
-
onClick: () => oe(
|
|
93
|
-
children:
|
|
94
|
-
},
|
|
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
95
|
ref: R,
|
|
96
96
|
id: B,
|
|
97
|
-
className:
|
|
98
|
-
style:
|
|
97
|
+
className: c(l.menu, F && l.menuOpen, g === "left" ? l.alignLeft : l.alignRight, !D && E && l.fullWidth, j?.menu),
|
|
98
|
+
style: e,
|
|
99
99
|
role: "menu",
|
|
100
100
|
onKeyDown: ae,
|
|
101
|
-
children: /* @__PURE__ */ d(
|
|
101
|
+
children: /* @__PURE__ */ d(u, {
|
|
102
102
|
value: se,
|
|
103
|
-
children: /* @__PURE__ */ d(
|
|
103
|
+
children: /* @__PURE__ */ d(ne.Provider, {
|
|
104
104
|
value: ce,
|
|
105
105
|
children: le
|
|
106
106
|
})
|
|
107
107
|
})
|
|
108
108
|
});
|
|
109
109
|
return V ? /* @__PURE__ */ f("div", {
|
|
110
|
-
ref:
|
|
111
|
-
className:
|
|
112
|
-
style:
|
|
110
|
+
ref: M,
|
|
111
|
+
className: c(l.root, U && E && l.fullWidth, j?.root, _),
|
|
112
|
+
style: v,
|
|
113
113
|
children: [U && /* @__PURE__ */ d("div", {
|
|
114
114
|
ref: L,
|
|
115
|
-
style:
|
|
115
|
+
style: E ? { width: "100%" } : void 0,
|
|
116
116
|
children: /* @__PURE__ */ f("button", {
|
|
117
117
|
ref: z,
|
|
118
|
-
id:
|
|
118
|
+
id: y,
|
|
119
119
|
type: "button",
|
|
120
|
-
className:
|
|
120
|
+
className: c(l.trigger, F && l.triggerOpen, T && l.triggerError, E && l.fullWidth, j?.trigger),
|
|
121
121
|
onClick: K,
|
|
122
122
|
"aria-expanded": F,
|
|
123
123
|
"aria-haspopup": "menu",
|
|
124
124
|
"aria-controls": F ? B : void 0,
|
|
125
125
|
children: [/* @__PURE__ */ d("span", {
|
|
126
|
-
className:
|
|
126
|
+
className: c(l.triggerLabel, Q && l.placeholder, j?.triggerLabel),
|
|
127
127
|
children: Z
|
|
128
128
|
}), /* @__PURE__ */ d("span", {
|
|
129
|
-
className:
|
|
129
|
+
className: c(l.chevron, j?.chevron),
|
|
130
130
|
"aria-hidden": "true"
|
|
131
131
|
})]
|
|
132
132
|
})
|
|
133
|
-
}), F && H && typeof document < "u" &&
|
|
133
|
+
}), F && H && typeof document < "u" && s($({
|
|
134
134
|
position: "fixed",
|
|
135
|
-
top: q?.top ??
|
|
136
|
-
left: q?.left ??
|
|
135
|
+
top: q?.top ?? A.y,
|
|
136
|
+
left: q?.left ?? A.x,
|
|
137
137
|
visibility: q ? void 0 : "hidden",
|
|
138
138
|
zIndex: "var(--crk-z-floating)"
|
|
139
139
|
}), document.body)]
|
|
140
140
|
}) : /* @__PURE__ */ f("div", {
|
|
141
|
-
ref:
|
|
142
|
-
className:
|
|
143
|
-
style:
|
|
141
|
+
ref: M,
|
|
142
|
+
className: c(l.root, E && l.fullWidth, j?.root, _),
|
|
143
|
+
style: v,
|
|
144
144
|
children: [/* @__PURE__ */ f("div", {
|
|
145
145
|
ref: L,
|
|
146
|
-
style:
|
|
146
|
+
style: E ? { width: "100%" } : void 0,
|
|
147
147
|
children: [/* @__PURE__ */ f("button", {
|
|
148
148
|
ref: z,
|
|
149
|
-
id:
|
|
149
|
+
id: y,
|
|
150
150
|
type: "button",
|
|
151
|
-
className:
|
|
151
|
+
className: c(l.trigger, F && l.triggerOpen, T && l.triggerError, E && l.fullWidth, j?.trigger),
|
|
152
152
|
onClick: K,
|
|
153
153
|
"aria-expanded": F,
|
|
154
154
|
"aria-haspopup": "menu",
|
|
155
155
|
"aria-controls": F ? B : void 0,
|
|
156
156
|
children: [/* @__PURE__ */ d("span", {
|
|
157
|
-
className:
|
|
157
|
+
className: c(l.triggerLabel, Q && l.placeholder, j?.triggerLabel),
|
|
158
158
|
children: Z
|
|
159
159
|
}), /* @__PURE__ */ d("span", {
|
|
160
|
-
className:
|
|
160
|
+
className: c(l.chevron, j?.chevron),
|
|
161
161
|
"aria-hidden": "true"
|
|
162
162
|
})]
|
|
163
|
-
}), !
|
|
164
|
-
}),
|
|
163
|
+
}), !D && $()]
|
|
164
|
+
}), D && F && typeof document < "u" && s($({
|
|
165
165
|
position: "fixed",
|
|
166
166
|
top: Y.top + 4,
|
|
167
|
-
left:
|
|
168
|
-
right:
|
|
167
|
+
left: g === "right" ? void 0 : Y.left,
|
|
168
|
+
right: g === "right" ? document.documentElement.clientWidth - (Y.left + Y.width) : void 0,
|
|
169
169
|
minWidth: Y.width,
|
|
170
170
|
zIndex: "var(--crk-z-floating)"
|
|
171
171
|
}), document.body)]
|
|
172
172
|
});
|
|
173
173
|
});
|
|
174
|
-
|
|
175
|
-
export {
|
|
174
|
+
h.displayName = "Dropdown";
|
|
175
|
+
export { h as Dropdown };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import i from "
|
|
1
|
+
import { forwardRef as e, useContext as t } from "react";
|
|
2
|
+
import n from "clsx";
|
|
3
|
+
import r from "./Dropdown.module.scss.js";
|
|
4
|
+
import { DropdownMenuContext as i } from "./dropdownContext.js";
|
|
5
5
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
6
|
// src/components/Dropdown/DropdownItem.tsx
|
|
7
|
-
var s =
|
|
8
|
-
let y =
|
|
7
|
+
var s = e(({ disabled: e = !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 = t(i), b = u !== void 0, x = f ?? !b;
|
|
9
9
|
return /* @__PURE__ */ o("button", {
|
|
10
10
|
ref: v,
|
|
11
11
|
type: "button",
|
|
12
12
|
role: b ? "menuitemcheckbox" : "menuitem",
|
|
13
13
|
"aria-checked": b ? u : void 0,
|
|
14
|
-
className:
|
|
15
|
-
disabled:
|
|
14
|
+
className: n(r.item, e && r.itemDisabled, s && r.itemDanger, b && u && r.itemChecked, p?.item, m),
|
|
15
|
+
disabled: e,
|
|
16
16
|
onClick: (e) => {
|
|
17
17
|
g?.(e), x && !e.defaultPrevented && y?.close();
|
|
18
18
|
},
|
|
19
19
|
..._,
|
|
20
20
|
children: [
|
|
21
21
|
b && /* @__PURE__ */ a("span", {
|
|
22
|
-
className:
|
|
22
|
+
className: n(r.itemCheck, p?.itemCheck),
|
|
23
23
|
"aria-hidden": "true",
|
|
24
24
|
children: u && /* @__PURE__ */ a("svg", {
|
|
25
25
|
viewBox: "0 0 16 16",
|
|
@@ -32,19 +32,19 @@ var s = n(({ disabled: n = !1, danger: s = !1, icon: c, shortcut: l, checked: u,
|
|
|
32
32
|
})
|
|
33
33
|
}),
|
|
34
34
|
c != null && /* @__PURE__ */ a("span", {
|
|
35
|
-
className:
|
|
35
|
+
className: n(r.itemIcon, p?.itemIcon),
|
|
36
36
|
"aria-hidden": "true",
|
|
37
37
|
children: c
|
|
38
38
|
}),
|
|
39
39
|
/* @__PURE__ */ o("span", {
|
|
40
|
-
className:
|
|
40
|
+
className: n(r.itemLabel, p?.itemLabel),
|
|
41
41
|
children: [h, d != null && /* @__PURE__ */ a("span", {
|
|
42
|
-
className:
|
|
42
|
+
className: n(r.itemDescription, p?.itemDescription),
|
|
43
43
|
children: d
|
|
44
44
|
})]
|
|
45
45
|
}),
|
|
46
46
|
l != null && /* @__PURE__ */ a("span", {
|
|
47
|
-
className:
|
|
47
|
+
className: n(r.itemShortcut, p?.itemShortcut),
|
|
48
48
|
"aria-hidden": "true",
|
|
49
49
|
children: l
|
|
50
50
|
})
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
import n from "
|
|
1
|
+
import { forwardRef as e } from "react";
|
|
2
|
+
import t from "clsx";
|
|
3
|
+
import n from "./Dropdown.module.scss.js";
|
|
4
4
|
import { jsx as r } from "react/jsx-runtime";
|
|
5
5
|
// src/components/Dropdown/DropdownLabel.tsx
|
|
6
|
-
var i =
|
|
6
|
+
var i = e(({ className: e, children: i, ...a }, o) => /* @__PURE__ */ r("div", {
|
|
7
7
|
ref: o,
|
|
8
8
|
role: "presentation",
|
|
9
|
-
className: n
|
|
9
|
+
className: t(n.label, e),
|
|
10
10
|
...a,
|
|
11
11
|
children: i
|
|
12
12
|
}));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
import n from "
|
|
1
|
+
import { forwardRef as e } from "react";
|
|
2
|
+
import t from "clsx";
|
|
3
|
+
import n from "./Dropdown.module.scss.js";
|
|
4
4
|
import { jsx as r } from "react/jsx-runtime";
|
|
5
5
|
// src/components/Dropdown/DropdownSeparator.tsx
|
|
6
|
-
var i =
|
|
6
|
+
var i = e(({ className: e, ...i }, a) => /* @__PURE__ */ r("div", {
|
|
7
7
|
ref: a,
|
|
8
8
|
role: "separator",
|
|
9
|
-
className: n
|
|
9
|
+
className: t(n.separator, e),
|
|
10
10
|
...i
|
|
11
11
|
}));
|
|
12
12
|
i.displayName = "DropdownSeparator";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
import a from "
|
|
1
|
+
import { forwardRef as e, useId as t, useRef as n, useState as r } from "react";
|
|
2
|
+
import i from "clsx";
|
|
3
|
+
import a from "./Dropzone.module.scss.js";
|
|
4
4
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
5
|
// src/components/Dropzone/Dropzone.tsx
|
|
6
6
|
function c(e, t) {
|
|
@@ -10,12 +10,12 @@ function c(e, t) {
|
|
|
10
10
|
function l(e, t) {
|
|
11
11
|
return !t || t.split(",").some((t) => c(e, t));
|
|
12
12
|
}
|
|
13
|
-
var u =
|
|
14
|
-
let S =
|
|
13
|
+
var u = e(({ onFiles: e, onReject: c, accept: u, multiple: d = !1, maxSize: f, disabled: p = !1, label: m = "Drag & drop files here, or click to browse", hint: h, children: g, classes: _, className: v, style: y, "aria-label": b = "Upload files" }, x) => {
|
|
14
|
+
let S = n(null), [C, w] = r(!1), T = n(0), E = t(), D = (e) => {
|
|
15
15
|
S.current = e, typeof x == "function" ? x(e) : x && (x.current = e);
|
|
16
|
-
}, O = (
|
|
17
|
-
if (!
|
|
18
|
-
let n = Array.from(
|
|
16
|
+
}, O = (t) => {
|
|
17
|
+
if (!t || p) return;
|
|
18
|
+
let n = Array.from(t), r = [];
|
|
19
19
|
!d && n.length > 1 && (n.slice(1).forEach((e) => r.push({
|
|
20
20
|
file: e,
|
|
21
21
|
reason: "multiple"
|
|
@@ -28,7 +28,7 @@ var u = t(({ onFiles: t, onReject: c, accept: u, multiple: d = !1, maxSize: f, d
|
|
|
28
28
|
file: e,
|
|
29
29
|
reason: "type"
|
|
30
30
|
});
|
|
31
|
-
i.length &&
|
|
31
|
+
i.length && e?.(i), r.length && c?.(r);
|
|
32
32
|
}, k = () => {
|
|
33
33
|
p || S.current?.click();
|
|
34
34
|
};
|
|
@@ -38,7 +38,7 @@ var u = t(({ onFiles: t, onReject: c, accept: u, multiple: d = !1, maxSize: f, d
|
|
|
38
38
|
"aria-label": b,
|
|
39
39
|
"aria-disabled": p || void 0,
|
|
40
40
|
"aria-describedby": h ? `${E}-hint` : void 0,
|
|
41
|
-
className: a
|
|
41
|
+
className: i(a.root, C && a.dragging, p && a.disabled, _?.root, v),
|
|
42
42
|
style: y,
|
|
43
43
|
onClick: k,
|
|
44
44
|
onKeyDown: (e) => {
|
|
@@ -60,7 +60,7 @@ var u = t(({ onFiles: t, onReject: c, accept: u, multiple: d = !1, maxSize: f, d
|
|
|
60
60
|
ref: D,
|
|
61
61
|
id: E,
|
|
62
62
|
type: "file",
|
|
63
|
-
className: a
|
|
63
|
+
className: i(a.input, _?.input),
|
|
64
64
|
accept: u,
|
|
65
65
|
multiple: d,
|
|
66
66
|
disabled: p,
|
|
@@ -69,10 +69,10 @@ var u = t(({ onFiles: t, onReject: c, accept: u, multiple: d = !1, maxSize: f, d
|
|
|
69
69
|
O(e.target.files), e.target.value = "";
|
|
70
70
|
}
|
|
71
71
|
}), typeof g == "function" ? g({ isDragging: C }) : g ?? /* @__PURE__ */ s("div", {
|
|
72
|
-
className: a
|
|
72
|
+
className: i(a.content, _?.content),
|
|
73
73
|
children: [
|
|
74
74
|
/* @__PURE__ */ o("span", {
|
|
75
|
-
className: a
|
|
75
|
+
className: i(a.icon, _?.icon),
|
|
76
76
|
"aria-hidden": "true",
|
|
77
77
|
children: /* @__PURE__ */ s("svg", {
|
|
78
78
|
viewBox: "0 0 24 24",
|
|
@@ -85,12 +85,12 @@ var u = t(({ onFiles: t, onReject: c, accept: u, multiple: d = !1, maxSize: f, d
|
|
|
85
85
|
})
|
|
86
86
|
}),
|
|
87
87
|
/* @__PURE__ */ o("span", {
|
|
88
|
-
className: a
|
|
88
|
+
className: i(a.label, _?.label),
|
|
89
89
|
children: m
|
|
90
90
|
}),
|
|
91
91
|
h != null && /* @__PURE__ */ o("span", {
|
|
92
92
|
id: `${E}-hint`,
|
|
93
|
-
className: a
|
|
93
|
+
className: i(a.hint, _?.hint),
|
|
94
94
|
children: h
|
|
95
95
|
})
|
|
96
96
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
import n from "
|
|
1
|
+
import { forwardRef as e } from "react";
|
|
2
|
+
import t from "clsx";
|
|
3
|
+
import n from "./EmptyState.module.scss.js";
|
|
4
4
|
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
5
|
// src/components/EmptyState/EmptyState.tsx
|
|
6
6
|
var a = () => /* @__PURE__ */ i("svg", {
|
|
@@ -25,30 +25,30 @@ var a = () => /* @__PURE__ */ i("svg", {
|
|
|
25
25
|
/* @__PURE__ */ r("path", { d: "M12 9v4" }),
|
|
26
26
|
/* @__PURE__ */ r("path", { d: "M12 17h.01" })
|
|
27
27
|
]
|
|
28
|
-
}), s =
|
|
29
|
-
let v = s === void 0 ? r(
|
|
28
|
+
}), s = e(({ variant: e = "empty", icon: s, title: c, description: l, action: u, children: d, size: f = "md", bordered: p = !1, classes: m, className: h, ...g }, _) => {
|
|
29
|
+
let v = s === void 0 ? r(e === "error" ? o : a, {}) : s;
|
|
30
30
|
return /* @__PURE__ */ i("div", {
|
|
31
31
|
ref: _,
|
|
32
|
-
role:
|
|
33
|
-
className: n
|
|
32
|
+
role: e === "error" ? "alert" : void 0,
|
|
33
|
+
className: t(n.root, n[e], n[f], p && n.bordered, m?.root, h),
|
|
34
34
|
...g,
|
|
35
35
|
children: [
|
|
36
36
|
v !== !1 && v != null && /* @__PURE__ */ r("div", {
|
|
37
|
-
className: n
|
|
37
|
+
className: t(n.icon, m?.icon),
|
|
38
38
|
"aria-hidden": "true",
|
|
39
39
|
children: v
|
|
40
40
|
}),
|
|
41
41
|
c && /* @__PURE__ */ r("div", {
|
|
42
|
-
className: n
|
|
42
|
+
className: t(n.title, m?.title),
|
|
43
43
|
children: c
|
|
44
44
|
}),
|
|
45
45
|
l && /* @__PURE__ */ r("div", {
|
|
46
|
-
className: n
|
|
46
|
+
className: t(n.description, m?.description),
|
|
47
47
|
children: l
|
|
48
48
|
}),
|
|
49
49
|
d,
|
|
50
50
|
u && /* @__PURE__ */ r("div", {
|
|
51
|
-
className: n
|
|
51
|
+
className: t(n.action, m?.action),
|
|
52
52
|
children: u
|
|
53
53
|
})
|
|
54
54
|
]
|
package/components/Form/Form.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import r from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { useMemo as e } from "react";
|
|
2
|
+
import { FormProvider as t } from "react-hook-form";
|
|
3
|
+
import n from "clsx";
|
|
4
|
+
import r from "./Form.module.scss.js";
|
|
5
|
+
import { FormFieldDefaultsContext as i } from "./formFieldDefaults.js";
|
|
6
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
7
|
// src/components/Form/Form.tsx
|
|
8
8
|
function s({ form: s, onSubmit: c, errors: l, reserveErrorSpace: u, fieldClasses: d, className: f, style: p, children: m }) {
|
|
9
|
-
let h = l && l.length > 0, g =
|
|
9
|
+
let h = l && l.length > 0, g = e(() => ({
|
|
10
10
|
reserveErrorSpace: u,
|
|
11
11
|
classes: d
|
|
12
12
|
}), [u, d]);
|
|
13
|
-
return /* @__PURE__ */
|
|
13
|
+
return /* @__PURE__ */ a(t, {
|
|
14
14
|
...s,
|
|
15
|
-
children: /* @__PURE__ */ i
|
|
15
|
+
children: /* @__PURE__ */ a(i.Provider, {
|
|
16
16
|
value: g,
|
|
17
|
-
children: /* @__PURE__ */
|
|
17
|
+
children: /* @__PURE__ */ o("form", {
|
|
18
18
|
onSubmit: s.handleSubmit(c),
|
|
19
|
-
className: r
|
|
19
|
+
className: n(r.root, u === !1 && r.rootLooseGap, f),
|
|
20
20
|
style: p,
|
|
21
|
-
children: [h && /* @__PURE__ */
|
|
22
|
-
className:
|
|
21
|
+
children: [h && /* @__PURE__ */ a("ul", {
|
|
22
|
+
className: r.formErrors,
|
|
23
23
|
role: "alert",
|
|
24
|
-
children: l.map((
|
|
25
|
-
className:
|
|
26
|
-
children:
|
|
27
|
-
},
|
|
24
|
+
children: l.map((e, t) => /* @__PURE__ */ a("li", {
|
|
25
|
+
className: r.formError,
|
|
26
|
+
children: e
|
|
27
|
+
}, t))
|
|
28
28
|
}), m]
|
|
29
29
|
})
|
|
30
30
|
})
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import {
|
|
3
|
-
import { cloneElement as n, useCallback as r, useContext as i, useRef as a } from "react";
|
|
1
|
+
import { cloneElement as e, useCallback as t, useContext as n, useRef as r } from "react";
|
|
2
|
+
import { useController as i, useFormContext as a } from "react-hook-form";
|
|
4
3
|
import o from "clsx";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
4
|
+
import s from "./Form.module.scss.js";
|
|
5
|
+
import { FormFieldDefaultsContext as c } from "./formFieldDefaults.js";
|
|
6
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
7
|
// src/components/Form/FormField.tsx
|
|
8
8
|
var d = /* @__PURE__ */ new Set([
|
|
9
9
|
"Select",
|
|
@@ -13,31 +13,31 @@ var d = /* @__PURE__ */ new Set([
|
|
|
13
13
|
"Dropdown"
|
|
14
14
|
]);
|
|
15
15
|
function f({ name: f, label: p, helperText: m, required: h, rules: g, reserveErrorSpace: _, classes: v, className: y, style: b, children: x }) {
|
|
16
|
-
let { control: S } =
|
|
16
|
+
let { control: S } = a(), { field: C, fieldState: w } = i({
|
|
17
17
|
name: f,
|
|
18
18
|
control: S,
|
|
19
19
|
rules: g
|
|
20
|
-
}), T =
|
|
20
|
+
}), T = n(c), E = _ ?? T?.reserveErrorSpace ?? !0, D = T?.classes, O = x.type, k = typeof O == "string" ? "" : O?.displayName ?? O?.name ?? "", A = d.has(k), { ref: j, ...M } = C, N = typeof M.value == "boolean", P = r(j);
|
|
21
21
|
P.current = j;
|
|
22
|
-
let F =
|
|
22
|
+
let F = t((e) => {
|
|
23
23
|
if (e) {
|
|
24
24
|
let t = e.matches("input, select, textarea, button, [tabindex]") ? e : e.querySelector("input, select, textarea, button, [tabindex]:not([tabindex=\"-1\"])");
|
|
25
25
|
P.current(t ?? e);
|
|
26
26
|
} else P.current(null);
|
|
27
27
|
}, []);
|
|
28
|
-
return /* @__PURE__ */
|
|
29
|
-
className: o(
|
|
28
|
+
return /* @__PURE__ */ u("div", {
|
|
29
|
+
className: o(s.field, D?.field, v?.field, y),
|
|
30
30
|
style: b,
|
|
31
31
|
children: [
|
|
32
|
-
p && /* @__PURE__ */
|
|
33
|
-
className: o(
|
|
32
|
+
p && /* @__PURE__ */ u("label", {
|
|
33
|
+
className: o(s.label, w.error && s.labelError, D?.label, v?.label),
|
|
34
34
|
htmlFor: f,
|
|
35
|
-
children: [p, h && /* @__PURE__ */
|
|
36
|
-
className:
|
|
35
|
+
children: [p, h && /* @__PURE__ */ l("span", {
|
|
36
|
+
className: s.required,
|
|
37
37
|
children: "*"
|
|
38
38
|
})]
|
|
39
39
|
}),
|
|
40
|
-
|
|
40
|
+
e(x, {
|
|
41
41
|
...M,
|
|
42
42
|
...N && { value: void 0 },
|
|
43
43
|
ref: F,
|
|
@@ -51,20 +51,20 @@ function f({ name: f, label: p, helperText: m, required: h, rules: g, reserveErr
|
|
|
51
51
|
},
|
|
52
52
|
checked: N ? M.value : void 0
|
|
53
53
|
}),
|
|
54
|
-
w.error?.message && /* @__PURE__ */
|
|
54
|
+
w.error?.message && /* @__PURE__ */ l("span", {
|
|
55
55
|
id: `${f}-error`,
|
|
56
|
-
className: o(
|
|
56
|
+
className: o(s.error, D?.error, v?.error),
|
|
57
57
|
role: "alert",
|
|
58
58
|
children: w.error.message
|
|
59
59
|
}),
|
|
60
|
-
m && /* @__PURE__ */
|
|
60
|
+
m && /* @__PURE__ */ l("span", {
|
|
61
61
|
id: `${f}-helper`,
|
|
62
|
-
className: o(
|
|
62
|
+
className: o(s.helperText, D?.helperText, v?.helperText),
|
|
63
63
|
children: m
|
|
64
64
|
}),
|
|
65
|
-
E !== !1 && !w.error?.message && /* @__PURE__ */
|
|
65
|
+
E !== !1 && !w.error?.message && /* @__PURE__ */ l("div", {
|
|
66
66
|
"aria-hidden": "true",
|
|
67
|
-
className: o(
|
|
67
|
+
className: o(s.messageReserve, D?.message, v?.message),
|
|
68
68
|
style: typeof E == "number" ? { minHeight: `${E}px` } : typeof E == "string" ? { minHeight: E } : void 0
|
|
69
69
|
})
|
|
70
70
|
]
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import t from "
|
|
1
|
+
import e from "clsx";
|
|
2
|
+
import t from "./Form.module.scss.js";
|
|
3
3
|
import { jsx as n } from "react/jsx-runtime";
|
|
4
4
|
// src/components/Form/FormRow.tsx
|
|
5
5
|
function r({ children: r, className: i, style: a }) {
|
|
6
6
|
return /* @__PURE__ */ n("div", {
|
|
7
|
-
className: t
|
|
7
|
+
className: e(t.row, i),
|
|
8
8
|
style: a,
|
|
9
9
|
children: r
|
|
10
10
|
});
|