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