@pismo/marola 1.0.0-beta.18 → 1.0.0-beta.2

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 (118) hide show
  1. package/dist/{Button-DiLqcAJG.js → Button-2b1peDFT.js} +2 -2
  2. package/dist/{ClickAwayListener-BaJ-OV_7.js → ClickAwayListener-BSW-Nd-y.js} +3 -4
  3. package/dist/Dialog.module-DFEmFdYT.js +30 -0
  4. package/dist/{Popup-lLWZt2wk.js → Popup-B6ZSGIEI.js} +3 -3
  5. package/dist/{Portal-B_Es6eUL.js → Portal-DIeBsWdL.js} +2 -2
  6. package/dist/SelectButton-C8JQKaf4.js +61 -0
  7. package/dist/Toggle-BCgIItCc.js +142 -0
  8. package/dist/assets/Advice.css +1 -1
  9. package/dist/assets/Button.css +1 -1
  10. package/dist/assets/Checkbox.css +1 -1
  11. package/dist/assets/Dialog.css +1 -1
  12. package/dist/assets/IconButton.css +1 -1
  13. package/dist/assets/Input.css +1 -1
  14. package/dist/assets/PageHeader.css +1 -1
  15. package/dist/assets/Pagination.css +1 -1
  16. package/dist/assets/SelectButton.css +1 -1
  17. package/dist/assets/Snackbar.css +1 -1
  18. package/dist/assets/SortTooltip.css +1 -1
  19. package/dist/assets/Stepper.css +1 -1
  20. package/dist/assets/Table.css +1 -1
  21. package/dist/assets/TextDisplay.css +1 -1
  22. package/dist/assets/Toggle.css +1 -1
  23. package/dist/assets/Toggle2.css +1 -1
  24. package/dist/assets/Typography.css +1 -1
  25. package/dist/{combineHooksSlotProps-BtBYUV_B.js → combineHooksSlotProps-DVjg9PRh.js} +1 -1
  26. package/dist/components/Advice/Advice.d.ts +17 -32
  27. package/dist/components/Advice/Advice.js +40 -39
  28. package/dist/components/Advice/Advice.stories.d.ts +3 -4
  29. package/dist/components/Button/Button.d.ts +0 -2
  30. package/dist/components/Button/Button.js +49 -51
  31. package/dist/components/Checkbox/Checkbox.js +52 -52
  32. package/dist/components/Chip/Chip.d.ts +12 -6
  33. package/dist/components/Chip/Chip.js +5 -6
  34. package/dist/components/Chip/Chip.stories.d.ts +14 -5
  35. package/dist/components/Dialog/Actions.js +1 -1
  36. package/dist/components/Dialog/Backdrop.js +1 -1
  37. package/dist/components/Dialog/CloseIconButton.js +2 -2
  38. package/dist/components/Dialog/Dialog.d.ts +6 -9
  39. package/dist/components/Dialog/Dialog.js +162 -162
  40. package/dist/components/Dialog/Dialog.stories.d.ts +46 -50
  41. package/dist/components/Dialog/DialogTitle.js +1 -1
  42. package/dist/components/EllipsisTooltip/EllipsisTooltip.js +17 -30
  43. package/dist/components/EllipsisTooltip/EllipsisTooltip.stories.d.ts +1 -2
  44. package/dist/components/Icon/Icon.js +34 -52
  45. package/dist/components/Icon/types.d.ts +1 -1
  46. package/dist/components/IconButton/IconButton.js +42 -42
  47. package/dist/components/Input/Input.d.ts +2 -4
  48. package/dist/components/Input/Input.js +471 -74
  49. package/dist/components/Input/Input.stories.d.ts +1 -1
  50. package/dist/components/InputSearch/InputSearch.stories.d.ts +1 -1
  51. package/dist/components/PageHeader/PageHeader.js +57 -57
  52. package/dist/components/Pagination/Pagination.d.ts +1 -7
  53. package/dist/components/Pagination/Pagination.js +182 -104
  54. package/dist/components/Select/Select.js +8 -9
  55. package/dist/components/Select/SelectButton.js +1 -1
  56. package/dist/components/Skeleton/Skeleton.d.ts +1 -3
  57. package/dist/components/Skeleton/Skeleton.js +12 -18
  58. package/dist/components/Skeleton/SkeletonTable.stories.d.ts +1 -1
  59. package/dist/components/Snackbar/Snackbar.js +94 -94
  60. package/dist/components/Snackbar/Snackbar.stories.d.ts +3 -3
  61. package/dist/components/SortTooltip/SortTooltip.js +46 -46
  62. package/dist/components/Stepper/Stepper.js +35 -35
  63. package/dist/components/Table/Table.d.ts +1 -3
  64. package/dist/components/Table/Table.js +85 -88
  65. package/dist/components/Table/Table.stories.d.ts +1 -1
  66. package/dist/components/Tabs/Tab.js +17 -18
  67. package/dist/components/Tabs/TabPanel.js +26 -27
  68. package/dist/components/Tabs/Tabs.js +25 -25
  69. package/dist/components/TextDisplay/TextDisplay.d.ts +1 -3
  70. package/dist/components/TextDisplay/TextDisplay.js +28 -42
  71. package/dist/components/TextDisplay/TextDisplay.stories.d.ts +1 -2
  72. package/dist/components/Toggle/Toggle.js +56 -56
  73. package/dist/components/ToggleGroup/Toggle.js +3 -3
  74. package/dist/components/ToggleGroup/ToggleGroup.js +1 -1
  75. package/dist/components/Tooltip/Tooltip.d.ts +1 -3
  76. package/dist/components/Tooltip/Tooltip.js +4 -4
  77. package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -1
  78. package/dist/components/Typography/Typography.js +47 -47
  79. package/dist/{useSlotProps-kRhf7Gil.js → index-CH45lKw7.js} +94 -93
  80. package/dist/{index-D3Wj0eid.js → index-CjW42-M-.js} +1 -1
  81. package/dist/main.d.ts +0 -5
  82. package/dist/main.js +76 -85
  83. package/dist/{useButton-Bn3MNH8I.js → useButton-DNk3wrQp.js} +1 -1
  84. package/dist/useCompoundItem-D1iRfg8D.js +84 -0
  85. package/dist/useEventCallback-xTG9piMa.js +45 -0
  86. package/dist/{useList-BpJT77u3.js → useList-B0hog_3-.js} +2 -2
  87. package/package.json +3 -8
  88. package/dist/Dialog.module-D9e4RsKo.js +0 -30
  89. package/dist/Input.module-ZTRZRcNt.js +0 -405
  90. package/dist/SelectButton-CoOT2txy.js +0 -61
  91. package/dist/Toggle-CRfZgFJp.js +0 -181
  92. package/dist/assets/Adornment.css +0 -1
  93. package/dist/assets/Autocomplete.css +0 -1
  94. package/dist/assets/ResultWithChips.css +0 -1
  95. package/dist/assets/StepperNavigator.css +0 -1
  96. package/dist/components/Adornment/Adornment.d.ts +0 -20
  97. package/dist/components/Adornment/Adornment.js +0 -13
  98. package/dist/components/Adornment/Adornment.stories.d.ts +0 -14
  99. package/dist/components/Adornment/adornment.test.d.ts +0 -1
  100. package/dist/components/Autocomplete/Autocomplete.d.ts +0 -52
  101. package/dist/components/Autocomplete/Autocomplete.js +0 -690
  102. package/dist/components/Autocomplete/Autocomplete.stories.d.ts +0 -46
  103. package/dist/components/Pagination/usePagination.d.ts +0 -90
  104. package/dist/components/Pagination/usePagination.js +0 -79
  105. package/dist/components/ResultWithChips/ResultWithChips.d.ts +0 -12
  106. package/dist/components/ResultWithChips/ResultWithChips.js +0 -33
  107. package/dist/components/RowItem/RowItem.d.ts +0 -25
  108. package/dist/components/RowItem/RowItem.js +0 -19
  109. package/dist/components/RowItem/RowItem.stories.d.ts +0 -17
  110. package/dist/components/RowItem/rowItem.test.d.ts +0 -1
  111. package/dist/components/StepperNavigator/StepperNavigator.d.ts +0 -43
  112. package/dist/components/StepperNavigator/StepperNavigator.js +0 -56
  113. package/dist/components/StepperNavigator/StepperNavigator.stories.d.ts +0 -16
  114. package/dist/components/StepperNavigator/StepperNavigator.test.d.ts +0 -1
  115. package/dist/ownerDocument-B61GUaFs.js +0 -33
  116. package/dist/useCompoundItem-B7Eo_qZk.js +0 -68
  117. package/dist/useEventCallback-BAQJJ3ye.js +0 -14
  118. package/dist/useId-BW-oWmul.js +0 -19
