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