@pismo/marola 1.0.0-beta.20 → 1.0.0-beta.22

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