@pismo/marola 1.0.0-beta.9 → 1.0.0
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/Dialog.module-W7UCXlf3.js +29 -0
- package/dist/Group-DspH8hyO.js +30 -0
- package/dist/Popover.module-B4boCutS.js +10 -0
- package/dist/{Popup-lLWZt2wk.js → Popup-Ck3XlWMq.js} +3 -3
- package/dist/{Portal-B_Es6eUL.js → Portal-oY3enyAm.js} +2 -2
- package/dist/SelectButton-B38avP9u.js +75 -0
- package/dist/{Tabs.module-jkH1Qjn7.js → Tabs.module-BGGTkDc5.js} +7 -7
- package/dist/Toggle-MfR7l8Wn.js +190 -0
- package/dist/assets/Alert.css +1 -0
- package/dist/assets/Autocomplete.css +1 -1
- package/dist/assets/Avatar.css +1 -0
- package/dist/assets/Description.css +1 -0
- package/dist/assets/Dialog.css +1 -1
- package/dist/assets/EllipsisTooltip.css +1 -1
- package/dist/assets/Group.css +1 -1
- package/dist/assets/Input.css +1 -1
- package/dist/assets/PageHeader.css +1 -1
- package/dist/assets/Popover.css +1 -0
- package/dist/assets/RadioButton.css +1 -0
- package/dist/assets/ResultWithChips.css +1 -0
- package/dist/assets/SelectButton.css +1 -1
- package/dist/assets/Skeleton.css +1 -1
- package/dist/assets/Snackbar.css +1 -1
- package/dist/assets/StepperNavigator.css +1 -0
- package/dist/assets/Table.css +1 -1
- package/dist/assets/Tabs.css +1 -1
- package/dist/assets/Toggle2.css +1 -1
- package/dist/{combineHooksSlotProps-BtBYUV_B.js → combineHooksSlotProps-C-zYvfnF.js} +1 -1
- package/dist/components/Adornment/Adornment.d.ts +11 -2
- package/dist/components/Adornment/Adornment.js +6 -6
- package/dist/components/Adornment/Adornment.stories.d.ts +14 -0
- package/dist/components/Adornment/adornment.test.d.ts +1 -0
- package/dist/components/Advice/Advice.d.ts +2 -2
- package/dist/components/Alert/Alert.d.ts +11 -0
- package/dist/components/Alert/Alert.js +46 -0
- package/dist/components/Alert/Alert.stories.d.ts +24 -0
- package/dist/components/Alert/Alert.test.d.ts +1 -0
- package/dist/components/Autocomplete/Autocomplete.d.ts +12 -42
- package/dist/components/Autocomplete/Autocomplete.js +422 -432
- package/dist/components/Autocomplete/Autocomplete.stories.d.ts +3 -25
- package/dist/components/Avatar/Avatar.d.ts +15 -0
- package/dist/components/Avatar/Avatar.js +51 -0
- package/dist/components/Avatar/Avatar.stories.d.ts +25 -0
- package/dist/components/Button/Button.d.ts +2 -0
- package/dist/components/Button/Button.js +23 -21
- package/dist/components/Chip/Chip.d.ts +6 -4
- package/dist/components/Chip/Chip.js +10 -6
- package/dist/components/Chip/Chip.stories.d.ts +5 -14
- package/dist/components/ConfirmationDialog/ConfirmationDialog.d.ts +14 -0
- package/dist/components/ConfirmationDialog/ConfirmationDialog.js +37 -0
- package/dist/components/ConfirmationDialog/ConfirmationDialog.stories.d.ts +23 -0
- package/dist/components/ConfirmationDialog/ConfirmationModal.test.d.ts +1 -0
- package/dist/components/Description/Description.d.ts +21 -0
- package/dist/components/Description/Description.js +66 -0
- package/dist/components/Description/Description.stories.d.ts +22 -0
- package/dist/components/Description/Description.test.d.ts +1 -0
- package/dist/components/Dialog/Actions.js +1 -1
- package/dist/components/Dialog/Backdrop.d.ts +3 -3
- package/dist/components/Dialog/Backdrop.js +8 -7
- package/dist/components/Dialog/CloseIconButton.d.ts +1 -2
- package/dist/components/Dialog/CloseIconButton.js +15 -18
- package/dist/components/Dialog/Dialog.d.ts +16 -10
- package/dist/components/Dialog/Dialog.js +167 -167
- package/dist/components/Dialog/Dialog.stories.d.ts +73 -67
- package/dist/components/Dialog/DialogTitle.d.ts +5 -2
- package/dist/components/Dialog/DialogTitle.js +22 -16
- package/dist/components/EllipsisTooltip/EllipsisTooltip.js +30 -17
- package/dist/components/EllipsisTooltip/EllipsisTooltip.stories.d.ts +1 -0
- package/dist/components/Icon/Icon.js +331 -51
- package/dist/components/Icon/types.d.ts +1 -1
- package/dist/components/IconButton/IconButton.js +1 -1
- package/dist/components/Input/Input.d.ts +26 -5
- package/dist/components/Input/Input.js +514 -102
- package/dist/components/Input/Input.stories.d.ts +2 -21
- package/dist/components/InputSearch/InputSearch.d.ts +37 -7
- package/dist/components/InputSearch/InputSearch.js +27 -29
- package/dist/components/InputSearch/InputSearch.stories.d.ts +15 -3
- package/dist/components/PageHeader/PageHeader.d.ts +6 -2
- package/dist/components/PageHeader/PageHeader.js +77 -70
- package/dist/components/PageHeader/PageHeader.stories.d.ts +3 -1
- package/dist/components/PageHeader/PageHeader.test.d.ts +1 -0
- package/dist/components/Pagination/Pagination.d.ts +5 -1
- package/dist/components/Pagination/Pagination.js +45 -46
- package/dist/components/Pagination/Pagination.stories.d.ts +1 -1
- package/dist/components/Popover/Popover.d.ts +32 -0
- package/dist/components/Popover/Popover.js +24 -0
- package/dist/components/Popover/Popover.stories.d.ts +34 -0
- package/dist/components/Popover/PopoverBody.d.ts +6 -0
- package/dist/components/Popover/PopoverBody.js +6 -0
- package/dist/components/Popover/PopoverFooter.d.ts +6 -0
- package/dist/components/Popover/PopoverFooter.js +6 -0
- package/dist/components/Popover/PopoverHeader.d.ts +6 -0
- package/dist/components/Popover/PopoverHeader.js +6 -0
- package/dist/components/RadioButton/RadioButton.d.ts +19 -0
- package/dist/components/RadioButton/RadioButton.js +37 -0
- package/dist/components/RadioButton/RadioButton.stories.d.ts +24 -0
- package/dist/components/RadioButton/RadioButton.test.d.ts +1 -0
- package/dist/components/ResultWithChips/ResultWithChips.d.ts +12 -0
- package/dist/components/ResultWithChips/ResultWithChips.js +33 -0
- package/dist/components/RowItem/RowItem.d.ts +2 -2
- package/dist/components/RowItem/RowItem.js +9 -5
- package/dist/components/RowItem/RowItem.stories.d.ts +17 -0
- package/dist/components/RowItem/rowItem.test.d.ts +1 -0
- package/dist/components/Select/Select.d.ts +22 -0
- package/dist/components/Select/Select.js +476 -414
- package/dist/components/Select/SelectButton.d.ts +2 -0
- package/dist/components/Select/SelectButton.js +3 -2
- package/dist/components/Skeleton/Skeleton.d.ts +3 -1
- package/dist/components/Skeleton/Skeleton.js +20 -14
- package/dist/components/Skeleton/SkeletonTable.stories.d.ts +1 -1
- package/dist/components/Snackbar/Snackbar.js +119 -134
- package/dist/components/StepperNavigator/StepperNavigator.d.ts +58 -0
- package/dist/components/StepperNavigator/StepperNavigator.js +115 -0
- package/dist/components/StepperNavigator/StepperNavigator.stories.d.ts +18 -0
- package/dist/components/StepperNavigator/StepperNavigator.test.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +3 -1
- package/dist/components/Table/Table.js +89 -101
- package/dist/components/Table/Table.stories.d.ts +1 -1
- package/dist/components/Tabs/Tab.d.ts +5 -3
- package/dist/components/Tabs/Tab.js +36 -35
- package/dist/components/Tabs/TabPanel.d.ts +4 -2
- package/dist/components/Tabs/TabPanel.js +48 -38
- package/dist/components/Tabs/Tabs.d.ts +6 -4
- package/dist/components/Tabs/Tabs.js +115 -112
- package/dist/components/TextDisplay/TextDisplay.d.ts +7 -3
- package/dist/components/TextDisplay/TextDisplay.js +44 -37
- package/dist/components/TextDisplay/TextDisplay.stories.d.ts +2 -1
- package/dist/components/Toggle/Toggle.js +1 -1
- package/dist/components/ToggleGroup/Group.d.ts +2 -0
- package/dist/components/ToggleGroup/Group.js +4 -2
- package/dist/components/ToggleGroup/Toggle.d.ts +2 -0
- package/dist/components/ToggleGroup/Toggle.js +8 -4
- package/dist/components/ToggleGroup/ToggleGroup.js +2 -2
- package/dist/components/ToggleGroup/ToggleGroup.stories.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +3 -1
- package/dist/components/Tooltip/Tooltip.js +4 -4
- package/dist/components/Tooltip/Tooltip.stories.d.ts +1 -0
- package/dist/contexts/SnackbarProvider/SnackbarProvider.d.ts +2 -2
- package/dist/contexts/SnackbarProvider/SnackbarProvider.js +35 -30
- package/dist/contexts/SnackbarProvider/SnackbarProvider.stories.d.ts +1 -1
- package/dist/{index-D3Wj0eid.js → index-bQFToy-I.js} +1 -1
- package/dist/main.d.ts +8 -0
- package/dist/main.js +95 -79
- package/dist/marola.css +1 -1
- package/dist/{ownerDocument-B61GUaFs.js → ownerDocument-YGhwAnr1.js} +1 -1
- package/dist/test-utils/assertStyles.d.ts +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 +22 -13
- package/dist/Dialog.module-DFcZsVAd.js +0 -30
- package/dist/Group-B3p31ftp.js +0 -26
- package/dist/Input.module-ZTRZRcNt.js +0 -405
- package/dist/SelectButton-CoOT2txy.js +0 -61
- package/dist/Toggle-f5brSwAI.js +0 -175
|
@@ -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 pt } from "../Icon/Icon.js";
|
|
6
|
+
import { Input as ft } from "../Input/Input.js";
|
|
7
|
+
import { b as je, s as dt } from "../../useSlotProps-C_I1kEHr.js";
|
|
8
|
+
import { u as gt } from "../../useId-BW-oWmul.js";
|
|
9
|
+
import { u as _e } 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 Ve(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: D,
|
|
25
|
+
matchFrom: K = "any",
|
|
26
|
+
stringify: v,
|
|
27
|
+
trim: C = !1
|
|
28
|
+
} = c;
|
|
29
|
+
return (N, {
|
|
30
|
+
inputValue: L,
|
|
31
|
+
getOptionLabel: y
|
|
34
32
|
}) => {
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
let
|
|
39
|
-
return
|
|
40
|
-
}) :
|
|
41
|
-
return typeof
|
|
33
|
+
let S = C ? L.trim() : L;
|
|
34
|
+
g && (S = S.toLowerCase()), b && (S = Ve(S));
|
|
35
|
+
const q = S ? N.filter((z) => {
|
|
36
|
+
let w = (v || y)(z);
|
|
37
|
+
return g && (w = w.toLowerCase()), b && (w = Ve(w)), K === "start" ? w.indexOf(S) === 0 : w.indexOf(S) > -1;
|
|
38
|
+
}) : N;
|
|
39
|
+
return typeof D == "number" ? q.slice(0, D) : q;
|
|
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(), Me = 5, yt = (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 xt(c) {
|
|
55
53
|
const {
|
|
56
54
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
57
|
-
unstable_isActiveElementInListbox: b =
|
|
55
|
+
unstable_isActiveElementInListbox: b = yt,
|
|
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:
|
|
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: D = !1,
|
|
59
|
+
autoHighlight: K = !1,
|
|
60
|
+
autoSelect: v = !1,
|
|
61
|
+
blurOnSelect: C = !1,
|
|
62
|
+
clearOnBlur: N = !c.freeSolo,
|
|
63
|
+
clearOnEscape: L = !1,
|
|
64
|
+
componentName: y = "useAutocomplete",
|
|
65
|
+
defaultValue: S = c.multiple ? [] : null,
|
|
66
|
+
disableClearable: q = !1,
|
|
67
|
+
disableCloseOnSelect: z = !1,
|
|
68
|
+
disabled: w,
|
|
69
|
+
disabledItemsFocusable: ce = !1,
|
|
70
|
+
disableListWrap: J = !1,
|
|
71
|
+
filterOptions: pe = bt,
|
|
72
|
+
filterSelectedOptions: Q = !1,
|
|
73
|
+
freeSolo: i = !1,
|
|
74
|
+
getOptionDisabled: m,
|
|
75
|
+
getOptionKey: j,
|
|
76
|
+
getOptionLabel: V = (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: _,
|
|
81
|
+
handleHomeEndKeys: Z = !c.freeSolo,
|
|
82
|
+
id: fe,
|
|
83
|
+
includeInputInList: Oe = !1,
|
|
84
|
+
inputValue: Re,
|
|
85
|
+
isOptionEqualToValue: M = (t, e) => t === e,
|
|
86
|
+
multiple: u = !1,
|
|
87
|
+
onChange: Ie,
|
|
88
|
+
onClose: Se,
|
|
89
|
+
onHighlightChange: we,
|
|
90
|
+
onInputChange: R,
|
|
91
|
+
onOpen: ke,
|
|
92
|
+
open: He,
|
|
93
|
+
openOnFocus: Fe = !1,
|
|
94
|
+
options: de,
|
|
95
|
+
readOnly: W = !1,
|
|
96
|
+
selectOnFocus: qe = !c.freeSolo,
|
|
97
|
+
value: Be
|
|
98
|
+
} = c, E = gt(fe);
|
|
99
|
+
let O = V;
|
|
100
|
+
O = (t) => {
|
|
101
|
+
const e = V(t);
|
|
104
102
|
if (typeof e != "string") {
|
|
105
103
|
if (process.env.NODE_ENV !== "production") {
|
|
106
|
-
const
|
|
107
|
-
console.error(`MUI: The \`getOptionLabel\` method of ${
|
|
104
|
+
const r = e === void 0 ? "undefined" : `${typeof e} (${e})`;
|
|
105
|
+
console.error(`MUI: The \`getOptionLabel\` method of ${y} returned ${r} 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:
|
|
115
|
-
default:
|
|
116
|
-
name:
|
|
117
|
-
}), [a,
|
|
118
|
-
controlled:
|
|
111
|
+
const ge = h.useRef(!1), he = h.useRef(!0), f = h.useRef(null), T = h.useRef(null), [ee, Ue] = h.useState(null), [$, me] = h.useState(-1), Ee = K ? 0 : -1, x = h.useRef(Ee), [o, Ke] = _e({
|
|
112
|
+
controlled: Be,
|
|
113
|
+
default: S,
|
|
114
|
+
name: y
|
|
115
|
+
}), [a, te] = _e({
|
|
116
|
+
controlled: Re,
|
|
119
117
|
default: "",
|
|
120
|
-
name:
|
|
118
|
+
name: y,
|
|
121
119
|
state: "inputValue"
|
|
122
|
-
}), [
|
|
123
|
-
if (!(
|
|
120
|
+
}), [re, Te] = h.useState(!1), oe = h.useCallback((t, e) => {
|
|
121
|
+
if (!(u ? o.length < e.length : e !== null) && !N)
|
|
124
122
|
return;
|
|
125
|
-
let
|
|
126
|
-
if (
|
|
127
|
-
|
|
123
|
+
let n;
|
|
124
|
+
if (u)
|
|
125
|
+
n = "";
|
|
128
126
|
else if (e == null)
|
|
129
|
-
|
|
127
|
+
n = "";
|
|
130
128
|
else {
|
|
131
|
-
const s =
|
|
132
|
-
|
|
129
|
+
const s = O(e);
|
|
130
|
+
n = typeof s == "string" ? s : "";
|
|
133
131
|
}
|
|
134
|
-
a !==
|
|
135
|
-
}, [
|
|
136
|
-
controlled:
|
|
132
|
+
a !== n && (te(n), R && R(t, n, "reset"));
|
|
133
|
+
}, [O, a, u, R, te, N, o]), [B, $e] = _e({
|
|
134
|
+
controlled: He,
|
|
137
135
|
default: !1,
|
|
138
|
-
name:
|
|
136
|
+
name: y,
|
|
139
137
|
state: "open"
|
|
140
|
-
}), [
|
|
141
|
-
|
|
138
|
+
}), [ze, Pe] = h.useState(!0), Ae = !u && o != null && a === O(o), k = B && !W, p = k ? pe(
|
|
139
|
+
de.filter((t) => !(Q && (u ? o : [o]).some((e) => e !== null && M(t, e)))),
|
|
142
140
|
// we use the empty string to manipulate `filterOptions` to not filter any options
|
|
143
141
|
// i.e. the filter predicate always returns true
|
|
144
142
|
{
|
|
145
|
-
inputValue:
|
|
146
|
-
getOptionLabel:
|
|
143
|
+
inputValue: Ae && ze ? "" : a,
|
|
144
|
+
getOptionLabel: O
|
|
147
145
|
}
|
|
148
|
-
) : [],
|
|
149
|
-
filteredOptions:
|
|
150
|
-
value:
|
|
146
|
+
) : [], P = ht({
|
|
147
|
+
filteredOptions: p,
|
|
148
|
+
value: o,
|
|
151
149
|
inputValue: a
|
|
152
150
|
});
|
|
153
|
-
|
|
154
|
-
const t =
|
|
155
|
-
|
|
156
|
-
}, [
|
|
157
|
-
const
|
|
158
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
159
|
-
const t = (
|
|
160
|
-
t.length > 0 && console.warn([`MUI: The value provided to ${
|
|
151
|
+
h.useEffect(() => {
|
|
152
|
+
const t = o !== P.value;
|
|
153
|
+
re && !t || i && !t || oe(null, o);
|
|
154
|
+
}, [o, oe, re, P.value, i]);
|
|
155
|
+
const be = B && p.length > 0 && !W;
|
|
156
|
+
if (process.env.NODE_ENV !== "production" && o !== null && !i && de.length > 0) {
|
|
157
|
+
const t = (u ? o : [o]).filter((e) => !de.some((r) => M(r, e)));
|
|
158
|
+
t.length > 0 && console.warn([`MUI: The value provided to ${y} 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 ne = ae((t) => {
|
|
162
|
+
t === -1 ? f.current.focus() : ee.querySelector(`[data-tag-index="${t}"]`).focus();
|
|
165
163
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}, [
|
|
169
|
-
function
|
|
170
|
-
if (!
|
|
164
|
+
h.useEffect(() => {
|
|
165
|
+
u && $ > o.length - 1 && (me(-1), ne(-1));
|
|
166
|
+
}, [o, u, $, ne]);
|
|
167
|
+
function Je(t, e) {
|
|
168
|
+
if (!T.current || t < 0 || t >= p.length)
|
|
171
169
|
return -1;
|
|
172
|
-
let
|
|
170
|
+
let r = t;
|
|
173
171
|
for (; ; ) {
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
176
|
-
return
|
|
177
|
-
if (e === "next" ?
|
|
172
|
+
const n = T.current.querySelector(`[data-option-index="${r}"]`), s = ce ? !1 : !n || n.disabled || n.getAttribute("aria-disabled") === "true";
|
|
173
|
+
if (n && n.hasAttribute("tabindex") && !s)
|
|
174
|
+
return r;
|
|
175
|
+
if (e === "next" ? r = (r + 1) % p.length : r = (r - 1 + p.length) % p.length, r === t)
|
|
178
176
|
return -1;
|
|
179
177
|
}
|
|
180
178
|
}
|
|
181
|
-
const
|
|
179
|
+
const H = ae(({
|
|
182
180
|
event: t,
|
|
183
181
|
index: e,
|
|
184
|
-
reason:
|
|
182
|
+
reason: r = "auto"
|
|
185
183
|
}) => {
|
|
186
|
-
if (x.current = e, e === -1 ?
|
|
184
|
+
if (x.current = e, e === -1 ? f.current.removeAttribute("aria-activedescendant") : f.current.setAttribute("aria-activedescendant", `${E}-option-${e}`), we && we(t, e === -1 ? null : p[e], r), !T.current)
|
|
187
185
|
return;
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
let s =
|
|
191
|
-
if (
|
|
186
|
+
const n = T.current.querySelector(`[role="option"].${g}-focused`);
|
|
187
|
+
n && (n.classList.remove(`${g}-focused`), n.classList.remove(`${g}-focusVisible`));
|
|
188
|
+
let s = T.current;
|
|
189
|
+
if (T.current.getAttribute("role") !== "listbox" && (s = T.current.parentElement.querySelector('[role="listbox"]')), !s)
|
|
192
190
|
return;
|
|
193
191
|
if (e === -1) {
|
|
194
192
|
s.scrollTop = 0;
|
|
195
193
|
return;
|
|
196
194
|
}
|
|
197
|
-
const l =
|
|
198
|
-
if (l && (l.classList.add(`${
|
|
199
|
-
const
|
|
200
|
-
|
|
195
|
+
const l = T.current.querySelector(`[data-option-index="${e}"]`);
|
|
196
|
+
if (l && (l.classList.add(`${g}-focused`), r === "keyboard" && l.classList.add(`${g}-focusVisible`), s.scrollHeight > s.clientHeight && r !== "mouse" && r !== "touch")) {
|
|
197
|
+
const d = l, I = s.clientHeight + s.scrollTop, ie = d.offsetTop + d.offsetHeight;
|
|
198
|
+
ie > I ? s.scrollTop = ie - s.clientHeight : d.offsetTop - d.offsetHeight * (_ ? 1.3 : 0) < s.scrollTop && (s.scrollTop = d.offsetTop - d.offsetHeight * (_ ? 1.3 : 0));
|
|
201
199
|
}
|
|
202
|
-
}),
|
|
200
|
+
}), A = ae(({
|
|
203
201
|
event: t,
|
|
204
202
|
diff: e,
|
|
205
|
-
direction:
|
|
206
|
-
reason:
|
|
203
|
+
direction: r = "next",
|
|
204
|
+
reason: n = "auto"
|
|
207
205
|
}) => {
|
|
208
|
-
if (!
|
|
206
|
+
if (!k)
|
|
209
207
|
return;
|
|
210
|
-
const l =
|
|
211
|
-
const
|
|
208
|
+
const l = Je((() => {
|
|
209
|
+
const d = p.length - 1;
|
|
212
210
|
if (e === "reset")
|
|
213
|
-
return
|
|
211
|
+
return Ee;
|
|
214
212
|
if (e === "start")
|
|
215
213
|
return 0;
|
|
216
214
|
if (e === "end")
|
|
217
|
-
return
|
|
218
|
-
const
|
|
219
|
-
return
|
|
220
|
-
})(),
|
|
221
|
-
if (
|
|
215
|
+
return d;
|
|
216
|
+
const I = x.current + e;
|
|
217
|
+
return I < 0 ? I === -1 && Oe ? -1 : J && x.current !== -1 || Math.abs(e) > 1 ? 0 : d : I > d ? I === d + 1 && Oe ? -1 : J || Math.abs(e) > 1 ? d : 0 : I;
|
|
218
|
+
})(), r);
|
|
219
|
+
if (H({
|
|
222
220
|
index: l,
|
|
223
|
-
reason:
|
|
221
|
+
reason: n,
|
|
224
222
|
event: t
|
|
225
|
-
}),
|
|
223
|
+
}), D && e !== "reset")
|
|
226
224
|
if (l === -1)
|
|
227
|
-
|
|
225
|
+
f.current.value = a;
|
|
228
226
|
else {
|
|
229
|
-
const
|
|
230
|
-
|
|
227
|
+
const d = O(p[l]);
|
|
228
|
+
f.current.value = d, d.toLowerCase().indexOf(a.toLowerCase()) === 0 && a.length > 0 && f.current.setSelectionRange(a.length, d.length);
|
|
231
229
|
}
|
|
232
|
-
}),
|
|
233
|
-
const t = (e,
|
|
234
|
-
const
|
|
235
|
-
return
|
|
230
|
+
}), We = () => {
|
|
231
|
+
const t = (e, r) => {
|
|
232
|
+
const n = e ? O(e) : "", s = r ? O(r) : "";
|
|
233
|
+
return n === s;
|
|
236
234
|
};
|
|
237
|
-
if (x.current !== -1 &&
|
|
238
|
-
const e =
|
|
235
|
+
if (x.current !== -1 && P.filteredOptions && P.filteredOptions.length !== p.length && P.inputValue === a && (u ? o.length === P.value.length && P.value.every((e, r) => O(o[r]) === O(e)) : t(P.value, o))) {
|
|
236
|
+
const e = P.filteredOptions[x.current];
|
|
239
237
|
if (e)
|
|
240
|
-
return
|
|
238
|
+
return ue(p, (r) => O(r) === O(e));
|
|
241
239
|
}
|
|
242
240
|
return -1;
|
|
243
|
-
},
|
|
244
|
-
if (!
|
|
241
|
+
}, ye = h.useCallback(() => {
|
|
242
|
+
if (!k)
|
|
245
243
|
return;
|
|
246
|
-
const t =
|
|
244
|
+
const t = We();
|
|
247
245
|
if (t !== -1) {
|
|
248
246
|
x.current = t;
|
|
249
247
|
return;
|
|
250
248
|
}
|
|
251
|
-
const e =
|
|
252
|
-
if (
|
|
253
|
-
|
|
249
|
+
const e = u ? o[0] : o;
|
|
250
|
+
if (p.length === 0 || e == null) {
|
|
251
|
+
A({
|
|
254
252
|
diff: "reset"
|
|
255
253
|
});
|
|
256
254
|
return;
|
|
257
255
|
}
|
|
258
|
-
if (
|
|
256
|
+
if (T.current) {
|
|
259
257
|
if (e != null) {
|
|
260
|
-
const
|
|
261
|
-
if (
|
|
258
|
+
const r = p[x.current];
|
|
259
|
+
if (u && r && ue(o, (s) => M(r, s)) !== -1)
|
|
262
260
|
return;
|
|
263
|
-
const
|
|
264
|
-
|
|
261
|
+
const n = ue(p, (s) => M(s, e));
|
|
262
|
+
n === -1 ? A({
|
|
265
263
|
diff: "reset"
|
|
266
|
-
}) :
|
|
267
|
-
index:
|
|
264
|
+
}) : H({
|
|
265
|
+
index: n
|
|
268
266
|
});
|
|
269
267
|
return;
|
|
270
268
|
}
|
|
271
|
-
if (x.current >=
|
|
272
|
-
|
|
273
|
-
index:
|
|
269
|
+
if (x.current >= p.length - 1) {
|
|
270
|
+
H({
|
|
271
|
+
index: p.length - 1
|
|
274
272
|
});
|
|
275
273
|
return;
|
|
276
274
|
}
|
|
277
|
-
|
|
275
|
+
H({
|
|
278
276
|
index: x.current
|
|
279
277
|
});
|
|
280
278
|
}
|
|
281
279
|
}, [
|
|
282
280
|
// Only sync the highlighted index when the option switch between empty and not
|
|
283
|
-
|
|
281
|
+
p.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
|
+
Q,
|
|
286
|
+
A,
|
|
287
|
+
H,
|
|
288
|
+
k,
|
|
291
289
|
a,
|
|
292
|
-
|
|
293
|
-
]),
|
|
294
|
-
|
|
290
|
+
u
|
|
291
|
+
]), Ye = ae((t) => {
|
|
292
|
+
dt(T, t), t && ye();
|
|
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
|
+
(!f.current || f.current.nodeName !== "INPUT") && (f.current && f.current.nodeName === "TEXTAREA" ? console.warn([`A textarea element was provided to ${y} 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 ${f.current} while an HTMLInputElement was expected.`, `Instead, ${y} expects an input element.`, "", y === "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 (
|
|
309
|
-
if (
|
|
298
|
+
}, [y]), h.useEffect(() => {
|
|
299
|
+
ye();
|
|
300
|
+
}, [ye]);
|
|
301
|
+
const F = (t) => {
|
|
302
|
+
B || ($e(!0), Pe(!0), ke && ke(t));
|
|
303
|
+
}, Y = (t, e) => {
|
|
304
|
+
B && ($e(!1), Se && Se(t, e));
|
|
305
|
+
}, U = (t, e, r, n) => {
|
|
306
|
+
if (u) {
|
|
307
|
+
if (o.length === e.length && o.every((s, l) => s === e[l]))
|
|
310
308
|
return;
|
|
311
|
-
} else if (
|
|
309
|
+
} else if (o === e)
|
|
312
310
|
return;
|
|
313
|
-
|
|
314
|
-
},
|
|
315
|
-
let s =
|
|
316
|
-
if (
|
|
317
|
-
if (l = Array.isArray(
|
|
318
|
-
const
|
|
319
|
-
|
|
311
|
+
Ie && Ie(t, e, r, n), Ke(e);
|
|
312
|
+
}, se = h.useRef(!1), X = (t, e, r = "selectOption", n = "options") => {
|
|
313
|
+
let s = r, l = e;
|
|
314
|
+
if (u) {
|
|
315
|
+
if (l = Array.isArray(o) ? o.slice() : [], process.env.NODE_ENV !== "production") {
|
|
316
|
+
const I = l.filter((ie) => M(e, ie));
|
|
317
|
+
I.length > 1 && console.error([`MUI: The \`isOptionEqualToValue\` method of ${y} 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 d = ue(l, (I) => M(e, I));
|
|
321
|
+
d === -1 ? l.push(e) : n !== "freeSolo" && (l.splice(d, 1), s = "removeOption");
|
|
324
322
|
}
|
|
325
|
-
|
|
323
|
+
oe(t, l), U(t, l, s, {
|
|
326
324
|
option: e
|
|
327
|
-
}), !
|
|
325
|
+
}), !z && (!t || !t.ctrlKey && !t.metaKey) && Y(t, s), (C === !0 || C === "touch" && se.current || C === "mouse" && !se.current) && f.current.blur();
|
|
328
326
|
};
|
|
329
|
-
function
|
|
327
|
+
function Xe(t, e) {
|
|
330
328
|
if (t === -1)
|
|
331
329
|
return -1;
|
|
332
|
-
let
|
|
330
|
+
let r = t;
|
|
333
331
|
for (; ; ) {
|
|
334
|
-
if (e === "next" &&
|
|
332
|
+
if (e === "next" && r === o.length || e === "previous" && r === -1)
|
|
335
333
|
return -1;
|
|
336
|
-
const
|
|
337
|
-
if (!
|
|
338
|
-
|
|
334
|
+
const n = ee.querySelector(`[data-tag-index="${r}"]`);
|
|
335
|
+
if (!n || !n.hasAttribute("tabindex") || n.disabled || n.getAttribute("aria-disabled") === "true")
|
|
336
|
+
r += e === "next" ? 1 : -1;
|
|
339
337
|
else
|
|
340
|
-
return
|
|
338
|
+
return r;
|
|
341
339
|
}
|
|
342
340
|
}
|
|
343
|
-
const
|
|
344
|
-
if (!
|
|
341
|
+
const De = (t, e) => {
|
|
342
|
+
if (!u)
|
|
345
343
|
return;
|
|
346
|
-
a === "" &&
|
|
347
|
-
let
|
|
348
|
-
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
},
|
|
352
|
-
if (t.onKeyDown && t.onKeyDown(e), !e.defaultMuiPrevented && (
|
|
344
|
+
a === "" && Y(t, "toggleInput");
|
|
345
|
+
let r = $;
|
|
346
|
+
$ === -1 ? a === "" && e === "previous" && (r = o.length - 1) : (r += e === "next" ? 1 : -1, r < 0 && (r = 0), r === o.length && (r = -1)), r = Xe(r, e), me(r), ne(r);
|
|
347
|
+
}, Ce = (t) => {
|
|
348
|
+
ge.current = !0, te(""), R && R(t, "", "clear"), U(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), ne(-1)), e.which !== 229))
|
|
353
351
|
switch (e.key) {
|
|
354
352
|
case "Home":
|
|
355
|
-
|
|
353
|
+
k && Z && (e.preventDefault(), A({
|
|
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
|
+
k && Z && (e.preventDefault(), A({
|
|
364
362
|
diff: "end",
|
|
365
363
|
direction: "previous",
|
|
366
364
|
reason: "keyboard",
|
|
@@ -368,187 +366,187 @@ function It(u) {
|
|
|
368
366
|
}));
|
|
369
367
|
break;
|
|
370
368
|
case "PageUp":
|
|
371
|
-
e.preventDefault(),
|
|
372
|
-
diff: -
|
|
369
|
+
e.preventDefault(), A({
|
|
370
|
+
diff: -Me,
|
|
373
371
|
direction: "previous",
|
|
374
372
|
reason: "keyboard",
|
|
375
373
|
event: e
|
|
376
|
-
}),
|
|
374
|
+
}), F(e);
|
|
377
375
|
break;
|
|
378
376
|
case "PageDown":
|
|
379
|
-
e.preventDefault(),
|
|
380
|
-
diff:
|
|
377
|
+
e.preventDefault(), A({
|
|
378
|
+
diff: Me,
|
|
381
379
|
direction: "next",
|
|
382
380
|
reason: "keyboard",
|
|
383
381
|
event: e
|
|
384
|
-
}),
|
|
382
|
+
}), F(e);
|
|
385
383
|
break;
|
|
386
384
|
case "ArrowDown":
|
|
387
|
-
e.preventDefault(),
|
|
385
|
+
e.preventDefault(), A({
|
|
388
386
|
diff: 1,
|
|
389
387
|
direction: "next",
|
|
390
388
|
reason: "keyboard",
|
|
391
389
|
event: e
|
|
392
|
-
}),
|
|
390
|
+
}), F(e);
|
|
393
391
|
break;
|
|
394
392
|
case "ArrowUp":
|
|
395
|
-
e.preventDefault(),
|
|
393
|
+
e.preventDefault(), A({
|
|
396
394
|
diff: -1,
|
|
397
395
|
direction: "previous",
|
|
398
396
|
reason: "keyboard",
|
|
399
397
|
event: e
|
|
400
|
-
}),
|
|
398
|
+
}), F(e);
|
|
401
399
|
break;
|
|
402
400
|
case "ArrowLeft":
|
|
403
|
-
|
|
401
|
+
De(e, "previous");
|
|
404
402
|
break;
|
|
405
403
|
case "ArrowRight":
|
|
406
|
-
|
|
404
|
+
De(e, "next");
|
|
407
405
|
break;
|
|
408
406
|
case "Enter":
|
|
409
|
-
if (x.current !== -1 &&
|
|
410
|
-
const
|
|
411
|
-
if (e.preventDefault(),
|
|
407
|
+
if (x.current !== -1 && k) {
|
|
408
|
+
const r = p[x.current], n = m ? m(r) : !1;
|
|
409
|
+
if (e.preventDefault(), n)
|
|
412
410
|
return;
|
|
413
|
-
|
|
411
|
+
X(e, r, "selectOption"), D && f.current.setSelectionRange(f.current.value.length, f.current.value.length);
|
|
414
412
|
} else
|
|
415
|
-
|
|
413
|
+
i && a !== "" && Ae === !1 && (u && e.preventDefault(), X(e, a, "createOption", "freeSolo"));
|
|
416
414
|
break;
|
|
417
415
|
case "Escape":
|
|
418
|
-
|
|
416
|
+
k ? (e.preventDefault(), e.stopPropagation(), Y(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
|
|
423
|
-
|
|
424
|
-
option: r
|
|
419
|
+
if (u && !W && a === "" && o.length > 0) {
|
|
420
|
+
const r = $ === -1 ? o.length - 1 : $, n = o.slice();
|
|
421
|
+
n.splice(r, 1), U(e, n, "removeOption", {
|
|
422
|
+
option: o[r]
|
|
425
423
|
});
|
|
426
424
|
}
|
|
427
425
|
break;
|
|
428
426
|
case "Delete":
|
|
429
|
-
if (
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
option: r
|
|
427
|
+
if (u && !W && a === "" && o.length > 0 && $ !== -1) {
|
|
428
|
+
const r = $, n = o.slice();
|
|
429
|
+
n.splice(r, 1), U(e, n, "removeOption", {
|
|
430
|
+
option: o[r]
|
|
433
431
|
});
|
|
434
432
|
}
|
|
435
433
|
break;
|
|
436
434
|
}
|
|
437
|
-
},
|
|
438
|
-
|
|
439
|
-
},
|
|
440
|
-
if (b(
|
|
441
|
-
|
|
435
|
+
}, Qe = (t) => {
|
|
436
|
+
Te(!0), Fe && !ge.current && F(t);
|
|
437
|
+
}, Ne = (t) => {
|
|
438
|
+
if (b(T)) {
|
|
439
|
+
f.current.focus();
|
|
442
440
|
return;
|
|
443
441
|
}
|
|
444
|
-
|
|
445
|
-
},
|
|
442
|
+
Te(!1), he.current = !0, ge.current = !1, v && x.current !== -1 && k ? X(t, p[x.current], "blur") : v && i && a !== "" ? X(t, a, "blur", "freeSolo") : N && oe(t, o), Y(t, "blur");
|
|
443
|
+
}, Ze = (t) => {
|
|
446
444
|
const e = t.target.value;
|
|
447
|
-
a !== e && (
|
|
448
|
-
},
|
|
445
|
+
a !== e && (te(e), Pe(!1), R && R(t, e, "input")), e === "" ? !q && !u && U(t, null, "clear") : F(t);
|
|
446
|
+
}, et = (t) => {
|
|
449
447
|
const e = Number(t.currentTarget.getAttribute("data-option-index"));
|
|
450
|
-
x.current !== e &&
|
|
448
|
+
x.current !== e && H({
|
|
451
449
|
event: t,
|
|
452
450
|
index: e,
|
|
453
451
|
reason: "mouse"
|
|
454
452
|
});
|
|
455
|
-
},
|
|
456
|
-
|
|
453
|
+
}, tt = (t) => {
|
|
454
|
+
H({
|
|
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
|
+
}, rt = (t) => {
|
|
462
460
|
const e = Number(t.currentTarget.getAttribute("data-option-index"));
|
|
463
|
-
|
|
464
|
-
},
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
option:
|
|
461
|
+
X(t, p[e], "selectOption"), se.current = !1;
|
|
462
|
+
}, ot = (t) => (e) => {
|
|
463
|
+
const r = o.slice();
|
|
464
|
+
r.splice(t, 1), U(e, r, "removeOption", {
|
|
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
|
+
}, ve = (t) => {
|
|
468
|
+
B ? Y(t, "toggleInput") : F(t);
|
|
469
|
+
}, nt = (t) => {
|
|
470
|
+
t.currentTarget.contains(t.target) && t.target.getAttribute("id") !== E && t.preventDefault();
|
|
471
|
+
}, st = (t) => {
|
|
472
|
+
t.currentTarget.contains(t.target) && (f.current.focus(), qe && he.current && f.current.selectionEnd - f.current.selectionStart === 0 && f.current.select(), he.current = !1);
|
|
473
|
+
}, it = (t) => {
|
|
474
|
+
!w && (a === "" || !B) && ve(t);
|
|
477
475
|
};
|
|
478
|
-
let
|
|
479
|
-
|
|
480
|
-
let
|
|
481
|
-
if (
|
|
476
|
+
let xe = i && a.length > 0;
|
|
477
|
+
xe = xe || (u ? o.length > 0 : o !== null);
|
|
478
|
+
let Le = p;
|
|
479
|
+
if (_) {
|
|
482
480
|
const t = /* @__PURE__ */ new Map();
|
|
483
481
|
let e = !1;
|
|
484
|
-
|
|
485
|
-
const l =
|
|
486
|
-
return
|
|
482
|
+
Le = p.reduce((r, n, s) => {
|
|
483
|
+
const l = _(n);
|
|
484
|
+
return r.length > 0 && r[r.length - 1].group === l ? r[r.length - 1].options.push(n) : (process.env.NODE_ENV !== "production" && (t.get(l) && !e && (console.warn(`MUI: The options provided combined with the \`groupBy\` method of ${y} returns duplicated headers.`, "You can solve the issue by sorting the options with the output of `groupBy`."), e = !0), t.set(l, !0)), r.push({
|
|
487
485
|
key: s,
|
|
488
486
|
index: s,
|
|
489
487
|
group: l,
|
|
490
|
-
options: [
|
|
491
|
-
})),
|
|
488
|
+
options: [n]
|
|
489
|
+
})), r;
|
|
492
490
|
}, []);
|
|
493
491
|
}
|
|
494
|
-
return
|
|
495
|
-
getRootProps: (t = {}) =>
|
|
496
|
-
"aria-owns":
|
|
492
|
+
return w && re && Ne(), {
|
|
493
|
+
getRootProps: (t = {}) => je({
|
|
494
|
+
"aria-owns": be ? `${E}-listbox` : null
|
|
497
495
|
}, t, {
|
|
498
|
-
onKeyDown:
|
|
499
|
-
onMouseDown:
|
|
500
|
-
onClick:
|
|
496
|
+
onKeyDown: Ge(t),
|
|
497
|
+
onMouseDown: nt,
|
|
498
|
+
onClick: st
|
|
501
499
|
}),
|
|
502
500
|
getInputLabelProps: () => ({
|
|
503
|
-
id: `${
|
|
504
|
-
htmlFor:
|
|
501
|
+
id: `${E}-label`,
|
|
502
|
+
htmlFor: E
|
|
505
503
|
}),
|
|
506
504
|
getInputProps: () => ({
|
|
507
|
-
id:
|
|
505
|
+
id: E,
|
|
508
506
|
value: a,
|
|
509
|
-
onBlur:
|
|
510
|
-
onFocus:
|
|
511
|
-
onChange:
|
|
512
|
-
onMouseDown:
|
|
507
|
+
onBlur: Ne,
|
|
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": k ? "" : null,
|
|
514
|
+
"aria-autocomplete": D ? "both" : "list",
|
|
515
|
+
"aria-controls": be ? `${E}-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: f,
|
|
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: ve
|
|
537
535
|
}),
|
|
538
536
|
getTagProps: ({
|
|
539
537
|
index: t
|
|
540
|
-
}) =>
|
|
538
|
+
}) => je({
|
|
541
539
|
key: t,
|
|
542
540
|
"data-tag-index": t,
|
|
543
541
|
tabIndex: -1
|
|
544
|
-
}, !
|
|
545
|
-
onDelete:
|
|
542
|
+
}, !W && {
|
|
543
|
+
onDelete: ot(t)
|
|
546
544
|
}),
|
|
547
545
|
getListboxProps: () => ({
|
|
548
546
|
role: "listbox",
|
|
549
|
-
id: `${
|
|
550
|
-
"aria-labelledby": `${
|
|
551
|
-
ref:
|
|
547
|
+
id: `${E}-listbox`,
|
|
548
|
+
"aria-labelledby": `${E}-label`,
|
|
549
|
+
ref: Ye,
|
|
552
550
|
onMouseDown: (t) => {
|
|
553
551
|
t.preventDefault();
|
|
554
552
|
}
|
|
@@ -557,133 +555,125 @@ function It(u) {
|
|
|
557
555
|
index: t,
|
|
558
556
|
option: e
|
|
559
557
|
}) => {
|
|
560
|
-
var
|
|
561
|
-
const
|
|
558
|
+
var r;
|
|
559
|
+
const n = (u ? o : [o]).some((l) => l != null && M(e, l)), s = m ? m(e) : !1;
|
|
562
560
|
return {
|
|
563
|
-
key: (
|
|
561
|
+
key: (r = j == null ? void 0 : j(e)) != null ? r : O(e),
|
|
564
562
|
tabIndex: -1,
|
|
565
563
|
role: "option",
|
|
566
|
-
id: `${
|
|
567
|
-
onMouseMove:
|
|
568
|
-
onClick:
|
|
569
|
-
onTouchStart:
|
|
564
|
+
id: `${E}-option-${t}`,
|
|
565
|
+
onMouseMove: et,
|
|
566
|
+
onClick: rt,
|
|
567
|
+
onTouchStart: tt,
|
|
570
568
|
"data-option-index": t,
|
|
571
569
|
"aria-disabled": s,
|
|
572
|
-
"aria-selected":
|
|
570
|
+
"aria-selected": n
|
|
573
571
|
};
|
|
574
572
|
},
|
|
575
|
-
id:
|
|
573
|
+
id: E,
|
|
576
574
|
inputValue: a,
|
|
577
|
-
value:
|
|
578
|
-
dirty:
|
|
579
|
-
expanded:
|
|
580
|
-
popupOpen:
|
|
581
|
-
focused:
|
|
582
|
-
anchorEl:
|
|
583
|
-
setAnchorEl:
|
|
584
|
-
focusedTag:
|
|
585
|
-
groupedOptions:
|
|
575
|
+
value: o,
|
|
576
|
+
dirty: xe,
|
|
577
|
+
expanded: k && ee,
|
|
578
|
+
popupOpen: k,
|
|
579
|
+
focused: re || $ !== -1,
|
|
580
|
+
anchorEl: ee,
|
|
581
|
+
setAnchorEl: Ue,
|
|
582
|
+
focusedTag: $,
|
|
583
|
+
groupedOptions: Le
|
|
586
584
|
};
|
|
587
585
|
}
|
|
588
|
-
const _t = "
|
|
586
|
+
const _t = "_autocomplete_mj65r_65", G = {
|
|
587
|
+
"u-typography-h1": "_u-typography-h1_mj65r_1",
|
|
588
|
+
"u-typography-h2": "_u-typography-h2_mj65r_8",
|
|
589
|
+
"u-typography-h3": "_u-typography-h3_mj65r_15",
|
|
590
|
+
"u-typography-h4": "_u-typography-h4_mj65r_22",
|
|
591
|
+
"u-typography-h5": "_u-typography-h5_mj65r_29",
|
|
592
|
+
"u-typography-h6": "_u-typography-h6_mj65r_36",
|
|
593
|
+
"u-typography-base": "_u-typography-base_mj65r_43",
|
|
594
|
+
"u-typography-base--xxl": "_u-typography-base--xxl_mj65r_49",
|
|
595
|
+
"u-typography-base--xl": "_u-typography-base--xl_mj65r_53",
|
|
596
|
+
"u-typography-base--lg": "_u-typography-base--lg_mj65r_57",
|
|
597
|
+
"u-typography-base--sm": "_u-typography-base--sm_mj65r_61",
|
|
598
|
+
"u-typography-base--bold": "_u-typography-base--bold_mj65r_65",
|
|
599
|
+
"autocomplete__dropdown-item": "_autocomplete__dropdown-item_mj65r_65",
|
|
600
|
+
"u-typography-base--strikethrough": "_u-typography-base--strikethrough_mj65r_68",
|
|
601
|
+
"u-typography-base--underlined": "_u-typography-base--underlined_mj65r_71",
|
|
602
|
+
"u-typography-base--strikethrough-underlined": "_u-typography-base--strikethrough-underlined_mj65r_74",
|
|
589
603
|
autocomplete: _t,
|
|
590
|
-
"autocomplete__dropdown-list": "_autocomplete__dropdown-
|
|
591
|
-
"
|
|
592
|
-
},
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
options:
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
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
|
|
604
|
+
"autocomplete__dropdown-list": "_autocomplete__dropdown-list_mj65r_82",
|
|
605
|
+
"option-focused": "_option-focused_mj65r_106"
|
|
606
|
+
}, Pt = ({
|
|
607
|
+
labelKey: c,
|
|
608
|
+
valueKey: b,
|
|
609
|
+
options: g,
|
|
610
|
+
type: D,
|
|
611
|
+
value: K,
|
|
612
|
+
onChange: v,
|
|
613
|
+
onInputChange: C,
|
|
614
|
+
"data-testid-wrapper": N,
|
|
615
|
+
...L
|
|
613
616
|
}) => {
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
617
|
+
const y = at(), [S, q] = ut("");
|
|
618
|
+
g != null && g.some((i) => typeof i != "string") && (!c || !b) && console.error(
|
|
619
|
+
'[autocomplete] When options is a list of objects, you must provide the "labelKey" and "valueKey" parameters.'
|
|
620
|
+
);
|
|
621
|
+
const { getRootProps: z, getInputProps: w, getOptionProps: ce, groupedOptions: J, getListboxProps: pe } = xt({
|
|
622
|
+
id: `autocomplete_${y}`,
|
|
623
|
+
options: g,
|
|
624
|
+
getOptionLabel: (i) => typeof i == "string" ? i : String(i[c || "label"]),
|
|
625
|
+
value: K,
|
|
626
|
+
inputValue: S,
|
|
627
|
+
isOptionEqualToValue: (i, m) => typeof i == "string" ? String(i) === String(m) : String(i[b || "id"]) === String(m[b || "id"]),
|
|
628
|
+
onChange: (i, m) => {
|
|
629
|
+
v && v(i, m);
|
|
624
630
|
},
|
|
625
|
-
onInputChange: (
|
|
626
|
-
|
|
631
|
+
onInputChange: (i, m) => {
|
|
632
|
+
C && C(i, m), q(m);
|
|
633
|
+
},
|
|
634
|
+
onHighlightChange: (i, m, j) => {
|
|
635
|
+
var V;
|
|
636
|
+
if (j === "keyboard") {
|
|
637
|
+
const _ = document.querySelector("#autocomplete-list"), Z = (i == null ? void 0 : i.target).getAttribute("aria-activedescendant");
|
|
638
|
+
_ == null || _.querySelectorAll("li").forEach((fe) => fe.classList.remove(G["option-focused"])), (V = _ == null ? void 0 : _.querySelector(`[id="${Z}"]`)) == null || V.classList.add(G["option-focused"]);
|
|
639
|
+
}
|
|
627
640
|
}
|
|
628
|
-
})
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
641
|
+
}), Q = {
|
|
642
|
+
...w(),
|
|
643
|
+
...L
|
|
644
|
+
};
|
|
645
|
+
return /* @__PURE__ */ le("div", { className: G.autocomplete, "data-testid": N, children: /* @__PURE__ */ lt("div", { ...z(), children: [
|
|
646
|
+
/* @__PURE__ */ le(
|
|
647
|
+
ft,
|
|
632
648
|
{
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
className: Z(P.input__label, U),
|
|
636
|
-
"data-testid": ee,
|
|
637
|
-
children: u
|
|
649
|
+
rightIcon: D === "search" && /* @__PURE__ */ le(pt, { color: "var(--accent)", icon: "magnifying-glass" }),
|
|
650
|
+
...Q
|
|
638
651
|
}
|
|
639
652
|
),
|
|
640
|
-
|
|
641
|
-
|
|
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,
|
|
653
|
+
J.length > 0 && !L.disabled && /* @__PURE__ */ le(
|
|
654
|
+
"ul",
|
|
676
655
|
{
|
|
677
|
-
|
|
678
|
-
"
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
656
|
+
...pe(),
|
|
657
|
+
id: "autocomplete-list",
|
|
658
|
+
className: G["autocomplete__dropdown-list"],
|
|
659
|
+
children: J.map((i, m) => {
|
|
660
|
+
const j = ce({ option: i, index: m }), V = typeof i == "string" ? i : String(i[c || "label"]), _ = j.key === S;
|
|
661
|
+
return /* @__PURE__ */ ct(
|
|
662
|
+
"li",
|
|
663
|
+
{
|
|
664
|
+
tabIndex: m,
|
|
665
|
+
className: G["autocomplete__dropdown-item"],
|
|
666
|
+
...j,
|
|
667
|
+
"aria-selected": _,
|
|
668
|
+
key: String(m)
|
|
669
|
+
},
|
|
670
|
+
V
|
|
671
|
+
);
|
|
672
|
+
})
|
|
683
673
|
}
|
|
684
674
|
)
|
|
685
|
-
] });
|
|
675
|
+
] }) });
|
|
686
676
|
};
|
|
687
677
|
export {
|
|
688
|
-
|
|
678
|
+
Pt as Autocomplete
|
|
689
679
|
};
|