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