@mortenbrudvik/waveui 0.14.0 → 0.15.0
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/README.md +142 -32
- package/dist/components/data-display/InfoButton.cjs +1 -1
- package/dist/components/data-display/InfoButton.cjs.map +1 -1
- package/dist/components/data-display/InfoButton.mjs +90 -82
- package/dist/components/data-display/InfoButton.mjs.map +1 -1
- package/dist/components/data-display/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +19 -18
- package/dist/components/data-display/InfoLabel.mjs.map +1 -1
- package/dist/components/feedback/MessageBarGroup.cjs +2 -0
- package/dist/components/feedback/MessageBarGroup.cjs.map +1 -0
- package/dist/components/feedback/MessageBarGroup.mjs +63 -0
- package/dist/components/feedback/MessageBarGroup.mjs.map +1 -0
- package/dist/components/feedback/ProgressBar.cjs +1 -1
- package/dist/components/feedback/ProgressBar.cjs.map +1 -1
- package/dist/components/feedback/ProgressBar.mjs +41 -39
- package/dist/components/feedback/ProgressBar.mjs.map +1 -1
- package/dist/components/feedback/Toaster.cjs +1 -1
- package/dist/components/feedback/Toaster.cjs.map +1 -1
- package/dist/components/feedback/Toaster.mjs +222 -216
- package/dist/components/feedback/Toaster.mjs.map +1 -1
- package/dist/components/layout/Accordion.cjs +1 -1
- package/dist/components/layout/Accordion.cjs.map +1 -1
- package/dist/components/layout/Accordion.mjs +124 -109
- package/dist/components/layout/Accordion.mjs.map +1 -1
- package/dist/components/layout/Carousel.cjs +1 -1
- package/dist/components/layout/Carousel.cjs.map +1 -1
- package/dist/components/layout/Carousel.mjs +207 -193
- package/dist/components/layout/Carousel.mjs.map +1 -1
- package/dist/components/layout/TabList.cjs +1 -1
- package/dist/components/layout/TabList.cjs.map +1 -1
- package/dist/components/layout/TabList.mjs +149 -108
- package/dist/components/layout/TabList.mjs.map +1 -1
- package/dist/components/layout/Tree.cjs.map +1 -1
- package/dist/components/layout/Tree.context.cjs +1 -1
- package/dist/components/layout/Tree.context.cjs.map +1 -1
- package/dist/components/layout/Tree.context.mjs +2 -1
- package/dist/components/layout/Tree.context.mjs.map +1 -1
- package/dist/components/layout/Tree.core.cjs +1 -1
- package/dist/components/layout/Tree.core.cjs.map +1 -1
- package/dist/components/layout/Tree.core.mjs +178 -165
- package/dist/components/layout/Tree.core.mjs.map +1 -1
- package/dist/components/layout/Tree.mjs.map +1 -1
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +154 -168
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- package/dist/components/navigation/Nav.cjs +1 -1
- package/dist/components/navigation/Nav.cjs.map +1 -1
- package/dist/components/navigation/Nav.mjs +156 -136
- package/dist/components/navigation/Nav.mjs.map +1 -1
- package/dist/components/navigation/NavDrawer.cjs +1 -1
- package/dist/components/navigation/NavDrawer.cjs.map +1 -1
- package/dist/components/navigation/NavDrawer.mjs +48 -45
- package/dist/components/navigation/NavDrawer.mjs.map +1 -1
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +128 -122
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.cjs +1 -1
- package/dist/components/overlays/Dialog.slots.cjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.mjs +12 -12
- package/dist/components/overlays/Dialog.slots.mjs.map +1 -1
- package/dist/components/overlays/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer.mjs.map +1 -1
- package/dist/components/overlays/Drawer.panel.cjs +1 -1
- package/dist/components/overlays/Drawer.panel.cjs.map +1 -1
- package/dist/components/overlays/Drawer.panel.mjs +97 -81
- package/dist/components/overlays/Drawer.panel.mjs.map +1 -1
- package/dist/components/overlays/Drawer.root.cjs +1 -1
- package/dist/components/overlays/Drawer.root.cjs.map +1 -1
- package/dist/components/overlays/Drawer.root.mjs +34 -31
- package/dist/components/overlays/Drawer.root.mjs.map +1 -1
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +231 -216
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.parts.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.parts.mjs +202 -173
- package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.root.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.root.mjs +108 -99
- package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +66 -61
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/provider/WaveProvider.cjs +1 -1
- package/dist/components/provider/WaveProvider.cjs.map +1 -1
- package/dist/components/provider/WaveProvider.mjs +26 -23
- package/dist/components/provider/WaveProvider.mjs.map +1 -1
- package/dist/hooks/useCollapsePresence.cjs +2 -0
- package/dist/hooks/useCollapsePresence.cjs.map +1 -0
- package/dist/hooks/useCollapsePresence.mjs +21 -0
- package/dist/hooks/useCollapsePresence.mjs.map +1 -0
- package/dist/hooks/useFocusBeforeClose.cjs +2 -0
- package/dist/hooks/useFocusBeforeClose.cjs.map +1 -0
- package/dist/hooks/useFocusBeforeClose.mjs +33 -0
- package/dist/hooks/useFocusBeforeClose.mjs.map +1 -0
- package/dist/hooks/useMotion.cjs +2 -0
- package/dist/hooks/useMotion.cjs.map +1 -0
- package/dist/hooks/useMotion.mjs +14 -0
- package/dist/hooks/useMotion.mjs.map +1 -0
- package/dist/hooks/usePresenceGroup.cjs +2 -0
- package/dist/hooks/usePresenceGroup.cjs.map +1 -0
- package/dist/hooks/usePresenceGroup.mjs +68 -0
- package/dist/hooks/usePresenceGroup.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +721 -131
- package/dist/index.d.ts +721 -131
- package/dist/index.mjs +136 -135
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +101 -90
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/motion.cjs +2 -0
- package/dist/lib/motion.cjs.map +1 -0
- package/dist/lib/motion.mjs +43 -0
- package/dist/lib/motion.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +2 -1
|
@@ -7,36 +7,39 @@ import { useEventCallback as i } from "../../hooks/useEventCallback.mjs";
|
|
|
7
7
|
import { getArrowIntent as a, getDirection as ee } from "../../lib/direction.mjs";
|
|
8
8
|
import { isConnectedAndFocusable as o } from "../../lib/focus.mjs";
|
|
9
9
|
import { useRovingTabIndex as te } from "../../hooks/useRovingTabIndex.mjs";
|
|
10
|
-
import { useMergedRefs as
|
|
11
|
-
import { usePresence as
|
|
12
|
-
import { resolvePositioning as
|
|
13
|
-
import { useDismiss as
|
|
14
|
-
import { useRestoreFocus as
|
|
15
|
-
import { Portal as
|
|
16
|
-
import { isEditableTarget as
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
10
|
+
import { useMergedRefs as s } from "../../hooks/useMergedRefs.mjs";
|
|
11
|
+
import { usePresence as ne } from "../../hooks/usePresence.mjs";
|
|
12
|
+
import { resolvePositioning as re, usePopupPosition as ie } from "../../hooks/usePopupPosition.mjs";
|
|
13
|
+
import { useDismiss as ae } from "../../hooks/useDismiss.mjs";
|
|
14
|
+
import { useRestoreFocus as oe } from "../../hooks/useRestoreFocus.mjs";
|
|
15
|
+
import { Portal as se, PortalDepthContext as ce } from "../portal/Portal.mjs";
|
|
16
|
+
import { isEditableTarget as le, isOwnEvent as c } from "../../lib/events.mjs";
|
|
17
|
+
import { popupMotion as ue } from "../../lib/motion.mjs";
|
|
18
|
+
import { useFocusBeforeClose as de } from "../../hooks/useFocusBeforeClose.mjs";
|
|
19
|
+
import { createHoverIntentGroup as l } from "../../hooks/useHoverIntent.mjs";
|
|
20
|
+
import { useMotionClasses as u } from "../../hooks/useMotion.mjs";
|
|
21
|
+
import { getTriggerFocusTarget as d, useTriggerFocusRef as fe } from "../../hooks/useTriggerElement.mjs";
|
|
22
|
+
import { MenuListContext as pe, useCheckableRegistry as me, useMenuContext as he } from "./Menu.context.mjs";
|
|
23
|
+
import { MENU_ITEM_SELECTOR as f, menuPopoverClasses as ge, useStaticMenuPartWarning as _e, withTypeaheadText as ve } from "./Menu.shared.mjs";
|
|
24
|
+
import { usePopupTarget as ye } from "../../hooks/useResolvedTarget.mjs";
|
|
25
|
+
import * as p from "react";
|
|
26
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
24
27
|
//#region src/components/navigation/Menu.popover.tsx
|
|
25
|
-
var
|
|
28
|
+
var be = {
|
|
26
29
|
padding: 8,
|
|
27
30
|
crossAxis: !0
|
|
28
31
|
};
|
|
29
|
-
function
|
|
32
|
+
function xe(e) {
|
|
30
33
|
return !!e && e.nodeType === 1;
|
|
31
34
|
}
|
|
32
|
-
function
|
|
33
|
-
let [t] =
|
|
35
|
+
function h(e) {
|
|
36
|
+
let [t] = p.useState(l), n = p.useRef(!1);
|
|
34
37
|
return {
|
|
35
38
|
hoverGroup: t,
|
|
36
|
-
isHoverFocusing:
|
|
39
|
+
isHoverFocusing: p.useCallback(() => n.current, []),
|
|
37
40
|
onPointerMove: i((r) => {
|
|
38
|
-
if (r.pointerType === "touch" || r.pointerType === "pen" || !
|
|
39
|
-
let i = r.target.closest(
|
|
41
|
+
if (r.pointerType === "touch" || r.pointerType === "pen" || !c(r)) return;
|
|
42
|
+
let i = r.target.closest(f);
|
|
40
43
|
if (!i || !r.currentTarget.contains(i) || i.getAttribute("aria-disabled") === "true" || i.ownerDocument.activeElement === i) return;
|
|
41
44
|
let a = e;
|
|
42
45
|
for (; a.parent;) a = a.parent;
|
|
@@ -46,197 +49,180 @@ function p(e) {
|
|
|
46
49
|
})
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
|
-
var
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
let { target:
|
|
53
|
-
|
|
54
|
-
}, []), { isMounted:
|
|
55
|
-
open:
|
|
56
|
-
side:
|
|
57
|
-
align:
|
|
58
|
-
shift:
|
|
59
|
-
...
|
|
60
|
-
offset:
|
|
52
|
+
var g = ({ side: l, align: g = "start", offset: _, target: Se, positioning: v, motion: Ce, children: we, className: y, style: Te, onKeyDown: Ee, onKeyDownCapture: De, onFocus: Oe, onPointerEnter: ke, onPointerLeave: Ae, onPointerMove: je, onContextMenu: Me, ref: Ne, ...b }) => {
|
|
53
|
+
let x = he("Menu.Popover"), { popup: Pe, open: S, takeInitialFocus: C, registerSurface: w, menuId: Fe, labelledBy: Ie, triggerRef: T, triggerElement: E, isSubmenu: D, requestClose: Le, closeChain: O, dismiss: Re, hoverSurfaceHandlers: k, isHoverClose: ze, openOnContext: A, contextSurfaceHandlers: Be, contextAnchor: j, fromContext: M, contextOpener: N } = x;
|
|
54
|
+
_e("Menu.Popover", Pe);
|
|
55
|
+
let { target: P, pending: Ve } = ye("Menu.Popover", Se, v), F = xe(P) ? P : null, [I, He] = p.useState(null), L = p.useRef(null), Ue = p.useCallback((e) => {
|
|
56
|
+
L.current = e, He(e);
|
|
57
|
+
}, []), { isMounted: R, ref: We, presenceProps: Ge } = ne(S, { appear: !0 }), Ke = u(Ce, ue, y), { setReference: z, setFloating: qe, floatingProps: B, isPositioned: V } = ie({
|
|
58
|
+
open: S,
|
|
59
|
+
side: l ?? (D ? "end" : "bottom"),
|
|
60
|
+
align: g,
|
|
61
|
+
shift: D ? be : void 0,
|
|
62
|
+
...re(v, {
|
|
63
|
+
offset: D ? 0 : 4,
|
|
61
64
|
fitViewport: !0
|
|
62
65
|
}),
|
|
63
|
-
...
|
|
64
|
-
}),
|
|
65
|
-
...
|
|
66
|
+
..._ !== void 0 && { offset: _ }
|
|
67
|
+
}), H = Ve ? {
|
|
68
|
+
...B,
|
|
66
69
|
style: {
|
|
67
|
-
...
|
|
70
|
+
...B.style,
|
|
68
71
|
visibility: "hidden"
|
|
69
72
|
}
|
|
70
|
-
} :
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
} : B, { maxHeight: Je, maxWidth: Ye, ...Xe } = H.style;
|
|
74
|
+
p.useLayoutEffect(() => {
|
|
75
|
+
z(M ? j ?? d(E) ?? E : P ?? E);
|
|
73
76
|
}, [
|
|
74
|
-
|
|
75
|
-
O,
|
|
76
|
-
k,
|
|
77
|
+
z,
|
|
77
78
|
j,
|
|
78
|
-
|
|
79
|
+
M,
|
|
80
|
+
P,
|
|
81
|
+
E
|
|
79
82
|
]);
|
|
80
|
-
let
|
|
81
|
-
let e =
|
|
82
|
-
return e && o(e) ? e :
|
|
83
|
-
}),
|
|
84
|
-
return
|
|
85
|
-
} }), [
|
|
86
|
-
open:
|
|
87
|
-
onDismiss:
|
|
88
|
-
refs:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
let U = i(() => {
|
|
84
|
+
let e = A ? N.current : null;
|
|
85
|
+
return e && o(e) ? e : d(T.current) || (F && o(F) ? F : null);
|
|
86
|
+
}), Ze = p.useMemo(() => ({ get current() {
|
|
87
|
+
return U() ?? T.current;
|
|
88
|
+
} }), [U, T]), W = { current: F }, { layerId: G } = ae({
|
|
89
|
+
open: S,
|
|
90
|
+
onDismiss: Re,
|
|
91
|
+
refs: A ? [L, W] : [
|
|
92
|
+
L,
|
|
93
|
+
T,
|
|
94
|
+
W
|
|
92
95
|
],
|
|
93
|
-
anchorRef:
|
|
96
|
+
anchorRef: Ze,
|
|
94
97
|
kind: "menu",
|
|
95
98
|
focusOutside: !0,
|
|
96
|
-
outsidePress:
|
|
97
|
-
}),
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
105
|
-
let Ze = i(() => {
|
|
106
|
-
let e = P.current;
|
|
107
|
-
return [
|
|
108
|
-
D ? A.current : null,
|
|
109
|
-
W.current,
|
|
110
|
-
B()
|
|
111
|
-
].find((t) => !!t && o(t) && !e?.contains(t)) ?? null;
|
|
112
|
-
});
|
|
113
|
-
se({
|
|
114
|
-
enabled: y,
|
|
115
|
-
container: N,
|
|
116
|
-
triggerRef: D ? void 0 : U,
|
|
117
|
-
finalFocusRef: D ? A : void 0,
|
|
118
|
-
fallback: B,
|
|
99
|
+
outsidePress: A ? (e) => !(e.ctrlKey && e.target instanceof Node && T.current?.contains(e.target)) : !0
|
|
100
|
+
}), K = fe(T);
|
|
101
|
+
oe({
|
|
102
|
+
enabled: S,
|
|
103
|
+
container: I,
|
|
104
|
+
triggerRef: A ? void 0 : K,
|
|
105
|
+
finalFocusRef: A ? N : void 0,
|
|
106
|
+
fallback: U,
|
|
119
107
|
onlyIfFocusInside: !0,
|
|
120
|
-
isHoverClose:
|
|
108
|
+
isHoverClose: ze
|
|
121
109
|
});
|
|
122
|
-
let
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}, [
|
|
126
|
-
let { containerProps: { ref: Qe }, handleKeyDown: $e, handleKeyDownCapture: et, handleFocus: tt, focusFirst:
|
|
110
|
+
let q = R && (A || P != null && !E) && b["aria-label"] === void 0 && b["aria-labelledby"] === void 0;
|
|
111
|
+
p.useEffect(() => {
|
|
112
|
+
q && t("Menu.Popover:name", "Menu.Popover: this menu has no trigger to name it (a context menu, or a menu placed at a `target` without Menu.Trigger): give Menu.Popover an aria-label or aria-labelledby.");
|
|
113
|
+
}, [q]);
|
|
114
|
+
let { containerProps: { ref: Qe }, handleKeyDown: $e, handleKeyDownCapture: et, handleFocus: tt, focusFirst: J, focusLast: Y } = te({
|
|
127
115
|
orientation: "vertical",
|
|
128
116
|
loop: !0,
|
|
129
117
|
typeahead: !0,
|
|
130
118
|
manageTabIndex: !0,
|
|
131
|
-
itemSelector:
|
|
132
|
-
}), nt =
|
|
133
|
-
|
|
134
|
-
if (
|
|
135
|
-
focusFirst:
|
|
136
|
-
focusLast:
|
|
137
|
-
surface:
|
|
138
|
-
layerId:
|
|
139
|
-
getReturnFocus:
|
|
140
|
-
}), () =>
|
|
119
|
+
itemSelector: f
|
|
120
|
+
}), nt = s(Ne, Ue, Qe, qe, We);
|
|
121
|
+
p.useLayoutEffect(() => {
|
|
122
|
+
if (I && S) return w({
|
|
123
|
+
focusFirst: J,
|
|
124
|
+
focusLast: Y,
|
|
125
|
+
surface: I,
|
|
126
|
+
layerId: G,
|
|
127
|
+
getReturnFocus: U
|
|
128
|
+
}), () => w(null);
|
|
141
129
|
}, [
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
q,
|
|
130
|
+
I,
|
|
131
|
+
S,
|
|
132
|
+
w,
|
|
146
133
|
J,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
e === "last" ? J() : e === "first" && q();
|
|
134
|
+
Y,
|
|
135
|
+
G,
|
|
136
|
+
U
|
|
137
|
+
]), de({
|
|
138
|
+
open: S,
|
|
139
|
+
surfaceRef: L,
|
|
140
|
+
captureOpener: () => A ? null : K.current,
|
|
141
|
+
candidates: (e) => [
|
|
142
|
+
A ? N.current : null,
|
|
143
|
+
e,
|
|
144
|
+
U()
|
|
145
|
+
]
|
|
146
|
+
}), p.useLayoutEffect(() => {
|
|
147
|
+
if (!S || !I || I.contains(I.ownerDocument.activeElement)) return;
|
|
148
|
+
let e = C();
|
|
149
|
+
e === "last" ? Y() : e === "first" && J();
|
|
164
150
|
}, [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
]),
|
|
171
|
-
if (!
|
|
172
|
-
let e =
|
|
173
|
-
e && e !==
|
|
174
|
-
}, [
|
|
175
|
-
let
|
|
176
|
-
menu:
|
|
151
|
+
S,
|
|
152
|
+
I,
|
|
153
|
+
C,
|
|
154
|
+
J,
|
|
155
|
+
Y
|
|
156
|
+
]), p.useLayoutEffect(() => {
|
|
157
|
+
if (!V || !I) return;
|
|
158
|
+
let e = I.ownerDocument.activeElement;
|
|
159
|
+
e && e !== I && I.contains(e) && e.scrollIntoView?.({ block: "nearest" });
|
|
160
|
+
}, [V, I]);
|
|
161
|
+
let X = p.useContext(ce) + 1, Z = me(), { hoverGroup: Q, isHoverFocusing: $, onPointerMove: rt } = h(x), it = p.useMemo(() => ({
|
|
162
|
+
menu: x,
|
|
177
163
|
isStatic: !1,
|
|
178
|
-
portalDepth:
|
|
179
|
-
closeFromItem:
|
|
180
|
-
registerCheckable:
|
|
181
|
-
hoverGroup:
|
|
182
|
-
isHoverFocusing:
|
|
164
|
+
portalDepth: X,
|
|
165
|
+
closeFromItem: O,
|
|
166
|
+
registerCheckable: Z,
|
|
167
|
+
hoverGroup: Q,
|
|
168
|
+
isHoverFocusing: $
|
|
183
169
|
}), [
|
|
184
|
-
|
|
170
|
+
x,
|
|
171
|
+
X,
|
|
172
|
+
O,
|
|
185
173
|
Z,
|
|
186
|
-
T,
|
|
187
174
|
Q,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (Te?.(e), !e.defaultPrevented && s(e)) {
|
|
175
|
+
$
|
|
176
|
+
]), at = (e) => {
|
|
177
|
+
if (Ee?.(e), !e.defaultPrevented && c(e)) {
|
|
192
178
|
if (e.key === "Tab") {
|
|
193
|
-
|
|
179
|
+
O();
|
|
194
180
|
return;
|
|
195
181
|
}
|
|
196
|
-
if (
|
|
182
|
+
if (D && !e.altKey && !e.ctrlKey && !e.metaKey && !le(e.target) && a(e.key, {
|
|
197
183
|
orientation: "horizontal",
|
|
198
184
|
dir: ee(e.currentTarget)
|
|
199
185
|
}) === "prev") {
|
|
200
|
-
e.preventDefault(),
|
|
186
|
+
e.preventDefault(), U()?.focus({ preventScroll: !0 }), Le();
|
|
201
187
|
return;
|
|
202
188
|
}
|
|
203
189
|
$e(e);
|
|
204
190
|
}
|
|
205
191
|
};
|
|
206
|
-
return
|
|
207
|
-
layerId:
|
|
208
|
-
children: /* @__PURE__ */
|
|
209
|
-
value:
|
|
210
|
-
children: /* @__PURE__ */
|
|
192
|
+
return R ? /* @__PURE__ */ m(se, {
|
|
193
|
+
layerId: G,
|
|
194
|
+
children: /* @__PURE__ */ m(pe.Provider, {
|
|
195
|
+
value: it,
|
|
196
|
+
children: /* @__PURE__ */ m("div", {
|
|
211
197
|
role: "menu",
|
|
212
|
-
...
|
|
213
|
-
"aria-labelledby":
|
|
214
|
-
...
|
|
198
|
+
...b,
|
|
199
|
+
"aria-labelledby": b["aria-labelledby"] === void 0 ? E && !A && b["aria-label"] === void 0 ? Ie : void 0 : b["aria-labelledby"],
|
|
200
|
+
...Ge,
|
|
215
201
|
ref: nt,
|
|
216
|
-
id:
|
|
217
|
-
"data-state":
|
|
218
|
-
"data-side":
|
|
219
|
-
"data-align":
|
|
202
|
+
id: Fe,
|
|
203
|
+
"data-state": S ? "open" : "closed",
|
|
204
|
+
"data-side": H["data-side"],
|
|
205
|
+
"data-align": H["data-align"],
|
|
220
206
|
"data-roving-container": "",
|
|
221
207
|
style: {
|
|
222
|
-
...
|
|
223
|
-
...
|
|
208
|
+
...Xe,
|
|
209
|
+
...Te
|
|
224
210
|
},
|
|
225
|
-
onKeyDown:
|
|
226
|
-
onKeyDownCapture:
|
|
227
|
-
onFocus: n(
|
|
228
|
-
onPointerEnter: n(
|
|
229
|
-
onPointerLeave: n(
|
|
230
|
-
onPointerMove: n(
|
|
231
|
-
onContextMenu: n(
|
|
232
|
-
className: e(r.root,
|
|
233
|
-
children:
|
|
211
|
+
onKeyDown: at,
|
|
212
|
+
onKeyDownCapture: ve(n(De, et)),
|
|
213
|
+
onFocus: n(Oe, tt, { checkDefaultPrevented: !1 }),
|
|
214
|
+
onPointerEnter: n(ke, k.onPointerEnter),
|
|
215
|
+
onPointerLeave: n(Ae, k.onPointerLeave),
|
|
216
|
+
onPointerMove: n(je, rt),
|
|
217
|
+
onContextMenu: n(Me, Be.onContextMenu),
|
|
218
|
+
className: e(r.root, ge, Ke, y),
|
|
219
|
+
children: we
|
|
234
220
|
})
|
|
235
221
|
})
|
|
236
222
|
}) : null;
|
|
237
223
|
};
|
|
238
|
-
|
|
224
|
+
g.displayName = "MenuPopover";
|
|
239
225
|
//#endregion
|
|
240
|
-
export {
|
|
226
|
+
export { g as MenuPopover, h as useMenuListPointer };
|
|
241
227
|
|
|
242
228
|
//# sourceMappingURL=Menu.popover.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.popover.mjs","names":["React","SUBMENU_SHIFT","isElementTarget","target","useMenuListPointer","hoverGroup","createHoverIntentGroup","hoverFocusingRef","useEventCallback","event","isOwnEvent","item","MENU_ITEM_SELECTOR","root","menu","MenuPopover","targetProp","rest","useMenuContext","popup","targetPending","usePopupTarget","positioning","targetElement","surface","setSurface","surfaceRef","setSurfaceElement","element","presenceRef","usePresence","open","positionedProps","usePopupPosition","side","isSubmenu","resolvePositioning","offset","floatingProps","_maxHeight","_maxWidth","positionStyle","fromContext","contextAnchor","getTriggerFocusTarget","triggerElement","setReference","getReturnFocus","opener","openOnContext","contextOpener","isConnectedAndFocusable","triggerRef","returnFocusRef","targetRef","useDismiss","dismiss","triggerFocusRef","useTriggerFocusRef","openerRef","wasOpenRef","captureOpener","container","doc","isCandidate","el","trigger","active","wasOpen","getCloseFocus","unnamed","isMounted","warnOnce","rovingRef","rovingKeyDown","rovingKeyDownCapture","rovingFocus","useRovingTabIndex","mergedRef","useMergedRefs","ref","setFloating","registerSurface","focusFirst","focusLast","layerId","unmountingRef","focusReturnTargetOnClose","surfaceElement","takeInitialFocus","isPositioned","portalDepth","PortalDepthContext","registerCheckable","useCheckableRegistry","listPointerMove","listContext","closeChain","isHoverFocusing","handleKeyDown","onKeyDown","isEditableTarget","getArrowIntent","getDirection","requestClose","Portal","MenuListContext","labelledBy","presenceProps","menuId","style","withTypeaheadText","composeEventHandlers","onKeyDownCapture","onFocus","onPointerEnter","hoverSurfaceHandlers","onPointerLeave","onPointerMove","onContextMenu","contextSurfaceHandlers","cn","menuPopoverClassNames","menuPopoverClasses","className"],"sources":["../../../src/components/navigation/Menu.popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuPopoverClassNames } from '../../lib/classNames';\nimport type {\n PopupAlign,\n PopupPositioning,\n PopupSide,\n PopupTarget,\n PopupTargetInput,\n} from '../../lib/types';\nimport { usePopupTarget } from '../../hooks/useResolvedTarget';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isEditableTarget, isOwnEvent } from '../../lib/events';\nimport { isConnectedAndFocusable } from '../../lib/focus';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { createHoverIntentGroup, type HoverIntentGroup } from '../../hooks/useHoverIntent';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { resolvePositioning, usePopupPosition } from '../../hooks/usePopupPosition';\nimport { usePresence } from '../../hooks/usePresence';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { getTriggerFocusTarget, useTriggerFocusRef } from '../../hooks/useTriggerElement';\nimport { Portal, PortalDepthContext } from '../portal/Portal';\nimport { MenuListContext, useCheckableRegistry, useMenuContext } from './Menu.context';\nimport type { MenuContextValue, MenuListContextValue } from './Menu.context';\nimport {\n MENU_ITEM_SELECTOR,\n menuPopoverClasses,\n useStaticMenuPartWarning,\n withTypeaheadText,\n} from './Menu.shared';\n\n/** Properties for the MenuPopover sub-component. */\nexport interface MenuPopoverProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'id'> {\n /**\n * Side of the trigger the menu opens on (`start`/`end` follow the writing direction).\n * @default 'bottom' ('end' in a submenu)\n */\n side?: PopupSide;\n /** Alignment along that side. @default 'start' */\n align?: PopupAlign;\n /** Distance from the trigger in px. @default 4 (0 in a submenu) */\n offset?: number;\n /**\n * Where to place the menu instead of next to `Menu.Trigger`: an element or a `VirtualElement`\n * (a rectangle, such as a point; an inline object is fine). With a controlled `open`, a menu\n * with a `target` needs no trigger; name it with `aria-label`, and give a toggle button you use\n * as the target `aria-haspopup=\"menu\"` and `aria-expanded` yourself (the menu's `id` is\n * generated, so the toggle cannot point `aria-controls` at it). A press on a target element\n * does not close the menu. Hold the element in state, or pass a ref object (read after\n * each render of the menu). A menu opened by `openOnContext` is placed at\n * the gesture instead.\n */\n target?: PopupTargetInput;\n /**\n * Advanced positioning (Fluent's `positioning`): `offset`, `fitViewport`, `matchReferenceWidth`,\n * `fallbackPlacements` and `target` (used when the `target` prop is not set). `side` and `align`\n * stay separate props, and the `offset` prop wins over `positioning.offset`.\n * @default `{ fitViewport: true }`\n */\n positioning?: PopupPositioning;\n /** Menu items and dividers. */\n children: React.ReactNode;\n /**\n * Ref to the portaled `role=\"menu\"` surface. Its `id` is generated (the trigger's\n * `aria-controls` points to it), and it is labelled by the trigger unless `aria-label` or\n * `aria-labelledby` is given (one that holds `undefined` counts as not given).\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * A submenu with room on neither side of its trigger item is shifted across that side, over its\n * parent menu, to stay inside the viewport (as native and Fluent menus do).\n */\nconst SUBMENU_SHIFT = { padding: 8, crossAxis: true } as const;\n\n/** Whether a `target` is an element (duck typed, so an element of another realm counts). */\nfunction isElementTarget(target: PopupTarget | undefined): target is HTMLElement {\n return !!target && (target as Partial<Node>).nodeType === 1;\n}\n\n/**\n * Internal: the mouse behaviour of a menu list (the static root and every `Menu.Popover`\n * surface). While focus is inside a list of the menu tree (the chain's root list or any of its\n * submenus), a mouse `pointermove` over an enabled item of this list focuses it (`preventScroll`),\n * unless it already has focus or a submenu's safe zone of this list holds the point. Hover moves\n * no focus while focus is elsewhere, so a hover-opened menu or a static menu the user is not in\n * never takes focus from the page, and a Popover, Dialog or other portal opened from an item\n * keeps it. Also returns the list's hover group (the safe zones of its submenu trigger items) and\n * the flag the submenus of the list read while such a focus change runs.\n */\nexport function useMenuListPointer(menu: MenuContextValue): {\n hoverGroup: HoverIntentGroup;\n isHoverFocusing: () => boolean;\n onPointerMove: React.PointerEventHandler<HTMLElement>;\n} {\n const [hoverGroup] = React.useState(createHoverIntentGroup);\n const hoverFocusingRef = React.useRef(false);\n const isHoverFocusing = React.useCallback(() => hoverFocusingRef.current, []);\n const onPointerMove = useEventCallback((event: React.PointerEvent<HTMLElement>) => {\n if (event.pointerType === 'touch' || event.pointerType === 'pen' || !isOwnEvent(event)) return;\n const target = event.target as Element;\n const item = target.closest<HTMLElement>(MENU_ITEM_SELECTOR);\n if (!item || !event.currentTarget.contains(item)) return;\n if (item.getAttribute('aria-disabled') === 'true') return;\n if (item.ownerDocument.activeElement === item) return;\n let root = menu;\n while (root.parent) root = root.parent;\n if (!root.listContainsFocus() || hoverGroup.isHeld(event.clientX, event.clientY)) return;\n hoverFocusingRef.current = true;\n item.focus({ preventScroll: true });\n // A submenu that just lost focus is dismissed (focus outside) in a microtask the focus change\n // queued; the flag is cleared after it.\n queueMicrotask(() => {\n hoverFocusingRef.current = false;\n });\n });\n return { hoverGroup, isHoverFocusing, onPointerMove };\n}\n\n/**\n * The portaled `role=\"menu\"` surface of a popup menu, positioned next to `Menu.Trigger`. A menu\n * taller than the space available scrolls inside the viewport: the surface is limited to the space\n * next to the trigger (`max-height`/`max-width` classes, which a `max-h-*`/`max-w-*` class in\n * `className` or a `style` replaces) and scrolls, and an item that receives focus is scrolled into\n * view. Focus moves to the first (ArrowUp: last) enabled item when it opens; arrows, Home/End and\n * typeahead move between enabled items. Escape closes it and returns focus to the trigger. An\n * outside press closes it and leaves focus where the press put it (on the trigger only when focus\n * was still in the menu or lost to the page). Tab closes it and moves focus to the trigger without\n * preventing the default, so tabbing continues from the trigger (inside a Dialog, the focus trap\n * moves on from there). The trigger here is the element that takes its focus: for a wrapper span,\n * the element inside it that carries the state ARIA (the span itself when you made it the trigger\n * with a `role` such as `button` and `tabIndex={0}`, or when nothing inside it can take focus).\n * Keys from a portal opened inside the menu (a Popover of an item) are left to that portal: Tab\n * there moves on inside it and keeps the menu open.\n *\n * In a submenu it opens at the end side of its trigger item (`side=\"end\"`, `offset={0}`) and\n * flips to fit the viewport; with room on neither side, it overlaps its parent menu inside the\n * viewport. ArrowLeft (ArrowRight in RTL) and Escape close only the submenu and return focus to\n * its trigger item; item activation and Tab close every menu of the chain and put focus on the\n * root trigger.\n *\n * While focus is inside the menu (or one of its submenus), the item under the mouse pointer takes\n * focus, so Enter activates the item you point at. Focus in a Popover, Dialog or other portal\n * opened from an item stays there.\n *\n * A context menu (`openOnContext`) opens at the pointer or at the focused row and returns focus to\n * the element focused at the gesture; it is not labelled by its region, so give it `aria-label`\n * (development warning otherwise), as for a menu placed at a `target` without `Menu.Trigger`.\n *\n * The surface mounts through the presence core (`usePresence`): it carries\n * `data-presence=\"entering\" | \"entered\" | \"exiting\"` and, while it closes, `data-state=\"closed\"`\n * and `inert`, so exit motion classes on `data-presence` keep it on screen until they end. Focus,\n * the dismiss layer and positioning follow the open state, not the exit. Without motion it unmounts\n * as soon as it closes.\n *\n * Also exported as `MenuPopover` (import the flat name from React Server Components).\n */\nexport const MenuPopover = ({\n side,\n align = 'start',\n offset,\n target: targetProp,\n positioning,\n children,\n className,\n style,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onPointerEnter,\n onPointerLeave,\n onPointerMove,\n onContextMenu,\n ref,\n ...rest\n}: MenuPopoverProps) => {\n const menu = useMenuContext('Menu.Popover');\n const {\n popup,\n open,\n takeInitialFocus,\n registerSurface,\n menuId,\n labelledBy,\n triggerRef,\n triggerElement,\n isSubmenu,\n requestClose,\n closeChain,\n dismiss,\n hoverSurfaceHandlers,\n isHoverClose,\n openOnContext,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n } = menu;\n useStaticMenuPartWarning('Menu.Popover', popup);\n const { target, pending: targetPending } = usePopupTarget(\n 'Menu.Popover',\n targetProp,\n positioning,\n );\n const targetElement = isElementTarget(target) ? target : null;\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const setSurfaceElement = React.useCallback((element: HTMLDivElement | null) => {\n surfaceRef.current = element;\n setSurface(element);\n }, []);\n\n // The surface mounts and unmounts through the presence core; everything else below keys on\n // `open`, so focus returns and the layer goes on close, not after an exit motion.\n const { isMounted, ref: presenceRef, presenceProps } = usePresence(open);\n\n const {\n setReference,\n setFloating,\n floatingProps: positionedProps,\n isPositioned,\n } = usePopupPosition({\n open,\n side: side ?? (isSubmenu ? 'end' : 'bottom'),\n align,\n shift: isSubmenu ? SUBMENU_SHIFT : undefined,\n ...resolvePositioning(positioning, { offset: isSubmenu ? 0 : 4, fitViewport: true }),\n ...(offset !== undefined && { offset }),\n });\n // A ref target that holds no element yet keeps the popup hidden (as TeachingPopover's is).\n const floatingProps = targetPending\n ? { ...positionedProps, style: { ...positionedProps.style, visibility: 'hidden' as const } }\n : positionedProps;\n // The size limits come from menuPopoverClasses, which a consumer class can replace; an inline\n // max-height/max-width would beat every class.\n const { maxHeight: _maxHeight, maxWidth: _maxWidth, ...positionStyle } = floatingProps.style;\n // The positioning reference: the anchor of a context gesture (the point, else the focused row,\n // else the trigger's focus target), else `target`, else the trigger. Kept while the surface\n // exits, so it does not jump; a new inline VirtualElement only recomputes the position.\n React.useLayoutEffect(() => {\n setReference(\n fromContext\n ? (contextAnchor ?? getTriggerFocusTarget(triggerElement) ?? triggerElement)\n : (target ?? triggerElement),\n );\n }, [setReference, contextAnchor, fromContext, target, triggerElement]);\n\n // Where focus returns when the menu closes (item activation, Tab, Escape): in a context menu,\n // the element focused at the gesture when it can take focus; else the element that takes focus\n // for the trigger (for a wrapper span, the element inside it that carries the state ARIA; for a\n // submenu, its trigger item); else a focusable `target` element.\n const getReturnFocus = useEventCallback((): HTMLElement | null => {\n const opener = openOnContext ? contextOpener.current : null;\n if (opener && isConnectedAndFocusable(opener)) return opener;\n const triggerTarget = getTriggerFocusTarget(triggerRef.current);\n if (triggerTarget) return triggerTarget;\n return targetElement && isConnectedAndFocusable(targetElement) ? targetElement : null;\n });\n\n // The layer's anchor (where a surface opened from an item that is gone by then restores focus):\n // the return target, else the trigger itself.\n const returnFocusRef = React.useMemo<React.RefObject<HTMLElement | null>>(\n () => ({\n get current() {\n return getReturnFocus() ?? triggerRef.current;\n },\n }),\n [getReturnFocus, triggerRef],\n );\n // A context region is not part of the layer (a press on another row closes the menu), and a\n // Ctrl+press there is a macOS context click, which moves the menu instead; a target element is.\n const targetRef = { current: targetElement };\n const { layerId } = useDismiss({\n open,\n onDismiss: dismiss,\n refs: openOnContext ? [surfaceRef, targetRef] : [surfaceRef, triggerRef, targetRef],\n anchorRef: returnFocusRef,\n kind: 'menu',\n focusOutside: true,\n outsidePress: openOnContext\n ? (event) =>\n !(\n event.ctrlKey &&\n event.target instanceof Node &&\n triggerRef.current?.contains(event.target)\n )\n : true,\n });\n\n const triggerFocusRef = useTriggerFocusRef(triggerRef);\n\n // The element focused when the menu opened, captured as useRestoreFocus captures its opener: in\n // the commit that opens the menu, before the initial focus moves into it; the trigger's focus\n // target first (not in a context menu, whose region is no opener), else the focused element.\n const openerRef = React.useRef<HTMLElement | null>(null);\n const wasOpenRef = React.useRef(false);\n const captureOpener = useEventCallback(() => {\n const container = surfaceRef.current;\n const doc = (triggerRef.current ?? container)?.ownerDocument ?? document;\n const isCandidate = (el: Element | null | undefined): el is HTMLElement =>\n !!el && el !== doc.body && el !== doc.documentElement && !container?.contains(el);\n const trigger = openOnContext ? null : triggerFocusRef.current;\n const active = doc.activeElement;\n openerRef.current = isCandidate(trigger) ? trigger : isCandidate(active) ? active : null;\n });\n React.useInsertionEffect(() => {\n const wasOpen = wasOpenRef.current;\n wasOpenRef.current = open;\n if (open && !wasOpen) captureOpener();\n });\n // Where focus goes when the menu closes with focus inside it (Escape, a close by the app): where\n // useRestoreFocus would put it, in its order: the context opener, the element focused when the\n // menu opened, then the return target (a menu with a `target` and no trigger returns focus to\n // its opener, not to a focusable target element).\n const getCloseFocus = useEventCallback((): HTMLElement | null => {\n const container = surfaceRef.current;\n const candidates = [\n openOnContext ? contextOpener.current : null,\n openerRef.current,\n getReturnFocus(),\n ];\n return (\n candidates.find(\n (el): el is HTMLElement => !!el && isConnectedAndFocusable(el) && !container?.contains(el),\n ) ?? null\n );\n });\n\n useRestoreFocus({\n enabled: open,\n container: surface,\n // A context menu returns focus to the opener (the focused row), not to the region.\n triggerRef: openOnContext ? undefined : triggerFocusRef,\n finalFocusRef: openOnContext ? contextOpener : undefined,\n fallback: getReturnFocus,\n onlyIfFocusInside: true,\n // A hover close moves no focus (a submenu closing with it is taken along by the hook).\n isHoverClose,\n });\n\n // C-DEV: a surface that no trigger labels needs its own name.\n const unnamed =\n isMounted &&\n (openOnContext || (target != null && !triggerElement)) &&\n rest['aria-label'] === undefined &&\n rest['aria-labelledby'] === undefined;\n React.useEffect(() => {\n if (!unnamed) return;\n warnOnce(\n 'Menu.Popover:name',\n 'Menu.Popover: this menu has no trigger to name it (a context menu, or a menu placed at a `target` without Menu.Trigger): give Menu.Popover an aria-label or aria-labelledby.',\n );\n }, [unnamed]);\n\n const {\n containerProps: { ref: rovingRef },\n handleKeyDown: rovingKeyDown,\n handleKeyDownCapture: rovingKeyDownCapture,\n handleFocus: rovingFocus,\n focusFirst,\n focusLast,\n } = useRovingTabIndex({\n orientation: 'vertical',\n loop: true,\n typeahead: true,\n manageTabIndex: true,\n itemSelector: MENU_ITEM_SELECTOR,\n });\n\n const mergedRef = useMergedRefs<HTMLDivElement>(\n ref,\n setSurfaceElement,\n rovingRef,\n setFloating,\n presenceRef,\n );\n\n // Lets the trigger move focus into an already open menu (ArrowDown/ArrowUp on the trigger) and\n // the root reach the surface. Only an open surface registers, and it unregisters in the commit\n // that closes the menu: a surface that stays mounted while it exits would otherwise make the next\n // opening focus its (inert) items instead of opening the menu.\n React.useLayoutEffect(() => {\n if (!surface || !open) return;\n registerSurface({ focusFirst, focusLast, surface, layerId, getReturnFocus });\n return () => registerSurface(null);\n }, [surface, open, registerSurface, focusFirst, focusLast, layerId, getReturnFocus]);\n\n // Focus before close, on every close: when the menu closes with focus inside it, focus moves to\n // where the restore would put it (`getCloseFocus`) in the closing commit's mutation phase (a\n // layout effect cleanup), before a surface opened in the same update (a Dialog rendered after\n // the menu, opened by the item that closed it) records the focused element as its opener. The\n // closing surface is still in the document then (it unmounts once its exit phase ends), so that\n // opener would be its item, gone by the time the Dialog closes. The surface is inert from this\n // commit on, so in a browser React cannot put focus back on the item after the commit, and\n // useRestoreFocus, which then finds focus outside, leaves it there: the two must agree on the\n // target. Unmounting is left to useRestoreFocus.\n const unmountingRef = React.useRef(false);\n React.useLayoutEffect(() => {\n unmountingRef.current = false;\n return () => {\n unmountingRef.current = true;\n };\n }, []);\n const focusReturnTargetOnClose = useEventCallback(() => {\n const surfaceElement = surfaceRef.current;\n const active = surfaceElement?.ownerDocument.activeElement;\n if (unmountingRef.current || !surfaceElement || !active || !surfaceElement.contains(active)) {\n return;\n }\n getCloseFocus()?.focus({ preventScroll: true });\n });\n React.useLayoutEffect(() => {\n if (!open) return undefined;\n return focusReturnTargetOnClose;\n }, [open, focusReturnTargetOnClose]);\n\n // Initial focus: the first (or last) enabled item, unless focus is already inside. A hover\n // opening moves no focus.\n React.useLayoutEffect(() => {\n if (!open || !surface) return;\n if (surface.contains(surface.ownerDocument.activeElement)) return;\n const target = takeInitialFocus();\n if (target === 'last') focusLast();\n else if (target === 'first') focusFirst();\n }, [open, surface, takeInitialFocus, focusFirst, focusLast]);\n\n // The initial focus lands before the surface is limited to the available height (floating-ui\n // measures after mount), so it scrolls nothing: once positioned, the focused item (the last one\n // after ArrowUp) is scrolled into view. Later focus moves scroll through the native focus().\n React.useLayoutEffect(() => {\n if (!isPositioned || !surface) return;\n const active = surface.ownerDocument.activeElement as HTMLElement | null;\n if (active && active !== surface && surface.contains(active)) {\n active.scrollIntoView?.({ block: 'nearest' });\n }\n }, [isPositioned, surface]);\n\n // The list the items render in. Its children sit inside the Portal, one portal level deeper.\n // Item activation closes the whole chain; the item under the mouse takes focus while focus is\n // inside the menu tree.\n const portalDepth = React.useContext(PortalDepthContext) + 1;\n const registerCheckable = useCheckableRegistry();\n const { hoverGroup, isHoverFocusing, onPointerMove: listPointerMove } = useMenuListPointer(menu);\n const listContext = React.useMemo<MenuListContextValue>(\n () => ({\n menu,\n isStatic: false,\n portalDepth,\n closeFromItem: closeChain,\n registerCheckable,\n hoverGroup,\n isHoverFocusing,\n }),\n [menu, portalDepth, closeChain, registerCheckable, hoverGroup, isHoverFocusing],\n );\n\n // C-COMPOSE: the consumer's onKeyDown runs first; preventDefault() skips the built-in keys. A key\n // from a portal opened inside the menu (a Popover of an item, a submenu) is that portal's: Tab\n // moves on inside it and never closes the menu.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || !isOwnEvent(event)) return;\n if (event.key === 'Tab') {\n // Close every menu of the chain and put focus on the root trigger; the default Tab action\n // then continues from there.\n closeChain();\n return;\n }\n // \"Previous\" (ArrowLeft, ArrowRight in RTL) closes a submenu and returns to its trigger item.\n if (\n isSubmenu &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey &&\n !isEditableTarget(event.target) &&\n getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n }) === 'prev'\n ) {\n event.preventDefault();\n getReturnFocus()?.focus({ preventScroll: true });\n requestClose();\n return;\n }\n rovingKeyDown(event);\n };\n\n if (!isMounted) return null;\n\n return (\n <Portal layerId={layerId}>\n <MenuListContext.Provider value={listContext}>\n <div\n role=\"menu\"\n {...rest}\n // After the spread: a consumer name wins when it is defined, and a forwarded key that\n // holds `undefined` does not remove the trigger's. A context region's whole text is no\n // name: a context menu is named by aria-label.\n aria-labelledby={\n rest['aria-labelledby'] !== undefined\n ? rest['aria-labelledby']\n : triggerElement && !openOnContext && rest['aria-label'] === undefined\n ? labelledBy\n : undefined\n }\n {...presenceProps}\n ref={mergedRef}\n id={menuId}\n data-state={open ? 'open' : 'closed'}\n data-side={floatingProps['data-side']}\n data-align={floatingProps['data-align']}\n data-roving-container=\"\"\n style={{ ...positionStyle, ...style }}\n onKeyDown={handleKeyDown}\n onKeyDownCapture={withTypeaheadText(\n composeEventHandlers(onKeyDownCapture, rovingKeyDownCapture),\n )}\n onFocus={composeEventHandlers(onFocus, rovingFocus, { checkDefaultPrevented: false })}\n onPointerEnter={composeEventHandlers(onPointerEnter, hoverSurfaceHandlers.onPointerEnter)}\n onPointerLeave={composeEventHandlers(onPointerLeave, hoverSurfaceHandlers.onPointerLeave)}\n onPointerMove={composeEventHandlers(onPointerMove, listPointerMove)}\n onContextMenu={composeEventHandlers(onContextMenu, contextSurfaceHandlers.onContextMenu)}\n className={cn(menuPopoverClassNames.root, menuPopoverClasses, className)}\n >\n {children}\n </div>\n </MenuListContext.Provider>\n </Portal>\n );\n};\nMenuPopover.displayName = 'MenuPopover';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8EA,IAAMC,KAAgB;CAAE,SAAS;CAAG,WAAW;AAAK;AAGpD,SAASC,GAAgB,GAAwD;CA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uB,KAAA,IAExB4B,KAAkB,CAACI,KAAiBhC,EAAK,kBAAkB,KAAA,IACzD0F,KACA,KAAA,IAHF1F,EAAK;IAKX,GAAI2F;IACJ,KAAK9B;IACL,IAAI+B;IACJ,cAAY9E,IAAO,SAAS;IAC5B,aAAWO,EAAc;IACzB,cAAYA,EAAc;IAC1B,yBAAsB;IACtB,OAAO;KAAE,GAAGG;KAAe,GAAGqE;IAAM;IACpC,WAAWX;IACX,kBAAkBY,GAChBC,EAAqBC,IAAkBtC,EAAoB,CAC7D;IACA,SAASqC,EAAqBE,IAAStC,IAAa,EAAE,uBAAuB,GAAM,CAAC;IACpF,gBAAgBoC,EAAqBG,IAAgBC,EAAqB,cAAc;IACxF,gBAAgBJ,EAAqBK,IAAgBD,EAAqB,cAAc;IACxF,eAAeJ,EAAqBM,IAAevB,EAAe;IAClE,eAAeiB,EAAqBO,IAAeC,GAAuB,aAAa;IACvF,WAAWC,EAAGC,EAAsB,MAAMC,IAAoBC,EAAS;IAEtE;GACE,CAAA;EACmB,CAAA;CACpB,CAAA,IAxCa;AA0CzB;AACA,EAAY,cAAc"}
|
|
1
|
+
{"version":3,"file":"Menu.popover.mjs","names":["React","SUBMENU_SHIFT","isElementTarget","target","useMenuListPointer","hoverGroup","createHoverIntentGroup","hoverFocusingRef","useEventCallback","event","isOwnEvent","item","MENU_ITEM_SELECTOR","root","menu","MenuPopover","targetProp","rest","useMenuContext","popup","targetPending","usePopupTarget","positioning","targetElement","surface","setSurface","surfaceRef","setSurfaceElement","element","presenceRef","usePresence","open","motionClassName","useMotionClasses","motion","popupMotion","className","positionedProps","usePopupPosition","side","isSubmenu","resolvePositioning","offset","floatingProps","_maxHeight","_maxWidth","positionStyle","fromContext","contextAnchor","getTriggerFocusTarget","triggerElement","setReference","getReturnFocus","opener","openOnContext","contextOpener","isConnectedAndFocusable","triggerRef","returnFocusRef","targetRef","useDismiss","dismiss","triggerFocusRef","useTriggerFocusRef","unnamed","isMounted","warnOnce","rovingRef","rovingKeyDown","rovingKeyDownCapture","rovingFocus","useRovingTabIndex","mergedRef","useMergedRefs","ref","setFloating","registerSurface","focusFirst","focusLast","layerId","useFocusBeforeClose","takeInitialFocus","isPositioned","active","portalDepth","PortalDepthContext","registerCheckable","useCheckableRegistry","listPointerMove","listContext","closeChain","isHoverFocusing","handleKeyDown","onKeyDown","isEditableTarget","getArrowIntent","getDirection","requestClose","Portal","MenuListContext","labelledBy","presenceProps","menuId","style","withTypeaheadText","composeEventHandlers","onKeyDownCapture","onFocus","onPointerEnter","hoverSurfaceHandlers","onPointerLeave","onPointerMove","onContextMenu","contextSurfaceHandlers","cn","menuPopoverClassNames","menuPopoverClasses"],"sources":["../../../src/components/navigation/Menu.popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuPopoverClassNames } from '../../lib/classNames';\nimport { popupMotion } from '../../lib/motion';\nimport type {\n MotionSlot,\n PopupAlign,\n PopupPositioning,\n PopupSide,\n PopupTarget,\n PopupTargetInput,\n} from '../../lib/types';\nimport { usePopupTarget } from '../../hooks/useResolvedTarget';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isEditableTarget, isOwnEvent } from '../../lib/events';\nimport { isConnectedAndFocusable } from '../../lib/focus';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useFocusBeforeClose } from '../../hooks/useFocusBeforeClose';\nimport { createHoverIntentGroup, type HoverIntentGroup } from '../../hooks/useHoverIntent';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useMotionClasses } from '../../hooks/useMotion';\nimport { resolvePositioning, usePopupPosition } from '../../hooks/usePopupPosition';\nimport { usePresence } from '../../hooks/usePresence';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { getTriggerFocusTarget, useTriggerFocusRef } from '../../hooks/useTriggerElement';\nimport { Portal, PortalDepthContext } from '../portal/Portal';\nimport { MenuListContext, useCheckableRegistry, useMenuContext } from './Menu.context';\nimport type { MenuContextValue, MenuListContextValue } from './Menu.context';\nimport {\n MENU_ITEM_SELECTOR,\n menuPopoverClasses,\n useStaticMenuPartWarning,\n withTypeaheadText,\n} from './Menu.shared';\n\n/** Properties for the MenuPopover sub-component. */\nexport interface MenuPopoverProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'id'> {\n /**\n * Side of the trigger the menu opens on (`start`/`end` follow the writing direction).\n * @default 'bottom' ('end' in a submenu)\n */\n side?: PopupSide;\n /** Alignment along that side. @default 'start' */\n align?: PopupAlign;\n /** Distance from the trigger in px. @default 4 (0 in a submenu) */\n offset?: number;\n /**\n * Where to place the menu instead of next to `Menu.Trigger`: an element or a `VirtualElement`\n * (a rectangle, such as a point; an inline object is fine). With a controlled `open`, a menu\n * with a `target` needs no trigger; name it with `aria-label`, and give a toggle button you use\n * as the target `aria-haspopup=\"menu\"` and `aria-expanded` yourself (the menu's `id` is\n * generated, so the toggle cannot point `aria-controls` at it). A press on a target element\n * does not close the menu. Hold the element in state, or pass a ref object (read after\n * each render of the menu). A menu opened by `openOnContext` is placed at\n * the gesture instead.\n */\n target?: PopupTargetInput;\n /**\n * Advanced positioning (Fluent's `positioning`): `offset`, `fitViewport`, `matchReferenceWidth`,\n * `fallbackPlacements` and `target` (used when the `target` prop is not set). `side` and `align`\n * stay separate props, and the `offset` prop wins over `positioning.offset`.\n * @default `{ fitViewport: true }`\n */\n positioning?: PopupPositioning;\n /**\n * The menu's motion. By default it fades in and slides 4px away from its trigger, on the side\n * it opened on (a submenu away from its parent menu), over 200 ms with a decelerating curve, and\n * fades out and slides back over 100 ms with an accelerating curve; under reduced motion it\n * appears and disappears at once. `null` turns the motion off (the surface still renders its\n * `data-presence` phases, which then end at once); a class string or `{ className }` replaces\n * the default classes with yours (see `MotionSlot`), also under a `WaveProvider` with\n * `motion=\"none\"`, which otherwise turns the default off. A `className` that holds\n * `data-[presence=…]` classes while `motion` is unset keeps 0.14's behaviour: no default motion,\n * your classes animate the surface. Fluent's `Menu` `surfaceMotion`.\n * @default the fade and slide above\n */\n motion?: MotionSlot | null;\n /** Menu items and dividers. */\n children: React.ReactNode;\n /**\n * Ref to the portaled `role=\"menu\"` surface. Its `id` is generated (the trigger's\n * `aria-controls` points to it), and it is labelled by the trigger unless `aria-label` or\n * `aria-labelledby` is given (one that holds `undefined` counts as not given).\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * A submenu with room on neither side of its trigger item is shifted across that side, over its\n * parent menu, to stay inside the viewport (as native and Fluent menus do).\n */\nconst SUBMENU_SHIFT = { padding: 8, crossAxis: true } as const;\n\n/** Whether a `target` is an element (duck typed, so an element of another realm counts). */\nfunction isElementTarget(target: PopupTarget | undefined): target is HTMLElement {\n return !!target && (target as Partial<Node>).nodeType === 1;\n}\n\n/**\n * Internal: the mouse behaviour of a menu list (the static root and every `Menu.Popover`\n * surface). While focus is inside a list of the menu tree (the chain's root list or any of its\n * submenus), a mouse `pointermove` over an enabled item of this list focuses it (`preventScroll`),\n * unless it already has focus or a submenu's safe zone of this list holds the point. Hover moves\n * no focus while focus is elsewhere, so a hover-opened menu or a static menu the user is not in\n * never takes focus from the page, and a Popover, Dialog or other portal opened from an item\n * keeps it. Also returns the list's hover group (the safe zones of its submenu trigger items) and\n * the flag the submenus of the list read while such a focus change runs.\n */\nexport function useMenuListPointer(menu: MenuContextValue): {\n hoverGroup: HoverIntentGroup;\n isHoverFocusing: () => boolean;\n onPointerMove: React.PointerEventHandler<HTMLElement>;\n} {\n const [hoverGroup] = React.useState(createHoverIntentGroup);\n const hoverFocusingRef = React.useRef(false);\n const isHoverFocusing = React.useCallback(() => hoverFocusingRef.current, []);\n const onPointerMove = useEventCallback((event: React.PointerEvent<HTMLElement>) => {\n if (event.pointerType === 'touch' || event.pointerType === 'pen' || !isOwnEvent(event)) return;\n const target = event.target as Element;\n const item = target.closest<HTMLElement>(MENU_ITEM_SELECTOR);\n if (!item || !event.currentTarget.contains(item)) return;\n if (item.getAttribute('aria-disabled') === 'true') return;\n if (item.ownerDocument.activeElement === item) return;\n let root = menu;\n while (root.parent) root = root.parent;\n if (!root.listContainsFocus() || hoverGroup.isHeld(event.clientX, event.clientY)) return;\n hoverFocusingRef.current = true;\n item.focus({ preventScroll: true });\n // A submenu that just lost focus is dismissed (focus outside) in a microtask the focus change\n // queued; the flag is cleared after it.\n queueMicrotask(() => {\n hoverFocusingRef.current = false;\n });\n });\n return { hoverGroup, isHoverFocusing, onPointerMove };\n}\n\n/**\n * The portaled `role=\"menu\"` surface of a popup menu, positioned next to `Menu.Trigger`. A menu\n * taller than the space available scrolls inside the viewport: the surface is limited to the space\n * next to the trigger (`max-height`/`max-width` classes, which a `max-h-*`/`max-w-*` class in\n * `className` or a `style` replaces) and scrolls, and an item that receives focus is scrolled into\n * view. Focus moves to the first (ArrowUp: last) enabled item when it opens; arrows, Home/End and\n * typeahead move between enabled items. Escape closes it and returns focus to the trigger. An\n * outside press closes it and leaves focus where the press put it (on the trigger only when focus\n * was still in the menu or lost to the page). Tab closes it and moves focus to the trigger without\n * preventing the default, so tabbing continues from the trigger (inside a Dialog, the focus trap\n * moves on from there). The trigger here is the element that takes its focus: for a wrapper span,\n * the element inside it that carries the state ARIA (the span itself when you made it the trigger\n * with a `role` such as `button` and `tabIndex={0}`, or when nothing inside it can take focus).\n * Keys from a portal opened inside the menu (a Popover of an item) are left to that portal: Tab\n * there moves on inside it and keeps the menu open.\n *\n * In a submenu it opens at the end side of its trigger item (`side=\"end\"`, `offset={0}`) and\n * flips to fit the viewport; with room on neither side, it overlaps its parent menu inside the\n * viewport. ArrowLeft (ArrowRight in RTL) and Escape close only the submenu and return focus to\n * its trigger item; item activation and Tab close every menu of the chain and put focus on the\n * root trigger.\n *\n * While focus is inside the menu (or one of its submenus), the item under the mouse pointer takes\n * focus, so Enter activates the item you point at. Focus in a Popover, Dialog or other portal\n * opened from an item stays there.\n *\n * A context menu (`openOnContext`) opens at the pointer or at the focused row and returns focus to\n * the element focused at the gesture; it is not labelled by its region, so give it `aria-label`\n * (development warning otherwise), as for a menu placed at a `target` without `Menu.Trigger`.\n *\n * It moves in and out: the surface fades in and slides 4px away from its trigger over 200 ms, and\n * fades out and slides back over 100 ms, on the side it opened on (`data-side`), so a submenu\n * slides out of its parent menu; a menu open by default animates in when it mounts in the\n * browser. Under reduced motion it appears and disappears at once. `motion` turns the motion off\n * (`null`) or replaces its classes, and a `WaveProvider` with `motion=\"none\"` turns the default\n * off; a `className` with `data-[presence=…]` classes and no `motion` keeps 0.14's behaviour (your\n * classes, no default motion). The surface mounts through the presence core (`usePresence`): it\n * carries `data-presence=\"entering\" | \"entered\" | \"exiting\"` and, while it closes,\n * `data-state=\"closed\"` and `inert`, so it stays on screen, where it was, until its exit motion\n * ends. Focus, the dismiss layer and positioning follow the open state, not the exit: focus\n * inside a closing menu leaves it in the commit that closes it. Without motion it unmounts as\n * soon as it closes.\n *\n * Also exported as `MenuPopover` (import the flat name from React Server Components).\n */\nexport const MenuPopover = ({\n side,\n align = 'start',\n offset,\n target: targetProp,\n positioning,\n motion,\n children,\n className,\n style,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onPointerEnter,\n onPointerLeave,\n onPointerMove,\n onContextMenu,\n ref,\n ...rest\n}: MenuPopoverProps) => {\n const menu = useMenuContext('Menu.Popover');\n const {\n popup,\n open,\n takeInitialFocus,\n registerSurface,\n menuId,\n labelledBy,\n triggerRef,\n triggerElement,\n isSubmenu,\n requestClose,\n closeChain,\n dismiss,\n hoverSurfaceHandlers,\n isHoverClose,\n openOnContext,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n } = menu;\n useStaticMenuPartWarning('Menu.Popover', popup);\n const { target, pending: targetPending } = usePopupTarget(\n 'Menu.Popover',\n targetProp,\n positioning,\n );\n const targetElement = isElementTarget(target) ? target : null;\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const setSurfaceElement = React.useCallback((element: HTMLDivElement | null) => {\n surfaceRef.current = element;\n setSurface(element);\n }, []);\n\n // The surface mounts and unmounts through the presence core, and enters also when it mounts open\n // (D9: a menu open by default animates in on a client render as after hydration); everything\n // else below keys on `open`, so focus returns and the layer goes on close, not after the exit.\n const { isMounted, ref: presenceRef, presenceProps } = usePresence(open, { appear: true });\n // The motion classes (a `className` with presence variants keeps 0.14's own motion, D19).\n const motionClassName = useMotionClasses(motion, popupMotion, className);\n\n const {\n setReference,\n setFloating,\n floatingProps: positionedProps,\n isPositioned,\n } = usePopupPosition({\n open,\n side: side ?? (isSubmenu ? 'end' : 'bottom'),\n align,\n shift: isSubmenu ? SUBMENU_SHIFT : undefined,\n ...resolvePositioning(positioning, { offset: isSubmenu ? 0 : 4, fitViewport: true }),\n ...(offset !== undefined && { offset }),\n });\n // A ref target that holds no element yet keeps the popup hidden (as TeachingPopover's is).\n const floatingProps = targetPending\n ? { ...positionedProps, style: { ...positionedProps.style, visibility: 'hidden' as const } }\n : positionedProps;\n // The size limits come from menuPopoverClasses, which a consumer class can replace; an inline\n // max-height/max-width would beat every class.\n const { maxHeight: _maxHeight, maxWidth: _maxWidth, ...positionStyle } = floatingProps.style;\n // The positioning reference: the anchor of a context gesture (the point, else the focused row,\n // else the trigger's focus target), else `target`, else the trigger. Kept while the surface\n // exits, so it does not jump; a new inline VirtualElement only recomputes the position.\n React.useLayoutEffect(() => {\n setReference(\n fromContext\n ? (contextAnchor ?? getTriggerFocusTarget(triggerElement) ?? triggerElement)\n : (target ?? triggerElement),\n );\n }, [setReference, contextAnchor, fromContext, target, triggerElement]);\n\n // Where focus returns when the menu closes (item activation, Tab, Escape): in a context menu,\n // the element focused at the gesture when it can take focus; else the element that takes focus\n // for the trigger (for a wrapper span, the element inside it that carries the state ARIA; for a\n // submenu, its trigger item); else a focusable `target` element.\n const getReturnFocus = useEventCallback((): HTMLElement | null => {\n const opener = openOnContext ? contextOpener.current : null;\n if (opener && isConnectedAndFocusable(opener)) return opener;\n const triggerTarget = getTriggerFocusTarget(triggerRef.current);\n if (triggerTarget) return triggerTarget;\n return targetElement && isConnectedAndFocusable(targetElement) ? targetElement : null;\n });\n\n // The layer's anchor (where a surface opened from an item that is gone by then restores focus):\n // the return target, else the trigger itself.\n const returnFocusRef = React.useMemo<React.RefObject<HTMLElement | null>>(\n () => ({\n get current() {\n return getReturnFocus() ?? triggerRef.current;\n },\n }),\n [getReturnFocus, triggerRef],\n );\n // A context region is not part of the layer (a press on another row closes the menu), and a\n // Ctrl+press there is a macOS context click, which moves the menu instead; a target element is.\n const targetRef = { current: targetElement };\n const { layerId } = useDismiss({\n open,\n onDismiss: dismiss,\n refs: openOnContext ? [surfaceRef, targetRef] : [surfaceRef, triggerRef, targetRef],\n anchorRef: returnFocusRef,\n kind: 'menu',\n focusOutside: true,\n outsidePress: openOnContext\n ? (event) =>\n !(\n event.ctrlKey &&\n event.target instanceof Node &&\n triggerRef.current?.contains(event.target)\n )\n : true,\n });\n\n const triggerFocusRef = useTriggerFocusRef(triggerRef);\n\n useRestoreFocus({\n enabled: open,\n container: surface,\n // A context menu returns focus to the opener (the focused row), not to the region.\n triggerRef: openOnContext ? undefined : triggerFocusRef,\n finalFocusRef: openOnContext ? contextOpener : undefined,\n fallback: getReturnFocus,\n onlyIfFocusInside: true,\n // A hover close moves no focus (a submenu closing with it is taken along by the hook).\n isHoverClose,\n });\n\n // C-DEV: a surface that no trigger labels needs its own name.\n const unnamed =\n isMounted &&\n (openOnContext || (target != null && !triggerElement)) &&\n rest['aria-label'] === undefined &&\n rest['aria-labelledby'] === undefined;\n React.useEffect(() => {\n if (!unnamed) return;\n warnOnce(\n 'Menu.Popover:name',\n 'Menu.Popover: this menu has no trigger to name it (a context menu, or a menu placed at a `target` without Menu.Trigger): give Menu.Popover an aria-label or aria-labelledby.',\n );\n }, [unnamed]);\n\n const {\n containerProps: { ref: rovingRef },\n handleKeyDown: rovingKeyDown,\n handleKeyDownCapture: rovingKeyDownCapture,\n handleFocus: rovingFocus,\n focusFirst,\n focusLast,\n } = useRovingTabIndex({\n orientation: 'vertical',\n loop: true,\n typeahead: true,\n manageTabIndex: true,\n itemSelector: MENU_ITEM_SELECTOR,\n });\n\n const mergedRef = useMergedRefs<HTMLDivElement>(\n ref,\n setSurfaceElement,\n rovingRef,\n setFloating,\n presenceRef,\n );\n\n // Lets the trigger move focus into an already open menu (ArrowDown/ArrowUp on the trigger) and\n // the root reach the surface. Only an open surface registers, and it unregisters in the commit\n // that closes the menu: a surface that stays mounted while it exits would otherwise make the next\n // opening focus its (inert) items instead of opening the menu.\n React.useLayoutEffect(() => {\n if (!surface || !open) return;\n registerSurface({ focusFirst, focusLast, surface, layerId, getReturnFocus });\n return () => registerSurface(null);\n }, [surface, open, registerSurface, focusFirst, focusLast, layerId, getReturnFocus]);\n\n // Focus before close, on every close: when the menu closes with focus inside it, focus moves in\n // the closing commit to where useRestoreFocus would put it, in its order: the context opener,\n // the element focused when the menu opened (the trigger's focus target first, but not in a\n // context menu, whose region is no opener), then the return target (a menu with a `target` and\n // no trigger returns focus to its opener, not to a focusable target element). A Dialog opened\n // by the item that closed the menu then records that element as its opener, not the item, which\n // the exiting surface still holds. Unmounting is left to useRestoreFocus.\n useFocusBeforeClose({\n open,\n surfaceRef,\n captureOpener: () => (openOnContext ? null : triggerFocusRef.current),\n candidates: (opener) => [\n openOnContext ? contextOpener.current : null,\n opener,\n getReturnFocus(),\n ],\n });\n\n // Initial focus: the first (or last) enabled item, unless focus is already inside. A hover\n // opening moves no focus.\n React.useLayoutEffect(() => {\n if (!open || !surface) return;\n if (surface.contains(surface.ownerDocument.activeElement)) return;\n const target = takeInitialFocus();\n if (target === 'last') focusLast();\n else if (target === 'first') focusFirst();\n }, [open, surface, takeInitialFocus, focusFirst, focusLast]);\n\n // The initial focus lands before the surface is limited to the available height (floating-ui\n // measures after mount), so it scrolls nothing: once positioned, the focused item (the last one\n // after ArrowUp) is scrolled into view. Later focus moves scroll through the native focus().\n React.useLayoutEffect(() => {\n if (!isPositioned || !surface) return;\n const active = surface.ownerDocument.activeElement as HTMLElement | null;\n if (active && active !== surface && surface.contains(active)) {\n active.scrollIntoView?.({ block: 'nearest' });\n }\n }, [isPositioned, surface]);\n\n // The list the items render in. Its children sit inside the Portal, one portal level deeper.\n // Item activation closes the whole chain; the item under the mouse takes focus while focus is\n // inside the menu tree.\n const portalDepth = React.useContext(PortalDepthContext) + 1;\n const registerCheckable = useCheckableRegistry();\n const { hoverGroup, isHoverFocusing, onPointerMove: listPointerMove } = useMenuListPointer(menu);\n const listContext = React.useMemo<MenuListContextValue>(\n () => ({\n menu,\n isStatic: false,\n portalDepth,\n closeFromItem: closeChain,\n registerCheckable,\n hoverGroup,\n isHoverFocusing,\n }),\n [menu, portalDepth, closeChain, registerCheckable, hoverGroup, isHoverFocusing],\n );\n\n // C-COMPOSE: the consumer's onKeyDown runs first; preventDefault() skips the built-in keys. A key\n // from a portal opened inside the menu (a Popover of an item, a submenu) is that portal's: Tab\n // moves on inside it and never closes the menu.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || !isOwnEvent(event)) return;\n if (event.key === 'Tab') {\n // Close every menu of the chain and put focus on the root trigger; the default Tab action\n // then continues from there.\n closeChain();\n return;\n }\n // \"Previous\" (ArrowLeft, ArrowRight in RTL) closes a submenu and returns to its trigger item.\n if (\n isSubmenu &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey &&\n !isEditableTarget(event.target) &&\n getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n }) === 'prev'\n ) {\n event.preventDefault();\n getReturnFocus()?.focus({ preventScroll: true });\n requestClose();\n return;\n }\n rovingKeyDown(event);\n };\n\n if (!isMounted) return null;\n\n return (\n <Portal layerId={layerId}>\n <MenuListContext.Provider value={listContext}>\n <div\n role=\"menu\"\n {...rest}\n // After the spread: a consumer name wins when it is defined, and a forwarded key that\n // holds `undefined` does not remove the trigger's. A context region's whole text is no\n // name: a context menu is named by aria-label.\n aria-labelledby={\n rest['aria-labelledby'] !== undefined\n ? rest['aria-labelledby']\n : triggerElement && !openOnContext && rest['aria-label'] === undefined\n ? labelledBy\n : undefined\n }\n {...presenceProps}\n ref={mergedRef}\n id={menuId}\n data-state={open ? 'open' : 'closed'}\n data-side={floatingProps['data-side']}\n data-align={floatingProps['data-align']}\n data-roving-container=\"\"\n style={{ ...positionStyle, ...style }}\n onKeyDown={handleKeyDown}\n onKeyDownCapture={withTypeaheadText(\n composeEventHandlers(onKeyDownCapture, rovingKeyDownCapture),\n )}\n onFocus={composeEventHandlers(onFocus, rovingFocus, { checkDefaultPrevented: false })}\n onPointerEnter={composeEventHandlers(onPointerEnter, hoverSurfaceHandlers.onPointerEnter)}\n onPointerLeave={composeEventHandlers(onPointerLeave, hoverSurfaceHandlers.onPointerLeave)}\n onPointerMove={composeEventHandlers(onPointerMove, listPointerMove)}\n onContextMenu={composeEventHandlers(onContextMenu, contextSurfaceHandlers.onContextMenu)}\n className={cn(menuPopoverClassNames.root, menuPopoverClasses, motionClassName, className)}\n >\n {children}\n </div>\n </MenuListContext.Provider>\n </Portal>\n );\n};\nMenuPopover.displayName = 'MenuPopover';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,IAAMC,KAAgB;CAAE,SAAS;CAAG,WAAW;AAAK;AAGpD,SAASC,GAAgB,GAAwD;CAC/E,OAAO,CAAC,CAACC,KAAWA,EAAyB,aAAa;AAC5D;AAYA,SAAgBC,EAAmB,GAIjC;CACA,IAAM,CAACC,KAAcL,EAAM,SAASM,CAAsB,GACpDC,IAAmBP,EAAM,OAAO,EAAK;CAoB3C,OAAO;EAAE;EAAY,iBAnBGA,EAAM,kBAAkBO,EAAiB,SAAS,CAAC,CAmBtD;EAAiB,eAlBhBC,GAA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iC,KAAkB,CAACI,KAAiBrC,EAAK,kBAAkB,KAAA,IACzDmF,KACA,KAAA,IAHFnF,EAAK;IAKX,GAAIoF;IACJ,KAAK7B;IACL,IAAI8B;IACJ,cAAYvE,IAAO,SAAS;IAC5B,aAAWY,EAAc;IACzB,cAAYA,EAAc;IAC1B,yBAAsB;IACtB,OAAO;KAAE,GAAGG;KAAe,GAAGyD;IAAM;IACpC,WAAWX;IACX,kBAAkBY,GAChBC,EAAqBC,IAAkBrC,EAAoB,CAC7D;IACA,SAASoC,EAAqBE,IAASrC,IAAa,EAAE,uBAAuB,GAAM,CAAC;IACpF,gBAAgBmC,EAAqBG,IAAgBC,EAAqB,cAAc;IACxF,gBAAgBJ,EAAqBK,IAAgBD,EAAqB,cAAc;IACxF,eAAeJ,EAAqBM,IAAevB,EAAe;IAClE,eAAeiB,EAAqBO,IAAeC,GAAuB,aAAa;IACvF,WAAWC,EAAGC,EAAsB,MAAMC,IAAoBpF,IAAiBI,CAAS;IAEvF;GACE,CAAA;EACmB,CAAA;CACpB,CAAA,IAxCa;AA0CzB;AACA,EAAY,cAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useId.cjs"),o=require("../../lib/styles.cjs"),s=require("../../lib/icons.cjs"),
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useId.cjs"),o=require("../../lib/styles.cjs"),s=require("../button/Button.slots.cjs"),c=require("../../lib/icons.cjs"),l=require("../../lib/motion.cjs"),u=require("../../hooks/useMotion.cjs"),d=require("../../hooks/useCollapsePresence.cjs"),f=require("./Nav.context.cjs"),p=require("./Nav.parts.cjs"),m=require("./Nav.root.cjs");let h=require("react");h=e.__toESM(h,1);let g=require("react/jsx-runtime");var _=`flex h-5 w-5 shrink-0 items-center justify-center`;function v(e,n){return e&&r.slotRendersContent(e)?r.renderSlot(e,`span`,t.cn(n,_),{"aria-hidden":!0}):null}var y={base:t.cn(`flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none`,o.focusRingInset,o.disabledStyles),selected:`bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary`,idle:`text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`,selectedInRow:`text-primary font-semibold`,rowSelected:`bg-subtle-selected border-s-2 border-s-primary`},b={base:t.cn(`flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none`,o.focusRingInset,o.disabledStyles),selected:`text-primary font-semibold`,idle:`text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`,selectedInRow:`text-primary font-semibold`,rowSelected:void 0},x=`group/nav-row flex items-center transition-colors motion-reduce:transition-none`,S=`hover:bg-subtle-hover`,C=t.cn(`flex shrink-0 items-center gap-1 pe-2`,`*:opacity-0 group-hover/nav-row:*:opacity-100 group-focus-within/nav-row:*:opacity-100`,`forced-colors:*:opacity-100 [@media(hover:none)]:*:opacity-100`,`*:has-[[aria-pressed=true]]:opacity-100 *:has-[[aria-expanded=true]]:opacity-100`,`[&>[aria-pressed=true]]:opacity-100 [&>[aria-expanded=true]]:opacity-100`),w=t.cn(`flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none`,`data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary`,o.focusRingInset);function T(e){if(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;let t=e.currentTarget,n=t.getAttribute(`target`);return!!n&&n.toLowerCase()!==`_self`||t.hasAttribute(`download`)}function E(e,n,i,a,o,s,c,u){let{value:d,icon:f,disabled:p=!1,href:m,className:h,children:_,onClick:y,actions:b,ref:w,...E}=e,D=n.value===d,O=m!==void 0,k=i?{"data-roving-value":d}:void 0,A=r.slotRendersContent(b),j=E.id??c,M=A?{id:j}:void 0,N=e=>{if(p){e.preventDefault();return}y?.(e),!(O?!e.defaultPrevented&&T(e):e.defaultPrevented)&&n.select(d)},P=(0,g.jsxs)(g.Fragment,{children:[s&&v(f,o.icon),s?(0,g.jsx)(`span`,{className:t.cn(o.content,`flex-1 text-start`),children:_}):_]}),F=t.cn(o.root,a.base,D?A?a.selectedInRow:a.selected:a.idle,A&&`min-w-0 flex-1`,h),I=A?t.cn(o.listItem,x,D&&a.rowSelected?a.rowSelected:!p&&S):o.listItem,L=A?(0,g.jsx)(`span`,{role:`group`,"aria-labelledby":j,"data-wave-nav-actions":``,className:t.cn(o.actions,C,u===`none`?void 0:l.navActionsRevealMotion),children:r.materialiseSlotContent(b)}):null;if(O)return(0,g.jsxs)(`li`,{className:I,children:[(0,g.jsx)(`a`,{...E,...M,...k,ref:w,href:p?void 0:m,role:p?`link`:E.role,"aria-disabled":p?!0:E[`aria-disabled`],"aria-current":D?`page`:void 0,onClick:N,className:F,children:P}),L]});let{rel:R,...z}=E;return(0,g.jsxs)(`li`,{className:I,children:[(0,g.jsx)(`button`,{type:`button`,...z,...M,...k,ref:w,disabled:p,"aria-current":D?`page`:void 0,onClick:N,className:F,children:P}),L]})}var D=({value:e,label:o,icon:p,expandIcon:m,expandIconMotion:_,motion:y,className:b,children:x,ref:S,...C})=>{let T=f.useNavContext(`Nav.Category`),E=h.useContext(f.NavRovingContext),{value:D,openCategories:O,toggleCategory:k,currentCategory:A,categoryStore:j}=T;f.useNavValue(T,`category`,e);let M=a.useId(`wave-nav-category`),N=O.includes(e),P=!N&&D!==``&&f.containsValue(x,D),F=h.useSyncExternalStore(j.subscribe,()=>D!==``&&j.get(D)===e,()=>!1);h.useLayoutEffect(()=>{if(P)return j.record(D,e),()=>j.forget(D,e)},[j,P,D,e]);let I=!N&&(A===e||F||P);h.useLayoutEffect(()=>{if(E)return E.reportCurrentCategory(e,I),()=>E.reportCurrentCategory(e,!1)},[E,e,I]);let L=h.useRef(null);f.useNavListChildCheck(L,`Nav.Category`,`sub-items`);let R=h.useRef(null),{isMounted:z,wrapperRef:B,presenceProps:V,className:H}=d.useCollapsePresence(N,{motion:y,partRef:L,getTrigger:()=>R.current}),{glyph:U,button:W}=s.unwrapButtonGlyph(m);h.useEffect(()=>{W&&n.warnOnce(`Nav.Category:expandIcon-button`,`Nav.Category: \`expandIcon\` received ${W}; its children render as the glyph of the toggle button and its props were dropped (buttons cannot be nested). Pass icon content instead, e.g. \`expandIcon={<MyIcon />}\`.`)},[W]);let G=u.useMotionClasses(_,l.expandIconMotion),K=null;U==null?K=(0,g.jsx)(c.ChevronDownIcon,{className:t.cn(i.navCategoryClassNames.expandIcon,`shrink-0`,G,N&&`rotate-180`)}):r.slotRendersContent(U)&&(K=r.renderSlot(U,`span`,t.cn(i.navCategoryClassNames.expandIcon,`inline-flex shrink-0`,G),{"aria-hidden":!0}));let q=o,J=x;if(o===void 0){n.warnDeprecated(`Nav.Category`,`text children as the label`,`label`,"Pass the category label in `label` and only the sub-items as children.");let e=h.Children.toArray(x),t=e=>typeof e==`string`||typeof e==`number`;q=e.filter(t).join(``),J=e.filter(e=>!t(e))}return(0,g.jsxs)(`li`,{ref:S,...C,className:t.cn(i.navCategoryClassNames.root,b),children:[(0,g.jsxs)(`button`,{ref:R,type:`button`,"aria-expanded":N,"aria-controls":N?M:void 0,"aria-current":I?!0:void 0,"data-contains-current":I?``:void 0,"data-roving-value":E?`wave-nav-category:${e}`:void 0,onClick:()=>k(e),className:t.cn(i.navCategoryClassNames.button,w),children:[v(p,i.navCategoryClassNames.icon),(0,g.jsx)(`span`,{className:t.cn(i.navCategoryClassNames.label,`flex-1 text-start`),children:q}),K]}),z&&(0,g.jsx)(f.NavCategoryValueContext.Provider,{value:e,children:(0,g.jsx)(`div`,{ref:B,...V,className:t.cn(i.navCategoryClassNames.collapse,H),children:(0,g.jsx)(`ul`,{ref:L,id:M,className:t.cn(i.navCategoryClassNames.list,`m-0 list-none p-0`),children:J})})})]})};D.displayName=`NavCategory`,f.markNavPart(D,`category`);function O(e){let t=f.useNavContext(`Nav.Item`);f.useNavValue(t,`item`,e.value),f.useRecordCategory(t,e.value);let n=h.useContext(f.NavRovingContext),r=a.useId(`wave-nav-item`),o=u.useMotionPreference();return E(e,t,n,y,{root:i.navItemClassNames.root,listItem:i.navItemClassNames.listItem,actions:i.navItemClassNames.actions,icon:i.navItemClassNames.icon,content:i.navItemClassNames.content},!0,r,o)}O.displayName=`NavItem`,f.markNavPart(O,`entry`);function k(e){let t=f.useNavContext(`Nav.SubItem`);f.useNavValue(t,`item`,e.value),f.useRecordCategory(t,e.value);let n=h.useContext(f.NavRovingContext),r=a.useId(`wave-nav-item`),o=u.useMotionPreference();return E(e,t,n,b,{root:i.navSubItemClassNames.root,listItem:i.navSubItemClassNames.listItem,actions:i.navSubItemClassNames.actions},!1,r,o)}k.displayName=`NavSubItem`,f.markNavPart(k,`entry`);var A=Object.assign(m.NavRoot,{Category:D,Item:O,SubItem:k,SectionHeader:p.NavSectionHeader,Divider:p.NavDivider,AppItem:p.NavAppItem,AppItemStatic:p.NavAppItemStatic});exports.Nav=A,exports.NavAppItem=p.NavAppItem,exports.NavAppItemStatic=p.NavAppItemStatic,exports.NavCategory=D,exports.NavDivider=p.NavDivider,exports.NavItem=O,exports.NavSectionHeader=p.NavSectionHeader,exports.NavSubItem=k;
|
|
2
2
|
//# sourceMappingURL=Nav.cjs.map
|