@stackone/malachite 2.49.0 → 2.49.2

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