@stackone/malachite 2.42.2 → 2.44.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,43 +1,45 @@
1
- import { jsx as r, jsxs as w, Fragment as dt } from "react/jsx-runtime";
2
- import ut, { useId as ft, useState as H, useRef as T, useMemo as D, useCallback as p, useEffect as Pe, useLayoutEffect as mt, useInsertionEffect as ht } from "react";
3
- import { createPortal as pt } from "react-dom";
4
- import gt, { useFormFieldIds as bt } from "./BaseFormComponent.js";
5
- import vt from "./CustomIcons/CaretDownIcon.js";
6
- import xt from "./CustomIcons/InfoFilledIcon.js";
7
- import yt from "./CustomIcons/SearchIcon.js";
8
- import Me from "./LoadingInput.js";
9
- import wt from "./Spinner.js";
10
- import { Tag as Et } from "./Tag.js";
11
- import We from "./Tooltip.js";
12
- import { CONTROL_TEXT_SIZE_CLASS as de, CONTROL_TEXT_SIZE as It } from "./controlTextSize.js";
13
- import { controlWidthStyle as $e } from "./controlWidth.js";
14
- import { getTriggerVisual as St, DROPDOWN_TRIGGER_ATTR as Tt } from "./dropdownTriggerStyle.js";
15
- import { pushEscapeLayer as kt } from "./escapeLayers.js";
16
- import { measureMenuGeometry as Lt, MENU_MAX_HEIGHT_PX as Rt, MENU_SPECS as K } from "./floatingMenuGeometry.js";
17
- import { ensureMultiSelectPanelStyles as Ot } from "./optionRowStyles.js";
18
- import { overlayIdentity as _t } from "./portalOverlay.js";
19
- import { useTopLayer as Nt } from "./topLayer.js";
20
- import { tooltipLines as Ct, isCut as At, isClamped as Dt } from "./truncatedLines.js";
21
- const Ht = {
1
+ import { jsx as r, jsxs as w, Fragment as ft } from "react/jsx-runtime";
2
+ import mt, { useId as pt, useState as P, useRef as T, useMemo as H, useCallback as m, useEffect as Me, useLayoutEffect as ht, useInsertionEffect as gt } from "react";
3
+ import { createPortal as bt } from "react-dom";
4
+ import vt, { useFormFieldIds as xt } from "./BaseFormComponent.js";
5
+ import yt from "./CustomIcons/CaretDownIcon.js";
6
+ import wt from "./CustomIcons/InfoFilledIcon.js";
7
+ import Et from "./CustomIcons/SearchIcon.js";
8
+ import We from "./LoadingInput.js";
9
+ import It from "./Spinner.js";
10
+ import { Tag as St } from "./Tag.js";
11
+ import $e from "./Tooltip.js";
12
+ import { getDeepActiveElement as Tt } from "./activeElement.js";
13
+ import { CONTROL_TEXT_SIZE_CLASS as ue, CONTROL_TEXT_SIZE as kt } from "./controlTextSize.js";
14
+ import { controlWidthStyle as Ge } from "./controlWidth.js";
15
+ import { getTriggerVisual as Rt, DROPDOWN_TRIGGER_ATTR as _t } from "./dropdownTriggerStyle.js";
16
+ import { pushEscapeLayer as Lt } from "./escapeLayers.js";
17
+ import { measureMenuGeometry as Ot, MENU_MAX_HEIGHT_PX as Nt, MENU_SPECS as B } from "./floatingMenuGeometry.js";
18
+ import { FOCUS_RING as Ct, FOCUS_RING_WITHIN_INPUT as At } from "./focusRing.js";
19
+ import { ensureMultiSelectPanelStyles as Dt } from "./optionRowStyles.js";
20
+ import { usePopupLayer as Ht } from "./overlayLayers.js";
21
+ import { useTopLayer as Pt } from "./topLayer.js";
22
+ import { tooltipLines as Mt, isCut as Wt, isClamped as $t } from "./truncatedLines.js";
23
+ const Gt = {
22
24
  padding: "8px 10px",
23
25
  color: "var(--malachite-text-secondary, rgb(123, 123, 123))"
24
- }, z = {
26
+ }, K = {
25
27
  small: "h-[var(--malachite-control-height-small,28px)]",
26
28
  medium: "h-[var(--malachite-control-height-medium,32px)]",
27
29
  large: "h-[var(--malachite-control-height-large,42px)]"
28
- }, Pt = {
29
- small: `${z.small} gap-[6px] px-2.5 ${de.small} rounded-[var(--malachite-radius-10,10px)]`,
30
- medium: `${z.medium} gap-[8px] px-3 ${de.medium} rounded-xl`,
31
- large: `${z.large} gap-[10px] px-4 ${de.large} rounded-[var(--malachite-radius-xxl,14px)]`
32
- }, Mt = 10, Ke = "ArrowDown", ze = "ArrowUp", Fe = "Enter", Wt = "Backspace", $t = /* @__PURE__ */ new Set([Ke, ze, Fe]), Ye = ut.forwardRef(
33
- ({ triggerRole: n, disabled: k, children: R, ...u }, g) => n !== "button" ? /* @__PURE__ */ r(
30
+ }, Ft = {
31
+ small: `${K.small} gap-[6px] px-2.5 ${ue.small} rounded-[var(--malachite-radius-10,10px)]`,
32
+ medium: `${K.medium} gap-[8px] px-3 ${ue.medium} rounded-xl`,
33
+ large: `${K.large} gap-[10px] px-4 ${ue.large} rounded-[var(--malachite-radius-xxl,14px)]`
34
+ }, Bt = 10, Ke = "ArrowDown", ze = "ArrowUp", Ue = "Enter", Kt = "Backspace", zt = /* @__PURE__ */ new Set([Ke, ze, Ue]), Ye = mt.forwardRef(
35
+ ({ triggerRole: n, disabled: k, children: _, ...u }, g) => n !== "button" ? /* @__PURE__ */ r(
34
36
  "div",
35
37
  {
36
38
  ref: g,
37
39
  role: n,
38
40
  tabIndex: k ? -1 : 0,
39
41
  ...u,
40
- children: R
42
+ children: _
41
43
  }
42
44
  ) : /* @__PURE__ */ r(
43
45
  "button",
@@ -46,25 +48,25 @@ const Ht = {
46
48
  type: "button",
47
49
  disabled: k,
48
50
  ...u,
49
- children: R
51
+ children: _
50
52
  }
51
53
  )
52
54
  );
53
55
  Ye.displayName = "TriggerElement";
54
- const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
55
- const k = T(null), R = T(null), u = n.description ? n.descriptionMode ?? "icon" : null, g = u === "subtitle", [_, Z] = H({ label: !0, subtitle: !0 }), N = () => {
56
- const E = At(k.current), m = Dt(R.current);
57
- return !E && !m && u !== "hover" ? !1 : (Z({ label: E, subtitle: m }), !0);
58
- }, P = u === "hover" || g && _.subtitle, M = (E) => /* @__PURE__ */ r(
59
- We,
56
+ const Fe = 0.6, Be = 420, Ut = ({ option: n }) => {
57
+ const k = T(null), _ = T(null), u = n.description ? n.descriptionMode ?? "icon" : null, g = u === "subtitle", [N, Z] = P({ label: !0, subtitle: !0 }), C = () => {
58
+ const E = Wt(k.current), p = $t(_.current);
59
+ return !E && !p && u !== "hover" ? !1 : (Z({ label: E, subtitle: p }), !0);
60
+ }, M = u === "hover" || g && N.subtitle, W = (E) => /* @__PURE__ */ r(
61
+ $e,
60
62
  {
61
- text: Ct([
62
- ["label", _.label && n.label],
63
- ["description", P && n.description]
63
+ text: Mt([
64
+ ["label", N.label && n.label],
65
+ ["description", M && n.description]
64
66
  ]),
65
- shouldShow: N,
66
- delay: Be,
67
- maxWidth: Ge,
67
+ shouldShow: C,
68
+ delay: Fe,
69
+ maxWidth: Be,
68
70
  triggerAs: "span",
69
71
  isShrinkable: !0,
70
72
  describesTrigger: u === "hover",
@@ -83,7 +85,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
83
85
  children: n.label
84
86
  }
85
87
  );
86
- return g ? M(
88
+ return g ? W(
87
89
  /* @__PURE__ */ w(
88
90
  "span",
89
91
  {
@@ -100,7 +102,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
100
102
  /* @__PURE__ */ r(
101
103
  "span",
102
104
  {
103
- ref: R,
105
+ ref: _,
104
106
  style: {
105
107
  fontSize: 12,
106
108
  color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
@@ -130,13 +132,13 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
130
132
  gap: 6
131
133
  },
132
134
  children: [
133
- M(b),
135
+ W(b),
134
136
  u === "icon" && /* @__PURE__ */ r(
135
- We,
137
+ $e,
136
138
  {
137
139
  text: n.description,
138
- delay: Be,
139
- maxWidth: Ge,
140
+ delay: Fe,
141
+ maxWidth: Be,
140
142
  children: /* @__PURE__ */ r(
141
143
  "span",
142
144
  {
@@ -146,7 +148,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
146
148
  },
147
149
  "aria-label": "More information",
148
150
  onClick: (E) => E.stopPropagation(),
149
- children: n.descriptionIcon ?? /* @__PURE__ */ r(xt, { size: 14 })
151
+ children: n.descriptionIcon ?? /* @__PURE__ */ r(wt, { size: 14 })
150
152
  }
151
153
  )
152
154
  }
@@ -154,169 +156,172 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
154
156
  ]
155
157
  }
156
158
  );
157
- }, sr = ({
159
+ }, pr = ({
158
160
  options: n,
159
161
  value: k,
160
- defaultValue: R,
162
+ defaultValue: _,
161
163
  onChange: u,
162
164
  placeholder: g = "Select",
163
- renderTrigger: _,
165
+ renderTrigger: N,
164
166
  searchable: Z,
165
- size: N = "large",
166
- width: P = "auto",
167
- minWidth: M,
167
+ size: C = "large",
168
+ width: M = "auto",
169
+ minWidth: W,
168
170
  disabled: b = !1,
169
171
  error: E = !1,
170
- loading: m = !1,
171
- label: F,
172
- name: ue,
172
+ loading: p = !1,
173
+ label: z,
174
+ name: fe,
173
175
  description: q,
174
- tooltip: fe,
176
+ tooltip: me,
175
177
  hint: J,
176
- rightSideContent: me,
178
+ rightSideContent: pe,
177
179
  required: Q = !1,
178
- requiredIndicator: Ue,
180
+ requiredIndicator: Ve,
179
181
  formControl: he,
180
182
  chips: ee = !1,
181
183
  chipsRemovable: te = !0,
182
- chipsMax: pe = "auto",
184
+ chipsMax: ge = "auto",
183
185
  inlineSearch: v = !1,
184
- onSearchChange: W,
185
- localFilter: ge = !0,
186
- className: Ve = "",
187
- style: Xe,
188
- id: je,
189
- "aria-label": be,
190
- "aria-labelledby": Ze
186
+ onSearchChange: $,
187
+ localFilter: be = !0,
188
+ className: Xe = "",
189
+ style: je,
190
+ id: Ze,
191
+ "aria-label": ve,
192
+ "aria-labelledby": qe
191
193
  }) => {
192
- const ve = ft(), xe = `${ve}-listbox`, ye = (e) => `${ve}-option-${e}`, { controlId: we, labelId: Ee, descriptionId: qe, hintId: Je, describedBy: Qe } = bt({
193
- id: je,
194
- label: F,
194
+ const xe = pt(), ye = `${xe}-listbox`, we = (e) => `${xe}-option-${e}`, { controlId: Ee, labelId: Ie, descriptionId: Je, hintId: Qe, describedBy: et } = xt({
195
+ id: Ze,
196
+ label: z,
195
197
  description: q,
196
198
  hint: J
197
- }), [et, tt] = H(() => R ?? []), re = k !== void 0, f = re ? k : et, [o, Y] = H(!1), [c, Ie] = H(null), [L, rt] = H(""), [x, C] = H(-1), ne = T(null), $ = T(null), B = T(null), Se = T(null);
198
- Nt(B, o);
199
- const Te = T([]), ae = D(() => new Set(f), [f]), s = D(
199
+ }), [tt, rt] = P(() => _ ?? []), re = k !== void 0, f = re ? k : tt, [o, ne] = P(!1), [c, Se] = P(null), [R, nt] = P(""), [x, A] = P(-1), U = T(null), G = T(null), L = T(null), Te = T(null);
200
+ Pt(L, o);
201
+ const at = Ht("multiselect", o, L), ke = T([]), ae = H(() => new Set(f), [f]), s = H(
200
202
  () => n.filter((e) => ae.has(e.value)),
201
203
  [n, ae]
202
- ), le = typeof pe == "number" ? pe : void 0, O = D(() => {
203
- if (!ge) return n;
204
- const e = L.trim().toLowerCase();
204
+ ), le = typeof ge == "number" ? ge : void 0, O = H(() => {
205
+ if (!be) return n;
206
+ const e = R.trim().toLowerCase();
205
207
  return e ? n.filter((t) => (t.searchText ?? (typeof t.label == "string" ? t.label : "")).toLowerCase().includes(e)) : n;
206
- }, [n, L, ge]), oe = T(!1), ke = T(""), U = p(
208
+ }, [n, R, be]), oe = T(!1), Re = T(""), Y = m(
207
209
  (e, t) => {
208
- ke.current !== e && (ke.current = e, t && (oe.current = !0), rt(e), W == null || W(e));
210
+ Re.current !== e && (Re.current = e, t && (oe.current = !0), nt(e), $ == null || $(e));
209
211
  },
210
- [W]
211
- ), se = p(
212
- (e) => U(e, !0),
213
- [U]
214
- ), G = p(() => U("", !1), [U]);
215
- Pe(() => {
216
- oe.current && (C(-1), oe.current = !1);
217
- }, [L]);
218
- const nt = Z ?? (W !== void 0 || n.length > Mt), Le = v ? !1 : nt, A = p(() => {
219
- const e = ne.current;
212
+ [$]
213
+ ), se = m(
214
+ (e) => Y(e, !0),
215
+ [Y]
216
+ ), F = m(() => Y("", !1), [Y]);
217
+ Me(() => {
218
+ oe.current && (A(-1), oe.current = !1);
219
+ }, [R]);
220
+ const lt = Z ?? ($ !== void 0 || n.length > Bt), _e = v ? !1 : lt, ie = m(() => {
221
+ var e, t;
222
+ ne(!1), (e = L.current) != null && e.contains(Tt()) && ((t = U.current) == null || t.focus());
223
+ }, []), D = m(() => {
224
+ const e = U.current;
220
225
  if (!e) return;
221
- const t = Lt(B.current, {
226
+ const t = Ot(L.current, {
222
227
  triggerRect: e.getBoundingClientRect(),
223
228
  preset: "standard",
224
- minWidth: M,
229
+ minWidth: W,
225
230
  viewportWidth: window.innerWidth,
226
231
  viewportHeight: window.innerHeight
227
232
  });
228
- Ie(t);
229
- }, [M]);
230
- Pe(() => {
233
+ Se(t);
234
+ }, [W]);
235
+ Me(() => {
231
236
  var S;
232
237
  if (!o) {
233
- G(), C(-1), Ie(null);
238
+ F(), A(-1), Se(null);
234
239
  return;
235
240
  }
236
- A(), v && ((S = $.current) == null || S.focus());
237
- const e = () => A(), t = (y) => {
238
- const d = y.composedPath(), a = ne.current, i = B.current;
239
- (!a || !d.includes(a)) && (!i || !d.includes(i)) && Y(!1);
240
- }, l = kt(() => Y(!1));
241
+ D(), v && ((S = G.current) == null || S.focus());
242
+ const e = () => D(), t = (y) => {
243
+ const d = y.composedPath(), a = U.current, i = L.current;
244
+ (!a || !d.includes(a)) && (!i || !d.includes(i)) && ie();
245
+ }, l = Lt(ie);
241
246
  return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), document.addEventListener("mousedown", t), () => {
242
247
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e), document.removeEventListener("mousedown", t), l();
243
248
  };
244
- }, [o, A, v, G]), mt(() => {
249
+ }, [o, D, v, F, ie]), ht(() => {
245
250
  if (!o)
246
251
  return;
247
- A();
248
- const e = B.current;
252
+ D();
253
+ const e = L.current;
249
254
  if (!e || typeof ResizeObserver > "u")
250
255
  return;
251
- const t = new ResizeObserver(() => A());
256
+ const t = new ResizeObserver(() => D());
252
257
  return t.observe(e), () => t.disconnect();
253
- }, [o, A]);
254
- const I = p(
258
+ }, [o, D]);
259
+ const I = m(
255
260
  (e) => {
256
- re || tt(e), u == null || u(e);
261
+ re || rt(e), u == null || u(e);
257
262
  },
258
263
  [re, u]
259
- ), V = p(
264
+ ), V = m(
260
265
  (e) => n.some((t) => t.value === e && t.disabled),
261
266
  [n]
262
- ), ie = p(
267
+ ), ce = m(
263
268
  (e) => {
264
269
  V(e) || (f.includes(e) ? I(f.filter((t) => t !== e)) : I([...f, e]));
265
270
  },
266
271
  [f, I, V]
267
- ), X = D(() => {
272
+ ), X = H(() => {
268
273
  const e = /* @__PURE__ */ new Set();
269
274
  for (const t of n)
270
275
  t.disabled && e.add(t.value);
271
276
  return e;
272
- }, [n]), at = p(
277
+ }, [n]), ot = m(
273
278
  (e) => {
274
279
  e.stopPropagation();
275
280
  const t = f.filter((l) => X.has(l));
276
281
  I(t);
277
282
  },
278
283
  [I, f, X]
279
- ), Re = p(
284
+ ), Le = m(
280
285
  (e, t) => {
281
286
  t.stopPropagation(), !V(e) && I(f.filter((l) => l !== e));
282
287
  },
283
288
  [f, I, V]
284
- ), j = p(
289
+ ), j = m(
285
290
  (e) => {
286
- if (!$t.has(e.key)) return;
291
+ if (!zt.has(e.key)) return;
287
292
  if (e.preventDefault(), e.stopPropagation(), !o) {
288
- Y(!0);
293
+ ne(!0);
289
294
  return;
290
295
  }
291
296
  const t = O.length;
292
297
  if (t === 0) return;
293
298
  const l = (d) => {
294
299
  requestAnimationFrame(() => {
295
- const a = Te.current[d], i = Se.current;
300
+ const a = ke.current[d], i = Te.current;
296
301
  if (!a || !i) return;
297
- const h = a.offsetTop, De = h + a.offsetHeight, He = i.scrollTop, ct = He + i.clientHeight;
298
- De > ct ? i.scrollTo({
299
- top: De - i.clientHeight,
302
+ const h = a.offsetTop, He = h + a.offsetHeight, Pe = i.scrollTop, ut = Pe + i.clientHeight;
303
+ He > ut ? i.scrollTo({
304
+ top: He - i.clientHeight,
300
305
  behavior: "smooth"
301
- }) : h < He && i.scrollTo({ top: h, behavior: "smooth" });
306
+ }) : h < Pe && i.scrollTo({ top: h, behavior: "smooth" });
302
307
  });
303
308
  }, S = (d) => {
304
309
  var i;
305
310
  let a = x;
306
311
  for (let h = 0; h < t; h++)
307
312
  if (a = d === 1 ? a < t - 1 ? a + 1 : 0 : a > 0 ? a - 1 : t - 1, !((i = O[a]) != null && i.disabled)) {
308
- l(a), C(a);
313
+ l(a), A(a);
309
314
  return;
310
315
  }
311
316
  }, y = () => {
312
317
  var i;
313
318
  if (x < 0 || x >= t || (i = O[x]) != null && i.disabled) return;
314
319
  const d = O[x].value;
315
- ie(d), G();
320
+ ce(d), F();
316
321
  const a = n.findIndex((h) => h.value === d);
317
- C(a >= 0 ? a : -1), l(a >= 0 ? a : 0), requestAnimationFrame(() => {
322
+ A(a >= 0 ? a : -1), l(a >= 0 ? a : 0), requestAnimationFrame(() => {
318
323
  var h;
319
- return (h = $.current) == null ? void 0 : h.focus();
324
+ return (h = G.current) == null ? void 0 : h.focus();
320
325
  });
321
326
  };
322
327
  switch (e.key) {
@@ -326,36 +331,36 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
326
331
  case ze:
327
332
  S(-1);
328
333
  break;
329
- case Fe:
334
+ case Ue:
330
335
  y();
331
336
  break;
332
337
  }
333
338
  },
334
- [o, O, x, ie, n, G]
335
- ), Oe = p(
339
+ [o, O, x, ce, n, F]
340
+ ), Oe = m(
336
341
  (e) => {
337
- if (e.key === Wt && L === "" && f.length > 0) {
342
+ if (e.key === Kt && R === "" && f.length > 0) {
338
343
  e.preventDefault(), I(f.slice(0, -1)), requestAnimationFrame(() => {
339
344
  var t;
340
- return (t = $.current) == null ? void 0 : t.focus();
345
+ return (t = G.current) == null ? void 0 : t.focus();
341
346
  });
342
347
  return;
343
348
  }
344
349
  j(e);
345
350
  },
346
- [j, L, f, I]
347
- ), _e = s.length > 0 && !b && !m, lt = St({
351
+ [j, R, f, I]
352
+ ), Ne = s.length > 0 && !b && !p, st = Rt({
348
353
  disabled: b,
349
354
  error: E,
350
355
  open: o,
351
- loading: m,
356
+ loading: p,
352
357
  hasSelection: s.length > 0
353
- }), ce = D(() => v ? /* @__PURE__ */ r(
358
+ }), de = H(() => v ? /* @__PURE__ */ r(
354
359
  "input",
355
360
  {
356
- ref: $,
361
+ ref: G,
357
362
  type: "text",
358
- value: L,
363
+ value: R,
359
364
  onChange: (e) => se(e.target.value),
360
365
  onKeyDown: Oe,
361
366
  placeholder: s.length === 0 ? g : "",
@@ -366,14 +371,14 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
366
371
  }
367
372
  ) : null, [
368
373
  v,
369
- L,
374
+ R,
370
375
  se,
371
376
  Oe,
372
377
  s.length,
373
378
  g
374
- ]), ot = D(() => {
375
- if (_ && s.length > 0)
376
- return _(s);
379
+ ]), it = H(() => {
380
+ if (N && s.length > 0)
381
+ return N(s);
377
382
  if (ee && s.length > 0) {
378
383
  const e = le != null ? s.slice(0, le) : s, t = s.length - e.length;
379
384
  return /* @__PURE__ */ w(
@@ -385,12 +390,12 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
385
390
  e.map((l) => {
386
391
  const S = X.has(l.value);
387
392
  return /* @__PURE__ */ r(
388
- Et,
393
+ St,
389
394
  {
390
395
  value: l.label,
391
396
  type: "default",
392
397
  textTransform: "none",
393
- onRemove: te && !b && !S ? (y) => Re(l.value, y) : void 0,
398
+ onRemove: te && !b && !S ? (y) => Le(l.value, y) : void 0,
394
399
  className: "shrink-0"
395
400
  },
396
401
  l.value
@@ -400,85 +405,85 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
400
405
  "+",
401
406
  t
402
407
  ] }),
403
- ce
408
+ de
404
409
  ]
405
410
  }
406
411
  );
407
412
  }
408
- return v && s.length === 0 ? ce : s.length === 0 ? /* @__PURE__ */ r("span", { className: "text-[var(--malachite-text-placeholder)]", children: g }) : s.length === 1 ? /* @__PURE__ */ r("span", { children: s[0].label }) : /* @__PURE__ */ r("span", { children: `${s.length} selected` });
413
+ return v && s.length === 0 ? de : s.length === 0 ? /* @__PURE__ */ r("span", { className: "text-[var(--malachite-text-placeholder)]", children: g }) : s.length === 1 ? /* @__PURE__ */ r("span", { children: s[0].label }) : /* @__PURE__ */ r("span", { children: `${s.length} selected` });
409
414
  }, [
410
415
  s,
411
- _,
416
+ N,
412
417
  ee,
413
418
  le,
414
419
  te,
415
420
  b,
416
- Re,
421
+ Le,
417
422
  v,
418
- ce,
423
+ de,
419
424
  g,
420
425
  X
421
- ]), st = n.length === 0 ? "No options available" : "No results found";
422
- ht(() => {
423
- o && Ot();
426
+ ]), ct = n.length === 0 ? "No options available" : "No results found";
427
+ gt(() => {
428
+ o && Dt();
424
429
  }, [o]);
425
- const it = {
430
+ const dt = {
426
431
  position: "fixed",
427
432
  top: (c == null ? void 0 : c.top) ?? 0,
428
433
  left: (c == null ? void 0 : c.left) ?? 0,
429
434
  width: c == null ? void 0 : c.width,
430
- background: K.standard.background,
431
- border: K.standard.border,
432
- borderRadius: K.standard.radius,
433
- boxShadow: K.standard.shadow,
434
- padding: K.standard.padding,
435
+ background: B.standard.background,
436
+ border: B.standard.border,
437
+ borderRadius: B.standard.radius,
438
+ boxShadow: B.standard.shadow,
439
+ padding: B.standard.padding,
435
440
  display: "flex",
436
441
  flexDirection: "column",
437
442
  gap: 4,
438
- maxHeight: (c == null ? void 0 : c.maxHeight) ?? Rt,
439
- fontSize: It[N],
443
+ maxHeight: (c == null ? void 0 : c.maxHeight) ?? Nt,
444
+ fontSize: kt[C],
440
445
  visibility: c ? "visible" : "hidden",
441
446
  opacity: c ? 1 : 0
442
- }, Ne = !!(q || fe || J || me || ue || he || Q), Ce = Ne && !!F, Ae = /* @__PURE__ */ w(dt, { children: [
443
- /* @__PURE__ */ w("div", { className: "relative", style: $e(P), children: [
447
+ }, Ce = !!(q || me || J || pe || fe || he || Q), Ae = Ce && !!z, De = /* @__PURE__ */ w(ft, { children: [
448
+ /* @__PURE__ */ w("div", { className: "relative", style: Ge(M), children: [
444
449
  /* @__PURE__ */ w(
445
450
  Ye,
446
451
  {
447
- ref: ne,
448
- id: we,
452
+ ref: U,
453
+ id: Ee,
449
454
  triggerRole: v ? "combobox" : ee && te ? "group" : "button",
450
- disabled: b || m,
451
- [Tt]: "",
455
+ disabled: b || p,
456
+ [_t]: "",
452
457
  "aria-haspopup": "listbox",
453
458
  "aria-expanded": o,
454
- "aria-controls": o ? xe : void 0,
455
- "aria-activedescendant": v && o && x >= 0 ? ye(x) : void 0,
456
- "aria-labelledby": Ze ?? (Ce && !be ? Ee : void 0),
457
- "aria-label": be ?? (Ce ? void 0 : F),
459
+ "aria-controls": o ? ye : void 0,
460
+ "aria-activedescendant": v && o && x >= 0 ? we(x) : void 0,
461
+ "aria-labelledby": qe ?? (Ae && !ve ? Ie : void 0),
462
+ "aria-label": ve ?? (Ae ? void 0 : z),
458
463
  "aria-invalid": E || void 0,
459
464
  "aria-required": Q || void 0,
460
- "aria-describedby": Qe,
461
- "aria-busy": m || void 0,
465
+ "aria-describedby": et,
466
+ "aria-busy": p || void 0,
462
467
  onClick: () => {
463
- b || m || Y((e) => !e);
468
+ b || p || ne((e) => !e);
464
469
  },
465
470
  onKeyDown: j,
466
471
  style: {
467
472
  transition: "border-color 0.15s ease, box-shadow 0.15s ease",
468
- ...lt,
469
- ...Xe
473
+ ...st,
474
+ ...je
470
475
  },
471
- className: `w-full ${Pt[N]} border border-solid flex items-center font-normal text-[var(--malachite-text-primary)] ${b || m ? "cursor-not-allowed" : "cursor-pointer"} ${Ve}`,
476
+ className: `w-full ${Ft[C]} border border-solid flex items-center font-normal text-[var(--malachite-text-primary)] ${b || p ? "cursor-not-allowed" : "cursor-pointer"} ${Ct} ${At} ${Xe}`,
472
477
  children: [
473
478
  /* @__PURE__ */ r(
474
479
  "span",
475
480
  {
476
- className: `flex-1 min-w-0 text-left ${v ? "flex" : "truncate"} ${_e ? "pr-[18px]" : ""}`,
477
- children: ot
481
+ className: `flex-1 min-w-0 text-left ${v ? "flex" : "truncate"} ${Ne ? "pr-[18px]" : ""}`,
482
+ children: it
478
483
  }
479
484
  ),
480
- m ? /* @__PURE__ */ r("span", { className: "flex items-center justify-center shrink-0 size-[14px]", children: /* @__PURE__ */ r(wt, { size: "xxxsmall" }) }) : /* @__PURE__ */ r(
481
- vt,
485
+ p ? /* @__PURE__ */ r("span", { className: "flex items-center justify-center shrink-0 size-[14px]", children: /* @__PURE__ */ r(It, { size: "xxxsmall" }) }) : /* @__PURE__ */ r(
486
+ yt,
482
487
  {
483
488
  size: 13,
484
489
  className: "shrink-0",
@@ -492,29 +497,29 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
492
497
  ]
493
498
  }
494
499
  ),
495
- _e && /* @__PURE__ */ r(
500
+ Ne && /* @__PURE__ */ r(
496
501
  "button",
497
502
  {
498
503
  type: "button",
499
504
  "aria-label": "Clear selection",
500
- onClick: at,
505
+ onClick: ot,
501
506
  className: "absolute top-0 bottom-0 right-[28px] flex items-center justify-center px-[2px] leading-none bg-transparent border-none text-[var(--malachite-text-placeholder)] hover:text-[var(--malachite-text-primary)] cursor-pointer",
502
507
  children: "×"
503
508
  }
504
509
  )
505
510
  ] }),
506
- o && pt(
511
+ o && bt(
507
512
  /* @__PURE__ */ w(
508
513
  "div",
509
514
  {
510
- ref: B,
511
- id: xe,
515
+ ref: L,
516
+ id: ye,
512
517
  role: "listbox",
513
518
  "aria-multiselectable": "true",
514
- ..._t("multiselect"),
515
- style: it,
519
+ ...at,
520
+ style: dt,
516
521
  children: [
517
- Le && /* @__PURE__ */ w(
522
+ _e && /* @__PURE__ */ w(
518
523
  "div",
519
524
  {
520
525
  style: {
@@ -529,7 +534,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
529
534
  },
530
535
  children: [
531
536
  /* @__PURE__ */ r(
532
- yt,
537
+ Et,
533
538
  {
534
539
  size: 13,
535
540
  style: {
@@ -542,7 +547,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
542
547
  "input",
543
548
  {
544
549
  type: "text",
545
- value: L,
550
+ value: R,
546
551
  onChange: (e) => se(e.target.value),
547
552
  onKeyDown: j,
548
553
  placeholder: "Search",
@@ -562,7 +567,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
562
567
  ]
563
568
  }
564
569
  ),
565
- Le && /* @__PURE__ */ r(
570
+ _e && /* @__PURE__ */ r(
566
571
  "div",
567
572
  {
568
573
  "aria-hidden": "true",
@@ -577,7 +582,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
577
582
  /* @__PURE__ */ r(
578
583
  "div",
579
584
  {
580
- ref: Se,
585
+ ref: Te,
581
586
  style: {
582
587
  display: "flex",
583
588
  flexDirection: "column",
@@ -591,15 +596,15 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
591
596
  },
592
597
  children: O.length === 0 ? (
593
598
  // `role="listbox"` admits only option/group children.
594
- /* @__PURE__ */ r("div", { role: "presentation", style: Ht, children: st })
599
+ /* @__PURE__ */ r("div", { role: "presentation", style: Gt, children: ct })
595
600
  ) : O.map((e, t) => {
596
601
  const l = ae.has(e.value), S = t === x, y = !!e.disabled;
597
602
  return /* @__PURE__ */ w(
598
603
  "button",
599
604
  {
600
- id: ye(t),
605
+ id: we(t),
601
606
  ref: (d) => {
602
- Te.current[t] = d;
607
+ ke.current[t] = d;
603
608
  },
604
609
  type: "button",
605
610
  role: "option",
@@ -607,11 +612,11 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
607
612
  "aria-disabled": y || void 0,
608
613
  onClick: () => {
609
614
  var d;
610
- ie(e.value), G(), (d = $.current) == null || d.focus();
615
+ ce(e.value), F(), (d = G.current) == null || d.focus();
611
616
  },
612
- onMouseEnter: () => C(t),
617
+ onMouseEnter: () => A(t),
613
618
  onMouseLeave: () => {
614
- x === t && C(-1);
619
+ x === t && A(-1);
615
620
  },
616
621
  className: "malachite-multiselect-option",
617
622
  "data-checked": l,
@@ -633,7 +638,7 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
633
638
  color: l ? "var(--malachite-accent-foreground, rgb(2, 122, 66))" : "var(--malachite-text-primary, rgb(10, 10, 10))"
634
639
  },
635
640
  children: [
636
- /* @__PURE__ */ r(Bt, { option: e }),
641
+ /* @__PURE__ */ r(Ut, { option: e }),
637
642
  e.badge && /* @__PURE__ */ r(
638
643
  "span",
639
644
  {
@@ -658,29 +663,29 @@ const Be = 0.6, Ge = 420, Bt = ({ option: n }) => {
658
663
  document.body
659
664
  )
660
665
  ] });
661
- return Ne ? /* @__PURE__ */ r(
662
- gt,
666
+ return Ce ? /* @__PURE__ */ r(
667
+ vt,
663
668
  {
664
- label: F,
669
+ label: z,
665
670
  hint: J,
666
- rightSideContent: me,
667
- tooltip: fe,
668
- name: ue ?? "",
671
+ rightSideContent: pe,
672
+ tooltip: me,
673
+ name: fe ?? "",
669
674
  required: Q,
670
- requiredIndicator: Ue,
671
- loading: m,
675
+ requiredIndicator: Ve,
676
+ loading: p,
672
677
  formControl: he,
673
678
  description: q,
674
- controlId: we,
675
- labelId: Ee,
676
- descriptionId: qe,
677
- hintId: Je,
678
- loadingComponent: P === void 0 ? /* @__PURE__ */ r(Me, { heightClass: z[N] }) : /* @__PURE__ */ r("div", { style: $e(P), children: /* @__PURE__ */ r(Me, { heightClass: z[N] }) }),
679
- children: Ae
679
+ controlId: Ee,
680
+ labelId: Ie,
681
+ descriptionId: Je,
682
+ hintId: Qe,
683
+ loadingComponent: M === void 0 ? /* @__PURE__ */ r(We, { heightClass: K[C] }) : /* @__PURE__ */ r("div", { style: Ge(M), children: /* @__PURE__ */ r(We, { heightClass: K[C] }) }),
684
+ children: De
680
685
  }
681
- ) : Ae;
686
+ ) : De;
682
687
  };
683
688
  export {
684
- sr as default
689
+ pr as default
685
690
  };
686
691
  //# sourceMappingURL=MultiSelect.js.map