asma-ui-core 3.47.0 → 3.47.1

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,92 +1,100 @@
1
- import { cn as P } from "../../../helpers/cn.js";
2
- import { ChevronDownIcon as Ue } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
1
+ import { cn as $ } from "../../../helpers/cn.js";
2
+ import { ChevronDownIcon as Ve } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
3
3
  import { CloseIcon as He } from "../../icons/close-icon/CloseIcon.js";
4
4
  import { CheckIcon as Te } from "../../icons/check-icon/CheckIcon.js";
5
- import { PlusIconCircle as Ve } from "../../icons/plus-icon-circle/PlusIconCircle.js";
6
- import { StyledChip as Ye } from "../../data-display/chip/StyledChip.js";
7
- import { StyledCheckbox as O } from "../checkbox/base-ui/StyledCheckbox.js";
8
- import { TOP_LAYER_PROPS as Oe, TOP_LAYER_RESET_STYLE as Be, getOpenModalDialogAncestor as qe, useTopLayerRef as Ge } from "../../../hooks/useTopLayer.hook.js";
9
- import { LoadingIcon as Je } from "../../../table/shared-components/LoadingIcon.js";
10
- import B from "./StyledSelectAutocomplete.module.js";
11
- import { useMemo as M, useRef as q, useState as w } from "react";
5
+ import { PlusIconCircle as Ye } from "../../icons/plus-icon-circle/PlusIconCircle.js";
6
+ import { StyledChip as Oe } from "../../data-display/chip/StyledChip.js";
7
+ import { StyledCheckbox as q } from "../checkbox/base-ui/StyledCheckbox.js";
8
+ import { TOP_LAYER_PROPS as Be, TOP_LAYER_RESET_STYLE as qe, getOpenModalDialogAncestor as Ge, useTopLayerRef as Je } from "../../../hooks/useTopLayer.hook.js";
9
+ import { LoadingIcon as Qe } from "../../../table/shared-components/LoadingIcon.js";
10
+ import G from "./StyledSelectAutocomplete.module.js";
11
+ import { useEffect as Xe, useMemo as L, useRef as J, useState as w } from "react";
12
12
  import { jsx as s, jsxs as y } from "react/jsx-runtime";
