@overdoser/react-toolkit 0.7.0 → 0.8.1
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/CHANGELOG.md +32 -0
- package/components/ActionButton/ActionButton.js +211 -0
- package/components/ActionButton/ActionButton.module.scss.js +47 -0
- package/components/ActionButton/CopyButton.js +66 -0
- package/components/Alert/Alert.js +82 -0
- package/components/Alert/Alert.module.scss.js +25 -0
- package/components/Avatar/Avatar.js +57 -0
- package/components/Avatar/Avatar.module.scss.js +43 -0
- package/components/Badge/Badge.js +38 -0
- package/components/Badge/Badge.module.scss.js +31 -0
- package/components/Breadcrumbs/Breadcrumbs.js +49 -0
- package/components/Breadcrumbs/Breadcrumbs.module.scss.js +17 -0
- package/components/Button/Button.js +57 -0
- package/components/Button/Button.module.scss.js +47 -0
- package/components/Chart/AreaChart.js +244 -0
- package/components/Chart/Axis.js +45 -0
- package/components/Chart/BarChart.js +353 -0
- package/components/Chart/Chart.module.scss.js +61 -0
- package/components/Chart/ChartContainer.js +41 -0
- package/components/Chart/ChartLegend.js +31 -0
- package/components/Chart/ChartTooltip.js +42 -0
- package/components/Chart/LineChart.js +236 -0
- package/components/Chart/PieChart.js +248 -0
- package/components/Chart/RadarChart.js +221 -0
- package/components/Chart/Sparkline.js +69 -0
- package/components/Chart/TradingChart.js +732 -0
- package/components/Chart/scales.js +39 -0
- package/components/Chart/trading/indicators.js +68 -0
- package/components/Chart/trading/period.js +71 -0
- package/components/Chart/useChartDimensions.js +23 -0
- package/components/Divider/Divider.js +36 -0
- package/components/Divider/Divider.module.scss.js +31 -0
- package/components/Draggable/Draggable.js +155 -0
- package/components/Draggable/Draggable.module.scss.js +17 -0
- package/components/Drawer/Drawer.js +126 -0
- package/components/Drawer/Drawer.module.scss.js +117 -0
- package/components/Dropdown/Dropdown.js +142 -0
- package/components/Dropdown/Dropdown.module.scss.js +35 -0
- package/components/Dropdown/DropdownItem.js +31 -0
- package/components/Dropzone/Dropzone.js +107 -0
- package/components/Dropzone/Dropzone.module.scss.js +21 -0
- package/components/Form/Form.js +36 -0
- package/components/Form/Form.module.scss.js +29 -0
- package/components/Form/FormField.js +76 -0
- package/components/Form/FormRow.js +9 -0
- package/components/Form/formFieldDefaults.js +5 -0
- package/components/Link/Link.js +59 -0
- package/components/Link/Link.module.scss.js +16 -0
- package/components/List/List.js +46 -0
- package/components/List/List.module.scss.js +21 -0
- package/components/Modal/Modal.js +114 -0
- package/components/Modal/Modal.module.scss.js +31 -0
- package/components/Pagination/Pagination.js +84 -0
- package/components/Pagination/Pagination.module.scss.js +23 -0
- package/components/Pagination/paginationRange.js +24 -0
- package/components/Popover/Popover.js +138 -0
- package/components/Popover/Popover.module.scss.js +21 -0
- package/components/Skeleton/Skeleton.js +50 -0
- package/components/Skeleton/Skeleton.module.scss.js +25 -0
- package/components/Spinner/Spinner.js +25 -0
- package/components/Spinner/Spinner.module.scss.js +20 -0
- package/components/Table/Table.js +284 -0
- package/components/Table/Table.module.scss.js +59 -0
- package/components/Table/useTableSort.js +44 -0
- package/components/Tabs/Tabs.js +163 -0
- package/components/Tabs/Tabs.module.scss.js +53 -0
- package/components/Timer/Timer.js +159 -0
- package/components/Timer/Timer.module.scss.js +55 -0
- package/components/Toast/Toast.js +133 -0
- package/components/Toast/Toast.module.scss.js +62 -0
- package/components/Toast/toastStore.js +62 -0
- package/components/ToggleIconButton/ToggleIconButton.js +58 -0
- package/components/ToggleIconButton/ToggleIconButton.module.scss.js +27 -0
- package/components/Tooltip/Tooltip.js +86 -0
- package/components/Tooltip/Tooltip.module.scss.js +30 -0
- package/components/Typography/Typography.js +37 -0
- package/components/Typography/Typography.module.scss.js +53 -0
- package/components/inputs/Checkbox/Checkbox.js +50 -0
- package/components/inputs/Checkbox/Checkbox.module.scss.js +15 -0
- package/components/inputs/Checkbox/CheckboxGroup.js +111 -0
- package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +31 -0
- package/components/inputs/DatePicker/DatePicker.js +229 -0
- package/components/inputs/DatePicker/DatePicker.module.scss.js +45 -0
- package/components/inputs/DatePicker/dateUtils.js +41 -0
- package/components/inputs/Input/Input.js +50 -0
- package/components/inputs/Input/Input.module.scss.js +25 -0
- package/components/inputs/NumberInput/NumberInput.js +134 -0
- package/components/inputs/NumberInput/NumberInput.module.scss.js +25 -0
- package/components/inputs/Radio/Radio.js +68 -0
- package/components/inputs/Radio/Radio.module.scss.js +13 -0
- package/components/inputs/Select/Select.js +520 -0
- package/components/inputs/Select/Select.module.scss.js +69 -0
- package/components/inputs/Slider/Slider.js +128 -0
- package/components/inputs/Slider/Slider.module.scss.js +15 -0
- package/components/inputs/Textarea/Textarea.js +58 -0
- package/components/inputs/Textarea/Textarea.module.scss.js +25 -0
- package/hooks/useClickOutside.js +15 -0
- package/hooks/useFocusTrap.js +39 -0
- package/hooks/useKeyboard.js +19 -0
- package/hooks/usePortalPosition.js +20 -0
- package/index.css +1 -1
- package/index.js +119 -7000
- package/index.layered.css +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import { jsx as o, jsxs as P, Fragment as me } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ne, useState as Q, useRef as w, useId as le, useCallback as S, useMemo as ae, useEffect as q } from "react";
|
|
3
|
+
import { createPortal as ie } from "react-dom";
|
|
4
|
+
import f from "clsx";
|
|
5
|
+
import e from "./Select.module.scss.js";
|
|
6
|
+
import { usePortalPosition as oe } from "../../../hooks/usePortalPosition.js";
|
|
7
|
+
const se = ne(
|
|
8
|
+
({
|
|
9
|
+
inputSize: h = "md",
|
|
10
|
+
error: b = !1,
|
|
11
|
+
options: p,
|
|
12
|
+
placeholder: H,
|
|
13
|
+
classes: u,
|
|
14
|
+
className: F,
|
|
15
|
+
style: U,
|
|
16
|
+
children: y,
|
|
17
|
+
searchable: g,
|
|
18
|
+
searchPlaceholder: ee,
|
|
19
|
+
onChange: te,
|
|
20
|
+
onValueChange: v,
|
|
21
|
+
...L
|
|
22
|
+
}, N) => {
|
|
23
|
+
const W = te || v ? (s) => {
|
|
24
|
+
te?.(s), v?.(s.target.value);
|
|
25
|
+
} : void 0;
|
|
26
|
+
return /* @__PURE__ */ P("div", { className: f(e.wrapper, e[h], b && e.error, u?.wrapper, F), style: U, children: [
|
|
27
|
+
/* @__PURE__ */ P(
|
|
28
|
+
"select",
|
|
29
|
+
{
|
|
30
|
+
ref: N,
|
|
31
|
+
className: f(e.root, e[h], b && e.error, u?.root),
|
|
32
|
+
onChange: W,
|
|
33
|
+
...L,
|
|
34
|
+
children: [
|
|
35
|
+
H && /* @__PURE__ */ o("option", { value: "", disabled: !0, children: H }),
|
|
36
|
+
p ? p.map((s) => /* @__PURE__ */ o("option", { value: s.value, disabled: s.disabled, children: s.label }, s.value)) : y
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
/* @__PURE__ */ o("span", { className: f(e.arrow, u?.arrow) })
|
|
41
|
+
] });
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
se.displayName = "NativeSelect";
|
|
45
|
+
const ce = ne(
|
|
46
|
+
({
|
|
47
|
+
inputSize: h = "md",
|
|
48
|
+
error: b = !1,
|
|
49
|
+
options: p = [],
|
|
50
|
+
placeholder: H = "Select...",
|
|
51
|
+
classes: u,
|
|
52
|
+
className: F,
|
|
53
|
+
style: U,
|
|
54
|
+
value: y,
|
|
55
|
+
disabled: g,
|
|
56
|
+
id: ee,
|
|
57
|
+
searchPlaceholder: te = "Search...",
|
|
58
|
+
onChange: v,
|
|
59
|
+
onValueChange: L,
|
|
60
|
+
portal: N = !0
|
|
61
|
+
}, W) => {
|
|
62
|
+
const [s, B] = Q(!1), [M, X] = Q(""), [c, d] = Q(0), K = w(null), I = w(null), A = w(null), R = w(null), k = w(null), $ = le(), O = oe(K, s && N), re = w(null), T = W ?? re, z = w(!1);
|
|
63
|
+
q(() => {
|
|
64
|
+
z.current && !s && A.current?.focus(), z.current = s;
|
|
65
|
+
}, [s]);
|
|
66
|
+
const C = S(() => {
|
|
67
|
+
B(!1), X(""), d(0);
|
|
68
|
+
}, []), G = S(() => {
|
|
69
|
+
g || (B(!0), X(""), d(0), setTimeout(() => I.current?.focus(), 0));
|
|
70
|
+
}, [g]), J = S(
|
|
71
|
+
(n) => {
|
|
72
|
+
if (L?.(n), T.current) {
|
|
73
|
+
Object.getOwnPropertyDescriptor(
|
|
74
|
+
HTMLSelectElement.prototype,
|
|
75
|
+
"value"
|
|
76
|
+
)?.set?.call(T.current, n);
|
|
77
|
+
const r = new Event("change", { bubbles: !0 });
|
|
78
|
+
T.current.dispatchEvent(r), v?.(r);
|
|
79
|
+
}
|
|
80
|
+
C();
|
|
81
|
+
},
|
|
82
|
+
[L, v, T, C]
|
|
83
|
+
), x = ae(() => {
|
|
84
|
+
if (!M) return p;
|
|
85
|
+
const n = M.toLowerCase();
|
|
86
|
+
return p.filter((a) => a.label.toLowerCase().includes(n));
|
|
87
|
+
}, [p, M]);
|
|
88
|
+
q(() => {
|
|
89
|
+
const n = x.findIndex((a) => !a.disabled);
|
|
90
|
+
d(n >= 0 ? n : 0);
|
|
91
|
+
}, [x]), q(() => {
|
|
92
|
+
if (!s) return;
|
|
93
|
+
const n = k.current;
|
|
94
|
+
if (!n) return;
|
|
95
|
+
n.querySelectorAll('[role="option"]')[c]?.scrollIntoView?.({ block: "nearest" });
|
|
96
|
+
}, [c, s]);
|
|
97
|
+
const E = S(
|
|
98
|
+
(n) => {
|
|
99
|
+
const a = x.map((r, m) => r.disabled ? -1 : m).filter((r) => r >= 0);
|
|
100
|
+
if (a.length !== 0)
|
|
101
|
+
if (n.key === "ArrowDown")
|
|
102
|
+
n.preventDefault(), d((r) => {
|
|
103
|
+
const m = a.indexOf(r);
|
|
104
|
+
return m < a.length - 1 ? a[m + 1] : a[0];
|
|
105
|
+
});
|
|
106
|
+
else if (n.key === "ArrowUp")
|
|
107
|
+
n.preventDefault(), d((r) => {
|
|
108
|
+
const m = a.indexOf(r);
|
|
109
|
+
return m > 0 ? a[m - 1] : a[a.length - 1];
|
|
110
|
+
});
|
|
111
|
+
else if (n.key === "Enter") {
|
|
112
|
+
n.preventDefault();
|
|
113
|
+
const r = x[c];
|
|
114
|
+
r && !r.disabled && J(r.value);
|
|
115
|
+
} else n.key === "Escape" && (n.preventDefault(), C());
|
|
116
|
+
},
|
|
117
|
+
[x, c, J, C]
|
|
118
|
+
);
|
|
119
|
+
q(() => {
|
|
120
|
+
if (!s) return;
|
|
121
|
+
const n = (a) => {
|
|
122
|
+
const r = a.target;
|
|
123
|
+
K.current?.contains(r) || R.current?.contains(r) || C();
|
|
124
|
+
};
|
|
125
|
+
return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
|
|
126
|
+
}, [s, C]);
|
|
127
|
+
const _ = p.find((n) => n.value === y)?.label, Y = x.filter((n) => !n.disabled);
|
|
128
|
+
return /* @__PURE__ */ P(
|
|
129
|
+
"div",
|
|
130
|
+
{
|
|
131
|
+
ref: K,
|
|
132
|
+
className: f(
|
|
133
|
+
e.wrapper,
|
|
134
|
+
e.searchableWrapper,
|
|
135
|
+
e[h],
|
|
136
|
+
b && e.error,
|
|
137
|
+
g && e.disabled,
|
|
138
|
+
u?.wrapper,
|
|
139
|
+
F
|
|
140
|
+
),
|
|
141
|
+
style: U,
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ o(
|
|
144
|
+
"select",
|
|
145
|
+
{
|
|
146
|
+
ref: T,
|
|
147
|
+
className: e.hiddenSelect,
|
|
148
|
+
value: y ?? "",
|
|
149
|
+
disabled: g,
|
|
150
|
+
tabIndex: -1,
|
|
151
|
+
"aria-hidden": "true",
|
|
152
|
+
onChange: () => {
|
|
153
|
+
},
|
|
154
|
+
children: p.map((n) => /* @__PURE__ */ o("option", { value: n.value, children: n.label }, n.value))
|
|
155
|
+
}
|
|
156
|
+
),
|
|
157
|
+
/* @__PURE__ */ P(
|
|
158
|
+
"button",
|
|
159
|
+
{
|
|
160
|
+
ref: A,
|
|
161
|
+
id: ee,
|
|
162
|
+
type: "button",
|
|
163
|
+
className: f(
|
|
164
|
+
e.root,
|
|
165
|
+
e.searchableTrigger,
|
|
166
|
+
e[h],
|
|
167
|
+
s && e.triggerOpen,
|
|
168
|
+
b && e.error,
|
|
169
|
+
s && e.visuallyHidden,
|
|
170
|
+
u?.root
|
|
171
|
+
),
|
|
172
|
+
onClick: G,
|
|
173
|
+
disabled: g,
|
|
174
|
+
"aria-expanded": s,
|
|
175
|
+
"aria-haspopup": "listbox",
|
|
176
|
+
"aria-controls": s ? $ : void 0,
|
|
177
|
+
children: [
|
|
178
|
+
/* @__PURE__ */ o("span", { className: f(e.triggerLabel, !_ && e.placeholder), children: _ || H }),
|
|
179
|
+
/* @__PURE__ */ o("span", { className: f(e.arrow, e.arrowInline, u?.arrow) })
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
s && /* @__PURE__ */ o(
|
|
184
|
+
"input",
|
|
185
|
+
{
|
|
186
|
+
ref: I,
|
|
187
|
+
type: "text",
|
|
188
|
+
role: "combobox",
|
|
189
|
+
className: f(
|
|
190
|
+
e.root,
|
|
191
|
+
e.searchableTrigger,
|
|
192
|
+
e[h],
|
|
193
|
+
e.triggerOpen,
|
|
194
|
+
b && e.error,
|
|
195
|
+
u?.root,
|
|
196
|
+
u?.search
|
|
197
|
+
),
|
|
198
|
+
placeholder: _ || H,
|
|
199
|
+
value: M,
|
|
200
|
+
onChange: (n) => X(n.target.value),
|
|
201
|
+
onKeyDown: E,
|
|
202
|
+
"aria-expanded": !0,
|
|
203
|
+
"aria-haspopup": "listbox",
|
|
204
|
+
"aria-controls": $,
|
|
205
|
+
"aria-activedescendant": Y.length > 0 ? `select-option-${x[c]?.value}` : void 0
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
s && (() => {
|
|
209
|
+
const n = N ? {
|
|
210
|
+
position: "fixed",
|
|
211
|
+
top: O.top + 4,
|
|
212
|
+
left: O.left,
|
|
213
|
+
right: "auto",
|
|
214
|
+
width: O.width,
|
|
215
|
+
zIndex: "var(--crk-z-floating)"
|
|
216
|
+
} : void 0, a = /* @__PURE__ */ o(
|
|
217
|
+
"div",
|
|
218
|
+
{
|
|
219
|
+
id: $,
|
|
220
|
+
ref: R,
|
|
221
|
+
className: f(e.menu, u?.menu),
|
|
222
|
+
style: n,
|
|
223
|
+
role: "listbox",
|
|
224
|
+
children: /* @__PURE__ */ o("div", { className: e.menuItems, ref: k, children: x.length === 0 ? /* @__PURE__ */ o("div", { className: e.noResults, children: "No results" }) : x.map((r, m) => /* @__PURE__ */ o(
|
|
225
|
+
"button",
|
|
226
|
+
{
|
|
227
|
+
id: `select-option-${r.value}`,
|
|
228
|
+
type: "button",
|
|
229
|
+
role: "option",
|
|
230
|
+
"aria-selected": r.value === y,
|
|
231
|
+
className: f(
|
|
232
|
+
e.item,
|
|
233
|
+
r.disabled && e.itemDisabled,
|
|
234
|
+
r.value === y && e.itemSelected,
|
|
235
|
+
m === c && e.itemHighlighted,
|
|
236
|
+
u?.item
|
|
237
|
+
),
|
|
238
|
+
disabled: r.disabled,
|
|
239
|
+
onClick: () => J(r.value),
|
|
240
|
+
onMouseEnter: () => d(m),
|
|
241
|
+
children: r.content ?? r.label
|
|
242
|
+
},
|
|
243
|
+
r.value
|
|
244
|
+
)) })
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
return N && typeof document < "u" ? ie(a, document.body) : a;
|
|
248
|
+
})()
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
ce.displayName = "SearchableSelect";
|
|
255
|
+
const ue = ne(
|
|
256
|
+
({
|
|
257
|
+
inputSize: h = "md",
|
|
258
|
+
error: b = !1,
|
|
259
|
+
options: p = [],
|
|
260
|
+
placeholder: H = "Select...",
|
|
261
|
+
classes: u,
|
|
262
|
+
className: F,
|
|
263
|
+
style: U,
|
|
264
|
+
value: y,
|
|
265
|
+
disabled: g,
|
|
266
|
+
id: ee,
|
|
267
|
+
searchPlaceholder: te,
|
|
268
|
+
onValuesChange: v,
|
|
269
|
+
clearSearchOnSelect: L = !0,
|
|
270
|
+
closeOnSelect: N = !0,
|
|
271
|
+
allowCreate: W = !1,
|
|
272
|
+
onCreate: s,
|
|
273
|
+
createLabel: B,
|
|
274
|
+
portal: M = !0
|
|
275
|
+
}, X) => {
|
|
276
|
+
const c = Array.isArray(y) ? y : y ? [y] : [], [d, K] = Q(!1), [I, A] = Q(""), [R, k] = Q(0), $ = w(null), O = w(null), re = w(null), T = w(null), z = w(null), C = le(), G = oe(z, d && M), J = w(null), x = X ?? J, E = S(() => {
|
|
277
|
+
K(!1), A(""), k(0);
|
|
278
|
+
}, []), _ = S(() => {
|
|
279
|
+
g || (K(!0), A(""), k(0), setTimeout(() => O.current?.focus(), 0));
|
|
280
|
+
}, [g]), Y = S(
|
|
281
|
+
(t) => {
|
|
282
|
+
const i = c.includes(t) ? c.filter((l) => l !== t) : [...c, t];
|
|
283
|
+
v?.(i), N ? E() : L && A("");
|
|
284
|
+
},
|
|
285
|
+
[c, v, N, E, L]
|
|
286
|
+
), n = S(
|
|
287
|
+
(t, i) => {
|
|
288
|
+
i.stopPropagation(), v?.(c.filter((l) => l !== t));
|
|
289
|
+
},
|
|
290
|
+
[c, v]
|
|
291
|
+
), a = ae(() => {
|
|
292
|
+
if (!I) return p;
|
|
293
|
+
const t = I.toLowerCase();
|
|
294
|
+
return p.filter((i) => i.label.toLowerCase().includes(t));
|
|
295
|
+
}, [p, I]), r = I.trim(), m = W && r.length > 0 && !p.some(
|
|
296
|
+
(t) => t.label.toLowerCase() === r.toLowerCase() || t.value === r
|
|
297
|
+
) && !c.includes(r), j = S(() => {
|
|
298
|
+
r && (c.includes(r) || (s?.(r), v?.([...c, r]), N ? E() : L && A("")));
|
|
299
|
+
}, [r, c, s, v, N, E, L]);
|
|
300
|
+
q(() => {
|
|
301
|
+
const t = a.findIndex((i) => !i.disabled);
|
|
302
|
+
k(t >= 0 ? t : 0);
|
|
303
|
+
}, [a]), q(() => {
|
|
304
|
+
if (!d) return;
|
|
305
|
+
const t = T.current;
|
|
306
|
+
if (!t) return;
|
|
307
|
+
t.querySelectorAll('[role="option"]')[R]?.scrollIntoView?.({ block: "nearest" });
|
|
308
|
+
}, [R, d]);
|
|
309
|
+
const Z = a.length, de = S(
|
|
310
|
+
(t) => {
|
|
311
|
+
const i = a.map((l, D) => l.disabled ? -1 : D).filter((l) => l >= 0);
|
|
312
|
+
if (m && i.push(Z), t.key === "Backspace" && I === "" && c.length > 0) {
|
|
313
|
+
t.preventDefault(), v?.(c.slice(0, -1));
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (i.length !== 0)
|
|
317
|
+
if (t.key === "ArrowDown") {
|
|
318
|
+
if (t.preventDefault(), !d) {
|
|
319
|
+
_();
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
k((l) => {
|
|
323
|
+
const D = i.indexOf(l);
|
|
324
|
+
return D < i.length - 1 ? i[D + 1] : i[0];
|
|
325
|
+
});
|
|
326
|
+
} else if (t.key === "ArrowUp")
|
|
327
|
+
t.preventDefault(), k((l) => {
|
|
328
|
+
const D = i.indexOf(l);
|
|
329
|
+
return D > 0 ? i[D - 1] : i[i.length - 1];
|
|
330
|
+
});
|
|
331
|
+
else if (t.key === "Enter") {
|
|
332
|
+
if (t.preventDefault(), m && R === Z) {
|
|
333
|
+
j();
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const l = a[R];
|
|
337
|
+
l && !l.disabled ? Y(l.value) : m && j();
|
|
338
|
+
} else t.key === "Escape" && (t.preventDefault(), E());
|
|
339
|
+
},
|
|
340
|
+
[a, R, Y, E, I, c, v, d, _, m, j, Z]
|
|
341
|
+
);
|
|
342
|
+
q(() => {
|
|
343
|
+
if (!d) return;
|
|
344
|
+
const t = (i) => {
|
|
345
|
+
const l = i.target;
|
|
346
|
+
$.current?.contains(l) || re.current?.contains(l) || E();
|
|
347
|
+
};
|
|
348
|
+
return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
|
|
349
|
+
}, [d, E]);
|
|
350
|
+
const fe = c.map((t) => p.find((l) => l.value === t) ?? { value: t, label: t });
|
|
351
|
+
return /* @__PURE__ */ P(
|
|
352
|
+
"div",
|
|
353
|
+
{
|
|
354
|
+
ref: $,
|
|
355
|
+
className: f(
|
|
356
|
+
e.wrapper,
|
|
357
|
+
e.searchableWrapper,
|
|
358
|
+
e[h],
|
|
359
|
+
b && e.error,
|
|
360
|
+
g && e.disabled,
|
|
361
|
+
u?.wrapper,
|
|
362
|
+
F
|
|
363
|
+
),
|
|
364
|
+
style: U,
|
|
365
|
+
children: [
|
|
366
|
+
/* @__PURE__ */ o(
|
|
367
|
+
"select",
|
|
368
|
+
{
|
|
369
|
+
ref: x,
|
|
370
|
+
className: e.hiddenSelect,
|
|
371
|
+
multiple: !0,
|
|
372
|
+
value: c,
|
|
373
|
+
disabled: g,
|
|
374
|
+
tabIndex: -1,
|
|
375
|
+
"aria-hidden": "true",
|
|
376
|
+
onChange: () => {
|
|
377
|
+
},
|
|
378
|
+
children: p.map((t) => /* @__PURE__ */ o("option", { value: t.value, children: t.label }, t.value))
|
|
379
|
+
}
|
|
380
|
+
),
|
|
381
|
+
/* @__PURE__ */ P(
|
|
382
|
+
"div",
|
|
383
|
+
{
|
|
384
|
+
ref: z,
|
|
385
|
+
className: f(
|
|
386
|
+
e.multiTrigger,
|
|
387
|
+
e[h],
|
|
388
|
+
d && e.triggerOpen,
|
|
389
|
+
b && e.error,
|
|
390
|
+
g && e.multiTriggerDisabled,
|
|
391
|
+
u?.root
|
|
392
|
+
),
|
|
393
|
+
onClick: () => {
|
|
394
|
+
d ? O.current?.focus() : _();
|
|
395
|
+
},
|
|
396
|
+
role: "combobox",
|
|
397
|
+
"aria-expanded": d,
|
|
398
|
+
"aria-haspopup": "listbox",
|
|
399
|
+
"aria-controls": d ? C : void 0,
|
|
400
|
+
children: [
|
|
401
|
+
fe.map((t) => /* @__PURE__ */ P("span", { className: f(e.chip, u?.chip), children: [
|
|
402
|
+
/* @__PURE__ */ o("span", { className: e.chipLabel, children: t.content ?? t.label }),
|
|
403
|
+
/* @__PURE__ */ o(
|
|
404
|
+
"button",
|
|
405
|
+
{
|
|
406
|
+
type: "button",
|
|
407
|
+
className: f(e.chipRemove, u?.chipRemove),
|
|
408
|
+
onClick: (i) => n(t.value, i),
|
|
409
|
+
"aria-label": `Remove ${t.label}`,
|
|
410
|
+
tabIndex: -1,
|
|
411
|
+
children: "×"
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
] }, t.value)),
|
|
415
|
+
/* @__PURE__ */ o(
|
|
416
|
+
"input",
|
|
417
|
+
{
|
|
418
|
+
ref: O,
|
|
419
|
+
id: ee,
|
|
420
|
+
type: "text",
|
|
421
|
+
className: e.multiSearch,
|
|
422
|
+
placeholder: c.length === 0 ? H : "",
|
|
423
|
+
value: I,
|
|
424
|
+
onChange: (t) => {
|
|
425
|
+
A(t.target.value), d || _();
|
|
426
|
+
},
|
|
427
|
+
onKeyDown: de,
|
|
428
|
+
disabled: g,
|
|
429
|
+
"aria-label": "Search options"
|
|
430
|
+
}
|
|
431
|
+
),
|
|
432
|
+
/* @__PURE__ */ o("span", { className: f(e.arrow, e.arrowMulti, u?.arrow) })
|
|
433
|
+
]
|
|
434
|
+
}
|
|
435
|
+
),
|
|
436
|
+
d && (() => {
|
|
437
|
+
const t = M ? {
|
|
438
|
+
position: "fixed",
|
|
439
|
+
top: G.top + 4,
|
|
440
|
+
left: G.left,
|
|
441
|
+
right: "auto",
|
|
442
|
+
width: G.width,
|
|
443
|
+
zIndex: "var(--crk-z-floating)"
|
|
444
|
+
} : void 0, i = /* @__PURE__ */ o(
|
|
445
|
+
"div",
|
|
446
|
+
{
|
|
447
|
+
id: C,
|
|
448
|
+
ref: re,
|
|
449
|
+
className: f(e.menu, u?.menu),
|
|
450
|
+
style: t,
|
|
451
|
+
role: "listbox",
|
|
452
|
+
"aria-multiselectable": "true",
|
|
453
|
+
children: /* @__PURE__ */ P("div", { className: e.menuItems, ref: T, children: [
|
|
454
|
+
a.length === 0 && !m && /* @__PURE__ */ o("div", { className: e.noResults, children: "No results" }),
|
|
455
|
+
a.map((l, D) => {
|
|
456
|
+
const V = c.includes(l.value);
|
|
457
|
+
return /* @__PURE__ */ P(
|
|
458
|
+
"button",
|
|
459
|
+
{
|
|
460
|
+
id: `select-option-${l.value}`,
|
|
461
|
+
type: "button",
|
|
462
|
+
role: "option",
|
|
463
|
+
"aria-selected": V,
|
|
464
|
+
className: f(
|
|
465
|
+
e.item,
|
|
466
|
+
l.disabled && e.itemDisabled,
|
|
467
|
+
V && e.itemSelected,
|
|
468
|
+
D === R && e.itemHighlighted,
|
|
469
|
+
u?.item
|
|
470
|
+
),
|
|
471
|
+
disabled: l.disabled,
|
|
472
|
+
onClick: () => Y(l.value),
|
|
473
|
+
onMouseEnter: () => k(D),
|
|
474
|
+
children: [
|
|
475
|
+
V && /* @__PURE__ */ o("span", { className: e.itemCheck, "aria-hidden": "true" }),
|
|
476
|
+
l.content ?? l.label
|
|
477
|
+
]
|
|
478
|
+
},
|
|
479
|
+
l.value
|
|
480
|
+
);
|
|
481
|
+
}),
|
|
482
|
+
m && /* @__PURE__ */ o(
|
|
483
|
+
"button",
|
|
484
|
+
{
|
|
485
|
+
type: "button",
|
|
486
|
+
role: "option",
|
|
487
|
+
"aria-selected": !1,
|
|
488
|
+
className: f(
|
|
489
|
+
e.item,
|
|
490
|
+
R === Z && e.itemHighlighted,
|
|
491
|
+
u?.item
|
|
492
|
+
),
|
|
493
|
+
onClick: j,
|
|
494
|
+
onMouseEnter: () => k(Z),
|
|
495
|
+
children: B ? B(r) : /* @__PURE__ */ P(me, { children: [
|
|
496
|
+
"Create “",
|
|
497
|
+
/* @__PURE__ */ o("strong", { children: r }),
|
|
498
|
+
"”"
|
|
499
|
+
] })
|
|
500
|
+
},
|
|
501
|
+
"__create__"
|
|
502
|
+
)
|
|
503
|
+
] })
|
|
504
|
+
}
|
|
505
|
+
);
|
|
506
|
+
return M && typeof document < "u" ? ie(i, document.body) : i;
|
|
507
|
+
})()
|
|
508
|
+
]
|
|
509
|
+
}
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
);
|
|
513
|
+
ue.displayName = "MultiSelect";
|
|
514
|
+
const he = ne(
|
|
515
|
+
(h, b) => h.multiple ? /* @__PURE__ */ o(ue, { ref: b, ...h }) : h.searchable ? /* @__PURE__ */ o(ce, { ref: b, ...h }) : /* @__PURE__ */ o(se, { ref: b, ...h })
|
|
516
|
+
);
|
|
517
|
+
he.displayName = "Select";
|
|
518
|
+
export {
|
|
519
|
+
he as Select
|
|
520
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const e = "crk-wrapper-SP2JE", r = "crk-sm-DqshL", c = "crk-md-j4AKI", t = "crk-lg-24Xd3", i = "crk-root-Uu9Ah", s = "crk-error-9oRU6", l = "crk-arrow-WU8ZW", n = "crk-searchableWrapper-7AL4l", o = "crk-hiddenSelect-s3DEx", a = "crk-searchableTrigger-m-GWV", m = "crk-triggerOpen-Lo8-j", g = "crk-triggerLabel-5rETZ", d = "crk-placeholder-teBBh", h = "crk-arrowInline-m-roG", k = "crk-disabled-pcSeq", u = "crk-visuallyHidden-2tTD5", p = "crk-menu--i-je", b = "crk-menuEnter-vJjLV", w = "crk-menuItems-VrZnE", S = "crk-item-fU3XI", T = "crk-itemHighlighted-MvR41", L = "crk-itemDisabled-KTUO8", D = "crk-itemSelected-42-BG", R = "crk-noResults-uicSW", v = "crk-multiTrigger-Pd3wJ", H = "crk-multiTriggerDisabled-9ajge", I = "crk-chip-TuYUB", W = "crk-chipLabel-H4JWu", E = "crk-chipRemove-Lfk0R", U = "crk-multiSearch-OrVeS", j = "crk-arrowMulti-Nh9Hr", B = "crk-itemCheck-DPB5A", O = {
|
|
2
|
+
wrapper: e,
|
|
3
|
+
sm: r,
|
|
4
|
+
md: c,
|
|
5
|
+
lg: t,
|
|
6
|
+
root: i,
|
|
7
|
+
error: s,
|
|
8
|
+
arrow: l,
|
|
9
|
+
searchableWrapper: n,
|
|
10
|
+
hiddenSelect: o,
|
|
11
|
+
searchableTrigger: a,
|
|
12
|
+
triggerOpen: m,
|
|
13
|
+
triggerLabel: g,
|
|
14
|
+
placeholder: d,
|
|
15
|
+
arrowInline: h,
|
|
16
|
+
disabled: k,
|
|
17
|
+
visuallyHidden: u,
|
|
18
|
+
menu: p,
|
|
19
|
+
menuEnter: b,
|
|
20
|
+
menuItems: w,
|
|
21
|
+
item: S,
|
|
22
|
+
itemHighlighted: T,
|
|
23
|
+
itemDisabled: L,
|
|
24
|
+
itemSelected: D,
|
|
25
|
+
noResults: R,
|
|
26
|
+
multiTrigger: v,
|
|
27
|
+
multiTriggerDisabled: H,
|
|
28
|
+
chip: I,
|
|
29
|
+
chipLabel: W,
|
|
30
|
+
chipRemove: E,
|
|
31
|
+
multiSearch: U,
|
|
32
|
+
arrowMulti: j,
|
|
33
|
+
itemCheck: B
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
l as arrow,
|
|
37
|
+
h as arrowInline,
|
|
38
|
+
j as arrowMulti,
|
|
39
|
+
I as chip,
|
|
40
|
+
W as chipLabel,
|
|
41
|
+
E as chipRemove,
|
|
42
|
+
O as default,
|
|
43
|
+
k as disabled,
|
|
44
|
+
s as error,
|
|
45
|
+
o as hiddenSelect,
|
|
46
|
+
S as item,
|
|
47
|
+
B as itemCheck,
|
|
48
|
+
L as itemDisabled,
|
|
49
|
+
T as itemHighlighted,
|
|
50
|
+
D as itemSelected,
|
|
51
|
+
t as lg,
|
|
52
|
+
c as md,
|
|
53
|
+
p as menu,
|
|
54
|
+
b as menuEnter,
|
|
55
|
+
w as menuItems,
|
|
56
|
+
U as multiSearch,
|
|
57
|
+
v as multiTrigger,
|
|
58
|
+
H as multiTriggerDisabled,
|
|
59
|
+
R as noResults,
|
|
60
|
+
d as placeholder,
|
|
61
|
+
i as root,
|
|
62
|
+
a as searchableTrigger,
|
|
63
|
+
n as searchableWrapper,
|
|
64
|
+
r as sm,
|
|
65
|
+
g as triggerLabel,
|
|
66
|
+
m as triggerOpen,
|
|
67
|
+
u as visuallyHidden,
|
|
68
|
+
e as wrapper
|
|
69
|
+
};
|