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