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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,51 +1,51 @@
1
1
  import '../../assets/Autocomplete.css';
2
- import { jsx as ue, jsxs as at } from "react/jsx-runtime";
2
+ import { jsx as le, jsxs as lt } from "react/jsx-runtime";
3
3
  import * as h from "react";
4
- import { useId as ut, useState as Me, createElement as ct } from "react";
4
+ import { useId as at, useState as ut, createElement as ct } from "react";
5
5
  import { Icon as ft } from "../Icon/Icon.js";
6
6
  import { Input as dt } from "../Input/Input.js";
7
- import { b as Re, s as pt } from "../../useSlotProps-C_I1kEHr.js";
7
+ import { b as Ve, s as pt } from "../../useSlotProps-C_I1kEHr.js";
8
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";
9
+ import { u as Oe } from "../../useControlled-CCMYYdCM.js";
10
+ import { u as ae } from "../../useEventCallback-BAQJJ3ye.js";
11
11
  const ht = (c) => {
12
12
  const b = h.useRef({});
13
13
  return h.useEffect(() => {
14
14
  b.current = c;
15
15
  }), b.current;
16
16
  };
17
- function He(c) {
17
+ function Me(c) {
18
18
  return typeof c.normalize < "u" ? c.normalize("NFD").replace(/[\u0300-\u036f]/g, "") : c;
19
19
  }
20
20
  function mt(c = {}) {
21
21
  const {
22
22
  ignoreAccents: b = !0,
23
23
  ignoreCase: g = !0,
24
- limit: A,
25
- matchFrom: z = "any",
26
- stringify: L,
27
- trim: D = !1
24
+ limit: P,
25
+ matchFrom: U = "any",
26
+ stringify: N,
27
+ trim: C = !1
28
28
  } = c;
29
- return (P, {
30
- inputValue: V,
29
+ return (v, {
30
+ inputValue: L,
31
31
  getOptionLabel: x
32
32
  }) => {
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;
39
- return typeof A == "number" ? q.slice(0, A) : q;
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;
40
40
  };
41
41
  }
42
- function fe(c, b) {
42
+ function ue(c, b) {
43
43
  for (let g = 0; g < c.length; g += 1)
44
44
  if (b(c[g]))
45
45
  return g;
46
46
  return -1;
47
47
  }
48
- const bt = mt(), Fe = 5, xt = (c) => {
48
+ const bt = mt(), Re = 5, xt = (c) => {
49
49
  var b;
50
50
  return c.current !== null && ((b = c.current.parentElement) == null ? void 0 : b.contains(document.activeElement));
51
51
  };
@@ -55,50 +55,50 @@ function yt(c) {
55
55
  unstable_isActiveElementInListbox: b = xt,
56
56
  // eslint-disable-next-line @typescript-eslint/naming-convention
57
57
  unstable_classNamePrefix: g = "Mui",
58
- autoComplete: A = !1,
59
- autoHighlight: z = !1,
60
- autoSelect: L = !1,
61
- blurOnSelect: D = !1,
62
- clearOnBlur: P = !c.freeSolo,
63
- clearOnEscape: V = !1,
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
64
  componentName: x = "useAutocomplete",
65
65
  defaultValue: k = c.multiple ? [] : null,
66
- disableClearable: q = !1,
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) => {
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) => {
77
77
  var e;
78
78
  return (e = t.label) != null ? e : t;
79
79
  },
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,
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
86
  multiple: u = !1,
87
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,
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
97
  value: Ue
98
- } = c, E = gt(N);
99
- let O = m;
98
+ } = c, T = gt(de);
99
+ let O = z;
100
100
  O = (t) => {
101
- const e = m(t);
101
+ const e = z(t);
102
102
  if (typeof e != "string") {
103
103
  if (process.env.NODE_ENV !== "production") {
104
104
  const n = e === void 0 ? "undefined" : `${typeof e} (${e})`;
@@ -108,17 +108,17 @@ function yt(c) {
108
108
  }
109
109
  return e;
110
110
  };
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({
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
112
  controlled: Ue,
113
113
  default: k,
114
114
  name: x
115
- }), [a, oe] = Se({
116
- controlled: ge,
115
+ }), [a, te] = Oe({
116
+ controlled: He,
117
117
  default: "",
118
118
  name: x,
119
119
  state: "inputValue"
120
- }), [re, $e] = h.useState(!1), se = h.useCallback((t, e) => {
121
- if (!(u ? o.length < e.length : e !== null) && !P)
120
+ }), [ne, _e] = h.useState(!1), oe = h.useCallback((t, e) => {
121
+ if (!(u ? o.length < e.length : e !== null) && !v)
122
122
  return;
123
123
  let r;
124
124
  if (u)
@@ -129,150 +129,150 @@ function yt(c) {
129
129
  const s = O(e);
130
130
  r = typeof s == "string" ? s : "";
131
131
  }
132
- a !== r && (oe(r), R && R(t, r, "reset"));
133
- }, [O, a, u, R, oe, P, o]), [U, ve] = Se({
134
- controlled: qe,
132
+ a !== r && (te(r), M && M(t, r, "reset"));
133
+ }, [O, a, u, M, te, v, o]), [q, $e] = Oe({
134
+ controlled: Fe,
135
135
  default: !1,
136
136
  name: x,
137
137
  state: "open"
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)))),
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)))),
140
140
  // we use the empty string to manipulate `filterOptions` to not filter any options
