@pismo/marola 1.0.0-beta.18 → 1.0.0-beta.19
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_1k4ph_1{margin-bottom:16px;position:relative}._autocomplete__dropdown-list_1k4ph_5{position:absolute;background-color:var(--white-100);margin-top:.1rem;border:solid .0625rem var(--gray-25);border-radius:.375rem}._autocomplete__dropdown-list_1k4ph_5:hover{border-color:var(--gray-75)}._autocomplete__dropdown-item_1k4ph_15{background-color:var(--white-100);padding:.375rem;list-style-type:none;cursor:pointer}._autocomplete__dropdown-item_1k4ph_15:hover{color:var(--accent)}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import '../../assets/Autocomplete.css';
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as qe, jsx as $ } from "react/jsx-runtime";
|
|
3
3
|
import * as g from "react";
|
|
4
|
-
import { useId as pt, useState as
|
|
4
|
+
import { useId as pt, useState as Be } from "react";
|
|
5
5
|
import { c as ee } from "../../clsx-DB4S2d7J.js";
|
|
6
|
-
import { Icon as
|
|
6
|
+
import { Icon as Ke } from "../Icon/Icon.js";
|
|
7
7
|
import { s as P, I as gt } from "../../Input.module-ZTRZRcNt.js";
|
|
8
|
-
import { Typography as
|
|
9
|
-
import { b as
|
|
8
|
+
import { Typography as Ue } from "../Typography/Typography.js";
|
|
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";
|
|
12
12
|
import { u as me } from "../../useEventCallback-BAQJJ3ye.js";
|
|
@@ -16,7 +16,7 @@ const bt = (u) => {
|
|
|
16
16
|
b.current = u;
|
|
17
17
|
}), b.current;
|
|
18
18
|
};
|
|
19
|
-
function
|
|
19
|
+
function ze(u) {
|
|
20
20
|
return typeof u.normalize < "u" ? u.normalize("NFD").replace(/[\u0300-\u036f]/g, "") : u;
|
|
21
21
|
}
|
|
22
22
|
function xt(u = {}) {
|
|
@@ -33,10 +33,10 @@ function xt(u = {}) {
|
|
|
33
33
|
getOptionLabel: m
|
|
34
34
|
}) => {
|
|
35
35
|
let I = V ? F.trim() : F;
|
|
36
|
-
h && (I = I.toLowerCase()), b && (I =
|
|
36
|
+
h && (I = I.toLowerCase()), b && (I = ze(I));
|
|
37
37
|
const q = I ? M.filter((Y) => {
|
|
38
38
|
let _ = (H || m)(Y);
|
|
39
|
-
return h && (_ = _.toLowerCase()), b && (_ =
|
|
39
|
+
return h && (_ = _.toLowerCase()), b && (_ = ze(_)), D === "start" ? _.indexOf(I) === 0 : _.indexOf(I) > -1;
|
|
40
40
|
}) : M;
|
|
41
41
|
return typeof A == "number" ? q.slice(0, A) : q;
|
|
42
42
|
};
|
|
@@ -47,7 +47,7 @@ function be(u, b) {
|
|
|
47
47
|
return h;
|
|
48
48
|
return -1;
|
|
49
49
|
}
|
|
50
|
-
const yt = xt(),
|
|
50
|
+
const yt = xt(), Je = 5, Ot = (u) => {
|
|
51
51
|
var b;
|
|
52
52
|
return u.current !== null && ((b = u.current.parentElement) == null ? void 0 : b.contains(document.activeElement));
|
|
53
53
|
};
|
|
@@ -110,7 +110,7 @@ function It(u) {
|
|
|
110
110
|
}
|
|
111
111
|
return e;
|
|
112
112
|
};
|
|
113
|
-
const we = g.useRef(!1), ke = g.useRef(!0), d = g.useRef(null), N = g.useRef(null), [ue, Xe] = g.useState(null), [S, Ne] = g.useState(-1),
|
|
113
|
+
const we = g.useRef(!1), ke = g.useRef(!0), d = g.useRef(null), N = g.useRef(null), [ue, Xe] = g.useState(null), [S, Ne] = g.useState(-1), De = D ? 0 : -1, x = g.useRef(De), [r, Ge] = $e({
|
|
114
114
|
controlled: We,
|
|
115
115
|
default: I,
|
|
116
116
|
name: m
|
|
@@ -119,7 +119,7 @@ function It(u) {
|
|
|
119
119
|
default: "",
|
|
120
120
|
name: m,
|
|
121
121
|
state: "inputValue"
|
|
122
|
-
}), [fe,
|
|
122
|
+
}), [fe, Ee] = g.useState(!1), de = g.useCallback((t, e) => {
|
|
123
123
|
if (!(i ? r.length < e.length : e !== null) && !M)
|
|
124
124
|
return;
|
|
125
125
|
let o;
|
|
@@ -132,17 +132,17 @@ function It(u) {
|
|
|
132
132
|
o = typeof s == "string" ? s : "";
|
|
133
133
|
}
|
|
134
134
|
a !== o && (ce(o), v && v(t, o, "reset"));
|
|
135
|
-
}, [y, a, i, v, ce, M, r]), [z,
|
|
135
|
+
}, [y, a, i, v, ce, M, r]), [z, ve] = $e({
|
|
136
136
|
controlled: c,
|
|
137
137
|
default: !1,
|
|
138
138
|
name: m,
|
|
139
139
|
state: "open"
|
|
140
|
-
}), [Qe,
|
|
140
|
+
}), [Qe, Ce] = g.useState(!0), Le = !i && r != null && a === y(r), w = z && !G, f = w ? ye(
|
|
141
141
|
_e.filter((t) => !(ne && (i ? r : [r]).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
|
{
|
|
145
|
-
inputValue:
|
|
145
|
+
inputValue: Le && Qe ? "" : a,
|
|
146
146
|
getOptionLabel: y
|
|
147
147
|
}
|
|
148
148
|
) : [], C = bt({
|
|
@@ -210,7 +210,7 @@ function It(u) {
|
|
|
210
210
|
const l = Ze((() => {
|
|
211
211
|
const p = f.length - 1;
|
|
212
212
|
if (e === "reset")
|
|
213
|
-
return
|
|
213
|
+
return De;
|
|
214
214
|
if (e === "start")
|
|
215
215
|
return 0;
|
|
216
216
|
if (e === "end")
|
|
@@ -301,9 +301,9 @@ function It(u) {
|
|
|
301
301
|
Pe();
|
|
302
302
|
}, [Pe]);
|
|
303
303
|
const K = (t) => {
|
|
304
|
-
z || (
|
|
304
|
+
z || (ve(!0), Ce(!0), ae && ae(t));
|
|
305
305
|
}, Q = (t, e) => {
|
|
306
|
-
z && (
|
|
306
|
+
z && (ve(!1), X && X(t, e));
|
|
307
307
|
}, J = (t, e, n, o) => {
|
|
308
308
|
if (i) {
|
|
309
309
|
if (r.length === e.length && r.every((s, l) => s === e[l]))
|
|
@@ -340,13 +340,13 @@ function It(u) {
|
|
|
340
340
|
return n;
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
const
|
|
343
|
+
const Ve = (t, e) => {
|
|
344
344
|
if (!i)
|
|
345
345
|
return;
|
|
346
346
|
a === "" && Q(t, "toggleInput");
|
|
347
347
|
let n = S;
|
|
348
348
|
S === -1 ? a === "" && e === "previous" && (n = r.length - 1) : (n += e === "next" ? 1 : -1, n < 0 && (n = 0), n === r.length && (n = -1)), n = nt(n, e), Ne(n), pe(n);
|
|
349
|
-
},
|
|
349
|
+
}, Me = (t) => {
|
|
350
350
|
we.current = !0, ce(""), v && v(t, "", "clear"), J(t, i ? [] : null, "clear");
|
|
351
351
|
}, rt = (t) => (e) => {
|
|
352
352
|
if (t.onKeyDown && t.onKeyDown(e), !e.defaultMuiPrevented && (S !== -1 && ["ArrowLeft", "ArrowRight"].indexOf(e.key) === -1 && (Ne(-1), pe(-1)), e.which !== 229))
|
|
@@ -369,7 +369,7 @@ function It(u) {
|
|
|
369
369
|
break;
|
|
370
370
|
case "PageUp":
|
|
371
371
|
e.preventDefault(), L({
|
|
372
|
-
diff: -
|
|
372
|
+
diff: -Je,
|
|
373
373
|
direction: "previous",
|
|
374
374
|
reason: "keyboard",
|
|
375
375
|
event: e
|
|
@@ -377,7 +377,7 @@ function It(u) {
|
|
|
377
377
|
break;
|
|
378
378
|
case "PageDown":
|
|
379
379
|
e.preventDefault(), L({
|
|
380
|
-
diff:
|
|
380
|
+
diff: Je,
|
|
381
381
|
direction: "next",
|
|
382
382
|
reason: "keyboard",
|
|
383
383
|
event: e
|
|
@@ -400,10 +400,10 @@ function It(u) {
|
|
|
400
400
|
}), K(e);
|
|
401
401
|
break;
|
|
402
402
|
case "ArrowLeft":
|
|
403
|
-
|
|
403
|
+
Ve(e, "previous");
|
|
404
404
|
break;
|
|
405
405
|
case "ArrowRight":
|
|
406
|
-
|
|
406
|
+
Ve(e, "next");
|
|
407
407
|
break;
|
|
408
408
|
case "Enter":
|
|
409
409
|
if (x.current !== -1 && w) {
|
|
@@ -412,10 +412,10 @@ function It(u) {
|
|
|
412
412
|
return;
|
|
413
413
|
Z(e, n, "selectOption"), A && d.current.setSelectionRange(d.current.value.length, d.current.value.length);
|
|
414
414
|
} else
|
|
415
|
-
R && a !== "" &&
|
|
415
|
+
R && a !== "" && Le === !1 && (i && e.preventDefault(), Z(e, a, "createOption", "freeSolo"));
|
|
416
416
|
break;
|
|
417
417
|
case "Escape":
|
|
418
|
-
w ? (e.preventDefault(), e.stopPropagation(), Q(e, "escape")) : F && (a !== "" || i && r.length > 0) && (e.preventDefault(), e.stopPropagation(),
|
|
418
|
+
w ? (e.preventDefault(), e.stopPropagation(), Q(e, "escape")) : F && (a !== "" || i && r.length > 0) && (e.preventDefault(), e.stopPropagation(), Me(e));
|
|
419
419
|
break;
|
|
420
420
|
case "Backspace":
|
|
421
421
|
if (i && !G && a === "" && r.length > 0) {
|
|
@@ -435,16 +435,16 @@ function It(u) {
|
|
|
435
435
|
break;
|
|
436
436
|
}
|
|
437
437
|
}, ot = (t) => {
|
|
438
|
-
|
|
439
|
-
},
|
|
438
|
+
Ee(!0), T && !we.current && K(t);
|
|
439
|
+
}, Re = (t) => {
|
|
440
440
|
if (b(N)) {
|
|
441
441
|
d.current.focus();
|
|
442
442
|
return;
|
|
443
443
|
}
|
|
444
|
-
|
|
444
|
+
Ee(!1), ke.current = !0, we.current = !1, H && x.current !== -1 && w ? Z(t, f[x.current], "blur") : H && R && a !== "" ? Z(t, a, "blur", "freeSolo") : M && de(t, r), Q(t, "blur");
|
|
445
445
|
}, st = (t) => {
|
|
446
446
|
const e = t.target.value;
|
|
447
|
-
a !== e && (ce(e),
|
|
447
|
+
a !== e && (ce(e), Ce(!1), v && v(t, e, "input")), e === "" ? !q && !i && J(t, null, "clear") : K(t);
|
|
448
448
|
}, it = (t) => {
|
|
449
449
|
const e = Number(t.currentTarget.getAttribute("data-option-index"));
|
|
450
450
|
x.current !== e && B({
|
|
@@ -466,22 +466,22 @@ function It(u) {
|
|
|
466
466
|
n.splice(t, 1), J(e, n, "removeOption", {
|
|
467
467
|
option: r[t]
|
|
468
468
|
});
|
|
469
|
-
},
|
|
469
|
+
}, He = (t) => {
|
|
470
470
|
z ? Q(t, "toggleInput") : K(t);
|
|
471
471
|
}, ct = (t) => {
|
|
472
472
|
t.currentTarget.contains(t.target) && t.target.getAttribute("id") !== k && t.preventDefault();
|
|
473
473
|
}, ft = (t) => {
|
|
474
474
|
t.currentTarget.contains(t.target) && (d.current.focus(), Ye && ke.current && d.current.selectionEnd - d.current.selectionStart === 0 && d.current.select(), ke.current = !1);
|
|
475
475
|
}, dt = (t) => {
|
|
476
|
-
!_ && (a === "" || !z) &&
|
|
476
|
+
!_ && (a === "" || !z) && He(t);
|
|
477
477
|
};
|
|
478
478
|
let Te = R && a.length > 0;
|
|
479
479
|
Te = Te || (i ? r.length > 0 : r !== null);
|
|
480
|
-
let
|
|
480
|
+
let Fe = f;
|
|
481
481
|
if (j) {
|
|
482
482
|
const t = /* @__PURE__ */ new Map();
|
|
483
483
|
let e = !1;
|
|
484
|
-
|
|
484
|
+
Fe = f.reduce((n, o, s) => {
|
|
485
485
|
const l = j(o);
|
|
486
486
|
return n.length > 0 && n[n.length - 1].group === l ? n[n.length - 1].options.push(o) : (process.env.NODE_ENV !== "production" && (t.get(l) && !e && (console.warn(`MUI: The options provided combined with the \`groupBy\` method of ${m} returns duplicated headers.`, "You can solve the issue by sorting the options with the output of `groupBy`."), e = !0), t.set(l, !0)), n.push({
|
|
487
487
|
key: s,
|
|
@@ -491,8 +491,8 @@ function It(u) {
|
|
|
491
491
|
})), n;
|
|
492
492
|
}, []);
|
|
493
493
|
}
|
|
494
|
-
return _ && fe &&
|
|
495
|
-
getRootProps: (t = {}) =>
|
|
494
|
+
return _ && fe && Re(), {
|
|
495
|
+
getRootProps: (t = {}) => je({
|
|
496
496
|
"aria-owns": Se ? `${k}-listbox` : null
|
|
497
497
|
}, t, {
|
|
498
498
|
onKeyDown: rt(t),
|
|
@@ -506,7 +506,7 @@ function It(u) {
|
|
|
506
506
|
getInputProps: () => ({
|
|
507
507
|
id: k,
|
|
508
508
|
value: a,
|
|
509
|
-
onBlur:
|
|
509
|
+
onBlur: Re,
|
|
510
510
|
onFocus: ot,
|
|
511
511
|
onChange: st,
|
|
512
512
|
onMouseDown: dt,
|
|
@@ -528,16 +528,16 @@ function It(u) {
|
|
|
528
528
|
getClearProps: () => ({
|
|
529
529
|
tabIndex: -1,
|
|
530
530
|
type: "button",
|
|
531
|
-
onClick:
|
|
531
|
+
onClick: Me
|
|
532
532
|
}),
|
|
533
533
|
getPopupIndicatorProps: () => ({
|
|
534
534
|
tabIndex: -1,
|
|
535
535
|
type: "button",
|
|
536
|
-
onClick:
|
|
536
|
+
onClick: He
|
|
537
537
|
}),
|
|
538
538
|
getTagProps: ({
|
|
539
539
|
index: t
|
|
540
|
-
}) =>
|
|
540
|
+
}) => je({
|
|
541
541
|
key: t,
|
|
542
542
|
"data-tag-index": t,
|
|
543
543
|
tabIndex: -1
|
|
@@ -582,13 +582,13 @@ function It(u) {
|
|
|
582
582
|
anchorEl: ue,
|
|
583
583
|
setAnchorEl: Xe,
|
|
584
584
|
focusedTag: S,
|
|
585
|
-
groupedOptions:
|
|
585
|
+
groupedOptions: Fe
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
|
-
const _t = "
|
|
588
|
+
const _t = "_autocomplete_1k4ph_1", Ae = {
|
|
589
589
|
autocomplete: _t,
|
|
590
|
-
"autocomplete__dropdown-list": "_autocomplete__dropdown-
|
|
591
|
-
"autocomplete__dropdown-item": "_autocomplete__dropdown-
|
|
590
|
+
"autocomplete__dropdown-list": "_autocomplete__dropdown-list_1k4ph_5",
|
|
591
|
+
"autocomplete__dropdown-item": "_autocomplete__dropdown-item_1k4ph_15"
|
|
592
592
|
}, vt = ({
|
|
593
593
|
label: u,
|
|
594
594
|
type: b,
|
|
@@ -614,7 +614,7 @@ const _t = "_autocomplete_1mx2f_1", Je = {
|
|
|
614
614
|
}) => {
|
|
615
615
|
const re = pt(), j = M || `input_${re}`;
|
|
616
616
|
Object.assign(W, { "data-testid": ne });
|
|
617
|
-
const [oe, Oe] =
|
|
617
|
+
const [oe, Oe] = Be(), [se, Ie] = Be(""), { getRootProps: E, getInputProps: i, getOptionProps: ie, groupedOptions: X, getListboxProps: le, focused: v, getInputLabelProps: ae } = It({
|
|
618
618
|
id: j,
|
|
619
619
|
options: h,
|
|
620
620
|
getOptionLabel: (c) => typeof c == "string" ? c : c == null ? void 0 : c.label,
|
|
@@ -627,9 +627,9 @@ const _t = "_autocomplete_1mx2f_1", Je = {
|
|
|
627
627
|
q && q(c, T), Ie(T);
|
|
628
628
|
}
|
|
629
629
|
});
|
|
630
|
-
return /* @__PURE__ */
|
|
630
|
+
return /* @__PURE__ */ qe("div", { className: Ae.autocomplete, children: [
|
|
631
631
|
u && /* @__PURE__ */ $(
|
|
632
|
-
|
|
632
|
+
Ue,
|
|
633
633
|
{
|
|
634
634
|
element: "label",
|
|
635
635
|
elementProps: { ...ae() },
|
|
@@ -660,25 +660,25 @@ const _t = "_autocomplete_1mx2f_1", Je = {
|
|
|
660
660
|
}
|
|
661
661
|
},
|
|
662
662
|
startAdornment: H && /* @__PURE__ */ $("span", { className: P["input__left-icon"], children: H }),
|
|
663
|
-
endAdornment: b === "search" ? /* @__PURE__ */ $("span", { className: P["input__right-icon"], children: /* @__PURE__ */ $(
|
|
663
|
+
endAdornment: b === "search" ? /* @__PURE__ */ $("span", { className: P["input__right-icon"], children: /* @__PURE__ */ $(Ke, { color: "var(--accent)", icon: "magnifying-glass" }) }) : V && /* @__PURE__ */ $("span", { className: P["input__right-icon"], children: V })
|
|
664
664
|
}
|
|
665
665
|
) }),
|
|
666
|
-
X.length > 0 && !F && /* @__PURE__ */ $("ul", { ...le(), className:
|
|
666
|
+
X.length > 0 && !F && /* @__PURE__ */ $("ul", { ...le(), className: Ae["autocomplete__dropdown-list"], children: X.map((c, T) => /* @__PURE__ */ $(
|
|
667
667
|
"li",
|
|
668
668
|
{
|
|
669
669
|
tabIndex: T,
|
|
670
|
-
className:
|
|
670
|
+
className: Ae["autocomplete__dropdown-item"],
|
|
671
671
|
...ie({ option: c, index: T }),
|
|
672
672
|
children: typeof c == "string" ? c : c == null ? void 0 : c.label
|
|
673
673
|
}
|
|
674
674
|
)) }),
|
|
675
|
-
(D || A) && /* @__PURE__ */
|
|
676
|
-
|
|
675
|
+
(D || A) && /* @__PURE__ */ qe(
|
|
676
|
+
Ue,
|
|
677
677
|
{
|
|
678
678
|
className: D ? ee(P["input__error-message"], xe) : ee(P["input__info-message"], te),
|
|
679
679
|
"data-testid": D ? U : R,
|
|
680
680
|
children: [
|
|
681
|
-
/* @__PURE__ */ $(
|
|
681
|
+
/* @__PURE__ */ $(Ke, { icon: "circle-exclamation" }),
|
|
682
682
|
D || A
|
|
683
683
|
]
|
|
684
684
|
}
|