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