13
- import { FloatingPortal as Qe, autoUpdate as Xe, flip as Ze, offset as Ke, shift as et, size as tt, useDismiss as rt, useFloating as lt, useInteractions as st, useMergeRefs as G, useRole as ot } from "@floating-ui/react";
14
- var at = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), J = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
15
- function yt({ dataTest: l, options: p, renderInput: Q, value: v, onChange: N, getOptionLabel: X, getOptionKey: D, isOptionEqualToValue: L, renderOption: _, renderValue: j, filterOptions: I, loading: E, loadingText: Z = "Loading…", noOptionsText: K = "No options", disabled: R, readOnly: m, size: ee = "small", disableClearable: te, disableCloseOnSelect: re, popupIcon: le, autoHeight: se, multiple: oe, allowSelectAll: ae, selectAllLabel: z = "Select all", fullWidth: ne, classes: ce, inputValue: F, onInputChange: ie, open: W, onOpen: de, onClose: ue, className: pe, wrapperClassName: me, getOptionDisabled: fe, slotProps: U }) {
16
- const o = oe === !0, n = X ?? at, S = (e, t) => L ? L(e, t) : e === t, [he, ge] = w(!1), a = W ?? he, f = (e) => {
17
- e && (m || R) || (W === void 0 && ge(e), e ? de?.() : ue?.());
18
- }, [be, xe] = w(""), h = F ?? be, C = (e, t, r) => {
19
- F === void 0 && xe(t), ie?.(e, t, r);
20
- }, [g, $] = w(null), we = q([]), H = q(null), [ye, ve] = w(null), [Ne, De] = w(null), c = o ? Array.isArray(v) ? v : [] : [], b = o ? null : v ?? null, T = (e) => o ? c.some((t) => S(e, t)) : b !== null && S(e, b), V = M(() => {
13
+ import { FloatingPortal as Ze, autoUpdate as Ke, flip as et, offset as tt, shift as rt, size as lt, useDismiss as st, useFloating as ot, useInteractions as at, useMergeRefs as Q, useRole as nt } from "@floating-ui/react";
14
+ var ct = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), X = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
15
+ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, getOptionLabel: K, getOptionKey: D, isOptionEqualToValue: _, renderOption: E, renderValue: j, filterOptions: k, loading: z, loadingText: ee = "Loading…", noOptionsText: te = "No options", disabled: R, readOnly: m, size: re = "small", disableClearable: le, disableCloseOnSelect: se, popupIcon: oe, autoHeight: ae, multiple: ne, allowSelectAll: ce, selectAllLabel: F = "Select all", fullWidth: ie, classes: de, inputValue: S, onInputChange: ue, open: W, onOpen: pe, onClose: me, className: fe, wrapperClassName: he, getOptionDisabled: ge, slotProps: U }) {
16
+ const o = ne === !0, n = K ?? ct, C = (e, t) => _ ? _(e, t) : e === t, [be, xe] = w(!1), a = W ?? be, f = (e) => {
17
+ e && (m || R) || (W === void 0 && xe(e), e ? pe?.() : me?.());
18
+ }, [we, V] = w(""), h = S ?? we, A = (e, t, r) => {
19
+ S === void 0 && V(t), ue?.(e, t, r);
20
+ }, [b, I] = w(null), ye = J([]), H = J(null), [ve, Ne] = w(null), [De, Re] = w(null), c = o ? Array.isArray(v) ? v : [] : [], g = o ? null : v ?? null, T = !o && g !== null ? n(g) : "";
21
+ Xe(() => {
22
+ S !== void 0 || o || V(T);
23
+ }, [
24
+ S,
25
+ o,
26
+ T
27
+ ]);
28
+ const Y = (e) => o ? c.some((t) => C(e, t)) : g !== null && C(e, g), O = L(() => {
21
29
  const e = [...p];
22
- if (I) return I(e, { inputValue: h });
23
- const t = !o && b !== null ? n(b).toLowerCase() : null;
30
+ if (k) return k(e, { inputValue: h });
31
+ const t = !o && g !== null ? n(g).toLowerCase() : null;
24
32
  if (!h || h.toLowerCase() === t) return e;
25
33
  const r = h.toLowerCase();
26
34
  return e.filter((d) => n(d).toLowerCase().includes(r));
27
35
  }, [
28
36
  p,
29
37
  h,
30
- I,
38
+ k,
31
39
  v
32
- ]), i = M(() => V.slice(0, 100), [V]), { refs: A, floatingStyles: Re, context: Y } = lt({
40
+ ]), i = L(() => O.slice(0, 100), [O]), { refs: P, floatingStyles: Se, context: B } = ot({
33
41
  open: a,
34
42
  onOpenChange: f,
35
43
  placement: "bottom-start",
36
44
  strategy: "fixed",
37
- whileElementsMounted: Xe,
45
+ whileElementsMounted: Ke,
38
46
  middleware: [
39
- Ke(4),
40
- Ze({ padding: 8 }),
47
+ tt(4),
41
48
  et({ padding: 8 }),
42
- tt({ apply({ rects: e, availableHeight: t }) {
43
- ve(e.reference.width), De(se ? t - 8 : Math.min(t - 8, 320));
49
+ rt({ padding: 8 }),
50
+ lt({ apply({ rects: e, availableHeight: t }) {
51
+ Ne(e.reference.width), Re(ae ? t - 8 : Math.min(t - 8, 320));
44
52
  } })
45
53
  ]
46
- }), { getReferenceProps: Se, getFloatingProps: Ce, getItemProps: Ae } = st([rt(Y), ot(Y, { role: "listbox" })]), Pe = G([A.setReference]), Ie = G([Ge(A.setFloating)]), $e = M(() => a ? qe(A.reference.current) : void 0, [a, A]), k = (e, t) => {
54
+ }), { getReferenceProps: Ce, getFloatingProps: Ae, getItemProps: Pe } = at([st(B), nt(B, { role: "listbox" })]), $e = Q([P.setReference]), ke = Q([Je(P.setFloating)]), Ie = L(() => a ? Ge(P.reference.current) : void 0, [a, P]), M = (e, t) => {
47
55
  if (o) {
48
- const r = c.some((u) => S(t, u)), d = r ? c.filter((u) => !S(t, u)) : [...c, t];
49
- N?.(e, d, r ? "removeOption" : "selectOption", { option: t }), C(e, "", "reset"), re || f(!1);
56
+ const r = c.some((u) => C(t, u)), d = r ? c.filter((u) => !C(t, u)) : [...c, t];
57
+ N?.(e, d, r ? "removeOption" : "selectOption", { option: t }), A(e, "", "reset"), se || f(!1);
50
58
  } else
51
- N?.(e, t, "selectOption", { option: t }), C(e, n(t), "reset"), f(!1);
52
- }, ke = (e) => {
53
- N?.(e, o ? [] : null, "clear", void 0), C(e, "", "clear");
59
+ N?.(e, t, "selectOption", { option: t }), A(e, n(t), "reset"), f(!1);
54
60
  }, Me = (e) => {
55
- if (e.key === "Enter" && a && g != null && i[g] != null) {
61
+ N?.(e, o ? [] : null, "clear", void 0), A(e, "", "clear");
62
+ }, Le = (e) => {
63
+ if (e.key === "Enter" && a && b != null && i[b] != null) {
56
64
  e.preventDefault();
57
- const t = i[g];
58
- J(t) || k(e, t);
65
+ const t = i[b];
66
+ X(t) || M(e, t);
59
67
  } else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
60
68
  if (e.preventDefault(), !a) {
61
- $(null), f(!0);
69
+ I(null), f(!0);
62
70
  return;
63
71
  }
64
72
  if (i.length === 0) return;
65
73
  const t = e.key === "ArrowDown" ? 1 : -1;
66
- $((r) => r == null ? t > 0 ? 0 : i.length - 1 : (r + t + i.length) % i.length);
74
+ I((r) => r == null ? t > 0 ? 0 : i.length - 1 : (r + t + i.length) % i.length);
67
75
  }
68
- }, Le = !te && !m && !R && (o ? c.length > 0 : b !== null), _e = (e) => {
76
+ }, _e = !le && !m && !R && (o ? c.length > 0 : g !== null), Ee = (e) => {
69
77
  e.preventDefault(), !(R || m) && (H.current?.focus(), f(!a));
70
- }, je = o ? j ? j(c, ({ index: e }) => ({ "data-index": e })) : c.map((e, t) => /* @__PURE__ */ s(Ye, {
78
+ }, je = o ? j ? j(c, ({ index: e }) => ({ "data-index": e })) : c.map((e, t) => /* @__PURE__ */ s(Oe, {
71
79
  dataTest: `selected-chip-${n(e)}`,
72
80
  label: n(e),
73
81
  readOnly: m,
74
- onDelete: m ? void 0 : (r) => k(r, e)
75
- }, D ? D(e) : `${n(e)}-${t}`)) : void 0, Ee = /* @__PURE__ */ y("span", {
82
+ onDelete: m ? void 0 : (r) => M(r, e)
83
+ }, D ? D(e) : `${n(e)}-${t}`)) : void 0, ze = /* @__PURE__ */ y("span", {
76
84
  className: "flex items-center gap-1",
77
85
  children: [
78
- E && /* @__PURE__ */ s(Je, {
86
+ z && /* @__PURE__ */ s(Qe, {
79
87
  width: 20,
80
88
  height: 20,
81
89
  className: "animate-spin"
82
90
  }),
83
- Le && /* @__PURE__ */ s("button", {
91
+ _e && /* @__PURE__ */ s("button", {
84
92
  type: "button",
85
93
  "aria-label": "Clear",
86
94
  "data-testid": `${l}-clear`,
87
95
  className: "flex min-h-6 min-w-6 cursor-pointer items-center justify-center rounded-full border-0 bg-delta-50",
88
96
  onMouseDown: (e) => {
89
- e.preventDefault(), ke(e);
97
+ e.preventDefault(), Me(e);
90
98
  },
91
99
  children: /* @__PURE__ */ s(He, {
92
100
  width: 20,
@@ -100,51 +108,51 @@ function yt({ dataTest: l, options: p, renderInput: Q, value: v, onChange: N, ge
100
108
  "aria-expanded": a,
101
109
  "data-testid": `${l}-popup-indicator`,
102
110
  className: "flex cursor-pointer items-center border-0 bg-transparent",
103
- onMouseDown: _e,
104
- children: le ?? (o ? /* @__PURE__ */ s(Ve, {
111
+ onMouseDown: Ee,
112
+ children: oe ?? (o ? /* @__PURE__ */ s(Ye, {
105
113
  width: 24,
106
114
  height: 24,
107
115
  className: "text-delta-700"
108
- }) : /* @__PURE__ */ s(Ue, {
116
+ }) : /* @__PURE__ */ s(Ve, {
109
117
  width: 24,
110
118
  height: 24,
111
- className: P(B["select-custom-icon"], "text-delta-700 transition-transform", a && "rotate-180")
119
+ className: $(G["select-custom-icon"], "text-delta-700 transition-transform", a && "rotate-180")
112
120
  }))
113
121
  })
114
122
  ]
115
- }), ze = {
123
+ }), Fe = {
116
124
  disabled: R,
117
- size: ee,
125
+ size: re,
118
126
  fullWidth: !0,
119
127
  value: h,
120
128
  onChange: (e) => {
121
- C(e, e.target.value, "input"), a || f(!0);
129
+ A(e, e.target.value, "input"), a || f(!0);
122
130
  },
123
- onKeyDown: Me,
131
+ onKeyDown: Le,
124
132
  slotProps: {
125
133
  htmlInput: {
126
- ...Se(),
134
+ ...Ce(),
127
135
  ref: H,
128
136
  onClick: () => f(!0),
129
137
  role: "combobox",
130
138
  "aria-autocomplete": "list",
131
139
  "aria-expanded": a,
132
- "aria-activedescendant": a && g != null ? `${l}-option-${g}` : void 0,
140
+ "aria-activedescendant": a && b != null ? `${l}-option-${b}` : void 0,
133
141
  autoComplete: "off",
134
142
  readOnly: m
135
143
  },
136
144
  input: {
137
- ref: Pe,
145
+ ref: $e,
138
146
  startAdornment: je,
139
- endAdornment: Ee
147
+ endAdornment: ze
140
148
  }
141
149
  }
142
- }, Fe = (e, t, r) => {
150
+ }, We = (e, t, r) => {
143
151
  const { key: d, ...u } = e;
144
152
  return /* @__PURE__ */ y("li", {
145
153
  ...u,
146
- className: P("box-border flex min-h-10 cursor-pointer items-center gap-x-3 px-3 py-1.5 text-base text-delta-700 first:-mt-1", "aria-selected:bg-gama-50 data-[active]:bg-gama-50 data-[active]:text-delta-800", "aria-disabled:cursor-default aria-disabled:!bg-transparent aria-disabled:text-delta-300", o && "border-0 border-b border-solid border-delta-200"),
147
- children: [o ? /* @__PURE__ */ s(O, {
154
+ className: $("box-border flex min-h-10 cursor-pointer items-center gap-x-3 px-3 py-1.5 text-base text-delta-700 first:-mt-1", "aria-selected:bg-gama-50 data-[active]:bg-gama-50 data-[active]:text-delta-800", "aria-disabled:cursor-default aria-disabled:!bg-transparent aria-disabled:text-delta-300", o && "border-0 border-b border-solid border-delta-200"),
155
+ children: [o ? /* @__PURE__ */ s(q, {
148
156
  dataTest: `${l}-${n(t)}-checkbox`,
149
157
  checked: r.selected,
150
158
  size: "small",
@@ -162,54 +170,54 @@ function yt({ dataTest: l, options: p, renderInput: Q, value: v, onChange: N, ge
162
170
  children: n(t)
163
171
  })]
164
172
  }, d);
165
- }, We = (e, t) => {
166
- const r = fe?.(e) ?? J(e), d = {
167
- ...Ae({
173
+ }, Ue = (e, t) => {
174
+ const r = ge?.(e) ?? X(e), d = {
175
+ ...Pe({
168
176
  onMouseDown: (x) => x.preventDefault(),
169
177
  onClick: (x) => {
170
- r || k(x, e);
178
+ r || M(x, e);
171
179
  },
172
- onMouseMove: () => $(r ? null : t)
180
+ onMouseMove: () => I(r ? null : t)
173
181
  }),
174
182
  key: D ? String(D(e)) : `${n(e)}-${t}`,
175
183
  ref: (x) => {
176
- we.current[t] = x;
184
+ ye.current[t] = x;
177
185
  },
178
186
  role: "option",
179
187
  id: `${l}-option-${t}`,
180
- "aria-selected": T(e),
188
+ "aria-selected": Y(e),
181
189
  "aria-disabled": r || void 0,
182
- "data-active": g === t ? "" : void 0
190
+ "data-active": b === t ? "" : void 0
183
191
  }, u = {
184
- selected: T(e),
192
+ selected: Y(e),
185
193
  index: t,
186
194
  inputValue: h
187
195
  };
188
- return _ ? _(d, e, u) : Fe(d, e, u);
196
+ return E ? E(d, e, u) : We(d, e, u);
189
197
  };
190
198
  return /* @__PURE__ */ y("div", {
191
- className: P(B.styledSelectAutocompleteWrapper, !ne && "w-auto", me, pe),
192
- children: [Q(ze), a && /* @__PURE__ */ s(Qe, {
193
- root: $e,
199
+ className: $(G.styledSelectAutocompleteWrapper, !ie && "w-auto", he, fe),
200
+ children: [Z(Fe), a && /* @__PURE__ */ s(Ze, {
201
+ root: Ie,
194
202
  children: /* @__PURE__ */ y("ul", {
195
- ref: Ie,
196
- ...Oe,
203
+ ref: ke,
204
+ ...Be,
197
205
  style: {
198
- ...Be,
199
- ...Re,
200
- width: ye ?? void 0,
201
- maxHeight: Ne ?? void 0,
206
+ ...qe,
207
+ ...Se,
208
+ width: ve ?? void 0,
209
+ maxHeight: De ?? void 0,
202
210
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
203
211
  ...U?.popper?.style
204
212
  },
205
- ...Ce(),
206
- className: P("z-[1300] m-0 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white p-0 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", ce?.listbox, U?.popper?.className),
207
- children: [ae && o && /* @__PURE__ */ y("div", {
213
+ ...Ae(),
214
+ className: $("z-[1300] m-0 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white p-0 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", de?.listbox, U?.popper?.className),
215
+ children: [ce && o && /* @__PURE__ */ y("div", {
208
216
  role: "group",
209
217
  className: "flex min-h-12 items-center gap-x-1 border-0 border-b border-solid border-delta-200 px-4 text-sm text-delta-700",
210
- children: [/* @__PURE__ */ s(O, {
218
+ children: [/* @__PURE__ */ s(q, {
211
219
  dataTest: `${l}-select-all`,
212
- "aria-label": z,
220
+ "aria-label": F,
213
221
  checked: p.length > 0 && c.length === p.length,
214
222
  size: "small",
215
223
  hideWrapper: !0,
@@ -220,21 +228,21 @@ function yt({ dataTest: l, options: p, renderInput: Q, value: v, onChange: N, ge
220
228
  }
221
229
  }), /* @__PURE__ */ s("span", {
222
230
  className: "flex-1 truncate py-2",
223
- children: z
231
+ children: F
224
232
  })]
225
- }), E ? /* @__PURE__ */ s("li", {
233
+ }), z ? /* @__PURE__ */ s("li", {
226
234
  role: "presentation",
227
235
  className: "px-3 py-2 text-sm text-delta-600",
228
- children: Z
236
+ children: ee
229
237
  }) : i.length === 0 ? /* @__PURE__ */ s("li", {
230
238
  role: "presentation",
231
239
  className: "px-3 py-2 text-sm text-delta-600",
232
- children: K
233
- }) : i.map(We)]
240
+ children: te
241
+ }) : i.map(Ue)]
234
242
  })
235
243
  })]
236
244
  });
237
245
  }
238
246
  export {
239
- yt as StyledSelectAutocomplete
247
+ Nt as StyledSelectAutocomplete
240
248
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.47.0",
6
+ "version": "3.47.1",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",