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