@kolking/react-ui 1.8.6 → 1.8.7
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/components/Menu/Menu.js +31 -31
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as O, Fragment as W, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import _, { useState as l, useRef as g, useMemo as k, useEffect as A } from "react";
|
|
3
3
|
import { flushSync as D } from "react-dom";
|
|
4
4
|
import { useFloating as H, offset as U, flip as q, size as G, autoUpdate as J, useInteractions as K, useDismiss as Q, useRole as T, useClick as V, useListNavigation as X, useMergeRefs as Y, FloatingPortal as Z, FloatingFocusManager as $, FloatingList as ee } from "@floating-ui/react";
|
|
5
5
|
import te from "classnames";
|
|
@@ -14,71 +14,71 @@ const de = ({
|
|
|
14
14
|
unmount: v = !0,
|
|
15
15
|
minWidth: x,
|
|
16
16
|
maxWidth: F,
|
|
17
|
-
minHeight:
|
|
18
|
-
maxHeight:
|
|
19
|
-
className:
|
|
17
|
+
minHeight: y,
|
|
18
|
+
maxHeight: M,
|
|
19
|
+
className: P,
|
|
20
20
|
children: z,
|
|
21
21
|
onSelect: c,
|
|
22
22
|
...w
|
|
23
23
|
}) => {
|
|
24
|
-
const [
|
|
25
|
-
open:
|
|
24
|
+
const [r, m] = l(!1), [i, C] = l(null), [E, I] = l({}), f = g([]), d = g(null), { refs: n, context: e, floatingStyles: N } = H({
|
|
25
|
+
open: r,
|
|
26
26
|
placement: u,
|
|
27
|
-
onOpenChange:
|
|
27
|
+
onOpenChange: m,
|
|
28
28
|
whileElementsMounted: J,
|
|
29
29
|
middleware: [
|
|
30
30
|
U(R),
|
|
31
31
|
q({ padding: 10 }),
|
|
32
32
|
G({
|
|
33
33
|
padding: 10,
|
|
34
|
-
apply({ rects:
|
|
34
|
+
apply({ rects: a, availableWidth: s, availableHeight: L }) {
|
|
35
35
|
D(() => {
|
|
36
36
|
I({
|
|
37
|
-
minHeight:
|
|
38
|
-
minWidth: x ??
|
|
39
|
-
maxWidth: F ??
|
|
40
|
-
maxHeight:
|
|
37
|
+
minHeight: y,
|
|
38
|
+
minWidth: x ?? a.reference.width,
|
|
39
|
+
maxWidth: F ?? s,
|
|
40
|
+
maxHeight: M ?? L
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
})
|
|
45
45
|
]
|
|
46
|
-
}), { getReferenceProps: S, getFloatingProps:
|
|
46
|
+
}), { getReferenceProps: S, getFloatingProps: b, getItemProps: p } = K([
|
|
47
47
|
Q(e),
|
|
48
48
|
T(e, { role: "menu" }),
|
|
49
49
|
V(e, { event: "mousedown" }),
|
|
50
50
|
X(e, {
|
|
51
|
-
listRef:
|
|
51
|
+
listRef: f,
|
|
52
52
|
loop: !0,
|
|
53
|
-
activeIndex:
|
|
53
|
+
activeIndex: i,
|
|
54
54
|
onNavigate: C
|
|
55
55
|
})
|
|
56
|
-
]),
|
|
57
|
-
() => ({ active:
|
|
58
|
-
[
|
|
59
|
-
),
|
|
56
|
+
]), j = k(
|
|
57
|
+
() => ({ active: i, setOpen: m, getItemProps: p, onSelect: c }),
|
|
58
|
+
[i, p, c]
|
|
59
|
+
), B = Y([
|
|
60
60
|
n.setReference,
|
|
61
61
|
"ref" in o ? o.ref : null
|
|
62
62
|
]);
|
|
63
63
|
return A(() => {
|
|
64
|
-
var
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
}, [n]), /* @__PURE__ */ W
|
|
68
|
-
|
|
64
|
+
var s;
|
|
65
|
+
const a = (s = n.domReference.current) == null ? void 0 : s.closest("[data-floating-root]");
|
|
66
|
+
d.current = a ?? document.body;
|
|
67
|
+
}, [n]), /* @__PURE__ */ O(W, { children: [
|
|
68
|
+
_.cloneElement(
|
|
69
69
|
o,
|
|
70
|
-
S({ ref:
|
|
70
|
+
S({ ref: B, "data-menu-trigger": !0, ...o.props })
|
|
71
71
|
),
|
|
72
|
-
/* @__PURE__ */ t(oe.Provider, { value:
|
|
72
|
+
/* @__PURE__ */ t(oe.Provider, { value: j, children: (r || !v) && /* @__PURE__ */ t(Z, { root: d.current, children: /* @__PURE__ */ t($, { context: e, modal: !1, initialFocus: -1, children: /* @__PURE__ */ t(
|
|
73
73
|
"div",
|
|
74
74
|
{
|
|
75
|
-
...
|
|
75
|
+
...b(w),
|
|
76
76
|
ref: n.setFloating,
|
|
77
|
-
"data-open":
|
|
77
|
+
"data-open": r,
|
|
78
78
|
"data-menu": u,
|
|
79
|
-
className: te(se.menu,
|
|
79
|
+
className: te(se.menu, P),
|
|
80
80
|
style: { ...N, ...E, ...ne({ size: h }) },
|
|
81
|
-
children: /* @__PURE__ */ t(ee, { elementsRef:
|
|
81
|
+
children: /* @__PURE__ */ t(ee, { elementsRef: f, children: z })
|
|
82
82
|
}
|
|
83
83
|
) }) }) })
|
|
84
84
|
] });
|