141
141
  // i.e. the filter predicate always returns true
142
142
  {
143
- inputValue: De && Je ? "" : a,
143
+ inputValue: De && ze ? "" : a,
144
144
  getOptionLabel: O
145
145
  }
146
- ) : [], $ = ht({
146
+ ) : [], A = ht({
147
147
  filteredOptions: f,
148
148
  value: o,
149
149
  inputValue: a
150
150
  });
151
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)));
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
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(`
159
159
  `));
160
160
  }
161
- const ie = ce((t) => {
162
- t === -1 ? d.current.focus() : ne.querySelector(`[data-tag-index="${t}"]`).focus();
161
+ const re = ae((t) => {
162
+ t === -1 ? d.current.focus() : ee.querySelector(`[data-tag-index="${t}"]`).focus();
163
163
  });
164
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)
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)
169
169
  return -1;
170
170
  let n = t;
171
171
  for (; ; ) {
172
- const r = T.current.querySelector(`[data-option-index="${n}"]`), s = de ? !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";
173
173
  if (r && r.hasAttribute("tabindex") && !s)
174
174
  return n;
175
175
  if (e === "next" ? n = (n + 1) % f.length : n = (n - 1 + f.length) % f.length, n === t)
176
176
  return -1;
177
177
  }
178
178
  }
179
- const H = ce(({
179
+ const R = ae(({
180
180
  event: t,
181
181
  index: e,
182
182
  reason: n = "auto"
183
183
  }) => {
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)
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)
185
185
  return;
186
- const r = T.current.querySelector(`[role="option"].${g}-focused`);
186
+ const r = _.current.querySelector(`[role="option"].${g}-focused`);
187
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)
188
+ let s = _.current;
189
+ if (_.current.getAttribute("role") !== "listbox" && (s = _.current.parentElement.querySelector('[role="listbox"]')), !s)
190
190
  return;
191
191
  if (e === -1) {
192
192
  s.scrollTop = 0;
193
193
  return;
194
194
  }
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));
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));
199
199
  }
