@stackone/malachite 2.46.0 → 2.47.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.
|
@@ -1,202 +1,214 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { FieldMessage as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { jsx as e, jsxs as m, Fragment as bt } from "react/jsx-runtime";
|
|
2
|
+
import Ot, { useState as F, useRef as x, useEffect as Pt, useCallback as Mt, useLayoutEffect as oe, useInsertionEffect as le, useId as se } from "react";
|
|
3
|
+
import { createPortal as ce } from "react-dom";
|
|
4
|
+
import de, { useFormFieldIds as ue } from "./BaseFormComponent.js";
|
|
5
|
+
import Zt from "./CustomIcons/CaretDownIcon.js";
|
|
6
|
+
import Jt from "./CustomIcons/CloseIcon.js";
|
|
7
|
+
import { FieldMessage as pe } from "./FieldMessage.js";
|
|
8
|
+
import Ut from "./LoadingInput.js";
|
|
9
|
+
import fe from "./Spinner.js";
|
|
10
|
+
import { Tag as he } from "./Tag.js";
|
|
11
|
+
import $t from "./Tooltip.js";
|
|
12
|
+
import ge from "./Typography/MarkdownBlock.js";
|
|
13
|
+
import { inlineMarkdownText as xe } from "./Typography/inlineMarkdown.js";
|
|
14
|
+
import { getDeepActiveElement as Rt } from "./activeElement.js";
|
|
15
|
+
import { CONTROL_TEXT_SIZE_CLASS as nt, CONTROL_TEXT_SIZE as me } from "./controlTextSize.js";
|
|
16
|
+
import { controlWidthStyle as qt } from "./controlWidth.js";
|
|
17
|
+
import { getTriggerVisual as ve, DROPDOWN_TRIGGER_ATTR as Vt } from "./dropdownTriggerStyle.js";
|
|
18
|
+
import { pushEscapeLayer as be } from "./escapeLayers.js";
|
|
19
|
+
import { measureMenuGeometry as ye, isTriggerOffscreen as we, rectSignature as Se, MENU_MAX_HEIGHT_PX as Te, MENU_SPECS as gt } from "./floatingMenuGeometry.js";
|
|
20
|
+
import { FOCUS_RING_WITHIN_INPUT as Ee, FOCUS_RING as Ne } from "./focusRing.js";
|
|
21
|
+
import { hasBadge as Lt } from "./hasBadge.js";
|
|
22
|
+
import { ensureDropdownPanelStyles as Ce } from "./optionRowStyles.js";
|
|
23
|
+
import { usePopupLayer as _e } from "./overlayLayers.js";
|
|
24
|
+
import { useTopLayer as ke } from "./topLayer.js";
|
|
25
|
+
import { tooltipLines as It, isCut as xt } from "./truncatedLines.js";
|
|
26
|
+
const Re = Ot.lazy(() => import("./ActionMenuTagHost.js")), Xt = ({ id: t, text: a, disabled: r }) => /* @__PURE__ */ e(
|
|
27
|
+
"span",
|
|
27
28
|
{
|
|
28
|
-
|
|
29
|
+
id: t,
|
|
30
|
+
className: `flex min-w-0 max-w-[40%] [flex-shrink:3] ${r ? "opacity-60" : ""}`,
|
|
31
|
+
children: /* @__PURE__ */ e(he, { value: a, paddingSize: "compact", fontSize: "xsmall", textTransform: "none" })
|
|
32
|
+
}
|
|
33
|
+
), te = /[*`[<&\\]/, mt = ({ text: t }) => te.test(t) ? /* @__PURE__ */ e(
|
|
34
|
+
ge,
|
|
35
|
+
{
|
|
36
|
+
text: t,
|
|
29
37
|
variant: "inline",
|
|
30
38
|
color: "inherit",
|
|
31
39
|
size: "inherit",
|
|
32
40
|
links: "inert",
|
|
33
41
|
omitMargin: !0
|
|
34
42
|
}
|
|
35
|
-
) :
|
|
43
|
+
) : t, Yt = {
|
|
36
44
|
display: "flex",
|
|
37
45
|
alignItems: "center",
|
|
38
46
|
justifyContent: "center",
|
|
39
47
|
gap: 8,
|
|
40
48
|
padding: "24px 16px",
|
|
41
49
|
color: "var(--malachite-text-dimmed, rgb(161, 161, 161))"
|
|
42
|
-
},
|
|
43
|
-
const r = a.toLowerCase(),
|
|
44
|
-
return
|
|
45
|
-
},
|
|
50
|
+
}, Ft = "var(--malachite-font-size-xsmall, 11px)", Le = "[data-dropdown-option]", Wt = (t) => Array.from((t == null ? void 0 : t.querySelectorAll(Le)) ?? []), $e = (t) => te.test(t) ? xe(t) : t.replace(/\s+/g, " "), Oe = (t, a) => {
|
|
51
|
+
const r = a.toLowerCase(), u = t.label.toLowerCase().includes(r), d = t.subtitle ? $e(t.subtitle).toLowerCase().includes(r) : !1, S = t.rightSideText ? t.rightSideText.toLowerCase().includes(r) : !1;
|
|
52
|
+
return u || d || S;
|
|
53
|
+
}, vt = {
|
|
46
54
|
small: "h-[var(--malachite-control-height-small,28px)]",
|
|
47
55
|
medium: "h-[var(--malachite-control-height-medium,32px)]",
|
|
48
56
|
large: "h-[var(--malachite-control-height-large,42px)]"
|
|
49
|
-
},
|
|
50
|
-
small: `${
|
|
51
|
-
medium: `${
|
|
52
|
-
large: `${
|
|
53
|
-
},
|
|
54
|
-
small: `min-h-[var(--malachite-control-height-small,28px)] px-2.5 py-1.5 ${
|
|
55
|
-
medium: `min-h-[var(--malachite-control-height-medium,32px)] px-3 py-1.5 ${
|
|
56
|
-
large: `min-h-[var(--malachite-control-height-large,42px)] px-4 py-2.5 ${
|
|
57
|
-
},
|
|
57
|
+
}, De = {
|
|
58
|
+
small: `${vt.small} px-2.5 py-1.5 ${nt.small}`,
|
|
59
|
+
medium: `${vt.medium} px-3 py-1.5 ${nt.medium}`,
|
|
60
|
+
large: `${vt.large} px-4 py-2.5 ${nt.large}`
|
|
61
|
+
}, ze = {
|
|
62
|
+
small: `min-h-[var(--malachite-control-height-small,28px)] px-2.5 py-1.5 ${nt.small}`,
|
|
63
|
+
medium: `min-h-[var(--malachite-control-height-medium,32px)] px-3 py-1.5 ${nt.medium}`,
|
|
64
|
+
large: `min-h-[var(--malachite-control-height-large,42px)] px-4 py-2.5 ${nt.large}`
|
|
65
|
+
}, Ae = {
|
|
58
66
|
small: "right-[26px] size-4",
|
|
59
67
|
medium: "right-[30px] size-4",
|
|
60
68
|
large: "right-[38px] size-4"
|
|
61
|
-
},
|
|
69
|
+
}, Me = {
|
|
62
70
|
small: "top-[calc(var(--malachite-control-height-small,28px)/2)] -translate-y-1/2",
|
|
63
71
|
medium: "top-[calc(var(--malachite-control-height-medium,32px)/2)] -translate-y-1/2",
|
|
64
72
|
large: "top-[calc(var(--malachite-control-height-large,42px)/2)] -translate-y-1/2"
|
|
65
|
-
},
|
|
73
|
+
}, Fe = {
|
|
66
74
|
small: "rounded-[var(--malachite-radius-10,10px)]",
|
|
67
75
|
medium: "rounded-xl",
|
|
68
76
|
large: "rounded-[var(--malachite-radius-xxl,14px)]"
|
|
69
|
-
},
|
|
70
|
-
wrap:
|
|
77
|
+
}, Qt = () => !1, Pe = ({
|
|
78
|
+
wrap: t,
|
|
71
79
|
id: a,
|
|
72
80
|
children: r
|
|
73
|
-
}) =>
|
|
81
|
+
}) => t ? /* @__PURE__ */ e("span", { id: a, className: "min-w-0 flex items-center gap-2", children: r }) : /* @__PURE__ */ e(bt, { children: r }), We = ({ row: t, children: a }) => t ? /* @__PURE__ */ e("span", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 }, children: a }) : /* @__PURE__ */ e(bt, { children: a }), ee = Ot.forwardRef(
|
|
74
82
|
({
|
|
75
|
-
isOpen:
|
|
83
|
+
isOpen: t,
|
|
76
84
|
onClick: a,
|
|
77
85
|
selectedItem: r,
|
|
78
|
-
disabled:
|
|
86
|
+
disabled: u = !1,
|
|
79
87
|
error: d = !1,
|
|
80
|
-
tone:
|
|
81
|
-
placeholder:
|
|
82
|
-
search:
|
|
83
|
-
showSubtitleInTrigger:
|
|
84
|
-
searchQuery:
|
|
85
|
-
onSearchChange:
|
|
86
|
-
onFocusOpen:
|
|
87
|
-
onArrowDown:
|
|
88
|
-
onTabAway:
|
|
89
|
-
size:
|
|
90
|
-
hasClear:
|
|
91
|
-
onClear:
|
|
92
|
-
clearLabel:
|
|
88
|
+
tone: S,
|
|
89
|
+
placeholder: N,
|
|
90
|
+
search: p = !1,
|
|
91
|
+
showSubtitleInTrigger: T = !1,
|
|
92
|
+
searchQuery: L = "",
|
|
93
|
+
onSearchChange: C,
|
|
94
|
+
onFocusOpen: _,
|
|
95
|
+
onArrowDown: y,
|
|
96
|
+
onTabAway: k,
|
|
97
|
+
size: E = "large",
|
|
98
|
+
hasClear: v = !1,
|
|
99
|
+
onClear: P,
|
|
100
|
+
clearLabel: W,
|
|
93
101
|
controlId: i,
|
|
94
|
-
labelId:
|
|
102
|
+
labelId: c,
|
|
95
103
|
describedBy: o,
|
|
96
|
-
required:
|
|
97
|
-
ariaLabel:
|
|
98
|
-
ariaLabelledBy:
|
|
104
|
+
required: f = !1,
|
|
105
|
+
ariaLabel: w,
|
|
106
|
+
ariaLabelledBy: yt,
|
|
99
107
|
hasCallerId: $ = !1
|
|
100
|
-
},
|
|
101
|
-
const O =
|
|
102
|
-
if (
|
|
103
|
-
|
|
108
|
+
}, wt) => {
|
|
109
|
+
const O = T && !p && !!(r != null && r.subtitle), it = O ? ze[E] : De[E], at = Fe[E], G = `${i}-value`, St = `${i}-subtitle`, D = `${i}-tag`, ot = !p || u, H = ot && !!(r != null && r.triggerTag), lt = !ot && !t && !!(r != null && r.triggerTag), st = H ? `${G} ${D}` : G, ct = !c && !w && !$ && (O || H), b = yt ?? (c && !w ? `${c} ${st}` : void 0) ?? (ct ? st : void 0), R = H && !(b != null && b.split(" ").includes(D)), Tt = (l) => {
|
|
110
|
+
if (l.key === "Tab") {
|
|
111
|
+
k == null || k();
|
|
104
112
|
return;
|
|
105
113
|
}
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
const
|
|
109
|
-
return !
|
|
114
|
+
l.key === "ArrowDown" && (l.preventDefault(), y == null || y());
|
|
115
|
+
}, j = x(null), J = x(null), z = ve({ disabled: u, error: d, tone: S, open: t }), dt = !t && !!r, K = (r == null ? void 0 : r.triggerLabel) ?? (r == null ? void 0 : r.label), g = O ? r == null ? void 0 : r.subtitle : void 0, I = () => xt(j.current), [tt, A] = F({ value: !1, subtitle: !0 }), Dt = () => {
|
|
116
|
+
const l = I(), et = xt(J.current);
|
|
117
|
+
return !l && !et ? !1 : (A({ value: l, subtitle: et }), !0);
|
|
110
118
|
};
|
|
111
|
-
if (
|
|
112
|
-
return /* @__PURE__ */
|
|
119
|
+
if (p && !u)
|
|
120
|
+
return /* @__PURE__ */ m(
|
|
113
121
|
"div",
|
|
114
122
|
{
|
|
115
|
-
ref:
|
|
123
|
+
ref: wt,
|
|
116
124
|
className: `
|
|
117
|
-
relative w-full ${
|
|
125
|
+
relative w-full ${it} ${at}
|
|
118
126
|
border border-solid
|
|
119
127
|
transition-all duration-200
|
|
120
|
-
flex items-center ${
|
|
128
|
+
flex items-center ${Ee}
|
|
121
129
|
`,
|
|
122
|
-
style:
|
|
123
|
-
[
|
|
124
|
-
onClick: (
|
|
130
|
+
style: z,
|
|
131
|
+
[Vt]: "",
|
|
132
|
+
onClick: (l) => l.stopPropagation(),
|
|
125
133
|
children: [
|
|
126
|
-
(r == null ? void 0 : r.icon) && /* @__PURE__ */
|
|
127
|
-
/* @__PURE__ */ t
|
|
128
|
-
|
|
134
|
+
(r == null ? void 0 : r.icon) && /* @__PURE__ */ e("span", { className: "flex shrink-0 items-center justify-center pr-2", children: r.icon }),
|
|
135
|
+
/* @__PURE__ */ e($t, { text: K, shouldShow: I, isShrinkable: !0, fill: !0, children: /* @__PURE__ */ m("div", { className: "relative flex-1 flex items-center min-w-0", children: [
|
|
136
|
+
dt && /* @__PURE__ */ e(
|
|
129
137
|
"span",
|
|
130
138
|
{
|
|
131
139
|
"aria-hidden": "true",
|
|
132
140
|
className: "absolute inset-0 flex items-center pointer-events-none",
|
|
133
|
-
children: /* @__PURE__ */
|
|
141
|
+
children: /* @__PURE__ */ e(
|
|
134
142
|
"span",
|
|
135
143
|
{
|
|
136
|
-
ref:
|
|
144
|
+
ref: j,
|
|
137
145
|
className: `min-w-0 block truncate text-[length:inherit]
|
|
138
146
|
text-[var(--malachite-text-primary)]`,
|
|
139
|
-
children:
|
|
147
|
+
children: K
|
|
140
148
|
}
|
|
141
149
|
)
|
|
142
150
|
}
|
|
143
151
|
),
|
|
144
|
-
/* @__PURE__ */
|
|
152
|
+
/* @__PURE__ */ e(
|
|
145
153
|
"input",
|
|
146
154
|
{
|
|
147
155
|
id: i,
|
|
148
156
|
type: "text",
|
|
149
|
-
"aria-label":
|
|
150
|
-
"aria-labelledby":
|
|
157
|
+
"aria-label": w,
|
|
158
|
+
"aria-labelledby": yt,
|
|
151
159
|
"aria-invalid": d || void 0,
|
|
152
|
-
"aria-required":
|
|
153
|
-
"aria-describedby": o,
|
|
154
|
-
value:
|
|
155
|
-
onChange: (
|
|
156
|
-
|
|
160
|
+
"aria-required": f || void 0,
|
|
161
|
+
"aria-describedby": [o, lt ? D : void 0].filter(Boolean).join(" ") || void 0,
|
|
162
|
+
value: t ? L : (r == null ? void 0 : r.label) ?? "",
|
|
163
|
+
onChange: (l) => {
|
|
164
|
+
l.stopPropagation(), C == null || C(l.target.value), t || a();
|
|
157
165
|
},
|
|
158
166
|
onFocus: () => {
|
|
159
|
-
|
|
167
|
+
_ == null || _();
|
|
160
168
|
},
|
|
161
|
-
onKeyDown:
|
|
162
|
-
placeholder:
|
|
169
|
+
onKeyDown: Tt,
|
|
170
|
+
placeholder: N ?? "Select Field",
|
|
163
171
|
className: `flex-1 min-w-0 bg-transparent outline-none
|
|
164
172
|
text-[length:inherit] font-normal
|
|
165
|
-
placeholder:text-[var(--malachite-text-dimmed)] ${
|
|
173
|
+
placeholder:text-[var(--malachite-text-dimmed)] ${dt ? "text-transparent" : "text-[var(--malachite-text-primary)]"}`
|
|
166
174
|
}
|
|
167
175
|
)
|
|
168
176
|
] }) }),
|
|
169
|
-
|
|
177
|
+
lt && (r == null ? void 0 : r.triggerTag) && /* @__PURE__ */ m(bt, { children: [
|
|
178
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", className: "w-2 shrink-0" }),
|
|
179
|
+
/* @__PURE__ */ e(Xt, { id: D, text: r.triggerTag })
|
|
180
|
+
] }),
|
|
181
|
+
v && /* @__PURE__ */ e(
|
|
170
182
|
"button",
|
|
171
183
|
{
|
|
172
184
|
type: "button",
|
|
173
|
-
"aria-label":
|
|
174
|
-
onClick:
|
|
185
|
+
"aria-label": W,
|
|
186
|
+
onClick: P,
|
|
175
187
|
className: `flex shrink-0 items-center justify-center pl-2 cursor-pointer
|
|
176
188
|
bg-transparent border-none p-0 text-[var(--malachite-text-placeholder)]
|
|
177
189
|
hover:text-[var(--malachite-text-primary)] transition-colors
|
|
178
190
|
rounded-full focus-visible:[outline:2px_solid_var(--malachite-text-primary)] focus-visible:outline-offset-2`,
|
|
179
|
-
children: /* @__PURE__ */
|
|
191
|
+
children: /* @__PURE__ */ e(Jt, { size: 13 })
|
|
180
192
|
}
|
|
181
193
|
),
|
|
182
|
-
/* @__PURE__ */
|
|
194
|
+
/* @__PURE__ */ e("div", { className: "flex items-center justify-center pl-2", children: /* @__PURE__ */ e(
|
|
183
195
|
"button",
|
|
184
196
|
{
|
|
185
197
|
type: "button",
|
|
186
198
|
tabIndex: -1,
|
|
187
|
-
"aria-label":
|
|
188
|
-
onClick: (
|
|
189
|
-
|
|
199
|
+
"aria-label": t ? "Close options" : "Open options",
|
|
200
|
+
onClick: (l) => {
|
|
201
|
+
l.stopPropagation(), a();
|
|
190
202
|
},
|
|
191
203
|
className: "flex items-center justify-center cursor-pointer bg-transparent border-none p-0",
|
|
192
|
-
children: /* @__PURE__ */
|
|
193
|
-
|
|
204
|
+
children: /* @__PURE__ */ e(
|
|
205
|
+
Zt,
|
|
194
206
|
{
|
|
195
207
|
size: 13,
|
|
196
208
|
style: {
|
|
197
|
-
color:
|
|
209
|
+
color: t ? "var(--malachite-text-primary, rgb(10, 10, 10))" : "var(--malachite-text-placeholder, rgb(187, 187, 187))",
|
|
198
210
|
transition: "transform 0.2s ease, color 0.2s ease",
|
|
199
|
-
transform:
|
|
211
|
+
transform: t ? "rotate(180deg)" : "rotate(0deg)"
|
|
200
212
|
}
|
|
201
213
|
}
|
|
202
214
|
)
|
|
@@ -205,139 +217,147 @@ const Rt = Ce.lazy(() => import("./ActionMenuTagHost.js")), Ye = /[*`[<&\\]/, de
|
|
|
205
217
|
]
|
|
206
218
|
}
|
|
207
219
|
);
|
|
208
|
-
const
|
|
220
|
+
const ut = /* @__PURE__ */ m(
|
|
209
221
|
"button",
|
|
210
222
|
{
|
|
211
|
-
ref:
|
|
223
|
+
ref: wt,
|
|
212
224
|
id: i,
|
|
213
225
|
type: "button",
|
|
214
|
-
"aria-label":
|
|
215
|
-
"aria-labelledby":
|
|
226
|
+
"aria-label": w,
|
|
227
|
+
"aria-labelledby": b,
|
|
216
228
|
"aria-invalid": d || void 0,
|
|
217
|
-
"aria-required":
|
|
218
|
-
"aria-describedby": [
|
|
219
|
-
|
|
220
|
-
|
|
229
|
+
"aria-required": f || void 0,
|
|
230
|
+
"aria-describedby": [
|
|
231
|
+
o,
|
|
232
|
+
g ? St : void 0,
|
|
233
|
+
R ? D : void 0
|
|
234
|
+
].filter(Boolean).join(" ") || void 0,
|
|
235
|
+
onClick: (l) => {
|
|
236
|
+
l.stopPropagation(), a(l.detail === 0);
|
|
221
237
|
},
|
|
222
|
-
onKeyDown:
|
|
223
|
-
disabled:
|
|
224
|
-
style:
|
|
225
|
-
[
|
|
238
|
+
onKeyDown: Tt,
|
|
239
|
+
disabled: u,
|
|
240
|
+
style: z,
|
|
241
|
+
[Vt]: "",
|
|
226
242
|
className: `
|
|
227
|
-
relative w-full ${
|
|
243
|
+
relative w-full ${it} ${at}
|
|
228
244
|
border border-solid
|
|
229
245
|
transition-all duration-200
|
|
230
246
|
flex ${O ? "items-start" : "items-center"} gap-3
|
|
231
247
|
cursor-pointer
|
|
232
|
-
disabled:cursor-not-allowed ${
|
|
248
|
+
disabled:cursor-not-allowed ${Ne}
|
|
233
249
|
`,
|
|
234
250
|
children: [
|
|
235
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ e(
|
|
236
252
|
"span",
|
|
237
253
|
{
|
|
238
|
-
id:
|
|
239
|
-
className: `text-left flex-1 min-w-0 flex ${
|
|
240
|
-
children: r ? /* @__PURE__ */
|
|
241
|
-
/* @__PURE__ */
|
|
242
|
-
r.icon && /* @__PURE__ */
|
|
243
|
-
/* @__PURE__ */
|
|
244
|
-
|
|
254
|
+
id: g ? void 0 : G,
|
|
255
|
+
className: `text-left ${H ? "flex-[1_1_auto]" : "flex-1"} min-w-0 flex ${g ? "flex-col gap-1" : "items-center gap-2"}`,
|
|
256
|
+
children: r ? /* @__PURE__ */ m(bt, { children: [
|
|
257
|
+
/* @__PURE__ */ m(Pe, { wrap: !!g, id: G, children: [
|
|
258
|
+
r.icon && /* @__PURE__ */ e("span", { className: "flex items-center justify-center shrink-0", children: r.icon }),
|
|
259
|
+
/* @__PURE__ */ e(
|
|
260
|
+
$t,
|
|
245
261
|
{
|
|
246
|
-
text:
|
|
247
|
-
shouldShow:
|
|
248
|
-
triggerAs:
|
|
262
|
+
text: K,
|
|
263
|
+
shouldShow: g ? Qt : I,
|
|
264
|
+
triggerAs: g ? "span" : "div",
|
|
249
265
|
isShrinkable: !0,
|
|
250
|
-
children: /* @__PURE__ */
|
|
266
|
+
children: /* @__PURE__ */ e(
|
|
251
267
|
"span",
|
|
252
268
|
{
|
|
253
|
-
ref:
|
|
254
|
-
className: `min-w-0 block truncate text-[length:inherit] ${
|
|
255
|
-
children:
|
|
269
|
+
ref: j,
|
|
270
|
+
className: `min-w-0 block truncate text-[length:inherit] ${u ? "text-[var(--malachite-text-placeholder)]" : "text-[var(--malachite-text-primary)]"}`,
|
|
271
|
+
children: K
|
|
256
272
|
}
|
|
257
273
|
)
|
|
258
274
|
}
|
|
259
275
|
)
|
|
260
276
|
] }),
|
|
261
|
-
|
|
277
|
+
g && /* @__PURE__ */ e(
|
|
262
278
|
"span",
|
|
263
279
|
{
|
|
264
|
-
id:
|
|
265
|
-
ref:
|
|
280
|
+
id: St,
|
|
281
|
+
ref: J,
|
|
266
282
|
className: "min-w-0 block truncate text-[length:var(--malachite-font-size-xsmall,11px)] text-[var(--malachite-text-secondary,rgb(123,123,123))] leading-normal",
|
|
267
|
-
children: /* @__PURE__ */
|
|
283
|
+
children: /* @__PURE__ */ e(mt, { text: g })
|
|
268
284
|
}
|
|
269
285
|
)
|
|
270
|
-
] }) : /* @__PURE__ */
|
|
286
|
+
] }) : /* @__PURE__ */ e(
|
|
271
287
|
"span",
|
|
272
288
|
{
|
|
273
|
-
className: `flex-1 min-w-0 truncate text-[length:inherit] ${
|
|
274
|
-
children:
|
|
289
|
+
className: `flex-1 min-w-0 truncate text-[length:inherit] ${u ? "text-[var(--malachite-text-placeholder)]" : "text-[var(--malachite-text-dimmed)]"}`,
|
|
290
|
+
children: N ?? "Select Field"
|
|
275
291
|
}
|
|
276
292
|
)
|
|
277
293
|
}
|
|
278
294
|
),
|
|
279
|
-
|
|
280
|
-
/* @__PURE__ */
|
|
281
|
-
|
|
295
|
+
(r == null ? void 0 : r.triggerTag) && /* @__PURE__ */ e(Xt, { id: D, text: r.triggerTag, disabled: u }),
|
|
296
|
+
v && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: "shrink-0 w-4" }),
|
|
297
|
+
/* @__PURE__ */ e("span", { className: "flex items-center justify-center shrink-0", children: /* @__PURE__ */ e(
|
|
298
|
+
Zt,
|
|
282
299
|
{
|
|
283
300
|
size: 13,
|
|
284
301
|
style: {
|
|
285
|
-
color:
|
|
302
|
+
color: t ? "var(--malachite-text-primary, rgb(10, 10, 10))" : "var(--malachite-text-placeholder, rgb(187, 187, 187))",
|
|
286
303
|
transition: "transform 0.2s ease, color 0.2s ease",
|
|
287
|
-
transform:
|
|
304
|
+
transform: t ? "rotate(180deg)" : "rotate(0deg)"
|
|
288
305
|
}
|
|
289
306
|
}
|
|
290
307
|
) })
|
|
291
308
|
]
|
|
292
309
|
}
|
|
293
310
|
);
|
|
294
|
-
return
|
|
295
|
-
|
|
311
|
+
return T && !p ? /* @__PURE__ */ e(
|
|
312
|
+
$t,
|
|
296
313
|
{
|
|
297
|
-
text:
|
|
298
|
-
["value",
|
|
314
|
+
text: It([
|
|
315
|
+
["value", tt.value && K],
|
|
299
316
|
[
|
|
300
317
|
"subtitle",
|
|
301
|
-
|
|
318
|
+
tt.subtitle && g && /* @__PURE__ */ e(mt, { text: g })
|
|
302
319
|
]
|
|
303
320
|
]),
|
|
304
|
-
shouldShow:
|
|
321
|
+
shouldShow: g ? Dt : Qt,
|
|
305
322
|
fill: !0,
|
|
306
323
|
describesTrigger: !1,
|
|
307
|
-
children:
|
|
324
|
+
children: ut
|
|
308
325
|
}
|
|
309
|
-
) :
|
|
326
|
+
) : ut;
|
|
310
327
|
}
|
|
311
328
|
);
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
item:
|
|
329
|
+
ee.displayName = "DropdownTrigger";
|
|
330
|
+
const Ge = ({
|
|
331
|
+
item: t,
|
|
315
332
|
selected: a,
|
|
316
333
|
showTooltipOnFocus: r,
|
|
317
|
-
subtitleLayout:
|
|
334
|
+
subtitleLayout: u,
|
|
318
335
|
onItemSelected: d
|
|
319
336
|
}) => {
|
|
320
|
-
const
|
|
321
|
-
const
|
|
322
|
-
return !
|
|
323
|
-
},
|
|
337
|
+
const S = a ? "var(--malachite-accent-foreground, rgb(2, 122, 66))" : "var(--malachite-text-primary, rgb(10, 10, 10))", N = u === "stacked" && !!t.subtitle, p = `mal-${se().replace(/[^a-zA-Z0-9_-]/g, "")}`, T = `${p}-label`, L = `${p}-subtitle`, C = `${p}-badge`, _ = x(null), y = x(null), k = x(null), [E, v] = F({ label: !0, subtitle: !0, rightSide: !0 }), P = () => {
|
|
338
|
+
const o = xt(_.current), f = xt(y.current), w = xt(k.current);
|
|
339
|
+
return !o && !f && !w ? !1 : (v({ label: o, subtitle: f, rightSide: w }), !0);
|
|
340
|
+
}, W = t.rightSideTextVariant === "primary" ? "var(--malachite-text-right-side-text-primary, rgb(10, 10, 10))" : "var(--malachite-text-right-side-text-muted, rgb(123, 123, 123))", i = t.rightSideTextAlignment === "left" ? "flex-start" : "flex-end", c = (
|
|
324
341
|
// `role="option"` would be invalid — nothing here declares a `listbox`, and an
|
|
325
342
|
// orphaned option is dropped from the a11y tree. `aria-current`, not
|
|
326
343
|
// `aria-pressed`: these are one-of-many choices, not toggles. tabIndex={-1}
|
|
327
344
|
// because the portaled panel is outside the trigger's tab order; DropdownPanel
|
|
328
345
|
// focuses an option on open and arrow keys move between them.
|
|
329
|
-
/* @__PURE__ */
|
|
346
|
+
/* @__PURE__ */ e(
|
|
330
347
|
"button",
|
|
331
348
|
{
|
|
332
349
|
type: "button",
|
|
333
350
|
"data-dropdown-option": "",
|
|
334
351
|
"data-selected": a,
|
|
335
352
|
"aria-current": a || void 0,
|
|
336
|
-
"aria-labelledby":
|
|
337
|
-
"aria-describedby":
|
|
353
|
+
"aria-labelledby": t.subtitle || Lt(t.badge) ? T : void 0,
|
|
354
|
+
"aria-describedby": [
|
|
355
|
+
t.subtitle ? L : void 0,
|
|
356
|
+
Lt(t.badge) ? C : void 0
|
|
357
|
+
].filter(Boolean).join(" ") || void 0,
|
|
338
358
|
tabIndex: -1,
|
|
339
|
-
onClick: (
|
|
340
|
-
|
|
359
|
+
onClick: (o) => {
|
|
360
|
+
o.stopPropagation(), d(t);
|
|
341
361
|
},
|
|
342
362
|
className: "malachite-dropdown-option",
|
|
343
363
|
style: {
|
|
@@ -356,7 +376,7 @@ const Pt = ({
|
|
|
356
376
|
font: "inherit",
|
|
357
377
|
color: "inherit"
|
|
358
378
|
},
|
|
359
|
-
children: /* @__PURE__ */
|
|
379
|
+
children: /* @__PURE__ */ m(
|
|
360
380
|
"span",
|
|
361
381
|
{
|
|
362
382
|
style: {
|
|
@@ -367,13 +387,13 @@ const Pt = ({
|
|
|
367
387
|
minWidth: 0
|
|
368
388
|
},
|
|
369
389
|
children: [
|
|
370
|
-
/* @__PURE__ */
|
|
390
|
+
/* @__PURE__ */ e("span", { style: { flex: "1 1 auto", display: "block", minWidth: 0 }, children: /* @__PURE__ */ m(
|
|
371
391
|
"span",
|
|
372
392
|
{
|
|
373
|
-
style:
|
|
393
|
+
style: N ? { display: "flex", flexDirection: "column", gap: 2 } : { display: "flex", alignItems: "center", gap: 8 },
|
|
374
394
|
children: [
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
|
|
395
|
+
/* @__PURE__ */ m(We, { row: N && !!t.icon, children: [
|
|
396
|
+
t.icon && /* @__PURE__ */ e(
|
|
377
397
|
"span",
|
|
378
398
|
{
|
|
379
399
|
style: {
|
|
@@ -382,43 +402,43 @@ const Pt = ({
|
|
|
382
402
|
justifyContent: "center",
|
|
383
403
|
flexShrink: 0
|
|
384
404
|
},
|
|
385
|
-
children:
|
|
405
|
+
children: t.icon
|
|
386
406
|
}
|
|
387
407
|
),
|
|
388
|
-
/* @__PURE__ */
|
|
408
|
+
/* @__PURE__ */ e(
|
|
389
409
|
"span",
|
|
390
410
|
{
|
|
391
|
-
id:
|
|
392
|
-
ref:
|
|
411
|
+
id: t.subtitle || Lt(t.badge) ? T : void 0,
|
|
412
|
+
ref: _,
|
|
393
413
|
style: {
|
|
394
414
|
fontWeight: 400,
|
|
395
|
-
color:
|
|
415
|
+
color: S,
|
|
396
416
|
whiteSpace: "nowrap",
|
|
397
417
|
overflow: "hidden",
|
|
398
418
|
textOverflow: "ellipsis",
|
|
399
419
|
minWidth: 0
|
|
400
420
|
},
|
|
401
|
-
children:
|
|
421
|
+
children: t.label
|
|
402
422
|
}
|
|
403
423
|
)
|
|
404
424
|
] }),
|
|
405
|
-
|
|
425
|
+
t.subtitle && (N ? /* @__PURE__ */ e(
|
|
406
426
|
"span",
|
|
407
427
|
{
|
|
408
|
-
id:
|
|
409
|
-
ref:
|
|
428
|
+
id: L,
|
|
429
|
+
ref: y,
|
|
410
430
|
style: {
|
|
411
|
-
fontSize:
|
|
431
|
+
fontSize: Ft,
|
|
412
432
|
fontWeight: 400,
|
|
413
433
|
lineHeight: 1.4,
|
|
414
|
-
color: a ?
|
|
434
|
+
color: a ? S : "var(--malachite-text-dimmed, rgb(161, 161, 161))",
|
|
415
435
|
whiteSpace: "nowrap",
|
|
416
436
|
overflow: "hidden",
|
|
417
437
|
textOverflow: "ellipsis"
|
|
418
438
|
},
|
|
419
|
-
children: /* @__PURE__ */
|
|
439
|
+
children: /* @__PURE__ */ e(mt, { text: t.subtitle })
|
|
420
440
|
}
|
|
421
|
-
) : /* @__PURE__ */
|
|
441
|
+
) : /* @__PURE__ */ m(
|
|
422
442
|
"span",
|
|
423
443
|
{
|
|
424
444
|
style: {
|
|
@@ -432,11 +452,11 @@ const Pt = ({
|
|
|
432
452
|
overflow: "hidden"
|
|
433
453
|
},
|
|
434
454
|
children: [
|
|
435
|
-
/* @__PURE__ */
|
|
455
|
+
/* @__PURE__ */ e(
|
|
436
456
|
"span",
|
|
437
457
|
{
|
|
438
458
|
style: {
|
|
439
|
-
fontSize:
|
|
459
|
+
fontSize: Ft,
|
|
440
460
|
fontWeight: 400,
|
|
441
461
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
442
462
|
flexShrink: 0
|
|
@@ -444,13 +464,13 @@ const Pt = ({
|
|
|
444
464
|
children: "|"
|
|
445
465
|
}
|
|
446
466
|
),
|
|
447
|
-
/* @__PURE__ */
|
|
467
|
+
/* @__PURE__ */ e(
|
|
448
468
|
"span",
|
|
449
469
|
{
|
|
450
|
-
id:
|
|
451
|
-
ref:
|
|
470
|
+
id: L,
|
|
471
|
+
ref: y,
|
|
452
472
|
style: {
|
|
453
|
-
fontSize:
|
|
473
|
+
fontSize: Ft,
|
|
454
474
|
fontWeight: 400,
|
|
455
475
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
456
476
|
whiteSpace: "nowrap",
|
|
@@ -458,7 +478,7 @@ const Pt = ({
|
|
|
458
478
|
textOverflow: "ellipsis",
|
|
459
479
|
minWidth: 0
|
|
460
480
|
},
|
|
461
|
-
children: /* @__PURE__ */
|
|
481
|
+
children: /* @__PURE__ */ e(mt, { text: t.subtitle })
|
|
462
482
|
}
|
|
463
483
|
)
|
|
464
484
|
]
|
|
@@ -467,140 +487,140 @@ const Pt = ({
|
|
|
467
487
|
]
|
|
468
488
|
}
|
|
469
489
|
) }),
|
|
470
|
-
/* @__PURE__ */
|
|
490
|
+
/* @__PURE__ */ e(
|
|
471
491
|
"span",
|
|
472
492
|
{
|
|
473
493
|
style: {
|
|
474
494
|
// Reserved only when there is something to put there: an empty slot
|
|
475
495
|
// still holding its width truncates the label and subtitle early.
|
|
476
|
-
minWidth:
|
|
496
|
+
minWidth: t.rightSideText ? "var(--malachite-text-right-side-text-min-width, 80px)" : 0,
|
|
477
497
|
flexShrink: 1,
|
|
478
498
|
display: "flex",
|
|
479
|
-
justifyContent:
|
|
499
|
+
justifyContent: i
|
|
480
500
|
},
|
|
481
|
-
children:
|
|
501
|
+
children: t.rightSideText && /* @__PURE__ */ e(
|
|
482
502
|
"span",
|
|
483
503
|
{
|
|
484
|
-
ref:
|
|
504
|
+
ref: k,
|
|
485
505
|
style: {
|
|
486
506
|
fontSize: "var(--malachite-text-right-side-text-font-size, 12px)",
|
|
487
507
|
fontWeight: 400,
|
|
488
|
-
color:
|
|
508
|
+
color: W,
|
|
489
509
|
whiteSpace: "nowrap",
|
|
490
510
|
overflow: "hidden",
|
|
491
511
|
textOverflow: "ellipsis",
|
|
492
512
|
minWidth: 0
|
|
493
513
|
},
|
|
494
|
-
children:
|
|
514
|
+
children: t.rightSideText
|
|
495
515
|
}
|
|
496
516
|
)
|
|
497
517
|
}
|
|
498
518
|
),
|
|
499
|
-
|
|
519
|
+
Lt(t.badge) && /* @__PURE__ */ e("span", { id: C, style: { flexShrink: 0, display: "flex" }, children: /* @__PURE__ */ e(Ot.Suspense, { fallback: null, children: /* @__PURE__ */ e(Re, { children: t.badge }) }) })
|
|
500
520
|
]
|
|
501
521
|
}
|
|
502
522
|
)
|
|
503
523
|
}
|
|
504
524
|
)
|
|
505
525
|
);
|
|
506
|
-
return /* @__PURE__ */
|
|
507
|
-
|
|
526
|
+
return /* @__PURE__ */ e(
|
|
527
|
+
$t,
|
|
508
528
|
{
|
|
509
|
-
text:
|
|
510
|
-
["label", E.label &&
|
|
529
|
+
text: It([
|
|
530
|
+
["label", E.label && t.label],
|
|
511
531
|
[
|
|
512
532
|
"subtitle",
|
|
513
|
-
E.subtitle &&
|
|
533
|
+
E.subtitle && t.subtitle && /* @__PURE__ */ e(mt, { text: t.subtitle })
|
|
514
534
|
],
|
|
515
|
-
["rightSide", E.rightSide &&
|
|
535
|
+
["rightSide", E.rightSide && t.rightSideText]
|
|
516
536
|
]),
|
|
517
|
-
shouldShow:
|
|
537
|
+
shouldShow: P,
|
|
518
538
|
showOnFocus: r,
|
|
519
539
|
isShrinkable: !0,
|
|
520
540
|
describesTrigger: !1,
|
|
521
|
-
children:
|
|
541
|
+
children: c
|
|
522
542
|
}
|
|
523
543
|
);
|
|
524
|
-
},
|
|
544
|
+
}, re = Ot.forwardRef((t, a) => {
|
|
525
545
|
const {
|
|
526
546
|
items: r,
|
|
527
|
-
onItemSelected:
|
|
547
|
+
onItemSelected: u,
|
|
528
548
|
selectedItem: d,
|
|
529
|
-
menuLoading:
|
|
530
|
-
emptyMessage:
|
|
531
|
-
autoFocus:
|
|
532
|
-
positioned:
|
|
533
|
-
onDismiss:
|
|
534
|
-
keyboardNavigation:
|
|
535
|
-
onKeyboardNavigation:
|
|
536
|
-
subtitleLayout:
|
|
537
|
-
size:
|
|
538
|
-
style:
|
|
539
|
-
} =
|
|
540
|
-
return
|
|
541
|
-
|
|
542
|
-
}, []),
|
|
549
|
+
menuLoading: S,
|
|
550
|
+
emptyMessage: N,
|
|
551
|
+
autoFocus: p,
|
|
552
|
+
positioned: T,
|
|
553
|
+
onDismiss: L,
|
|
554
|
+
keyboardNavigation: C,
|
|
555
|
+
onKeyboardNavigation: _,
|
|
556
|
+
subtitleLayout: y,
|
|
557
|
+
size: k,
|
|
558
|
+
style: E
|
|
559
|
+
} = t, v = x(null), P = _e("dropdown", !0, v);
|
|
560
|
+
return le(() => {
|
|
561
|
+
Ce();
|
|
562
|
+
}, []), ke(v, !0), Pt(() => {
|
|
543
563
|
var o;
|
|
544
|
-
if (!
|
|
564
|
+
if (!p || !T)
|
|
545
565
|
return;
|
|
546
|
-
const i =
|
|
547
|
-
(o = i.find((
|
|
548
|
-
}, [
|
|
566
|
+
const i = Wt(v.current);
|
|
567
|
+
(o = i.find((f) => f.dataset.selected === "true") ?? i[0] ?? v.current) == null || o.focus();
|
|
568
|
+
}, [p, T]), /* @__PURE__ */ e(
|
|
549
569
|
"div",
|
|
550
570
|
{
|
|
551
571
|
ref: (i) => {
|
|
552
|
-
|
|
572
|
+
v.current = i, typeof a == "function" ? a(i) : a && (a.current = i);
|
|
553
573
|
},
|
|
554
|
-
...
|
|
574
|
+
...P,
|
|
555
575
|
tabIndex: -1,
|
|
556
576
|
onKeyDown: (i) => {
|
|
557
|
-
var
|
|
577
|
+
var w;
|
|
558
578
|
if (i.key === "Tab") {
|
|
559
|
-
|
|
579
|
+
L();
|
|
560
580
|
return;
|
|
561
581
|
}
|
|
562
|
-
const
|
|
563
|
-
if (
|
|
582
|
+
const c = Wt(v.current);
|
|
583
|
+
if (c.length === 0)
|
|
564
584
|
return;
|
|
565
|
-
const o =
|
|
585
|
+
const o = c.indexOf(document.activeElement), f = {
|
|
566
586
|
ArrowDown: o + 1,
|
|
567
587
|
ArrowUp: o - 1,
|
|
568
588
|
Home: 0,
|
|
569
|
-
End:
|
|
589
|
+
End: c.length - 1
|
|
570
590
|
}[i.key];
|
|
571
|
-
|
|
591
|
+
f !== void 0 && (i.preventDefault(), _(), (w = c[Math.min(Math.max(f, 0), c.length - 1)]) == null || w.focus());
|
|
572
592
|
},
|
|
573
593
|
style: {
|
|
574
|
-
background:
|
|
575
|
-
border:
|
|
576
|
-
borderRadius:
|
|
577
|
-
boxShadow:
|
|
578
|
-
maxHeight:
|
|
594
|
+
background: gt.standard.background,
|
|
595
|
+
border: gt.standard.border,
|
|
596
|
+
borderRadius: gt.standard.radius,
|
|
597
|
+
boxShadow: gt.standard.shadow,
|
|
598
|
+
maxHeight: Te,
|
|
579
599
|
overflow: "hidden",
|
|
580
600
|
display: "flex",
|
|
581
601
|
flexDirection: "column",
|
|
582
|
-
fontSize:
|
|
583
|
-
...
|
|
602
|
+
fontSize: me[k],
|
|
603
|
+
...E
|
|
584
604
|
},
|
|
585
|
-
children:
|
|
586
|
-
/* @__PURE__ */
|
|
587
|
-
/* @__PURE__ */
|
|
588
|
-
] }) : r.length === 0 ? /* @__PURE__ */
|
|
605
|
+
children: S ? /* @__PURE__ */ m("div", { style: Yt, children: [
|
|
606
|
+
/* @__PURE__ */ e(fe, { size: "xxxsmall" }),
|
|
607
|
+
/* @__PURE__ */ e("span", { children: "Loading…" })
|
|
608
|
+
] }) : r.length === 0 ? /* @__PURE__ */ e("div", { style: Yt, children: N }) : /* @__PURE__ */ e(
|
|
589
609
|
"div",
|
|
590
610
|
{
|
|
591
611
|
style: {
|
|
592
612
|
display: "flex",
|
|
593
613
|
flexDirection: "column",
|
|
594
614
|
gap: 4,
|
|
595
|
-
padding:
|
|
615
|
+
padding: gt.standard.padding,
|
|
596
616
|
overflowY: "auto",
|
|
597
617
|
scrollbarWidth: "thin",
|
|
598
618
|
scrollbarColor: "var(--malachite-text-placeholder, rgb(187, 187, 187)) transparent"
|
|
599
619
|
},
|
|
600
|
-
children: r.map((i,
|
|
601
|
-
const o = r[
|
|
602
|
-
return /* @__PURE__ */
|
|
603
|
-
|
|
620
|
+
children: r.map((i, c) => {
|
|
621
|
+
const o = r[c - 1], f = !!i.group && (!o || o.group !== i.group);
|
|
622
|
+
return /* @__PURE__ */ m("div", { style: { flexShrink: 0 }, children: [
|
|
623
|
+
f && /* @__PURE__ */ e(
|
|
604
624
|
"div",
|
|
605
625
|
{
|
|
606
626
|
style: {
|
|
@@ -614,14 +634,14 @@ const Pt = ({
|
|
|
614
634
|
children: i.group
|
|
615
635
|
}
|
|
616
636
|
),
|
|
617
|
-
/* @__PURE__ */
|
|
618
|
-
|
|
637
|
+
/* @__PURE__ */ e(
|
|
638
|
+
Ge,
|
|
619
639
|
{
|
|
620
640
|
item: i,
|
|
621
|
-
onItemSelected:
|
|
622
|
-
subtitleLayout:
|
|
641
|
+
onItemSelected: u,
|
|
642
|
+
subtitleLayout: y,
|
|
623
643
|
selected: i.id === (d == null ? void 0 : d.id) || !1,
|
|
624
|
-
showTooltipOnFocus:
|
|
644
|
+
showTooltipOnFocus: C
|
|
625
645
|
}
|
|
626
646
|
)
|
|
627
647
|
] }, i.id);
|
|
@@ -631,269 +651,269 @@ const Pt = ({
|
|
|
631
651
|
}
|
|
632
652
|
);
|
|
633
653
|
});
|
|
634
|
-
|
|
635
|
-
const
|
|
636
|
-
items:
|
|
654
|
+
re.displayName = "DropdownPanel";
|
|
655
|
+
const pr = ({
|
|
656
|
+
items: t,
|
|
637
657
|
onItemSelected: a,
|
|
638
658
|
defaultValue: r,
|
|
639
|
-
value:
|
|
659
|
+
value: u,
|
|
640
660
|
disabled: d = !1,
|
|
641
|
-
error:
|
|
642
|
-
tone:
|
|
643
|
-
label:
|
|
644
|
-
hint:
|
|
645
|
-
rightSideContent:
|
|
646
|
-
tooltip:
|
|
647
|
-
name:
|
|
648
|
-
required:
|
|
649
|
-
requiredIndicator:
|
|
650
|
-
loading:
|
|
651
|
-
menuLoading:
|
|
652
|
-
formControl:
|
|
653
|
-
description:
|
|
661
|
+
error: S,
|
|
662
|
+
tone: N,
|
|
663
|
+
label: p,
|
|
664
|
+
hint: T,
|
|
665
|
+
rightSideContent: L,
|
|
666
|
+
tooltip: C,
|
|
667
|
+
name: _,
|
|
668
|
+
required: y = !1,
|
|
669
|
+
requiredIndicator: k,
|
|
670
|
+
loading: E,
|
|
671
|
+
menuLoading: v,
|
|
672
|
+
formControl: P,
|
|
673
|
+
description: W,
|
|
654
674
|
helperText: i,
|
|
655
|
-
placeholder:
|
|
675
|
+
placeholder: c,
|
|
656
676
|
search: o = !1,
|
|
657
|
-
showSubtitleInTrigger:
|
|
658
|
-
subtitleLayout:
|
|
659
|
-
clearable:
|
|
677
|
+
showSubtitleInTrigger: f = !1,
|
|
678
|
+
subtitleLayout: w = "inline",
|
|
679
|
+
clearable: yt = !1,
|
|
660
680
|
size: $ = "large",
|
|
661
|
-
fullWidth:
|
|
681
|
+
fullWidth: wt = !1,
|
|
662
682
|
width: O,
|
|
663
|
-
minWidth:
|
|
664
|
-
menuAlign:
|
|
665
|
-
id:
|
|
666
|
-
"aria-label":
|
|
667
|
-
"aria-labelledby":
|
|
683
|
+
minWidth: it,
|
|
684
|
+
menuAlign: at = "start",
|
|
685
|
+
id: G,
|
|
686
|
+
"aria-label": St,
|
|
687
|
+
"aria-labelledby": D
|
|
668
688
|
}) => {
|
|
669
|
-
const { controlId:
|
|
670
|
-
id:
|
|
671
|
-
label:
|
|
672
|
-
description:
|
|
673
|
-
hint:
|
|
689
|
+
const { controlId: ot, labelId: H, descriptionId: lt, hintId: st, helperTextId: ct } = ue({
|
|
690
|
+
id: G,
|
|
691
|
+
label: p,
|
|
692
|
+
description: W,
|
|
693
|
+
hint: T,
|
|
674
694
|
helperText: !0
|
|
675
|
-
}), [
|
|
676
|
-
|
|
677
|
-
|
|
695
|
+
}), [b, R] = F(!1), [Tt, j] = F(r), J = u ?? Tt, z = t.find((n) => n.id === J), dt = yt && J !== void 0 && J !== "" && !d, K = f && !o && !!(z != null && z.subtitle), g = `Clear ${p ?? c ?? "selection"}`, I = x(r);
|
|
696
|
+
Pt(() => {
|
|
697
|
+
I.current !== r && (I.current = r, j(r));
|
|
678
698
|
}, [r]);
|
|
679
|
-
const [
|
|
680
|
-
const n =
|
|
681
|
-
if (!(!
|
|
699
|
+
const [tt, A] = F(""), [Dt, ut] = F(!1), [l, et] = F(!1), zt = x(null), Et = x(null), B = x(null), [h, Gt] = F(null), Nt = x(!0), Z = Mt(() => {
|
|
700
|
+
const n = Et.current, s = n instanceof HTMLButtonElement ? n : (n == null ? void 0 : n.querySelector("input")) ?? null;
|
|
701
|
+
if (!(!s || s === Rt())) {
|
|
682
702
|
if (!o) {
|
|
683
|
-
|
|
703
|
+
s.focus();
|
|
684
704
|
return;
|
|
685
705
|
}
|
|
686
|
-
|
|
706
|
+
Nt.current = !1, s.focus(), Rt() !== s && (Nt.current = !0);
|
|
687
707
|
}
|
|
688
|
-
}, [o]),
|
|
708
|
+
}, [o]), Ht = Mt(
|
|
689
709
|
(n) => {
|
|
690
|
-
var
|
|
691
|
-
n.stopPropagation(),
|
|
710
|
+
var s;
|
|
711
|
+
n.stopPropagation(), j(void 0), (s = q.current) == null || s.call(q, At.current), a == null || a(void 0), Z();
|
|
692
712
|
},
|
|
693
|
-
[a,
|
|
694
|
-
),
|
|
695
|
-
const n =
|
|
696
|
-
n &&
|
|
697
|
-
|
|
713
|
+
[a, Z]
|
|
714
|
+
), U = Mt(() => {
|
|
715
|
+
const n = Et.current;
|
|
716
|
+
n && Gt(
|
|
717
|
+
ye(B.current, {
|
|
698
718
|
triggerRect: n.getBoundingClientRect(),
|
|
699
719
|
preset: "standard",
|
|
700
|
-
minWidth:
|
|
701
|
-
align:
|
|
720
|
+
minWidth: it,
|
|
721
|
+
align: at === "end" ? "right" : "left",
|
|
702
722
|
viewportWidth: window.innerWidth,
|
|
703
723
|
viewportHeight: window.innerHeight
|
|
704
724
|
})
|
|
705
725
|
);
|
|
706
|
-
}, [
|
|
707
|
-
|
|
708
|
-
if (!
|
|
709
|
-
|
|
726
|
+
}, [it, at]);
|
|
727
|
+
Pt(() => {
|
|
728
|
+
if (!b) {
|
|
729
|
+
Gt(null), ut(!1);
|
|
710
730
|
return;
|
|
711
731
|
}
|
|
712
|
-
|
|
713
|
-
const n = (
|
|
714
|
-
var
|
|
715
|
-
const
|
|
716
|
-
!
|
|
717
|
-
},
|
|
718
|
-
|
|
719
|
-
}),
|
|
720
|
-
let
|
|
721
|
-
const
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
724
|
-
const
|
|
725
|
-
if (
|
|
726
|
-
|
|
732
|
+
U();
|
|
733
|
+
const n = (X) => {
|
|
734
|
+
var ft, ht, Bt;
|
|
735
|
+
const M = X.composedPath(), Y = zt.current, Q = B.current, kt = !!Y && M.includes(Y), Kt = !!Q && M.includes(Q);
|
|
736
|
+
!kt && !Kt && (R(!1), o && A(""), (ft = B.current) != null && ft.contains(Rt()) && Z(), (ht = zt.current) != null && ht.contains(Rt()) || (Bt = V.current) == null || Bt.call(V));
|
|
737
|
+
}, s = be(() => {
|
|
738
|
+
R(!1), o && A(""), Z();
|
|
739
|
+
}), rt = () => U();
|
|
740
|
+
let pt = 0, Ct = "";
|
|
741
|
+
const _t = () => {
|
|
742
|
+
const X = Et.current;
|
|
743
|
+
if (X) {
|
|
744
|
+
const M = X.getBoundingClientRect();
|
|
745
|
+
if (we(M, window.innerWidth, window.innerHeight)) {
|
|
746
|
+
R(!1), o && A("");
|
|
727
747
|
return;
|
|
728
748
|
}
|
|
729
|
-
const
|
|
730
|
-
|
|
749
|
+
const Y = Se(M);
|
|
750
|
+
Y !== Ct && (Ct = Y, U());
|
|
731
751
|
}
|
|
732
|
-
|
|
752
|
+
pt = requestAnimationFrame(_t);
|
|
733
753
|
};
|
|
734
|
-
return
|
|
735
|
-
cancelAnimationFrame(
|
|
754
|
+
return pt = requestAnimationFrame(_t), document.addEventListener("mousedown", n), window.addEventListener("scroll", rt, !0), window.addEventListener("resize", rt), () => {
|
|
755
|
+
cancelAnimationFrame(pt), document.removeEventListener("mousedown", n), s(), window.removeEventListener("scroll", rt, !0), window.removeEventListener("resize", rt);
|
|
736
756
|
};
|
|
737
|
-
}, [
|
|
738
|
-
if (!
|
|
757
|
+
}, [b, o, U, Z]), oe(() => {
|
|
758
|
+
if (!b)
|
|
739
759
|
return;
|
|
740
|
-
|
|
741
|
-
const n =
|
|
760
|
+
U();
|
|
761
|
+
const n = B.current;
|
|
742
762
|
if (!n || typeof ResizeObserver > "u")
|
|
743
763
|
return;
|
|
744
|
-
const
|
|
745
|
-
return
|
|
746
|
-
}, [
|
|
747
|
-
const
|
|
748
|
-
var
|
|
749
|
-
|
|
750
|
-
},
|
|
751
|
-
|
|
752
|
-
},
|
|
753
|
-
|
|
754
|
-
const n =
|
|
764
|
+
const s = new ResizeObserver(() => U());
|
|
765
|
+
return s.observe(n), () => s.disconnect();
|
|
766
|
+
}, [b, U]);
|
|
767
|
+
const q = x(void 0), V = x(void 0), At = x(""), ne = (n) => {
|
|
768
|
+
var s;
|
|
769
|
+
j(n == null ? void 0 : n.id), (s = q.current) == null || s.call(q, (n == null ? void 0 : n.id) ?? At.current), R(!1), o && A(""), a == null || a(n == null ? void 0 : n.id), Z();
|
|
770
|
+
}, jt = () => {
|
|
771
|
+
R(!1), o && A(""), Z();
|
|
772
|
+
}, ie = () => {
|
|
773
|
+
et(!0);
|
|
774
|
+
const n = Wt(B.current)[0];
|
|
755
775
|
if (n) {
|
|
756
776
|
n.focus();
|
|
757
777
|
return;
|
|
758
778
|
}
|
|
759
|
-
|
|
760
|
-
},
|
|
761
|
-
return /* @__PURE__ */
|
|
762
|
-
|
|
779
|
+
ut(!0), R(!0);
|
|
780
|
+
}, ae = o && tt ? t.filter((n) => Oe(n, tt)) : t;
|
|
781
|
+
return /* @__PURE__ */ e(
|
|
782
|
+
de,
|
|
763
783
|
{
|
|
764
|
-
fullWidth:
|
|
765
|
-
label:
|
|
766
|
-
hint:
|
|
767
|
-
rightSideContent:
|
|
768
|
-
tooltip:
|
|
769
|
-
name:
|
|
770
|
-
required:
|
|
771
|
-
requiredIndicator:
|
|
772
|
-
loading:
|
|
773
|
-
formControl:
|
|
774
|
-
description:
|
|
775
|
-
controlId:
|
|
776
|
-
labelId:
|
|
777
|
-
descriptionId:
|
|
778
|
-
hintId:
|
|
779
|
-
loadingComponent: O === void 0 ? /* @__PURE__ */
|
|
780
|
-
|
|
784
|
+
fullWidth: wt,
|
|
785
|
+
label: p,
|
|
786
|
+
hint: T,
|
|
787
|
+
rightSideContent: L,
|
|
788
|
+
tooltip: C,
|
|
789
|
+
name: _,
|
|
790
|
+
required: y,
|
|
791
|
+
requiredIndicator: k,
|
|
792
|
+
loading: E,
|
|
793
|
+
formControl: P,
|
|
794
|
+
description: W,
|
|
795
|
+
controlId: ot,
|
|
796
|
+
labelId: H,
|
|
797
|
+
descriptionId: lt,
|
|
798
|
+
hintId: st,
|
|
799
|
+
loadingComponent: O === void 0 ? /* @__PURE__ */ e(
|
|
800
|
+
Ut,
|
|
781
801
|
{
|
|
782
|
-
heightClass:
|
|
802
|
+
heightClass: vt[$],
|
|
783
803
|
helperText: !!i,
|
|
784
804
|
helperTextMarginTop: !0
|
|
785
805
|
}
|
|
786
|
-
) : /* @__PURE__ */
|
|
787
|
-
|
|
806
|
+
) : /* @__PURE__ */ e("div", { style: qt(O), children: /* @__PURE__ */ e(
|
|
807
|
+
Ut,
|
|
788
808
|
{
|
|
789
|
-
heightClass:
|
|
809
|
+
heightClass: vt[$],
|
|
790
810
|
helperText: !!i,
|
|
791
811
|
helperTextMarginTop: !0
|
|
792
812
|
}
|
|
793
813
|
) }),
|
|
794
|
-
children: ({ error: n, message:
|
|
795
|
-
|
|
796
|
-
const
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
i ?
|
|
800
|
-
|
|
814
|
+
children: ({ error: n, message: s, onFieldChange: rt, onFieldBlur: pt, emptyValue: Ct }) => {
|
|
815
|
+
q.current = rt, V.current = pt, At.current = Ct;
|
|
816
|
+
const _t = S ?? n, X = S === !1 ? void 0 : s, M = `${ct}-error`, Y = [
|
|
817
|
+
lt,
|
|
818
|
+
st,
|
|
819
|
+
i ? ct : void 0,
|
|
820
|
+
X ? M : void 0
|
|
801
821
|
].filter(Boolean).join(" ") || void 0;
|
|
802
|
-
return /* @__PURE__ */
|
|
803
|
-
/* @__PURE__ */
|
|
822
|
+
return /* @__PURE__ */ m(bt, { children: [
|
|
823
|
+
/* @__PURE__ */ m(
|
|
804
824
|
"div",
|
|
805
825
|
{
|
|
806
|
-
ref:
|
|
826
|
+
ref: zt,
|
|
807
827
|
className: "relative w-full",
|
|
808
|
-
style:
|
|
809
|
-
onBlur: (
|
|
810
|
-
var
|
|
811
|
-
const
|
|
812
|
-
|
|
828
|
+
style: qt(O),
|
|
829
|
+
onBlur: (Q) => {
|
|
830
|
+
var ft, ht;
|
|
831
|
+
const kt = Q.relatedTarget;
|
|
832
|
+
Q.currentTarget.contains(kt) || ((ft = B.current) == null ? void 0 : ft.contains(kt)) === !0 || (ht = V.current) == null || ht.call(V);
|
|
813
833
|
},
|
|
814
834
|
children: [
|
|
815
|
-
|
|
835
|
+
dt && !o && /* @__PURE__ */ e(
|
|
816
836
|
"button",
|
|
817
837
|
{
|
|
818
838
|
type: "button",
|
|
819
|
-
onClick:
|
|
820
|
-
"aria-label":
|
|
821
|
-
className: `absolute ${
|
|
839
|
+
onClick: Ht,
|
|
840
|
+
"aria-label": g,
|
|
841
|
+
className: `absolute ${K ? Me[$] : "top-1/2 -translate-y-1/2"} z-10 flex items-center
|
|
822
842
|
justify-center rounded-full text-[var(--malachite-text-placeholder)]
|
|
823
843
|
hover:text-[var(--malachite-text-primary)] transition-colors
|
|
824
|
-
focus-visible:[outline:2px_solid_var(--malachite-text-primary)] focus-visible:outline-offset-2 ${
|
|
825
|
-
children: /* @__PURE__ */
|
|
844
|
+
focus-visible:[outline:2px_solid_var(--malachite-text-primary)] focus-visible:outline-offset-2 ${Ae[$]}`,
|
|
845
|
+
children: /* @__PURE__ */ e(Jt, { size: 13 })
|
|
826
846
|
}
|
|
827
847
|
),
|
|
828
|
-
/* @__PURE__ */
|
|
829
|
-
|
|
848
|
+
/* @__PURE__ */ e(
|
|
849
|
+
ee,
|
|
830
850
|
{
|
|
831
|
-
hasClear:
|
|
832
|
-
onClear:
|
|
833
|
-
clearLabel:
|
|
834
|
-
ref:
|
|
835
|
-
isOpen:
|
|
836
|
-
onClick: (
|
|
837
|
-
d || (
|
|
851
|
+
hasClear: dt,
|
|
852
|
+
onClear: Ht,
|
|
853
|
+
clearLabel: g,
|
|
854
|
+
ref: Et,
|
|
855
|
+
isOpen: b,
|
|
856
|
+
onClick: (Q) => {
|
|
857
|
+
d || (et(!!Q), R(!b));
|
|
838
858
|
},
|
|
839
|
-
selectedItem:
|
|
859
|
+
selectedItem: z,
|
|
840
860
|
disabled: d,
|
|
841
|
-
error:
|
|
842
|
-
tone:
|
|
843
|
-
placeholder:
|
|
861
|
+
error: _t,
|
|
862
|
+
tone: N,
|
|
863
|
+
placeholder: c,
|
|
844
864
|
search: o,
|
|
845
|
-
showSubtitleInTrigger:
|
|
846
|
-
searchQuery:
|
|
847
|
-
onSearchChange:
|
|
865
|
+
showSubtitleInTrigger: f,
|
|
866
|
+
searchQuery: tt,
|
|
867
|
+
onSearchChange: A,
|
|
848
868
|
onFocusOpen: () => {
|
|
849
|
-
if (!
|
|
850
|
-
|
|
869
|
+
if (!Nt.current) {
|
|
870
|
+
Nt.current = !0;
|
|
851
871
|
return;
|
|
852
872
|
}
|
|
853
|
-
|
|
873
|
+
R(!0);
|
|
854
874
|
},
|
|
855
875
|
onArrowDown: () => {
|
|
856
|
-
d ||
|
|
876
|
+
d || ie();
|
|
857
877
|
},
|
|
858
878
|
onTabAway: () => {
|
|
859
|
-
|
|
879
|
+
b && jt();
|
|
860
880
|
},
|
|
861
881
|
size: $,
|
|
862
|
-
controlId:
|
|
863
|
-
hasCallerId: !!
|
|
864
|
-
labelId:
|
|
865
|
-
describedBy:
|
|
866
|
-
required:
|
|
867
|
-
ariaLabel:
|
|
868
|
-
ariaLabelledBy:
|
|
882
|
+
controlId: ot,
|
|
883
|
+
hasCallerId: !!G,
|
|
884
|
+
labelId: H,
|
|
885
|
+
describedBy: Y,
|
|
886
|
+
required: y,
|
|
887
|
+
ariaLabel: St,
|
|
888
|
+
ariaLabelledBy: D
|
|
869
889
|
}
|
|
870
890
|
),
|
|
871
|
-
|
|
872
|
-
/* @__PURE__ */
|
|
873
|
-
|
|
891
|
+
b && ce(
|
|
892
|
+
/* @__PURE__ */ e(
|
|
893
|
+
re,
|
|
874
894
|
{
|
|
875
|
-
ref:
|
|
895
|
+
ref: B,
|
|
876
896
|
style: {
|
|
877
897
|
position: "fixed",
|
|
878
|
-
top: (
|
|
879
|
-
left: (
|
|
880
|
-
width:
|
|
881
|
-
maxHeight:
|
|
882
|
-
visibility:
|
|
883
|
-
opacity:
|
|
898
|
+
top: (h == null ? void 0 : h.top) ?? 0,
|
|
899
|
+
left: (h == null ? void 0 : h.left) ?? 0,
|
|
900
|
+
width: h == null ? void 0 : h.width,
|
|
901
|
+
maxHeight: h == null ? void 0 : h.maxHeight,
|
|
902
|
+
visibility: h ? "visible" : "hidden",
|
|
903
|
+
opacity: h ? 1 : 0
|
|
884
904
|
},
|
|
885
|
-
items:
|
|
886
|
-
onItemSelected:
|
|
887
|
-
selectedItem:
|
|
888
|
-
menuLoading:
|
|
889
|
-
emptyMessage:
|
|
890
|
-
subtitleLayout:
|
|
905
|
+
items: ae,
|
|
906
|
+
onItemSelected: ne,
|
|
907
|
+
selectedItem: z,
|
|
908
|
+
menuLoading: v,
|
|
909
|
+
emptyMessage: t.length === 0 ? "No options available" : "No results found",
|
|
910
|
+
subtitleLayout: w,
|
|
891
911
|
size: $,
|
|
892
|
-
autoFocus: !o ||
|
|
893
|
-
positioned:
|
|
894
|
-
onDismiss:
|
|
895
|
-
keyboardNavigation:
|
|
896
|
-
onKeyboardNavigation: () =>
|
|
912
|
+
autoFocus: !o || Dt,
|
|
913
|
+
positioned: h !== null,
|
|
914
|
+
onDismiss: jt,
|
|
915
|
+
keyboardNavigation: l,
|
|
916
|
+
onKeyboardNavigation: () => et(!0)
|
|
897
917
|
}
|
|
898
918
|
),
|
|
899
919
|
document.body
|
|
@@ -901,21 +921,21 @@ const cr = ({
|
|
|
901
921
|
]
|
|
902
922
|
}
|
|
903
923
|
),
|
|
904
|
-
i && /* @__PURE__ */
|
|
924
|
+
i && /* @__PURE__ */ e(
|
|
905
925
|
"div",
|
|
906
926
|
{
|
|
907
|
-
id:
|
|
927
|
+
id: ct,
|
|
908
928
|
className: "mt-1 text-[length:var(--malachite-font-size-small,13px)] text-left pl-2 text-[var(--malachite-text-dimmed,rgb(161,161,161))]",
|
|
909
929
|
children: i
|
|
910
930
|
}
|
|
911
931
|
),
|
|
912
|
-
/* @__PURE__ */
|
|
932
|
+
/* @__PURE__ */ e(pe, { id: M, message: X, spaced: !0 })
|
|
913
933
|
] });
|
|
914
934
|
}
|
|
915
935
|
}
|
|
916
936
|
);
|
|
917
937
|
};
|
|
918
938
|
export {
|
|
919
|
-
|
|
939
|
+
pr as Dropdown
|
|
920
940
|
};
|
|
921
941
|
//# sourceMappingURL=Dropdown.js.map
|