@stackone/malachite 2.42.1 → 2.43.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/COMPONENTS.md +3 -3
- package/README.md +7 -0
- package/dist/components/ActionMenu.js +70 -70
- package/dist/components/ActionMenu.js.map +1 -1
- package/dist/components/CardStrip.js +179 -172
- package/dist/components/CardStrip.js.map +1 -1
- package/dist/components/Chat/ChatModelPicker.js +74 -73
- package/dist/components/Chat/ChatModelPicker.js.map +1 -1
- package/dist/components/Dropdown.js +463 -440
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/MultiSelect.js +218 -213
- package/dist/components/MultiSelect.js.map +1 -1
- package/dist/components/Popover.js +102 -102
- package/dist/components/Popover.js.map +1 -1
- package/dist/components/QueryInput.js +65 -65
- package/dist/components/QueryInput.js.map +1 -1
- package/dist/components/SelectableCard.js +194 -168
- package/dist/components/SelectableCard.js.map +1 -1
- package/dist/components/Tooltip.js +100 -93
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/focusRing.js +7 -6
- package/dist/components/focusRing.js.map +1 -1
- package/dist/components/overlayBehaviour.js +145 -94
- package/dist/components/overlayBehaviour.js.map +1 -1
- package/dist/components/overlayLayers.js +34 -0
- package/dist/components/overlayLayers.js.map +1 -0
- package/dist/components/portalOverlay.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/tailwind.css.js +1 -1
- package/package.json +4 -3
|
@@ -1,43 +1,45 @@
|
|
|
1
|
-
import { jsx as r, jsxs as w, Fragment as
|
|
2
|
-
import
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { Tag as
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
1
|
+
import { jsx as r, jsxs as w, Fragment as ft } from "react/jsx-runtime";
|
|
2
|
+
import mt, { useId as pt, useState as P, useRef as T, useMemo as H, useCallback as m, useEffect as Me, useLayoutEffect as ht, useInsertionEffect as gt } from "react";
|
|
3
|
+
import { createPortal as bt } from "react-dom";
|
|
4
|
+
import vt, { useFormFieldIds as xt } from "./BaseFormComponent.js";
|
|
5
|
+
import yt from "./CustomIcons/CaretDownIcon.js";
|
|
6
|
+
import wt from "./CustomIcons/InfoFilledIcon.js";
|
|
7
|
+
import Et from "./CustomIcons/SearchIcon.js";
|
|
8
|
+
import We from "./LoadingInput.js";
|
|
9
|
+
import It from "./Spinner.js";
|
|
10
|
+
import { Tag as St } from "./Tag.js";
|
|
11
|
+
import $e from "./Tooltip.js";
|
|
12
|
+
import { getDeepActiveElement as Tt } from "./activeElement.js";
|
|
13
|
+
import { CONTROL_TEXT_SIZE_CLASS as ue, CONTROL_TEXT_SIZE as kt } from "./controlTextSize.js";
|
|
14
|
+
import { controlWidthStyle as Ge } from "./controlWidth.js";
|
|
15
|
+
import { getTriggerVisual as Rt, DROPDOWN_TRIGGER_ATTR as _t } from "./dropdownTriggerStyle.js";
|
|
16
|
+
import { pushEscapeLayer as Lt } from "./escapeLayers.js";
|
|
17
|
+
import { measureMenuGeometry as Ot, MENU_MAX_HEIGHT_PX as Nt, MENU_SPECS as B } from "./floatingMenuGeometry.js";
|
|
18
|
+
import { FOCUS_RING as Ct, FOCUS_RING_WITHIN_INPUT as At } from "./focusRing.js";
|
|
19
|
+
import { ensureMultiSelectPanelStyles as Dt } from "./optionRowStyles.js";
|
|
20
|
+
import { usePopupLayer as Ht } from "./overlayLayers.js";
|
|
21
|
+
import { useTopLayer as Pt } from "./topLayer.js";
|
|
22
|
+
import { tooltipLines as Mt, isCut as Wt, isClamped as $t } from "./truncatedLines.js";
|
|
23
|
+
const Gt = {
|
|
22
24
|
padding: "8px 10px",
|
|
23
25
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))"
|
|
24
|
-
},
|
|
26
|
+
}, K = {
|
|
25
27
|
small: "h-[var(--malachite-control-height-small,28px)]",
|
|
26
28
|
medium: "h-[var(--malachite-control-height-medium,32px)]",
|
|
27
29
|
large: "h-[var(--malachite-control-height-large,42px)]"
|
|
28
|
-
},
|
|
29
|
-
small: `${
|
|
30
|
-
medium: `${
|
|
31
|
-
large: `${
|
|
32
|
-
},
|
|
33
|
-
({ triggerRole: n, disabled: k, children:
|
|
30
|
+
}, Ft = {
|
|
31
|
+
small: `${K.small} gap-[6px] px-2.5 ${ue.small} rounded-[var(--malachite-radius-10,10px)]`,
|
|
32
|
+
medium: `${K.medium} gap-[8px] px-3 ${ue.medium} rounded-xl`,
|
|
33
|
+
large: `${K.large} gap-[10px] px-4 ${ue.large} rounded-[var(--malachite-radius-xxl,14px)]`
|
|
34
|
+
}, Bt = 10, Ke = "ArrowDown", ze = "ArrowUp", Ue = "Enter", Kt = "Backspace", zt = /* @__PURE__ */ new Set([Ke, ze, Ue]), Ye = mt.forwardRef(
|
|
35
|
+
({ triggerRole: n, disabled: k, children: _, ...u }, g) => n !== "button" ? /* @__PURE__ */ r(
|
|
34
36
|
"div",
|
|
35
37
|
{
|
|
36
38
|
ref: g,
|
|
37
39
|
role: n,
|
|
38
40
|
tabIndex: k ? -1 : 0,
|
|
39
41
|
...u,
|
|
40
|
-
children:
|
|
42
|
+
children: _
|
|
41
43
|
}
|
|
42
44
|
) : /* @__PURE__ */ r(
|
|
43
45
|
"button",
|
|
@@ -46,25 +48,25 @@ const Ht = {
|
|
|
46
48
|
type: "button",
|
|
47
49
|
disabled: k,
|
|
48
50
|
...u,
|
|
49
|
-
children:
|
|
51
|
+
children: _
|
|
50
52
|
}
|
|
51
53
|
)
|
|
52
54
|
);
|
|
53
55
|
Ye.displayName = "TriggerElement";
|
|
54
|
-
const
|
|
55
|
-
const k = T(null),
|
|
56
|
-
const E =
|
|
57
|
-
return !E && !
|
|
58
|
-
},
|
|
59
|
-
|
|
56
|
+
const Fe = 0.6, Be = 420, Ut = ({ option: n }) => {
|
|
57
|
+
const k = T(null), _ = T(null), u = n.description ? n.descriptionMode ?? "icon" : null, g = u === "subtitle", [N, Z] = P({ label: !0, subtitle: !0 }), C = () => {
|
|
58
|
+
const E = Wt(k.current), p = $t(_.current);
|
|
59
|
+
return !E && !p && u !== "hover" ? !1 : (Z({ label: E, subtitle: p }), !0);
|
|
60
|
+
}, M = u === "hover" || g && N.subtitle, W = (E) => /* @__PURE__ */ r(
|
|
61
|
+
$e,
|
|
60
62
|
{
|
|
61
|
-
text:
|
|
62
|
-
["label",
|
|
63
|
-
["description",
|
|
63
|
+
text: Mt([
|
|
64
|
+
["label", N.label && n.label],
|
|
65
|
+
["description", M && n.description]
|
|
64
66
|
]),
|
|
65
|
-
shouldShow:
|
|
66
|
-
delay:
|
|
67
|
-
maxWidth:
|
|
67
|
+
shouldShow: C,
|
|
68
|
+
delay: Fe,
|
|
69
|
+
maxWidth: Be,
|
|
68
70
|
triggerAs: "span",
|
|
69
71
|
isShrinkable: !0,
|
|
70
72
|
describesTrigger: u === "hover",
|
|
@@ -83,7 +85,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
83
85
|
children: n.label
|
|
84
86
|
}
|
|
85
87
|
);
|
|
86
|
-
return g ?
|
|
88
|
+
return g ? W(
|
|
87
89
|
/* @__PURE__ */ w(
|
|
88
90
|
"span",
|
|
89
91
|
{
|
|
@@ -100,7 +102,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
100
102
|
/* @__PURE__ */ r(
|
|
101
103
|
"span",
|
|
102
104
|
{
|
|
103
|
-
ref:
|
|
105
|
+
ref: _,
|
|
104
106
|
style: {
|
|
105
107
|
fontSize: 12,
|
|
106
108
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
@@ -130,13 +132,13 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
130
132
|
gap: 6
|
|
131
133
|
},
|
|
132
134
|
children: [
|
|
133
|
-
|
|
135
|
+
W(b),
|
|
134
136
|
u === "icon" && /* @__PURE__ */ r(
|
|
135
|
-
|
|
137
|
+
$e,
|
|
136
138
|
{
|
|
137
139
|
text: n.description,
|
|
138
|
-
delay:
|
|
139
|
-
maxWidth:
|
|
140
|
+
delay: Fe,
|
|
141
|
+
maxWidth: Be,
|
|
140
142
|
children: /* @__PURE__ */ r(
|
|
141
143
|
"span",
|
|
142
144
|
{
|
|
@@ -146,7 +148,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
146
148
|
},
|
|
147
149
|
"aria-label": "More information",
|
|
148
150
|
onClick: (E) => E.stopPropagation(),
|
|
149
|
-
children: n.descriptionIcon ?? /* @__PURE__ */ r(
|
|
151
|
+
children: n.descriptionIcon ?? /* @__PURE__ */ r(wt, { size: 14 })
|
|
150
152
|
}
|
|
151
153
|
)
|
|
152
154
|
}
|
|
@@ -154,169 +156,172 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
154
156
|
]
|
|
155
157
|
}
|
|
156
158
|
);
|
|
157
|
-
},
|
|
159
|
+
}, pr = ({
|
|
158
160
|
options: n,
|
|
159
161
|
value: k,
|
|
160
|
-
defaultValue:
|
|
162
|
+
defaultValue: _,
|
|
161
163
|
onChange: u,
|
|
162
164
|
placeholder: g = "Select",
|
|
163
|
-
renderTrigger:
|
|
165
|
+
renderTrigger: N,
|
|
164
166
|
searchable: Z,
|
|
165
|
-
size:
|
|
166
|
-
width:
|
|
167
|
-
minWidth:
|
|
167
|
+
size: C = "large",
|
|
168
|
+
width: M = "auto",
|
|
169
|
+
minWidth: W,
|
|
168
170
|
disabled: b = !1,
|
|
169
171
|
error: E = !1,
|
|
170
|
-
loading:
|
|
171
|
-
label:
|
|
172
|
-
name:
|
|
172
|
+
loading: p = !1,
|
|
173
|
+
label: z,
|
|
174
|
+
name: fe,
|
|
173
175
|
description: q,
|
|
174
|
-
tooltip:
|
|
176
|
+
tooltip: me,
|
|
175
177
|
hint: J,
|
|
176
|
-
rightSideContent:
|
|
178
|
+
rightSideContent: pe,
|
|
177
179
|
required: Q = !1,
|
|
178
|
-
requiredIndicator:
|
|
180
|
+
requiredIndicator: Ve,
|
|
179
181
|
formControl: he,
|
|
180
182
|
chips: ee = !1,
|
|
181
183
|
chipsRemovable: te = !0,
|
|
182
|
-
chipsMax:
|
|
184
|
+
chipsMax: ge = "auto",
|
|
183
185
|
inlineSearch: v = !1,
|
|
184
|
-
onSearchChange:
|
|
185
|
-
localFilter:
|
|
186
|
-
className:
|
|
187
|
-
style:
|
|
188
|
-
id:
|
|
189
|
-
"aria-label":
|
|
190
|
-
"aria-labelledby":
|
|
186
|
+
onSearchChange: $,
|
|
187
|
+
localFilter: be = !0,
|
|
188
|
+
className: Xe = "",
|
|
189
|
+
style: je,
|
|
190
|
+
id: Ze,
|
|
191
|
+
"aria-label": ve,
|
|
192
|
+
"aria-labelledby": qe
|
|
191
193
|
}) => {
|
|
192
|
-
const
|
|
193
|
-
id:
|
|
194
|
-
label:
|
|
194
|
+
const xe = pt(), ye = `${xe}-listbox`, we = (e) => `${xe}-option-${e}`, { controlId: Ee, labelId: Ie, descriptionId: Je, hintId: Qe, describedBy: et } = xt({
|
|
195
|
+
id: Ze,
|
|
196
|
+
label: z,
|
|
195
197
|
description: q,
|
|
196
198
|
hint: J
|
|
197
|
-
}), [
|
|
198
|
-
|
|
199
|
-
const
|
|
199
|
+
}), [tt, rt] = P(() => _ ?? []), re = k !== void 0, f = re ? k : tt, [o, ne] = P(!1), [c, Se] = P(null), [R, nt] = P(""), [x, A] = P(-1), U = T(null), G = T(null), L = T(null), Te = T(null);
|
|
200
|
+
Pt(L, o);
|
|
201
|
+
const at = Ht("multiselect", o, L), ke = T([]), ae = H(() => new Set(f), [f]), s = H(
|
|
200
202
|
() => n.filter((e) => ae.has(e.value)),
|
|
201
203
|
[n, ae]
|
|
202
|
-
), le = typeof
|
|
203
|
-
if (!
|
|
204
|
-
const e =
|
|
204
|
+
), le = typeof ge == "number" ? ge : void 0, O = H(() => {
|
|
205
|
+
if (!be) return n;
|
|
206
|
+
const e = R.trim().toLowerCase();
|
|
205
207
|
return e ? n.filter((t) => (t.searchText ?? (typeof t.label == "string" ? t.label : "")).toLowerCase().includes(e)) : n;
|
|
206
|
-
}, [n,
|
|
208
|
+
}, [n, R, be]), oe = T(!1), Re = T(""), Y = m(
|
|
207
209
|
(e, t) => {
|
|
208
|
-
|
|
210
|
+
Re.current !== e && (Re.current = e, t && (oe.current = !0), nt(e), $ == null || $(e));
|
|
209
211
|
},
|
|
210
|
-
[
|
|
211
|
-
), se =
|
|
212
|
-
(e) =>
|
|
213
|
-
[
|
|
214
|
-
),
|
|
215
|
-
|
|
216
|
-
oe.current && (
|
|
217
|
-
}, [
|
|
218
|
-
const
|
|
219
|
-
|
|
212
|
+
[$]
|
|
213
|
+
), se = m(
|
|
214
|
+
(e) => Y(e, !0),
|
|
215
|
+
[Y]
|
|
216
|
+
), F = m(() => Y("", !1), [Y]);
|
|
217
|
+
Me(() => {
|
|
218
|
+
oe.current && (A(-1), oe.current = !1);
|
|
219
|
+
}, [R]);
|
|
220
|
+
const lt = Z ?? ($ !== void 0 || n.length > Bt), _e = v ? !1 : lt, ie = m(() => {
|
|
221
|
+
var e, t;
|
|
222
|
+
ne(!1), (e = L.current) != null && e.contains(Tt()) && ((t = U.current) == null || t.focus());
|
|
223
|
+
}, []), D = m(() => {
|
|
224
|
+
const e = U.current;
|
|
220
225
|
if (!e) return;
|
|
221
|
-
const t =
|
|
226
|
+
const t = Ot(L.current, {
|
|
222
227
|
triggerRect: e.getBoundingClientRect(),
|
|
223
228
|
preset: "standard",
|
|
224
|
-
minWidth:
|
|
229
|
+
minWidth: W,
|
|
225
230
|
viewportWidth: window.innerWidth,
|
|
226
231
|
viewportHeight: window.innerHeight
|
|
227
232
|
});
|
|
228
|
-
|
|
229
|
-
}, [
|
|
230
|
-
|
|
233
|
+
Se(t);
|
|
234
|
+
}, [W]);
|
|
235
|
+
Me(() => {
|
|
231
236
|
var S;
|
|
232
237
|
if (!o) {
|
|
233
|
-
|
|
238
|
+
F(), A(-1), Se(null);
|
|
234
239
|
return;
|
|
235
240
|
}
|
|
236
|
-
|
|
237
|
-
const e = () =>
|
|
238
|
-
const d = y.composedPath(), a =
|
|
239
|
-
(!a || !d.includes(a)) && (!i || !d.includes(i)) &&
|
|
240
|
-
}, l =
|
|
241
|
+
D(), v && ((S = G.current) == null || S.focus());
|
|
242
|
+
const e = () => D(), t = (y) => {
|
|
243
|
+
const d = y.composedPath(), a = U.current, i = L.current;
|
|
244
|
+
(!a || !d.includes(a)) && (!i || !d.includes(i)) && ie();
|
|
245
|
+
}, l = Lt(ie);
|
|
241
246
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), document.addEventListener("mousedown", t), () => {
|
|
242
247
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e), document.removeEventListener("mousedown", t), l();
|
|
243
248
|
};
|
|
244
|
-
}, [o,
|
|
249
|
+
}, [o, D, v, F, ie]), ht(() => {
|
|
245
250
|
if (!o)
|
|
246
251
|
return;
|
|
247
|
-
|
|
248
|
-
const e =
|
|
252
|
+
D();
|
|
253
|
+
const e = L.current;
|
|
249
254
|
if (!e || typeof ResizeObserver > "u")
|
|
250
255
|
return;
|
|
251
|
-
const t = new ResizeObserver(() =>
|
|
256
|
+
const t = new ResizeObserver(() => D());
|
|
252
257
|
return t.observe(e), () => t.disconnect();
|
|
253
|
-
}, [o,
|
|
254
|
-
const I =
|
|
258
|
+
}, [o, D]);
|
|
259
|
+
const I = m(
|
|
255
260
|
(e) => {
|
|
256
|
-
re ||
|
|
261
|
+
re || rt(e), u == null || u(e);
|
|
257
262
|
},
|
|
258
263
|
[re, u]
|
|
259
|
-
), V =
|
|
264
|
+
), V = m(
|
|
260
265
|
(e) => n.some((t) => t.value === e && t.disabled),
|
|
261
266
|
[n]
|
|
262
|
-
),
|
|
267
|
+
), ce = m(
|
|
263
268
|
(e) => {
|
|
264
269
|
V(e) || (f.includes(e) ? I(f.filter((t) => t !== e)) : I([...f, e]));
|
|
265
270
|
},
|
|
266
271
|
[f, I, V]
|
|
267
|
-
), X =
|
|
272
|
+
), X = H(() => {
|
|
268
273
|
const e = /* @__PURE__ */ new Set();
|
|
269
274
|
for (const t of n)
|
|
270
275
|
t.disabled && e.add(t.value);
|
|
271
276
|
return e;
|
|
272
|
-
}, [n]),
|
|
277
|
+
}, [n]), ot = m(
|
|
273
278
|
(e) => {
|
|
274
279
|
e.stopPropagation();
|
|
275
280
|
const t = f.filter((l) => X.has(l));
|
|
276
281
|
I(t);
|
|
277
282
|
},
|
|
278
283
|
[I, f, X]
|
|
279
|
-
),
|
|
284
|
+
), Le = m(
|
|
280
285
|
(e, t) => {
|
|
281
286
|
t.stopPropagation(), !V(e) && I(f.filter((l) => l !== e));
|
|
282
287
|
},
|
|
283
288
|
[f, I, V]
|
|
284
|
-
), j =
|
|
289
|
+
), j = m(
|
|
285
290
|
(e) => {
|
|
286
|
-
if (
|
|
291
|
+
if (!zt.has(e.key)) return;
|
|
287
292
|
if (e.preventDefault(), e.stopPropagation(), !o) {
|
|
288
|
-
|
|
293
|
+
ne(!0);
|
|
289
294
|
return;
|
|
290
295
|
}
|
|
291
296
|
const t = O.length;
|
|
292
297
|
if (t === 0) return;
|
|
293
298
|
const l = (d) => {
|
|
294
299
|
requestAnimationFrame(() => {
|
|
295
|
-
const a =
|
|
300
|
+
const a = ke.current[d], i = Te.current;
|
|
296
301
|
if (!a || !i) return;
|
|
297
|
-
const h = a.offsetTop,
|
|
298
|
-
|
|
299
|
-
top:
|
|
302
|
+
const h = a.offsetTop, He = h + a.offsetHeight, Pe = i.scrollTop, ut = Pe + i.clientHeight;
|
|
303
|
+
He > ut ? i.scrollTo({
|
|
304
|
+
top: He - i.clientHeight,
|
|
300
305
|
behavior: "smooth"
|
|
301
|
-
}) : h <
|
|
306
|
+
}) : h < Pe && i.scrollTo({ top: h, behavior: "smooth" });
|
|
302
307
|
});
|
|
303
308
|
}, S = (d) => {
|
|
304
309
|
var i;
|
|
305
310
|
let a = x;
|
|
306
311
|
for (let h = 0; h < t; h++)
|
|
307
312
|
if (a = d === 1 ? a < t - 1 ? a + 1 : 0 : a > 0 ? a - 1 : t - 1, !((i = O[a]) != null && i.disabled)) {
|
|
308
|
-
l(a),
|
|
313
|
+
l(a), A(a);
|
|
309
314
|
return;
|
|
310
315
|
}
|
|
311
316
|
}, y = () => {
|
|
312
317
|
var i;
|
|
313
318
|
if (x < 0 || x >= t || (i = O[x]) != null && i.disabled) return;
|
|
314
319
|
const d = O[x].value;
|
|
315
|
-
|
|
320
|
+
ce(d), F();
|
|
316
321
|
const a = n.findIndex((h) => h.value === d);
|
|
317
|
-
|
|
322
|
+
A(a >= 0 ? a : -1), l(a >= 0 ? a : 0), requestAnimationFrame(() => {
|
|
318
323
|
var h;
|
|
319
|
-
return (h =
|
|
324
|
+
return (h = G.current) == null ? void 0 : h.focus();
|
|
320
325
|
});
|
|
321
326
|
};
|
|
322
327
|
switch (e.key) {
|
|
@@ -326,36 +331,36 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
326
331
|
case ze:
|
|
327
332
|
S(-1);
|
|
328
333
|
break;
|
|
329
|
-
case
|
|
334
|
+
case Ue:
|
|
330
335
|
y();
|
|
331
336
|
break;
|
|
332
337
|
}
|
|
333
338
|
},
|
|
334
|
-
[o, O, x,
|
|
335
|
-
), Oe =
|
|
339
|
+
[o, O, x, ce, n, F]
|
|
340
|
+
), Oe = m(
|
|
336
341
|
(e) => {
|
|
337
|
-
if (e.key ===
|
|
342
|
+
if (e.key === Kt && R === "" && f.length > 0) {
|
|
338
343
|
e.preventDefault(), I(f.slice(0, -1)), requestAnimationFrame(() => {
|
|
339
344
|
var t;
|
|
340
|
-
return (t =
|
|
345
|
+
return (t = G.current) == null ? void 0 : t.focus();
|
|
341
346
|
});
|
|
342
347
|
return;
|
|
343
348
|
}
|
|
344
349
|
j(e);
|
|
345
350
|
},
|
|
346
|
-
[j,
|
|
347
|
-
),
|
|
351
|
+
[j, R, f, I]
|
|
352
|
+
), Ne = s.length > 0 && !b && !p, st = Rt({
|
|
348
353
|
disabled: b,
|
|
349
354
|
error: E,
|
|
350
355
|
open: o,
|
|
351
|
-
loading:
|
|
356
|
+
loading: p,
|
|
352
357
|
hasSelection: s.length > 0
|
|
353
|
-
}),
|
|
358
|
+
}), de = H(() => v ? /* @__PURE__ */ r(
|
|
354
359
|
"input",
|
|
355
360
|
{
|
|
356
|
-
ref:
|
|
361
|
+
ref: G,
|
|
357
362
|
type: "text",
|
|
358
|
-
value:
|
|
363
|
+
value: R,
|
|
359
364
|
onChange: (e) => se(e.target.value),
|
|
360
365
|
onKeyDown: Oe,
|
|
361
366
|
placeholder: s.length === 0 ? g : "",
|
|
@@ -366,14 +371,14 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
366
371
|
}
|
|
367
372
|
) : null, [
|
|
368
373
|
v,
|
|
369
|
-
|
|
374
|
+
R,
|
|
370
375
|
se,
|
|
371
376
|
Oe,
|
|
372
377
|
s.length,
|
|
373
378
|
g
|
|
374
|
-
]),
|
|
375
|
-
if (
|
|
376
|
-
return
|
|
379
|
+
]), it = H(() => {
|
|
380
|
+
if (N && s.length > 0)
|
|
381
|
+
return N(s);
|
|
377
382
|
if (ee && s.length > 0) {
|
|
378
383
|
const e = le != null ? s.slice(0, le) : s, t = s.length - e.length;
|
|
379
384
|
return /* @__PURE__ */ w(
|
|
@@ -385,12 +390,12 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
385
390
|
e.map((l) => {
|
|
386
391
|
const S = X.has(l.value);
|
|
387
392
|
return /* @__PURE__ */ r(
|
|
388
|
-
|
|
393
|
+
St,
|
|
389
394
|
{
|
|
390
395
|
value: l.label,
|
|
391
396
|
type: "default",
|
|
392
397
|
textTransform: "none",
|
|
393
|
-
onRemove: te && !b && !S ? (y) =>
|
|
398
|
+
onRemove: te && !b && !S ? (y) => Le(l.value, y) : void 0,
|
|
394
399
|
className: "shrink-0"
|
|
395
400
|
},
|
|
396
401
|
l.value
|
|
@@ -400,85 +405,85 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
400
405
|
"+",
|
|
401
406
|
t
|
|
402
407
|
] }),
|
|
403
|
-
|
|
408
|
+
de
|
|
404
409
|
]
|
|
405
410
|
}
|
|
406
411
|
);
|
|
407
412
|
}
|
|
408
|
-
return v && s.length === 0 ?
|
|
413
|
+
return v && s.length === 0 ? de : s.length === 0 ? /* @__PURE__ */ r("span", { className: "text-[var(--malachite-text-placeholder)]", children: g }) : s.length === 1 ? /* @__PURE__ */ r("span", { children: s[0].label }) : /* @__PURE__ */ r("span", { children: `${s.length} selected` });
|
|
409
414
|
}, [
|
|
410
415
|
s,
|
|
411
|
-
|
|
416
|
+
N,
|
|
412
417
|
ee,
|
|
413
418
|
le,
|
|
414
419
|
te,
|
|
415
420
|
b,
|
|
416
|
-
|
|
421
|
+
Le,
|
|
417
422
|
v,
|
|
418
|
-
|
|
423
|
+
de,
|
|
419
424
|
g,
|
|
420
425
|
X
|
|
421
|
-
]),
|
|
422
|
-
|
|
423
|
-
o &&
|
|
426
|
+
]), ct = n.length === 0 ? "No options available" : "No results found";
|
|
427
|
+
gt(() => {
|
|
428
|
+
o && Dt();
|
|
424
429
|
}, [o]);
|
|
425
|
-
const
|
|
430
|
+
const dt = {
|
|
426
431
|
position: "fixed",
|
|
427
432
|
top: (c == null ? void 0 : c.top) ?? 0,
|
|
428
433
|
left: (c == null ? void 0 : c.left) ?? 0,
|
|
429
434
|
width: c == null ? void 0 : c.width,
|
|
430
|
-
background:
|
|
431
|
-
border:
|
|
432
|
-
borderRadius:
|
|
433
|
-
boxShadow:
|
|
434
|
-
padding:
|
|
435
|
+
background: B.standard.background,
|
|
436
|
+
border: B.standard.border,
|
|
437
|
+
borderRadius: B.standard.radius,
|
|
438
|
+
boxShadow: B.standard.shadow,
|
|
439
|
+
padding: B.standard.padding,
|
|
435
440
|
display: "flex",
|
|
436
441
|
flexDirection: "column",
|
|
437
442
|
gap: 4,
|
|
438
|
-
maxHeight: (c == null ? void 0 : c.maxHeight) ??
|
|
439
|
-
fontSize:
|
|
443
|
+
maxHeight: (c == null ? void 0 : c.maxHeight) ?? Nt,
|
|
444
|
+
fontSize: kt[C],
|
|
440
445
|
visibility: c ? "visible" : "hidden",
|
|
441
446
|
opacity: c ? 1 : 0
|
|
442
|
-
},
|
|
443
|
-
/* @__PURE__ */ w("div", { className: "relative", style:
|
|
447
|
+
}, Ce = !!(q || me || J || pe || fe || he || Q), Ae = Ce && !!z, De = /* @__PURE__ */ w(ft, { children: [
|
|
448
|
+
/* @__PURE__ */ w("div", { className: "relative", style: Ge(M), children: [
|
|
444
449
|
/* @__PURE__ */ w(
|
|
445
450
|
Ye,
|
|
446
451
|
{
|
|
447
|
-
ref:
|
|
448
|
-
id:
|
|
452
|
+
ref: U,
|
|
453
|
+
id: Ee,
|
|
449
454
|
triggerRole: v ? "combobox" : ee && te ? "group" : "button",
|
|
450
|
-
disabled: b ||
|
|
451
|
-
[
|
|
455
|
+
disabled: b || p,
|
|
456
|
+
[_t]: "",
|
|
452
457
|
"aria-haspopup": "listbox",
|
|
453
458
|
"aria-expanded": o,
|
|
454
|
-
"aria-controls": o ?
|
|
455
|
-
"aria-activedescendant": v && o && x >= 0 ?
|
|
456
|
-
"aria-labelledby":
|
|
457
|
-
"aria-label":
|
|
459
|
+
"aria-controls": o ? ye : void 0,
|
|
460
|
+
"aria-activedescendant": v && o && x >= 0 ? we(x) : void 0,
|
|
461
|
+
"aria-labelledby": qe ?? (Ae && !ve ? Ie : void 0),
|
|
462
|
+
"aria-label": ve ?? (Ae ? void 0 : z),
|
|
458
463
|
"aria-invalid": E || void 0,
|
|
459
464
|
"aria-required": Q || void 0,
|
|
460
|
-
"aria-describedby":
|
|
461
|
-
"aria-busy":
|
|
465
|
+
"aria-describedby": et,
|
|
466
|
+
"aria-busy": p || void 0,
|
|
462
467
|
onClick: () => {
|
|
463
|
-
b ||
|
|
468
|
+
b || p || ne((e) => !e);
|
|
464
469
|
},
|
|
465
470
|
onKeyDown: j,
|
|
466
471
|
style: {
|
|
467
472
|
transition: "border-color 0.15s ease, box-shadow 0.15s ease",
|
|
468
|
-
...
|
|
469
|
-
...
|
|
473
|
+
...st,
|
|
474
|
+
...je
|
|
470
475
|
},
|
|
471
|
-
className: `w-full ${
|
|
476
|
+
className: `w-full ${Ft[C]} border border-solid flex items-center font-normal text-[var(--malachite-text-primary)] ${b || p ? "cursor-not-allowed" : "cursor-pointer"} ${Ct} ${At} ${Xe}`,
|
|
472
477
|
children: [
|
|
473
478
|
/* @__PURE__ */ r(
|
|
474
479
|
"span",
|
|
475
480
|
{
|
|
476
|
-
className: `flex-1 min-w-0 text-left ${v ? "flex" : "truncate"} ${
|
|
477
|
-
children:
|
|
481
|
+
className: `flex-1 min-w-0 text-left ${v ? "flex" : "truncate"} ${Ne ? "pr-[18px]" : ""}`,
|
|
482
|
+
children: it
|
|
478
483
|
}
|
|
479
484
|
),
|
|
480
|
-
|
|
481
|
-
|
|
485
|
+
p ? /* @__PURE__ */ r("span", { className: "flex items-center justify-center shrink-0 size-[14px]", children: /* @__PURE__ */ r(It, { size: "xxxsmall" }) }) : /* @__PURE__ */ r(
|
|
486
|
+
yt,
|
|
482
487
|
{
|
|
483
488
|
size: 13,
|
|
484
489
|
className: "shrink-0",
|
|
@@ -492,29 +497,29 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
492
497
|
]
|
|
493
498
|
}
|
|
494
499
|
),
|
|
495
|
-
|
|
500
|
+
Ne && /* @__PURE__ */ r(
|
|
496
501
|
"button",
|
|
497
502
|
{
|
|
498
503
|
type: "button",
|
|
499
504
|
"aria-label": "Clear selection",
|
|
500
|
-
onClick:
|
|
505
|
+
onClick: ot,
|
|
501
506
|
className: "absolute top-0 bottom-0 right-[28px] flex items-center justify-center px-[2px] leading-none bg-transparent border-none text-[var(--malachite-text-placeholder)] hover:text-[var(--malachite-text-primary)] cursor-pointer",
|
|
502
507
|
children: "×"
|
|
503
508
|
}
|
|
504
509
|
)
|
|
505
510
|
] }),
|
|
506
|
-
o &&
|
|
511
|
+
o && bt(
|
|
507
512
|
/* @__PURE__ */ w(
|
|
508
513
|
"div",
|
|
509
514
|
{
|
|
510
|
-
ref:
|
|
511
|
-
id:
|
|
515
|
+
ref: L,
|
|
516
|
+
id: ye,
|
|
512
517
|
role: "listbox",
|
|
513
518
|
"aria-multiselectable": "true",
|
|
514
|
-
...
|
|
515
|
-
style:
|
|
519
|
+
...at,
|
|
520
|
+
style: dt,
|
|
516
521
|
children: [
|
|
517
|
-
|
|
522
|
+
_e && /* @__PURE__ */ w(
|
|
518
523
|
"div",
|
|
519
524
|
{
|
|
520
525
|
style: {
|
|
@@ -529,7 +534,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
529
534
|
},
|
|
530
535
|
children: [
|
|
531
536
|
/* @__PURE__ */ r(
|
|
532
|
-
|
|
537
|
+
Et,
|
|
533
538
|
{
|
|
534
539
|
size: 13,
|
|
535
540
|
style: {
|
|
@@ -542,7 +547,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
542
547
|
"input",
|
|
543
548
|
{
|
|
544
549
|
type: "text",
|
|
545
|
-
value:
|
|
550
|
+
value: R,
|
|
546
551
|
onChange: (e) => se(e.target.value),
|
|
547
552
|
onKeyDown: j,
|
|
548
553
|
placeholder: "Search",
|
|
@@ -562,7 +567,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
562
567
|
]
|
|
563
568
|
}
|
|
564
569
|
),
|
|
565
|
-
|
|
570
|
+
_e && /* @__PURE__ */ r(
|
|
566
571
|
"div",
|
|
567
572
|
{
|
|
568
573
|
"aria-hidden": "true",
|
|
@@ -577,7 +582,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
577
582
|
/* @__PURE__ */ r(
|
|
578
583
|
"div",
|
|
579
584
|
{
|
|
580
|
-
ref:
|
|
585
|
+
ref: Te,
|
|
581
586
|
style: {
|
|
582
587
|
display: "flex",
|
|
583
588
|
flexDirection: "column",
|
|
@@ -591,15 +596,15 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
591
596
|
},
|
|
592
597
|
children: O.length === 0 ? (
|
|
593
598
|
// `role="listbox"` admits only option/group children.
|
|
594
|
-
/* @__PURE__ */ r("div", { role: "presentation", style:
|
|
599
|
+
/* @__PURE__ */ r("div", { role: "presentation", style: Gt, children: ct })
|
|
595
600
|
) : O.map((e, t) => {
|
|
596
601
|
const l = ae.has(e.value), S = t === x, y = !!e.disabled;
|
|
597
602
|
return /* @__PURE__ */ w(
|
|
598
603
|
"button",
|
|
599
604
|
{
|
|
600
|
-
id:
|
|
605
|
+
id: we(t),
|
|
601
606
|
ref: (d) => {
|
|
602
|
-
|
|
607
|
+
ke.current[t] = d;
|
|
603
608
|
},
|
|
604
609
|
type: "button",
|
|
605
610
|
role: "option",
|
|
@@ -607,11 +612,11 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
607
612
|
"aria-disabled": y || void 0,
|
|
608
613
|
onClick: () => {
|
|
609
614
|
var d;
|
|
610
|
-
|
|
615
|
+
ce(e.value), F(), (d = G.current) == null || d.focus();
|
|
611
616
|
},
|
|
612
|
-
onMouseEnter: () =>
|
|
617
|
+
onMouseEnter: () => A(t),
|
|
613
618
|
onMouseLeave: () => {
|
|
614
|
-
x === t &&
|
|
619
|
+
x === t && A(-1);
|
|
615
620
|
},
|
|
616
621
|
className: "malachite-multiselect-option",
|
|
617
622
|
"data-checked": l,
|
|
@@ -633,7 +638,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
633
638
|
color: l ? "var(--malachite-accent-foreground, rgb(2, 122, 66))" : "var(--malachite-text-primary, rgb(10, 10, 10))"
|
|
634
639
|
},
|
|
635
640
|
children: [
|
|
636
|
-
/* @__PURE__ */ r(
|
|
641
|
+
/* @__PURE__ */ r(Ut, { option: e }),
|
|
637
642
|
e.badge && /* @__PURE__ */ r(
|
|
638
643
|
"span",
|
|
639
644
|
{
|
|
@@ -658,29 +663,29 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
|
|
|
658
663
|
document.body
|
|
659
664
|
)
|
|
660
665
|
] });
|
|
661
|
-
return
|
|
662
|
-
|
|
666
|
+
return Ce ? /* @__PURE__ */ r(
|
|
667
|
+
vt,
|
|
663
668
|
{
|
|
664
|
-
label:
|
|
669
|
+
label: z,
|
|
665
670
|
hint: J,
|
|
666
|
-
rightSideContent:
|
|
667
|
-
tooltip:
|
|
668
|
-
name:
|
|
671
|
+
rightSideContent: pe,
|
|
672
|
+
tooltip: me,
|
|
673
|
+
name: fe ?? "",
|
|
669
674
|
required: Q,
|
|
670
|
-
requiredIndicator:
|
|
671
|
-
loading:
|
|
675
|
+
requiredIndicator: Ve,
|
|
676
|
+
loading: p,
|
|
672
677
|
formControl: he,
|
|
673
678
|
description: q,
|
|
674
|
-
controlId:
|
|
675
|
-
labelId:
|
|
676
|
-
descriptionId:
|
|
677
|
-
hintId:
|
|
678
|
-
loadingComponent:
|
|
679
|
-
children:
|
|
679
|
+
controlId: Ee,
|
|
680
|
+
labelId: Ie,
|
|
681
|
+
descriptionId: Je,
|
|
682
|
+
hintId: Qe,
|
|
683
|
+
loadingComponent: M === void 0 ? /* @__PURE__ */ r(We, { heightClass: K[C] }) : /* @__PURE__ */ r("div", { style: Ge(M), children: /* @__PURE__ */ r(We, { heightClass: K[C] }) }),
|
|
684
|
+
children: De
|
|
680
685
|
}
|
|
681
|
-
) :
|
|
686
|
+
) : De;
|
|
682
687
|
};
|
|
683
688
|
export {
|
|
684
|
-
|
|
689
|
+
pr as default
|
|
685
690
|
};
|
|
686
691
|
//# sourceMappingURL=MultiSelect.js.map
|