@pismo/marola 0.0.1-alpha.11 → 0.0.1-alpha.12
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/{ClickAwayListener-BKznXF1d.js → ClickAwayListener-HI1G6ob9.js} +2 -1
- package/dist/Popup-DFJQc_jn.js +1249 -0
- package/dist/{Portal-BcdMtRGF.js → Portal-D__zvwbZ.js} +1 -1
- package/dist/SelectButton-DWtqAiwt.js +45 -0
- package/dist/Tabs.module-jkH1Qjn7.js +22 -0
- package/dist/assets/SelectButton.css +1 -0
- package/dist/combineHooksSlotProps-BHqhiBfc.js +81 -0
- package/dist/components/Button/Button.stories.js +7 -6
- package/dist/components/Dialog/Dialog.js +13 -12
- package/dist/components/Dialog/Dialog.stories.js +8 -7
- package/dist/components/LoadingSpinner/LoadingSpinner.stories.js +5 -4
- package/dist/components/PageHeader/PageHeader.stories.js +3 -3
- package/dist/components/Select/Select.d.ts +25 -0
- package/dist/components/Select/Select.js +860 -0
- package/dist/components/Select/Select.stories.d.ts +31 -0
- package/dist/components/Select/Select.stories.js +66 -0
- package/dist/components/Select/SelectButton.d.ts +13 -0
- package/dist/components/Select/SelectButton.js +8 -0
- package/dist/components/Snackbar/Snackbar.js +5 -4
- package/dist/components/Tabs/Tab.js +180 -6
- package/dist/components/Tabs/TabPanel.js +19 -18
- package/dist/components/Tabs/Tabs.js +237 -662
- package/dist/components/Tooltip/Tooltip.js +89 -1328
- package/dist/components/Typography/Typography.stories.js +5 -4
- package/dist/components/Typography/typography.test.js +3 -2
- package/dist/{index-BNWbc5Kh.js → index-BJ8HbRCy.js} +3109 -3152
- package/dist/main.d.ts +1 -0
- package/dist/main.js +34 -31
- package/dist/useCompoundItem-D1iRfg8D.js +84 -0
- package/dist/useEventCallback-vAfOD-oT.js +45 -0
- package/dist/useList-ByMguSS_.js +437 -0
- package/package.json +1 -1
- package/dist/Tab-CRwnhsj5.js +0 -254
- package/dist/Tabs.module-yYcTJnj6.js +0 -103
package/dist/main.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './components/InputSearch/InputSearch';
|
|
|
10
10
|
export * from './components/LoadingSpinner/LoadingSpinner';
|
|
11
11
|
export * from './components/PageHeader/PageHeader';
|
|
12
12
|
export * from './components/Pagination/Pagination';
|
|
13
|
+
export * from './components/Select/Select';
|
|
13
14
|
export * from './components/Skeleton/Skeleton';
|
|
14
15
|
export * from './components/Snackbar/Snackbar';
|
|
15
16
|
export * from './components/SortTooltip/SortTooltip';
|
package/dist/main.js
CHANGED
|
@@ -11,49 +11,52 @@ import { InputSearch as b } from "./components/InputSearch/InputSearch.js";
|
|
|
11
11
|
import { LoadingSpinner as k } from "./components/LoadingSpinner/LoadingSpinner.js";
|
|
12
12
|
import { PageHeader as D } from "./components/PageHeader/PageHeader.js";
|
|
13
13
|
import { Pagination as y, paginationDefaultTranslations as A } from "./components/Pagination/Pagination.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { default as
|
|
25
|
-
import { default as
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
14
|
+
import { Option as P, Select as B } from "./components/Select/Select.js";
|
|
15
|
+
import { Skeleton as F, SkeletonCircle as H, SkeletonTable as L } from "./components/Skeleton/Skeleton.js";
|
|
16
|
+
import { Snackbar as j } from "./components/Snackbar/Snackbar.js";
|
|
17
|
+
import { SortTooltip as w, sortTooltipDefaultTranslations as z } from "./components/SortTooltip/SortTooltip.js";
|
|
18
|
+
import { Stepper as G } from "./components/Stepper/Stepper.js";
|
|
19
|
+
import { Table as K } from "./components/Table/Table.js";
|
|
20
|
+
import { Tabs as N } from "./components/Tabs/Tabs.js";
|
|
21
|
+
import { Toggle as R } from "./components/Toggle/Toggle.js";
|
|
22
|
+
import { Tooltip as V } from "./components/Tooltip/Tooltip.js";
|
|
23
|
+
import { Typography as X } from "./components/Typography/Typography.js";
|
|
24
|
+
import { default as Z } from "./components/Dialog/Title.js";
|
|
25
|
+
import { default as $ } from "./components/Dialog/Content.js";
|
|
26
|
+
import { default as ro } from "./components/Dialog/Actions.js";
|
|
27
|
+
import { Tab as eo } from "./components/Tabs/Tab.js";
|
|
28
|
+
import { TabPanel as ao } from "./components/Tabs/TabPanel.js";
|
|
28
29
|
export {
|
|
29
|
-
|
|
30
|
+
ro as Actions,
|
|
30
31
|
e as Advice,
|
|
31
32
|
a as Button,
|
|
32
33
|
m as Checkbox,
|
|
33
|
-
|
|
34
|
+
$ as Content,
|
|
34
35
|
x as Dialog,
|
|
35
|
-
|
|
36
|
+
Z as DialogTitle,
|
|
36
37
|
i as FamilyAndIcons,
|
|
37
38
|
T as Icon,
|
|
38
39
|
c as IconButton,
|
|
39
40
|
u as Input,
|
|
40
41
|
b as InputSearch,
|
|
41
42
|
k as LoadingSpinner,
|
|
43
|
+
P as Option,
|
|
42
44
|
D as PageHeader,
|
|
43
45
|
y as Pagination,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
j as
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
K as
|
|
54
|
-
N as
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
B as Select,
|
|
47
|
+
F as Skeleton,
|
|
48
|
+
H as SkeletonCircle,
|
|
49
|
+
L as SkeletonTable,
|
|
50
|
+
j as Snackbar,
|
|
51
|
+
w as SortTooltip,
|
|
52
|
+
G as Stepper,
|
|
53
|
+
eo as Tab,
|
|
54
|
+
ao as TabPanel,
|
|
55
|
+
K as Table,
|
|
56
|
+
N as Tabs,
|
|
57
|
+
R as Toggle,
|
|
58
|
+
V as Tooltip,
|
|
59
|
+
X as Typography,
|
|
57
60
|
A as paginationDefaultTranslations,
|
|
58
|
-
|
|
61
|
+
z as sortTooltipDefaultTranslations
|
|
59
62
|
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { u as g } from "./useEnhancedEffect-CJGo-L3B.js";
|
|
3
|
+
let I = 0;
|
|
4
|
+
function x(e) {
|
|
5
|
+
const [n, t] = o.useState(e), u = e || n;
|
|
6
|
+
return o.useEffect(() => {
|
|
7
|
+
n == null && (I += 1, t(`mui-${I}`));
|
|
8
|
+
}, [n]), u;
|
|
9
|
+
}
|
|
10
|
+
const p = o.useId;
|
|
11
|
+
function y(e) {
|
|
12
|
+
if (p !== void 0) {
|
|
13
|
+
const n = p();
|
|
14
|
+
return e ?? n;
|
|
15
|
+
}
|
|
16
|
+
return x(e);
|
|
17
|
+
}
|
|
18
|
+
const b = /* @__PURE__ */ o.createContext(null);
|
|
19
|
+
process.env.NODE_ENV !== "production" && (b.displayName = "CompoundComponentContext");
|
|
20
|
+
function S(e) {
|
|
21
|
+
const n = Array.from(e.keys()).map((t) => {
|
|
22
|
+
const u = e.get(t);
|
|
23
|
+
return {
|
|
24
|
+
key: t,
|
|
25
|
+
subitem: u
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
return n.sort((t, u) => {
|
|
29
|
+
const s = t.subitem.ref.current, r = u.subitem.ref.current;
|
|
30
|
+
return s === null || r === null || s === r ? 0 : s.compareDocumentPosition(r) & Node.DOCUMENT_POSITION_PRECEDING ? 1 : -1;
|
|
31
|
+
}), new Map(n.map((t) => [t.key, t.subitem]));
|
|
32
|
+
}
|
|
33
|
+
function E() {
|
|
34
|
+
const [e, n] = o.useState(/* @__PURE__ */ new Map()), t = o.useRef(/* @__PURE__ */ new Set()), u = o.useCallback(function(a) {
|
|
35
|
+
t.current.delete(a), n((m) => {
|
|
36
|
+
const c = new Map(m);
|
|
37
|
+
return c.delete(a), c;
|
|
38
|
+
});
|
|
39
|
+
}, []), s = o.useCallback(function(a, m) {
|
|
40
|
+
let c;
|
|
41
|
+
return typeof a == "function" ? c = a(t.current) : c = a, t.current.add(c), n((C) => {
|
|
42
|
+
const l = new Map(C);
|
|
43
|
+
return l.set(c, m), l;
|
|
44
|
+
}), {
|
|
45
|
+
id: c,
|
|
46
|
+
deregister: () => u(c)
|
|
47
|
+
};
|
|
48
|
+
}, [u]), r = o.useMemo(() => S(e), [e]), i = o.useCallback(function(a) {
|
|
49
|
+
return Array.from(r.keys()).indexOf(a);
|
|
50
|
+
}, [r]);
|
|
51
|
+
return {
|
|
52
|
+
contextValue: o.useMemo(() => ({
|
|
53
|
+
getItemIndex: i,
|
|
54
|
+
registerItem: s,
|
|
55
|
+
totalSubitemCount: e.size
|
|
56
|
+
}), [i, s, e.size]),
|
|
57
|
+
subitems: r
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function N(e, n) {
|
|
61
|
+
const t = o.useContext(b);
|
|
62
|
+
if (t === null)
|
|
63
|
+
throw new Error("useCompoundItem must be used within a useCompoundParent");
|
|
64
|
+
const {
|
|
65
|
+
registerItem: u
|
|
66
|
+
} = t, [s, r] = o.useState(typeof e == "function" ? void 0 : e);
|
|
67
|
+
return g(() => {
|
|
68
|
+
const {
|
|
69
|
+
id: i,
|
|
70
|
+
deregister: d
|
|
71
|
+
} = u(e, n);
|
|
72
|
+
return r(i), d;
|
|
73
|
+
}, [u, n, e]), {
|
|
74
|
+
id: s,
|
|
75
|
+
index: s !== void 0 ? t.getItemIndex(s) : -1,
|
|
76
|
+
totalItemCount: t.totalSubitemCount
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
b as C,
|
|
81
|
+
N as a,
|
|
82
|
+
E as b,
|
|
83
|
+
y as u
|
|
84
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { P as a } from "./index-CqjC7P5Y.js";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
import { u as m } from "./useEnhancedEffect-CJGo-L3B.js";
|
|
4
|
+
function s(e, n) {
|
|
5
|
+
return process.env.NODE_ENV === "production" ? () => null : function(...o) {
|
|
6
|
+
return e(...o) || n(...o);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function d(e) {
|
|
10
|
+
const {
|
|
11
|
+
prototype: n = {}
|
|
12
|
+
} = e;
|
|
13
|
+
return !!n.isReactComponent;
|
|
14
|
+
}
|
|
15
|
+
function f(e, n, t, o, l) {
|
|
16
|
+
const u = e[n], p = l || n;
|
|
17
|
+
if (u == null || // When server-side rendering React doesn't warn either.
|
|
18
|
+
// This is not an accurate check for SSR.
|
|
19
|
+
// This is only in place for Emotion compat.
|
|
20
|
+
// TODO: Revisit once https://github.com/facebook/react/issues/20047 is resolved.
|
|
21
|
+
typeof window > "u")
|
|
22
|
+
return null;
|
|
23
|
+
let r;
|
|
24
|
+
const i = u.type;
|
|
25
|
+
return typeof i == "function" && !d(i) && (r = "Did you accidentally use a plain function component for an element instead?"), r !== void 0 ? new Error(`Invalid ${o} \`${p}\` supplied to \`${t}\`. Expected an element that can hold a ref. ${r} For more information see https://mui.com/r/caveat-with-refs-guide`) : null;
|
|
26
|
+
}
|
|
27
|
+
const y = s(a.element, f);
|
|
28
|
+
y.isRequired = s(a.element.isRequired, f);
|
|
29
|
+
function E(e) {
|
|
30
|
+
return e && e.ownerDocument || document;
|
|
31
|
+
}
|
|
32
|
+
function h(e) {
|
|
33
|
+
const n = c.useRef(e);
|
|
34
|
+
return m(() => {
|
|
35
|
+
n.current = e;
|
|
36
|
+
}), c.useRef((...t) => (
|
|
37
|
+
// @ts-expect-error hide `this`
|
|
38
|
+
(0, n.current)(...t)
|
|
39
|
+
)).current;
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
y as e,
|
|
43
|
+
E as o,
|
|
44
|
+
h as u
|
|
45
|
+
};
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { a as p } from "./objectWithoutPropertiesLoose-D7Cp0Pg_.js";
|
|
2
|
+
import * as f from "react";
|
|
3
|
+
import { L as x } from "./combineHooksSlotProps-BHqhiBfc.js";
|
|
4
|
+
import { u as re, e as ie } from "./index-CqjC7P5Y.js";
|
|
5
|
+
function W(t, e, r = (n, l) => n === l) {
|
|
6
|
+
return t.length === e.length && t.every((n, l) => r(n, e[l]));
|
|
7
|
+
}
|
|
8
|
+
function ue(t, e) {
|
|
9
|
+
return t === e;
|
|
10
|
+
}
|
|
11
|
+
const N = {}, q = () => {
|
|
12
|
+
};
|
|
13
|
+
function L(t, e) {
|
|
14
|
+
const r = p({}, t);
|
|
15
|
+
return Object.keys(e).forEach((n) => {
|
|
16
|
+
e[n] !== void 0 && (r[n] = e[n]);
|
|
17
|
+
}), r;
|
|
18
|
+
}
|
|
19
|
+
function ae(t) {
|
|
20
|
+
const {
|
|
21
|
+
nextState: e,
|
|
22
|
+
initialState: r,
|
|
23
|
+
stateComparers: n,
|
|
24
|
+
onStateChange: l,
|
|
25
|
+
controlledProps: s,
|
|
26
|
+
lastActionRef: i
|
|
27
|
+
} = t, h = f.useRef(r);
|
|
28
|
+
f.useEffect(() => {
|
|
29
|
+
if (i.current === null)
|
|
30
|
+
return;
|
|
31
|
+
const a = L(h.current, s);
|
|
32
|
+
Object.keys(e).forEach((C) => {
|
|
33
|
+
var V;
|
|
34
|
+
const g = (V = n[C]) != null ? V : ue, c = e[C], m = a[C];
|
|
35
|
+
if (m == null && c != null || m != null && c == null || m != null && c != null && !g(c, m)) {
|
|
36
|
+
var o, S;
|
|
37
|
+
l == null || l((o = i.current.event) != null ? o : null, C, c, (S = i.current.type) != null ? S : "", e);
|
|
38
|
+
}
|
|
39
|
+
}), h.current = e, i.current = null;
|
|
40
|
+
}, [h, e, i, l, n, s]);
|
|
41
|
+
}
|
|
42
|
+
function se(t) {
|
|
43
|
+
const e = f.useRef(null), {
|
|
44
|
+
reducer: r,
|
|
45
|
+
initialState: n,
|
|
46
|
+
controlledProps: l = N,
|
|
47
|
+
stateComparers: s = N,
|
|
48
|
+
onStateChange: i = q,
|
|
49
|
+
actionContext: h,
|
|
50
|
+
componentName: a = ""
|
|
51
|
+
} = t, C = f.useRef(l);
|
|
52
|
+
process.env.NODE_ENV !== "production" && f.useEffect(() => {
|
|
53
|
+
Object.keys(l).forEach((o) => {
|
|
54
|
+
C.current[o] !== void 0 && l[o] === void 0 && console.error(`useControllableReducer: ${a ? `The ${a} component` : "A component"} is changing a controlled prop to be uncontrolled: ${o}`), C.current[o] === void 0 && l[o] !== void 0 && console.error(`useControllableReducer: ${a ? `The ${a} component` : "A component"} is changing an uncontrolled prop to be controlled: ${o}`);
|
|
55
|
+
});
|
|
56
|
+
}, [l, a]);
|
|
57
|
+
const V = f.useCallback((o, S) => {
|
|
58
|
+
e.current = S;
|
|
59
|
+
const R = L(o, l);
|
|
60
|
+
return r(R, S);
|
|
61
|
+
}, [l, r]), [g, c] = f.useReducer(V, n), m = f.useCallback((o) => {
|
|
62
|
+
c(p({}, o, {
|
|
63
|
+
context: h
|
|
64
|
+
}));
|
|
65
|
+
}, [h]);
|
|
66
|
+
return ae({
|
|
67
|
+
nextState: g,
|
|
68
|
+
initialState: n,
|
|
69
|
+
stateComparers: s ?? N,
|
|
70
|
+
onStateChange: i ?? q,
|
|
71
|
+
controlledProps: l,
|
|
72
|
+
lastActionRef: e
|
|
73
|
+
}), [L(g, l), m];
|
|
74
|
+
}
|
|
75
|
+
function oe(t, e, r, n, l, s) {
|
|
76
|
+
if (r.length === 0 || !n && r.every((h, a) => l(h, a)))
|
|
77
|
+
return -1;
|
|
78
|
+
let i = t;
|
|
79
|
+
for (; ; ) {
|
|
80
|
+
if (!s && e === "next" && i === r.length || !s && e === "previous" && i === -1)
|
|
81
|
+
return -1;
|
|
82
|
+
if (n ? !1 : l(r[i], i))
|
|
83
|
+
i += e === "next" ? 1 : -1, s && (i = (i + r.length) % r.length);
|
|
84
|
+
else
|
|
85
|
+
return i;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function w(t, e, r) {
|
|
89
|
+
var n;
|
|
90
|
+
const {
|
|
91
|
+
items: l,
|
|
92
|
+
isItemDisabled: s,
|
|
93
|
+
disableListWrap: i,
|
|
94
|
+
disabledItemsFocusable: h,
|
|
95
|
+
itemComparer: a,
|
|
96
|
+
focusManagement: C
|
|
97
|
+
} = r, V = C === "DOM" ? 0 : -1, g = l.length - 1, c = t == null ? -1 : l.findIndex((D) => a(D, t));
|
|
98
|
+
let m, o, S = !i;
|
|
99
|
+
switch (e) {
|
|
100
|
+
case "reset":
|
|
101
|
+
if (V === -1)
|
|
102
|
+
return null;
|
|
103
|
+
m = 0, o = "next", S = !1;
|
|
104
|
+
break;
|
|
105
|
+
case "start":
|
|
106
|
+
m = 0, o = "next", S = !1;
|
|
107
|
+
break;
|
|
108
|
+
case "end":
|
|
109
|
+
m = g, o = "previous", S = !1;
|
|
110
|
+
break;
|
|
111
|
+
default: {
|
|
112
|
+
const D = c + e;
|
|
113
|
+
D < 0 ? !S && c !== -1 || Math.abs(e) > 1 ? (m = 0, o = "next") : (m = g, o = "previous") : D > g ? !S || Math.abs(e) > 1 ? (m = g, o = "previous") : (m = 0, o = "next") : (m = D, o = e >= 0 ? "next" : "previous");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const R = oe(m, o, l, h, s, S);
|
|
117
|
+
return R === -1 && t !== null && !s(t, c) ? t : (n = l[R]) != null ? n : null;
|
|
118
|
+
}
|
|
119
|
+
function ce(t, e, r, n) {
|
|
120
|
+
return r === "none" ? [] : r === "single" ? n(e[0], t) ? e : [t] : e.some((l) => n(l, t)) ? e.filter((l) => !n(l, t)) : [...e, t];
|
|
121
|
+
}
|
|
122
|
+
function j(t, e, r) {
|
|
123
|
+
const {
|
|
124
|
+
itemComparer: n,
|
|
125
|
+
isItemDisabled: l,
|
|
126
|
+
selectionMode: s,
|
|
127
|
+
items: i
|
|
128
|
+
} = r, {
|
|
129
|
+
selectedValues: h
|
|
130
|
+
} = e, a = i.findIndex((V) => n(t, V));
|
|
131
|
+
if (l(t, a))
|
|
132
|
+
return e;
|
|
133
|
+
const C = ce(t, h, s, n);
|
|
134
|
+
return p({}, e, {
|
|
135
|
+
selectedValues: C,
|
|
136
|
+
highlightedValue: t
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function he(t, e, r) {
|
|
140
|
+
const n = e.highlightedValue, {
|
|
141
|
+
orientation: l,
|
|
142
|
+
pageSize: s
|
|
143
|
+
} = r;
|
|
144
|
+
switch (t) {
|
|
145
|
+
case "Home":
|
|
146
|
+
return p({}, e, {
|
|
147
|
+
highlightedValue: w(n, "start", r)
|
|
148
|
+
});
|
|
149
|
+
case "End":
|
|
150
|
+
return p({}, e, {
|
|
151
|
+
highlightedValue: w(n, "end", r)
|
|
152
|
+
});
|
|
153
|
+
case "PageUp":
|
|
154
|
+
return p({}, e, {
|
|
155
|
+
highlightedValue: w(n, -s, r)
|
|
156
|
+
});
|
|
157
|
+
case "PageDown":
|
|
158
|
+
return p({}, e, {
|
|
159
|
+
highlightedValue: w(n, s, r)
|
|
160
|
+
});
|
|
161
|
+
case "ArrowUp":
|
|
162
|
+
if (l !== "vertical")
|
|
163
|
+
break;
|
|
164
|
+
return p({}, e, {
|
|
165
|
+
highlightedValue: w(n, -1, r)
|
|
166
|
+
});
|
|
167
|
+
case "ArrowDown":
|
|
168
|
+
if (l !== "vertical")
|
|
169
|
+
break;
|
|
170
|
+
return p({}, e, {
|
|
171
|
+
highlightedValue: w(n, 1, r)
|
|
172
|
+
});
|
|
173
|
+
case "ArrowLeft": {
|
|
174
|
+
if (l === "vertical")
|
|
175
|
+
break;
|
|
176
|
+
return p({}, e, {
|
|
177
|
+
highlightedValue: w(n, l === "horizontal-ltr" ? -1 : 1, r)
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
case "ArrowRight": {
|
|
181
|
+
if (l === "vertical")
|
|
182
|
+
break;
|
|
183
|
+
return p({}, e, {
|
|
184
|
+
highlightedValue: w(n, l === "horizontal-ltr" ? 1 : -1, r)
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
case "Enter":
|
|
188
|
+
case " ":
|
|
189
|
+
return e.highlightedValue === null ? e : j(e.highlightedValue, e, r);
|
|
190
|
+
}
|
|
191
|
+
return e;
|
|
192
|
+
}
|
|
193
|
+
function ge(t, e) {
|
|
194
|
+
return e.focusManagement === "DOM" ? t : p({}, t, {
|
|
195
|
+
highlightedValue: null
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function de(t, e, r) {
|
|
199
|
+
var n;
|
|
200
|
+
const l = (n = r(t)) == null ? void 0 : n.trim().toLowerCase();
|
|
201
|
+
return !l || l.length === 0 ? !1 : l.indexOf(e) === 0;
|
|
202
|
+
}
|
|
203
|
+
function fe(t, e, r) {
|
|
204
|
+
const {
|
|
205
|
+
items: n,
|
|
206
|
+
isItemDisabled: l,
|
|
207
|
+
disabledItemsFocusable: s,
|
|
208
|
+
getItemAsString: i
|
|
209
|
+
} = r, h = e.length > 1;
|
|
210
|
+
let a = h ? t.highlightedValue : w(t.highlightedValue, 1, r);
|
|
211
|
+
for (let C = 0; C < n.length; C += 1) {
|
|
212
|
+
if (!a || !h && t.highlightedValue === a)
|
|
213
|
+
return t;
|
|
214
|
+
if (de(a, e, i) && (!l(a, n.indexOf(a)) || s))
|
|
215
|
+
return p({}, t, {
|
|
216
|
+
highlightedValue: a
|
|
217
|
+
});
|
|
218
|
+
a = w(a, 1, r);
|
|
219
|
+
}
|
|
220
|
+
return t;
|
|
221
|
+
}
|
|
222
|
+
function me(t, e, r, n) {
|
|
223
|
+
var l;
|
|
224
|
+
const {
|
|
225
|
+
itemComparer: s,
|
|
226
|
+
focusManagement: i
|
|
227
|
+
} = n;
|
|
228
|
+
let h = null;
|
|
229
|
+
if (r.highlightedValue != null) {
|
|
230
|
+
var a;
|
|
231
|
+
h = (a = t.find((g) => s(g, r.highlightedValue))) != null ? a : null;
|
|
232
|
+
} else
|
|
233
|
+
i === "DOM" && e.length === 0 && (h = w(null, "reset", n));
|
|
234
|
+
const V = ((l = r.selectedValues) != null ? l : []).filter((g) => t.some((c) => s(c, g)));
|
|
235
|
+
return p({}, r, {
|
|
236
|
+
highlightedValue: h,
|
|
237
|
+
selectedValues: V
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
function pe(t, e) {
|
|
241
|
+
return p({}, t, {
|
|
242
|
+
highlightedValue: w(null, "reset", e)
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function Ce(t, e) {
|
|
246
|
+
return p({}, t, {
|
|
247
|
+
highlightedValue: w(null, "end", e)
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
function Se(t, e) {
|
|
251
|
+
return p({}, t, {
|
|
252
|
+
selectedValues: [],
|
|
253
|
+
highlightedValue: w(null, "reset", e)
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function Ie(t, e) {
|
|
257
|
+
const {
|
|
258
|
+
type: r,
|
|
259
|
+
context: n
|
|
260
|
+
} = e;
|
|
261
|
+
switch (r) {
|
|
262
|
+
case x.keyDown:
|
|
263
|
+
return he(e.key, t, n);
|
|
264
|
+
case x.itemClick:
|
|
265
|
+
return j(e.item, t, n);
|
|
266
|
+
case x.blur:
|
|
267
|
+
return ge(t, n);
|
|
268
|
+
case x.textNavigation:
|
|
269
|
+
return fe(t, e.searchString, n);
|
|
270
|
+
case x.itemsChange:
|
|
271
|
+
return me(e.items, e.previousItems, t, n);
|
|
272
|
+
case x.resetHighlight:
|
|
273
|
+
return pe(t, n);
|
|
274
|
+
case x.highlightLast:
|
|
275
|
+
return Ce(t, n);
|
|
276
|
+
case x.clearSelection:
|
|
277
|
+
return Se(t, n);
|
|
278
|
+
default:
|
|
279
|
+
return t;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const be = 500;
|
|
283
|
+
function xe(t) {
|
|
284
|
+
const e = f.useRef({
|
|
285
|
+
searchString: "",
|
|
286
|
+
lastTime: null
|
|
287
|
+
});
|
|
288
|
+
return f.useCallback((r) => {
|
|
289
|
+
if (r.key.length === 1 && r.key !== " ") {
|
|
290
|
+
const n = e.current, l = r.key.toLowerCase(), s = performance.now();
|
|
291
|
+
n.searchString.length > 0 && n.lastTime && s - n.lastTime > be ? n.searchString = l : (n.searchString.length !== 1 || l !== n.searchString) && (n.searchString += l), n.lastTime = s, t(n.searchString, r);
|
|
292
|
+
}
|
|
293
|
+
}, [t]);
|
|
294
|
+
}
|
|
295
|
+
const z = {}, Ve = () => {
|
|
296
|
+
}, we = (t, e) => t === e, De = () => !1, Re = (t) => typeof t == "string" ? t : String(t), ve = () => ({
|
|
297
|
+
highlightedValue: null,
|
|
298
|
+
selectedValues: []
|
|
299
|
+
});
|
|
300
|
+
function Oe(t) {
|
|
301
|
+
const {
|
|
302
|
+
controlledProps: e = z,
|
|
303
|
+
disabledItemsFocusable: r = !1,
|
|
304
|
+
disableListWrap: n = !1,
|
|
305
|
+
focusManagement: l = "activeDescendant",
|
|
306
|
+
getInitialState: s = ve,
|
|
307
|
+
getItemDomElement: i,
|
|
308
|
+
getItemId: h,
|
|
309
|
+
isItemDisabled: a = De,
|
|
310
|
+
rootRef: C,
|
|
311
|
+
onStateChange: V = Ve,
|
|
312
|
+
items: g,
|
|
313
|
+
itemComparer: c = we,
|
|
314
|
+
getItemAsString: m = Re,
|
|
315
|
+
onChange: o,
|
|
316
|
+
onHighlightChange: S,
|
|
317
|
+
onItemsChange: R,
|
|
318
|
+
orientation: D = "vertical",
|
|
319
|
+
pageSize: P = 5,
|
|
320
|
+
reducerActionContext: H = z,
|
|
321
|
+
selectionMode: $ = "single",
|
|
322
|
+
stateReducer: _,
|
|
323
|
+
componentName: G = "useList"
|
|
324
|
+
} = t;
|
|
325
|
+
if (process.env.NODE_ENV !== "production") {
|
|
326
|
+
if (l === "DOM" && i == null)
|
|
327
|
+
throw new Error("useList: The `getItemDomElement` prop is required when using the `DOM` focus management.");
|
|
328
|
+
if (l === "activeDescendant" && h == null)
|
|
329
|
+
throw new Error("useList: The `getItemId` prop is required when using the `activeDescendant` focus management.");
|
|
330
|
+
}
|
|
331
|
+
const B = f.useRef(null), F = re(C, B), T = f.useCallback((d, u, I) => {
|
|
332
|
+
if (S == null || S(d, u, I), l === "DOM" && u != null && (I === x.itemClick || I === x.keyDown || I === x.textNavigation)) {
|
|
333
|
+
var b;
|
|
334
|
+
i == null || (b = i(u)) == null || b.focus();
|
|
335
|
+
}
|
|
336
|
+
}, [i, S, l]), O = f.useMemo(() => ({
|
|
337
|
+
highlightedValue: c,
|
|
338
|
+
selectedValues: (d, u) => W(d, u, c)
|
|
339
|
+
}), [c]), J = f.useCallback((d, u, I, b, M) => {
|
|
340
|
+
switch (V == null || V(d, u, I, b, M), u) {
|
|
341
|
+
case "highlightedValue":
|
|
342
|
+
T(d, I, b);
|
|
343
|
+
break;
|
|
344
|
+
case "selectedValues":
|
|
345
|
+
o == null || o(d, I, b);
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
}, [T, o, V]), K = f.useMemo(() => ({
|
|
349
|
+
disabledItemsFocusable: r,
|
|
350
|
+
disableListWrap: n,
|
|
351
|
+
focusManagement: l,
|
|
352
|
+
isItemDisabled: a,
|
|
353
|
+
itemComparer: c,
|
|
354
|
+
items: g,
|
|
355
|
+
getItemAsString: m,
|
|
356
|
+
onHighlightChange: T,
|
|
357
|
+
orientation: D,
|
|
358
|
+
pageSize: P,
|
|
359
|
+
selectionMode: $,
|
|
360
|
+
stateComparers: O
|
|
361
|
+
}), [r, n, l, a, c, g, m, T, D, P, $, O]), Y = s(), X = _ ?? Ie, Q = f.useMemo(() => p({}, H, K), [H, K]), [k, v] = se({
|
|
362
|
+
reducer: X,
|
|
363
|
+
actionContext: Q,
|
|
364
|
+
initialState: Y,
|
|
365
|
+
controlledProps: e,
|
|
366
|
+
stateComparers: O,
|
|
367
|
+
onStateChange: J,
|
|
368
|
+
componentName: G
|
|
369
|
+
}), {
|
|
370
|
+
highlightedValue: E,
|
|
371
|
+
selectedValues: A
|
|
372
|
+
} = k, Z = xe((d, u) => v({
|
|
373
|
+
type: x.textNavigation,
|
|
374
|
+
event: u,
|
|
375
|
+
searchString: d
|
|
376
|
+
})), y = f.useRef([]);
|
|
377
|
+
f.useEffect(() => {
|
|
378
|
+
W(y.current, g, c) || (v({
|
|
379
|
+
type: x.itemsChange,
|
|
380
|
+
event: null,
|
|
381
|
+
items: g,
|
|
382
|
+
previousItems: y.current
|
|
383
|
+
}), y.current = g, R == null || R(g));
|
|
384
|
+
}, [g, c, v, R]);
|
|
385
|
+
const ee = (d) => (u) => {
|
|
386
|
+
var I;
|
|
387
|
+
if ((I = d.onKeyDown) == null || I.call(d, u), u.defaultMuiPrevented)
|
|
388
|
+
return;
|
|
389
|
+
const b = ["Home", "End", "PageUp", "PageDown"];
|
|
390
|
+
D === "vertical" ? b.push("ArrowUp", "ArrowDown") : b.push("ArrowLeft", "ArrowRight"), l === "activeDescendant" && b.push(" ", "Enter"), b.includes(u.key) && u.preventDefault(), v({
|
|
391
|
+
type: x.keyDown,
|
|
392
|
+
key: u.key,
|
|
393
|
+
event: u
|
|
394
|
+
}), Z(u);
|
|
395
|
+
}, te = (d) => (u) => {
|
|
396
|
+
var I, b;
|
|
397
|
+
(I = d.onBlur) == null || I.call(d, u), !u.defaultMuiPrevented && ((b = B.current) != null && b.contains(u.relatedTarget) || v({
|
|
398
|
+
type: x.blur,
|
|
399
|
+
event: u
|
|
400
|
+
}));
|
|
401
|
+
}, ne = (d = {}) => {
|
|
402
|
+
const u = ie(d);
|
|
403
|
+
return p({}, d, {
|
|
404
|
+
"aria-activedescendant": l === "activeDescendant" && E != null ? h(E) : void 0,
|
|
405
|
+
tabIndex: l === "DOM" ? -1 : 0,
|
|
406
|
+
ref: F
|
|
407
|
+
}, u, {
|
|
408
|
+
onBlur: te(u),
|
|
409
|
+
onKeyDown: ee(u)
|
|
410
|
+
});
|
|
411
|
+
}, U = f.useCallback((d) => {
|
|
412
|
+
const u = (A ?? []).some((M) => M != null && c(d, M)), I = E != null && c(d, E);
|
|
413
|
+
return {
|
|
414
|
+
focusable: l === "DOM",
|
|
415
|
+
highlighted: I,
|
|
416
|
+
selected: u
|
|
417
|
+
};
|
|
418
|
+
}, [c, A, E, l]), le = f.useMemo(() => ({
|
|
419
|
+
dispatch: v,
|
|
420
|
+
getItemState: U
|
|
421
|
+
}), [v, U]);
|
|
422
|
+
return f.useDebugValue({
|
|
423
|
+
state: k
|
|
424
|
+
}), {
|
|
425
|
+
contextValue: le,
|
|
426
|
+
dispatch: v,
|
|
427
|
+
getRootProps: ne,
|
|
428
|
+
rootRef: F,
|
|
429
|
+
state: k
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
export {
|
|
433
|
+
j as h,
|
|
434
|
+
Ie as l,
|
|
435
|
+
w as m,
|
|
436
|
+
Oe as u
|
|
437
|
+
};
|