@@ -1,690 +0,0 @@
1
- import '../../assets/Autocomplete.css';
2
- import { jsxs as Fe, jsx as $ } from "react/jsx-runtime";
3
- import * as g from "react";
4
- import { useId as pt, useState as qe } from "react";
5
- import { c as ee } from "../../clsx-DB4S2d7J.js";
6
- import { Icon as Be } from "../Icon/Icon.js";
7
- import { s as P, I as gt } from "../../Input.module-ZTRZRcNt.js";
8
- import { Typography as Ke } from "../Typography/Typography.js";
9
- import { b as Ue, 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;
17
- }), b.current;
18
- };
19
- function je(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: A,
27
- matchFrom: D = "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 = je(I));
37
- const q = I ? M.filter((Y) => {
38
- let _ = (H || m)(Y);
39
- return h && (_ = _.toLowerCase()), b && (_ = je(_)), D === "start" ? _.indexOf(I) === 0 : _.indexOf(I) > -1;
40
- }) : M;
41
- return typeof A == "number" ? q.slice(0, A) : q;
42
- };
43
- }
44
- function be(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(), ze = 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: 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,
68
- 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) => {
79
- var e;
80
- return (e = t.label) != null ? e : t;
81
- },
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);
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 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), Ae = D ? 0 : -1, x = g.useRef(Ae), [r, Ge] = $e({
114
- controlled: We,
115
- default: I,
116
- name: m
117
- }), [a, ce] = $e({
118
- controlled: Ie,
119
- default: "",
120
- name: m,
121
- state: "inputValue"
122
- }), [fe, De] = g.useState(!1), de = 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 && (ce(o), v && v(t, o, "reset"));
135
- }, [y, a, i, v, ce, M, r]), [z, Ee] = $e({
136
- controlled: c,
137
- default: !1,
138
- name: m,
139
- state: "open"
140
- }), [Qe, ve] = g.useState(!0), Ce = !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)))),
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: Ce && 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
- 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(`
161
- `));
162
- }
163
- const pe = me((t) => {
164
- t === -1 ? d.current.focus() : ue.querySelector(`[data-tag-index="${t}"]`).focus();
165
- });
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)
171
- return -1;
172
- let n = t;
173
- 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)
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 = me(({
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, 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));
201
- }
202
- }), L = me(({
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 Ae;
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 : 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;
220
- })(), n);
221
- if (B({
222
- index: l,
223
- reason: o,
224
- event: t
225
- }), A && 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 be(f, (n) => y(n) === y(e));
241
- }
242
- return -1;
243
- }, Pe = 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 && be(r, (s) => E(n, s)) !== -1)
262
- return;
263
- const o = be(f, (s) => E(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
- ne,
288
- L,
289
- B,
290
- w,
291
- a,
292
- i
293
- ]), tt = me((t) => {
294
- ht(N, t), t && Pe();
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
- Pe();
302
- }, [Pe]);
303
- const K = (t) => {
304
- z || (Ee(!0), ve(!0), ae && ae(t));
305
- }, Q = (t, e) => {
306
- z && (Ee(!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]))
310
- return;
311
- } else if (r === e)
312
- 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(`
320
- `));
321
- }
322
- const p = be(l, (O) => E(e, O));
323
- p === -1 ? l.push(e) : o !== "freeSolo" && (l.splice(p, 1), s = "removeOption");
324
- }
325
- de(t, l), J(t, l, s, {
326
- 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();
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 = ue.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 Le = (t, e) => {
344
- if (!i)
345
- 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
- }, Ve = (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))
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: -ze,
373
- direction: "previous",
374
- reason: "keyboard",
375
- event: e
376
- }), K(e);
377
- break;
378
- case "PageDown":
379
- e.preventDefault(), L({
380
- diff: ze,
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
- Le(e, "previous");
404
- break;
405
- case "ArrowRight":
406
- Le(e, "next");
407
- break;
408
- case "Enter":
409
- if (x.current !== -1 && w) {
410
- const n = f[x.current], o = U ? U(n) : !1;
411
- if (e.preventDefault(), o)
412
- return;
413
- Z(e, n, "selectOption"), A && d.current.setSelectionRange(d.current.value.length, d.current.value.length);
414
- } else
415
- R && a !== "" && Ce === !1 && (i && e.preventDefault(), Z(e, a, "createOption", "freeSolo"));
416
- break;
417
- case "Escape":
418
- w ? (e.preventDefault(), e.stopPropagation(), Q(e, "escape")) : F && (a !== "" || i && r.length > 0) && (e.preventDefault(), e.stopPropagation(), Ve(e));
419
- break;
420
- 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]
425
- });
426
- }
427
- break;
428
- 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]
433
- });
434
- }
435
- break;
436
- }
437
- }, ot = (t) => {
438
- De(!0), T && !we.current && K(t);
439
- }, Me = (t) => {
440
- if (b(N)) {
441
- d.current.focus();
442
- return;
443
- }
444
- De(!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) => {
446
- const e = t.target.value;
447
- a !== e && (ce(e), ve(!1), v && v(t, e, "input")), e === "" ? !q && !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
- }), ge.current = !0;
461
- }, at = (t) => {
462
- 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]
468
- });
469
- }, Re = (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) && Re(t);
477
- };
478
- let Te = R && a.length > 0;
479
- Te = Te || (i ? r.length > 0 : r !== null);
480
- let He = f;
481
- if (j) {
482
- const t = /* @__PURE__ */ new Map();
483
- let e = !1;
484
- He = 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 _ && fe && Me(), {
495
- getRootProps: (t = {}) => Ue({
496
- "aria-owns": Se ? `${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: Me,
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": A ? "both" : "list",
517
- "aria-controls": Se ? `${k}-listbox` : void 0,
518
- "aria-expanded": Se,
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: Ve
532
- }),
533
- getPopupIndicatorProps: () => ({
534
- tabIndex: -1,
535
- type: "button",
536
- onClick: Re
537
- }),
538
- getTagProps: ({
539
- index: t
540
- }) => Ue({
541
- key: t,
542
- "data-tag-index": t,
543
- tabIndex: -1
544
- }, !G && {
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 && E(e, l)), s = U ? U(e) : !1;
562
- return {
563
- key: (n = W == null ? void 0 : W(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: Te,
579
- expanded: w && ue,
580
- popupOpen: w,
581
- focused: fe || S !== -1,
582
- anchorEl: ue,
583
- setAnchorEl: Xe,
584
- focusedTag: S,
585
- groupedOptions: He
586
- };
587
- }
588
- const _t = "_autocomplete_1mx2f_1", Je = {
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: 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
614
- }) => {
615
- const re = pt(), j = M || `input_${re}`;
616
- Object.assign(W, { "data-testid": ne });
617
- const [oe, Oe] = qe(), [se, Ie] = qe(""), { 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);
625
- },
626
- onInputChange: (c, T) => {
627
- q && q(c, T), Ie(T);
628
- }
629
- });
630
- return /* @__PURE__ */ Fe("div", { className: "autocomplete", children: [
631
- u && /* @__PURE__ */ $(
632
- Ke,
633
- {
634
- element: "label",
635
- elementProps: { ...ae() },
636
- className: ee(P.input__label, Y),
637
- "data-testid": ye,
638
- children: u
639
- }
640
- ),
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__ */ $(Be, { 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: Je["autocomplete__dropdown-list"], children: X.map((c, T) => /* @__PURE__ */ $(
667
- "li",
668
- {
669
- tabIndex: T,
670
- className: Je["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__ */ Fe(
676
- Ke,
677
- {
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__ */ $(Be, { icon: "circle-exclamation" }),
682
- D || A
683
- ]
684
- }
685
- )
686
- ] });
687
- };
688
- export {
689
- vt as Autocomplete
690
- };