@pismo/marola 1.0.0-beta.21 → 1.0.0-beta.23

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 (44) hide show
  1. package/dist/{Button-DiLqcAJG.js → Button-BAljjMv3.js} +2 -2
  2. package/dist/{ClickAwayListener-BaJ-OV_7.js → ClickAwayListener-DbEYZpyh.js} +3 -3
  3. package/dist/{Popup-lLWZt2wk.js → Popup-Ck3XlWMq.js} +3 -3
  4. package/dist/{Portal-B_Es6eUL.js → Portal-oY3enyAm.js} +2 -2
  5. package/dist/SelectButton-oWzluvmj.js +63 -0
  6. package/dist/{Toggle-CRfZgFJp.js → Toggle-Buew6bzm.js} +8 -7
  7. package/dist/assets/Autocomplete.css +1 -1
  8. package/dist/assets/SelectButton.css +1 -1
  9. package/dist/{combineHooksSlotProps-BtBYUV_B.js → combineHooksSlotProps-C-zYvfnF.js} +1 -1
  10. package/dist/components/Autocomplete/Autocomplete.d.ts +8 -39
  11. package/dist/components/Autocomplete/Autocomplete.js +369 -400
  12. package/dist/components/Autocomplete/Autocomplete.stories.d.ts +2 -1
  13. package/dist/components/Button/Button.js +1 -1
  14. package/dist/components/Chip/Chip.js +4 -3
  15. package/dist/components/Dialog/CloseIconButton.js +1 -1
  16. package/dist/components/Dialog/Dialog.js +4 -4
  17. package/dist/components/Dialog/Dialog.stories.d.ts +1 -1
  18. package/dist/components/IconButton/IconButton.js +1 -1
  19. package/dist/components/Input/Input.d.ts +41 -2
  20. package/dist/components/Input/Input.js +500 -100
  21. package/dist/components/Input/Input.stories.d.ts +3 -3
  22. package/dist/components/InputSearch/InputSearch.stories.d.ts +2 -2
  23. package/dist/components/ResultWithChips/ResultWithChips.js +1 -1
  24. package/dist/components/RowItem/RowItem.js +4 -3
  25. package/dist/components/Select/Select.d.ts +6 -0
  26. package/dist/components/Select/Select.js +391 -358
  27. package/dist/components/Select/SelectButton.js +1 -1
  28. package/dist/components/Snackbar/Snackbar.js +3 -3
  29. package/dist/components/Tabs/Tab.js +3 -3
  30. package/dist/components/Tabs/TabPanel.js +1 -1
  31. package/dist/components/Tabs/Tabs.js +3 -3
  32. package/dist/components/Toggle/Toggle.js +1 -1
  33. package/dist/components/ToggleGroup/Toggle.js +3 -2
  34. package/dist/components/ToggleGroup/ToggleGroup.js +1 -1
  35. package/dist/components/Tooltip/Tooltip.js +3 -3
  36. package/dist/{index-D3Wj0eid.js → index-bQFToy-I.js} +1 -1
  37. package/dist/main.js +1 -1
  38. package/dist/{ownerDocument-B61GUaFs.js → ownerDocument-YGhwAnr1.js} +1 -1
  39. package/dist/{useButton-Bn3MNH8I.js → useButton-DcihopJG.js} +1 -1
  40. package/dist/{useList-BpJT77u3.js → useList-B9C55YB7.js} +2 -2
  41. package/dist/{useSlotProps-kRhf7Gil.js → useSlotProps-C_I1kEHr.js} +73 -72
  42. package/package.json +1 -1
  43. package/dist/Input.module-ZTRZRcNt.js +0 -405
  44. package/dist/SelectButton-CoOT2txy.js +0 -61
@@ -1,358 +1,356 @@
1
1
  import '../../assets/Autocomplete.css';
