@stackone/malachite 2.47.1 → 2.47.2
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/dist/components/Dropdown.js +109 -108
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/MultiSelect.js +138 -134
- package/dist/components/MultiSelect.js.map +1 -1
- package/dist/components/dropdownTriggerStyle.js +50 -21
- package/dist/components/dropdownTriggerStyle.js.map +1 -1
- package/dist/components/focusRing.js +6 -7
- package/dist/components/focusRing.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as r, jsxs as w, Fragment as mt } from "react/jsx-runtime";
|
|
2
|
-
import fe, { useId as pt, useState as P, useRef as T, useMemo as H, useCallback as
|
|
2
|
+
import fe, { useId as pt, useState as P, useRef as T, useMemo as H, useCallback as h, useEffect as We, useLayoutEffect as ht, useInsertionEffect as gt } from "react";
|
|
3
3
|
import { createPortal as bt } from "react-dom";
|
|
4
4
|
import vt, { useFormFieldIds as xt } from "./BaseFormComponent.js";
|
|
5
5
|
import yt from "./CustomIcons/CaretDownIcon.js";
|
|
@@ -12,68 +12,68 @@ import Be from "./Tooltip.js";
|
|
|
12
12
|
import { getDeepActiveElement as Tt } from "./activeElement.js";
|
|
13
13
|
import { CONTROL_TEXT_SIZE_CLASS as ue, CONTROL_TEXT_SIZE as kt } from "./controlTextSize.js";
|
|
14
14
|
import { controlWidthStyle as Ge } from "./controlWidth.js";
|
|
15
|
-
import { getTriggerVisual as
|
|
16
|
-
import { pushEscapeLayer as
|
|
17
|
-
import { measureMenuGeometry as
|
|
18
|
-
import { FOCUS_RING as Ct
|
|
19
|
-
import { hasBadge as
|
|
20
|
-
import { ensureMultiSelectPanelStyles as
|
|
21
|
-
import { usePopupLayer as
|
|
22
|
-
import { useTopLayer as
|
|
23
|
-
import { tooltipLines as
|
|
24
|
-
const
|
|
15
|
+
import { getTriggerVisual as Lt, DROPDOWN_TRIGGER_ATTR as Rt } from "./dropdownTriggerStyle.js";
|
|
16
|
+
import { pushEscapeLayer as Ot } from "./escapeLayers.js";
|
|
17
|
+
import { measureMenuGeometry as _t, MENU_MAX_HEIGHT_PX as Nt, MENU_SPECS as z } from "./floatingMenuGeometry.js";
|
|
18
|
+
import { FOCUS_RING as Ct } from "./focusRing.js";
|
|
19
|
+
import { hasBadge as At } from "./hasBadge.js";
|
|
20
|
+
import { ensureMultiSelectPanelStyles as Dt } from "./optionRowStyles.js";
|
|
21
|
+
import { usePopupLayer as Ht } from "./overlayLayers.js";
|
|
22
|
+
import { useTopLayer as Pt } from "./topLayer.js";
|
|
23
|
+
import { tooltipLines as Mt, isCut as Wt, isClamped as $t } from "./truncatedLines.js";
|
|
24
|
+
const Bt = fe.lazy(() => import("./ActionMenuTagHost.js")), Gt = {
|
|
25
25
|
padding: "8px 10px",
|
|
26
26
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))"
|
|
27
|
-
},
|
|
27
|
+
}, F = {
|
|
28
28
|
small: "h-[var(--malachite-control-height-small,28px)]",
|
|
29
29
|
medium: "h-[var(--malachite-control-height-medium,32px)]",
|
|
30
30
|
large: "h-[var(--malachite-control-height-large,42px)]"
|
|
31
31
|
}, zt = {
|
|
32
|
-
small: `${
|
|
33
|
-
medium: `${
|
|
34
|
-
large: `${
|
|
35
|
-
},
|
|
36
|
-
({ triggerRole: n, disabled: k, children:
|
|
32
|
+
small: `${F.small} gap-[6px] px-2.5 ${ue.small} rounded-[var(--malachite-radius-10,10px)]`,
|
|
33
|
+
medium: `${F.medium} gap-[8px] px-3 ${ue.medium} rounded-xl`,
|
|
34
|
+
large: `${F.large} gap-[10px] px-4 ${ue.large} rounded-[var(--malachite-radius-xxl,14px)]`
|
|
35
|
+
}, Ft = 10, Ke = "ArrowDown", Ye = "ArrowUp", Ue = "Enter", Kt = "Backspace", Yt = /* @__PURE__ */ new Set([Ke, Ye, Ue]), Ve = fe.forwardRef(
|
|
36
|
+
({ triggerRole: n, disabled: k, children: R, ...u }, b) => n !== "button" ? /* @__PURE__ */ r(
|
|
37
37
|
"div",
|
|
38
38
|
{
|
|
39
|
-
ref:
|
|
39
|
+
ref: b,
|
|
40
40
|
role: n,
|
|
41
41
|
tabIndex: k ? -1 : 0,
|
|
42
42
|
...u,
|
|
43
|
-
children:
|
|
43
|
+
children: R
|
|
44
44
|
}
|
|
45
45
|
) : /* @__PURE__ */ r(
|
|
46
46
|
"button",
|
|
47
47
|
{
|
|
48
|
-
ref:
|
|
48
|
+
ref: b,
|
|
49
49
|
type: "button",
|
|
50
50
|
disabled: k,
|
|
51
51
|
...u,
|
|
52
|
-
children:
|
|
52
|
+
children: R
|
|
53
53
|
}
|
|
54
54
|
)
|
|
55
55
|
);
|
|
56
56
|
Ve.displayName = "TriggerElement";
|
|
57
|
-
const
|
|
58
|
-
const k = T(null),
|
|
59
|
-
const E =
|
|
60
|
-
return !E && !
|
|
61
|
-
}, M = u === "hover" ||
|
|
57
|
+
const ze = 0.6, Fe = 420, Ut = ({ option: n }) => {
|
|
58
|
+
const k = T(null), R = T(null), u = n.description ? n.descriptionMode ?? "icon" : null, b = u === "subtitle", [N, Z] = P({ label: !0, subtitle: !0 }), C = () => {
|
|
59
|
+
const E = Wt(k.current), f = $t(R.current);
|
|
60
|
+
return !E && !f && u !== "hover" ? !1 : (Z({ label: E, subtitle: f }), !0);
|
|
61
|
+
}, M = u === "hover" || b && N.subtitle, W = (E) => /* @__PURE__ */ r(
|
|
62
62
|
Be,
|
|
63
63
|
{
|
|
64
|
-
text:
|
|
64
|
+
text: Mt([
|
|
65
65
|
["label", N.label && n.label],
|
|
66
66
|
["description", M && n.description]
|
|
67
67
|
]),
|
|
68
68
|
shouldShow: C,
|
|
69
|
-
delay:
|
|
70
|
-
maxWidth:
|
|
69
|
+
delay: ze,
|
|
70
|
+
maxWidth: Fe,
|
|
71
71
|
triggerAs: "span",
|
|
72
72
|
isShrinkable: !0,
|
|
73
73
|
describesTrigger: u === "hover",
|
|
74
74
|
children: E
|
|
75
75
|
}
|
|
76
|
-
),
|
|
76
|
+
), p = /* @__PURE__ */ r(
|
|
77
77
|
"span",
|
|
78
78
|
{
|
|
79
79
|
ref: k,
|
|
@@ -86,7 +86,7 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
86
86
|
children: n.label
|
|
87
87
|
}
|
|
88
88
|
);
|
|
89
|
-
return
|
|
89
|
+
return b ? W(
|
|
90
90
|
/* @__PURE__ */ w(
|
|
91
91
|
"span",
|
|
92
92
|
{
|
|
@@ -99,11 +99,11 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
99
99
|
gap: 2
|
|
100
100
|
},
|
|
101
101
|
children: [
|
|
102
|
-
|
|
102
|
+
p,
|
|
103
103
|
/* @__PURE__ */ r(
|
|
104
104
|
"span",
|
|
105
105
|
{
|
|
106
|
-
ref:
|
|
106
|
+
ref: R,
|
|
107
107
|
style: {
|
|
108
108
|
fontSize: 12,
|
|
109
109
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
@@ -133,13 +133,13 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
133
133
|
gap: 6
|
|
134
134
|
},
|
|
135
135
|
children: [
|
|
136
|
-
W(
|
|
136
|
+
W(p),
|
|
137
137
|
u === "icon" && /* @__PURE__ */ r(
|
|
138
138
|
Be,
|
|
139
139
|
{
|
|
140
140
|
text: n.description,
|
|
141
|
-
delay:
|
|
142
|
-
maxWidth:
|
|
141
|
+
delay: ze,
|
|
142
|
+
maxWidth: Fe,
|
|
143
143
|
children: /* @__PURE__ */ r(
|
|
144
144
|
"span",
|
|
145
145
|
{
|
|
@@ -157,20 +157,20 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
157
157
|
]
|
|
158
158
|
}
|
|
159
159
|
);
|
|
160
|
-
},
|
|
160
|
+
}, gr = ({
|
|
161
161
|
options: n,
|
|
162
162
|
value: k,
|
|
163
|
-
defaultValue:
|
|
163
|
+
defaultValue: R,
|
|
164
164
|
onChange: u,
|
|
165
|
-
placeholder:
|
|
165
|
+
placeholder: b = "Select",
|
|
166
166
|
renderTrigger: N,
|
|
167
167
|
searchable: Z,
|
|
168
168
|
size: C = "large",
|
|
169
169
|
width: M = "auto",
|
|
170
170
|
minWidth: W,
|
|
171
|
-
disabled:
|
|
171
|
+
disabled: p = !1,
|
|
172
172
|
error: E = !1,
|
|
173
|
-
loading:
|
|
173
|
+
loading: f = !1,
|
|
174
174
|
label: K,
|
|
175
175
|
name: me,
|
|
176
176
|
description: q,
|
|
@@ -197,34 +197,34 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
197
197
|
label: K,
|
|
198
198
|
description: q,
|
|
199
199
|
hint: J
|
|
200
|
-
}), [rt, nt] = P(() =>
|
|
201
|
-
|
|
202
|
-
const
|
|
200
|
+
}), [rt, nt] = P(() => R ?? []), re = k !== void 0, m = re ? k : rt, [o, ne] = P(!1), [c, Te] = P(null), [L, at] = P(""), [x, A] = P(-1), Y = T(null), B = T(null), O = T(null), ke = T(null);
|
|
201
|
+
Pt(O, o);
|
|
202
|
+
const ot = Ht("multiselect", o, O), Le = T([]), ae = H(() => new Set(m), [m]), s = H(
|
|
203
203
|
() => n.filter((e) => ae.has(e.value)),
|
|
204
204
|
[n, ae]
|
|
205
|
-
),
|
|
205
|
+
), oe = typeof be == "number" ? be : void 0, _ = H(() => {
|
|
206
206
|
if (!ve) return n;
|
|
207
|
-
const e =
|
|
207
|
+
const e = L.trim().toLowerCase();
|
|
208
208
|
return e ? n.filter((t) => (t.searchText ?? (typeof t.label == "string" ? t.label : "")).toLowerCase().includes(e)) : n;
|
|
209
|
-
}, [n,
|
|
209
|
+
}, [n, L, ve]), le = T(!1), Re = T(""), U = h(
|
|
210
210
|
(e, t) => {
|
|
211
|
-
|
|
211
|
+
Re.current !== e && (Re.current = e, t && (le.current = !0), at(e), $ == null || $(e));
|
|
212
212
|
},
|
|
213
213
|
[$]
|
|
214
|
-
), se =
|
|
215
|
-
(e) =>
|
|
216
|
-
[
|
|
217
|
-
), G =
|
|
214
|
+
), se = h(
|
|
215
|
+
(e) => U(e, !0),
|
|
216
|
+
[U]
|
|
217
|
+
), G = h(() => U("", !1), [U]);
|
|
218
218
|
We(() => {
|
|
219
|
-
|
|
220
|
-
}, [
|
|
221
|
-
const
|
|
219
|
+
le.current && (A(-1), le.current = !1);
|
|
220
|
+
}, [L]);
|
|
221
|
+
const lt = Z ?? ($ !== void 0 || n.length > Ft), Oe = v ? !1 : lt, ie = h(() => {
|
|
222
222
|
var e, t;
|
|
223
|
-
ne(!1), (e =
|
|
224
|
-
}, []), D =
|
|
225
|
-
const e =
|
|
223
|
+
ne(!1), (e = O.current) != null && e.contains(Tt()) && ((t = Y.current) == null || t.focus());
|
|
224
|
+
}, []), D = h(() => {
|
|
225
|
+
const e = Y.current;
|
|
226
226
|
if (!e) return;
|
|
227
|
-
const t =
|
|
227
|
+
const t = _t(O.current, {
|
|
228
228
|
triggerRect: e.getBoundingClientRect(),
|
|
229
229
|
preset: "standard",
|
|
230
230
|
minWidth: W,
|
|
@@ -241,9 +241,9 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
241
241
|
}
|
|
242
242
|
D(), v && ((S = B.current) == null || S.focus());
|
|
243
243
|
const e = () => D(), t = (y) => {
|
|
244
|
-
const d = y.composedPath(), a =
|
|
244
|
+
const d = y.composedPath(), a = Y.current, i = O.current;
|
|
245
245
|
(!a || !d.includes(a)) && (!i || !d.includes(i)) && ie();
|
|
246
|
-
}, l =
|
|
246
|
+
}, l = Ot(ie);
|
|
247
247
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), document.addEventListener("mousedown", t), () => {
|
|
248
248
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e), document.removeEventListener("mousedown", t), l();
|
|
249
249
|
};
|
|
@@ -251,97 +251,97 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
251
251
|
if (!o)
|
|
252
252
|
return;
|
|
253
253
|
D();
|
|
254
|
-
const e =
|
|
254
|
+
const e = O.current;
|
|
255
255
|
if (!e || typeof ResizeObserver > "u")
|
|
256
256
|
return;
|
|
257
257
|
const t = new ResizeObserver(() => D());
|
|
258
258
|
return t.observe(e), () => t.disconnect();
|
|
259
259
|
}, [o, D]);
|
|
260
|
-
const I =
|
|
260
|
+
const I = h(
|
|
261
261
|
(e) => {
|
|
262
262
|
re || nt(e), u == null || u(e);
|
|
263
263
|
},
|
|
264
264
|
[re, u]
|
|
265
|
-
), V =
|
|
265
|
+
), V = h(
|
|
266
266
|
(e) => n.some((t) => t.value === e && t.disabled),
|
|
267
267
|
[n]
|
|
268
|
-
), ce =
|
|
268
|
+
), ce = h(
|
|
269
269
|
(e) => {
|
|
270
|
-
V(e) || (
|
|
270
|
+
V(e) || (m.includes(e) ? I(m.filter((t) => t !== e)) : I([...m, e]));
|
|
271
271
|
},
|
|
272
|
-
[
|
|
272
|
+
[m, I, V]
|
|
273
273
|
), X = H(() => {
|
|
274
274
|
const e = /* @__PURE__ */ new Set();
|
|
275
275
|
for (const t of n)
|
|
276
276
|
t.disabled && e.add(t.value);
|
|
277
277
|
return e;
|
|
278
|
-
}, [n]), st =
|
|
278
|
+
}, [n]), st = h(
|
|
279
279
|
(e) => {
|
|
280
280
|
e.stopPropagation();
|
|
281
|
-
const t =
|
|
281
|
+
const t = m.filter((l) => X.has(l));
|
|
282
282
|
I(t);
|
|
283
283
|
},
|
|
284
|
-
[I,
|
|
285
|
-
),
|
|
284
|
+
[I, m, X]
|
|
285
|
+
), _e = h(
|
|
286
286
|
(e, t) => {
|
|
287
|
-
t.stopPropagation(), !V(e) && I(
|
|
287
|
+
t.stopPropagation(), !V(e) && I(m.filter((l) => l !== e));
|
|
288
288
|
},
|
|
289
|
-
[
|
|
290
|
-
), j =
|
|
289
|
+
[m, I, V]
|
|
290
|
+
), j = h(
|
|
291
291
|
(e) => {
|
|
292
292
|
if (!Yt.has(e.key)) return;
|
|
293
293
|
if (e.preventDefault(), e.stopPropagation(), !o) {
|
|
294
294
|
ne(!0);
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
const t =
|
|
297
|
+
const t = _.length;
|
|
298
298
|
if (t === 0) return;
|
|
299
299
|
const l = (d) => {
|
|
300
300
|
requestAnimationFrame(() => {
|
|
301
|
-
const a =
|
|
301
|
+
const a = Le.current[d], i = ke.current;
|
|
302
302
|
if (!a || !i) return;
|
|
303
|
-
const
|
|
303
|
+
const g = a.offsetTop, Pe = g + a.offsetHeight, Me = i.scrollTop, ft = Me + i.clientHeight;
|
|
304
304
|
Pe > ft ? i.scrollTo({
|
|
305
305
|
top: Pe - i.clientHeight,
|
|
306
306
|
behavior: "smooth"
|
|
307
|
-
}) :
|
|
307
|
+
}) : g < Me && i.scrollTo({ top: g, behavior: "smooth" });
|
|
308
308
|
});
|
|
309
309
|
}, S = (d) => {
|
|
310
310
|
var i;
|
|
311
311
|
let a = x;
|
|
312
|
-
for (let
|
|
313
|
-
if (a = d === 1 ? a < t - 1 ? a + 1 : 0 : a > 0 ? a - 1 : t - 1, !((i =
|
|
312
|
+
for (let g = 0; g < t; g++)
|
|
313
|
+
if (a = d === 1 ? a < t - 1 ? a + 1 : 0 : a > 0 ? a - 1 : t - 1, !((i = _[a]) != null && i.disabled)) {
|
|
314
314
|
l(a), A(a);
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
317
|
}, y = () => {
|
|
318
318
|
var i;
|
|
319
|
-
if (x < 0 || x >= t || (i =
|
|
320
|
-
const d =
|
|
319
|
+
if (x < 0 || x >= t || (i = _[x]) != null && i.disabled) return;
|
|
320
|
+
const d = _[x].value;
|
|
321
321
|
ce(d), G();
|
|
322
|
-
const a = n.findIndex((
|
|
322
|
+
const a = n.findIndex((g) => g.value === d);
|
|
323
323
|
A(a >= 0 ? a : -1), l(a >= 0 ? a : 0), requestAnimationFrame(() => {
|
|
324
|
-
var
|
|
325
|
-
return (
|
|
324
|
+
var g;
|
|
325
|
+
return (g = B.current) == null ? void 0 : g.focus();
|
|
326
326
|
});
|
|
327
327
|
};
|
|
328
328
|
switch (e.key) {
|
|
329
329
|
case Ke:
|
|
330
330
|
S(1);
|
|
331
331
|
break;
|
|
332
|
-
case
|
|
332
|
+
case Ye:
|
|
333
333
|
S(-1);
|
|
334
334
|
break;
|
|
335
|
-
case
|
|
335
|
+
case Ue:
|
|
336
336
|
y();
|
|
337
337
|
break;
|
|
338
338
|
}
|
|
339
339
|
},
|
|
340
|
-
[o,
|
|
341
|
-
), Ne =
|
|
340
|
+
[o, _, x, ce, n, G]
|
|
341
|
+
), Ne = h(
|
|
342
342
|
(e) => {
|
|
343
|
-
if (e.key ===
|
|
344
|
-
e.preventDefault(), I(
|
|
343
|
+
if (e.key === Kt && L === "" && m.length > 0) {
|
|
344
|
+
e.preventDefault(), I(m.slice(0, -1)), requestAnimationFrame(() => {
|
|
345
345
|
var t;
|
|
346
346
|
return (t = B.current) == null ? void 0 : t.focus();
|
|
347
347
|
});
|
|
@@ -349,22 +349,23 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
349
349
|
}
|
|
350
350
|
j(e);
|
|
351
351
|
},
|
|
352
|
-
[j,
|
|
353
|
-
), Ce = s.length > 0 && !
|
|
354
|
-
disabled:
|
|
352
|
+
[j, L, m, I]
|
|
353
|
+
), Ce = s.length > 0 && !p && !f, it = Lt({
|
|
354
|
+
disabled: p,
|
|
355
355
|
error: E,
|
|
356
356
|
open: o,
|
|
357
|
-
loading:
|
|
357
|
+
loading: f,
|
|
358
358
|
hasSelection: s.length > 0
|
|
359
359
|
}), de = H(() => v ? /* @__PURE__ */ r(
|
|
360
360
|
"input",
|
|
361
361
|
{
|
|
362
362
|
ref: B,
|
|
363
363
|
type: "text",
|
|
364
|
-
value:
|
|
364
|
+
value: L,
|
|
365
365
|
onChange: (e) => se(e.target.value),
|
|
366
366
|
onKeyDown: Ne,
|
|
367
|
-
|
|
367
|
+
disabled: p || f,
|
|
368
|
+
placeholder: s.length === 0 ? b : "",
|
|
368
369
|
className: "flex-1 w-full min-w-[40px] border-none outline-none bg-transparent text-[length:inherit] p-0 text-[var(--malachite-text-primary,rgb(10,10,10))]",
|
|
369
370
|
onMouseDown: (e) => {
|
|
370
371
|
e.preventDefault();
|
|
@@ -372,16 +373,18 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
372
373
|
}
|
|
373
374
|
) : null, [
|
|
374
375
|
v,
|
|
375
|
-
|
|
376
|
+
L,
|
|
376
377
|
se,
|
|
377
378
|
Ne,
|
|
379
|
+
p,
|
|
380
|
+
f,
|
|
378
381
|
s.length,
|
|
379
|
-
|
|
382
|
+
b
|
|
380
383
|
]), ct = H(() => {
|
|
381
384
|
if (N && s.length > 0)
|
|
382
385
|
return N(s);
|
|
383
386
|
if (ee && s.length > 0) {
|
|
384
|
-
const e =
|
|
387
|
+
const e = oe != null ? s.slice(0, oe) : s, t = s.length - e.length;
|
|
385
388
|
return /* @__PURE__ */ w(
|
|
386
389
|
"div",
|
|
387
390
|
{
|
|
@@ -396,7 +399,7 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
396
399
|
value: l.label,
|
|
397
400
|
type: "default",
|
|
398
401
|
textTransform: "none",
|
|
399
|
-
onRemove: te && !
|
|
402
|
+
onRemove: te && !p && !S ? (y) => _e(l.value, y) : void 0,
|
|
400
403
|
className: "shrink-0"
|
|
401
404
|
},
|
|
402
405
|
l.value
|
|
@@ -411,33 +414,33 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
411
414
|
}
|
|
412
415
|
);
|
|
413
416
|
}
|
|
414
|
-
return v && s.length === 0 ? de : s.length === 0 ? /* @__PURE__ */ r("span", { className: "text-[var(--malachite-text-placeholder)]", children:
|
|
417
|
+
return v && s.length === 0 ? de : s.length === 0 ? /* @__PURE__ */ r("span", { className: "text-[var(--malachite-text-placeholder)]", children: b }) : s.length === 1 ? /* @__PURE__ */ r("span", { children: s[0].label }) : /* @__PURE__ */ r("span", { children: `${s.length} selected` });
|
|
415
418
|
}, [
|
|
416
419
|
s,
|
|
417
420
|
N,
|
|
418
421
|
ee,
|
|
419
|
-
|
|
422
|
+
oe,
|
|
420
423
|
te,
|
|
421
|
-
|
|
422
|
-
|
|
424
|
+
p,
|
|
425
|
+
_e,
|
|
423
426
|
v,
|
|
424
427
|
de,
|
|
425
|
-
|
|
428
|
+
b,
|
|
426
429
|
X
|
|
427
430
|
]), dt = n.length === 0 ? "No options available" : "No results found";
|
|
428
431
|
gt(() => {
|
|
429
|
-
o &&
|
|
432
|
+
o && Dt();
|
|
430
433
|
}, [o]);
|
|
431
434
|
const ut = {
|
|
432
435
|
position: "fixed",
|
|
433
436
|
top: (c == null ? void 0 : c.top) ?? 0,
|
|
434
437
|
left: (c == null ? void 0 : c.left) ?? 0,
|
|
435
438
|
width: c == null ? void 0 : c.width,
|
|
436
|
-
background:
|
|
437
|
-
border:
|
|
438
|
-
borderRadius:
|
|
439
|
-
boxShadow:
|
|
440
|
-
padding:
|
|
439
|
+
background: z.standard.background,
|
|
440
|
+
border: z.standard.border,
|
|
441
|
+
borderRadius: z.standard.radius,
|
|
442
|
+
boxShadow: z.standard.shadow,
|
|
443
|
+
padding: z.standard.padding,
|
|
441
444
|
display: "flex",
|
|
442
445
|
flexDirection: "column",
|
|
443
446
|
gap: 4,
|
|
@@ -450,11 +453,12 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
450
453
|
/* @__PURE__ */ w(
|
|
451
454
|
Ve,
|
|
452
455
|
{
|
|
453
|
-
ref:
|
|
456
|
+
ref: Y,
|
|
454
457
|
id: Ie,
|
|
455
458
|
triggerRole: v ? "combobox" : ee && te ? "group" : "button",
|
|
456
|
-
disabled:
|
|
457
|
-
[
|
|
459
|
+
disabled: p || f,
|
|
460
|
+
[Rt]: "",
|
|
461
|
+
"data-open": o || void 0,
|
|
458
462
|
"aria-haspopup": "listbox",
|
|
459
463
|
"aria-expanded": o,
|
|
460
464
|
"aria-controls": o ? we : void 0,
|
|
@@ -464,9 +468,9 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
464
468
|
"aria-invalid": E || void 0,
|
|
465
469
|
"aria-required": Q || void 0,
|
|
466
470
|
"aria-describedby": tt,
|
|
467
|
-
"aria-busy":
|
|
471
|
+
"aria-busy": f || void 0,
|
|
468
472
|
onClick: () => {
|
|
469
|
-
|
|
473
|
+
p || f || ne((e) => !e);
|
|
470
474
|
},
|
|
471
475
|
onKeyDown: j,
|
|
472
476
|
style: {
|
|
@@ -474,7 +478,7 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
474
478
|
...it,
|
|
475
479
|
...Ze
|
|
476
480
|
},
|
|
477
|
-
className: `w-full ${zt[C]} border border-solid flex items-center font-normal text-[var(--malachite-text-primary)] ${
|
|
481
|
+
className: `w-full ${zt[C]} border border-solid flex items-center font-normal text-[var(--malachite-text-primary)] ${p || f ? "cursor-not-allowed" : "cursor-pointer"} ${Ct} ${je}`,
|
|
478
482
|
children: [
|
|
479
483
|
/* @__PURE__ */ r(
|
|
480
484
|
"span",
|
|
@@ -483,7 +487,7 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
483
487
|
children: ct
|
|
484
488
|
}
|
|
485
489
|
),
|
|
486
|
-
|
|
490
|
+
f ? /* @__PURE__ */ r("span", { className: "flex items-center justify-center shrink-0 size-[14px]", children: /* @__PURE__ */ r(It, { size: "xxxsmall" }) }) : /* @__PURE__ */ r(
|
|
487
491
|
yt,
|
|
488
492
|
{
|
|
489
493
|
size: 13,
|
|
@@ -513,14 +517,14 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
513
517
|
/* @__PURE__ */ w(
|
|
514
518
|
"div",
|
|
515
519
|
{
|
|
516
|
-
ref:
|
|
520
|
+
ref: O,
|
|
517
521
|
id: we,
|
|
518
522
|
role: "listbox",
|
|
519
523
|
"aria-multiselectable": "true",
|
|
520
|
-
...
|
|
524
|
+
...ot,
|
|
521
525
|
style: ut,
|
|
522
526
|
children: [
|
|
523
|
-
|
|
527
|
+
Oe && /* @__PURE__ */ w(
|
|
524
528
|
"div",
|
|
525
529
|
{
|
|
526
530
|
style: {
|
|
@@ -548,7 +552,7 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
548
552
|
"input",
|
|
549
553
|
{
|
|
550
554
|
type: "text",
|
|
551
|
-
value:
|
|
555
|
+
value: L,
|
|
552
556
|
onChange: (e) => se(e.target.value),
|
|
553
557
|
onKeyDown: j,
|
|
554
558
|
placeholder: "Search",
|
|
@@ -568,7 +572,7 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
568
572
|
]
|
|
569
573
|
}
|
|
570
574
|
),
|
|
571
|
-
|
|
575
|
+
Oe && /* @__PURE__ */ r(
|
|
572
576
|
"div",
|
|
573
577
|
{
|
|
574
578
|
"aria-hidden": "true",
|
|
@@ -595,17 +599,17 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
595
599
|
scrollbarWidth: "thin",
|
|
596
600
|
scrollbarColor: "var(--malachite-text-placeholder, rgb(187, 187, 187)) transparent"
|
|
597
601
|
},
|
|
598
|
-
children:
|
|
602
|
+
children: _.length === 0 ? (
|
|
599
603
|
// `role="listbox"` admits only option/group children.
|
|
600
|
-
/* @__PURE__ */ r("div", { role: "presentation", style:
|
|
601
|
-
) :
|
|
604
|
+
/* @__PURE__ */ r("div", { role: "presentation", style: Gt, children: dt })
|
|
605
|
+
) : _.map((e, t) => {
|
|
602
606
|
const l = ae.has(e.value), S = t === x, y = !!e.disabled;
|
|
603
607
|
return /* @__PURE__ */ w(
|
|
604
608
|
"button",
|
|
605
609
|
{
|
|
606
610
|
id: Ee(t),
|
|
607
611
|
ref: (d) => {
|
|
608
|
-
|
|
612
|
+
Le.current[t] = d;
|
|
609
613
|
},
|
|
610
614
|
type: "button",
|
|
611
615
|
role: "option",
|
|
@@ -639,8 +643,8 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
639
643
|
color: l ? "var(--malachite-accent-foreground, rgb(2, 122, 66))" : "var(--malachite-text-primary, rgb(10, 10, 10))"
|
|
640
644
|
},
|
|
641
645
|
children: [
|
|
642
|
-
/* @__PURE__ */ r(
|
|
643
|
-
|
|
646
|
+
/* @__PURE__ */ r(Ut, { option: e }),
|
|
647
|
+
At(e.badge) && /* @__PURE__ */ r(
|
|
644
648
|
"span",
|
|
645
649
|
{
|
|
646
650
|
style: {
|
|
@@ -648,7 +652,7 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
648
652
|
flexShrink: 0,
|
|
649
653
|
paddingLeft: 8
|
|
650
654
|
},
|
|
651
|
-
children: /* @__PURE__ */ r(fe.Suspense, { fallback: null, children: /* @__PURE__ */ r(
|
|
655
|
+
children: /* @__PURE__ */ r(fe.Suspense, { fallback: null, children: /* @__PURE__ */ r(Bt, { children: e.badge }) })
|
|
652
656
|
}
|
|
653
657
|
)
|
|
654
658
|
]
|
|
@@ -674,19 +678,19 @@ const Fe = 0.6, ze = 420, Vt = ({ option: n }) => {
|
|
|
674
678
|
name: me ?? "",
|
|
675
679
|
required: Q,
|
|
676
680
|
requiredIndicator: Xe,
|
|
677
|
-
loading:
|
|
681
|
+
loading: f,
|
|
678
682
|
formControl: ge,
|
|
679
683
|
description: q,
|
|
680
684
|
controlId: Ie,
|
|
681
685
|
labelId: Se,
|
|
682
686
|
descriptionId: Qe,
|
|
683
687
|
hintId: et,
|
|
684
|
-
loadingComponent: M === void 0 ? /* @__PURE__ */ r($e, { heightClass:
|
|
688
|
+
loadingComponent: M === void 0 ? /* @__PURE__ */ r($e, { heightClass: F[C] }) : /* @__PURE__ */ r("div", { style: Ge(M), children: /* @__PURE__ */ r($e, { heightClass: F[C] }) }),
|
|
685
689
|
children: He
|
|
686
690
|
}
|
|
687
691
|
) : He;
|
|
688
692
|
};
|
|
689
693
|
export {
|
|
690
|
-
|
|
694
|
+
gr as default
|
|
691
695
|
};
|
|
692
696
|
//# sourceMappingURL=MultiSelect.js.map
|