@pismo/marola 1.0.0-beta.2 → 1.0.0-beta.21
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-2b1peDFT.js → Button-DiLqcAJG.js} +2 -2
- package/dist/{ClickAwayListener-BSW-Nd-y.js → ClickAwayListener-BaJ-OV_7.js} +4 -3
- package/dist/Dialog.module-D9e4RsKo.js +30 -0
- package/dist/Input.module-ZTRZRcNt.js +405 -0
- package/dist/{Popup-B6ZSGIEI.js → Popup-lLWZt2wk.js} +3 -3
- package/dist/{Portal-DIeBsWdL.js → Portal-B_Es6eUL.js} +2 -2
- package/dist/SelectButton-CoOT2txy.js +61 -0
- package/dist/Toggle-CRfZgFJp.js +181 -0
- package/dist/assets/Adornment.css +1 -0
- package/dist/assets/Advice.css +1 -1
- package/dist/assets/Autocomplete.css +1 -0
- package/dist/assets/Button.css +1 -1
- package/dist/assets/Checkbox.css +1 -1
- package/dist/assets/Dialog.css +1 -1
- package/dist/assets/IconButton.css +1 -1
- package/dist/assets/Input.css +1 -1
- package/dist/assets/PageHeader.css +1 -1
- package/dist/assets/Pagination.css +1 -1
- package/dist/assets/ResultWithChips.css +1 -0
- package/dist/assets/SelectButton.css +1 -1
- package/dist/assets/Snackbar.css +1 -1
- package/dist/assets/SortTooltip.css +1 -1
- package/dist/assets/Stepper.css +1 -1
- package/dist/assets/StepperNavigator.css +1 -0
- package/dist/assets/Table.css +1 -1
- package/dist/assets/TextDisplay.css +1 -1
- package/dist/assets/Toggle.css +1 -1
- package/dist/assets/Toggle2.css +1 -1
- package/dist/assets/Typography.css +1 -1
- package/dist/{combineHooksSlotProps-DVjg9PRh.js → combineHooksSlotProps-BtBYUV_B.js} +1 -1
- package/dist/components/Adornment/Adornment.d.ts +20 -0
- package/dist/components/Adornment/Adornment.js +13 -0
- 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 +32 -17
- package/dist/components/Advice/Advice.js +39 -40
- package/dist/components/Advice/Advice.stories.d.ts +4 -3
- package/dist/components/Autocomplete/Autocomplete.d.ts +51 -0
- package/dist/components/Autocomplete/Autocomplete.js +691 -0
- package/dist/components/Autocomplete/Autocomplete.stories.d.ts +22 -0
- package/dist/components/Button/Button.d.ts +2 -0
- package/dist/components/Button/Button.js +51 -49
- package/dist/components/Checkbox/Checkbox.js +52 -52
- package/dist/components/Chip/Chip.d.ts +6 -12
- package/dist/components/Chip/Chip.js +6 -5
- package/dist/components/Chip/Chip.stories.d.ts +5 -14
- 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 +9 -6
- package/dist/components/Dialog/Dialog.js +139 -139
- package/dist/components/Dialog/Dialog.stories.d.ts +50 -46
- package/dist/components/Dialog/DialogTitle.js +1 -1
- package/dist/components/EllipsisTooltip/EllipsisTooltip.js +30 -17
- package/dist/components/EllipsisTooltip/EllipsisTooltip.stories.d.ts +2 -1
- package/dist/components/Icon/Icon.js +62 -34
- package/dist/components/Icon/types.d.ts +1 -1
- package/dist/components/IconButton/IconButton.js +42 -42
- package/dist/components/Input/Input.d.ts +4 -2
- package/dist/components/Input/Input.js +74 -471
- package/dist/components/Input/Input.stories.d.ts +1 -1
- package/dist/components/InputSearch/InputSearch.stories.d.ts +1 -1
- package/dist/components/PageHeader/PageHeader.js +57 -57
- package/dist/components/Pagination/Pagination.d.ts +7 -1
- package/dist/components/Pagination/Pagination.js +104 -182
- package/dist/components/Pagination/usePagination.d.ts +90 -0
- package/dist/components/Pagination/usePagination.js +79 -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 +25 -0
- package/dist/components/RowItem/RowItem.js +19 -0
- 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.js +9 -8
- package/dist/components/Select/SelectButton.js +1 -1
- package/dist/components/Skeleton/Skeleton.d.ts +3 -1
- package/dist/components/Skeleton/Skeleton.js +18 -12
- package/dist/components/Skeleton/SkeletonTable.stories.d.ts +1 -1
- package/dist/components/Snackbar/Snackbar.js +94 -94
- package/dist/components/Snackbar/Snackbar.stories.d.ts +3 -3
- package/dist/components/SortTooltip/SortTooltip.js +46 -46
- package/dist/components/Stepper/Stepper.js +35 -35
- package/dist/components/StepperNavigator/StepperNavigator.d.ts +43 -0
- package/dist/components/StepperNavigator/StepperNavigator.js +56 -0
- package/dist/components/StepperNavigator/StepperNavigator.stories.d.ts +16 -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 +88 -85
- package/dist/components/Table/Table.stories.d.ts +1 -1
- package/dist/components/Tabs/Tab.js +18 -17
- package/dist/components/Tabs/TabPanel.js +27 -26
- package/dist/components/Tabs/Tabs.js +25 -25
- package/dist/components/TextDisplay/TextDisplay.d.ts +3 -1
- package/dist/components/TextDisplay/TextDisplay.js +42 -28
- package/dist/components/TextDisplay/TextDisplay.stories.d.ts +2 -1
- package/dist/components/Toggle/Toggle.js +56 -56
- package/dist/components/ToggleGroup/Toggle.js +3 -3
- package/dist/components/ToggleGroup/ToggleGroup.js +1 -1
- 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/components/Typography/Typography.js +47 -47
- package/dist/{index-CjW42-M-.js → index-D3Wj0eid.js} +1 -1
- package/dist/main.d.ts +5 -0
- package/dist/main.js +85 -76
- package/dist/ownerDocument-B61GUaFs.js +33 -0
- package/dist/{useButton-DNk3wrQp.js → useButton-Bn3MNH8I.js} +1 -1
- package/dist/useCompoundItem-B7Eo_qZk.js +68 -0
- package/dist/useEventCallback-BAQJJ3ye.js +14 -0
- package/dist/useId-BW-oWmul.js +19 -0
- package/dist/{useList-B0hog_3-.js → useList-BpJT77u3.js} +2 -2
- package/dist/{index-CH45lKw7.js → useSlotProps-kRhf7Gil.js} +93 -94
- package/package.json +8 -3
- package/dist/Dialog.module-DFEmFdYT.js +0 -30
- package/dist/SelectButton-C8JQKaf4.js +0 -61
- package/dist/Toggle-BCgIItCc.js +0 -142
- package/dist/useCompoundItem-D1iRfg8D.js +0 -84
- package/dist/useEventCallback-xTG9piMa.js +0 -45
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
import '../../assets/Autocomplete.css';
|
|
2
|
+
import { jsxs as qe, jsx as A } from "react/jsx-runtime";
|
|
3
|
+
import * as g from "react";
|
|
4
|
+
import { useId as pt, useState as Be } from "react";
|
|
5
|
+
import { c as ee } from "../../clsx-DB4S2d7J.js";
|
|
6
|
+
import { Icon as Ue } from "../Icon/Icon.js";
|
|
7
|
+
import { s as T, I as gt } from "../../Input.module-ZTRZRcNt.js";
|
|
8
|
+
import { Typography as Ke } from "../Typography/Typography.js";
|
|
9
|
+
import { b as je, 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 ze(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: V,
|
|
27
|
+
matchFrom: B = "any",
|
|
28
|
+
stringify: $,
|
|
29
|
+
trim: M = !1
|
|
30
|
+
} = u;
|
|
31
|
+
return (D, {
|
|
32
|
+
inputValue: U,
|
|
33
|
+
getOptionLabel: m
|
|
34
|
+
}) => {
|
|
35
|
+
let k = M ? U.trim() : U;
|
|
36
|
+
h && (k = k.toLowerCase()), b && (k = ze(k));
|
|
37
|
+
const H = k ? D.filter((K) => {
|
|
38
|
+
let I = ($ || m)(K);
|
|
39
|
+
return h && (I = I.toLowerCase()), b && (I = ze(I)), B === "start" ? I.indexOf(k) === 0 : I.indexOf(k) > -1;
|
|
40
|
+
}) : D;
|
|
41
|
+
return typeof V == "number" ? H.slice(0, V) : H;
|
|
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(), Je = 5, Ot = (u) => {
|
|
51
|
+
var b;
|
|
52
|
+
return u.current !== null && ((b = u.current.parentElement) == null ? void 0 : b.contains(document.activeElement));
|
|
53
|
+
};
|
|
54
|
+
function It(u) {
|
|
55
|
+
const {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
57
|
+
unstable_isActiveElementInListbox: b = Ot,
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
59
|
+
unstable_classNamePrefix: h = "Mui",
|
|
60
|
+
autoComplete: V = !1,
|
|
61
|
+
autoHighlight: B = !1,
|
|
62
|
+
autoSelect: $ = !1,
|
|
63
|
+
blurOnSelect: M = !1,
|
|
64
|
+
clearOnBlur: D = !u.freeSolo,
|
|
65
|
+
clearOnEscape: U = !1,
|
|
66
|
+
componentName: m = "useAutocomplete",
|
|
67
|
+
defaultValue: k = u.multiple ? [] : null,
|
|
68
|
+
disableClearable: H = !1,
|
|
69
|
+
disableCloseOnSelect: K = !1,
|
|
70
|
+
disabled: I,
|
|
71
|
+
disabledItemsFocusable: xe = !1,
|
|
72
|
+
disableListWrap: te = !1,
|
|
73
|
+
filterOptions: ye = yt,
|
|
74
|
+
filterSelectedOptions: ne = !1,
|
|
75
|
+
freeSolo: R = !1,
|
|
76
|
+
getOptionDisabled: j,
|
|
77
|
+
getOptionKey: oe,
|
|
78
|
+
getOptionLabel: W = (t) => {
|
|
79
|
+
var e;
|
|
80
|
+
return (e = t.label) != null ? e : t;
|
|
81
|
+
},
|
|
82
|
+
groupBy: z,
|
|
83
|
+
handleHomeEndKeys: re = !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: le,
|
|
91
|
+
onHighlightChange: X,
|
|
92
|
+
onInputChange: v,
|
|
93
|
+
onOpen: ae,
|
|
94
|
+
open: we,
|
|
95
|
+
openOnFocus: p = !1,
|
|
96
|
+
options: w,
|
|
97
|
+
readOnly: G = !1,
|
|
98
|
+
selectOnFocus: Ye = !u.freeSolo,
|
|
99
|
+
value: We
|
|
100
|
+
} = u, S = mt(Oe);
|
|
101
|
+
let y = W;
|
|
102
|
+
y = (t) => {
|
|
103
|
+
const e = W(t);
|
|
104
|
+
if (typeof e != "string") {
|
|
105
|
+
if (process.env.NODE_ENV !== "production") {
|
|
106
|
+
const n = e === void 0 ? "undefined" : `${typeof e} (${e})`;
|
|
107
|
+
console.error(`MUI: The \`getOptionLabel\` method of ${m} returned ${n} instead of a string for ${JSON.stringify(t)}.`);
|
|
108
|
+
}
|
|
109
|
+
return String(e);
|
|
110
|
+
}
|
|
111
|
+
return e;
|
|
112
|
+
};
|
|
113
|
+
const _e = g.useRef(!1), ke = g.useRef(!0), f = g.useRef(null), N = g.useRef(null), [ue, Xe] = g.useState(null), [P, Se] = g.useState(-1), De = B ? 0 : -1, x = g.useRef(De), [o, Ge] = $e({
|
|
114
|
+
controlled: We,
|
|
115
|
+
default: k,
|
|
116
|
+
name: m
|
|
117
|
+
}), [a, ce] = $e({
|
|
118
|
+
controlled: Ie,
|
|
119
|
+
default: "",
|
|
120
|
+
name: m,
|
|
121
|
+
state: "inputValue"
|
|
122
|
+
}), [fe, Ee] = g.useState(!1), de = g.useCallback((t, e) => {
|
|
123
|
+
if (!(i ? o.length < e.length : e !== null) && !D)
|
|
124
|
+
return;
|
|
125
|
+
let r;
|
|
126
|
+
if (i)
|
|
127
|
+
r = "";
|
|
128
|
+
else if (e == null)
|
|
129
|
+
r = "";
|
|
130
|
+
else {
|
|
131
|
+
const s = y(e);
|
|
132
|
+
r = typeof s == "string" ? s : "";
|
|
133
|
+
}
|
|
134
|
+
a !== r && (ce(r), v && v(t, r, "reset"));
|
|
135
|
+
}, [y, a, i, v, ce, D, o]), [J, ve] = $e({
|
|
136
|
+
controlled: we,
|
|
137
|
+
default: !1,
|
|
138
|
+
name: m,
|
|
139
|
+
state: "open"
|
|
140
|
+
}), [Qe, Ce] = g.useState(!0), Le = !i && o != null && a === y(o), _ = J && !G, c = _ ? ye(
|
|
141
|
+
w.filter((t) => !(ne && (i ? o : [o]).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: Le && Qe ? "" : a,
|
|
146
|
+
getOptionLabel: y
|
|
147
|
+
}
|
|
148
|
+
) : [], C = bt({
|
|
149
|
+
filteredOptions: c,
|
|
150
|
+
value: o,
|
|
151
|
+
inputValue: a
|
|
152
|
+
});
|
|
153
|
+
g.useEffect(() => {
|
|
154
|
+
const t = o !== C.value;
|
|
155
|
+
fe && !t || R && !t || de(null, o);
|
|
156
|
+
}, [o, de, fe, C.value, R]);
|
|
157
|
+
const Ne = J && c.length > 0 && !G;
|
|
158
|
+
if (process.env.NODE_ENV !== "production" && o !== null && !R && w.length > 0) {
|
|
159
|
+
const t = (i ? o : [o]).filter((e) => !w.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 ? f.current.focus() : ue.querySelector(`[data-tag-index="${t}"]`).focus();
|
|
165
|
+
});
|
|
166
|
+
g.useEffect(() => {
|
|
167
|
+
i && P > o.length - 1 && (Se(-1), pe(-1));
|
|
168
|
+
}, [o, i, P, pe]);
|
|
169
|
+
function Ze(t, e) {
|
|
170
|
+
if (!N.current || t < 0 || t >= c.length)
|
|
171
|
+
return -1;
|
|
172
|
+
let n = t;
|
|
173
|
+
for (; ; ) {
|
|
174
|
+
const r = N.current.querySelector(`[data-option-index="${n}"]`), s = xe ? !1 : !r || r.disabled || r.getAttribute("aria-disabled") === "true";
|
|
175
|
+
if (r && r.hasAttribute("tabindex") && !s)
|
|
176
|
+
return n;
|
|
177
|
+
if (e === "next" ? n = (n + 1) % c.length : n = (n - 1 + c.length) % c.length, n === t)
|
|
178
|
+
return -1;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const F = me(({
|
|
182
|
+
event: t,
|
|
183
|
+
index: e,
|
|
184
|
+
reason: n = "auto"
|
|
185
|
+
}) => {
|
|
186
|
+
if (x.current = e, e === -1 ? f.current.removeAttribute("aria-activedescendant") : f.current.setAttribute("aria-activedescendant", `${S}-option-${e}`), X && X(t, e === -1 ? null : c[e], n), !N.current)
|
|
187
|
+
return;
|
|
188
|
+
const r = N.current.querySelector(`[role="option"].${h}-focused`);
|
|
189
|
+
r && (r.classList.remove(`${h}-focused`), r.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 d = l, O = s.clientHeight + s.scrollTop, he = d.offsetTop + d.offsetHeight;
|
|
200
|
+
he > O ? s.scrollTop = he - s.clientHeight : d.offsetTop - d.offsetHeight * (z ? 1.3 : 0) < s.scrollTop && (s.scrollTop = d.offsetTop - d.offsetHeight * (z ? 1.3 : 0));
|
|
201
|
+
}
|
|
202
|
+
}), L = me(({
|
|
203
|
+
event: t,
|
|
204
|
+
diff: e,
|
|
205
|
+
direction: n = "next",
|
|
206
|
+
reason: r = "auto"
|
|
207
|
+
}) => {
|
|
208
|
+
if (!_)
|
|
209
|
+
return;
|
|
210
|
+
const l = Ze((() => {
|
|
211
|
+
const d = c.length - 1;
|
|
212
|
+
if (e === "reset")
|
|
213
|
+
return De;
|
|
214
|
+
if (e === "start")
|
|
215
|
+
return 0;
|
|
216
|
+
if (e === "end")
|
|
217
|
+
return d;
|
|
218
|
+
const O = x.current + e;
|
|
219
|
+
return O < 0 ? O === -1 && se ? -1 : te && x.current !== -1 || Math.abs(e) > 1 ? 0 : d : O > d ? O === d + 1 && se ? -1 : te || Math.abs(e) > 1 ? d : 0 : O;
|
|
220
|
+
})(), n);
|
|
221
|
+
if (F({
|
|
222
|
+
index: l,
|
|
223
|
+
reason: r,
|
|
224
|
+
event: t
|
|
225
|
+
}), V && e !== "reset")
|
|
226
|
+
if (l === -1)
|
|
227
|
+
f.current.value = a;
|
|
228
|
+
else {
|
|
229
|
+
const d = y(c[l]);
|
|
230
|
+
f.current.value = d, d.toLowerCase().indexOf(a.toLowerCase()) === 0 && a.length > 0 && f.current.setSelectionRange(a.length, d.length);
|
|
231
|
+
}
|
|
232
|
+
}), et = () => {
|
|
233
|
+
const t = (e, n) => {
|
|
234
|
+
const r = e ? y(e) : "", s = n ? y(n) : "";
|
|
235
|
+
return r === s;
|
|
236
|
+
};
|
|
237
|
+
if (x.current !== -1 && C.filteredOptions && C.filteredOptions.length !== c.length && C.inputValue === a && (i ? o.length === C.value.length && C.value.every((e, n) => y(o[n]) === y(e)) : t(C.value, o))) {
|
|
238
|
+
const e = C.filteredOptions[x.current];
|
|
239
|
+
if (e)
|
|
240
|
+
return be(c, (n) => y(n) === y(e));
|
|
241
|
+
}
|
|
242
|
+
return -1;
|
|
243
|
+
}, Pe = g.useCallback(() => {
|
|
244
|
+
if (!_)
|
|
245
|
+
return;
|
|
246
|
+
const t = et();
|
|
247
|
+
if (t !== -1) {
|
|
248
|
+
x.current = t;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const e = i ? o[0] : o;
|
|
252
|
+
if (c.length === 0 || e == null) {
|
|
253
|
+
L({
|
|
254
|
+
diff: "reset"
|
|
255
|
+
});
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (N.current) {
|
|
259
|
+
if (e != null) {
|
|
260
|
+
const n = c[x.current];
|
|
261
|
+
if (i && n && be(o, (s) => E(n, s)) !== -1)
|
|
262
|
+
return;
|
|
263
|
+
const r = be(c, (s) => E(s, e));
|
|
264
|
+
r === -1 ? L({
|
|
265
|
+
diff: "reset"
|
|
266
|
+
}) : F({
|
|
267
|
+
index: r
|
|
268
|
+
});
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (x.current >= c.length - 1) {
|
|
272
|
+
F({
|
|
273
|
+
index: c.length - 1
|
|
274
|
+
});
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
F({
|
|
278
|
+
index: x.current
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}, [
|
|
282
|
+
// Only sync the highlighted index when the option switch between empty and not
|
|
283
|
+
c.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 : o,
|
|
287
|
+
ne,
|
|
288
|
+
L,
|
|
289
|
+
F,
|
|
290
|
+
_,
|
|
291
|
+
a,
|
|
292
|
+
i
|
|
293
|
+
]), tt = me((t) => {
|
|
294
|
+
ht(N, t), t && Pe();
|
|
295
|
+
});
|
|
296
|
+
process.env.NODE_ENV !== "production" && g.useEffect(() => {
|
|
297
|
+
(!f.current || f.current.nodeName !== "INPUT") && (f.current && f.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 ${f.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 q = (t) => {
|
|
304
|
+
J || (ve(!0), Ce(!0), ae && ae(t));
|
|
305
|
+
}, Q = (t, e) => {
|
|
306
|
+
J && (ve(!1), le && le(t, e));
|
|
307
|
+
}, Y = (t, e, n, r) => {
|
|
308
|
+
if (i) {
|
|
309
|
+
if (o.length === e.length && o.every((s, l) => s === e[l]))
|
|
310
|
+
return;
|
|
311
|
+
} else if (o === e)
|
|
312
|
+
return;
|
|
313
|
+
ie && ie(t, e, n, r), Ge(e);
|
|
314
|
+
}, ge = g.useRef(!1), Z = (t, e, n = "selectOption", r = "options") => {
|
|
315
|
+
let s = n, l = e;
|
|
316
|
+
if (i) {
|
|
317
|
+
if (l = Array.isArray(o) ? o.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 d = be(l, (O) => E(e, O));
|
|
323
|
+
d === -1 ? l.push(e) : r !== "freeSolo" && (l.splice(d, 1), s = "removeOption");
|
|
324
|
+
}
|
|
325
|
+
de(t, l), Y(t, l, s, {
|
|
326
|
+
option: e
|
|
327
|
+
}), !K && (!t || !t.ctrlKey && !t.metaKey) && Q(t, s), (M === !0 || M === "touch" && ge.current || M === "mouse" && !ge.current) && f.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 === o.length || e === "previous" && n === -1)
|
|
335
|
+
return -1;
|
|
336
|
+
const r = ue.querySelector(`[data-tag-index="${n}"]`);
|
|
337
|
+
if (!r || !r.hasAttribute("tabindex") || r.disabled || r.getAttribute("aria-disabled") === "true")
|
|
338
|
+
n += e === "next" ? 1 : -1;
|
|
339
|
+
else
|
|
340
|
+
return n;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const Ve = (t, e) => {
|
|
344
|
+
if (!i)
|
|
345
|
+
return;
|
|
346
|
+
a === "" && Q(t, "toggleInput");
|
|
347
|
+
let n = P;
|
|
348
|
+
P === -1 ? a === "" && e === "previous" && (n = o.length - 1) : (n += e === "next" ? 1 : -1, n < 0 && (n = 0), n === o.length && (n = -1)), n = nt(n, e), Se(n), pe(n);
|
|
349
|
+
}, Me = (t) => {
|
|
350
|
+
_e.current = !0, ce(""), v && v(t, "", "clear"), Y(t, i ? [] : null, "clear");
|
|
351
|
+
}, ot = (t) => (e) => {
|
|
352
|
+
if (t.onKeyDown && t.onKeyDown(e), !e.defaultMuiPrevented && (P !== -1 && ["ArrowLeft", "ArrowRight"].indexOf(e.key) === -1 && (Se(-1), pe(-1)), e.which !== 229))
|
|
353
|
+
switch (e.key) {
|
|
354
|
+
case "Home":
|
|
355
|
+
_ && re && (e.preventDefault(), L({
|
|
356
|
+
diff: "start",
|
|
357
|
+
direction: "next",
|
|
358
|
+
reason: "keyboard",
|
|
359
|
+
event: e
|
|
360
|
+
}));
|
|
361
|
+
break;
|
|
362
|
+
case "End":
|
|
363
|
+
_ && re && (e.preventDefault(), L({
|
|
364
|
+
diff: "end",
|
|
365
|
+
direction: "previous",
|
|
366
|
+
reason: "keyboard",
|
|
367
|
+
event: e
|
|
368
|
+
}));
|
|
369
|
+
break;
|
|
370
|
+
case "PageUp":
|
|
371
|
+
e.preventDefault(), L({
|
|
372
|
+
diff: -Je,
|
|
373
|
+
direction: "previous",
|
|
374
|
+
reason: "keyboard",
|
|
375
|
+
event: e
|
|
376
|
+
}), q(e);
|
|
377
|
+
break;
|
|
378
|
+
case "PageDown":
|
|
379
|
+
e.preventDefault(), L({
|
|
380
|
+
diff: Je,
|
|
381
|
+
direction: "next",
|
|
382
|
+
reason: "keyboard",
|
|
383
|
+
event: e
|
|
384
|
+
}), q(e);
|
|
385
|
+
break;
|
|
386
|
+
case "ArrowDown":
|
|
387
|
+
e.preventDefault(), L({
|
|
388
|
+
diff: 1,
|
|
389
|
+
direction: "next",
|
|
390
|
+
reason: "keyboard",
|
|
391
|
+
event: e
|
|
392
|
+
}), q(e);
|
|
393
|
+
break;
|
|
394
|
+
case "ArrowUp":
|
|
395
|
+
e.preventDefault(), L({
|
|
396
|
+
diff: -1,
|
|
397
|
+
direction: "previous",
|
|
398
|
+
reason: "keyboard",
|
|
399
|
+
event: e
|
|
400
|
+
}), q(e);
|
|
401
|
+
break;
|
|
402
|
+
case "ArrowLeft":
|
|
403
|
+
Ve(e, "previous");
|
|
404
|
+
break;
|
|
405
|
+
case "ArrowRight":
|
|
406
|
+
Ve(e, "next");
|
|
407
|
+
break;
|
|
408
|
+
case "Enter":
|
|
409
|
+
if (x.current !== -1 && _) {
|
|
410
|
+
const n = c[x.current], r = j ? j(n) : !1;
|
|
411
|
+
if (e.preventDefault(), r)
|
|
412
|
+
return;
|
|
413
|
+
Z(e, n, "selectOption"), V && f.current.setSelectionRange(f.current.value.length, f.current.value.length);
|
|
414
|
+
} else
|
|
415
|
+
R && a !== "" && Le === !1 && (i && e.preventDefault(), Z(e, a, "createOption", "freeSolo"));
|
|
416
|
+
break;
|
|
417
|
+
case "Escape":
|
|
418
|
+
_ ? (e.preventDefault(), e.stopPropagation(), Q(e, "escape")) : U && (a !== "" || i && o.length > 0) && (e.preventDefault(), e.stopPropagation(), Me(e));
|
|
419
|
+
break;
|
|
420
|
+
case "Backspace":
|
|
421
|
+
if (i && !G && a === "" && o.length > 0) {
|
|
422
|
+
const n = P === -1 ? o.length - 1 : P, r = o.slice();
|
|
423
|
+
r.splice(n, 1), Y(e, r, "removeOption", {
|
|
424
|
+
option: o[n]
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
break;
|
|
428
|
+
case "Delete":
|
|
429
|
+
if (i && !G && a === "" && o.length > 0 && P !== -1) {
|
|
430
|
+
const n = P, r = o.slice();
|
|
431
|
+
r.splice(n, 1), Y(e, r, "removeOption", {
|
|
432
|
+
option: o[n]
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
}, rt = (t) => {
|
|
438
|
+
Ee(!0), p && !_e.current && q(t);
|
|
439
|
+
}, Re = (t) => {
|
|
440
|
+
if (b(N)) {
|
|
441
|
+
f.current.focus();
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
Ee(!1), ke.current = !0, _e.current = !1, $ && x.current !== -1 && _ ? Z(t, c[x.current], "blur") : $ && R && a !== "" ? Z(t, a, "blur", "freeSolo") : D && de(t, o), Q(t, "blur");
|
|
445
|
+
}, st = (t) => {
|
|
446
|
+
const e = t.target.value;
|
|
447
|
+
a !== e && (ce(e), Ce(!1), v && v(t, e, "input")), e === "" ? !H && !i && Y(t, null, "clear") : q(t);
|
|
448
|
+
}, it = (t) => {
|
|
449
|
+
const e = Number(t.currentTarget.getAttribute("data-option-index"));
|
|
450
|
+
x.current !== e && F({
|
|
451
|
+
event: t,
|
|
452
|
+
index: e,
|
|
453
|
+
reason: "mouse"
|
|
454
|
+
});
|
|
455
|
+
}, lt = (t) => {
|
|
456
|
+
F({
|
|
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, c[e], "selectOption"), ge.current = !1;
|
|
464
|
+
}, ut = (t) => (e) => {
|
|
465
|
+
const n = o.slice();
|
|
466
|
+
n.splice(t, 1), Y(e, n, "removeOption", {
|
|
467
|
+
option: o[t]
|
|
468
|
+
});
|
|
469
|
+
}, He = (t) => {
|
|
470
|
+
J ? Q(t, "toggleInput") : q(t);
|
|
471
|
+
}, ct = (t) => {
|
|
472
|
+
t.currentTarget.contains(t.target) && t.target.getAttribute("id") !== S && t.preventDefault();
|
|
473
|
+
}, ft = (t) => {
|
|
474
|
+
t.currentTarget.contains(t.target) && (f.current.focus(), Ye && ke.current && f.current.selectionEnd - f.current.selectionStart === 0 && f.current.select(), ke.current = !1);
|
|
475
|
+
}, dt = (t) => {
|
|
476
|
+
!I && (a === "" || !J) && He(t);
|
|
477
|
+
};
|
|
478
|
+
let Te = R && a.length > 0;
|
|
479
|
+
Te = Te || (i ? o.length > 0 : o !== null);
|
|
480
|
+
let Fe = c;
|
|
481
|
+
if (z) {
|
|
482
|
+
const t = /* @__PURE__ */ new Map();
|
|
483
|
+
let e = !1;
|
|
484
|
+
Fe = c.reduce((n, r, s) => {
|
|
485
|
+
const l = z(r);
|
|
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 ${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: [r]
|
|
491
|
+
})), n;
|
|
492
|
+
}, []);
|
|
493
|
+
}
|
|
494
|
+
return I && fe && Re(), {
|
|
495
|
+
getRootProps: (t = {}) => je({
|
|
496
|
+
"aria-owns": Ne ? `${S}-listbox` : null
|
|
497
|
+
}, t, {
|
|
498
|
+
onKeyDown: ot(t),
|
|
499
|
+
onMouseDown: ct,
|
|
500
|
+
onClick: ft
|
|
501
|
+
}),
|
|
502
|
+
getInputLabelProps: () => ({
|
|
503
|
+
id: `${S}-label`,
|
|
504
|
+
htmlFor: S
|
|
505
|
+
}),
|
|
506
|
+
getInputProps: () => ({
|
|
507
|
+
id: S,
|
|
508
|
+
value: a,
|
|
509
|
+
onBlur: Re,
|
|
510
|
+
onFocus: rt,
|
|
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": _ ? "" : null,
|
|
516
|
+
"aria-autocomplete": V ? "both" : "list",
|
|
517
|
+
"aria-controls": Ne ? `${S}-listbox` : void 0,
|
|
518
|
+
"aria-expanded": Ne,
|
|
519
|
+
// Disable browser's suggestion that might overlap with the popup.
|
|
520
|
+
// Handle autocomplete but not autofill.
|
|
521
|
+
autoComplete: "off",
|
|
522
|
+
ref: f,
|
|
523
|
+
autoCapitalize: "none",
|
|
524
|
+
spellCheck: "false",
|
|
525
|
+
role: "combobox",
|
|
526
|
+
disabled: I
|
|
527
|
+
}),
|
|
528
|
+
getClearProps: () => ({
|
|
529
|
+
tabIndex: -1,
|
|
530
|
+
type: "button",
|
|
531
|
+
onClick: Me
|
|
532
|
+
}),
|
|
533
|
+
getPopupIndicatorProps: () => ({
|
|
534
|
+
tabIndex: -1,
|
|
535
|
+
type: "button",
|
|
536
|
+
onClick: He
|
|
537
|
+
}),
|
|
538
|
+
getTagProps: ({
|
|
539
|
+
index: t
|
|
540
|
+
}) => je({
|
|
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: `${S}-listbox`,
|
|
550
|
+
"aria-labelledby": `${S}-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 r = (i ? o : [o]).some((l) => l != null && E(e, l)), s = j ? j(e) : !1;
|
|
562
|
+
return {
|
|
563
|
+
key: (n = oe == null ? void 0 : oe(e)) != null ? n : y(e),
|
|
564
|
+
tabIndex: -1,
|
|
565
|
+
role: "option",
|
|
566
|
+
id: `${S}-option-${t}`,
|
|
567
|
+
onMouseMove: it,
|
|
568
|
+
onClick: at,
|
|
569
|
+
onTouchStart: lt,
|
|
570
|
+
"data-option-index": t,
|
|
571
|
+
"aria-disabled": s,
|
|
572
|
+
"aria-selected": r
|
|
573
|
+
};
|
|
574
|
+
},
|
|
575
|
+
id: S,
|
|
576
|
+
inputValue: a,
|
|
577
|
+
value: o,
|
|
578
|
+
dirty: Te,
|
|
579
|
+
expanded: _ && ue,
|
|
580
|
+
popupOpen: _,
|
|
581
|
+
focused: fe || P !== -1,
|
|
582
|
+
anchorEl: ue,
|
|
583
|
+
setAnchorEl: Xe,
|
|
584
|
+
focusedTag: P,
|
|
585
|
+
groupedOptions: Fe
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
const wt = "_autocomplete_19kw3_1", Ae = {
|
|
589
|
+
autocomplete: wt,
|
|
590
|
+
"autocomplete__dropdown-list": "_autocomplete__dropdown-list_19kw3_4",
|
|
591
|
+
"autocomplete__dropdown-item": "_autocomplete__dropdown-item_19kw3_10"
|
|
592
|
+
}, vt = ({
|
|
593
|
+
label: u,
|
|
594
|
+
type: b,
|
|
595
|
+
labelKey: h,
|
|
596
|
+
options: V,
|
|
597
|
+
infoMessage: B,
|
|
598
|
+
errorMessage: $,
|
|
599
|
+
leftIcon: M,
|
|
600
|
+
rightIcon: D,
|
|
601
|
+
id: U,
|
|
602
|
+
disabled: m,
|
|
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
|
|
615
|
+
}) => {
|
|
616
|
+
const z = pt(), re = U || `input_${z}`;
|
|
617
|
+
Object.assign(W, { "data-testid": R });
|
|
618
|
+
const [Oe, se] = Be(), [Ie, E] = Be(""), { getRootProps: i, getInputProps: ie, getOptionProps: le, groupedOptions: X, getListboxProps: v, focused: ae, getInputLabelProps: we } = It({
|
|
619
|
+
id: re,
|
|
620
|
+
options: V,
|
|
621
|
+
getOptionLabel: (p) => typeof p == "string" ? p : String(p[h || "label"]),
|
|
622
|
+
value: Oe,
|
|
623
|
+
inputValue: Ie,
|
|
624
|
+
onChange: (p, w) => {
|
|
625
|
+
H && H(p, w), se(w);
|
|
626
|
+
},
|
|
627
|
+
onInputChange: (p, w) => {
|
|
628
|
+
K && K(p, w), E(w);
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
return /* @__PURE__ */ qe("div", { className: Ae.autocomplete, children: [
|
|
632
|
+
u && /* @__PURE__ */ A(
|
|
633
|
+
Ke,
|
|
634
|
+
{
|
|
635
|
+
element: "label",
|
|
636
|
+
elementProps: { ...we() },
|
|
637
|
+
className: ee(T.input__label, I),
|
|
638
|
+
"data-testid": ne,
|
|
639
|
+
children: u
|
|
640
|
+
}
|
|
641
|
+
),
|
|
642
|
+
/* @__PURE__ */ A("div", { ...i(), className: ae ? "Mui-focused" : "", children: /* @__PURE__ */ A(
|
|
643
|
+
gt,
|
|
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,
|
|
678
|
+
{
|
|
679
|
+
className: $ ? ee(T["input__error-message"], te) : ee(T["input__info-message"], ye),
|
|
680
|
+
"data-testid": $ ? oe : j,
|
|
681
|
+
children: [
|
|
682
|
+
/* @__PURE__ */ A(Ue, { icon: "circle-exclamation" }),
|
|
683
|
+
$ || B
|
|
684
|
+
]
|
|
685
|
+
}
|
|
686
|
+
)
|
|
687
|
+
] });
|
|
688
|
+
};
|
|
689
|
+
export {
|
|
690
|
+
vt as Autocomplete
|
|
691
|
+
};
|