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