@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.
@@ -1,201 +1,214 @@
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,
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
- text: e,
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
- ) : e, Ke = {
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
- }, $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 = {
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
- }, _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 = {
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
- }, $t = {
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
- }, Ot = {
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
- }, Ze = () => !1, Dt = ({
69
- wrap: e,
77
+ }, Qt = () => !1, Pe = ({
78
+ wrap: t,
70
79
  id: a,
71
80
  children: r
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(
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: e,
83
+ isOpen: t,
75
84
  onClick: a,
76
85
  selectedItem: r,
77
- disabled: g = !1,
86
+ disabled: u = !1,
78
87
  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,
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: l,
102
+ labelId: c,
94
103
  describedBy: o,
95
- required: u = !1,
96
- ariaLabel: k,
97
- ariaLabelledBy: pe,
104
+ required: f = !1,
105
+ ariaLabel: w,
106
+ ariaLabelledBy: yt,
98
107
  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();
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
- 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);
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 (m && !g)
111
- return /* @__PURE__ */ v(
119
+ if (p && !u)
120
+ return /* @__PURE__ */ m(
112
121
  "div",
113
122
  {
114
- ref: fe,
123
+ ref: wt,
115
124
  className: `
116
- relative w-full ${te} ${re}
125
+ relative w-full ${it} ${at}
117
126
  border border-solid
118
127
  transition-all duration-200
119
- flex items-center ${yt}
128
+ flex items-center ${Ee}
120
129
  `,
121
- style: E,
122
- [Ie]: "",
123
- onClick: (s) => s.stopPropagation(),
130
+ style: z,
131
+ [Vt]: "",
132
+ onClick: (l) => l.stopPropagation(),
124
133
  children: [
125
- (r == null ? void 0 : r.icon) && /* @__PURE__ */ t("span", { className: "flex shrink-0 items-center justify-center pr-2", children: r.icon }),
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(
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__ */ t(
141
+ children: /* @__PURE__ */ e(
133
142
  "span",
134
143
  {
135
- ref: V,
144
+ ref: j,
136
145
  className: `min-w-0 block truncate text-[length:inherit]
137
146
  text-[var(--malachite-text-primary)]`,
138
- children: P
147
+ children: K
139
148
  }
140
149
  )
141
150
  }
142
151
  ),
143
- /* @__PURE__ */ t(
152
+ /* @__PURE__ */ e(
144
153
  "input",
145
154
  {
146
155
  id: i,
147
156
  type: "text",
148
- "aria-label": k,
149
- "aria-labelledby": pe,
157
+ "aria-label": w,
158
+ "aria-labelledby": yt,
150
159
  "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();
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
- w == null || w();
167
+ _ == null || _();
159
168
  },
160
- onKeyDown: ne,
161
- placeholder: C ?? "Select Field",
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)] ${N ? "text-transparent" : "text-[var(--malachite-text-primary)]"}`
173
+ placeholder:text-[var(--malachite-text-dimmed)] ${dt ? "text-transparent" : "text-[var(--malachite-text-primary)]"}`
165
174
  }
166
175
  )
167
176
  ] }) }),
168
- x && /* @__PURE__ */ t(
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": F,
173
- onClick: M,
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__ */ t(Be, { size: 13 })
191
+ children: /* @__PURE__ */ e(Jt, { size: 13 })
179
192
  }
180
193
  ),
