@pismo/marola 1.0.0-beta.20 → 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.
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._autocomplete_19kw3_1{margin-bottom:16px}._autocomplete__dropdown-list_19kw3_4{padding:0;margin-top:.1rem;border:solid .0625rem var(--gray-25);border-radius:.375rem}._autocomplete__dropdown-item_19kw3_10{padding:.375rem 1rem;list-style-type:none;cursor:pointer}._autocomplete__dropdown-item_19kw3_10:hover{color:var(--accent)}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { InputHTMLAttributes, ReactNode, SyntheticEvent } from 'react';
|
|
2
2
|
|
|
3
|
-
type AutocompleteProps<T> = Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> & {
|
|
3
|
+
export type AutocompleteProps<T> = Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> & {
|
|
4
4
|
/** Label text */
|
|
5
5
|
label?: string;
|
|
6
|
+
/** Object key to be used as label when options are an array of object */
|
|
7
|
+
labelKey?: T extends object ? keyof T : never;
|
|
6
8
|
/** Options array */
|
|
7
9
|
options?: Array<T>;
|
|
8
10
|
/** callback for new option selected */
|
|
@@ -46,7 +48,4 @@ type AutocompleteProps<T> = Omit<InputHTMLAttributes<HTMLInputElement>, 'onChang
|
|
|
46
48
|
/** Id to be applied as `data-testid` on the chars counter element */
|
|
47
49
|
'data-testid-charsCounter'?: string;
|
|
48
50
|
};
|
|
49
|
-
export declare const Autocomplete: <T extends string | (
|
|
50
|
-
label: string;
|
|
51
|
-
})>({ label, type, options, infoMessage, errorMessage, leftIcon, rightIcon, id, disabled, maxLength, onChange, onInputChange, classNameLabel, classNameInput, classNameErrorMessage, classNameInfoMessage, "data-testid-label": testIdLabel, "data-testid-input": testIdInput, "data-testid-infoMessage": testIdInfoMessage, "data-testid-errorMessage": testIdErrorMessage, ...rest }: AutocompleteProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
52
|
-
export {};
|
|
51
|
+
export declare const Autocomplete: <T extends string | object>({ label, type, labelKey, options, infoMessage, errorMessage, leftIcon, rightIcon, id, disabled, maxLength, onChange, onInputChange, classNameLabel, classNameInput, classNameErrorMessage, classNameInfoMessage, "data-testid-label": testIdLabel, "data-testid-input": testIdInput, "data-testid-infoMessage": testIdInfoMessage, "data-testid-errorMessage": testIdErrorMessage, ...rest }: AutocompleteProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import '../../assets/Autocomplete.css';
|
|
2
|
-
import { jsxs as qe, jsx as
|
|
2
|
+
import { jsxs as qe, jsx as A } from "react/jsx-runtime";
|
|
3
3
|
import * as g from "react";
|
|
4
4
|
import { useId as pt, useState as Be } from "react";
|
|
5
5
|
import { c as ee } from "../../clsx-DB4S2d7J.js";
|
|
6
|
-
import { Icon as
|
|
7
|
-
import { s as
|
|
8
|
-
import { Typography as
|
|
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
9
|
import { b as je, s as ht } from "../../useSlotProps-kRhf7Gil.js";
|
|
10
10
|
import { u as mt } from "../../useId-BW-oWmul.js";
|
|
11
11
|
import { u as $e } from "../../useControlled-CCMYYdCM.js";
|
|
@@ -23,22 +23,22 @@ function xt(u = {}) {
|
|
|
23
23
|
const {
|
|
24
24
|
ignoreAccents: b = !0,
|
|
25
25
|
ignoreCase: h = !0,
|
|
26
|
-
limit:
|
|
27
|
-
matchFrom:
|
|
28
|
-
stringify:
|
|
29
|
-
trim:
|
|
26
|
+
limit: V,
|
|
27
|
+
matchFrom: B = "any",
|
|
28
|
+
stringify: $,
|
|
29
|
+
trim: M = !1
|
|
30
30
|
} = u;
|
|
31
|
-
return (
|
|
32
|
-
inputValue:
|
|
31
|
+
return (D, {
|
|
32
|
+
inputValue: U,
|
|
33
33
|
getOptionLabel: m
|
|
34
34
|
}) => {
|
|
35
|
-
let
|
|
36
|
-
h && (
|
|
37
|
-
const
|
|
38
|
-
let
|
|
39
|
-
return h && (
|
|
40
|
-
}) :
|
|
41
|
-
return typeof
|
|
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
42
|
};
|
|
43
43
|
}
|
|
44
44
|
function be(u, b) {
|
|
@@ -57,50 +57,50 @@ function It(u) {
|
|
|
57
57
|
unstable_isActiveElementInListbox: b = Ot,
|
|
58
58
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
59
59
|
unstable_classNamePrefix: h = "Mui",
|
|
60
|
-
autoComplete:
|
|
61
|
-
autoHighlight:
|
|
62
|
-
autoSelect:
|
|
63
|
-
blurOnSelect:
|
|
64
|
-
clearOnBlur:
|
|
65
|
-
clearOnEscape:
|
|
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
66
|
componentName: m = "useAutocomplete",
|
|
67
|
-
defaultValue:
|
|
68
|
-
disableClearable:
|
|
69
|
-
disableCloseOnSelect:
|
|
70
|
-
disabled:
|
|
67
|
+
defaultValue: k = u.multiple ? [] : null,
|
|
68
|
+
disableClearable: H = !1,
|
|
69
|
+
disableCloseOnSelect: K = !1,
|
|
70
|
+
disabled: I,
|
|
71
71
|
disabledItemsFocusable: xe = !1,
|
|
72
72
|
disableListWrap: te = !1,
|
|
73
73
|
filterOptions: ye = yt,
|
|
74
74
|
filterSelectedOptions: ne = !1,
|
|
75
75
|
freeSolo: R = !1,
|
|
76
|
-
getOptionDisabled:
|
|
77
|
-
getOptionKey:
|
|
78
|
-
getOptionLabel:
|
|
76
|
+
getOptionDisabled: j,
|
|
77
|
+
getOptionKey: oe,
|
|
78
|
+
getOptionLabel: W = (t) => {
|
|
79
79
|
var e;
|
|
80
80
|
return (e = t.label) != null ? e : t;
|
|
81
81
|
},
|
|
82
|
-
groupBy:
|
|
83
|
-
handleHomeEndKeys:
|
|
82
|
+
groupBy: z,
|
|
83
|
+
handleHomeEndKeys: re = !u.freeSolo,
|
|
84
84
|
id: Oe,
|
|
85
85
|
includeInputInList: se = !1,
|
|
86
86
|
inputValue: Ie,
|
|
87
87
|
isOptionEqualToValue: E = (t, e) => t === e,
|
|
88
88
|
multiple: i = !1,
|
|
89
89
|
onChange: ie,
|
|
90
|
-
onClose:
|
|
91
|
-
onHighlightChange:
|
|
90
|
+
onClose: le,
|
|
91
|
+
onHighlightChange: X,
|
|
92
92
|
onInputChange: v,
|
|
93
93
|
onOpen: ae,
|
|
94
|
-
open:
|
|
95
|
-
openOnFocus:
|
|
96
|
-
options:
|
|
94
|
+
open: we,
|
|
95
|
+
openOnFocus: p = !1,
|
|
96
|
+
options: w,
|
|
97
97
|
readOnly: G = !1,
|
|
98
98
|
selectOnFocus: Ye = !u.freeSolo,
|
|
99
99
|
value: We
|
|
100
|
-
} = u,
|
|
101
|
-
let y =
|
|
100
|
+
} = u, S = mt(Oe);
|
|
101
|
+
let y = W;
|
|
102
102
|
y = (t) => {
|
|
103
|
-
const e =
|
|
103
|
+
const e = W(t);
|
|
104
104
|
if (typeof e != "string") {
|
|
105
105
|
if (process.env.NODE_ENV !== "production") {
|
|
106
106
|
const n = e === void 0 ? "undefined" : `${typeof e} (${e})`;
|
|
@@ -110,9 +110,9 @@ function It(u) {
|
|
|
110
110
|
}
|
|
111
111
|
return e;
|
|
112
112
|
};
|
|
113
|
-
const
|
|
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
114
|
controlled: We,
|
|
115
|
-
default:
|
|
115
|
+
default: k,
|
|
116
116
|
name: m
|
|
117
117
|
}), [a, ce] = $e({
|
|
118
118
|
controlled: Ie,
|
|
@@ -120,25 +120,25 @@ function It(u) {
|
|
|
120
120
|
name: m,
|
|
121
121
|
state: "inputValue"
|
|
122
122
|
}), [fe, Ee] = g.useState(!1), de = g.useCallback((t, e) => {
|
|
123
|
-
if (!(i ?
|
|
123
|
+
if (!(i ? o.length < e.length : e !== null) && !D)
|
|
124
124
|
return;
|
|
125
|
-
let
|
|
125
|
+
let r;
|
|
126
126
|
if (i)
|
|
127
|
-
|
|
127
|
+
r = "";
|
|
128
128
|
else if (e == null)
|
|
129
|
-
|
|
129
|
+
r = "";
|
|
130
130
|
else {
|
|
131
131
|
const s = y(e);
|
|
132
|
-
|
|
132
|
+
r = typeof s == "string" ? s : "";
|
|
133
133
|
}
|
|
134
|
-
a !==
|
|
135
|
-
}, [y, a, i, v, ce,
|
|
136
|
-
controlled:
|
|
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
137
|
default: !1,
|
|
138
138
|
name: m,
|
|
139
139
|
state: "open"
|
|
140
|
-
}), [Qe, Ce] = g.useState(!0), Le = !i &&
|
|
141
|
-
|
|
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
142
|
// we use the empty string to manipulate `filterOptions` to not filter any options
|
|
143
143
|
// i.e. the filter predicate always returns true
|
|
144
144
|
{
|
|
@@ -146,47 +146,47 @@ function It(u) {
|
|
|
146
146
|
getOptionLabel: y
|
|
147
147
|
}
|
|
148
148
|
) : [], C = bt({
|
|
149
|
-
filteredOptions:
|
|
150
|
-
value:
|
|
149
|
+
filteredOptions: c,
|
|
150
|
+
value: o,
|
|
151
151
|
inputValue: a
|
|
152
152
|
});
|
|
153
153
|
g.useEffect(() => {
|
|
154
|
-
const t =
|
|
155
|
-
fe && !t || R && !t || de(null,
|
|
156
|
-
}, [
|
|
157
|
-
const
|
|
158
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
159
|
-
const t = (i ?
|
|
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
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
161
|
`));
|
|
162
162
|
}
|
|
163
163
|
const pe = me((t) => {
|
|
164
|
-
t === -1 ?
|
|
164
|
+
t === -1 ? f.current.focus() : ue.querySelector(`[data-tag-index="${t}"]`).focus();
|
|
165
165
|
});
|
|
166
166
|
g.useEffect(() => {
|
|
167
|
-
i &&
|
|
168
|
-
}, [
|
|
167
|
+
i && P > o.length - 1 && (Se(-1), pe(-1));
|
|
168
|
+
}, [o, i, P, pe]);
|
|
169
169
|
function Ze(t, e) {
|
|
170
|
-
if (!N.current || t < 0 || t >=
|
|
170
|
+
if (!N.current || t < 0 || t >= c.length)
|
|
171
171
|
return -1;
|
|
172
172
|
let n = t;
|
|
173
173
|
for (; ; ) {
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
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
176
|
return n;
|
|
177
|
-
if (e === "next" ? n = (n + 1) %
|
|
177
|
+
if (e === "next" ? n = (n + 1) % c.length : n = (n - 1 + c.length) % c.length, n === t)
|
|
178
178
|
return -1;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
const
|
|
181
|
+
const F = me(({
|
|
182
182
|
event: t,
|
|
183
183
|
index: e,
|
|
184
184
|
reason: n = "auto"
|
|
185
185
|
}) => {
|
|
186
|
-
if (x.current = e, e === -1 ?
|
|
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
187
|
return;
|
|
188
|
-
const
|
|
189
|
-
|
|
188
|
+
const r = N.current.querySelector(`[role="option"].${h}-focused`);
|
|
189
|
+
r && (r.classList.remove(`${h}-focused`), r.classList.remove(`${h}-focusVisible`));
|
|
190
190
|
let s = N.current;
|
|
191
191
|
if (N.current.getAttribute("role") !== "listbox" && (s = N.current.parentElement.querySelector('[role="listbox"]')), !s)
|
|
192
192
|
return;
|
|
@@ -196,60 +196,60 @@ function It(u) {
|
|
|
196
196
|
}
|
|
197
197
|
const l = N.current.querySelector(`[data-option-index="${e}"]`);
|
|
198
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
|
|
200
|
-
he > O ? s.scrollTop = he - s.clientHeight :
|
|
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
201
|
}
|
|
202
202
|
}), L = me(({
|
|
203
203
|
event: t,
|
|
204
204
|
diff: e,
|
|
205
205
|
direction: n = "next",
|
|
206
|
-
reason:
|
|
206
|
+
reason: r = "auto"
|
|
207
207
|
}) => {
|
|
208
|
-
if (!
|
|
208
|
+
if (!_)
|
|
209
209
|
return;
|
|
210
210
|
const l = Ze((() => {
|
|
211
|
-
const
|
|
211
|
+
const d = c.length - 1;
|
|
212
212
|
if (e === "reset")
|
|
213
213
|
return De;
|
|
214
214
|
if (e === "start")
|
|
215
215
|
return 0;
|
|
216
216
|
if (e === "end")
|
|
217
|
-
return
|
|
217
|
+
return d;
|
|
218
218
|
const O = x.current + e;
|
|
219
|
-
return O < 0 ? O === -1 && se ? -1 : te && x.current !== -1 || Math.abs(e) > 1 ? 0 :
|
|
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
220
|
})(), n);
|
|
221
|
-
if (
|
|
221
|
+
if (F({
|
|
222
222
|
index: l,
|
|
223
|
-
reason:
|
|
223
|
+
reason: r,
|
|
224
224
|
event: t
|
|
225
|
-
}),
|
|
225
|
+
}), V && e !== "reset")
|
|
226
226
|
if (l === -1)
|
|
227
|
-
|
|
227
|
+
f.current.value = a;
|
|
228
228
|
else {
|
|
229
|
-
const
|
|
230
|
-
|
|
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
231
|
}
|
|
232
232
|
}), et = () => {
|
|
233
233
|
const t = (e, n) => {
|
|
234
|
-
const
|
|
235
|
-
return
|
|
234
|
+
const r = e ? y(e) : "", s = n ? y(n) : "";
|
|
235
|
+
return r === s;
|
|
236
236
|
};
|
|
237
|
-
if (x.current !== -1 && C.filteredOptions && C.filteredOptions.length !==
|
|
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
238
|
const e = C.filteredOptions[x.current];
|
|
239
239
|
if (e)
|
|
240
|
-
return be(
|
|
240
|
+
return be(c, (n) => y(n) === y(e));
|
|
241
241
|
}
|
|
242
242
|
return -1;
|
|
243
243
|
}, Pe = g.useCallback(() => {
|
|
244
|
-
if (!
|
|
244
|
+
if (!_)
|
|
245
245
|
return;
|
|
246
246
|
const t = et();
|
|
247
247
|
if (t !== -1) {
|
|
248
248
|
x.current = t;
|
|
249
249
|
return;
|
|
250
250
|
}
|
|
251
|
-
const e = i ?
|
|
252
|
-
if (
|
|
251
|
+
const e = i ? o[0] : o;
|
|
252
|
+
if (c.length === 0 || e == null) {
|
|
253
253
|
L({
|
|
254
254
|
diff: "reset"
|
|
255
255
|
});
|
|
@@ -257,84 +257,84 @@ function It(u) {
|
|
|
257
257
|
}
|
|
258
258
|
if (N.current) {
|
|
259
259
|
if (e != null) {
|
|
260
|
-
const n =
|
|
261
|
-
if (i && n && be(
|
|
260
|
+
const n = c[x.current];
|
|
261
|
+
if (i && n && be(o, (s) => E(n, s)) !== -1)
|
|
262
262
|
return;
|
|
263
|
-
const
|
|
264
|
-
|
|
263
|
+
const r = be(c, (s) => E(s, e));
|
|
264
|
+
r === -1 ? L({
|
|
265
265
|
diff: "reset"
|
|
266
|
-
}) :
|
|
267
|
-
index:
|
|
266
|
+
}) : F({
|
|
267
|
+
index: r
|
|
268
268
|
});
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
|
-
if (x.current >=
|
|
272
|
-
|
|
273
|
-
index:
|
|
271
|
+
if (x.current >= c.length - 1) {
|
|
272
|
+
F({
|
|
273
|
+
index: c.length - 1
|
|
274
274
|
});
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
277
|
-
|
|
277
|
+
F({
|
|
278
278
|
index: x.current
|
|
279
279
|
});
|
|
280
280
|
}
|
|
281
281
|
}, [
|
|
282
282
|
// Only sync the highlighted index when the option switch between empty and not
|
|
283
|
-
|
|
283
|
+
c.length,
|
|
284
284
|
// Don't sync the highlighted index with the value when multiple
|
|
285
285
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
286
|
-
i ? !1 :
|
|
286
|
+
i ? !1 : o,
|
|
287
287
|
ne,
|
|
288
288
|
L,
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
F,
|
|
290
|
+
_,
|
|
291
291
|
a,
|
|
292
292
|
i
|
|
293
293
|
]), tt = me((t) => {
|
|
294
294
|
ht(N, t), t && Pe();
|
|
295
295
|
});
|
|
296
296
|
process.env.NODE_ENV !== "production" && g.useEffect(() => {
|
|
297
|
-
(!
|
|
298
|
-
`)) : console.error([`MUI: Unable to find the input element. It was resolved to ${
|
|
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
299
|
`)));
|
|
300
300
|
}, [m]), g.useEffect(() => {
|
|
301
301
|
Pe();
|
|
302
302
|
}, [Pe]);
|
|
303
|
-
const
|
|
304
|
-
|
|
303
|
+
const q = (t) => {
|
|
304
|
+
J || (ve(!0), Ce(!0), ae && ae(t));
|
|
305
305
|
}, Q = (t, e) => {
|
|
306
|
-
|
|
307
|
-
},
|
|
306
|
+
J && (ve(!1), le && le(t, e));
|
|
307
|
+
}, Y = (t, e, n, r) => {
|
|
308
308
|
if (i) {
|
|
309
|
-
if (
|
|
309
|
+
if (o.length === e.length && o.every((s, l) => s === e[l]))
|
|
310
310
|
return;
|
|
311
|
-
} else if (
|
|
311
|
+
} else if (o === e)
|
|
312
312
|
return;
|
|
313
|
-
ie && ie(t, e, n,
|
|
314
|
-
}, ge = g.useRef(!1), Z = (t, e, n = "selectOption",
|
|
313
|
+
ie && ie(t, e, n, r), Ge(e);
|
|
314
|
+
}, ge = g.useRef(!1), Z = (t, e, n = "selectOption", r = "options") => {
|
|
315
315
|
let s = n, l = e;
|
|
316
316
|
if (i) {
|
|
317
|
-
if (l = Array.isArray(
|
|
317
|
+
if (l = Array.isArray(o) ? o.slice() : [], process.env.NODE_ENV !== "production") {
|
|
318
318
|
const O = l.filter((he) => E(e, he));
|
|
319
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
320
|
`));
|
|
321
321
|
}
|
|
322
|
-
const
|
|
323
|
-
|
|
322
|
+
const d = be(l, (O) => E(e, O));
|
|
323
|
+
d === -1 ? l.push(e) : r !== "freeSolo" && (l.splice(d, 1), s = "removeOption");
|
|
324
324
|
}
|
|
325
|
-
de(t, l),
|
|
325
|
+
de(t, l), Y(t, l, s, {
|
|
326
326
|
option: e
|
|
327
|
-
}), !
|
|
327
|
+
}), !K && (!t || !t.ctrlKey && !t.metaKey) && Q(t, s), (M === !0 || M === "touch" && ge.current || M === "mouse" && !ge.current) && f.current.blur();
|
|
328
328
|
};
|
|
329
329
|
function nt(t, e) {
|
|
330
330
|
if (t === -1)
|
|
331
331
|
return -1;
|
|
332
332
|
let n = t;
|
|
333
333
|
for (; ; ) {
|
|
334
|
-
if (e === "next" && n ===
|
|
334
|
+
if (e === "next" && n === o.length || e === "previous" && n === -1)
|
|
335
335
|
return -1;
|
|
336
|
-
const
|
|
337
|
-
if (!
|
|
336
|
+
const r = ue.querySelector(`[data-tag-index="${n}"]`);
|
|
337
|
+
if (!r || !r.hasAttribute("tabindex") || r.disabled || r.getAttribute("aria-disabled") === "true")
|
|
338
338
|
n += e === "next" ? 1 : -1;
|
|
339
339
|
else
|
|
340
340
|
return n;
|
|
@@ -344,15 +344,15 @@ function It(u) {
|
|
|
344
344
|
if (!i)
|
|
345
345
|
return;
|
|
346
346
|
a === "" && Q(t, "toggleInput");
|
|
347
|
-
let n =
|
|
348
|
-
|
|
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
349
|
}, Me = (t) => {
|
|
350
|
-
|
|
351
|
-
},
|
|
352
|
-
if (t.onKeyDown && t.onKeyDown(e), !e.defaultMuiPrevented && (
|
|
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
353
|
switch (e.key) {
|
|
354
354
|
case "Home":
|
|
355
|
-
|
|
355
|
+
_ && re && (e.preventDefault(), L({
|
|
356
356
|
diff: "start",
|
|
357
357
|
direction: "next",
|
|
358
358
|
reason: "keyboard",
|
|
@@ -360,7 +360,7 @@ function It(u) {
|
|
|
360
360
|
}));
|
|
361
361
|
break;
|
|
362
362
|
case "End":
|
|
363
|
-
|
|
363
|
+
_ && re && (e.preventDefault(), L({
|
|
364
364
|
diff: "end",
|
|
365
365
|
direction: "previous",
|
|
366
366
|
reason: "keyboard",
|
|
@@ -373,7 +373,7 @@ function It(u) {
|
|
|
373
373
|
direction: "previous",
|
|
374
374
|
reason: "keyboard",
|
|
375
375
|
event: e
|
|
376
|
-
}),
|
|
376
|
+
}), q(e);
|
|
377
377
|
break;
|
|
378
378
|
case "PageDown":
|
|
379
379
|
e.preventDefault(), L({
|
|
@@ -381,7 +381,7 @@ function It(u) {
|
|
|
381
381
|
direction: "next",
|
|
382
382
|
reason: "keyboard",
|
|
383
383
|
event: e
|
|
384
|
-
}),
|
|
384
|
+
}), q(e);
|
|
385
385
|
break;
|
|
386
386
|
case "ArrowDown":
|
|
387
387
|
e.preventDefault(), L({
|
|
@@ -389,7 +389,7 @@ function It(u) {
|
|
|
389
389
|
direction: "next",
|
|
390
390
|
reason: "keyboard",
|
|
391
391
|
event: e
|
|
392
|
-
}),
|
|
392
|
+
}), q(e);
|
|
393
393
|
break;
|
|
394
394
|
case "ArrowUp":
|
|
395
395
|
e.preventDefault(), L({
|
|
@@ -397,7 +397,7 @@ function It(u) {
|
|
|
397
397
|
direction: "previous",
|
|
398
398
|
reason: "keyboard",
|
|
399
399
|
event: e
|
|
400
|
-
}),
|
|
400
|
+
}), q(e);
|
|
401
401
|
break;
|
|
402
402
|
case "ArrowLeft":
|
|
403
403
|
Ve(e, "previous");
|
|
@@ -406,124 +406,124 @@ function It(u) {
|
|
|
406
406
|
Ve(e, "next");
|
|
407
407
|
break;
|
|
408
408
|
case "Enter":
|
|
409
|
-
if (x.current !== -1 &&
|
|
410
|
-
const n =
|
|
411
|
-
if (e.preventDefault(),
|
|
409
|
+
if (x.current !== -1 && _) {
|
|
410
|
+
const n = c[x.current], r = j ? j(n) : !1;
|
|
411
|
+
if (e.preventDefault(), r)
|
|
412
412
|
return;
|
|
413
|
-
Z(e, n, "selectOption"),
|
|
413
|
+
Z(e, n, "selectOption"), V && f.current.setSelectionRange(f.current.value.length, f.current.value.length);
|
|
414
414
|
} else
|
|
415
415
|
R && a !== "" && Le === !1 && (i && e.preventDefault(), Z(e, a, "createOption", "freeSolo"));
|
|
416
416
|
break;
|
|
417
417
|
case "Escape":
|
|
418
|
-
|
|
418
|
+
_ ? (e.preventDefault(), e.stopPropagation(), Q(e, "escape")) : U && (a !== "" || i && o.length > 0) && (e.preventDefault(), e.stopPropagation(), Me(e));
|
|
419
419
|
break;
|
|
420
420
|
case "Backspace":
|
|
421
|
-
if (i && !G && a === "" &&
|
|
422
|
-
const n =
|
|
423
|
-
|
|
424
|
-
option:
|
|
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
425
|
});
|
|
426
426
|
}
|
|
427
427
|
break;
|
|
428
428
|
case "Delete":
|
|
429
|
-
if (i && !G && a === "" &&
|
|
430
|
-
const n =
|
|
431
|
-
|
|
432
|
-
option:
|
|
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
433
|
});
|
|
434
434
|
}
|
|
435
435
|
break;
|
|
436
436
|
}
|
|
437
|
-
},
|
|
438
|
-
Ee(!0),
|
|
437
|
+
}, rt = (t) => {
|
|
438
|
+
Ee(!0), p && !_e.current && q(t);
|
|
439
439
|
}, Re = (t) => {
|
|
440
440
|
if (b(N)) {
|
|
441
|
-
|
|
441
|
+
f.current.focus();
|
|
442
442
|
return;
|
|
443
443
|
}
|
|
444
|
-
Ee(!1), ke.current = !0,
|
|
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
445
|
}, st = (t) => {
|
|
446
446
|
const e = t.target.value;
|
|
447
|
-
a !== e && (ce(e), Ce(!1), v && v(t, e, "input")), e === "" ? !
|
|
447
|
+
a !== e && (ce(e), Ce(!1), v && v(t, e, "input")), e === "" ? !H && !i && Y(t, null, "clear") : q(t);
|
|
448
448
|
}, it = (t) => {
|
|
449
449
|
const e = Number(t.currentTarget.getAttribute("data-option-index"));
|
|
450
|
-
x.current !== e &&
|
|
450
|
+
x.current !== e && F({
|
|
451
451
|
event: t,
|
|
452
452
|
index: e,
|
|
453
453
|
reason: "mouse"
|
|
454
454
|
});
|
|
455
455
|
}, lt = (t) => {
|
|
456
|
-
|
|
456
|
+
F({
|
|
457
457
|
event: t,
|
|
458
458
|
index: Number(t.currentTarget.getAttribute("data-option-index")),
|
|
459
459
|
reason: "touch"
|
|
460
460
|
}), ge.current = !0;
|
|
461
461
|
}, at = (t) => {
|
|
462
462
|
const e = Number(t.currentTarget.getAttribute("data-option-index"));
|
|
463
|
-
Z(t,
|
|
463
|
+
Z(t, c[e], "selectOption"), ge.current = !1;
|
|
464
464
|
}, ut = (t) => (e) => {
|
|
465
|
-
const n =
|
|
466
|
-
n.splice(t, 1),
|
|
467
|
-
option:
|
|
465
|
+
const n = o.slice();
|
|
466
|
+
n.splice(t, 1), Y(e, n, "removeOption", {
|
|
467
|
+
option: o[t]
|
|
468
468
|
});
|
|
469
469
|
}, He = (t) => {
|
|
470
|
-
|
|
470
|
+
J ? Q(t, "toggleInput") : q(t);
|
|
471
471
|
}, ct = (t) => {
|
|
472
|
-
t.currentTarget.contains(t.target) && t.target.getAttribute("id") !==
|
|
472
|
+
t.currentTarget.contains(t.target) && t.target.getAttribute("id") !== S && t.preventDefault();
|
|
473
473
|
}, ft = (t) => {
|
|
474
|
-
t.currentTarget.contains(t.target) && (
|
|
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
475
|
}, dt = (t) => {
|
|
476
|
-
!
|
|
476
|
+
!I && (a === "" || !J) && He(t);
|
|
477
477
|
};
|
|
478
478
|
let Te = R && a.length > 0;
|
|
479
|
-
Te = Te || (i ?
|
|
480
|
-
let Fe =
|
|
481
|
-
if (
|
|
479
|
+
Te = Te || (i ? o.length > 0 : o !== null);
|
|
480
|
+
let Fe = c;
|
|
481
|
+
if (z) {
|
|
482
482
|
const t = /* @__PURE__ */ new Map();
|
|
483
483
|
let e = !1;
|
|
484
|
-
Fe =
|
|
485
|
-
const l =
|
|
486
|
-
return n.length > 0 && n[n.length - 1].group === l ? n[n.length - 1].options.push(
|
|
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
487
|
key: s,
|
|
488
488
|
index: s,
|
|
489
489
|
group: l,
|
|
490
|
-
options: [
|
|
490
|
+
options: [r]
|
|
491
491
|
})), n;
|
|
492
492
|
}, []);
|
|
493
493
|
}
|
|
494
|
-
return
|
|
494
|
+
return I && fe && Re(), {
|
|
495
495
|
getRootProps: (t = {}) => je({
|
|
496
|
-
"aria-owns":
|
|
496
|
+
"aria-owns": Ne ? `${S}-listbox` : null
|
|
497
497
|
}, t, {
|
|
498
|
-
onKeyDown:
|
|
498
|
+
onKeyDown: ot(t),
|
|
499
499
|
onMouseDown: ct,
|
|
500
500
|
onClick: ft
|
|
501
501
|
}),
|
|
502
502
|
getInputLabelProps: () => ({
|
|
503
|
-
id: `${
|
|
504
|
-
htmlFor:
|
|
503
|
+
id: `${S}-label`,
|
|
504
|
+
htmlFor: S
|
|
505
505
|
}),
|
|
506
506
|
getInputProps: () => ({
|
|
507
|
-
id:
|
|
507
|
+
id: S,
|
|
508
508
|
value: a,
|
|
509
509
|
onBlur: Re,
|
|
510
|
-
onFocus:
|
|
510
|
+
onFocus: rt,
|
|
511
511
|
onChange: st,
|
|
512
512
|
onMouseDown: dt,
|
|
513
513
|
// if open then this is handled imperatively so don't let react override
|
|
514
514
|
// only have an opinion about this when closed
|
|
515
|
-
"aria-activedescendant":
|
|
516
|
-
"aria-autocomplete":
|
|
517
|
-
"aria-controls":
|
|
518
|
-
"aria-expanded":
|
|
515
|
+
"aria-activedescendant": _ ? "" : null,
|
|
516
|
+
"aria-autocomplete": V ? "both" : "list",
|
|
517
|
+
"aria-controls": Ne ? `${S}-listbox` : void 0,
|
|
518
|
+
"aria-expanded": Ne,
|
|
519
519
|
// Disable browser's suggestion that might overlap with the popup.
|
|
520
520
|
// Handle autocomplete but not autofill.
|
|
521
521
|
autoComplete: "off",
|
|
522
|
-
ref:
|
|
522
|
+
ref: f,
|
|
523
523
|
autoCapitalize: "none",
|
|
524
524
|
spellCheck: "false",
|
|
525
525
|
role: "combobox",
|
|
526
|
-
disabled:
|
|
526
|
+
disabled: I
|
|
527
527
|
}),
|
|
528
528
|
getClearProps: () => ({
|
|
529
529
|
tabIndex: -1,
|
|
@@ -546,8 +546,8 @@ function It(u) {
|
|
|
546
546
|
}),
|
|
547
547
|
getListboxProps: () => ({
|
|
548
548
|
role: "listbox",
|
|
549
|
-
id: `${
|
|
550
|
-
"aria-labelledby": `${
|
|
549
|
+
id: `${S}-listbox`,
|
|
550
|
+
"aria-labelledby": `${S}-label`,
|
|
551
551
|
ref: tt,
|
|
552
552
|
onMouseDown: (t) => {
|
|
553
553
|
t.preventDefault();
|
|
@@ -558,128 +558,129 @@ function It(u) {
|
|
|
558
558
|
option: e
|
|
559
559
|
}) => {
|
|
560
560
|
var n;
|
|
561
|
-
const
|
|
561
|
+
const r = (i ? o : [o]).some((l) => l != null && E(e, l)), s = j ? j(e) : !1;
|
|
562
562
|
return {
|
|
563
|
-
key: (n =
|
|
563
|
+
key: (n = oe == null ? void 0 : oe(e)) != null ? n : y(e),
|
|
564
564
|
tabIndex: -1,
|
|
565
565
|
role: "option",
|
|
566
|
-
id: `${
|
|
566
|
+
id: `${S}-option-${t}`,
|
|
567
567
|
onMouseMove: it,
|
|
568
568
|
onClick: at,
|
|
569
569
|
onTouchStart: lt,
|
|
570
570
|
"data-option-index": t,
|
|
571
571
|
"aria-disabled": s,
|
|
572
|
-
"aria-selected":
|
|
572
|
+
"aria-selected": r
|
|
573
573
|
};
|
|
574
574
|
},
|
|
575
|
-
id:
|
|
575
|
+
id: S,
|
|
576
576
|
inputValue: a,
|
|
577
|
-
value:
|
|
577
|
+
value: o,
|
|
578
578
|
dirty: Te,
|
|
579
|
-
expanded:
|
|
580
|
-
popupOpen:
|
|
581
|
-
focused: fe ||
|
|
579
|
+
expanded: _ && ue,
|
|
580
|
+
popupOpen: _,
|
|
581
|
+
focused: fe || P !== -1,
|
|
582
582
|
anchorEl: ue,
|
|
583
583
|
setAnchorEl: Xe,
|
|
584
|
-
focusedTag:
|
|
584
|
+
focusedTag: P,
|
|
585
585
|
groupedOptions: Fe
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
|
-
const
|
|
589
|
-
autocomplete:
|
|
590
|
-
"autocomplete__dropdown-list": "_autocomplete__dropdown-
|
|
591
|
-
"autocomplete__dropdown-item": "_autocomplete__dropdown-
|
|
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
592
|
}, vt = ({
|
|
593
593
|
label: u,
|
|
594
594
|
type: b,
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
"data-testid-
|
|
611
|
-
"data-testid-
|
|
612
|
-
"data-testid-
|
|
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,
|
|
613
614
|
...W
|
|
614
615
|
}) => {
|
|
615
|
-
const
|
|
616
|
-
Object.assign(W, { "data-testid":
|
|
617
|
-
const [
|
|
618
|
-
id:
|
|
619
|
-
options:
|
|
620
|
-
getOptionLabel: (
|
|
621
|
-
value:
|
|
622
|
-
inputValue:
|
|
623
|
-
onChange: (
|
|
624
|
-
|
|
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);
|
|
625
626
|
},
|
|
626
|
-
onInputChange: (
|
|
627
|
-
|
|
627
|
+
onInputChange: (p, w) => {
|
|
628
|
+
K && K(p, w), E(w);
|
|
628
629
|
}
|
|
629
630
|
});
|
|
630
631
|
return /* @__PURE__ */ qe("div", { className: Ae.autocomplete, children: [
|
|
631
|
-
u && /* @__PURE__ */
|
|
632
|
-
|
|
632
|
+
u && /* @__PURE__ */ A(
|
|
633
|
+
Ke,
|
|
633
634
|
{
|
|
634
635
|
element: "label",
|
|
635
|
-
elementProps: { ...
|
|
636
|
-
className: ee(
|
|
637
|
-
"data-testid":
|
|
636
|
+
elementProps: { ...we() },
|
|
637
|
+
className: ee(T.input__label, I),
|
|
638
|
+
"data-testid": ne,
|
|
638
639
|
children: u
|
|
639
640
|
}
|
|
640
641
|
),
|
|
641
|
-
/* @__PURE__ */
|
|
642
|
+
/* @__PURE__ */ A("div", { ...i(), className: ae ? "Mui-focused" : "", children: /* @__PURE__ */ A(
|
|
642
643
|
gt,
|
|
643
644
|
{
|
|
644
|
-
disabled:
|
|
645
|
-
error:
|
|
645
|
+
disabled: m,
|
|
646
|
+
error: !!$,
|
|
646
647
|
"aria-label": u,
|
|
647
648
|
slotProps: {
|
|
648
|
-
root: (
|
|
649
|
-
className: ee(
|
|
650
|
-
[
|
|
651
|
-
[
|
|
652
|
-
[
|
|
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
|
|
653
654
|
})
|
|
654
655
|
}),
|
|
655
656
|
input: {
|
|
656
|
-
...
|
|
657
|
-
className: ee(
|
|
658
|
-
maxLength:
|
|
657
|
+
...ie(),
|
|
658
|
+
className: ee(T["input__input-el"], xe),
|
|
659
|
+
maxLength: k,
|
|
659
660
|
...W
|
|
660
661
|
}
|
|
661
662
|
},
|
|
662
|
-
startAdornment:
|
|
663
|
-
endAdornment: b === "search" ? /* @__PURE__ */
|
|
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 })
|
|
664
665
|
}
|
|
665
666
|
) }),
|
|
666
|
-
X.length > 0 && !
|
|
667
|
+
X.length > 0 && !m && /* @__PURE__ */ A("ul", { ...v(), className: Ae["autocomplete__dropdown-list"], children: X.map((p, w) => /* @__PURE__ */ A(
|
|
667
668
|
"li",
|
|
668
669
|
{
|
|
669
|
-
tabIndex:
|
|
670
|
+
tabIndex: w,
|
|
670
671
|
className: Ae["autocomplete__dropdown-item"],
|
|
671
|
-
...
|
|
672
|
-
children: typeof
|
|
672
|
+
...le({ option: p, index: w }),
|
|
673
|
+
children: typeof p == "string" ? p : String(p[h || "label"])
|
|
673
674
|
}
|
|
674
675
|
)) }),
|
|
675
|
-
(
|
|
676
|
-
|
|
676
|
+
($ || B) && /* @__PURE__ */ qe(
|
|
677
|
+
Ke,
|
|
677
678
|
{
|
|
678
|
-
className:
|
|
679
|
-
"data-testid":
|
|
679
|
+
className: $ ? ee(T["input__error-message"], te) : ee(T["input__info-message"], ye),
|
|
680
|
+
"data-testid": $ ? oe : j,
|
|
680
681
|
children: [
|
|
681
|
-
/* @__PURE__ */
|
|
682
|
-
|
|
682
|
+
/* @__PURE__ */ A(Ue, { icon: "circle-exclamation" }),
|
|
683
|
+
$ || B
|
|
683
684
|
]
|
|
684
685
|
}
|
|
685
686
|
)
|
|
@@ -2,32 +2,7 @@ import { StoryObj } from '@storybook/react';
|
|
|
2
2
|
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: <T extends string | (
|
|
6
|
-
label: string;
|
|
7
|
-
})>({ label, type, options, infoMessage, errorMessage, leftIcon, rightIcon, id, disabled, maxLength, onChange, onInputChange, classNameLabel, classNameInput, classNameErrorMessage, classNameInfoMessage, "data-testid-label": testIdLabel, "data-testid-input": testIdInput, "data-testid-infoMessage": testIdInfoMessage, "data-testid-errorMessage": testIdErrorMessage, ...rest }: Omit<import('react').InputHTMLAttributes<HTMLInputElement>, "onChange"> & {
|
|
8
|
-
label?: string | undefined;
|
|
9
|
-
options?: T[] | undefined;
|
|
10
|
-
onChange?: ((event: import('react').SyntheticEvent<Element, Event>, newValue: T) => void) | undefined;
|
|
11
|
-
onInputChange?: ((event: import('react').SyntheticEvent<Element, Event>, newValue: string) => void) | undefined;
|
|
12
|
-
infoMessage?: string | undefined;
|
|
13
|
-
errorMessage?: string | undefined;
|
|
14
|
-
leftIcon?: import('react').ReactNode;
|
|
15
|
-
rightIcon?: import('react').ReactNode;
|
|
16
|
-
type?: "search" | "text" | "password" | undefined;
|
|
17
|
-
hideCharsCounter?: boolean | undefined;
|
|
18
|
-
classNameWrapper?: string | undefined;
|
|
19
|
-
classNameLabel?: string | undefined;
|
|
20
|
-
classNameInput?: string | undefined;
|
|
21
|
-
classNameInfoMessage?: string | undefined;
|
|
22
|
-
classNameErrorMessage?: string | undefined;
|
|
23
|
-
classNameCharsCounter?: string | undefined;
|
|
24
|
-
'data-testid-wrapper'?: string | undefined;
|
|
25
|
-
'data-testid-label'?: string | undefined;
|
|
26
|
-
'data-testid-input'?: string | undefined;
|
|
27
|
-
'data-testid-infoMessage'?: string | undefined;
|
|
28
|
-
'data-testid-errorMessage'?: string | undefined;
|
|
29
|
-
'data-testid-charsCounter'?: string | undefined;
|
|
30
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
component: <T extends string | object>({ label, type, labelKey, options, infoMessage, errorMessage, leftIcon, rightIcon, id, disabled, maxLength, onChange, onInputChange, classNameLabel, classNameInput, classNameErrorMessage, classNameInfoMessage, "data-testid-label": testIdLabel, "data-testid-input": testIdInput, "data-testid-infoMessage": testIdInfoMessage, "data-testid-errorMessage": testIdErrorMessage, ...rest }: import('./Autocomplete.tsx').AutocompleteProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
31
6
|
tags: string[];
|
|
32
7
|
parameters: {
|
|
33
8
|
layout: string;
|
|
@@ -36,6 +11,7 @@ declare const meta: {
|
|
|
36
11
|
export default meta;
|
|
37
12
|
type Story = StoryObj<typeof meta>;
|
|
38
13
|
export declare const Simple: Story;
|
|
14
|
+
export declare const WithObjectsOptions: Story;
|
|
39
15
|
export declare const WithLabel: Story;
|
|
40
16
|
export declare const WithSearch: Story;
|
|
41
17
|
export declare const WithPlaceholder: Story;
|