asma-ui-core 3.68.6 → 3.69.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.
Files changed (38) hide show
  1. package/dist/components/inputs/dynamic-select/components/DynamicInteractiveChipGroup.js +49 -43
  2. package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +45 -44
  3. package/dist/components/inputs/input-field/StyledInputField.js +127 -116
  4. package/dist/components/inputs/radio-button/base-ui/StyledRadioGroup.js +37 -32
  5. package/dist/components/inputs/search-field/StyledSearchField.js +9 -8
  6. package/dist/components/inputs/select/StyledSelect.js +123 -111
  7. package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +67 -65
  8. package/dist/components/inputs/slider/StyledSlider.js +69 -61
  9. package/dist/components/inputs/textarea/StyledTextarea.js +52 -47
  10. package/dist/datetime/components/date-picker/components/BaseDatePickerInput.js +12 -12
  11. package/dist/datetime/components/date-picker/hooks/useDatePickerValidation.js +32 -31
  12. package/dist/datetime/components/time-picker/TimePickerInput.js +19 -18
  13. package/dist/datetime/components/time-picker/components/HelperText.js +10 -9
  14. package/dist/helpers/helperTextRoom.js +34 -0
  15. package/dist/helpers/useHelperAlertRole.js +11 -0
  16. package/dist/helpers/useHelperRowBudget.js +24 -0
  17. package/dist/helpers/warnMissingErrorMessage.js +6 -0
  18. package/dist/index.js +170 -165
  19. package/dist/src/components/inputs/dynamic-select/components/DynamicInteractiveChipGroup.test.d.ts +1 -0
  20. package/dist/src/components/inputs/dynamic-select/types.d.ts +1 -1
  21. package/dist/src/components/inputs/input-field/StyledInputField.d.ts +3 -3
  22. package/dist/src/components/inputs/input-field/StyledInputField.helper-slot.test.d.ts +1 -0
  23. package/dist/src/components/inputs/radio-button/base-ui/StyledRadioGroup.d.ts +2 -0
  24. package/dist/src/components/inputs/select/StyledSelect.d.ts +4 -4
  25. package/dist/src/components/inputs/select-autocomplete/StyledSelectAutocomplete.d.ts +5 -4
  26. package/dist/src/components/inputs/slider/StyledSlider.d.ts +2 -2
  27. package/dist/src/components/inputs/textarea/StyledTextarea.d.ts +1 -0
  28. package/dist/src/datetime/components/date-picker/hooks/useDatePickerValidation.d.ts +18 -1
  29. package/dist/src/datetime/components/date-picker/index.d.ts +1 -0
  30. package/dist/src/datetime/components/time-picker/components/HelperText.d.ts +12 -0
  31. package/dist/src/datetime/components/time-picker/index.d.ts +1 -0
  32. package/dist/src/helpers/helperTextRoom.d.ts +9 -0
  33. package/dist/src/helpers/helperTextRoom.test.d.ts +1 -0
  34. package/dist/src/helpers/useHelperAlertRole.d.ts +2 -0
  35. package/dist/src/helpers/useHelperAlertRole.test.d.ts +1 -0
  36. package/dist/src/helpers/useHelperRowBudget.d.ts +7 -0
  37. package/dist/src/helpers/warnMissingErrorMessage.d.ts +2 -0
  38. package/package.json +1 -1