181
- /* @__PURE__ */ t("div", { className: "flex items-center justify-center pl-2", children: /* @__PURE__ */ t(
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": e ? "Close options" : "Open options",
187
- onClick: (s) => {
188
- s.stopPropagation(), a();
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__ */ t(
192
- Ge,
204
+ children: /* @__PURE__ */ e(
205
+ Zt,
193
206
  {
194
207
  size: 13,
195
208
  style: {
196
- color: e ? "var(--malachite-text-primary, rgb(10, 10, 10))" : "var(--malachite-text-placeholder, rgb(187, 187, 187))",
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: e ? "rotate(180deg)" : "rotate(0deg)"
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 ie = /* @__PURE__ */ v(
220
+ const ut = /* @__PURE__ */ m(
208
221
  "button",
209
222
  {
210
- ref: fe,
223
+ ref: wt,
211
224
  id: i,
212
225
  type: "button",
213
- "aria-label": k,
214
- "aria-labelledby": me,
226
+ "aria-label": w,
227
+ "aria-labelledby": b,
215
228
  "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);
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: ne,
222
- disabled: g,
223
- style: E,
224
- [Ie]: "",
238
+ onKeyDown: Tt,
239
+ disabled: u,
240
+ style: z,
241
+ [Vt]: "",
225
242
  className: `
226
- relative w-full ${te} ${re}
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 ${wt}
248
+ disabled:cursor-not-allowed ${Ne}
232
249
  `,
233
250
  children: [
234
- /* @__PURE__ */ t(
251
+ /* @__PURE__ */ e(
235
252
  "span",
236
253
  {
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: [
241
- r.icon && /* @__PURE__ */ t("span", { className: "flex items-center justify-center shrink-0", children: r.icon }),
242
- /* @__PURE__ */ t(
243
- Ee,
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: P,
246
- shouldShow: p ? Ze : W,
247
- triggerAs: p ? "span" : "div",
262
+ text: K,
263
+ shouldShow: g ? Qt : I,
264
+ triggerAs: g ? "span" : "div",
248
265
  isShrinkable: !0,
249
- children: /* @__PURE__ */ t(
266
+ children: /* @__PURE__ */ e(
250
267
  "span",
251
268
  {
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
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
- p && /* @__PURE__ */ t(
277
+ g && /* @__PURE__ */ e(
261
278
  "span",
262
279
  {
263
- id: he,
264
- ref: X,
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__ */ t(de, { text: p })
283
+ children: /* @__PURE__ */ e(mt, { text: g })
267
284
  }
268
285
  )
269
- ] }) : /* @__PURE__ */ t(
286
+ ] }) : /* @__PURE__ */ e(
270
287
  "span",
271
288
  {
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"
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
- x && /* @__PURE__ */ t("span", { "aria-hidden": "true", className: "shrink-0 w-4" }),
279
- /* @__PURE__ */ t("span", { className: "flex items-center justify-center shrink-0", children: /* @__PURE__ */ t(
280
- Ge,
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: e ? "var(--malachite-text-primary, rgb(10, 10, 10))" : "var(--malachite-text-placeholder, rgb(187, 187, 187))",
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: e ? "rotate(180deg)" : "rotate(0deg)"
304
+ transform: t ? "rotate(180deg)" : "rotate(0deg)"
287
305
  }
288
306
  }
289
307
  ) })
290
308
  ]
291
309
  }
292
310
  );
293
- return y && !m ? /* @__PURE__ */ t(
294
- Ee,
311
+ return T && !p ? /* @__PURE__ */ e(
312
+ $t,
295
313
  {
296
- text: qe([
297
- ["value", D.value && P],
314
+ text: It([
315
+ ["value", tt.value && K],
298
316
  [
299
317
  "subtitle",
300
- D.subtitle && p && /* @__PURE__ */ t(de, { text: p })
318
+ tt.subtitle && g && /* @__PURE__ */ e(mt, { text: g })
301
319
  ]
302
320
  ]),
303
- shouldShow: p ? Ce : Ze,
321
+ shouldShow: g ? Dt : Qt,
304
322
  fill: !0,
305
323
  describesTrigger: !1,
306
- children: ie
324
+ children: ut
307
325
  }
308
- ) : ie;
326
+ ) : ut;
309
327
  }
310
328
  );
311
- Xe.displayName = "DropdownTrigger";
312
- const zt = ({
313
- item: e,
329
+ ee.displayName = "DropdownTrigger";
330
+ const Ge = ({
331
+ item: t,
314
332
  selected: a,
315
333
  showTooltipOnFocus: r,
316
- subtitleLayout: g,
334
+ subtitleLayout: u,
317
335
  onItemSelected: d
318
336
  }) => {
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 = (
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__ */ t(
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": e.subtitle ? y : void 0,
336
- "aria-describedby": e.subtitle ? _ : void 0,
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: (l) => {
339
- l.stopPropagation(), d(e);
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__ */ v(
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__ */ t("span", { style: { flex: "1 1 auto", display: "block", minWidth: 0 }, children: /* @__PURE__ */ v(
390
+ /* @__PURE__ */ e("span", { style: { flex: "1 1 auto", display: "block", minWidth: 0 }, children: /* @__PURE__ */ m(
370
391
  "span",
371
392
  {
372
- style: C ? { display: "flex", flexDirection: "column", gap: 2 } : { display: "flex", alignItems: "center", gap: 8 },
393
+ style: N ? { display: "flex", flexDirection: "column", gap: 2 } : { display: "flex", alignItems: "center", gap: 8 },
373
394
  children: [
374
- /* @__PURE__ */ v(At, { row: C && !!e.icon, children: [
375
- e.icon && /* @__PURE__ */ t(
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: e.icon
405
+ children: t.icon
385
406
  }
386
407
  ),
387
- /* @__PURE__ */ t(
408
+ /* @__PURE__ */ e(
388
409
  "span",
389
410
  {
390
- id: e.subtitle ? y : void 0,
391
- ref: R,
411
+ id: t.subtitle || Lt(t.badge) ? T : void 0,
412
+ ref: _,
392
413
  style: {
393
414
  fontWeight: 400,
394
- color: b,
415
+ color: S,
395
416
  whiteSpace: "nowrap",
396
417
  overflow: "hidden",
397
418
  textOverflow: "ellipsis",
398
419
  minWidth: 0
399
420
  },
400
- children: e.label
421
+ children: t.label
401
422
  }
402
423
  )
403
424
  ] }),
404
- e.subtitle && (C ? /* @__PURE__ */ t(
425
+ t.subtitle && (N ? /* @__PURE__ */ e(
405
426
  "span",
406
427
  {
407
- id: _,
408
- ref: w,
428
+ id: L,
429
+ ref: y,
409
430
  style: {
410
- fontSize: $e,
431
+ fontSize: Ft,
411
432
  fontWeight: 400,
412
433
  lineHeight: 1.4,
413
- color: a ? b : "var(--malachite-text-dimmed, rgb(161, 161, 161))",
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__ */ t(de, { text: e.subtitle })
439
+ children: /* @__PURE__ */ e(mt, { text: t.subtitle })
419
440
  }
420
- ) : /* @__PURE__ */ v(
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__ */ t(
455
+ /* @__PURE__ */ e(
435
456
  "span",
436
457
  {
437
458
  style: {
438
- fontSize: $e,
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__ */ t(
467
+ /* @__PURE__ */ e(
447
468
  "span",
448
469
  {
449
- id: _,
450
- ref: w,
470
+ id: L,
471
+ ref: y,
451
472
  style: {
452
- fontSize: $e,
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__ */ t(de, { text: e.subtitle })
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__ */ t(
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: e.rightSideText ? "var(--malachite-text-right-side-text-min-width, 80px)" : 0,
496
+ minWidth: t.rightSideText ? "var(--malachite-text-right-side-text-min-width, 80px)" : 0,
476
497
  flexShrink: 1,
477
498
  display: "flex",
478
- justifyContent: F
499
+ justifyContent: i
479
500
  },
480
- children: e.rightSideText && /* @__PURE__ */ t(
501
+ children: t.rightSideText && /* @__PURE__ */ e(
481
502
  "span",
482
503
  {
483
- ref: S,
504
+ ref: k,
484
505
  style: {
485
506
  fontSize: "var(--malachite-text-right-side-text-font-size, 12px)",
486
507
  fontWeight: 400,
487
- color: M,
508
+ color: W,
488
509
  whiteSpace: "nowrap",
489
510
  overflow: "hidden",
490
511
  textOverflow: "ellipsis",
491
512
  minWidth: 0
492
513
  },
493
- children: e.rightSideText
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__ */ t(
505
- Ee,
526
+ return /* @__PURE__ */ e(
527
+ $t,
506
528
  {
507
- text: qe([
508
- ["label", T.label && e.label],
529
+ text: It([
530
+ ["label", E.label && t.label],
509
531
  [
510
532
  "subtitle",
511
- T.subtitle && e.subtitle && /* @__PURE__ */ t(de, { text: e.subtitle })
533
+ E.subtitle && t.subtitle && /* @__PURE__ */ e(mt, { text: t.subtitle })
512
534
  ],
513
- ["rightSide", T.rightSide && e.rightSideText]
535
+ ["rightSide", E.rightSide && t.rightSideText]
514
536
  ]),
515
- shouldShow: x,
537
+ shouldShow: P,
516
538
  showOnFocus: r,
517
539
  isShrinkable: !0,
518
540
  describesTrigger: !1,
519
- children: i
541
+ children: c
520
542
  }
521
543
  );
522
- }, Ye = Ue.forwardRef((e, a) => {
544
+ }, re = Ot.forwardRef((t, a) => {
523
545
  const {
524
546
  items: r,
525
- onItemSelected: g,
547
+ onItemSelected: u,
526
548
  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(() => {
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 (!m || !y)
564
+ if (!p || !T)
543
565
  return;
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(
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
- x.current = i, typeof a == "function" ? a(i) : a && (a.current = i);
572
+ v.current = i, typeof a == "function" ? a(i) : a && (a.current = i);
551
573
  },
552
- ...M,
574
+ ...P,
553
575
  tabIndex: -1,
554
576
  onKeyDown: (i) => {
555
- var k;
577
+ var w;
556
578
  if (i.key === "Tab") {
557
- _();
579
+ L();
558
580
  return;
559
581
  }
560
- const l = De(x.current);
561
- if (l.length === 0)
582
+ const c = Wt(v.current);
583
+ if (c.length === 0)
562
584
  return;
563
- const o = l.indexOf(document.activeElement), u = {
585
+ const o = c.indexOf(document.activeElement), f = {
564
586
  ArrowDown: o + 1,
565
587
  ArrowUp: o - 1,
566
588
  Home: 0,
567
- End: l.length - 1
589
+ End: c.length - 1
568
590
  }[i.key];
569
- u !== void 0 && (i.preventDefault(), w(), (k = l[Math.min(Math.max(u, 0), l.length - 1)]) == null || k.focus());
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: se.standard.background,
573
- border: se.standard.border,
574
- borderRadius: se.standard.radius,
575
- boxShadow: se.standard.shadow,
576
- maxHeight: bt,
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: ft[T],
581
- ...L
602
+ fontSize: me[k],
603
+ ...E
582
604
  },
583
- children: b ? /* @__PURE__ */ v("div", { style: Ke, children: [
584
- /* @__PURE__ */ t(dt, { size: "xxxsmall" }),
585
- /* @__PURE__ */ t("span", { children: "Loading…" })
586
- ] }) : r.length === 0 ? /* @__PURE__ */ t("div", { style: Ke, children: C }) : /* @__PURE__ */ t(
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: se.standard.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, 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(
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__ */ t(
616
- zt,
637
+ /* @__PURE__ */ e(
638
+ Ge,
617
639
  {
618
640
  item: i,
619
- onItemSelected: g,
620
- subtitleLayout: S,
641
+ onItemSelected: u,
642
+ subtitleLayout: y,
621
643
  selected: i.id === (d == null ? void 0 : d.id) || !1,
622
- showTooltipOnFocus: R
644
+ showTooltipOnFocus: C
623
645
  }
624
646
  )
625
647
  ] }, i.id);
@@ -629,267 +651,269 @@ const zt = ({
629
651
  }
630
652
  );
631
653
  });
632
- Ye.displayName = "DropdownPanel";
633
- const ar = ({
634
- items: e,
654
+ re.displayName = "DropdownPanel";
655
+ const pr = ({
656
+ items: t,
635
657
  onItemSelected: a,
636
658
  defaultValue: r,
637
- value: g,
659
+ value: u,
638
660
  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,
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: l,
675
+ placeholder: c,
654
676
  search: o = !1,
655
- showSubtitleInTrigger: u = !1,
656
- subtitleLayout: k = "inline",
657
- clearable: pe = !1,
677
+ showSubtitleInTrigger: f = !1,
678
+ subtitleLayout: w = "inline",
679
+ clearable: yt = !1,
658
680
  size: $ = "large",
659
- fullWidth: fe = !1,
681
+ fullWidth: wt = !1,
660
682
  width: O,
661
- minWidth: te,
662
- id: re,
663
- "aria-label": q,
664
- "aria-labelledby": he
683
+ minWidth: it,
684
+ menuAlign: at = "start",
685
+ id: G,
686
+ "aria-label": St,
687
+ "aria-labelledby": D
665
688
  }) => {
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,
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
- }), [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));
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 [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())) {
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
- c.focus();
703
+ s.focus();
681
704
  return;
682
705
  }
683
- be.current = !1, c.focus(), Te() !== c && (be.current = !0);
706
+ Nt.current = !1, s.focus(), Rt() !== s && (Nt.current = !0);
684
707
  }
685
- }, [o]), Me = ke(
708
+ }, [o]), Ht = Mt(
686
709
  (n) => {
687
- var c;
688
- n.stopPropagation(), p(void 0), (c = I.current) == null || c.call(I, Le.current), a == null || a(void 0), H();
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, H]
691
- ), j = ke(() => {
692
- const n = ve.current;
693
- n && ze(
694
- mt(G.current, {
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: te,
720
+ minWidth: it,
721
+ align: at === "end" ? "right" : "left",
698
722
  viewportWidth: window.innerWidth,
699
723
  viewportHeight: window.innerHeight
700
724
  })
701
725
  );
702
- }, [te]);
703
- Oe(() => {
704
- if (!E) {
705
- ze(null), Ae(!1);
726
+ }, [it, at]);
727
+ Pt(() => {
728
+ if (!b) {
729
+ Gt(null), ut(!1);
706
730
  return;
707
731
  }
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("");
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 U = vt(A);
726
- U !== ye && (ye = U, j());
749
+ const Y = Se(M);
750
+ Y !== Ct && (Ct = Y, U());
727
751
  }
728
- ae = requestAnimationFrame(we);
752
+ pt = requestAnimationFrame(_t);
729
753
  };
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);
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
- }, [E, o, j, H]), nt(() => {
734
- if (!E)
757
+ }, [b, o, U, Z]), oe(() => {
758
+ if (!b)
735
759
  return;
736
- j();
737
- const n = G.current;
760
+ U();
761
+ const n = B.current;
738
762
  if (!n || typeof ResizeObserver > "u")
739
763
  return;
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];
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
- Ae(!0), N(!0);
756
- }, rt = o && Y ? e.filter((n) => Rt(n, Y)) : e;
757
- return /* @__PURE__ */ t(
758
- lt,
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: 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,
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: ue[$],
802
+ heightClass: vt[$],
779
803
  helperText: !!i,
780
804
  helperTextMarginTop: !0
781
805
  }
782
- ) : /* @__PURE__ */ t("div", { style: je(O), children: /* @__PURE__ */ t(
783
- He,
806
+ ) : /* @__PURE__ */ e("div", { style: qt(O), children: /* @__PURE__ */ e(
807
+ Ut,
784
808
  {
785
- heightClass: ue[$],
809
+ heightClass: vt[$],
786
810
  helperText: !!i,
787
811
  helperTextMarginTop: !0
788
812
  }
789
813
  ) }),
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
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__ */ v(Ne, { children: [
799
- /* @__PURE__ */ v(
822
+ return /* @__PURE__ */ m(bt, { children: [
823
+ /* @__PURE__ */ m(
800
824
  "div",
801
825
  {
802
- ref: _e,
826
+ ref: zt,
803
827
  className: "relative w-full",
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);
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
- xe && !o && /* @__PURE__ */ t(
835
+ dt && !o && /* @__PURE__ */ e(
812
836
  "button",
813
837
  {
814
838
  type: "button",
815
- onClick: Me,
816
- "aria-label": ie,
817
- className: `absolute ${Ce ? $t[$] : "top-1/2 -translate-y-1/2"} z-10 flex items-center
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 ${kt[$]}`,
821
- children: /* @__PURE__ */ t(Be, { size: 13 })
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__ */ t(
825
- Xe,
848
+ /* @__PURE__ */ e(
849
+ ee,
826
850
  {
827
- hasClear: xe,
828
- onClear: Me,
829
- clearLabel: ie,
830
- ref: ve,
831
- isOpen: E,
832
- onClick: (B) => {
833
- d || (Re(!!B), N(!E));
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: D,
859
+ selectedItem: z,
836
860
  disabled: d,
837
- error: we,
838
- tone: C,
839
- placeholder: l,
861
+ error: _t,
862
+ tone: N,
863
+ placeholder: c,
840
864
  search: o,
841
- showSubtitleInTrigger: u,
842
- searchQuery: Y,
843
- onSearchChange: Q,
865
+ showSubtitleInTrigger: f,
866
+ searchQuery: tt,
867
+ onSearchChange: A,
844
868
  onFocusOpen: () => {
845
- if (!be.current) {
846
- be.current = !0;
869
+ if (!Nt.current) {
870
+ Nt.current = !0;
847
871
  return;
848
872
  }
849
- N(!0);
873
+ R(!0);
850
874
  },
851
875
  onArrowDown: () => {
852
- d || tt();
876
+ d || ie();
853
877
  },
854
878
  onTabAway: () => {
855
- E && Fe();
879
+ b && jt();
856
880
  },
857
881
  size: $,
858
- controlId: ge,
859
- hasCallerId: !!re,
860
- labelId: me,
861
- describedBy: U,
862
- required: S,
863
- ariaLabel: q,
864
- ariaLabelledBy: he
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
- E && ot(
868
- /* @__PURE__ */ t(
869
- Ye,
891
+ b && ce(
892
+ /* @__PURE__ */ e(
893
+ re,
870
894
  {
871
- ref: G,
895
+ ref: B,
872
896
  style: {
873
897
  position: "fixed",
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
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: rt,
882
- onItemSelected: et,
883
- selectedItem: D,
884
- menuLoading: x,
885
- emptyMessage: e.length === 0 ? "No options available" : "No results found",
886
- subtitleLayout: k,
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 || Qe,
889
- positioned: f !== null,
890
- onDismiss: Fe,
891
- keyboardNavigation: Je,
892
- onKeyboardNavigation: () => Re(!0)
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__ */ t(
924
+ i && /* @__PURE__ */ e(
901
925
  "div",
902
926
  {
903
- id: X,
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__ */ t(ct, { id: A, message: Z, spaced: !0 })
932
+ /* @__PURE__ */ e(pe, { id: M, message: X, spaced: !0 })
909
933
  ] });
910
934
  }
911
935
  }
912
936
  );
913
937
  };
914
938
  export {
915
- ar as Dropdown
939
+ pr as Dropdown
916
940
  };
917
941
  //# sourceMappingURL=Dropdown.js.map