@stackone/malachite 2.42.1 → 2.43.0

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