asma-ui-core 3.50.1 → 3.51.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,24 +1,24 @@
1
1
  import { cn as $ } from "../../../helpers/cn.js";
2
- import { ChevronDownIcon as Ve } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
3
- import { CloseIcon as He } from "../../icons/close-icon/CloseIcon.js";
4
- import { CheckIcon as Te } from "../../icons/check-icon/CheckIcon.js";
5
- import { PlusIconCircle as Ye } from "../../icons/plus-icon-circle/PlusIconCircle.js";
6
- import { StyledChip as Oe } from "../../data-display/chip/StyledChip.js";
2
+ import { ChevronDownIcon as He } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
3
+ import { CloseIcon as Te } from "../../icons/close-icon/CloseIcon.js";
4
+ import { CheckIcon as Ye } from "../../icons/check-icon/CheckIcon.js";
5
+ import { PlusIconCircle as Oe } from "../../icons/plus-icon-circle/PlusIconCircle.js";
6
+ import { StyledChip as Be } from "../../data-display/chip/StyledChip.js";
7
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";
8
+ import { TOP_LAYER_PROPS as qe, TOP_LAYER_RESET_STYLE as Ge, getOpenModalDialogAncestor as Je, useTopLayerRef as Qe } from "../../../hooks/useTopLayer.hook.js";
9
+ import { LoadingIcon as Xe } from "../../../table/shared-components/LoadingIcon.js";
10
10
  import G from "./StyledSelectAutocomplete.module.js";
