@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,688 +1,561 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
-
onChange: Ce,
|
|
53
|
-
...be,
|
|
54
|
-
children: [
|
|
55
|
-
m && /* @__PURE__ */ c("option", { value: "", disabled: !0, children: m }),
|
|
56
|
-
d ? d.map((H) => /* @__PURE__ */ c("option", { value: H.value, disabled: H.disabled, children: H.label }, H.value)) : u
|
|
57
|
-
]
|
|
58
|
-
}
|
|
59
|
-
),
|
|
60
|
-
/* @__PURE__ */ c("span", { className: f(t.arrow, r?.arrow) })
|
|
61
|
-
] });
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
Pe.displayName = "NativeSelect";
|
|
65
|
-
function Te(n) {
|
|
66
|
-
const { name: a, form: d, required: m, title: r, autoFocus: _, tabIndex: R } = n, u = { title: r, autoFocus: _, tabIndex: R };
|
|
67
|
-
m && (u["aria-required"] = !0);
|
|
68
|
-
for (const w of Object.keys(n))
|
|
69
|
-
(w.startsWith("aria-") || w.startsWith("data-")) && (u[w] = n[w]);
|
|
70
|
-
const v = {};
|
|
71
|
-
for (const w of Object.keys(u))
|
|
72
|
-
w.startsWith("aria-") && (v[w] = u[w]);
|
|
73
|
-
return { hidden: { name: a, form: d }, control: u, aria: v };
|
|
1
|
+
import e from "./Select.module.js";
|
|
2
|
+
import { usePortalPosition as t } from "../../../hooks/usePortalPosition.js";
|
|
3
|
+
import { Spinner as n } from "../../Spinner/Spinner.js";
|
|
4
|
+
import { forwardRef as r, useCallback as i, useEffect as a, useId as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
5
|
+
import u from "clsx";
|
|
6
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
7
|
+
import { createPortal as ee } from "react-dom";
|
|
8
|
+
// src/components/inputs/Select/Select.tsx
|
|
9
|
+
var m = r(({ inputSize: t = "md", error: n = !1, options: r, placeholder: i, classes: a, className: o, style: s, children: c, searchable: l, searchPlaceholder: d, onValuesChange: ee, clearSearchOnSelect: m, closeOnSelect: te, allowCreate: ne, onCreate: re, createLabel: ie, portal: ae, onSearch: oe, searchDebounce: h, minSearchLength: g, searchPrompt: se, loading: _, loadingMessage: v, noResultsMessage: y, highlightMatches: ce, selectedLabels: le, onChange: b, onValueChange: x, ...S }, ue) => {
|
|
10
|
+
let C = b || x ? (e) => {
|
|
11
|
+
b?.(e), x?.(e.target.value);
|
|
12
|
+
} : void 0;
|
|
13
|
+
return /* @__PURE__ */ p("div", {
|
|
14
|
+
className: u(e.wrapper, e[t], n && e.error, a?.wrapper, o),
|
|
15
|
+
style: s,
|
|
16
|
+
children: [/* @__PURE__ */ p("select", {
|
|
17
|
+
ref: ue,
|
|
18
|
+
className: u(e.root, e[t], n && e.error, a?.root),
|
|
19
|
+
onChange: C,
|
|
20
|
+
...S,
|
|
21
|
+
children: [i && /* @__PURE__ */ f("option", {
|
|
22
|
+
value: "",
|
|
23
|
+
disabled: !0,
|
|
24
|
+
children: i
|
|
25
|
+
}), r ? r.map((e) => /* @__PURE__ */ f("option", {
|
|
26
|
+
value: e.value,
|
|
27
|
+
disabled: e.disabled,
|
|
28
|
+
children: e.label
|
|
29
|
+
}, e.value)) : c]
|
|
30
|
+
}), /* @__PURE__ */ f("span", { className: u(e.arrow, a?.arrow) })]
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
m.displayName = "NativeSelect";
|
|
34
|
+
function te(e) {
|
|
35
|
+
let { name: t, form: n, required: r, title: i, autoFocus: a, tabIndex: o } = e, s = {
|
|
36
|
+
title: i,
|
|
37
|
+
autoFocus: a,
|
|
38
|
+
tabIndex: o
|
|
39
|
+
};
|
|
40
|
+
r && (s["aria-required"] = !0);
|
|
41
|
+
for (let t of Object.keys(e)) (t.startsWith("aria-") || t.startsWith("data-")) && (s[t] = e[t]);
|
|
42
|
+
let c = {};
|
|
43
|
+
for (let e of Object.keys(s)) e.startsWith("aria-") && (c[e] = s[e]);
|
|
44
|
+
return {
|
|
45
|
+
hidden: {
|
|
46
|
+
name: t,
|
|
47
|
+
form: n
|
|
48
|
+
},
|
|
49
|
+
control: s,
|
|
50
|
+
aria: c
|
|
51
|
+
};
|
|
74
52
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
53
|
+
function ne(e, t, n) {
|
|
54
|
+
let r = c(!1);
|
|
55
|
+
return {
|
|
56
|
+
onFocus: (t) => {
|
|
57
|
+
r.current || (r.current = !0, e?.(t));
|
|
58
|
+
},
|
|
59
|
+
onBlur: (e) => {
|
|
60
|
+
let i = e.relatedTarget;
|
|
61
|
+
i && n.some((e) => e.current?.contains(i)) || (r.current = !1, t?.(e));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
86
64
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
65
|
+
function re(e, t, n, r, i) {
|
|
66
|
+
let o = c(e);
|
|
67
|
+
o.current = e;
|
|
68
|
+
let s = c(null), l = !!e;
|
|
69
|
+
a(() => {
|
|
70
|
+
if (!l || !n || t.length < i) return;
|
|
71
|
+
let e = () => {
|
|
72
|
+
s.current !== t && (s.current = t, o.current?.(t));
|
|
73
|
+
};
|
|
74
|
+
if (r <= 0 || t === "") {
|
|
75
|
+
e();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let a = setTimeout(e, r);
|
|
79
|
+
return () => clearTimeout(a);
|
|
80
|
+
}, [
|
|
81
|
+
l,
|
|
82
|
+
n,
|
|
83
|
+
t,
|
|
84
|
+
r,
|
|
85
|
+
i
|
|
86
|
+
]);
|
|
103
87
|
}
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
88
|
+
function ie(e, t, n) {
|
|
89
|
+
return s(() => {
|
|
90
|
+
if (n || !t) return e;
|
|
91
|
+
let r = t.toLowerCase();
|
|
92
|
+
return e.filter((e) => e.label.toLowerCase().includes(r));
|
|
93
|
+
}, [
|
|
94
|
+
e,
|
|
95
|
+
t,
|
|
96
|
+
n
|
|
97
|
+
]);
|
|
110
98
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
99
|
+
function ae(t, n, r, i) {
|
|
100
|
+
if (t.content !== void 0) return t.content;
|
|
101
|
+
if (!r || !n) return t.label;
|
|
102
|
+
let a = t.label.toLowerCase().indexOf(n.toLowerCase());
|
|
103
|
+
return a < 0 ? t.label : /* @__PURE__ */ p(d, { children: [
|
|
104
|
+
t.label.slice(0, a),
|
|
105
|
+
/* @__PURE__ */ f("mark", {
|
|
106
|
+
className: u(e.match, i),
|
|
107
|
+
children: t.label.slice(a, a + n.length)
|
|
108
|
+
}),
|
|
109
|
+
t.label.slice(a + n.length)
|
|
110
|
+
] });
|
|
120
111
|
}
|
|
121
|
-
function
|
|
122
|
-
|
|
112
|
+
function oe(e) {
|
|
113
|
+
return e.loading ? e.loadingMessage : e.remote && e.query.length < e.minSearchLength ? e.searchPrompt : e.empty ? e.noResultsMessage : null;
|
|
123
114
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
type: "button",
|
|
572
|
-
className: f(t.chipRemove, r?.chipRemove),
|
|
573
|
-
onClick: (i) => L(e.value, i),
|
|
574
|
-
"aria-label": `Remove ${e.label}`,
|
|
575
|
-
tabIndex: -1,
|
|
576
|
-
children: "×"
|
|
577
|
-
}
|
|
578
|
-
)
|
|
579
|
-
] }, e.value)),
|
|
580
|
-
/* @__PURE__ */ c(
|
|
581
|
-
"input",
|
|
582
|
-
{
|
|
583
|
-
ref: Q,
|
|
584
|
-
id: w,
|
|
585
|
-
type: "text",
|
|
586
|
-
className: t.multiSearch,
|
|
587
|
-
placeholder: g.length === 0 ? m : "",
|
|
588
|
-
value: S,
|
|
589
|
-
onChange: (e) => {
|
|
590
|
-
I(e.target.value), h || $(!0);
|
|
591
|
-
},
|
|
592
|
-
onKeyDown: xe,
|
|
593
|
-
disabled: v,
|
|
594
|
-
"aria-label": we["aria-labelledby"] ? void 0 : "Search options",
|
|
595
|
-
...we
|
|
596
|
-
}
|
|
597
|
-
),
|
|
598
|
-
q && /* @__PURE__ */ c(Oe, { size: "sm", label: "", "aria-hidden": "true", className: f(t.spinner, r?.spinner) }),
|
|
599
|
-
/* @__PURE__ */ c("span", { className: f(t.arrow, t.arrowMulti, r?.arrow) })
|
|
600
|
-
]
|
|
601
|
-
}
|
|
602
|
-
),
|
|
603
|
-
h && (() => {
|
|
604
|
-
const e = J ? {
|
|
605
|
-
position: "fixed",
|
|
606
|
-
top: ce.top + 4,
|
|
607
|
-
left: ce.left,
|
|
608
|
-
right: "auto",
|
|
609
|
-
width: ce.width,
|
|
610
|
-
zIndex: "var(--crk-z-floating)"
|
|
611
|
-
} : void 0, i = /* @__PURE__ */ c(
|
|
612
|
-
"div",
|
|
613
|
-
{
|
|
614
|
-
id: ge,
|
|
615
|
-
ref: ne,
|
|
616
|
-
className: f(t.menu, r?.menu),
|
|
617
|
-
style: e,
|
|
618
|
-
role: "listbox",
|
|
619
|
-
"aria-multiselectable": "true",
|
|
620
|
-
onMouseDown: (o) => o.preventDefault(),
|
|
621
|
-
children: /* @__PURE__ */ k("div", { className: t.menuItems, ref: re, children: [
|
|
622
|
-
p !== null && /* @__PURE__ */ c("div", { className: f(t.noResults, r?.message), role: "status", children: p }),
|
|
623
|
-
s && T.map((o, E) => {
|
|
624
|
-
const de = g.includes(o.value);
|
|
625
|
-
return /* @__PURE__ */ k(
|
|
626
|
-
"button",
|
|
627
|
-
{
|
|
628
|
-
id: `select-option-${o.value}`,
|
|
629
|
-
type: "button",
|
|
630
|
-
role: "option",
|
|
631
|
-
"aria-selected": de,
|
|
632
|
-
className: f(
|
|
633
|
-
t.item,
|
|
634
|
-
o.disabled && t.itemDisabled,
|
|
635
|
-
de && t.itemSelected,
|
|
636
|
-
E === D && t.itemHighlighted,
|
|
637
|
-
r?.item
|
|
638
|
-
),
|
|
639
|
-
disabled: o.disabled,
|
|
640
|
-
onClick: () => U(o.value),
|
|
641
|
-
onMouseEnter: () => P(E),
|
|
642
|
-
children: [
|
|
643
|
-
de && /* @__PURE__ */ c("span", { className: t.itemCheck, "aria-hidden": "true" }),
|
|
644
|
-
We(o, S, se && !b, r?.match)
|
|
645
|
-
]
|
|
646
|
-
},
|
|
647
|
-
o.value
|
|
648
|
-
);
|
|
649
|
-
}),
|
|
650
|
-
s && M && /* @__PURE__ */ c(
|
|
651
|
-
"button",
|
|
652
|
-
{
|
|
653
|
-
type: "button",
|
|
654
|
-
role: "option",
|
|
655
|
-
"aria-selected": !1,
|
|
656
|
-
className: f(
|
|
657
|
-
t.item,
|
|
658
|
-
D === X && t.itemHighlighted,
|
|
659
|
-
r?.item
|
|
660
|
-
),
|
|
661
|
-
onClick: V,
|
|
662
|
-
onMouseEnter: () => P(X),
|
|
663
|
-
children: G ? G(N) : /* @__PURE__ */ k(De, { children: [
|
|
664
|
-
"Create “",
|
|
665
|
-
/* @__PURE__ */ c("strong", { children: N }),
|
|
666
|
-
"”"
|
|
667
|
-
] })
|
|
668
|
-
},
|
|
669
|
-
"__create__"
|
|
670
|
-
)
|
|
671
|
-
] })
|
|
672
|
-
}
|
|
673
|
-
);
|
|
674
|
-
return J && typeof document < "u" ? Le(i, document.body) : i;
|
|
675
|
-
})()
|
|
676
|
-
]
|
|
677
|
-
}
|
|
678
|
-
);
|
|
679
|
-
}
|
|
680
|
-
);
|
|
681
|
-
Ke.displayName = "MultiSelect";
|
|
682
|
-
const Qe = Ne(
|
|
683
|
-
(n, a) => n.multiple ? /* @__PURE__ */ c(Ke, { ref: a, ...n }) : n.searchable ? /* @__PURE__ */ c(Be, { ref: a, ...n }) : /* @__PURE__ */ c(Pe, { ref: a, ...n })
|
|
684
|
-
);
|
|
685
|
-
Qe.displayName = "Select";
|
|
686
|
-
export {
|
|
687
|
-
Qe as Select
|
|
688
|
-
};
|
|
115
|
+
var h = r(({ inputSize: r = "md", error: s = !1, options: d = [], placeholder: m = "Select...", classes: h, className: g, style: se, value: _, disabled: v, id: y, searchPlaceholder: ce = "Search...", onChange: le, onValueChange: b, portal: x = !0, onFocus: S, onBlur: ue, onSearch: C, searchDebounce: de = 250, minSearchLength: w = 0, searchPrompt: fe = "Type to search", loading: T = !1, loadingMessage: pe = "Loading…", noResultsMessage: me = "No results", highlightMatches: E = !1, selectedLabels: he, multiple: ge, onValuesChange: _e, clearSearchOnSelect: ve, closeOnSelect: ye, allowCreate: be, onCreate: xe, createLabel: Se, ...Ce }, D) => {
|
|
116
|
+
let O = !!C, [k, A] = l(!1), [j, M] = l(""), N = T || O && j.length < w, [P, F] = l(0), I = c(null), L = c(null), R = c(null), z = c(null), B = c(null), V = o(), H = t(I, k && x), { hidden: we, control: Te, aria: U } = te(Ce), Ee = ne(S, ue, [I, z]), W = c(null), De = (e) => {
|
|
117
|
+
W.current = e, typeof D == "function" ? D(e) : D && (D.current = e);
|
|
118
|
+
}, Oe = c(!1);
|
|
119
|
+
a(() => {
|
|
120
|
+
Oe.current && !k && R.current?.focus(), Oe.current = k;
|
|
121
|
+
}, [k]);
|
|
122
|
+
let G = i(() => {
|
|
123
|
+
A(!1), M(""), F(0);
|
|
124
|
+
}, []), K = i(() => {
|
|
125
|
+
v || (A(!0), M(""), F(0), setTimeout(() => L.current?.focus(), 0));
|
|
126
|
+
}, [v]), q = i((e) => {
|
|
127
|
+
if (b?.(e), W.current) {
|
|
128
|
+
(Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")?.set)?.call(W.current, e);
|
|
129
|
+
let t = new Event("change", { bubbles: !0 });
|
|
130
|
+
W.current.dispatchEvent(t), le?.(t);
|
|
131
|
+
}
|
|
132
|
+
G();
|
|
133
|
+
}, [
|
|
134
|
+
b,
|
|
135
|
+
le,
|
|
136
|
+
W,
|
|
137
|
+
G
|
|
138
|
+
]), J = ie(d, j, O);
|
|
139
|
+
re(C, j, k, de, w), a(() => {
|
|
140
|
+
let e = J.findIndex((e) => !e.disabled);
|
|
141
|
+
F(e >= 0 ? e : 0);
|
|
142
|
+
}, [J]), a(() => {
|
|
143
|
+
if (!k) return;
|
|
144
|
+
let e = B.current;
|
|
145
|
+
e && e.querySelectorAll("[role=\"option\"]")[P]?.scrollIntoView?.({ block: "nearest" });
|
|
146
|
+
}, [P, k]);
|
|
147
|
+
let ke = i((e) => {
|
|
148
|
+
let t = J.map((e, t) => e.disabled ? -1 : t).filter((e) => e >= 0);
|
|
149
|
+
if (e.key === "Escape") e.preventDefault(), G();
|
|
150
|
+
else if (t.length !== 0) {
|
|
151
|
+
if (e.key === "ArrowDown") e.preventDefault(), F((e) => {
|
|
152
|
+
let n = t.indexOf(e);
|
|
153
|
+
return n < t.length - 1 ? t[n + 1] : t[0];
|
|
154
|
+
});
|
|
155
|
+
else if (e.key === "ArrowUp") e.preventDefault(), F((e) => {
|
|
156
|
+
let n = t.indexOf(e);
|
|
157
|
+
return n > 0 ? t[n - 1] : t[t.length - 1];
|
|
158
|
+
});
|
|
159
|
+
else if (e.key === "Enter") {
|
|
160
|
+
if (e.preventDefault(), N) return;
|
|
161
|
+
let t = J[P];
|
|
162
|
+
t && !t.disabled && q(t.value);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, [
|
|
166
|
+
J,
|
|
167
|
+
P,
|
|
168
|
+
q,
|
|
169
|
+
G,
|
|
170
|
+
N
|
|
171
|
+
]);
|
|
172
|
+
a(() => {
|
|
173
|
+
if (!k) return;
|
|
174
|
+
let e = (e) => {
|
|
175
|
+
let t = e.target;
|
|
176
|
+
I.current?.contains(t) || z.current?.contains(t) || G();
|
|
177
|
+
};
|
|
178
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
179
|
+
}, [k, G]);
|
|
180
|
+
let Y = d.find((e) => e.value === _), X = Y?.label ?? (_ ? he?.[_] ?? (O ? _ : void 0) : void 0), Z = typeof X == "string" ? X : void 0, Q = J.filter((e) => !e.disabled), $ = oe({
|
|
181
|
+
loading: T,
|
|
182
|
+
loadingMessage: pe,
|
|
183
|
+
remote: O,
|
|
184
|
+
query: j,
|
|
185
|
+
minSearchLength: w,
|
|
186
|
+
searchPrompt: fe,
|
|
187
|
+
empty: J.length === 0,
|
|
188
|
+
noResultsMessage: me
|
|
189
|
+
});
|
|
190
|
+
return /* @__PURE__ */ p("div", {
|
|
191
|
+
ref: I,
|
|
192
|
+
className: u(e.wrapper, e.searchableWrapper, e[r], s && e.error, v && e.disabled, h?.wrapper, g),
|
|
193
|
+
style: se,
|
|
194
|
+
...Ee,
|
|
195
|
+
children: [
|
|
196
|
+
/* @__PURE__ */ p("select", {
|
|
197
|
+
ref: De,
|
|
198
|
+
className: e.hiddenSelect,
|
|
199
|
+
value: _ ?? "",
|
|
200
|
+
disabled: v,
|
|
201
|
+
tabIndex: -1,
|
|
202
|
+
"aria-hidden": "true",
|
|
203
|
+
onChange: () => {},
|
|
204
|
+
...we,
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ f("option", { value: "" }),
|
|
207
|
+
d.map((e) => /* @__PURE__ */ f("option", {
|
|
208
|
+
value: e.value,
|
|
209
|
+
children: e.label
|
|
210
|
+
}, e.value)),
|
|
211
|
+
_ && !Y && /* @__PURE__ */ f("option", {
|
|
212
|
+
value: _,
|
|
213
|
+
children: Z ?? _
|
|
214
|
+
})
|
|
215
|
+
]
|
|
216
|
+
}),
|
|
217
|
+
/* @__PURE__ */ p("button", {
|
|
218
|
+
ref: R,
|
|
219
|
+
id: k ? void 0 : y,
|
|
220
|
+
type: "button",
|
|
221
|
+
className: u(e.root, e.searchableTrigger, e[r], k && e.triggerOpen, s && e.error, k && e.visuallyHidden, h?.root),
|
|
222
|
+
onClick: K,
|
|
223
|
+
disabled: v,
|
|
224
|
+
"aria-expanded": k,
|
|
225
|
+
"aria-haspopup": "listbox",
|
|
226
|
+
"aria-controls": k ? V : void 0,
|
|
227
|
+
...Te,
|
|
228
|
+
children: [
|
|
229
|
+
/* @__PURE__ */ f("span", {
|
|
230
|
+
className: u(e.triggerLabel, !X && e.placeholder),
|
|
231
|
+
children: X || m
|
|
232
|
+
}),
|
|
233
|
+
T && /* @__PURE__ */ f(n, {
|
|
234
|
+
size: "sm",
|
|
235
|
+
label: "",
|
|
236
|
+
"aria-hidden": "true",
|
|
237
|
+
className: u(e.spinner, h?.spinner)
|
|
238
|
+
}),
|
|
239
|
+
/* @__PURE__ */ f("span", { className: u(e.arrow, e.arrowInline, h?.arrow) })
|
|
240
|
+
]
|
|
241
|
+
}),
|
|
242
|
+
k && /* @__PURE__ */ f("input", {
|
|
243
|
+
ref: L,
|
|
244
|
+
id: y,
|
|
245
|
+
type: "text",
|
|
246
|
+
role: "combobox",
|
|
247
|
+
className: u(e.root, e.searchableTrigger, e[r], e.triggerOpen, s && e.error, h?.root, h?.search),
|
|
248
|
+
placeholder: Z || (typeof m == "string" ? m : void 0),
|
|
249
|
+
value: j,
|
|
250
|
+
onChange: (e) => M(e.target.value),
|
|
251
|
+
onKeyDown: ke,
|
|
252
|
+
"aria-expanded": !0,
|
|
253
|
+
"aria-haspopup": "listbox",
|
|
254
|
+
"aria-controls": V,
|
|
255
|
+
"aria-activedescendant": Q.length > 0 ? `select-option-${J[P]?.value}` : void 0,
|
|
256
|
+
"aria-label": U["aria-labelledby"] || y ? void 0 : ce,
|
|
257
|
+
...U
|
|
258
|
+
}),
|
|
259
|
+
k && (() => {
|
|
260
|
+
let t = x ? {
|
|
261
|
+
position: "fixed",
|
|
262
|
+
top: H.top + 4,
|
|
263
|
+
left: H.left,
|
|
264
|
+
right: "auto",
|
|
265
|
+
width: H.width,
|
|
266
|
+
zIndex: "var(--crk-z-floating)"
|
|
267
|
+
} : void 0, n = /* @__PURE__ */ f("div", {
|
|
268
|
+
id: V,
|
|
269
|
+
ref: z,
|
|
270
|
+
className: u(e.menu, h?.menu),
|
|
271
|
+
style: t,
|
|
272
|
+
role: "listbox",
|
|
273
|
+
children: /* @__PURE__ */ f("div", {
|
|
274
|
+
className: e.menuItems,
|
|
275
|
+
ref: B,
|
|
276
|
+
children: $ === null ? J.map((t, n) => /* @__PURE__ */ f("button", {
|
|
277
|
+
id: `select-option-${t.value}`,
|
|
278
|
+
type: "button",
|
|
279
|
+
role: "option",
|
|
280
|
+
"aria-selected": t.value === _,
|
|
281
|
+
className: u(e.item, t.disabled && e.itemDisabled, t.value === _ && e.itemSelected, n === P && e.itemHighlighted, h?.item),
|
|
282
|
+
disabled: t.disabled,
|
|
283
|
+
onClick: () => q(t.value),
|
|
284
|
+
onMouseEnter: () => F(n),
|
|
285
|
+
children: ae(t, j, E && !O, h?.match)
|
|
286
|
+
}, t.value)) : /* @__PURE__ */ f("div", {
|
|
287
|
+
className: u(e.noResults, h?.message),
|
|
288
|
+
role: "status",
|
|
289
|
+
children: $
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
});
|
|
293
|
+
return x && typeof document < "u" ? ee(n, document.body) : n;
|
|
294
|
+
})()
|
|
295
|
+
]
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
h.displayName = "SearchableSelect";
|
|
299
|
+
var g = r(({ inputSize: r = "md", error: s = !1, options: m = [], placeholder: h = "Select...", classes: g, className: se, style: _, value: v, disabled: y, id: ce, searchPlaceholder: le, onValuesChange: b, clearSearchOnSelect: x = !0, closeOnSelect: S = !0, allowCreate: ue = !1, onCreate: C, createLabel: de, portal: w = !0, onFocus: fe, onBlur: T, onSearch: pe, searchDebounce: me = 250, minSearchLength: E = 0, searchPrompt: he = "Type to search", loading: ge = !1, loadingMessage: _e = "Loading…", noResultsMessage: ve = "No results", highlightMatches: ye = !1, selectedLabels: be, multiple: xe, searchable: Se, onChange: Ce, onValueChange: D, ...O }, k) => {
|
|
300
|
+
let A = !!pe, j = Array.isArray(v) ? v : v ? [v] : [], [M, N] = l(!1), [P, F] = l(""), I = ge || A && P.length < E, [L, R] = l(0), z = c(null), B = c(null), V = c(null), H = c(null), we = c(null), Te = o(), U = t(we, M && w), { hidden: Ee, control: W } = te(O), De = ne(fe, T, [z, V]), Oe = c(null), G = (e) => {
|
|
301
|
+
Oe.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
|
|
302
|
+
}, K = i(() => {
|
|
303
|
+
N(!1), F(""), R(0);
|
|
304
|
+
}, []), q = i(() => {
|
|
305
|
+
y || (N(!0), F(""), R(0), setTimeout(() => B.current?.focus(), 0));
|
|
306
|
+
}, [y]), J = i((e) => {
|
|
307
|
+
let t = j.includes(e) ? j.filter((t) => t !== e) : [...j, e];
|
|
308
|
+
b?.(t), S ? K() : x && F("");
|
|
309
|
+
}, [
|
|
310
|
+
j,
|
|
311
|
+
b,
|
|
312
|
+
S,
|
|
313
|
+
K,
|
|
314
|
+
x
|
|
315
|
+
]), ke = i((e, t) => {
|
|
316
|
+
t.stopPropagation(), b?.(j.filter((t) => t !== e));
|
|
317
|
+
}, [j, b]), Y = ie(m, P, A);
|
|
318
|
+
re(pe, P, M, me, E);
|
|
319
|
+
let X = P.trim(), Z = ue && X.length > 0 && !m.some((e) => e.label.toLowerCase() === X.toLowerCase() || e.value === X) && !j.includes(X), Q = i(() => {
|
|
320
|
+
X && (j.includes(X) || (C?.(X), b?.([...j, X]), S ? K() : x && F("")));
|
|
321
|
+
}, [
|
|
322
|
+
X,
|
|
323
|
+
j,
|
|
324
|
+
C,
|
|
325
|
+
b,
|
|
326
|
+
S,
|
|
327
|
+
K,
|
|
328
|
+
x
|
|
329
|
+
]);
|
|
330
|
+
a(() => {
|
|
331
|
+
let e = Y.findIndex((e) => !e.disabled);
|
|
332
|
+
R(e >= 0 ? e : 0);
|
|
333
|
+
}, [Y]), a(() => {
|
|
334
|
+
if (!M) return;
|
|
335
|
+
let e = H.current;
|
|
336
|
+
e && e.querySelectorAll("[role=\"option\"]")[L]?.scrollIntoView?.({ block: "nearest" });
|
|
337
|
+
}, [L, M]);
|
|
338
|
+
let $ = Y.length, Ae = i((e) => {
|
|
339
|
+
let t = Y.map((e, t) => e.disabled ? -1 : t).filter((e) => e >= 0);
|
|
340
|
+
if (Z && t.push($), e.key === "Backspace" && P === "" && j.length > 0) e.preventDefault(), b?.(j.slice(0, -1));
|
|
341
|
+
else if (e.key === "Escape") {
|
|
342
|
+
if (!M) return;
|
|
343
|
+
e.preventDefault(), K();
|
|
344
|
+
} else if (t.length !== 0) {
|
|
345
|
+
if (e.key === "ArrowDown") {
|
|
346
|
+
if (e.preventDefault(), !M) {
|
|
347
|
+
q();
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
R((e) => {
|
|
351
|
+
let n = t.indexOf(e);
|
|
352
|
+
return n < t.length - 1 ? t[n + 1] : t[0];
|
|
353
|
+
});
|
|
354
|
+
} else if (e.key === "ArrowUp") e.preventDefault(), R((e) => {
|
|
355
|
+
let n = t.indexOf(e);
|
|
356
|
+
return n > 0 ? t[n - 1] : t[t.length - 1];
|
|
357
|
+
});
|
|
358
|
+
else if (e.key === "Enter") {
|
|
359
|
+
if (e.preventDefault(), I) return;
|
|
360
|
+
if (Z && L === $) {
|
|
361
|
+
Q();
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
let t = Y[L];
|
|
365
|
+
t && !t.disabled ? J(t.value) : Z && Q();
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}, [
|
|
369
|
+
Y,
|
|
370
|
+
L,
|
|
371
|
+
J,
|
|
372
|
+
K,
|
|
373
|
+
P,
|
|
374
|
+
j,
|
|
375
|
+
b,
|
|
376
|
+
M,
|
|
377
|
+
q,
|
|
378
|
+
Z,
|
|
379
|
+
Q,
|
|
380
|
+
$,
|
|
381
|
+
I
|
|
382
|
+
]);
|
|
383
|
+
a(() => {
|
|
384
|
+
if (!M) return;
|
|
385
|
+
let e = (e) => {
|
|
386
|
+
let t = e.target;
|
|
387
|
+
z.current?.contains(t) || V.current?.contains(t) || K();
|
|
388
|
+
};
|
|
389
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
390
|
+
}, [M, K]);
|
|
391
|
+
let je = j.map((e) => {
|
|
392
|
+
let t = m.find((t) => t.value === e);
|
|
393
|
+
if (t) return t;
|
|
394
|
+
let n = be?.[e];
|
|
395
|
+
return typeof n == "string" ? {
|
|
396
|
+
value: e,
|
|
397
|
+
label: n
|
|
398
|
+
} : {
|
|
399
|
+
value: e,
|
|
400
|
+
label: e,
|
|
401
|
+
content: n
|
|
402
|
+
};
|
|
403
|
+
}), Me = oe({
|
|
404
|
+
loading: ge,
|
|
405
|
+
loadingMessage: _e,
|
|
406
|
+
remote: A,
|
|
407
|
+
query: P,
|
|
408
|
+
minSearchLength: E,
|
|
409
|
+
searchPrompt: he,
|
|
410
|
+
empty: Y.length === 0 && !Z,
|
|
411
|
+
noResultsMessage: ve
|
|
412
|
+
}), Ne = Me === null;
|
|
413
|
+
return /* @__PURE__ */ p("div", {
|
|
414
|
+
ref: z,
|
|
415
|
+
className: u(e.wrapper, e.searchableWrapper, e[r], s && e.error, y && e.disabled, g?.wrapper, se),
|
|
416
|
+
style: _,
|
|
417
|
+
...De,
|
|
418
|
+
children: [
|
|
419
|
+
/* @__PURE__ */ p("select", {
|
|
420
|
+
ref: G,
|
|
421
|
+
className: e.hiddenSelect,
|
|
422
|
+
multiple: !0,
|
|
423
|
+
value: j,
|
|
424
|
+
disabled: y,
|
|
425
|
+
tabIndex: -1,
|
|
426
|
+
"aria-hidden": "true",
|
|
427
|
+
onChange: () => {},
|
|
428
|
+
...Ee,
|
|
429
|
+
children: [m.map((e) => /* @__PURE__ */ f("option", {
|
|
430
|
+
value: e.value,
|
|
431
|
+
children: e.label
|
|
432
|
+
}, e.value)), je.filter((e) => !m.some((t) => t.value === e.value)).map((e) => /* @__PURE__ */ f("option", {
|
|
433
|
+
value: e.value,
|
|
434
|
+
children: e.label
|
|
435
|
+
}, e.value))]
|
|
436
|
+
}),
|
|
437
|
+
/* @__PURE__ */ p("div", {
|
|
438
|
+
ref: we,
|
|
439
|
+
className: u(e.multiTrigger, e[r], M && e.triggerOpen, s && e.error, y && e.multiTriggerDisabled, g?.root),
|
|
440
|
+
onClick: () => {
|
|
441
|
+
M ? B.current?.focus() : q();
|
|
442
|
+
},
|
|
443
|
+
role: "combobox",
|
|
444
|
+
"aria-expanded": M,
|
|
445
|
+
"aria-haspopup": "listbox",
|
|
446
|
+
"aria-controls": M ? Te : void 0,
|
|
447
|
+
children: [
|
|
448
|
+
je.map((t) => /* @__PURE__ */ p("span", {
|
|
449
|
+
className: u(e.chip, g?.chip),
|
|
450
|
+
children: [/* @__PURE__ */ f("span", {
|
|
451
|
+
className: e.chipLabel,
|
|
452
|
+
children: t.content ?? t.label
|
|
453
|
+
}), /* @__PURE__ */ f("button", {
|
|
454
|
+
type: "button",
|
|
455
|
+
className: u(e.chipRemove, g?.chipRemove),
|
|
456
|
+
onClick: (e) => ke(t.value, e),
|
|
457
|
+
"aria-label": `Remove ${t.label}`,
|
|
458
|
+
tabIndex: -1,
|
|
459
|
+
children: "×"
|
|
460
|
+
})]
|
|
461
|
+
}, t.value)),
|
|
462
|
+
/* @__PURE__ */ f("input", {
|
|
463
|
+
ref: B,
|
|
464
|
+
id: ce,
|
|
465
|
+
type: "text",
|
|
466
|
+
className: e.multiSearch,
|
|
467
|
+
placeholder: j.length === 0 ? h : "",
|
|
468
|
+
value: P,
|
|
469
|
+
onChange: (e) => {
|
|
470
|
+
F(e.target.value), M || N(!0);
|
|
471
|
+
},
|
|
472
|
+
onKeyDown: Ae,
|
|
473
|
+
disabled: y,
|
|
474
|
+
"aria-label": W["aria-labelledby"] ? void 0 : "Search options",
|
|
475
|
+
...W
|
|
476
|
+
}),
|
|
477
|
+
ge && /* @__PURE__ */ f(n, {
|
|
478
|
+
size: "sm",
|
|
479
|
+
label: "",
|
|
480
|
+
"aria-hidden": "true",
|
|
481
|
+
className: u(e.spinner, g?.spinner)
|
|
482
|
+
}),
|
|
483
|
+
/* @__PURE__ */ f("span", { className: u(e.arrow, e.arrowMulti, g?.arrow) })
|
|
484
|
+
]
|
|
485
|
+
}),
|
|
486
|
+
M && (() => {
|
|
487
|
+
let t = w ? {
|
|
488
|
+
position: "fixed",
|
|
489
|
+
top: U.top + 4,
|
|
490
|
+
left: U.left,
|
|
491
|
+
right: "auto",
|
|
492
|
+
width: U.width,
|
|
493
|
+
zIndex: "var(--crk-z-floating)"
|
|
494
|
+
} : void 0, n = /* @__PURE__ */ f("div", {
|
|
495
|
+
id: Te,
|
|
496
|
+
ref: V,
|
|
497
|
+
className: u(e.menu, g?.menu),
|
|
498
|
+
style: t,
|
|
499
|
+
role: "listbox",
|
|
500
|
+
"aria-multiselectable": "true",
|
|
501
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
502
|
+
children: /* @__PURE__ */ p("div", {
|
|
503
|
+
className: e.menuItems,
|
|
504
|
+
ref: H,
|
|
505
|
+
children: [
|
|
506
|
+
Me !== null && /* @__PURE__ */ f("div", {
|
|
507
|
+
className: u(e.noResults, g?.message),
|
|
508
|
+
role: "status",
|
|
509
|
+
children: Me
|
|
510
|
+
}),
|
|
511
|
+
Ne && Y.map((t, n) => {
|
|
512
|
+
let r = j.includes(t.value);
|
|
513
|
+
return /* @__PURE__ */ p("button", {
|
|
514
|
+
id: `select-option-${t.value}`,
|
|
515
|
+
type: "button",
|
|
516
|
+
role: "option",
|
|
517
|
+
"aria-selected": r,
|
|
518
|
+
className: u(e.item, t.disabled && e.itemDisabled, r && e.itemSelected, n === L && e.itemHighlighted, g?.item),
|
|
519
|
+
disabled: t.disabled,
|
|
520
|
+
onClick: () => J(t.value),
|
|
521
|
+
onMouseEnter: () => R(n),
|
|
522
|
+
children: [r && /* @__PURE__ */ f("span", {
|
|
523
|
+
className: e.itemCheck,
|
|
524
|
+
"aria-hidden": "true"
|
|
525
|
+
}), ae(t, P, ye && !A, g?.match)]
|
|
526
|
+
}, t.value);
|
|
527
|
+
}),
|
|
528
|
+
Ne && Z && /* @__PURE__ */ f("button", {
|
|
529
|
+
type: "button",
|
|
530
|
+
role: "option",
|
|
531
|
+
"aria-selected": !1,
|
|
532
|
+
className: u(e.item, L === $ && e.itemHighlighted, g?.item),
|
|
533
|
+
onClick: Q,
|
|
534
|
+
onMouseEnter: () => R($),
|
|
535
|
+
children: de ? de(X) : /* @__PURE__ */ p(d, { children: [
|
|
536
|
+
"Create “",
|
|
537
|
+
/* @__PURE__ */ f("strong", { children: X }),
|
|
538
|
+
"”"
|
|
539
|
+
] })
|
|
540
|
+
}, "__create__")
|
|
541
|
+
]
|
|
542
|
+
})
|
|
543
|
+
});
|
|
544
|
+
return w && typeof document < "u" ? ee(n, document.body) : n;
|
|
545
|
+
})()
|
|
546
|
+
]
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
g.displayName = "MultiSelect";
|
|
550
|
+
var se = r((e, t) => e.multiple ? /* @__PURE__ */ f(g, {
|
|
551
|
+
ref: t,
|
|
552
|
+
...e
|
|
553
|
+
}) : e.searchable ? /* @__PURE__ */ f(h, {
|
|
554
|
+
ref: t,
|
|
555
|
+
...e
|
|
556
|
+
}) : /* @__PURE__ */ f(m, {
|
|
557
|
+
ref: t,
|
|
558
|
+
...e
|
|
559
|
+
}));
|
|
560
|
+
se.displayName = "Select";
|
|
561
|
+
export { se as Select };
|