@radix-ui/react-navigation-menu 1.0.1-rc.9 → 1.1.0-rc.2
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/index.d.ts +26 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -63
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +115 -64
- package/dist/index.module.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -9,13 +9,29 @@ type Direction = 'ltr' | 'rtl';
|
|
|
9
9
|
export const createNavigationMenuScope: import("@radix-ui/react-context").CreateScope;
|
|
10
10
|
type NavigationMenuElement = React.ElementRef<typeof Primitive.nav>;
|
|
11
11
|
type PrimitiveNavProps = Radix.ComponentPropsWithoutRef<typeof Primitive.nav>;
|
|
12
|
-
export interface NavigationMenuProps extends Omit<NavigationMenuProviderProps, keyof NavigationMenuProviderPrivateProps>,
|
|
12
|
+
export interface NavigationMenuProps extends Omit<NavigationMenuProviderProps, keyof NavigationMenuProviderPrivateProps>, PrimitiveNavProps {
|
|
13
|
+
value?: string;
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
onValueChange?: (value: string) => void;
|
|
13
16
|
dir?: Direction;
|
|
14
17
|
orientation?: Orientation;
|
|
18
|
+
/**
|
|
19
|
+
* The duration from when the pointer enters the trigger until the tooltip gets opened.
|
|
20
|
+
* @defaultValue 200
|
|
21
|
+
*/
|
|
22
|
+
delayDuration?: number;
|
|
23
|
+
/**
|
|
24
|
+
* How much time a user has to enter another trigger without incurring a delay again.
|
|
25
|
+
* @defaultValue 300
|
|
26
|
+
*/
|
|
27
|
+
skipDelayDuration?: number;
|
|
15
28
|
}
|
|
16
29
|
export const NavigationMenu: React.ForwardRefExoticComponent<NavigationMenuProps & React.RefAttributes<HTMLElement>>;
|
|
17
30
|
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
18
|
-
export interface NavigationMenuSubProps extends Omit<NavigationMenuProviderProps, keyof NavigationMenuProviderPrivateProps>,
|
|
31
|
+
export interface NavigationMenuSubProps extends Omit<NavigationMenuProviderProps, keyof NavigationMenuProviderPrivateProps>, PrimitiveDivProps {
|
|
32
|
+
value?: string;
|
|
33
|
+
defaultValue?: string;
|
|
34
|
+
onValueChange?: (value: string) => void;
|
|
19
35
|
orientation?: Orientation;
|
|
20
36
|
}
|
|
21
37
|
export const NavigationMenuSub: React.ForwardRefExoticComponent<NavigationMenuSubProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -26,11 +42,15 @@ interface NavigationMenuProviderPrivateProps {
|
|
|
26
42
|
orientation: Orientation;
|
|
27
43
|
dir: Direction;
|
|
28
44
|
rootNavigationMenu: NavigationMenuElement | null;
|
|
45
|
+
value: string;
|
|
46
|
+
onTriggerEnter(itemValue: string): void;
|
|
47
|
+
onTriggerLeave?(): void;
|
|
48
|
+
onContentEnter?(): void;
|
|
49
|
+
onContentLeave?(): void;
|
|
50
|
+
onItemSelect(itemValue: string): void;
|
|
51
|
+
onItemDismiss(): void;
|
|
29
52
|
}
|
|
30
53
|
interface NavigationMenuProviderProps extends NavigationMenuProviderPrivateProps {
|
|
31
|
-
value?: string;
|
|
32
|
-
defaultValue?: string;
|
|
33
|
-
onValueChange?: (value: string) => void;
|
|
34
54
|
}
|
|
35
55
|
type PrimitiveUnorderedListProps = Radix.ComponentPropsWithoutRef<typeof Primitive.ul>;
|
|
36
56
|
export interface NavigationMenuListProps extends PrimitiveUnorderedListProps {
|
|
@@ -76,6 +96,7 @@ interface NavigationMenuContentImplPrivateProps {
|
|
|
76
96
|
value: string;
|
|
77
97
|
triggerRef: React.RefObject<NavigationMenuTriggerElement>;
|
|
78
98
|
focusProxyRef: React.RefObject<FocusProxyElement>;
|
|
99
|
+
wasEscapeCloseRef: React.MutableRefObject<boolean>;
|
|
79
100
|
onContentFocusOutside(): void;
|
|
80
101
|
onRootContentClose(): void;
|
|
81
102
|
}
|
package/dist/index.d.ts.map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B,CAAC;AAChC,OAAA,MAAM,8GAAmC,CAAC;AAC1C,OAAA,MAAM,0GAA+B,CAAC;AACtC,OAAA,MAAM,4GAAiC,CAAC","sources":["packages/react/navigation-menu/src/packages/react/navigation-menu/src/NavigationMenu.tsx","packages/react/navigation-menu/src/packages/react/navigation-menu/src/index.ts","packages/react/navigation-menu/src/index.ts"],"sourcesContent":[null,null,"export {\n createNavigationMenuScope,\n //\n NavigationMenu,\n NavigationMenuSub,\n NavigationMenuList,\n NavigationMenuItem,\n NavigationMenuTrigger,\n NavigationMenuLink,\n NavigationMenuIndicator,\n NavigationMenuContent,\n NavigationMenuViewport,\n //\n Root,\n Sub,\n List,\n Item,\n Trigger,\n Link,\n Indicator,\n Content,\n Viewport,\n} from './NavigationMenu';\nexport type {\n NavigationMenuProps,\n NavigationMenuSubProps,\n NavigationMenuListProps,\n NavigationMenuItemProps,\n NavigationMenuTriggerProps,\n NavigationMenuLinkProps,\n NavigationMenuIndicatorProps,\n NavigationMenuContentProps,\n NavigationMenuViewportProps,\n} from './NavigationMenu';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
CHANGED
|
@@ -71,20 +71,90 @@ const [$7f73b938b73b5118$var$createNavigationMenuContext, $7f73b938b73b5118$expo
|
|
|
71
71
|
const [$7f73b938b73b5118$var$NavigationMenuProviderImpl, $7f73b938b73b5118$var$useNavigationMenuContext] = $7f73b938b73b5118$var$createNavigationMenuContext($7f73b938b73b5118$var$NAVIGATION_MENU_NAME);
|
|
72
72
|
const [$7f73b938b73b5118$var$ViewportContentProvider, $7f73b938b73b5118$var$useViewportContentContext] = $7f73b938b73b5118$var$createNavigationMenuContext($7f73b938b73b5118$var$NAVIGATION_MENU_NAME);
|
|
73
73
|
const $7f73b938b73b5118$export$5b2278cf1e8bcae2 = /*#__PURE__*/ $6jHCS$react.forwardRef((props, forwardedRef)=>{
|
|
74
|
-
const { __scopeNavigationMenu: __scopeNavigationMenu , value:
|
|
74
|
+
const { __scopeNavigationMenu: __scopeNavigationMenu , value: valueProp , onValueChange: onValueChange , defaultValue: defaultValue , delayDuration: delayDuration = 200 , skipDelayDuration: skipDelayDuration = 300 , orientation: orientation = 'horizontal' , dir: dir , ...NavigationMenuProps } = props;
|
|
75
75
|
const [navigationMenu, setNavigationMenu] = $6jHCS$react.useState(null);
|
|
76
76
|
const composedRef = $6jHCS$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setNavigationMenu(node)
|
|
77
77
|
);
|
|
78
78
|
const direction = $6jHCS$radixuireactdirection.useDirection(dir);
|
|
79
|
+
const openTimerRef = $6jHCS$react.useRef(0);
|
|
80
|
+
const closeTimerRef = $6jHCS$react.useRef(0);
|
|
81
|
+
const skipDelayTimerRef = $6jHCS$react.useRef(0);
|
|
82
|
+
const [isOpenDelayed, setIsOpenDelayed] = $6jHCS$react.useState(true);
|
|
83
|
+
const [value1 = '', setValue] = $6jHCS$radixuireactusecontrollablestate.useControllableState({
|
|
84
|
+
prop: valueProp,
|
|
85
|
+
onChange: (value)=>{
|
|
86
|
+
const isOpen = value !== '';
|
|
87
|
+
const hasSkipDelayDuration = skipDelayDuration > 0;
|
|
88
|
+
if (isOpen) {
|
|
89
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
90
|
+
if (hasSkipDelayDuration) setIsOpenDelayed(false);
|
|
91
|
+
} else {
|
|
92
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
93
|
+
skipDelayTimerRef.current = window.setTimeout(()=>setIsOpenDelayed(true)
|
|
94
|
+
, skipDelayDuration);
|
|
95
|
+
}
|
|
96
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(value);
|
|
97
|
+
},
|
|
98
|
+
defaultProp: defaultValue
|
|
99
|
+
});
|
|
100
|
+
const startCloseTimer = $6jHCS$react.useCallback(()=>{
|
|
101
|
+
window.clearTimeout(closeTimerRef.current);
|
|
102
|
+
closeTimerRef.current = window.setTimeout(()=>setValue('')
|
|
103
|
+
, 150);
|
|
104
|
+
}, [
|
|
105
|
+
setValue
|
|
106
|
+
]);
|
|
107
|
+
const handleOpen = $6jHCS$react.useCallback((itemValue)=>{
|
|
108
|
+
window.clearTimeout(closeTimerRef.current);
|
|
109
|
+
setValue(itemValue);
|
|
110
|
+
}, [
|
|
111
|
+
setValue
|
|
112
|
+
]);
|
|
113
|
+
const handleDelayedOpen = $6jHCS$react.useCallback((itemValue)=>{
|
|
114
|
+
const isOpenItem = value1 === itemValue;
|
|
115
|
+
if (isOpenItem) // If the item is already open (e.g. we're transitioning from the content to the trigger)
|
|
116
|
+
// then we want to clear the close timer immediately.
|
|
117
|
+
window.clearTimeout(closeTimerRef.current);
|
|
118
|
+
else openTimerRef.current = window.setTimeout(()=>{
|
|
119
|
+
window.clearTimeout(closeTimerRef.current);
|
|
120
|
+
setValue(itemValue);
|
|
121
|
+
}, delayDuration);
|
|
122
|
+
}, [
|
|
123
|
+
value1,
|
|
124
|
+
setValue,
|
|
125
|
+
delayDuration
|
|
126
|
+
]);
|
|
127
|
+
$6jHCS$react.useEffect(()=>{
|
|
128
|
+
return ()=>{
|
|
129
|
+
window.clearTimeout(openTimerRef.current);
|
|
130
|
+
window.clearTimeout(closeTimerRef.current);
|
|
131
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
132
|
+
};
|
|
133
|
+
}, []);
|
|
79
134
|
return /*#__PURE__*/ $6jHCS$react.createElement($7f73b938b73b5118$var$NavigationMenuProvider, {
|
|
80
135
|
scope: __scopeNavigationMenu,
|
|
81
136
|
isRootMenu: true,
|
|
82
|
-
value:
|
|
83
|
-
onValueChange: onValueChange,
|
|
84
|
-
defaultValue: defaultValue,
|
|
137
|
+
value: value1,
|
|
85
138
|
dir: direction,
|
|
86
139
|
orientation: orientation,
|
|
87
|
-
rootNavigationMenu: navigationMenu
|
|
140
|
+
rootNavigationMenu: navigationMenu,
|
|
141
|
+
onTriggerEnter: (itemValue)=>{
|
|
142
|
+
window.clearTimeout(openTimerRef.current);
|
|
143
|
+
if (isOpenDelayed) handleDelayedOpen(itemValue);
|
|
144
|
+
else handleOpen(itemValue);
|
|
145
|
+
},
|
|
146
|
+
onTriggerLeave: ()=>{
|
|
147
|
+
window.clearTimeout(openTimerRef.current);
|
|
148
|
+
startCloseTimer();
|
|
149
|
+
},
|
|
150
|
+
onContentEnter: ()=>window.clearTimeout(closeTimerRef.current)
|
|
151
|
+
,
|
|
152
|
+
onContentLeave: startCloseTimer,
|
|
153
|
+
onItemSelect: (itemValue)=>{
|
|
154
|
+
setValue((prevValue)=>prevValue === itemValue ? '' : itemValue
|
|
155
|
+
);
|
|
156
|
+
},
|
|
157
|
+
onItemDismiss: ()=>setValue('')
|
|
88
158
|
}, /*#__PURE__*/ $6jHCS$react.createElement($6jHCS$radixuireactprimitive.Primitive.nav, ($parcel$interopDefault($6jHCS$babelruntimehelpersextends))({
|
|
89
159
|
"aria-label": "Main",
|
|
90
160
|
"data-orientation": orientation,
|
|
@@ -100,17 +170,25 @@ const $7f73b938b73b5118$export$5b2278cf1e8bcae2 = /*#__PURE__*/ $6jHCS$react.for
|
|
|
100
170
|
* NavigationMenuSub
|
|
101
171
|
* -----------------------------------------------------------------------------------------------*/ const $7f73b938b73b5118$var$SUB_NAME = 'NavigationMenuSub';
|
|
102
172
|
const $7f73b938b73b5118$export$5958edd6c4ee7c79 = /*#__PURE__*/ $6jHCS$react.forwardRef((props, forwardedRef)=>{
|
|
103
|
-
const { __scopeNavigationMenu: __scopeNavigationMenu , value:
|
|
173
|
+
const { __scopeNavigationMenu: __scopeNavigationMenu , value: valueProp , onValueChange: onValueChange , defaultValue: defaultValue , orientation: orientation = 'horizontal' , ...subProps } = props;
|
|
104
174
|
const context = $7f73b938b73b5118$var$useNavigationMenuContext($7f73b938b73b5118$var$SUB_NAME, __scopeNavigationMenu);
|
|
175
|
+
const [value = '', setValue] = $6jHCS$radixuireactusecontrollablestate.useControllableState({
|
|
176
|
+
prop: valueProp,
|
|
177
|
+
onChange: onValueChange,
|
|
178
|
+
defaultProp: defaultValue
|
|
179
|
+
});
|
|
105
180
|
return /*#__PURE__*/ $6jHCS$react.createElement($7f73b938b73b5118$var$NavigationMenuProvider, {
|
|
106
181
|
scope: __scopeNavigationMenu,
|
|
107
182
|
isRootMenu: false,
|
|
108
183
|
value: value,
|
|
109
|
-
onValueChange: onValueChange,
|
|
110
|
-
defaultValue: defaultValue,
|
|
111
184
|
dir: context.dir,
|
|
112
185
|
orientation: orientation,
|
|
113
|
-
rootNavigationMenu: context.rootNavigationMenu
|
|
186
|
+
rootNavigationMenu: context.rootNavigationMenu,
|
|
187
|
+
onTriggerEnter: (itemValue)=>setValue(itemValue)
|
|
188
|
+
,
|
|
189
|
+
onItemSelect: (itemValue)=>setValue(itemValue)
|
|
190
|
+
,
|
|
191
|
+
onItemDismiss: ()=>setValue('')
|
|
114
192
|
}, /*#__PURE__*/ $6jHCS$react.createElement($6jHCS$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($6jHCS$babelruntimehelpersextends))({
|
|
115
193
|
"data-orientation": orientation
|
|
116
194
|
}, subProps, {
|
|
@@ -121,22 +199,10 @@ const $7f73b938b73b5118$export$5958edd6c4ee7c79 = /*#__PURE__*/ $6jHCS$react.for
|
|
|
121
199
|
displayName: $7f73b938b73b5118$var$SUB_NAME
|
|
122
200
|
});
|
|
123
201
|
/* -----------------------------------------------------------------------------------------------*/ const $7f73b938b73b5118$var$NavigationMenuProvider = (props)=>{
|
|
124
|
-
const { scope: scope , isRootMenu: isRootMenu , rootNavigationMenu: rootNavigationMenu , value:
|
|
202
|
+
const { scope: scope , isRootMenu: isRootMenu , rootNavigationMenu: rootNavigationMenu , dir: dir , orientation: orientation , children: children , value: value , onItemSelect: onItemSelect , onItemDismiss: onItemDismiss , onTriggerEnter: onTriggerEnter , onTriggerLeave: onTriggerLeave , onContentEnter: onContentEnter , onContentLeave: onContentLeave } = props;
|
|
125
203
|
const [viewport, setViewport] = $6jHCS$react.useState(null);
|
|
126
204
|
const [viewportContent, setViewportContent] = $6jHCS$react.useState(new Map());
|
|
127
205
|
const [indicatorTrack, setIndicatorTrack] = $6jHCS$react.useState(null);
|
|
128
|
-
const closeTimerRef = $6jHCS$react.useRef(0);
|
|
129
|
-
const [value = '', setValue] = $6jHCS$radixuireactusecontrollablestate.useControllableState({
|
|
130
|
-
prop: valueProp,
|
|
131
|
-
onChange: onValueChange,
|
|
132
|
-
defaultProp: defaultValue
|
|
133
|
-
});
|
|
134
|
-
$6jHCS$react.useEffect(()=>{
|
|
135
|
-
return ()=>window.clearTimeout(closeTimerRef.current)
|
|
136
|
-
;
|
|
137
|
-
}, [
|
|
138
|
-
closeTimerRef
|
|
139
|
-
]);
|
|
140
206
|
return /*#__PURE__*/ $6jHCS$react.createElement($7f73b938b73b5118$var$NavigationMenuProviderImpl, {
|
|
141
207
|
scope: scope,
|
|
142
208
|
isRootMenu: isRootMenu,
|
|
@@ -150,35 +216,12 @@ const $7f73b938b73b5118$export$5958edd6c4ee7c79 = /*#__PURE__*/ $6jHCS$react.for
|
|
|
150
216
|
onViewportChange: setViewport,
|
|
151
217
|
indicatorTrack: indicatorTrack,
|
|
152
218
|
onIndicatorTrackChange: setIndicatorTrack,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
]),
|
|
160
|
-
onItemLeave: $6jHCS$react.useCallback(()=>{
|
|
161
|
-
if (isRootMenu) {
|
|
162
|
-
window.clearTimeout(closeTimerRef.current);
|
|
163
|
-
closeTimerRef.current = window.setTimeout(()=>setValue('')
|
|
164
|
-
, 150);
|
|
165
|
-
}
|
|
166
|
-
}, [
|
|
167
|
-
setValue,
|
|
168
|
-
isRootMenu
|
|
169
|
-
]),
|
|
170
|
-
onItemSelect: $6jHCS$react.useCallback((itemValue)=>{
|
|
171
|
-
setValue((prevValue)=>{
|
|
172
|
-
return isRootMenu ? prevValue === itemValue ? '' : itemValue : itemValue;
|
|
173
|
-
});
|
|
174
|
-
}, [
|
|
175
|
-
setValue,
|
|
176
|
-
isRootMenu
|
|
177
|
-
]),
|
|
178
|
-
onItemDismiss: $6jHCS$react.useCallback(()=>setValue('')
|
|
179
|
-
, [
|
|
180
|
-
setValue
|
|
181
|
-
]),
|
|
219
|
+
onTriggerEnter: $6jHCS$radixuireactusecallbackref.useCallbackRef(onTriggerEnter),
|
|
220
|
+
onTriggerLeave: $6jHCS$radixuireactusecallbackref.useCallbackRef(onTriggerLeave),
|
|
221
|
+
onContentEnter: $6jHCS$radixuireactusecallbackref.useCallbackRef(onContentEnter),
|
|
222
|
+
onContentLeave: $6jHCS$radixuireactusecallbackref.useCallbackRef(onContentLeave),
|
|
223
|
+
onItemSelect: $6jHCS$radixuireactusecallbackref.useCallbackRef(onItemSelect),
|
|
224
|
+
onItemDismiss: $6jHCS$radixuireactusecallbackref.useCallbackRef(onItemDismiss),
|
|
182
225
|
onViewportContentChange: $6jHCS$react.useCallback((contentValue, contentData)=>{
|
|
183
226
|
setViewportContent((prevContent)=>{
|
|
184
227
|
prevContent.set(contentValue, contentData);
|
|
@@ -237,6 +280,7 @@ const $7f73b938b73b5118$export$ffdbb83a2de845c2 = /*#__PURE__*/ $6jHCS$react.for
|
|
|
237
280
|
const triggerRef = $6jHCS$react.useRef(null);
|
|
238
281
|
const focusProxyRef = $6jHCS$react.useRef(null);
|
|
239
282
|
const restoreContentTabOrderRef = $6jHCS$react.useRef(()=>{});
|
|
283
|
+
const wasEscapeCloseRef = $6jHCS$react.useRef(false);
|
|
240
284
|
const handleContentEntry = $6jHCS$react.useCallback((side = 'start')=>{
|
|
241
285
|
if (contentRef.current) {
|
|
242
286
|
restoreContentTabOrderRef.current();
|
|
@@ -256,6 +300,7 @@ const $7f73b938b73b5118$export$ffdbb83a2de845c2 = /*#__PURE__*/ $6jHCS$react.for
|
|
|
256
300
|
triggerRef: triggerRef,
|
|
257
301
|
contentRef: contentRef,
|
|
258
302
|
focusProxyRef: focusProxyRef,
|
|
303
|
+
wasEscapeCloseRef: wasEscapeCloseRef,
|
|
259
304
|
onEntryKeyDown: handleContentEntry,
|
|
260
305
|
onFocusProxyEnter: handleContentEntry,
|
|
261
306
|
onRootContentClose: handleContentExit,
|
|
@@ -278,6 +323,7 @@ const $7f73b938b73b5118$export$37fe8002734d8f2 = /*#__PURE__*/ $6jHCS$react.forw
|
|
|
278
323
|
const composedRefs = $6jHCS$radixuireactcomposerefs.useComposedRefs(ref, itemContext.triggerRef, forwardedRef);
|
|
279
324
|
const triggerId = $7f73b938b73b5118$var$makeTriggerId(context.baseId, itemContext.value);
|
|
280
325
|
const contentId = $7f73b938b73b5118$var$makeContentId(context.baseId, itemContext.value);
|
|
326
|
+
const hasPointerMoveOpenedRef = $6jHCS$react.useRef(false);
|
|
281
327
|
const wasClickCloseRef = $6jHCS$react.useRef(false);
|
|
282
328
|
const open = itemContext.value === context.value;
|
|
283
329
|
return /*#__PURE__*/ $6jHCS$react.createElement($6jHCS$react.Fragment, null, /*#__PURE__*/ $6jHCS$react.createElement($7f73b938b73b5118$var$Collection.ItemSlot, {
|
|
@@ -296,14 +342,17 @@ const $7f73b938b73b5118$export$37fe8002734d8f2 = /*#__PURE__*/ $6jHCS$react.forw
|
|
|
296
342
|
ref: composedRefs,
|
|
297
343
|
onPointerEnter: $6jHCS$radixuiprimitive.composeEventHandlers(props.onPointerEnter, ()=>{
|
|
298
344
|
wasClickCloseRef.current = false;
|
|
345
|
+
itemContext.wasEscapeCloseRef.current = false;
|
|
299
346
|
}),
|
|
300
347
|
onPointerMove: $6jHCS$radixuiprimitive.composeEventHandlers(props.onPointerMove, $7f73b938b73b5118$var$whenMouse(()=>{
|
|
301
|
-
if (disabled || wasClickCloseRef.current) return;
|
|
302
|
-
context.
|
|
348
|
+
if (disabled || wasClickCloseRef.current || itemContext.wasEscapeCloseRef.current || hasPointerMoveOpenedRef.current) return;
|
|
349
|
+
context.onTriggerEnter(itemContext.value);
|
|
350
|
+
hasPointerMoveOpenedRef.current = true;
|
|
303
351
|
})),
|
|
304
352
|
onPointerLeave: $6jHCS$radixuiprimitive.composeEventHandlers(props.onPointerLeave, $7f73b938b73b5118$var$whenMouse(()=>{
|
|
305
353
|
if (disabled) return;
|
|
306
|
-
context.
|
|
354
|
+
context.onTriggerLeave();
|
|
355
|
+
hasPointerMoveOpenedRef.current = false;
|
|
307
356
|
})),
|
|
308
357
|
onClick: $6jHCS$radixuiprimitive.composeEventHandlers(props.onClick, ()=>{
|
|
309
358
|
context.onItemSelect(itemContext.value);
|
|
@@ -456,6 +505,7 @@ const $7f73b938b73b5118$export$38e00e996c2f93f7 = /*#__PURE__*/ $6jHCS$react.for
|
|
|
456
505
|
value: itemContext.value,
|
|
457
506
|
triggerRef: itemContext.triggerRef,
|
|
458
507
|
focusProxyRef: itemContext.focusProxyRef,
|
|
508
|
+
wasEscapeCloseRef: itemContext.wasEscapeCloseRef,
|
|
459
509
|
onContentFocusOutside: itemContext.onContentFocusOutside,
|
|
460
510
|
onRootContentClose: itemContext.onRootContentClose,
|
|
461
511
|
...contentProps
|
|
@@ -466,10 +516,8 @@ const $7f73b938b73b5118$export$38e00e996c2f93f7 = /*#__PURE__*/ $6jHCS$react.for
|
|
|
466
516
|
"data-state": $7f73b938b73b5118$var$getOpenState(open)
|
|
467
517
|
}, commonProps, {
|
|
468
518
|
ref: composedRefs,
|
|
469
|
-
onPointerEnter: $6jHCS$radixuiprimitive.composeEventHandlers(props.onPointerEnter,
|
|
470
|
-
|
|
471
|
-
}),
|
|
472
|
-
onPointerLeave: $6jHCS$radixuiprimitive.composeEventHandlers(props.onPointerLeave, $7f73b938b73b5118$var$whenMouse(context.onItemLeave)),
|
|
519
|
+
onPointerEnter: $6jHCS$radixuiprimitive.composeEventHandlers(props.onPointerEnter, context.onContentEnter),
|
|
520
|
+
onPointerLeave: $6jHCS$radixuiprimitive.composeEventHandlers(props.onPointerLeave, $7f73b938b73b5118$var$whenMouse(context.onContentLeave)),
|
|
473
521
|
style: {
|
|
474
522
|
// Prevent interaction when animating out
|
|
475
523
|
pointerEvents: !open && context.isRootMenu ? 'none' : undefined,
|
|
@@ -508,7 +556,7 @@ const $7f73b938b73b5118$export$38e00e996c2f93f7 = /*#__PURE__*/ $6jHCS$react.for
|
|
|
508
556
|
});
|
|
509
557
|
/* -----------------------------------------------------------------------------------------------*/ const $7f73b938b73b5118$var$ROOT_CONTENT_DISMISS = 'navigationMenu.rootContentDismiss';
|
|
510
558
|
const $7f73b938b73b5118$var$NavigationMenuContentImpl = /*#__PURE__*/ $6jHCS$react.forwardRef((props, forwardedRef)=>{
|
|
511
|
-
const { __scopeNavigationMenu: __scopeNavigationMenu , value: value , triggerRef: triggerRef , focusProxyRef: focusProxyRef , onRootContentClose: onRootContentClose , onContentFocusOutside: onContentFocusOutside , ...contentProps } = props;
|
|
559
|
+
const { __scopeNavigationMenu: __scopeNavigationMenu , value: value , triggerRef: triggerRef , focusProxyRef: focusProxyRef , wasEscapeCloseRef: wasEscapeCloseRef , onRootContentClose: onRootContentClose , onContentFocusOutside: onContentFocusOutside , ...contentProps } = props;
|
|
512
560
|
const context = $7f73b938b73b5118$var$useNavigationMenuContext($7f73b938b73b5118$var$CONTENT_NAME, __scopeNavigationMenu);
|
|
513
561
|
const ref = $6jHCS$react.useRef(null);
|
|
514
562
|
const composedRefs = $6jHCS$radixuireactcomposerefs.useComposedRefs(ref, forwardedRef);
|
|
@@ -620,6 +668,11 @@ const $7f73b938b73b5118$var$NavigationMenuContentImpl = /*#__PURE__*/ $6jHCS$rea
|
|
|
620
668
|
(_focusProxyRef$curren = focusProxyRef.current) === null || _focusProxyRef$curren === void 0 || _focusProxyRef$curren.focus();
|
|
621
669
|
}
|
|
622
670
|
}
|
|
671
|
+
}),
|
|
672
|
+
onEscapeKeyDown: $6jHCS$radixuiprimitive.composeEventHandlers(props.onEscapeKeyDown, (event)=>{
|
|
673
|
+
// prevent the dropdown from reopening
|
|
674
|
+
// after the escape key has been pressed
|
|
675
|
+
wasEscapeCloseRef.current = true;
|
|
623
676
|
})
|
|
624
677
|
})));
|
|
625
678
|
});
|
|
@@ -675,10 +728,8 @@ const $7f73b938b73b5118$export$ee880b97cc6d44a5 = /*#__PURE__*/ $6jHCS$react.for
|
|
|
675
728
|
['--radix-navigation-menu-viewport-height']: viewportHeight,
|
|
676
729
|
...viewportImplProps.style
|
|
677
730
|
},
|
|
678
|
-
onPointerEnter: $6jHCS$radixuiprimitive.composeEventHandlers(props1.onPointerEnter,
|
|
679
|
-
|
|
680
|
-
}),
|
|
681
|
-
onPointerLeave: $6jHCS$radixuiprimitive.composeEventHandlers(props1.onPointerLeave, $7f73b938b73b5118$var$whenMouse(context.onItemLeave))
|
|
731
|
+
onPointerEnter: $6jHCS$radixuiprimitive.composeEventHandlers(props1.onPointerEnter, context.onContentEnter),
|
|
732
|
+
onPointerLeave: $6jHCS$radixuiprimitive.composeEventHandlers(props1.onPointerLeave, $7f73b938b73b5118$var$whenMouse(context.onContentLeave))
|
|
682
733
|
}), Array.from(viewportContentContext.items).map(([value, { ref: ref , forceMount: forceMount , ...props }])=>{
|
|
683
734
|
const isActive = activeContentValue === value;
|
|
684
735
|
return /*#__PURE__*/ $6jHCS$react.createElement($6jHCS$radixuireactpresence.Presence, {
|