200
- }), v = ce(({
200
+ }), D = ae(({
201
201
  event: t,
202
202
  diff: e,
203
203
  direction: n = "next",
204
204
  reason: r = "auto"
205
205
  }) => {
206
- if (!w)
206
+ if (!S)
207
207
  return;
208
- const i = We((() => {
208
+ const l = Je((() => {
209
209
  const p = f.length - 1;
210
210
  if (e === "reset")
211
- return _e;
211
+ return Te;
212
212
  if (e === "start")
213
213
  return 0;
214
214
  if (e === "end")
215
215
  return p;
216
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;
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;
218
218
  })(), n);
219
- if (H({
220
- index: i,
219
+ if (R({
220
+ index: l,
221
221
  reason: r,
222
222
  event: t
223
- }), A && e !== "reset")
224
- if (i === -1)
223
+ }), P && e !== "reset")
224
+ if (l === -1)
225
225
  d.current.value = a;
226
226
  else {
227
- const p = O(f[i]);
227
+ const p = O(f[l]);
228
228
  d.current.value = p, p.toLowerCase().indexOf(a.toLowerCase()) === 0 && a.length > 0 && d.current.setSelectionRange(a.length, p.length);
229
229
  }
230
- }), Ye = () => {
230
+ }), We = () => {
231
231
  const t = (e, n) => {
232
232
  const r = e ? O(e) : "", s = n ? O(n) : "";
233
233
  return r === s;
234
234
  };
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];
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];
237
237
  if (e)
238
- return fe(f, (n) => O(n) === O(e));
238
+ return ue(f, (n) => O(n) === O(e));
239
239
  }
240
240
  return -1;
241
- }, Oe = h.useCallback(() => {
242
- if (!w)
241
+ }, xe = h.useCallback(() => {
242
+ if (!S)
243
243
  return;
244
- const t = Ye();
244
+ const t = We();
245
245
  if (t !== -1) {
246
246
  y.current = t;
247
247
  return;
248
248
  }
249
249
  const e = u ? o[0] : o;
250
250
  if (f.length === 0 || e == null) {
251
- v({
251
+ D({
252
252
  diff: "reset"
253
253
  });
254
254
  return;
255
255
  }
256
- if (T.current) {
256
+ if (_.current) {
257
257
  if (e != null) {
258
258
  const n = f[y.current];
259
- if (u && n && fe(o, (s) => M(n, s)) !== -1)
259
+ if (u && n && ue(o, (s) => V(n, s)) !== -1)
260
260
  return;
261
- const r = fe(f, (s) => M(s, e));
262
- r === -1 ? v({
261
+ const r = ue(f, (s) => V(s, e));
262
+ r === -1 ? D({
263
263
  diff: "reset"
264
- }) : H({
264
+ }) : R({
265
265
  index: r
266
266
  });
267
267
  return;
268
268
  }
269
269
  if (y.current >= f.length - 1) {
270
- H({
270
+ R({
271
271
  index: f.length - 1
272
272
  });
273
273
  return;
274
274
  }
275
- H({
275
+ R({
276
276
  index: y.current
277
277
  });
278
278
  }
@@ -282,56 +282,56 @@ function yt(c) {
282
282
  // Don't sync the highlighted index with the value when multiple
283
283
  // eslint-disable-next-line react-hooks/exhaustive-deps
284
284
  u ? !1 : o,
285
- W,
286
- v,
287
- H,
288
- w,
285
+ G,
286
+ D,
287
+ R,
288
+ S,
289
289
  a,
290
290
  u
291
- ]), Xe = ce((t) => {
292
- pt(T, t), t && Oe();
291
+ ]), Ye = ae((t) => {
292
+ pt(_, t), t && xe();
293
293
  });
294
294
  process.env.NODE_ENV !== "production" && h.useEffect(() => {
295
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
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(`
297
297
  `)));
298
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) => {
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
306
  if (u) {
307
- if (o.length === e.length && o.every((s, i) => s === e[i]))
307
+ if (o.length === e.length && o.every((s, l) => s === e[l]))
308
308
  return;
309
309
  } else if (o === e)
310
310
  return;
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;
311
+ we && we(t, e, n, r), Ke(e);
312
+ }, se = h.useRef(!1), Y = (t, e, n = "selectOption", r = "options") => {
313
+ let s = n, l = e;
314
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));
315
+ if (l = Array.isArray(o) ? o.slice() : [], process.env.NODE_ENV !== "production") {
316
+ const I = l.filter((ie) => V(e, ie));
317
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(`
318
318
  `));
319
319
  }
320
- const p = fe(i, (I) => M(e, I));
321
- p === -1 ? i.push(e) : r !== "freeSolo" && (i.splice(p, 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");
322
322
  }
323
- se(t, i), j(t, i, s, {
323
+ oe(t, l), B(t, l, s, {
324
324
  option: e
325
- }), !J && (!t || !t.ctrlKey && !t.metaKey) && G(t, s), (D === !0 || D === "touch" && le.current || D === "mouse" && !le.current) && d.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();
326
326
  };
327
- function Ge(t, e) {
327
+ function Xe(t, e) {
328
328
  if (t === -1)
329
329
  return -1;
330
330
  let n = t;
331
331
  for (; ; ) {
332
332
  if (e === "next" && n === o.length || e === "previous" && n === -1)
333
333
  return -1;
334
- const r = ne.querySelector(`[data-tag-index="${n}"]`);
334
+ const r = ee.querySelector(`[data-tag-index="${n}"]`);
335
335
  if (!r || !r.hasAttribute("tabindex") || r.disabled || r.getAttribute("aria-disabled") === "true")
336
336
  n += e === "next" ? 1 : -1;
337
337
  else
@@ -341,16 +341,16 @@ function yt(c) {
341
341
  const Pe = (t, e) => {
342
342
  if (!u)
343
343
  return;
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);
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
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))
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))
351
351
  switch (e.key) {
352
352
  case "Home":
353
- w && Y && (e.preventDefault(), v({
353
+ S && Z && (e.preventDefault(), D({
354
354
  diff: "start",
355
355
  direction: "next",
356
356
  reason: "keyboard",
@@ -358,7 +358,7 @@ function yt(c) {
358
358
  }));
359
359
  break;
360
360
  case "End":
361
- w && Y && (e.preventDefault(), v({
361
+ S && Z && (e.preventDefault(), D({
362
362
  diff: "end",
363
363
  direction: "previous",
364
364
  reason: "keyboard",
@@ -366,36 +366,36 @@ function yt(c) {
366
366
  }));
367
367
  break;
368
368
  case "PageUp":
369
- e.preventDefault(), v({
370
- diff: -Fe,
369
+ e.preventDefault(), D({
370
+ diff: -Re,
371
371
  direction: "previous",
372
372
  reason: "keyboard",
373
373
  event: e
374
- }), F(e);
374
+ }), H(e);
375
375
  break;
376
376
  case "PageDown":
377
- e.preventDefault(), v({
378
- diff: Fe,
377
+ e.preventDefault(), D({
378
+ diff: Re,
379
379
  direction: "next",
380
380
  reason: "keyboard",
381
381
  event: e
382
- }), F(e);
382
+ }), H(e);
383
383
  break;
384
384
  case "ArrowDown":
385
- e.preventDefault(), v({
385
+ e.preventDefault(), D({
386
386
  diff: 1,
387
387
  direction: "next",
388
388
  reason: "keyboard",
389
389
  event: e
390
- }), F(e);
390
+ }), H(e);
391
391
  break;
392
392
  case "ArrowUp":
393
- e.preventDefault(), v({
393
+ e.preventDefault(), D({
394
394
  diff: -1,
395
395
  direction: "previous",
396
396
  reason: "keyboard",
397
397
  event: e
398
- }), F(e);
398
+ }), H(e);
399
399
  break;
400
400
  case "ArrowLeft":
401
401
  Pe(e, "previous");
@@ -404,116 +404,116 @@ function yt(c) {
404
404
  Pe(e, "next");
405
405
  break;
406
406
  case "Enter":
407
- if (y.current !== -1 && w) {
408
- const n = f[y.current], r = B ? B(n) : !1;
407
+ if (y.current !== -1 && S) {
408
+ const n = f[y.current], r = m ? m(n) : !1;
409
409
  if (e.preventDefault(), r)
410
410
  return;
411
- Q(e, n, "selectOption"), A && d.current.setSelectionRange(d.current.value.length, d.current.value.length);
411
+ Y(e, n, "selectOption"), P && d.current.setSelectionRange(d.current.value.length, d.current.value.length);
412
412
  } else
413
- C && a !== "" && De === !1 && (u && e.preventDefault(), Q(e, a, "createOption", "freeSolo"));
413
+ i && a !== "" && De === !1 && (u && e.preventDefault(), Y(e, a, "createOption", "freeSolo"));
414
414
  break;
415
415
  case "Escape":
416
- w ? (e.preventDefault(), e.stopPropagation(), G(e, "escape")) : V && (a !== "" || u && o.length > 0) && (e.preventDefault(), e.stopPropagation(), Ce(e));
416
+ S ? (e.preventDefault(), e.stopPropagation(), W(e, "escape")) : L && (a !== "" || u && o.length > 0) && (e.preventDefault(), e.stopPropagation(), Ce(e));
417
417
  break;
418
418
  case "Backspace":
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", {
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", {
422
422
  option: o[n]
423
423
  });
424
424
  }
425
425
  break;
426
426
  case "Delete":
427
- if (u && !X && a === "" && o.length > 0 && _ !== -1) {
428
- const n = _, r = o.slice();
429
- r.splice(n, 1), j(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", {
430
430
  option: o[n]
431
431
  });
432
432
  }
433
433
  break;
434
434
  }
435
- }, Ze = (t) => {
436
- $e(!0), Be && !me.current && F(t);
437
- }, Ne = (t) => {
438
- if (b(T)) {
435
+ }, Qe = (t) => {
436
+ _e(!0), qe && !ge.current && H(t);
437
+ }, ve = (t) => {
438
+ if (b(_)) {
439
439
  d.current.focus();
440
440
  return;
441
441
  }
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) => {
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) => {
444
444
  const e = t.target.value;
445
- a !== e && (oe(e), Ae(!1), R && R(t, e, "input")), e === "" ? !q && !u && j(t, null, "clear") : F(t);
446
- }, tt = (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) => {
447
447
  const e = Number(t.currentTarget.getAttribute("data-option-index"));
448
- y.current !== e && H({
448
+ y.current !== e && R({
449
449
  event: t,
450
450
  index: e,
451
451
  reason: "mouse"
452
452
  });
453
- }, nt = (t) => {
454
- H({
453
+ }, tt = (t) => {
454
+ R({
455
455
  event: t,
456
456
  index: Number(t.currentTarget.getAttribute("data-option-index")),
457
457
  reason: "touch"
458
- }), le.current = !0;
459
- }, ot = (t) => {
458
+ }), se.current = !0;
459
+ }, nt = (t) => {
460
460
  const e = Number(t.currentTarget.getAttribute("data-option-index"));
461
- Q(t, f[e], "selectOption"), le.current = !1;
462
- }, rt = (t) => (e) => {
461
+ Y(t, f[e], "selectOption"), se.current = !1;
462
+ }, ot = (t) => (e) => {
463
463
  const n = o.slice();
464
- n.splice(t, 1), j(e, n, "removeOption", {
464
+ n.splice(t, 1), B(e, n, "removeOption", {
465
465
  option: o[t]
466
466
  });
467
- }, Le = (t) => {
468
- U ? G(t, "toggleInput") : F(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();
469
471
  }, st = (t) => {
470
- t.currentTarget.contains(t.target) && t.target.getAttribute("id") !== E && t.preventDefault();
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);
471
473
  }, 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);
474
+ !w && (a === "" || !q) && Ne(t);
475
475
  };
476
- let Ie = C && a.length > 0;
477
- Ie = Ie || (u ? o.length > 0 : o !== null);
478
- let Ve = f;
479
- if (K) {
476
+ let ye = i && a.length > 0;
477
+ ye = ye || (u ? o.length > 0 : o !== null);
478
+ let Le = f;
479
+ if (E) {
480
480
  const t = /* @__PURE__ */ new Map();
481
481
  let e = !1;
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({
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({
485
485
  key: s,
486
486
  index: s,
487
- group: i,
487
+ group: l,
488
488
  options: [r]
489
489
  })), n;
490
490
  }, []);
491
491
  }
492
- return S && re && Ne(), {
493
- getRootProps: (t = {}) => Re({
494
- "aria-owns": ye ? `${E}-listbox` : null
492
+ return w && ne && ve(), {
493
+ getRootProps: (t = {}) => Ve({
494
+ "aria-owns": be ? `${T}-listbox` : null
495
495
  }, t, {
496
- onKeyDown: Qe(t),
497
- onMouseDown: st,
498
- onClick: it
496
+ onKeyDown: Ge(t),
497
+ onMouseDown: rt,
498
+ onClick: st
499
499
  }),
500
500
  getInputLabelProps: () => ({
501
- id: `${E}-label`,
502
- htmlFor: E
501
+ id: `${T}-label`,
502
+ htmlFor: T
503
503
  }),
504
504
  getInputProps: () => ({
505
- id: E,
505
+ id: T,
506
506
  value: a,
507
- onBlur: Ne,
508
- onFocus: Ze,
509
- onChange: et,
510
- onMouseDown: lt,
507
+ onBlur: ve,
508
+ onFocus: Qe,
509
+ onChange: Ze,
510
+ onMouseDown: it,
511
511
  // if open then this is handled imperatively so don't let react override
512
512
  // only have an opinion about this when closed
513
- "aria-activedescendant": w ? "" : null,
514
- "aria-autocomplete": A ? "both" : "list",
515
- "aria-controls": ye ? `${E}-listbox` : void 0,
516
- "aria-expanded": ye,
513
+ "aria-activedescendant": S ? "" : null,
514
+ "aria-autocomplete": P ? "both" : "list",
515
+ "aria-controls": be ? `${T}-listbox` : void 0,
516
+ "aria-expanded": be,
517
517
  // Disable browser's suggestion that might overlap with the popup.
518
518
  // Handle autocomplete but not autofill.
519
519
  autoComplete: "off",
@@ -521,7 +521,7 @@ function yt(c) {
521
521
  autoCapitalize: "none",
522
522
  spellCheck: "false",
523
523
  role: "combobox",
524
- disabled: S
524
+ disabled: w
525
525
  }),
526
526
  getClearProps: () => ({
527
527
  tabIndex: -1,
@@ -531,22 +531,22 @@ function yt(c) {
531
531
  getPopupIndicatorProps: () => ({
532
532
  tabIndex: -1,
533
533
  type: "button",
534
- onClick: Le
534
+ onClick: Ne
535
535
  }),
536
536
  getTagProps: ({
537
537
  index: t
538
- }) => Re({
538
+ }) => Ve({
539
539
  key: t,
540
540
  "data-tag-index": t,
541
541
  tabIndex: -1
542
- }, !X && {
543
- onDelete: rt(t)
542
+ }, !J && {
543
+ onDelete: ot(t)
544
544
  }),
545
545
  getListboxProps: () => ({
546
546
  role: "listbox",
547
- id: `${E}-listbox`,
548
- "aria-labelledby": `${E}-label`,
549
- ref: Xe,
547
+ id: `${T}-listbox`,
548
+ "aria-labelledby": `${T}-label`,
549
+ ref: Ye,
550
550
  onMouseDown: (t) => {
551
551
  t.preventDefault();
552
552
  }
@@ -556,105 +556,105 @@ function yt(c) {
556
556
  option: e
557
557
  }) => {
558
558
  var n;
559
- const r = (u ? o : [o]).some((i) => i != null && M(e, i)), s = B ? B(e) : !1;
559
+ const r = (u ? o : [o]).some((l) => l != null && V(e, l)), s = m ? m(e) : !1;
560
560
  return {
561
- key: (n = l == null ? void 0 : l(e)) != null ? n : O(e),
561
+ key: (n = Q == null ? void 0 : Q(e)) != null ? n : O(e),
562
562
  tabIndex: -1,
563
563
  role: "option",
564
- id: `${E}-option-${t}`,
565
- onMouseMove: tt,
566
- onClick: ot,
567
- onTouchStart: nt,
564
+ id: `${T}-option-${t}`,
565
+ onMouseMove: et,
566
+ onClick: nt,
567
+ onTouchStart: tt,
568
568
  "data-option-index": t,
569
569
  "aria-disabled": s,
570
570
  "aria-selected": r
571
571
  };
572
572
  },
573
- id: E,
573
+ id: T,
574
574
  inputValue: a,
575
575
  value: o,
576
- dirty: Ie,
577
- expanded: w && ne,
578
- popupOpen: w,
579
- focused: re || _ !== -1,
580
- anchorEl: ne,
576
+ dirty: ye,
577
+ expanded: S && ee,
578
+ popupOpen: S,
579
+ focused: ne || $ !== -1,
580
+ anchorEl: ee,
581
581
  setAnchorEl: je,
582
- focusedTag: _,
583
- groupedOptions: Ve
582
+ focusedTag: $,
583
+ groupedOptions: Le
584
584
  };
585
585
  }
586
- const Ot = "_autocomplete_pfc9v_1", Z = {
586
+ const Ot = "_autocomplete_pfc9v_1", X = {
587
587
  autocomplete: Ot,
588
588
  "autocomplete__dropdown-list": "_autocomplete__dropdown-list_pfc9v_5",
589
589
  "autocomplete__dropdown-item": "_autocomplete__dropdown-item_pfc9v_17",
590
590
  "option-focused": "_option-focused_pfc9v_26"
591
- }, vt = ({
591
+ }, At = ({
592
592
  labelKey: c,
593
593
  valueKey: b,
594
594
  options: g,
595
- type: A,
596
- value: z,
597
- onChange: L,
598
- onInputChange: D,
599
- "data-testid-wrapper": P,
600
- ...V
595
+ type: P,
596
+ value: U,
597
+ onChange: N,
598
+ onInputChange: C,
599
+ "data-testid-wrapper": v,
600
+ ...L
601
601
  }) => {
602
- const x = ut(), [k, q] = Me(z || ""), [J, S] = Me("");
603
- g != null && g.some((l) => typeof l != "string") && console.error(
602
+ const x = at(), [k, F] = ut("");
603
+ g != null && g.some((i) => typeof i != "string") && (!c || !b) && console.error(
604
604
  '[autocomplete] When options is a list of objects, you must provide the "labelKey" and "valueKey" parameters.'
605
605
  );
606
- const { getRootProps: de, getInputProps: ee, getOptionProps: pe, groupedOptions: W, getListboxProps: C } = yt({
606
+ const { getRootProps: j, getInputProps: w, getOptionProps: ce, groupedOptions: K, getListboxProps: fe } = yt({
607
607
  id: `autocomplete_${x}`,
608
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);
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
615
  },
616
- onInputChange: (l, m) => {
617
- D && D(l, m), S(m);
616
+ onInputChange: (i, m) => {
617
+ C && C(i, m), F(m);
618
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"]);
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
624
  }
625
625
  }
626
- }), B = {
627
- ...ee(),
628
- ...V
626
+ }), G = {
627
+ ...w(),
628
+ ...L
629
629
  };
630
- return /* @__PURE__ */ ue("div", { className: Z.autocomplete, "data-testid": P, children: /* @__PURE__ */ at("div", { ...de(), children: [
631
- /* @__PURE__ */ ue(
630
+ return /* @__PURE__ */ le("div", { className: X.autocomplete, "data-testid": v, children: /* @__PURE__ */ lt("div", { ...j(), children: [
631
+ /* @__PURE__ */ le(
632
632
  dt,
633
633
  {
634
- rightIcon: A === "search" && /* @__PURE__ */ ue(ft, { color: "var(--accent)", icon: "magnifying-glass" }),
635
- ...B
634
+ rightIcon: P === "search" && /* @__PURE__ */ le(ft, { color: "var(--accent)", icon: "magnifying-glass" }),
635
+ ...G
636
636
  }
637
637
  ),
638
- W.length > 0 && !V.disabled && /* @__PURE__ */ ue(
638
+ K.length > 0 && !L.disabled && /* @__PURE__ */ le(
639
639
  "ul",
640
640
  {
641
- ...C(),
641
+ ...fe(),
642
642
  id: "autocomplete-list",
643
- className: Z["autocomplete__dropdown-list"],
644
- children: W.map((l, m) => /* @__PURE__ */ ct(
643
+ className: X["autocomplete__dropdown-list"],
644
+ children: K.map((i, m) => /* @__PURE__ */ ct(
645
645
  "li",
646
646
  {
647
647
  tabIndex: m,
648
- className: Z["autocomplete__dropdown-item"],
649
- ...pe({ option: l, index: m }),
648
+ className: X["autocomplete__dropdown-item"],
649
+ ...ce({ option: i, index: m }),
650
650
  key: String(m)
651
651
  },
652
- typeof l == "string" ? l : String(l[c || "label"])
652
+ typeof i == "string" ? i : String(i[c || "label"])
653
653
  ))
654
654
  }
655
655
  )
656
656
  ] }) });
657
657
  };
658
658
  export {
659
- vt as Autocomplete
659
+ At as Autocomplete
660
660
  };