@@ -1,186 +1,198 @@
1
- import { cn as f } from "../../../helpers/cn.js";
2
- import { resolveSx as he } from "../../../helpers/sx.js";
3
- import { ChevronDownIcon as we } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
4
- import { CloseIcon as Ae } from "../../icons/close-icon/CloseIcon.js";
5
- import { ErrorOutlineIcon as ve } from "../../icons/error-outline-icon/ErrorOutlineIcon.js";
6
- import { TOP_LAYER_PROPS as Re, TOP_LAYER_RESET_STYLE as ke, getOpenModalDialogAncestor as Fe, shouldUsePopoverTopLayer as De, useTopLayerRef as Se } from "../../../hooks/useTopLayer.hook.js";
7
- import { outlineClass as Ce } from "../field-styles.js";
8
- import { useFormControlContext as Ee } from "../../miscellaneous/FormControlContext.js";
9
- import { StyledFormHelperText as Ne } from "../../miscellaneous/StyledFormHelperText.js";
10
- import { Children as E, cloneElement as Pe, isValidElement as N, useEffect as P, useMemo as _e, useRef as H, useState as _ } from "react";
11
- import { jsx as n, jsxs as h } from "react/jsx-runtime";
12
- import { FloatingPortal as qe, autoUpdate as Te, flip as Le, offset as Ue, shift as Ve, size as je, useClick as Be, useDismiss as Ie, useFloating as Ke, useInteractions as Me, useMergeRefs as Y, useRole as Oe } from "@floating-ui/react";
13
- var rt = ({ dataTest: q, value: T, defaultValue: z, onChange: L, error: W, errorText: $, allowClear: U, disabled: G, readOnly: c, name: m, placeholder: w, displayEmpty: A, multiple: u, renderValue: V, fullWidth: J, className: Q, style: X, sx: Z, variant: ee, children: v, MenuProps: te, onFocus: re, onBlur: oe, labelId: p }) => {
14
- const i = Ee(), j = `${q}-listbox`, g = ee === "standard", B = W ?? i?.error ?? !1, s = G ?? i?.disabled ?? !1, [o, y] = _(!1), [x, R] = _(!1), [se, I] = _(z), k = T !== void 0, r = k ? T : se, a = Array.isArray(r) ? r.length > 0 : r !== void 0 && r !== "" && r !== null, l = H(null), K = H(null), ne = (e) => {
15
- if (y(e), e) return;
1
+ import { cn as u } from "../../../helpers/cn.js";
2
+ import { resolveSx as Ce } from "../../../helpers/sx.js";
3
+ import { ChevronDownIcon as Ne } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
4
+ import { CloseIcon as Pe } from "../../icons/close-icon/CloseIcon.js";
5
+ import { ErrorOutlineIcon as _e } from "../../icons/error-outline-icon/ErrorOutlineIcon.js";
6
+ import { TOP_LAYER_PROPS as qe, TOP_LAYER_RESET_STYLE as Ie, getOpenModalDialogAncestor as Be, shouldUsePopoverTopLayer as Le, useTopLayerRef as Me } from "../../../hooks/useTopLayer.hook.js";
7
+ import { useHelperAlertRole as Te } from "../../../helpers/useHelperAlertRole.js";
8
+ import { useHelperRowBudget as Ue } from "../../../helpers/useHelperRowBudget.js";
9
+ import { warnMissingErrorMessage as Ve } from "../../../helpers/warnMissingErrorMessage.js";
10
+ import { outlineClass as je } from "../field-styles.js";
11
+ import { useFormControlContext as He } from "../../miscellaneous/FormControlContext.js";
12
+ import { Children as _, cloneElement as Ke, isValidElement as q, useEffect as I, useId as Oe, useMemo as Ye, useRef as $, useState as B } from "react";
13
+ import { jsx as n, jsxs as w } from "react/jsx-runtime";
14
+ import { FloatingPortal as ze, autoUpdate as We, flip as $e, offset as Ge, shift as Je, size as Qe, useClick as Xe, useDismiss as Ze, useFloating as et, useInteractions as tt, useMergeRefs as G, useRole as rt } from "@floating-ui/react";
15
+ var ht = ({ dataTest: L, value: M, defaultValue: J, onChange: T, error: Q, errorText: X, helperText: U, reserveHelperText: Z = !0, expandHelperText: ee = !0, allowClear: V, disabled: te, readOnly: c, name: p, placeholder: A, displayEmpty: v, multiple: f, renderValue: j, fullWidth: re, className: oe, style: se, sx: ne, variant: le, children: R, MenuProps: ie, onFocus: ae, onBlur: ce, labelId: g }) => {
16
+ const d = He(), H = `${L}-listbox`, K = Oe(), y = le === "standard", l = Q ?? d?.error ?? !1, s = te ?? d?.disabled ?? !1, k = l ? X ?? U : U, S = !c && (Z || k != null || l);
17
+ Ve("StyledSelect", l, k);
18
+ const de = Te(l), { fieldRef: ue, rowRef: fe, rowStyle: me } = Ue(ee && S), [o, h] = B(!1), [b, D] = B(!1), [pe, O] = B(J), F = M !== void 0, r = F ? M : pe, i = Array.isArray(r) ? r.length > 0 : r !== void 0 && r !== "" && r !== null, a = $(null), Y = $(null), ge = (e) => {
19
+ if (h(e), e) return;
16
20
  const t = document.activeElement;
17
- t && t !== document.body && !l.current?.contains(t) || K.current?.focus();
18
- }, { refs: d, floatingStyles: ae, context: F } = Ke({
21
+ t && t !== document.body && !a.current?.contains(t) || Y.current?.focus();
22
+ }, { refs: m, floatingStyles: ye, context: E } = et({
19
23
  open: o,
20
- onOpenChange: ne,
24
+ onOpenChange: ge,
21
25
  placement: "bottom-start",
22
26
  strategy: "fixed",
23
- whileElementsMounted: Te,
27
+ whileElementsMounted: We,
24
28
  middleware: [
25
- Ue(4),
26
- Le({ padding: 8 }),
27
- Ve({ padding: 8 }),
28
- je({ apply({ rects: e, elements: t }) {
29
+ Ge(4),
30
+ $e({ padding: 8 }),
31
+ Je({ padding: 8 }),
32
+ Qe({ apply({ rects: e, elements: t }) {
29
33
  t.floating.style.minWidth = `${e.reference.width + 20}px`;
30
34
  } })
31
35
  ]
32
- }), { getReferenceProps: le, getFloatingProps: ie } = Me([
33
- Be(F, { enabled: !s && !c }),
34
- Ie(F),
35
- Oe(F, { role: "listbox" })
36
- ]), ce = Y([d.setReference, K]), M = _e(() => o ? Fe(d.reference.current) : void 0, [o, d]), D = De(M), ue = Y([Se(d.setFloating, D), l]);
37
- P(() => i?.setFocused(o || x), [
36
+ }), { getReferenceProps: he, getFloatingProps: be } = tt([
37
+ Xe(E, { enabled: !s && !c }),
38
+ Ze(E),
39
+ rt(E, { role: "listbox" })
40
+ ]), xe = G([m.setReference, Y]), z = Ye(() => o ? Be(m.reference.current) : void 0, [o, m]), C = Le(z), we = G([Me(m.setFloating, C), a]);
41
+ I(() => d?.setFocused(o || b), [
38
42
  o,
39
- x,
40
- i
41
- ]), P(() => i?.setFilled(a || !!w || !!A), [
42
- a,
43
- w,
43
+ b,
44
+ d
45
+ ]), I(() => d?.setFilled(i || !!A || !!v), [
46
+ i,
44
47
  A,
45
- i
46
- ]), P(() => {
48
+ v,
49
+ d
50
+ ]), I(() => {
47
51
  if (!o) return;
48
52
  const e = requestAnimationFrame(() => {
49
- const t = l.current?.querySelector('[role="option"][aria-selected="true"]');
53
+ const t = a.current?.querySelector('[role="option"][aria-selected="true"]');
50
54
  t && (t.scrollIntoView({ block: "nearest" }), t.focus());
51
55
  });
52
56
  return () => cancelAnimationFrame(e);
53
57
  }, [o]);
54
- const de = (e, t) => {
55
- const b = u ? Array.isArray(r) && r.includes(e) ? r.filter((C) => C !== e) : [...Array.isArray(r) ? r : [], e] : e;
56
- k || I(b), L?.({ target: {
57
- value: b,
58
- name: m
59
- } }, t), u || (y(!1), requestAnimationFrame(() => d.domReference.current?.focus()));
60
- }, O = () => {
61
- const e = u ? [] : "";
62
- k || I(e), L?.({ target: {
58
+ const Ae = (e, t) => {
59
+ const x = f ? Array.isArray(r) && r.includes(e) ? r.filter((P) => P !== e) : [...Array.isArray(r) ? r : [], e] : e;
60
+ F || O(x), T?.({ target: {
61
+ value: x,
62
+ name: p
63
+ } }, t), f || (h(!1), requestAnimationFrame(() => m.domReference.current?.focus()));
64
+ }, W = () => {
65
+ const e = f ? [] : "";
66
+ F || O(e), T?.({ target: {
63
67
  value: e,
64
- name: m
65
- } }, null), y(!1), R(!1);
66
- }, fe = E.map(v, (e) => {
67
- if (!N(e)) return e;
68
+ name: p
69
+ } }, null), h(!1), D(!1);
70
+ }, ve = _.map(R, (e) => {
71
+ if (!q(e)) return e;
68
72
  const t = e.props.value;
69
- return Pe(e, {
70
- selected: u ? Array.isArray(r) && r.includes(t) : t === r,
71
- onClick: () => de(t, e.props.children)
73
+ return Ke(e, {
74
+ selected: f ? Array.isArray(r) && r.includes(t) : t === r,
75
+ onClick: () => Ae(t, e.props.children)
72
76
  });
73
- }), me = E.toArray(v).find((e) => N(e) && e.props.value === r), pe = V ? V(r) : u && Array.isArray(r) ? E.toArray(v).filter((e) => N(e) && r.includes(e.props.value)).map((e) => {
77
+ }), Re = _.toArray(R).find((e) => q(e) && e.props.value === r), ke = j ? j(r) : f && Array.isArray(r) ? _.toArray(R).filter((e) => q(e) && r.includes(e.props.value)).map((e) => {
74
78
  const t = e.props.children;
75
79
  return typeof t == "string" || typeof t == "number" ? String(t) : "";
76
- }).join(", ") : me?.props.children, ge = (e) => {
77
- if ((e.key === "Backspace" || e.key === "Delete") && U && a && !s && !c) {
78
- e.preventDefault(), O();
80
+ }).join(", ") : Re?.props.children, Se = (e) => {
81
+ if ((e.key === "Backspace" || e.key === "Delete") && V && i && !s && !c) {
82
+ e.preventDefault(), W();
79
83
  return;
80
84
  }
81
- e.key !== "ArrowDown" && e.key !== "ArrowUp" || s || c || (e.preventDefault(), y(!0), requestAnimationFrame(() => {
82
- if (l.current?.querySelector('[role="option"][aria-selected="true"]')) return;
83
- const t = l.current?.querySelectorAll('[role="option"]:not([aria-disabled="true"])');
85
+ e.key !== "ArrowDown" && e.key !== "ArrowUp" || s || c || (e.preventDefault(), h(!0), requestAnimationFrame(() => {
86
+ if (a.current?.querySelector('[role="option"][aria-selected="true"]')) return;
87
+ const t = a.current?.querySelectorAll('[role="option"]:not([aria-disabled="true"])');
84
88
  t?.length && t[e.key === "ArrowUp" ? t.length - 1 : 0]?.focus();
85
89
  }));
86
- }, ye = (e) => {
87
- const t = l.current ? Array.from(l.current.querySelectorAll('[role="option"]:not([aria-disabled="true"])')) : [];
90
+ }, De = (e) => {
91
+ const t = a.current ? Array.from(a.current.querySelectorAll('[role="option"]:not([aria-disabled="true"])')) : [];
88
92
  if (t.length === 0) return;
89
- const b = t.findIndex((C) => C === document.activeElement);
90
- e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), t[(b + (e.key === "ArrowDown" ? 1 : -1) + t.length) % t.length]?.focus()) : (e.key === "Enter" || e.key === " ") && (e.preventDefault(), document.activeElement?.click());
91
- }, S = g && (o || x), xe = s ? "text-delta-300" : S ? "text-gama-500" : "text-delta-800", be = s ? "text-delta-300" : "text-delta-700";
92
- return /* @__PURE__ */ h("div", {
93
- className: f("group relative inline-flex flex-col", J && "w-full", Q),
93
+ const x = t.findIndex((P) => P === document.activeElement);
94
+ e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), t[(x + (e.key === "ArrowDown" ? 1 : -1) + t.length) % t.length]?.focus()) : (e.key === "Enter" || e.key === " ") && (e.preventDefault(), document.activeElement?.click());
95
+ }, N = y && (o || b), Fe = s ? "text-delta-300" : N ? "text-gama-500" : "text-delta-800", Ee = s ? "text-delta-300" : "text-delta-700";
96
+ return /* @__PURE__ */ w("div", {
97
+ ref: ue,
98
+ className: u("group relative inline-flex flex-col", re && "w-full", oe),
94
99
  style: {
95
100
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
96
- ...he(Z),
97
- ...X
101
+ ...Ce(ne),
102
+ ...se
98
103
  },
99
104
  children: [
100
- /* @__PURE__ */ h("button", {
101
- ref: ce,
105
+ /* @__PURE__ */ w("button", {
106
+ ref: xe,
102
107
  type: "button",
103
- "data-testid": q,
104
- ...le({ onKeyDown: ge }),
108
+ "data-testid": L,
109
+ ...he({ onKeyDown: Se }),
105
110
  role: "combobox",
106
111
  "aria-haspopup": "listbox",
107
112
  "aria-expanded": o,
108
- "aria-controls": j,
109
- "aria-labelledby": p,
110
- "aria-label": p ? void 0 : m,
113
+ "aria-controls": H,
114
+ "aria-labelledby": g,
115
+ "aria-label": g ? void 0 : p,
116
+ "aria-invalid": l ? !0 : void 0,
117
+ "aria-describedby": S ? K : void 0,
111
118
  "aria-disabled": s ? !0 : void 0,
112
119
  disabled: s,
113
120
  onFocus: (e) => {
114
- R(!0), re?.(e);
121
+ D(!0), ae?.(e);
115
122
  },
116
123
  onBlur: (e) => {
117
- R(!1), oe?.(e);
124
+ D(!1), ce?.(e);
118
125
  },
119
- style: { minWidth: a && !g ? 105 : void 0 },
120
- className: f("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors", S ? "bg-gama-50" : "bg-transparent", xe, g && "min-w-0", s && "cursor-not-allowed", c && "pointer-events-none"),
126
+ style: { minWidth: i && !y ? 105 : void 0 },
127
+ className: u("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors", N ? "bg-gama-50" : "bg-transparent", Fe, y && "min-w-0", s && "cursor-not-allowed", c && "pointer-events-none"),
121
128
  children: [
122
129
  /* @__PURE__ */ n("span", {
123
- className: f("min-w-0 flex-1 truncate", !a && "text-delta-500"),
124
- children: a || A ? pe : w
130
+ className: u("min-w-0 flex-1 truncate", !i && "text-delta-500"),
131
+ children: i || v ? ke : A
125
132
  }),
126
- /* @__PURE__ */ h("span", {
133
+ /* @__PURE__ */ w("span", {
127
134
  className: "flex items-center gap-1",
128
- children: [U && a && !s && /* @__PURE__ */ n("span", {
135
+ children: [V && i && !s && /* @__PURE__ */ n("span", {
129
136
  "aria-hidden": "true",
130
137
  "data-testid": "select-clear-button",
131
138
  className: "flex items-center justify-center rounded-full p-[2px] hover:bg-gama-100",
132
139
  onClick: (e) => {
133
- e.stopPropagation(), O();
140
+ e.stopPropagation(), W();
134
141
  },
135
- children: /* @__PURE__ */ n(Ae, {
142
+ children: /* @__PURE__ */ n(Pe, {
136
143
  width: 18,
137
144
  height: 18
138
145
  })
139
- }), /* @__PURE__ */ n(we, {
146
+ }), /* @__PURE__ */ n(Ne, {
140
147
  width: 24,
141
148
  height: 24,
142
- className: f("shrink-0 transition-transform", S ? "text-gama-500" : be, o && "rotate-180")
149
+ className: u("shrink-0 transition-transform", N ? "text-gama-500" : Ee, o && "rotate-180")
143
150
  })]
144
151
  }),
145
- /* @__PURE__ */ n("div", { className: Ce({
146
- focused: o || x,
147
- error: B,
152
+ /* @__PURE__ */ n("div", { className: je({
153
+ focused: o || b,
154
+ error: l,
148
155
  disabled: s,
149
156
  readOnly: c,
150
- borderless: g
157
+ borderless: y
151
158
  }) })
152
159
  ]
153
160
  }),
154
- o && /* @__PURE__ */ n(qe, {
155
- root: M,
161
+ o && /* @__PURE__ */ n(ze, {
162
+ root: z,
156
163
  children: /* @__PURE__ */ n("ul", {
157
- ref: ue,
158
- id: j,
164
+ ref: we,
165
+ id: H,
159
166
  role: "listbox",
160
- "aria-labelledby": p,
161
- "aria-label": p ? void 0 : m,
162
- ...D ? Re : {},
167
+ "aria-labelledby": g,
168
+ "aria-label": g ? void 0 : p,
169
+ ...C ? qe : {},
163
170
  style: {
164
- ...D ? ke : {},
165
- ...ae,
171
+ ...C ? Ie : {},
172
+ ...ye,
166
173
  fontFamily: "Roboto, Helvetica, Arial, sans-serif"
167
174
  },
168
- ...ie(),
169
- onKeyDown: ye,
170
- className: f("z-[1300] m-0 max-h-72 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white px-0 py-1 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", te?.className),
171
- children: fe
175
+ ...be(),
176
+ onKeyDown: De,
177
+ className: u("z-[1300] m-0 max-h-72 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white px-0 py-1 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", ie?.className),
178
+ children: ve
172
179
  })
173
180
  }),
174
- B && /* @__PURE__ */ h(Ne, {
175
- className: "m-0 flex items-center gap-1 pt-1 text-sm text-error-500",
176
- children: [/* @__PURE__ */ n(ve, {
181
+ S && /* @__PURE__ */ w("div", {
182
+ ref: fe,
183
+ id: K,
184
+ role: de,
185
+ className: u("m-0 mr-[14px] box-border flex min-h-[24px] items-center gap-1 pt-1 text-sm leading-5 tracking-[0.03333em]", l ? "text-error-500" : "text-delta-600"),
186
+ style: me,
187
+ children: [l && /* @__PURE__ */ n(_e, {
177
188
  width: 20,
178
- height: 20
179
- }), $ ?? "Required"]
189
+ height: 20,
190
+ className: "min-w-5 shrink-0"
191
+ }), /* @__PURE__ */ n("span", { children: k })]
180
192
  })
181
193
  ]
182
194
  });
183
195
  };
184
196
  export {
185
- rt as StyledSelect
197
+ ht as StyledSelect
186
198
  };
@@ -1,24 +1,24 @@
1
1
  import { cn as L } from "../../../helpers/cn.js";
2
- import { ChevronDownIcon as He } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
3
- import { CloseIcon as Ye } from "../../icons/close-icon/CloseIcon.js";
4
- import { CheckIcon as Oe } from "../../icons/check-icon/CheckIcon.js";
5
- import { PlusIconCircle as Be } from "../../icons/plus-icon-circle/PlusIconCircle.js";
6
- import { StyledChip as qe } from "../../data-display/chip/StyledChip.js";
2
+ import { ChevronDownIcon as Oe } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
3
+ import { CloseIcon as Be } from "../../icons/close-icon/CloseIcon.js";
4
+ import { CheckIcon as qe } from "../../icons/check-icon/CheckIcon.js";
5
+ import { PlusIconCircle as Ge } from "../../icons/plus-icon-circle/PlusIconCircle.js";
6
+ import { StyledChip as Je } from "../../data-display/chip/StyledChip.js";
7
7
  import { StyledCheckbox as Q } from "../checkbox/base-ui/StyledCheckbox.js";
8
- import { TOP_LAYER_PROPS as Ge, TOP_LAYER_RESET_STYLE as Je, getOpenModalDialogAncestor as Qe, shouldUsePopoverTopLayer as Xe, useTopLayerRef as Ze } from "../../../hooks/useTopLayer.hook.js";
9
- import { LoadingIcon as Ke } from "../../../table/shared-components/LoadingIcon.js";
8
+ import { TOP_LAYER_PROPS as Qe, TOP_LAYER_RESET_STYLE as Xe, getOpenModalDialogAncestor as Ze, shouldUsePopoverTopLayer as Ke, useTopLayerRef as et } from "../../../hooks/useTopLayer.hook.js";
9
+ import { LoadingIcon as tt } from "../../../table/shared-components/LoadingIcon.js";
10
10
  import _ from "./StyledSelectAutocomplete.module.js";
11
- import { useEffect as et, useMemo as E, useRef as X, useState as w } from "react";
11
+ import { useEffect as rt, useMemo as E, useRef as X, useState as w } from "react";
12
12
  import { jsx as s, jsxs as y } from "react/jsx-runtime";
13
- import { FloatingPortal as tt, autoUpdate as rt, flip as lt, offset as st, shift as ot, size as at, useDismiss as nt, useFloating as ct, useInteractions as it, useMergeRefs as Z, useRole as dt } from "@floating-ui/react";
14
- var ut = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), K = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
15
- function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, getOptionLabel: te, getOptionKey: R, isOptionEqualToValue: j, renderOption: z, renderValue: F, filterOptions: $, loading: W, loadingText: re = "Loading…", noOptionsText: le = "No options", disabled: D, readOnly: m, size: se = "small", disableClearable: oe, disableCloseOnSelect: ae, popupIcon: ne, autoHeight: ce, multiple: ie, allowSelectAll: de, selectAllLabel: U = "Select all", fullWidth: ue, classes: pe, inputValue: S, onInputChange: me, open: T, onOpen: fe, onClose: he, className: ge, wrapperClassName: be, getOptionDisabled: xe, slotProps: V }) {
16
- const o = ie === !0, n = te ?? ut, C = (e, t) => j ? j(e, t) : e === t, [we, ye] = w(!1), a = T ?? we, f = (e) => {
17
- e && (m || D) || (T === void 0 && ye(e), e ? fe?.() : he?.());
18
- }, [ve, H] = w(""), h = S ?? ve, P = (e, t, r) => {
19
- S === void 0 && H(t), me?.(e, t, r);
20
- }, [b, k] = w(null), Ne = X([]), Y = X(null), [Re, De] = w(null), [Se, Ce] = w(null), c = o ? Array.isArray(v) ? v : [] : [], g = o ? null : v ?? null, O = !o && g !== null ? n(g) : "";
21
- et(() => {
13
+ import { FloatingPortal as lt, autoUpdate as st, flip as ot, offset as at, shift as nt, size as ct, useDismiss as it, useFloating as dt, useInteractions as ut, useMergeRefs as Z, useRole as pt } from "@floating-ui/react";
14
+ var mt = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), K = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
15
+ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, getOptionLabel: te, getOptionKey: R, isOptionEqualToValue: j, renderOption: z, renderValue: F, filterOptions: $, loading: W, loadingText: re = "Loading…", noOptionsText: le = "No options", disabled: D, readOnly: m, error: se, helperText: oe, size: ae = "small", disableClearable: ne, disableCloseOnSelect: ce, popupIcon: ie, autoHeight: de, multiple: ue, allowSelectAll: pe, selectAllLabel: U = "Select all", fullWidth: me, classes: fe, inputValue: S, onInputChange: he, open: T, onOpen: ge, onClose: be, className: xe, wrapperClassName: we, getOptionDisabled: ye, slotProps: V }) {
16
+ const o = ue === !0, n = te ?? mt, C = (e, t) => j ? j(e, t) : e === t, [ve, Ne] = w(!1), a = T ?? ve, f = (e) => {
17
+ e && (m || D) || (T === void 0 && Ne(e), e ? ge?.() : be?.());
18
+ }, [Re, H] = w(""), h = S ?? Re, P = (e, t, r) => {
19
+ S === void 0 && H(t), he?.(e, t, r);
20
+ }, [b, k] = w(null), De = X([]), Y = X(null), [Se, Ce] = w(null), [Pe, Ae] = w(null), c = o ? Array.isArray(v) ? v : [] : [], g = o ? null : v ?? null, O = !o && g !== null ? n(g) : "";
21
+ rt(() => {
22
22
  S !== void 0 || o || H(O);
23
23
  }, [
24
24
  S,
@@ -37,29 +37,29 @@ function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
37
37
  h,
38
38
  $,
39
39
  v
40
- ]), i = E(() => q.slice(0, 100), [q]), { refs: A, floatingStyles: Pe, context: G } = ct({
40
+ ]), i = E(() => q.slice(0, 100), [q]), { refs: A, floatingStyles: Le, context: G } = dt({
41
41
  open: a,
42
42
  onOpenChange: f,
43
43
  placement: "bottom-start",
44
44
  strategy: "fixed",
45
- whileElementsMounted: rt,
45
+ whileElementsMounted: st,
46
46
  middleware: [
47
- st(4),
48
- lt({ padding: 8 }),
47
+ at(4),
49
48
  ot({ padding: 8 }),
50
- at({ apply({ rects: e, availableHeight: t }) {
51
- De(e.reference.width), Ce(ce ? t - 8 : Math.min(t - 8, 320));
49
+ nt({ padding: 8 }),
50
+ ct({ apply({ rects: e, availableHeight: t }) {
51
+ Ce(e.reference.width), Ae(de ? t - 8 : Math.min(t - 8, 320));
52
52
  } })
53
53
  ]
54
- }), { getReferenceProps: Ae, getFloatingProps: Le, getItemProps: $e } = it([nt(G), dt(G, { role: "listbox" })]), ke = Z([A.setReference]), J = E(() => a ? Qe(A.reference.current) : void 0, [a, A]), I = Xe(J), Ie = Z([Ze(A.setFloating, I)]), M = (e, t) => {
54
+ }), { getReferenceProps: $e, getFloatingProps: ke, getItemProps: Ie } = ut([it(G), pt(G, { role: "listbox" })]), Me = Z([A.setReference]), J = E(() => a ? Ze(A.reference.current) : void 0, [a, A]), I = Ke(J), _e = Z([et(A.setFloating, I)]), 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
- N?.(e, d, r ? "removeOption" : "selectOption", { option: t }), P(e, "", "reset"), ae || f(!1);
57
+ N?.(e, d, r ? "removeOption" : "selectOption", { option: t }), P(e, "", "reset"), ce || f(!1);
58
58
  } else
59
59
  N?.(e, t, "selectOption", { option: t }), P(e, n(t), "reset"), f(!1);
60
- }, Me = (e) => {
60
+ }, Ee = (e) => {
61
61
  N?.(e, o ? [] : null, "clear", void 0), P(e, "", "clear");
62
- }, _e = (e) => {
62
+ }, je = (e) => {
63
63
  if (e.key === "Enter" && a && b != null && i[b] != null) {
64
64
  e.preventDefault();
65
65
  const t = i[b];
@@ -73,30 +73,30 @@ function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
73
73
  const t = e.key === "ArrowDown" ? 1 : -1;
74
74
  k((r) => r == null ? t > 0 ? 0 : i.length - 1 : (r + t + i.length) % i.length);
75
75
  }
76
- }, Ee = !oe && !m && !D && (o ? c.length > 0 : g !== null), je = (e) => {
76
+ }, ze = !ne && !m && !D && (o ? c.length > 0 : g !== null), Fe = (e) => {
77
77
  e.preventDefault(), !(D || m) && (Y.current?.focus(), f(!a));
78
- }, ze = o ? F ? F(c, ({ index: e }) => ({ "data-index": e })) : c.map((e, t) => /* @__PURE__ */ s(qe, {
78
+ }, We = o ? F ? F(c, ({ index: e }) => ({ "data-index": e })) : c.map((e, t) => /* @__PURE__ */ s(Je, {
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
- }, R ? R(e) : `${n(e)}-${t}`)) : void 0, Fe = /* @__PURE__ */ y("span", {
83
+ }, R ? R(e) : `${n(e)}-${t}`)) : void 0, Ue = /* @__PURE__ */ y("span", {
84
84
  className: "flex items-center gap-1",
85
85
  children: [
86
- W && /* @__PURE__ */ s(Ke, {
86
+ W && /* @__PURE__ */ s(tt, {
87
87
  width: 20,
88
88
  height: 20,
89
89
  className: "animate-spin"
90
90
  }),
91
- Ee && /* @__PURE__ */ s("button", {
91
+ ze && /* @__PURE__ */ s("button", {
92
92
  type: "button",
93
93
  "aria-label": "Clear",
94
94
  "data-testid": `${l}-clear`,
95
95
  className: "flex min-h-6 min-w-6 cursor-pointer items-center justify-center rounded-full border-0 bg-delta-50",
96
96
  onMouseDown: (e) => {
97
- e.preventDefault(), Me(e);
97
+ e.preventDefault(), Ee(e);
98
98
  },
99
- children: /* @__PURE__ */ s(Ye, {
99
+ children: /* @__PURE__ */ s(Be, {
100
100
  width: 20,
101
101
  height: 20,
102
102
  className: "text-delta-700"
@@ -108,30 +108,32 @@ function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
108
108
  "aria-expanded": a,
109
109
  "data-testid": `${l}-popup-indicator`,
110
110
  className: "flex cursor-pointer items-center border-0 bg-transparent",
111
- onMouseDown: je,
112
- children: ne ?? (o ? /* @__PURE__ */ s(Be, {
111
+ onMouseDown: Fe,
112
+ children: ie ?? (o ? /* @__PURE__ */ s(Ge, {
113
113
  width: 24,
114
114
  height: 24,
115
115
  className: "text-delta-700"
116
- }) : /* @__PURE__ */ s(He, {
116
+ }) : /* @__PURE__ */ s(Oe, {
117
117
  width: 24,
118
118
  height: 24,
119
119
  className: L(_["select-custom-icon"], a && _["select-custom-icon-open"], "text-delta-700")
120
120
  }))
121
121
  })
122
122
  ]
123
- }), We = {
123
+ }), Te = {
124
124
  disabled: D,
125
- size: se,
125
+ size: ae,
126
126
  fullWidth: !0,
127
+ error: se,
128
+ helperText: oe,
127
129
  value: h,
128
130
  onChange: (e) => {
129
131
  P(e, e.target.value, "input"), a || f(!0);
130
132
  },
131
- onKeyDown: _e,
133
+ onKeyDown: je,
132
134
  slotProps: {
133
135
  htmlInput: {
134
- ...Ae(),
136
+ ...$e(),
135
137
  ref: Y,
136
138
  onClick: () => f(!0),
137
139
  role: "combobox",
@@ -142,12 +144,12 @@ function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
142
144
  readOnly: m
143
145
  },
144
146
  input: {
145
- ref: ke,
146
- startAdornment: ze,
147
- endAdornment: Fe
147
+ ref: Me,
148
+ startAdornment: We,
149
+ endAdornment: Ue
148
150
  }
149
151
  }
150
- }, Ue = L("box-border flex min-h-10 cursor-pointer items-center gap-x-3 px-3 py-1.5 text-base text-delta-800 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"), Te = (e, t, r) => {
152
+ }, Ve = L("box-border flex min-h-10 cursor-pointer items-center gap-x-3 px-3 py-1.5 text-base text-delta-800 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"), He = (e, t, r) => {
151
153
  const { key: d, ...u } = e;
152
154
  return /* @__PURE__ */ y("li", {
153
155
  ...u,
@@ -159,7 +161,7 @@ function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
159
161
  decorative: !0
160
162
  }) : /* @__PURE__ */ s("span", {
161
163
  className: "w-5",
162
- children: r.selected && /* @__PURE__ */ s(Oe, {
164
+ children: r.selected && /* @__PURE__ */ s(qe, {
163
165
  width: 20,
164
166
  height: 20,
165
167
  className: "text-gama-500"
@@ -169,9 +171,9 @@ function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
169
171
  children: n(t)
170
172
  })]
171
173
  }, d);
172
- }, Ve = (e, t) => {
173
- const r = xe?.(e) ?? K(e), d = {
174
- ...$e({
174
+ }, Ye = (e, t) => {
175
+ const r = ye?.(e) ?? K(e), d = {
176
+ ...Ie({
175
177
  onMouseDown: (x) => x.preventDefault(),
176
178
  onClick: (x) => {
177
179
  r || M(x, e);
@@ -180,39 +182,39 @@ function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
180
182
  }),
181
183
  key: R ? String(R(e)) : `${n(e)}-${t}`,
182
184
  ref: (x) => {
183
- Ne.current[t] = x;
185
+ De.current[t] = x;
184
186
  },
185
187
  role: "option",
186
188
  id: `${l}-option-${t}`,
187
189
  "aria-selected": B(e),
188
190
  "aria-disabled": r || void 0,
189
191
  "data-active": b === t ? "" : void 0,
190
- className: Ue
192
+ className: Ve
191
193
  }, u = {
192
194
  selected: B(e),
193
195
  index: t,
194
196
  inputValue: h
195
197
  };
196
- return z ? z(d, e, u) : Te(d, e, u);
198
+ return z ? z(d, e, u) : He(d, e, u);
197
199
  };
198
200
  return /* @__PURE__ */ y("div", {
199
- className: L(_.styledSelectAutocompleteWrapper, !ue && "w-auto", be, ge),
200
- children: [ee(We), a && /* @__PURE__ */ s(tt, {
201
+ className: L(_.styledSelectAutocompleteWrapper, !me && "w-auto", we, xe),
202
+ children: [ee(Te), a && /* @__PURE__ */ s(lt, {
201
203
  root: J,
202
204
  children: /* @__PURE__ */ y("ul", {
203
- ref: Ie,
204
- ...I ? Ge : {},
205
+ ref: _e,
206
+ ...I ? Qe : {},
205
207
  style: {
206
- ...I ? Je : {},
207
- ...Pe,
208
- width: Re ?? void 0,
209
- maxHeight: Se ?? void 0,
208
+ ...I ? Xe : {},
209
+ ...Le,
210
+ width: Se ?? void 0,
211
+ maxHeight: Pe ?? void 0,
210
212
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
211
213
  ...V?.popper?.style
212
214
  },
213
- ...Le(),
214
- className: L("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)]", pe?.listbox, V?.popper?.className),
215
- children: [de && o && /* @__PURE__ */ y("div", {
215
+ ...ke(),
216
+ className: L("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)]", fe?.listbox, V?.popper?.className),
217
+ children: [pe && o && /* @__PURE__ */ y("div", {
216
218
  role: "group",
217
219
  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",
218
220
  children: [/* @__PURE__ */ s(Q, {
@@ -238,11 +240,11 @@ function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
238
240
  role: "presentation",
239
241
  className: "px-3 py-2 text-sm text-delta-600",
240
242
  children: le
241
- }) : i.map(Ve)]
243
+ }) : i.map(Ye)]
242
244
  })
243
245
  })]
244
246
  });
245
247
  }
246
248
  export {
247
- St as StyledSelectAutocomplete
249
+ Pt as StyledSelectAutocomplete
248
250
  };