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