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