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