@pismo/marola 1.0.0-beta.7 → 1.0.0-beta.9

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