2
- import { jsxs as qe, jsx as A } from "react/jsx-runtime";
3
- import * as g from "react";
4
- import { useId as pt, useState as Be } from "react";
5
- import { c as ee } from "../../clsx-DB4S2d7J.js";
6
- import { Icon as Ue } from "../Icon/Icon.js";
7
- import { s as T, I as gt } from "../../Input.module-ZTRZRcNt.js";
8
- import { Typography as Ke } from "../Typography/Typography.js";
9
- import { b as je, s as ht } from "../../useSlotProps-kRhf7Gil.js";
10
- import { u as mt } from "../../useId-BW-oWmul.js";
11
- import { u as $e } from "../../useControlled-CCMYYdCM.js";
12
- import { u as me } from "../../useEventCallback-BAQJJ3ye.js";
13
- const bt = (u) => {
14
- const b = g.useRef({});
15
- return g.useEffect(() => {
16
- b.current = u;
2
+ import { jsx as le, jsxs as lt } from "react/jsx-runtime";
3
+ import * as h from "react";
4
+ import { useId as at, useState as ut, createElement as ct } from "react";
5
+ import { Icon as ft } from "../Icon/Icon.js";
6
+ import { Input as dt } from "../Input/Input.js";
7
+ import { b as Ve, s as pt } from "../../useSlotProps-C_I1kEHr.js";
8
+ import { u as gt } from "../../useId-BW-oWmul.js";
9
+ import { u as Oe } from "../../useControlled-CCMYYdCM.js";
10
+ import { u as ae } from "../../useEventCallback-BAQJJ3ye.js";
11
+ const ht = (c) => {
12
+ const b = h.useRef({});
13
+ return h.useEffect(() => {
14
+ b.current = c;
17
15
  }), b.current;
18
16
  };
19
- function ze(u) {
20
- return typeof u.normalize < "u" ? u.normalize("NFD").replace(/[\u0300-\u036f]/g, "") : u;
17
+ function Me(c) {
18
+ return typeof c.normalize < "u" ? c.normalize("NFD").replace(/[\u0300-\u036f]/g, "") : c;
21
19
  }
22
- function xt(u = {}) {
20
+ function mt(c = {}) {
23
21
  const {
24
22
  ignoreAccents: b = !0,
25
- ignoreCase: h = !0,
26
- limit: V,
27
- matchFrom: B = "any",
28
- stringify: $,
29
- trim: M = !1
30
- } = u;
31
- return (D, {
32
- inputValue: U,
33
- getOptionLabel: m
23
+ ignoreCase: g = !0,
24
+ limit: P,
25
+ matchFrom: U = "any",
26
+ stringify: N,
27
+ trim: C = !1
28
+ } = c;
29
+ return (v, {
30
+ inputValue: L,
31
+ getOptionLabel: x
34
32
  }) => {
35
- let k = M ? U.trim() : U;
36
- h && (k = k.toLowerCase()), b && (k = ze(k));
37
- const H = k ? D.filter((K) => {
38
- let I = ($ || m)(K);
39
- return h && (I = I.toLowerCase()), b && (I = ze(I)), B === "start" ? I.indexOf(k) === 0 : I.indexOf(k) > -1;
40
- }) : D;
41
- return typeof V == "number" ? H.slice(0, V) : H;
33
+ let k = C ? L.trim() : L;
34
+ g && (k = k.toLowerCase()), b && (k = Me(k));
35
+ const F = k ? v.filter((j) => {
36
+ let w = (N || x)(j);
37
+ return g && (w = w.toLowerCase()), b && (w = Me(w)), U === "start" ? w.indexOf(k) === 0 : w.indexOf(k) > -1;
38
+ }) : v;
39
+ return typeof P == "number" ? F.slice(0, P) : F;
42
40
  };
43
41
  }
44
- function be(u, b) {
45
- for (let h = 0; h < u.length; h += 1)
46
- if (b(u[h]))
47
- return h;
42
+ function ue(c, b) {
43
+ for (let g = 0; g < c.length; g += 1)
44
+ if (b(c[g]))
45
+ return g;
48
46
  return -1;
49
47
  }
50
- const yt = xt(), Je = 5, Ot = (u) => {
48
+ const bt = mt(), Re = 5, xt = (c) => {
51
49
  var b;
52
- return u.current !== null && ((b = u.current.parentElement) == null ? void 0 : b.contains(document.activeElement));
50
+ return c.current !== null && ((b = c.current.parentElement) == null ? void 0 : b.contains(document.activeElement));
53
51
  };
54
- function It(u) {
52
+ function yt(c) {
55
53
  const {
56
54
  // eslint-disable-next-line @typescript-eslint/naming-convention
57
- unstable_isActiveElementInListbox: b = Ot,
55
+ unstable_isActiveElementInListbox: b = xt,
58
56
  // eslint-disable-next-line @typescript-eslint/naming-convention
59
- unstable_classNamePrefix: h = "Mui",
60
- autoComplete: V = !1,
61
- autoHighlight: B = !1,
62
- autoSelect: $ = !1,
63
- blurOnSelect: M = !1,
64
- clearOnBlur: D = !u.freeSolo,
65
- clearOnEscape: U = !1,
66
- componentName: m = "useAutocomplete",
67
- defaultValue: k = u.multiple ? [] : null,
68
- disableClearable: H = !1,
69
- disableCloseOnSelect: K = !1,
70
- disabled: I,
71
- disabledItemsFocusable: xe = !1,
72
- disableListWrap: te = !1,
73
- filterOptions: ye = yt,
74
- filterSelectedOptions: ne = !1,
75
- freeSolo: R = !1,
76
- getOptionDisabled: j,
77
- getOptionKey: oe,
78
- getOptionLabel: W = (t) => {
57
+ unstable_classNamePrefix: g = "Mui",
58
+ autoComplete: P = !1,
59
+ autoHighlight: U = !1,
60
+ autoSelect: N = !1,
61
+ blurOnSelect: C = !1,
62
+ clearOnBlur: v = !c.freeSolo,
63
+ clearOnEscape: L = !1,
64
+ componentName: x = "useAutocomplete",
65
+ defaultValue: k = c.multiple ? [] : null,
66
+ disableClearable: F = !1,
67
+ disableCloseOnSelect: j = !1,
68
+ disabled: w,
69
+ disabledItemsFocusable: ce = !1,
70
+ disableListWrap: K = !1,
71
+ filterOptions: fe = bt,
72
+ filterSelectedOptions: G = !1,
73
+ freeSolo: i = !1,
74
+ getOptionDisabled: m,
75
+ getOptionKey: Q,
76
+ getOptionLabel: z = (t) => {
79
77
  var e;
80
78
  return (e = t.label) != null ? e : t;
81
79
  },
82
- groupBy: z,
83
- handleHomeEndKeys: re = !u.freeSolo,
84
- id: Oe,
85
- includeInputInList: se = !1,
86
- inputValue: Ie,
87
- isOptionEqualToValue: E = (t, e) => t === e,
88
- multiple: i = !1,
89
- onChange: ie,
90
- onClose: le,
91
- onHighlightChange: X,
92
- onInputChange: v,
93
- onOpen: ae,
94
- open: we,
95
- openOnFocus: p = !1,
96
- options: w,
97
- readOnly: G = !1,
98
- selectOnFocus: Ye = !u.freeSolo,
99
- value: We
100
- } = u, S = mt(Oe);
101
- let y = W;
102
- y = (t) => {
103
- const e = W(t);
80
+ groupBy: E,
81
+ handleHomeEndKeys: Z = !c.freeSolo,
82
+ id: de,
83
+ includeInputInList: Ie = !1,
84
+ inputValue: He,
85
+ isOptionEqualToValue: V = (t, e) => t === e,
86
+ multiple: u = !1,
87
+ onChange: we,
88
+ onClose: Se,
89
+ onHighlightChange: ke,
90
+ onInputChange: M,
91
+ onOpen: Ee,
92
+ open: Fe,
93
+ openOnFocus: qe = !1,
94
+ options: pe,
95
+ readOnly: J = !1,
96
+ selectOnFocus: Be = !c.freeSolo,
97
+ value: Ue
98
+ } = c, T = gt(de);
99
+ let O = z;
100
+ O = (t) => {
101
+ const e = z(t);
104
102
  if (typeof e != "string") {
105
103
  if (process.env.NODE_ENV !== "production") {
106
104
  const n = e === void 0 ? "undefined" : `${typeof e} (${e})`;
107
- console.error(`MUI: The \`getOptionLabel\` method of ${m} returned ${n} instead of a string for ${JSON.stringify(t)}.`);
105
+ console.error(`MUI: The \`getOptionLabel\` method of ${x} returned ${n} instead of a string for ${JSON.stringify(t)}.`);
108
106
  }
109
107
  return String(e);
110
108
  }
111
109
  return e;
112
110
  };
113
- const _e = g.useRef(!1), ke = g.useRef(!0), f = g.useRef(null), N = g.useRef(null), [ue, Xe] = g.useState(null), [P, Se] = g.useState(-1), De = B ? 0 : -1, x = g.useRef(De), [o, Ge] = $e({
114
- controlled: We,
111
+ const ge = h.useRef(!1), he = h.useRef(!0), d = h.useRef(null), _ = h.useRef(null), [ee, je] = h.useState(null), [$, me] = h.useState(-1), Te = U ? 0 : -1, y = h.useRef(Te), [o, Ke] = Oe({
112
+ controlled: Ue,
115
113
  default: k,
116
- name: m
117
- }), [a, ce] = $e({
118
- controlled: Ie,
114
+ name: x
115
+ }), [a, te] = Oe({
116
+ controlled: He,
119
117
  default: "",
120
- name: m,
118
+ name: x,
121
119
  state: "inputValue"
122
- }), [fe, Ee] = g.useState(!1), de = g.useCallback((t, e) => {
123
- if (!(i ? o.length < e.length : e !== null) && !D)
120
+ }), [ne, _e] = h.useState(!1), oe = h.useCallback((t, e) => {
121
+ if (!(u ? o.length < e.length : e !== null) && !v)
124
122
  return;
125
123
  let r;
126
- if (i)
124
+ if (u)
127
125
  r = "";
128
126
  else if (e == null)
129
127
  r = "";
130
128
  else {
131
- const s = y(e);
129
+ const s = O(e);
132
130
  r = typeof s == "string" ? s : "";
133
131
  }
134
- a !== r && (ce(r), v && v(t, r, "reset"));
135
- }, [y, a, i, v, ce, D, o]), [J, ve] = $e({
136
- controlled: we,
132
+ a !== r && (te(r), M && M(t, r, "reset"));
133
+ }, [O, a, u, M, te, v, o]), [q, $e] = Oe({
134
+ controlled: Fe,
137
135
  default: !1,
138
- name: m,
136
+ name: x,
139
137
  state: "open"
140
- }), [Qe, Ce] = g.useState(!0), Le = !i && o != null && a === y(o), _ = J && !G, c = _ ? ye(
141
- w.filter((t) => !(ne && (i ? o : [o]).some((e) => e !== null && E(t, e)))),
138
+ }), [ze, Ae] = h.useState(!0), De = !u && o != null && a === O(o), S = q && !J, f = S ? fe(
139
+ pe.filter((t) => !(G && (u ? o : [o]).some((e) => e !== null && V(t, e)))),
142
140
  // we use the empty string to manipulate `filterOptions` to not filter any options
143
141
  // i.e. the filter predicate always returns true
144
142
  {
145
- inputValue: Le && Qe ? "" : a,
146
- getOptionLabel: y
143
+ inputValue: De && ze ? "" : a,
144
+ getOptionLabel: O
147
145
  }
148
- ) : [], C = bt({
149
- filteredOptions: c,
146
+ ) : [], A = ht({
147
+ filteredOptions: f,
150
148
  value: o,
151
149
  inputValue: a
152
150
  });
153
- g.useEffect(() => {
154
- const t = o !== C.value;
155
- fe && !t || R && !t || de(null, o);
156
- }, [o, de, fe, C.value, R]);
157
- const Ne = J && c.length > 0 && !G;
158
- if (process.env.NODE_ENV !== "production" && o !== null && !R && w.length > 0) {
159
- const t = (i ? o : [o]).filter((e) => !w.some((n) => E(n, e)));
160
- t.length > 0 && console.warn([`MUI: The value provided to ${m} is invalid.`, `None of the options match with \`${t.length > 1 ? JSON.stringify(t) : JSON.stringify(t[0])}\`.`, "You can use the `isOptionEqualToValue` prop to customize the equality test."].join(`
151
+ h.useEffect(() => {
152
+ const t = o !== A.value;
153
+ ne && !t || i && !t || oe(null, o);
154
+ }, [o, oe, ne, A.value, i]);
155
+ const be = q && f.length > 0 && !J;
156
+ if (process.env.NODE_ENV !== "production" && o !== null && !i && pe.length > 0) {
157
+ const t = (u ? o : [o]).filter((e) => !pe.some((n) => V(n, e)));
158
+ t.length > 0 && console.warn([`MUI: The value provided to ${x} is invalid.`, `None of the options match with \`${t.length > 1 ? JSON.stringify(t) : JSON.stringify(t[0])}\`.`, "You can use the `isOptionEqualToValue` prop to customize the equality test."].join(`
161
159
  `));
162
160
  }
163
- const pe = me((t) => {
164
- t === -1 ? f.current.focus() : ue.querySelector(`[data-tag-index="${t}"]`).focus();
161
+ const re = ae((t) => {
162
+ t === -1 ? d.current.focus() : ee.querySelector(`[data-tag-index="${t}"]`).focus();
165
163
  });
166
- g.useEffect(() => {
167
- i && P > o.length - 1 && (Se(-1), pe(-1));
168
- }, [o, i, P, pe]);
169
- function Ze(t, e) {
170
- if (!N.current || t < 0 || t >= c.length)
164
+ h.useEffect(() => {
165
+ u && $ > o.length - 1 && (me(-1), re(-1));
166
+ }, [o, u, $, re]);
167
+ function Je(t, e) {
168
+ if (!_.current || t < 0 || t >= f.length)
171
169
  return -1;
172
170
  let n = t;
173
171
  for (; ; ) {
174
- const r = N.current.querySelector(`[data-option-index="${n}"]`), s = xe ? !1 : !r || r.disabled || r.getAttribute("aria-disabled") === "true";
172
+ const r = _.current.querySelector(`[data-option-index="${n}"]`), s = ce ? !1 : !r || r.disabled || r.getAttribute("aria-disabled") === "true";
175
173
  if (r && r.hasAttribute("tabindex") && !s)
176
174
  return n;
177
- if (e === "next" ? n = (n + 1) % c.length : n = (n - 1 + c.length) % c.length, n === t)
175
+ if (e === "next" ? n = (n + 1) % f.length : n = (n - 1 + f.length) % f.length, n === t)
178
176
  return -1;
179
177
  }
180
178
  }
181
- const F = me(({
179
+ const R = ae(({
182
180
  event: t,
183
181
  index: e,
184
182
  reason: n = "auto"
185
183
  }) => {
186
- if (x.current = e, e === -1 ? f.current.removeAttribute("aria-activedescendant") : f.current.setAttribute("aria-activedescendant", `${S}-option-${e}`), X && X(t, e === -1 ? null : c[e], n), !N.current)
184
+ if (y.current = e, e === -1 ? d.current.removeAttribute("aria-activedescendant") : d.current.setAttribute("aria-activedescendant", `${T}-option-${e}`), ke && ke(t, e === -1 ? null : f[e], n), !_.current)
187
185
  return;
188
- const r = N.current.querySelector(`[role="option"].${h}-focused`);
189
- r && (r.classList.remove(`${h}-focused`), r.classList.remove(`${h}-focusVisible`));
190
- let s = N.current;
191
- if (N.current.getAttribute("role") !== "listbox" && (s = N.current.parentElement.querySelector('[role="listbox"]')), !s)
186
+ const r = _.current.querySelector(`[role="option"].${g}-focused`);
187
+ r && (r.classList.remove(`${g}-focused`), r.classList.remove(`${g}-focusVisible`));
188
+ let s = _.current;
189
+ if (_.current.getAttribute("role") !== "listbox" && (s = _.current.parentElement.querySelector('[role="listbox"]')), !s)
192
190
  return;
193
191
  if (e === -1) {
194
192
  s.scrollTop = 0;
195
193
  return;
196
194
  }
197
- const l = N.current.querySelector(`[data-option-index="${e}"]`);
198
- if (l && (l.classList.add(`${h}-focused`), n === "keyboard" && l.classList.add(`${h}-focusVisible`), s.scrollHeight > s.clientHeight && n !== "mouse" && n !== "touch")) {
199
- const d = l, O = s.clientHeight + s.scrollTop, he = d.offsetTop + d.offsetHeight;
200
- he > O ? s.scrollTop = he - s.clientHeight : d.offsetTop - d.offsetHeight * (z ? 1.3 : 0) < s.scrollTop && (s.scrollTop = d.offsetTop - d.offsetHeight * (z ? 1.3 : 0));
195
+ const l = _.current.querySelector(`[data-option-index="${e}"]`);
196
+ if (l && (l.classList.add(`${g}-focused`), n === "keyboard" && l.classList.add(`${g}-focusVisible`), s.scrollHeight > s.clientHeight && n !== "mouse" && n !== "touch")) {
197
+ const p = l, I = s.clientHeight + s.scrollTop, ie = p.offsetTop + p.offsetHeight;
198
+ ie > I ? s.scrollTop = ie - s.clientHeight : p.offsetTop - p.offsetHeight * (E ? 1.3 : 0) < s.scrollTop && (s.scrollTop = p.offsetTop - p.offsetHeight * (E ? 1.3 : 0));
201
199
  }
202
- }), L = me(({
200
+ }), D = ae(({
203
201
  event: t,
204
202
  diff: e,
205
203
  direction: n = "next",
206
204
  reason: r = "auto"
207
205
  }) => {
208
- if (!_)
206
+ if (!S)
209
207
  return;
210
- const l = Ze((() => {
211
- const d = c.length - 1;
208
+ const l = Je((() => {
209
+ const p = f.length - 1;
212
210
  if (e === "reset")
213
- return De;
211
+ return Te;
214
212
  if (e === "start")
215
213
  return 0;
216
214
  if (e === "end")
217
- return d;
218
- const O = x.current + e;
219
- return O < 0 ? O === -1 && se ? -1 : te && x.current !== -1 || Math.abs(e) > 1 ? 0 : d : O > d ? O === d + 1 && se ? -1 : te || Math.abs(e) > 1 ? d : 0 : O;
215
+ return p;
216
+ const I = y.current + e;
217
+ return I < 0 ? I === -1 && Ie ? -1 : K && y.current !== -1 || Math.abs(e) > 1 ? 0 : p : I > p ? I === p + 1 && Ie ? -1 : K || Math.abs(e) > 1 ? p : 0 : I;
220
218
  })(), n);
221
- if (F({
219
+ if (R({
222
220
  index: l,
223
221
  reason: r,
224
222
  event: t
225
- }), V && e !== "reset")
223
+ }), P && e !== "reset")
226
224
  if (l === -1)
227
- f.current.value = a;
225
+ d.current.value = a;
228
226
  else {
229
- const d = y(c[l]);
230
- f.current.value = d, d.toLowerCase().indexOf(a.toLowerCase()) === 0 && a.length > 0 && f.current.setSelectionRange(a.length, d.length);
227
+ const p = O(f[l]);
228
+ d.current.value = p, p.toLowerCase().indexOf(a.toLowerCase()) === 0 && a.length > 0 && d.current.setSelectionRange(a.length, p.length);
231
229
  }
232
- }), et = () => {
230
+ }), We = () => {
233
231
  const t = (e, n) => {
234
- const r = e ? y(e) : "", s = n ? y(n) : "";
232
+ const r = e ? O(e) : "", s = n ? O(n) : "";
235
233
  return r === s;
236
234
  };
237
- if (x.current !== -1 && C.filteredOptions && C.filteredOptions.length !== c.length && C.inputValue === a && (i ? o.length === C.value.length && C.value.every((e, n) => y(o[n]) === y(e)) : t(C.value, o))) {
238
- const e = C.filteredOptions[x.current];
235
+ if (y.current !== -1 && A.filteredOptions && A.filteredOptions.length !== f.length && A.inputValue === a && (u ? o.length === A.value.length && A.value.every((e, n) => O(o[n]) === O(e)) : t(A.value, o))) {
236
+ const e = A.filteredOptions[y.current];
239
237
  if (e)
240
- return be(c, (n) => y(n) === y(e));
238
+ return ue(f, (n) => O(n) === O(e));
241
239
  }
242
240
  return -1;
243
- }, Pe = g.useCallback(() => {
244
- if (!_)
241
+ }, xe = h.useCallback(() => {
242
+ if (!S)
245
243
  return;
246
- const t = et();
244
+ const t = We();
247
245
  if (t !== -1) {
248
- x.current = t;
246
+ y.current = t;
249
247
  return;
250
248
  }
251
- const e = i ? o[0] : o;
252
- if (c.length === 0 || e == null) {
253
- L({
249
+ const e = u ? o[0] : o;
250
+ if (f.length === 0 || e == null) {
251
+ D({
254
252
  diff: "reset"
255
253
  });
256
254
  return;
257
255
  }
258
- if (N.current) {
256
+ if (_.current) {
259
257
  if (e != null) {
260
- const n = c[x.current];
261
- if (i && n && be(o, (s) => E(n, s)) !== -1)
258
+ const n = f[y.current];
259
+ if (u && n && ue(o, (s) => V(n, s)) !== -1)
262
260
  return;
263
- const r = be(c, (s) => E(s, e));
264
- r === -1 ? L({
261
+ const r = ue(f, (s) => V(s, e));
262
+ r === -1 ? D({
265
263
  diff: "reset"
266
- }) : F({
264
+ }) : R({
267
265
  index: r
268
266
  });
269
267
  return;
270
268
  }
271
- if (x.current >= c.length - 1) {
272
- F({
273
- index: c.length - 1
269
+ if (y.current >= f.length - 1) {
270
+ R({
271
+ index: f.length - 1
274
272
  });
275
273
  return;
276
274
  }
277
- F({
278
- index: x.current
275
+ R({
276
+ index: y.current
279
277
  });
280
278
  }
281
279
  }, [
282
280
  // Only sync the highlighted index when the option switch between empty and not
283
- c.length,
281
+ f.length,
284
282
  // Don't sync the highlighted index with the value when multiple
285
283
  // eslint-disable-next-line react-hooks/exhaustive-deps
286
- i ? !1 : o,
287
- ne,
288
- L,
289
- F,
290
- _,
284
+ u ? !1 : o,
285
+ G,
286
+ D,
287
+ R,
288
+ S,
291
289
  a,
292
- i
293
- ]), tt = me((t) => {
294
- ht(N, t), t && Pe();
290
+ u
291
+ ]), Ye = ae((t) => {
292
+ pt(_, t), t && xe();
295
293
  });
296
- process.env.NODE_ENV !== "production" && g.useEffect(() => {
297
- (!f.current || f.current.nodeName !== "INPUT") && (f.current && f.current.nodeName === "TEXTAREA" ? console.warn([`A textarea element was provided to ${m} where input was expected.`, "This is not a supported scenario but it may work under certain conditions.", "A textarea keyboard navigation may conflict with Autocomplete controls (for example enter and arrow keys).", "Make sure to test keyboard navigation and add custom event handlers if necessary."].join(`
298
- `)) : console.error([`MUI: Unable to find the input element. It was resolved to ${f.current} while an HTMLInputElement was expected.`, `Instead, ${m} expects an input element.`, "", m === "useAutocomplete" ? "Make sure you have bound getInputProps correctly and that the normal ref/effect resolutions order is guaranteed." : "Make sure you have customized the input component correctly."].join(`
294
+ process.env.NODE_ENV !== "production" && h.useEffect(() => {
295
+ (!d.current || d.current.nodeName !== "INPUT") && (d.current && d.current.nodeName === "TEXTAREA" ? console.warn([`A textarea element was provided to ${x} where input was expected.`, "This is not a supported scenario but it may work under certain conditions.", "A textarea keyboard navigation may conflict with Autocomplete controls (for example enter and arrow keys).", "Make sure to test keyboard navigation and add custom event handlers if necessary."].join(`
296
+ `)) : console.error([`MUI: Unable to find the input element. It was resolved to ${d.current} while an HTMLInputElement was expected.`, `Instead, ${x} expects an input element.`, "", x === "useAutocomplete" ? "Make sure you have bound getInputProps correctly and that the normal ref/effect resolutions order is guaranteed." : "Make sure you have customized the input component correctly."].join(`
299
297
  `)));
300
- }, [m]), g.useEffect(() => {
301
- Pe();
302
- }, [Pe]);
303
- const q = (t) => {
304
- J || (ve(!0), Ce(!0), ae && ae(t));
305
- }, Q = (t, e) => {
306
- J && (ve(!1), le && le(t, e));
307
- }, Y = (t, e, n, r) => {
308
- if (i) {
298
+ }, [x]), h.useEffect(() => {
299
+ xe();
300
+ }, [xe]);
301
+ const H = (t) => {
302
+ q || ($e(!0), Ae(!0), Ee && Ee(t));
303
+ }, W = (t, e) => {
304
+ q && ($e(!1), Se && Se(t, e));
305
+ }, B = (t, e, n, r) => {
306
+ if (u) {
309
307
  if (o.length === e.length && o.every((s, l) => s === e[l]))
310
308
  return;
311
309
  } else if (o === e)
312
310
  return;
313
- ie && ie(t, e, n, r), Ge(e);
314
- }, ge = g.useRef(!1), Z = (t, e, n = "selectOption", r = "options") => {
311
+ we && we(t, e, n, r), Ke(e);
312
+ }, se = h.useRef(!1), Y = (t, e, n = "selectOption", r = "options") => {
315
313
  let s = n, l = e;
316
- if (i) {
314
+ if (u) {
317
315
  if (l = Array.isArray(o) ? o.slice() : [], process.env.NODE_ENV !== "production") {
318
- const O = l.filter((he) => E(e, he));
319
- O.length > 1 && console.error([`MUI: The \`isOptionEqualToValue\` method of ${m} does not handle the arguments correctly.`, `The component expects a single value to match a given option but found ${O.length} matches.`].join(`
316
+ const I = l.filter((ie) => V(e, ie));
317
+ I.length > 1 && console.error([`MUI: The \`isOptionEqualToValue\` method of ${x} does not handle the arguments correctly.`, `The component expects a single value to match a given option but found ${I.length} matches.`].join(`
320
318
  `));
321
319
  }
322
- const d = be(l, (O) => E(e, O));
323
- d === -1 ? l.push(e) : r !== "freeSolo" && (l.splice(d, 1), s = "removeOption");
320
+ const p = ue(l, (I) => V(e, I));
321
+ p === -1 ? l.push(e) : r !== "freeSolo" && (l.splice(p, 1), s = "removeOption");
324
322
  }
325
- de(t, l), Y(t, l, s, {
323
+ oe(t, l), B(t, l, s, {
326
324
  option: e
327
- }), !K && (!t || !t.ctrlKey && !t.metaKey) && Q(t, s), (M === !0 || M === "touch" && ge.current || M === "mouse" && !ge.current) && f.current.blur();
325
+ }), !j && (!t || !t.ctrlKey && !t.metaKey) && W(t, s), (C === !0 || C === "touch" && se.current || C === "mouse" && !se.current) && d.current.blur();
328
326
  };
329
- function nt(t, e) {
327
+ function Xe(t, e) {
330
328
  if (t === -1)
331
329
  return -1;
332
330
  let n = t;
333
331
  for (; ; ) {
334
332
  if (e === "next" && n === o.length || e === "previous" && n === -1)
335
333
  return -1;
336
- const r = ue.querySelector(`[data-tag-index="${n}"]`);
334
+ const r = ee.querySelector(`[data-tag-index="${n}"]`);
337
335
  if (!r || !r.hasAttribute("tabindex") || r.disabled || r.getAttribute("aria-disabled") === "true")
338
336
  n += e === "next" ? 1 : -1;
339
337
  else
340
338
  return n;
341
339
  }
342
340
  }
343
- const Ve = (t, e) => {
344
- if (!i)
341
+ const Pe = (t, e) => {
342
+ if (!u)
345
343
  return;
346
- a === "" && Q(t, "toggleInput");
347
- let n = P;
348
- P === -1 ? a === "" && e === "previous" && (n = o.length - 1) : (n += e === "next" ? 1 : -1, n < 0 && (n = 0), n === o.length && (n = -1)), n = nt(n, e), Se(n), pe(n);
349
- }, Me = (t) => {
350
- _e.current = !0, ce(""), v && v(t, "", "clear"), Y(t, i ? [] : null, "clear");
351
- }, ot = (t) => (e) => {
352
- if (t.onKeyDown && t.onKeyDown(e), !e.defaultMuiPrevented && (P !== -1 && ["ArrowLeft", "ArrowRight"].indexOf(e.key) === -1 && (Se(-1), pe(-1)), e.which !== 229))
344
+ a === "" && W(t, "toggleInput");
345
+ let n = $;
346
+ $ === -1 ? a === "" && e === "previous" && (n = o.length - 1) : (n += e === "next" ? 1 : -1, n < 0 && (n = 0), n === o.length && (n = -1)), n = Xe(n, e), me(n), re(n);
347
+ }, Ce = (t) => {
348
+ ge.current = !0, te(""), M && M(t, "", "clear"), B(t, u ? [] : null, "clear");
349
+ }, Ge = (t) => (e) => {
350
+ if (t.onKeyDown && t.onKeyDown(e), !e.defaultMuiPrevented && ($ !== -1 && ["ArrowLeft", "ArrowRight"].indexOf(e.key) === -1 && (me(-1), re(-1)), e.which !== 229))
353
351
  switch (e.key) {
354
352
  case "Home":
355
- _ && re && (e.preventDefault(), L({
353
+ S && Z && (e.preventDefault(), D({
356
354
  diff: "start",
357
355
  direction: "next",
358
356
  reason: "keyboard",
@@ -360,7 +358,7 @@ function It(u) {
360
358
  }));
361
359
  break;
362
360
  case "End":
363
- _ && re && (e.preventDefault(), L({
361
+ S && Z && (e.preventDefault(), D({
364
362
  diff: "end",
365
363
  direction: "previous",
366
364
  reason: "keyboard",
@@ -368,122 +366,122 @@ function It(u) {
368
366
  }));
369
367
  break;
370
368
  case "PageUp":
371
- e.preventDefault(), L({
372
- diff: -Je,
369
+ e.preventDefault(), D({
370
+ diff: -Re,
373
371
  direction: "previous",
374
372
  reason: "keyboard",
375
373
  event: e
376
- }), q(e);
374
+ }), H(e);
377
375
  break;
378
376
  case "PageDown":
379
- e.preventDefault(), L({
380
- diff: Je,
377
+ e.preventDefault(), D({
378
+ diff: Re,
381
379
  direction: "next",
382
380
  reason: "keyboard",
383
381
  event: e
384
- }), q(e);
382
+ }), H(e);
385
383
  break;
386
384
  case "ArrowDown":
387
- e.preventDefault(), L({
385
+ e.preventDefault(), D({
388
386
  diff: 1,
389
387
  direction: "next",
390
388
  reason: "keyboard",
391
389
  event: e
392
- }), q(e);
390
+ }), H(e);
393
391
  break;
394
392
  case "ArrowUp":
395
- e.preventDefault(), L({
393
+ e.preventDefault(), D({
396
394
  diff: -1,
397
395
  direction: "previous",
398
396
  reason: "keyboard",
399
397
  event: e
400
- }), q(e);
398
+ }), H(e);
401
399
  break;
402
400
  case "ArrowLeft":
403
- Ve(e, "previous");
401
+ Pe(e, "previous");
404
402
  break;
405
403
  case "ArrowRight":
406
- Ve(e, "next");
404
+ Pe(e, "next");
407
405
  break;
408
406
  case "Enter":
409
- if (x.current !== -1 && _) {
410
- const n = c[x.current], r = j ? j(n) : !1;
407
+ if (y.current !== -1 && S) {
408
+ const n = f[y.current], r = m ? m(n) : !1;
411
409
  if (e.preventDefault(), r)
412
410
  return;
413
- Z(e, n, "selectOption"), V && f.current.setSelectionRange(f.current.value.length, f.current.value.length);
411
+ Y(e, n, "selectOption"), P && d.current.setSelectionRange(d.current.value.length, d.current.value.length);
414
412
  } else
415
- R && a !== "" && Le === !1 && (i && e.preventDefault(), Z(e, a, "createOption", "freeSolo"));
413
+ i && a !== "" && De === !1 && (u && e.preventDefault(), Y(e, a, "createOption", "freeSolo"));
416
414
  break;
417
415
  case "Escape":
418
- _ ? (e.preventDefault(), e.stopPropagation(), Q(e, "escape")) : U && (a !== "" || i && o.length > 0) && (e.preventDefault(), e.stopPropagation(), Me(e));
416
+ S ? (e.preventDefault(), e.stopPropagation(), W(e, "escape")) : L && (a !== "" || u && o.length > 0) && (e.preventDefault(), e.stopPropagation(), Ce(e));
419
417
  break;
420
418
  case "Backspace":
421
- if (i && !G && a === "" && o.length > 0) {
422
- const n = P === -1 ? o.length - 1 : P, r = o.slice();
423
- r.splice(n, 1), Y(e, r, "removeOption", {
419
+ if (u && !J && a === "" && o.length > 0) {
420
+ const n = $ === -1 ? o.length - 1 : $, r = o.slice();
421
+ r.splice(n, 1), B(e, r, "removeOption", {
424
422
  option: o[n]
425
423
  });
426
424
  }
427
425
  break;
428
426
  case "Delete":
429
- if (i && !G && a === "" && o.length > 0 && P !== -1) {
430
- const n = P, r = o.slice();
431
- r.splice(n, 1), Y(e, r, "removeOption", {
427
+ if (u && !J && a === "" && o.length > 0 && $ !== -1) {
428
+ const n = $, r = o.slice();
429
+ r.splice(n, 1), B(e, r, "removeOption", {
432
430
  option: o[n]
433
431
  });
434
432
  }
435
433
  break;
436
434
  }
437
- }, rt = (t) => {
438
- Ee(!0), p && !_e.current && q(t);
439
- }, Re = (t) => {
440
- if (b(N)) {
441
- f.current.focus();
435
+ }, Qe = (t) => {
436
+ _e(!0), qe && !ge.current && H(t);
437
+ }, ve = (t) => {
438
+ if (b(_)) {
439
+ d.current.focus();
442
440
  return;
443
441
  }
444
- Ee(!1), ke.current = !0, _e.current = !1, $ && x.current !== -1 && _ ? Z(t, c[x.current], "blur") : $ && R && a !== "" ? Z(t, a, "blur", "freeSolo") : D && de(t, o), Q(t, "blur");
445
- }, st = (t) => {
442
+ _e(!1), he.current = !0, ge.current = !1, N && y.current !== -1 && S ? Y(t, f[y.current], "blur") : N && i && a !== "" ? Y(t, a, "blur", "freeSolo") : v && oe(t, o), W(t, "blur");
443
+ }, Ze = (t) => {
446
444
  const e = t.target.value;
447
- a !== e && (ce(e), Ce(!1), v && v(t, e, "input")), e === "" ? !H && !i && Y(t, null, "clear") : q(t);
448
- }, it = (t) => {
445
+ a !== e && (te(e), Ae(!1), M && M(t, e, "input")), e === "" ? !F && !u && B(t, null, "clear") : H(t);
446
+ }, et = (t) => {
449
447
  const e = Number(t.currentTarget.getAttribute("data-option-index"));
450
- x.current !== e && F({
448
+ y.current !== e && R({
451
449
  event: t,
452
450
  index: e,
453
451
  reason: "mouse"
454
452
  });
455
- }, lt = (t) => {
456
- F({
453
+ }, tt = (t) => {
454
+ R({
457
455
  event: t,
458
456
  index: Number(t.currentTarget.getAttribute("data-option-index")),
459
457
  reason: "touch"
460
- }), ge.current = !0;
461
- }, at = (t) => {
458
+ }), se.current = !0;
459
+ }, nt = (t) => {
462
460
  const e = Number(t.currentTarget.getAttribute("data-option-index"));
463
- Z(t, c[e], "selectOption"), ge.current = !1;
464
- }, ut = (t) => (e) => {
461
+ Y(t, f[e], "selectOption"), se.current = !1;
462
+ }, ot = (t) => (e) => {
465
463
  const n = o.slice();
466
- n.splice(t, 1), Y(e, n, "removeOption", {
464
+ n.splice(t, 1), B(e, n, "removeOption", {
467
465
  option: o[t]
468
466
  });
469
- }, He = (t) => {
470
- J ? Q(t, "toggleInput") : q(t);
471
- }, ct = (t) => {
472
- t.currentTarget.contains(t.target) && t.target.getAttribute("id") !== S && t.preventDefault();
473
- }, ft = (t) => {
474
- t.currentTarget.contains(t.target) && (f.current.focus(), Ye && ke.current && f.current.selectionEnd - f.current.selectionStart === 0 && f.current.select(), ke.current = !1);
475
- }, dt = (t) => {
476
- !I && (a === "" || !J) && He(t);
467
+ }, Ne = (t) => {
468
+ q ? W(t, "toggleInput") : H(t);
469
+ }, rt = (t) => {
470
+ t.currentTarget.contains(t.target) && t.target.getAttribute("id") !== T && t.preventDefault();
471
+ }, st = (t) => {
472
+ t.currentTarget.contains(t.target) && (d.current.focus(), Be && he.current && d.current.selectionEnd - d.current.selectionStart === 0 && d.current.select(), he.current = !1);
473
+ }, it = (t) => {
474
+ !w && (a === "" || !q) && Ne(t);
477
475
  };
478
- let Te = R && a.length > 0;
479
- Te = Te || (i ? o.length > 0 : o !== null);
480
- let Fe = c;
481
- if (z) {
476
+ let ye = i && a.length > 0;
477
+ ye = ye || (u ? o.length > 0 : o !== null);
478
+ let Le = f;
479
+ if (E) {
482
480
  const t = /* @__PURE__ */ new Map();
483
481
  let e = !1;
484
- Fe = c.reduce((n, r, s) => {
485
- const l = z(r);
486
- return n.length > 0 && n[n.length - 1].group === l ? n[n.length - 1].options.push(r) : (process.env.NODE_ENV !== "production" && (t.get(l) && !e && (console.warn(`MUI: The options provided combined with the \`groupBy\` method of ${m} returns duplicated headers.`, "You can solve the issue by sorting the options with the output of `groupBy`."), e = !0), t.set(l, !0)), n.push({
482
+ Le = f.reduce((n, r, s) => {
483
+ const l = E(r);
484
+ return n.length > 0 && n[n.length - 1].group === l ? n[n.length - 1].options.push(r) : (process.env.NODE_ENV !== "production" && (t.get(l) && !e && (console.warn(`MUI: The options provided combined with the \`groupBy\` method of ${x} returns duplicated headers.`, "You can solve the issue by sorting the options with the output of `groupBy`."), e = !0), t.set(l, !0)), n.push({
487
485
  key: s,
488
486
  index: s,
489
487
  group: l,
@@ -491,64 +489,64 @@ function It(u) {
491
489
  })), n;
492
490
  }, []);
493
491
  }
494
- return I && fe && Re(), {
495
- getRootProps: (t = {}) => je({
496
- "aria-owns": Ne ? `${S}-listbox` : null
492
+ return w && ne && ve(), {
493
+ getRootProps: (t = {}) => Ve({
494
+ "aria-owns": be ? `${T}-listbox` : null
497
495
  }, t, {
498
- onKeyDown: ot(t),
499
- onMouseDown: ct,
500
- onClick: ft
496
+ onKeyDown: Ge(t),
497
+ onMouseDown: rt,
498
+ onClick: st
501
499
  }),
502
500
  getInputLabelProps: () => ({
503
- id: `${S}-label`,
504
- htmlFor: S
501
+ id: `${T}-label`,
502
+ htmlFor: T
505
503
  }),
506
504
  getInputProps: () => ({
507
- id: S,
505
+ id: T,
508
506
  value: a,
509
- onBlur: Re,
510
- onFocus: rt,
511
- onChange: st,
512
- onMouseDown: dt,
507
+ onBlur: ve,
508
+ onFocus: Qe,
509
+ onChange: Ze,
510
+ onMouseDown: it,
513
511
  // if open then this is handled imperatively so don't let react override
514
512
  // only have an opinion about this when closed
515
- "aria-activedescendant": _ ? "" : null,
516
- "aria-autocomplete": V ? "both" : "list",
517
- "aria-controls": Ne ? `${S}-listbox` : void 0,
518
- "aria-expanded": Ne,
513
+ "aria-activedescendant": S ? "" : null,
514
+ "aria-autocomplete": P ? "both" : "list",
515
+ "aria-controls": be ? `${T}-listbox` : void 0,
516
+ "aria-expanded": be,
519
517
  // Disable browser's suggestion that might overlap with the popup.
520
518
  // Handle autocomplete but not autofill.
521
519
  autoComplete: "off",
522
- ref: f,
520
+ ref: d,
523
521
  autoCapitalize: "none",
524
522
  spellCheck: "false",
525
523
  role: "combobox",
526
- disabled: I
524
+ disabled: w
527
525
  }),
528
526
  getClearProps: () => ({
529
527
  tabIndex: -1,
530
528
  type: "button",
531
- onClick: Me
529
+ onClick: Ce
532
530
  }),
533
531
  getPopupIndicatorProps: () => ({
534
532
  tabIndex: -1,
535
533
  type: "button",
536
- onClick: He
534
+ onClick: Ne
537
535
  }),
538
536
  getTagProps: ({
539
537
  index: t
540
- }) => je({
538
+ }) => Ve({
541
539
  key: t,
542
540
  "data-tag-index": t,
543
541
  tabIndex: -1
544
- }, !G && {
545
- onDelete: ut(t)
542
+ }, !J && {
543
+ onDelete: ot(t)
546
544
  }),
547
545
  getListboxProps: () => ({
548
546
  role: "listbox",
549
- id: `${S}-listbox`,
550
- "aria-labelledby": `${S}-label`,
551
- ref: tt,
547
+ id: `${T}-listbox`,
548
+ "aria-labelledby": `${T}-label`,
549
+ ref: Ye,
552
550
  onMouseDown: (t) => {
553
551
  t.preventDefault();
554
552
  }
@@ -558,134 +556,105 @@ function It(u) {
558
556
  option: e
559
557
  }) => {
560
558
  var n;
561
- const r = (i ? o : [o]).some((l) => l != null && E(e, l)), s = j ? j(e) : !1;
559
+ const r = (u ? o : [o]).some((l) => l != null && V(e, l)), s = m ? m(e) : !1;
562
560
  return {
563
- key: (n = oe == null ? void 0 : oe(e)) != null ? n : y(e),
561
+ key: (n = Q == null ? void 0 : Q(e)) != null ? n : O(e),
564
562
  tabIndex: -1,
565
563
  role: "option",
566
- id: `${S}-option-${t}`,
567
- onMouseMove: it,
568
- onClick: at,
569
- onTouchStart: lt,
564
+ id: `${T}-option-${t}`,
565
+ onMouseMove: et,
566
+ onClick: nt,
567
+ onTouchStart: tt,
570
568
  "data-option-index": t,
571
569
  "aria-disabled": s,
572
570
  "aria-selected": r
573
571
  };
574
572
  },
575
- id: S,
573
+ id: T,
576
574
  inputValue: a,
577
575
  value: o,
578
- dirty: Te,
579
- expanded: _ && ue,
580
- popupOpen: _,
581
- focused: fe || P !== -1,
582
- anchorEl: ue,
583
- setAnchorEl: Xe,
584
- focusedTag: P,
585
- groupedOptions: Fe
576
+ dirty: ye,
577
+ expanded: S && ee,
578
+ popupOpen: S,
579
+ focused: ne || $ !== -1,
580
+ anchorEl: ee,
581
+ setAnchorEl: je,
582
+ focusedTag: $,
583
+ groupedOptions: Le
586
584
  };
587
585
  }
588
- const wt = "_autocomplete_19kw3_1", Ae = {
589
- autocomplete: wt,
590
- "autocomplete__dropdown-list": "_autocomplete__dropdown-list_19kw3_4",
591
- "autocomplete__dropdown-item": "_autocomplete__dropdown-item_19kw3_10"
592
- }, vt = ({
593
- label: u,
594
- type: b,
595
- labelKey: h,
596
- options: V,
597
- infoMessage: B,
598
- errorMessage: $,
599
- leftIcon: M,
600
- rightIcon: D,
601
- id: U,
602
- disabled: m,
603
- maxLength: k,
604
- onChange: H,
605
- onInputChange: K,
606
- classNameLabel: I,
607
- classNameInput: xe,
608
- classNameErrorMessage: te,
609
- classNameInfoMessage: ye,
610
- "data-testid-label": ne,
611
- "data-testid-input": R,
612
- "data-testid-infoMessage": j,
613
- "data-testid-errorMessage": oe,
614
- ...W
586
+ const Ot = "_autocomplete_pfc9v_1", X = {
587
+ autocomplete: Ot,
588
+ "autocomplete__dropdown-list": "_autocomplete__dropdown-list_pfc9v_5",
589
+ "autocomplete__dropdown-item": "_autocomplete__dropdown-item_pfc9v_17",
590
+ "option-focused": "_option-focused_pfc9v_26"
591
+ }, At = ({
592
+ labelKey: c,
593
+ valueKey: b,
594
+ options: g,
595
+ type: P,
596
+ value: U,
597
+ onChange: N,
598
+ onInputChange: C,
599
+ "data-testid-wrapper": v,
600
+ ...L
615
601
  }) => {
616
- const z = pt(), re = U || `input_${z}`;
617
- Object.assign(W, { "data-testid": R });
618
- const [Oe, se] = Be(), [Ie, E] = Be(""), { getRootProps: i, getInputProps: ie, getOptionProps: le, groupedOptions: X, getListboxProps: v, focused: ae, getInputLabelProps: we } = It({
619
- id: re,
620
- options: V,
621
- getOptionLabel: (p) => typeof p == "string" ? p : String(p[h || "label"]),
622
- value: Oe,
623
- inputValue: Ie,
624
- onChange: (p, w) => {
625
- H && H(p, w), se(w);
602
+ const x = at(), [k, F] = ut("");
603
+ g != null && g.some((i) => typeof i != "string") && (!c || !b) && console.error(
604
+ '[autocomplete] When options is a list of objects, you must provide the "labelKey" and "valueKey" parameters.'
605
+ );
606
+ const { getRootProps: j, getInputProps: w, getOptionProps: ce, groupedOptions: K, getListboxProps: fe } = yt({
607
+ id: `autocomplete_${x}`,
608
+ options: g,
609
+ getOptionLabel: (i) => typeof i == "string" ? i : String(i[c || "label"]),
610
+ value: U,
611
+ inputValue: k,
612
+ isOptionEqualToValue: (i, m) => typeof i == "string" ? String(i) === String(m) : String(i[b || "id"]) === String(m[b || "id"]),
613
+ onChange: (i, m) => {
614
+ N && N(i, m);
615
+ },
616
+ onInputChange: (i, m) => {
617
+ C && C(i, m), F(m);
626
618
  },
627
- onInputChange: (p, w) => {
628
- K && K(p, w), E(w);
619
+ onHighlightChange: (i, m, Q) => {
620
+ var z;
621
+ if (Q === "keyboard") {
622
+ const E = document.querySelector("#autocomplete-list"), Z = (i == null ? void 0 : i.target).getAttribute("aria-activedescendant");
623
+ E == null || E.querySelectorAll("li").forEach((de) => de.classList.remove(X["option-focused"])), (z = E == null ? void 0 : E.querySelector(`[id="${Z}"]`)) == null || z.classList.add(X["option-focused"]);
624
+ }
629
625
  }
630
- });
631
- return /* @__PURE__ */ qe("div", { className: Ae.autocomplete, children: [
632
- u && /* @__PURE__ */ A(
633
- Ke,
626
+ }), G = {
627
+ ...w(),
628
+ ...L
629
+ };
630
+ return /* @__PURE__ */ le("div", { className: X.autocomplete, "data-testid": v, children: /* @__PURE__ */ lt("div", { ...j(), children: [
631
+ /* @__PURE__ */ le(
632
+ dt,
634
633
  {
635
- element: "label",
636
- elementProps: { ...we() },
637
- className: ee(T.input__label, I),
638
- "data-testid": ne,
639
- children: u
634
+ rightIcon: P === "search" && /* @__PURE__ */ le(ft, { color: "var(--accent)", icon: "magnifying-glass" }),
635
+ ...G
640
636
  }
641
637
  ),
642
- /* @__PURE__ */ A("div", { ...i(), className: ae ? "Mui-focused" : "", children: /* @__PURE__ */ A(
643
- gt,
644
- {
645
- disabled: m,
646
- error: !!$,
647
- "aria-label": u,
648
- slotProps: {
649
- root: (p) => ({
650
- className: ee(T["input__input-el-wrapper"], {
651
- [T["input--disabled"]]: p.disabled,
652
- [T["input--focused"]]: p.focused,
653
- [T["input--error"]]: p.error
654
- })
655
- }),
656
- input: {
657
- ...ie(),
658
- className: ee(T["input__input-el"], xe),
659
- maxLength: k,
660
- ...W
661
- }
662
- },
663
- startAdornment: M && /* @__PURE__ */ A("span", { className: T["input__left-icon"], children: M }),
664
- endAdornment: b === "search" ? /* @__PURE__ */ A("span", { className: T["input__right-icon"], children: /* @__PURE__ */ A(Ue, { color: "var(--accent)", icon: "magnifying-glass" }) }) : D && /* @__PURE__ */ A("span", { className: T["input__right-icon"], children: D })
665
- }
666
- ) }),
667
- X.length > 0 && !m && /* @__PURE__ */ A("ul", { ...v(), className: Ae["autocomplete__dropdown-list"], children: X.map((p, w) => /* @__PURE__ */ A(
668
- "li",
669
- {
670
- tabIndex: w,
671
- className: Ae["autocomplete__dropdown-item"],
672
- ...le({ option: p, index: w }),
673
- children: typeof p == "string" ? p : String(p[h || "label"])
674
- }
675
- )) }),
676
- ($ || B) && /* @__PURE__ */ qe(
677
- Ke,
638
+ K.length > 0 && !L.disabled && /* @__PURE__ */ le(
639
+ "ul",
678
640
  {
679
- className: $ ? ee(T["input__error-message"], te) : ee(T["input__info-message"], ye),
680
- "data-testid": $ ? oe : j,
681
- children: [
682
- /* @__PURE__ */ A(Ue, { icon: "circle-exclamation" }),
683
- $ || B
684
- ]
641
+ ...fe(),
642
+ id: "autocomplete-list",
643
+ className: X["autocomplete__dropdown-list"],
644
+ children: K.map((i, m) => /* @__PURE__ */ ct(
645
+ "li",
646
+ {
647
+ tabIndex: m,
648
+ className: X["autocomplete__dropdown-item"],
649
+ ...ce({ option: i, index: m }),
650
+ key: String(m)
651
+ },
652
+ typeof i == "string" ? i : String(i[c || "label"])
653
+ ))
685
654
  }
686
655
  )
687
- ] });
656
+ ] }) });
688
657
  };
689
658
  export {
690
- vt as Autocomplete
659
+ At as Autocomplete
691
660
  };