11
- import { useEffect as Xe, useMemo as L, useRef as J, useState as w } from "react";
11
+ import { useEffect as Ze, 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 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?.());
13
+ import { FloatingPortal as Ke, autoUpdate as et, flip as tt, offset as rt, shift as lt, size as st, useDismiss as ot, useFloating as at, useInteractions as nt, useMergeRefs as Q, useRole as ct } from "@floating-ui/react";
14
+ var it = (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 Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, getOptionLabel: K, getOptionKey: R, isOptionEqualToValue: _, renderOption: E, renderValue: j, filterOptions: k, loading: z, loadingText: ee = "Loading…", noOptionsText: te = "No options", disabled: D, 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 ?? it, C = (e, t) => _ ? _(e, t) : e === t, [be, xe] = w(!1), a = W ?? be, f = (e) => {
17
+ e && (m || D) || (W === void 0 && xe(e), e ? pe?.() : me?.());
18
18
  }, [we, V] = w(""), h = S ?? we, A = (e, t, r) => {
19
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(() => {
20
+ }, [b, I] = w(null), ye = J([]), H = J(null), [ve, Ne] = w(null), [Re, De] = w(null), c = o ? Array.isArray(v) ? v : [] : [], g = o ? null : v ?? null, T = !o && g !== null ? n(g) : "";
21
+ Ze(() => {
22
22
  S !== void 0 || o || V(T);
23
23
  }, [
24
24
  S,
@@ -37,21 +37,21 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
37
37
  h,
38
38
  k,
39
39
  v
40
- ]), i = L(() => O.slice(0, 100), [O]), { refs: P, floatingStyles: Se, context: B } = ot({
40
+ ]), i = L(() => O.slice(0, 100), [O]), { refs: P, floatingStyles: Se, context: B } = at({
41
41
  open: a,
42
42
  onOpenChange: f,
43
43
  placement: "bottom-start",
44
44
  strategy: "fixed",
45
- whileElementsMounted: Ke,
45
+ whileElementsMounted: et,
46
46
  middleware: [
47
- tt(4),
48
- et({ padding: 8 }),
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));
47
+ rt(4),
48
+ tt({ padding: 8 }),
49
+ lt({ padding: 8 }),
50
+ st({ apply({ rects: e, availableHeight: t }) {
51
+ Ne(e.reference.width), De(ae ? t - 8 : Math.min(t - 8, 320));
52
52
  } })
53
53
  ]
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) => {
54
+ }), { getReferenceProps: Ce, getFloatingProps: Ae, getItemProps: Pe } = nt([ot(B), ct(B, { role: "listbox" })]), $e = Q([P.setReference]), ke = Q([Qe(P.setFloating)]), Ie = L(() => a ? Je(P.reference.current) : void 0, [a, P]), M = (e, t) => {
55
55
  if (o) {
56
56
  const r = c.some((u) => C(t, u)), d = r ? c.filter((u) => !C(t, u)) : [...c, t];
57
57
  N?.(e, d, r ? "removeOption" : "selectOption", { option: t }), A(e, "", "reset"), se || f(!1);
@@ -73,17 +73,17 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
73
73
  const t = e.key === "ArrowDown" ? 1 : -1;
74
74
  I((r) => r == null ? t > 0 ? 0 : i.length - 1 : (r + t + i.length) % i.length);
75
75
  }
76
- }, _e = !le && !m && !R && (o ? c.length > 0 : g !== null), Ee = (e) => {
77
- e.preventDefault(), !(R || m) && (H.current?.focus(), f(!a));
78
- }, je = o ? j ? j(c, ({ index: e }) => ({ "data-index": e })) : c.map((e, t) => /* @__PURE__ */ s(Oe, {
76
+ }, _e = !le && !m && !D && (o ? c.length > 0 : g !== null), Ee = (e) => {
77
+ e.preventDefault(), !(D || m) && (H.current?.focus(), f(!a));
78
+ }, je = o ? j ? j(c, ({ index: e }) => ({ "data-index": e })) : c.map((e, t) => /* @__PURE__ */ s(Be, {
79
79
  dataTest: `selected-chip-${n(e)}`,
80
80
  label: n(e),
81
81
  readOnly: m,
82
82
  onDelete: m ? void 0 : (r) => M(r, e)
83
- }, D ? D(e) : `${n(e)}-${t}`)) : void 0, ze = /* @__PURE__ */ y("span", {
83
+ }, R ? R(e) : `${n(e)}-${t}`)) : void 0, ze = /* @__PURE__ */ y("span", {
84
84
  className: "flex items-center gap-1",
85
85
  children: [
86
- z && /* @__PURE__ */ s(Qe, {
86
+ z && /* @__PURE__ */ s(Xe, {
87
87
  width: 20,
88
88
  height: 20,
89
89
  className: "animate-spin"
@@ -96,7 +96,7 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
96
96
  onMouseDown: (e) => {
97
97
  e.preventDefault(), Me(e);
98
98
  },
99
- children: /* @__PURE__ */ s(He, {
99
+ children: /* @__PURE__ */ s(Te, {
100
100
  width: 20,
101
101
  height: 20,
102
102
  className: "text-delta-700"
@@ -109,11 +109,11 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
109
109
  "data-testid": `${l}-popup-indicator`,
110
110
  className: "flex cursor-pointer items-center border-0 bg-transparent",
111
111
  onMouseDown: Ee,
112
- children: oe ?? (o ? /* @__PURE__ */ s(Ye, {
112
+ children: oe ?? (o ? /* @__PURE__ */ s(Oe, {
113
113
  width: 24,
114
114
  height: 24,
115
115
  className: "text-delta-700"
116
- }) : /* @__PURE__ */ s(Ve, {
116
+ }) : /* @__PURE__ */ s(He, {
117
117
  width: 24,
118
118
  height: 24,
119
119
  className: $(G["select-custom-icon"], "text-delta-700 transition-transform", a && "rotate-180")
@@ -121,7 +121,7 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
121
121
  })
122
122
  ]
123
123
  }), Fe = {
124
- disabled: R,
124
+ disabled: D,
125
125
  size: re,
126
126
  fullWidth: !0,
127
127
  value: h,
@@ -147,11 +147,10 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
147
147
  endAdornment: ze
148
148
  }
149
149
  }
150
- }, We = (e, t, r) => {
150
+ }, We = $("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"), Ue = (e, t, r) => {
151
151
  const { key: d, ...u } = e;
152
152
  return /* @__PURE__ */ y("li", {
153
153
  ...u,
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
154
  children: [o ? /* @__PURE__ */ s(q, {
156
155
  dataTest: `${l}-${n(t)}-checkbox`,
157
156
  checked: r.selected,
@@ -160,7 +159,7 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
160
159
  decorative: !0
161
160
  }) : /* @__PURE__ */ s("span", {
162
161
  className: "w-5",
163
- children: r.selected && /* @__PURE__ */ s(Te, {
162
+ children: r.selected && /* @__PURE__ */ s(Ye, {
164
163
  width: 20,
165
164
  height: 20,
166
165
  className: "text-gama-500"
@@ -170,7 +169,7 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
170
169
  children: n(t)
171
170
  })]
172
171
  }, d);
173
- }, Ue = (e, t) => {
172
+ }, Ve = (e, t) => {
174
173
  const r = ge?.(e) ?? X(e), d = {
175
174
  ...Pe({
176
175
  onMouseDown: (x) => x.preventDefault(),
@@ -179,7 +178,7 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
179
178
  },
180
179
  onMouseMove: () => I(r ? null : t)
181
180
  }),
182
- key: D ? String(D(e)) : `${n(e)}-${t}`,
181
+ key: R ? String(R(e)) : `${n(e)}-${t}`,
183
182
  ref: (x) => {
184
183
  ye.current[t] = x;
185
184
  },
@@ -187,26 +186,27 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
187
186
  id: `${l}-option-${t}`,
188
187
  "aria-selected": Y(e),
189
188
  "aria-disabled": r || void 0,
190
- "data-active": b === t ? "" : void 0
189
+ "data-active": b === t ? "" : void 0,
190
+ className: We
191
191
  }, u = {
192
192
  selected: Y(e),
193
193
  index: t,
194
194
  inputValue: h
195
195
  };
196
- return E ? E(d, e, u) : We(d, e, u);
196
+ return E ? E(d, e, u) : Ue(d, e, u);
197
197
  };
198
198
  return /* @__PURE__ */ y("div", {
199
199
  className: $(G.styledSelectAutocompleteWrapper, !ie && "w-auto", he, fe),
200
- children: [Z(Fe), a && /* @__PURE__ */ s(Ze, {
200
+ children: [Z(Fe), a && /* @__PURE__ */ s(Ke, {
201
201
  root: Ie,
202
202
  children: /* @__PURE__ */ y("ul", {
203
203
  ref: ke,
204
- ...Be,
204
+ ...qe,
205
205
  style: {
206
- ...qe,
206
+ ...Ge,
207
207
  ...Se,
208
208
  width: ve ?? void 0,
209
- maxHeight: De ?? void 0,
209
+ maxHeight: Re ?? void 0,
210
210
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
211
211
  ...U?.popper?.style
212
212
  },
@@ -238,11 +238,11 @@ function Nt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
238
238
  role: "presentation",
239
239
  className: "px-3 py-2 text-sm text-delta-600",
240
240
  children: te
241
- }) : i.map(Ue)]
241
+ }) : i.map(Ve)]
242
242
  })
243
243
  })]
244
244
  });
245
245
  }
246
246
  export {
247
- Nt as StyledSelectAutocomplete
247
+ Rt as StyledSelectAutocomplete
248
248
  };
@@ -1,34 +1,34 @@
1
- import { useEffect as m } from "react";
2
- var l = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])', E = (o, s, c) => {
3
- m(() => {
4
- if (!o) return;
5
- const t = s.current;
1
+ import { useEffect as d } from "react";
2
+ var m = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])', b = (c, u, a) => {
3
+ d(() => {
4
+ if (!c) return;
5
+ const t = u.current;
6
6
  if (!t) return;
7
- const r = document.activeElement, d = requestAnimationFrame(() => {
8
- (t.querySelector(l) ?? t).focus();
9
- }), u = (e) => {
7
+ const r = document.activeElement, l = requestAnimationFrame(() => {
8
+ t.focus({ preventScroll: !0 });
9
+ }), i = (e) => {
10
10
  if (e.key === "Escape") {
11
- c?.();
11
+ a?.();
12
12
  return;
13
13
  }
14
14
  if (e.key !== "Tab") return;
15
- const n = Array.from(t.querySelectorAll(l));
15
+ const n = Array.from(t.querySelectorAll(m));
16
16
  if (n.length === 0) {
17
17
  e.preventDefault();
18
18
  return;
19
19
  }
20
- const i = n[0], a = n[n.length - 1], f = document.activeElement;
21
- e.shiftKey && f === i ? (e.preventDefault(), a?.focus()) : !e.shiftKey && f === a && (e.preventDefault(), i?.focus());
20
+ const s = n[0], f = n[n.length - 1], o = document.activeElement;
21
+ e.shiftKey && (o === s || o === t) ? (e.preventDefault(), f?.focus()) : (!e.shiftKey && o === f || !e.shiftKey && o === t) && (e.preventDefault(), s?.focus());
22
22
  };
23
- return document.addEventListener("keydown", u), () => {
24
- cancelAnimationFrame(d), document.removeEventListener("keydown", u), r && document.contains(r) && r.focus();
23
+ return document.addEventListener("keydown", i), () => {
24
+ cancelAnimationFrame(l), document.removeEventListener("keydown", i), r && document.contains(r) && r.focus();
25
25
  };
26
26
  }, [
27
- o,
28
- s,
29
- c
27
+ c,
28
+ u,
29
+ a
30
30
  ]);
31
31
  };
32
32
  export {
33
- E as useFocusTrap
33
+ b as useFocusTrap
34
34
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.50.1",
6
+ "version": "3.51.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",