@radix-ui/react-menubar 1.0.0-rc.1
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 +13 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +539 -0
- package/dist/index.js.map +1 -0
- package/dist/index.module.js +498 -0
- package/dist/index.module.js.map +1 -0
- package/package.json +44 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
var $fIWtd$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
|
|
2
|
+
var $fIWtd$react = require("react");
|
|
3
|
+
var $fIWtd$radixuireactcollection = require("@radix-ui/react-collection");
|
|
4
|
+
var $fIWtd$radixuireactdirection = require("@radix-ui/react-direction");
|
|
5
|
+
var $fIWtd$radixuiprimitive = require("@radix-ui/primitive");
|
|
6
|
+
var $fIWtd$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
|
|
7
|
+
var $fIWtd$radixuireactcontext = require("@radix-ui/react-context");
|
|
8
|
+
var $fIWtd$radixuireactid = require("@radix-ui/react-id");
|
|
9
|
+
var $fIWtd$radixuireactmenu = require("@radix-ui/react-menu");
|
|
10
|
+
var $fIWtd$radixuireactrovingfocus = require("@radix-ui/react-roving-focus");
|
|
11
|
+
var $fIWtd$radixuireactprimitive = require("@radix-ui/react-primitive");
|
|
12
|
+
var $fIWtd$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
|
|
13
|
+
|
|
14
|
+
function $parcel$export(e, n, v, s) {
|
|
15
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
16
|
+
}
|
|
17
|
+
function $parcel$interopDefault(a) {
|
|
18
|
+
return a && a.__esModule ? a.default : a;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
$parcel$export(module.exports, "createMenubarScope", () => $f5560139001bae38$export$7a4049d5555b545c);
|
|
22
|
+
$parcel$export(module.exports, "Menubar", () => $f5560139001bae38$export$7d4583da7581e674);
|
|
23
|
+
$parcel$export(module.exports, "MenubarMenu", () => $f5560139001bae38$export$c777b394d551050b);
|
|
24
|
+
$parcel$export(module.exports, "MenubarTrigger", () => $f5560139001bae38$export$df05cd234081ebd5);
|
|
25
|
+
$parcel$export(module.exports, "MenubarPortal", () => $f5560139001bae38$export$a98ed304d621e164);
|
|
26
|
+
$parcel$export(module.exports, "MenubarContent", () => $f5560139001bae38$export$f42a00bc8a46c161);
|
|
27
|
+
$parcel$export(module.exports, "MenubarGroup", () => $f5560139001bae38$export$7669e79198e0f2eb);
|
|
28
|
+
$parcel$export(module.exports, "MenubarLabel", () => $f5560139001bae38$export$39935c5b19a4b4e);
|
|
29
|
+
$parcel$export(module.exports, "MenubarItem", () => $f5560139001bae38$export$92f903c8c91c291c);
|
|
30
|
+
$parcel$export(module.exports, "MenubarCheckboxItem", () => $f5560139001bae38$export$372384eccd27af53);
|
|
31
|
+
$parcel$export(module.exports, "MenubarRadioGroup", () => $f5560139001bae38$export$94dfa2322f330fdb);
|
|
32
|
+
$parcel$export(module.exports, "MenubarRadioItem", () => $f5560139001bae38$export$7d2f467b4a7f68d8);
|
|
33
|
+
$parcel$export(module.exports, "MenubarItemIndicator", () => $f5560139001bae38$export$63e15a0e2af5a57);
|
|
34
|
+
$parcel$export(module.exports, "MenubarSeparator", () => $f5560139001bae38$export$588aef9e7b5183b5);
|
|
35
|
+
$parcel$export(module.exports, "MenubarArrow", () => $f5560139001bae38$export$474b9891f5b9e633);
|
|
36
|
+
$parcel$export(module.exports, "MenubarSubMenu", () => $f5560139001bae38$export$e19edd7963476d53);
|
|
37
|
+
$parcel$export(module.exports, "MenubarSubTrigger", () => $f5560139001bae38$export$1820ea18a1dfed3c);
|
|
38
|
+
$parcel$export(module.exports, "MenubarSubContent", () => $f5560139001bae38$export$1b21e255bb3e4f7f);
|
|
39
|
+
$parcel$export(module.exports, "Root", () => $f5560139001bae38$export$be92b6f5f03c0fe9);
|
|
40
|
+
$parcel$export(module.exports, "Menu", () => $f5560139001bae38$export$d9b273488cd8ce6f);
|
|
41
|
+
$parcel$export(module.exports, "Trigger", () => $f5560139001bae38$export$41fb9f06171c75f4);
|
|
42
|
+
$parcel$export(module.exports, "Portal", () => $f5560139001bae38$export$602eac185826482c);
|
|
43
|
+
$parcel$export(module.exports, "Content", () => $f5560139001bae38$export$7c6e2c02157bb7d2);
|
|
44
|
+
$parcel$export(module.exports, "Group", () => $f5560139001bae38$export$eb2fcfdbd7ba97d4);
|
|
45
|
+
$parcel$export(module.exports, "Label", () => $f5560139001bae38$export$b04be29aa201d4f5);
|
|
46
|
+
$parcel$export(module.exports, "Item", () => $f5560139001bae38$export$6d08773d2e66f8f2);
|
|
47
|
+
$parcel$export(module.exports, "CheckboxItem", () => $f5560139001bae38$export$16ce288f89fa631c);
|
|
48
|
+
$parcel$export(module.exports, "RadioGroup", () => $f5560139001bae38$export$a98f0dcb43a68a25);
|
|
49
|
+
$parcel$export(module.exports, "RadioItem", () => $f5560139001bae38$export$371ab307eab489c0);
|
|
50
|
+
$parcel$export(module.exports, "ItemIndicator", () => $f5560139001bae38$export$c3468e2714d175fa);
|
|
51
|
+
$parcel$export(module.exports, "Separator", () => $f5560139001bae38$export$1ff3c3f08ae963c0);
|
|
52
|
+
$parcel$export(module.exports, "Arrow", () => $f5560139001bae38$export$21b07c8f274aebd5);
|
|
53
|
+
$parcel$export(module.exports, "SubMenu", () => $f5560139001bae38$export$a9c522a6d7beb830);
|
|
54
|
+
$parcel$export(module.exports, "SubTrigger", () => $f5560139001bae38$export$2ea8a7a591ac5eac);
|
|
55
|
+
$parcel$export(module.exports, "SubContent", () => $f5560139001bae38$export$6d4de93b380beddf);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
/* -------------------------------------------------------------------------------------------------
|
|
71
|
+
* Menubar
|
|
72
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$MENUBAR_NAME = 'Menubar';
|
|
73
|
+
const [$f5560139001bae38$var$Collection, $f5560139001bae38$var$useCollection, $f5560139001bae38$var$createCollectionScope] = $fIWtd$radixuireactcollection.createCollection($f5560139001bae38$var$MENUBAR_NAME);
|
|
74
|
+
const [$f5560139001bae38$var$createMenubarContext, $f5560139001bae38$export$7a4049d5555b545c] = $fIWtd$radixuireactcontext.createContextScope($f5560139001bae38$var$MENUBAR_NAME, [
|
|
75
|
+
$f5560139001bae38$var$createCollectionScope,
|
|
76
|
+
$fIWtd$radixuireactrovingfocus.createRovingFocusGroupScope
|
|
77
|
+
]);
|
|
78
|
+
const $f5560139001bae38$var$useMenuScope = $fIWtd$radixuireactmenu.createMenuScope();
|
|
79
|
+
const $f5560139001bae38$var$useRovingFocusGroupScope = $fIWtd$radixuireactrovingfocus.createRovingFocusGroupScope();
|
|
80
|
+
const [$f5560139001bae38$var$MenubarContextProvider, $f5560139001bae38$var$useMenubarContext] = $f5560139001bae38$var$createMenubarContext($f5560139001bae38$var$MENUBAR_NAME);
|
|
81
|
+
const $f5560139001bae38$export$7d4583da7581e674 = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
82
|
+
const { __scopeMenubar: __scopeMenubar , value: valueProp , onValueChange: onValueChange , defaultValue: defaultValue , loop: loop = true , dir: dir , ...menubarProps } = props;
|
|
83
|
+
const direction = $fIWtd$radixuireactdirection.useDirection(dir);
|
|
84
|
+
const rovingFocusGroupScope = $f5560139001bae38$var$useRovingFocusGroupScope(__scopeMenubar);
|
|
85
|
+
const [value1 = '', setValue] = $fIWtd$radixuireactusecontrollablestate.useControllableState({
|
|
86
|
+
prop: valueProp,
|
|
87
|
+
onChange: onValueChange,
|
|
88
|
+
defaultProp: defaultValue
|
|
89
|
+
}); // We need to manage tab stop id manually as `RovingFocusGroup` updates the stop
|
|
90
|
+
// based on focus, and in some situations our triggers won't ever be given focus
|
|
91
|
+
// (e.g. click to open and then outside to close)
|
|
92
|
+
const [currentTabStopId, setCurrentTabStopId] = $fIWtd$react.useState(null);
|
|
93
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($f5560139001bae38$var$MenubarContextProvider, {
|
|
94
|
+
scope: __scopeMenubar,
|
|
95
|
+
value: value1,
|
|
96
|
+
onMenuOpen: $fIWtd$react.useCallback((value)=>{
|
|
97
|
+
setValue(value);
|
|
98
|
+
setCurrentTabStopId(value);
|
|
99
|
+
}, [
|
|
100
|
+
setValue
|
|
101
|
+
]),
|
|
102
|
+
onMenuClose: $fIWtd$react.useCallback(()=>setValue('')
|
|
103
|
+
, [
|
|
104
|
+
setValue
|
|
105
|
+
]),
|
|
106
|
+
onMenuToggle: $fIWtd$react.useCallback((value)=>{
|
|
107
|
+
setValue((prevValue)=>Boolean(prevValue) ? '' : value
|
|
108
|
+
); // `openMenuOpen` and `onMenuToggle` are called exclusively so we
|
|
109
|
+
// need to update the id in either case.
|
|
110
|
+
setCurrentTabStopId(value);
|
|
111
|
+
}, [
|
|
112
|
+
setValue
|
|
113
|
+
]),
|
|
114
|
+
dir: direction,
|
|
115
|
+
loop: loop
|
|
116
|
+
}, /*#__PURE__*/ $fIWtd$react.createElement($f5560139001bae38$var$Collection.Provider, {
|
|
117
|
+
scope: __scopeMenubar
|
|
118
|
+
}, /*#__PURE__*/ $fIWtd$react.createElement($f5560139001bae38$var$Collection.Slot, {
|
|
119
|
+
scope: __scopeMenubar
|
|
120
|
+
}, /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactrovingfocus.Root, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({
|
|
121
|
+
asChild: true
|
|
122
|
+
}, rovingFocusGroupScope, {
|
|
123
|
+
orientation: "horizontal",
|
|
124
|
+
loop: loop,
|
|
125
|
+
dir: direction,
|
|
126
|
+
currentTabStopId: currentTabStopId,
|
|
127
|
+
onCurrentTabStopIdChange: setCurrentTabStopId
|
|
128
|
+
}), /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({
|
|
129
|
+
role: "menubar"
|
|
130
|
+
}, menubarProps, {
|
|
131
|
+
ref: forwardedRef
|
|
132
|
+
}))))));
|
|
133
|
+
});
|
|
134
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$7d4583da7581e674, {
|
|
135
|
+
displayName: $f5560139001bae38$var$MENUBAR_NAME
|
|
136
|
+
});
|
|
137
|
+
/* -------------------------------------------------------------------------------------------------
|
|
138
|
+
* MenubarMenu
|
|
139
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$MENU_NAME = 'MenubarMenu';
|
|
140
|
+
const [$f5560139001bae38$var$MenubarMenuProvider, $f5560139001bae38$var$useMenubarMenuContext] = $f5560139001bae38$var$createMenubarContext($f5560139001bae38$var$MENU_NAME);
|
|
141
|
+
const $f5560139001bae38$export$c777b394d551050b = (props)=>{
|
|
142
|
+
const { __scopeMenubar: __scopeMenubar , value: valueProp , ...menuProps } = props;
|
|
143
|
+
const autoValue = $fIWtd$radixuireactid.useId(); // We need to provide an initial deterministic value as `useId` will return
|
|
144
|
+
// empty string on the first render and we don't want to match our internal "closed" value.
|
|
145
|
+
const value = valueProp || autoValue || 'LEGACY_REACT_AUTO_VALUE';
|
|
146
|
+
const context = $f5560139001bae38$var$useMenubarContext($f5560139001bae38$var$MENU_NAME, __scopeMenubar);
|
|
147
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
148
|
+
const triggerRef = $fIWtd$react.useRef(null);
|
|
149
|
+
const wasKeyboardTriggerOpenRef = $fIWtd$react.useRef(false);
|
|
150
|
+
const open1 = context.value === value;
|
|
151
|
+
$fIWtd$react.useEffect(()=>{
|
|
152
|
+
if (!open1) wasKeyboardTriggerOpenRef.current = false;
|
|
153
|
+
}, [
|
|
154
|
+
open1
|
|
155
|
+
]);
|
|
156
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($f5560139001bae38$var$MenubarMenuProvider, {
|
|
157
|
+
scope: __scopeMenubar,
|
|
158
|
+
value: value,
|
|
159
|
+
triggerId: $fIWtd$radixuireactid.useId(),
|
|
160
|
+
triggerRef: triggerRef,
|
|
161
|
+
contentId: $fIWtd$radixuireactid.useId(),
|
|
162
|
+
wasKeyboardTriggerOpenRef: wasKeyboardTriggerOpenRef
|
|
163
|
+
}, /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.Root, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, {
|
|
164
|
+
open: open1,
|
|
165
|
+
onOpenChange: (open)=>{
|
|
166
|
+
// Menu only calls `onOpenChange` when dismissing so we
|
|
167
|
+
// want to close our MenuBar based on the same events.
|
|
168
|
+
if (!open) context.onMenuClose();
|
|
169
|
+
},
|
|
170
|
+
modal: false,
|
|
171
|
+
dir: context.dir
|
|
172
|
+
}, menuProps)));
|
|
173
|
+
};
|
|
174
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$c777b394d551050b, {
|
|
175
|
+
displayName: $f5560139001bae38$var$MENU_NAME
|
|
176
|
+
});
|
|
177
|
+
/* -------------------------------------------------------------------------------------------------
|
|
178
|
+
* MenubarTrigger
|
|
179
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$TRIGGER_NAME = 'MenubarTrigger';
|
|
180
|
+
const $f5560139001bae38$export$df05cd234081ebd5 = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
181
|
+
const { __scopeMenubar: __scopeMenubar , disabled: disabled = false , ...triggerProps } = props;
|
|
182
|
+
const rovingFocusGroupScope = $f5560139001bae38$var$useRovingFocusGroupScope(__scopeMenubar);
|
|
183
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
184
|
+
const context = $f5560139001bae38$var$useMenubarContext($f5560139001bae38$var$TRIGGER_NAME, __scopeMenubar);
|
|
185
|
+
const menuContext = $f5560139001bae38$var$useMenubarMenuContext($f5560139001bae38$var$TRIGGER_NAME, __scopeMenubar);
|
|
186
|
+
const ref = $fIWtd$react.useRef(null);
|
|
187
|
+
const composedRefs = $fIWtd$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref, menuContext.triggerRef);
|
|
188
|
+
const [isFocused, setIsFocused] = $fIWtd$react.useState(false);
|
|
189
|
+
const open = context.value === menuContext.value;
|
|
190
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($f5560139001bae38$var$Collection.ItemSlot, {
|
|
191
|
+
scope: __scopeMenubar,
|
|
192
|
+
value: menuContext.value,
|
|
193
|
+
disabled: disabled
|
|
194
|
+
}, /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactrovingfocus.Item, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({
|
|
195
|
+
asChild: true
|
|
196
|
+
}, rovingFocusGroupScope, {
|
|
197
|
+
focusable: !disabled,
|
|
198
|
+
tabStopId: menuContext.value
|
|
199
|
+
}), /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.Anchor, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({
|
|
200
|
+
asChild: true
|
|
201
|
+
}, menuScope), /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({
|
|
202
|
+
type: "button",
|
|
203
|
+
role: "menuitem",
|
|
204
|
+
id: menuContext.triggerId,
|
|
205
|
+
"aria-haspopup": "menu",
|
|
206
|
+
"aria-expanded": open,
|
|
207
|
+
"aria-controls": open ? menuContext.contentId : undefined,
|
|
208
|
+
"data-highlighted": isFocused ? '' : undefined,
|
|
209
|
+
"data-state": open ? 'open' : 'closed',
|
|
210
|
+
"data-disabled": disabled ? '' : undefined,
|
|
211
|
+
disabled: disabled
|
|
212
|
+
}, triggerProps, {
|
|
213
|
+
ref: composedRefs,
|
|
214
|
+
onPointerDown: $fIWtd$radixuiprimitive.composeEventHandlers(props.onPointerDown, (event)=>{
|
|
215
|
+
// only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
|
|
216
|
+
// but not when the control key is pressed (avoiding MacOS right click)
|
|
217
|
+
if (!disabled && event.button === 0 && event.ctrlKey === false) {
|
|
218
|
+
context.onMenuOpen(menuContext.value); // prevent trigger focusing when opening
|
|
219
|
+
// this allows the content to be given focus without competition
|
|
220
|
+
if (!open) event.preventDefault();
|
|
221
|
+
}
|
|
222
|
+
}),
|
|
223
|
+
onPointerEnter: $fIWtd$radixuiprimitive.composeEventHandlers(props.onPointerEnter, ()=>{
|
|
224
|
+
const menubarOpen = Boolean(context.value);
|
|
225
|
+
if (menubarOpen && !open) {
|
|
226
|
+
var _ref$current;
|
|
227
|
+
context.onMenuOpen(menuContext.value);
|
|
228
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
|
|
229
|
+
}
|
|
230
|
+
}),
|
|
231
|
+
onKeyDown: $fIWtd$radixuiprimitive.composeEventHandlers(props.onKeyDown, (event)=>{
|
|
232
|
+
if (disabled) return;
|
|
233
|
+
if ([
|
|
234
|
+
'Enter',
|
|
235
|
+
' '
|
|
236
|
+
].includes(event.key)) context.onMenuToggle(menuContext.value);
|
|
237
|
+
if (event.key === 'ArrowDown') context.onMenuOpen(menuContext.value); // prevent keydown from scrolling window / first focused item to execute
|
|
238
|
+
// that keydown (inadvertently closing the menu)
|
|
239
|
+
if ([
|
|
240
|
+
'Enter',
|
|
241
|
+
' ',
|
|
242
|
+
'ArrowDown'
|
|
243
|
+
].includes(event.key)) {
|
|
244
|
+
menuContext.wasKeyboardTriggerOpenRef.current = true;
|
|
245
|
+
event.preventDefault();
|
|
246
|
+
}
|
|
247
|
+
}),
|
|
248
|
+
onFocus: $fIWtd$radixuiprimitive.composeEventHandlers(props.onFocus, ()=>setIsFocused(true)
|
|
249
|
+
),
|
|
250
|
+
onBlur: $fIWtd$radixuiprimitive.composeEventHandlers(props.onBlur, ()=>setIsFocused(false)
|
|
251
|
+
)
|
|
252
|
+
})))));
|
|
253
|
+
});
|
|
254
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$df05cd234081ebd5, {
|
|
255
|
+
displayName: $f5560139001bae38$var$TRIGGER_NAME
|
|
256
|
+
});
|
|
257
|
+
/* -------------------------------------------------------------------------------------------------
|
|
258
|
+
* MenubarPortal
|
|
259
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$PORTAL_NAME = 'MenubarPortal';
|
|
260
|
+
const $f5560139001bae38$export$a98ed304d621e164 = (props)=>{
|
|
261
|
+
const { __scopeMenubar: __scopeMenubar , ...portalProps } = props;
|
|
262
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
263
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.Portal, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, portalProps));
|
|
264
|
+
};
|
|
265
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$a98ed304d621e164, {
|
|
266
|
+
displayName: $f5560139001bae38$var$PORTAL_NAME
|
|
267
|
+
});
|
|
268
|
+
/* -------------------------------------------------------------------------------------------------
|
|
269
|
+
* MenubarContent
|
|
270
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$CONTENT_NAME = 'MenubarContent';
|
|
271
|
+
const $f5560139001bae38$export$f42a00bc8a46c161 = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
272
|
+
const { __scopeMenubar: __scopeMenubar , align: align = 'start' , ...contentProps } = props;
|
|
273
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
274
|
+
const context = $f5560139001bae38$var$useMenubarContext($f5560139001bae38$var$CONTENT_NAME, __scopeMenubar);
|
|
275
|
+
const menuContext = $f5560139001bae38$var$useMenubarMenuContext($f5560139001bae38$var$CONTENT_NAME, __scopeMenubar);
|
|
276
|
+
const getItems = $f5560139001bae38$var$useCollection(__scopeMenubar);
|
|
277
|
+
const hasInteractedOutsideRef = $fIWtd$react.useRef(false);
|
|
278
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.Content, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({
|
|
279
|
+
id: menuContext.contentId,
|
|
280
|
+
"aria-labelledby": menuContext.triggerId,
|
|
281
|
+
"data-radix-menubar-content": ""
|
|
282
|
+
}, menuScope, contentProps, {
|
|
283
|
+
ref: forwardedRef,
|
|
284
|
+
align: align,
|
|
285
|
+
onCloseAutoFocus: $fIWtd$radixuiprimitive.composeEventHandlers(props.onCloseAutoFocus, (event)=>{
|
|
286
|
+
const menubarOpen = Boolean(context.value);
|
|
287
|
+
if (!menubarOpen && !hasInteractedOutsideRef.current) {
|
|
288
|
+
var _menuContext$triggerR;
|
|
289
|
+
(_menuContext$triggerR = menuContext.triggerRef.current) === null || _menuContext$triggerR === void 0 || _menuContext$triggerR.focus();
|
|
290
|
+
}
|
|
291
|
+
hasInteractedOutsideRef.current = false; // Always prevent auto focus because we either focus manually or want user agent focus
|
|
292
|
+
event.preventDefault();
|
|
293
|
+
}),
|
|
294
|
+
onFocusOutside: $fIWtd$radixuiprimitive.composeEventHandlers(props.onFocusOutside, (event)=>{
|
|
295
|
+
const target = event.target;
|
|
296
|
+
const isMenubarTrigger = getItems().some((item)=>{
|
|
297
|
+
var _item$ref$current;
|
|
298
|
+
return (_item$ref$current = item.ref.current) === null || _item$ref$current === void 0 ? void 0 : _item$ref$current.contains(target);
|
|
299
|
+
});
|
|
300
|
+
if (isMenubarTrigger) event.preventDefault();
|
|
301
|
+
}),
|
|
302
|
+
onInteractOutside: $fIWtd$radixuiprimitive.composeEventHandlers(props.onInteractOutside, ()=>{
|
|
303
|
+
hasInteractedOutsideRef.current = true;
|
|
304
|
+
}),
|
|
305
|
+
onEntryFocus: (event)=>{
|
|
306
|
+
if (!menuContext.wasKeyboardTriggerOpenRef.current) event.preventDefault();
|
|
307
|
+
},
|
|
308
|
+
onKeyDown: $fIWtd$radixuiprimitive.composeEventHandlers(props.onKeyDown, (event)=>{
|
|
309
|
+
if ([
|
|
310
|
+
'ArrowRight',
|
|
311
|
+
'ArrowLeft'
|
|
312
|
+
].includes(event.key)) {
|
|
313
|
+
const target = event.target;
|
|
314
|
+
const targetIsSubTrigger = target.hasAttribute('data-radix-menubar-subtrigger');
|
|
315
|
+
const isKeyDownInsideSubMenu = target.closest('[data-radix-menubar-content]') !== event.currentTarget;
|
|
316
|
+
const prevMenuKey = context.dir === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
|
|
317
|
+
const isPrevKey = prevMenuKey === event.key;
|
|
318
|
+
const isNextKey = !isPrevKey; // Prevent navigation when we're opening a submenu
|
|
319
|
+
if (isNextKey && targetIsSubTrigger) return; // or we're inside a submenu and are moving backwards to close it
|
|
320
|
+
if (isKeyDownInsideSubMenu && isPrevKey) return;
|
|
321
|
+
const items = getItems().filter((item)=>!item.disabled
|
|
322
|
+
);
|
|
323
|
+
let candidateValues = items.map((item)=>item.value
|
|
324
|
+
);
|
|
325
|
+
if (isPrevKey) candidateValues.reverse();
|
|
326
|
+
const currentIndex = candidateValues.indexOf(menuContext.value);
|
|
327
|
+
candidateValues = context.loop ? $f5560139001bae38$var$wrapArray(candidateValues, currentIndex + 1) : candidateValues.slice(currentIndex + 1);
|
|
328
|
+
const [nextValue] = candidateValues;
|
|
329
|
+
if (nextValue) context.onMenuOpen(nextValue);
|
|
330
|
+
}
|
|
331
|
+
}, {
|
|
332
|
+
checkForDefaultPrevented: false
|
|
333
|
+
}),
|
|
334
|
+
style: {
|
|
335
|
+
...props.style,
|
|
336
|
+
// re-namespace exposed content custom property
|
|
337
|
+
['--radix-menubar-content-transform-origin']: 'var(--radix-popper-transform-origin)'
|
|
338
|
+
}
|
|
339
|
+
}));
|
|
340
|
+
});
|
|
341
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$f42a00bc8a46c161, {
|
|
342
|
+
displayName: $f5560139001bae38$var$CONTENT_NAME
|
|
343
|
+
});
|
|
344
|
+
/* -------------------------------------------------------------------------------------------------
|
|
345
|
+
* MenubarGroup
|
|
346
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$GROUP_NAME = 'MenubarGroup';
|
|
347
|
+
const $f5560139001bae38$export$7669e79198e0f2eb = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
348
|
+
const { __scopeMenubar: __scopeMenubar , ...groupProps } = props;
|
|
349
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
350
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.Group, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, groupProps, {
|
|
351
|
+
ref: forwardedRef
|
|
352
|
+
}));
|
|
353
|
+
});
|
|
354
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$7669e79198e0f2eb, {
|
|
355
|
+
displayName: $f5560139001bae38$var$GROUP_NAME
|
|
356
|
+
});
|
|
357
|
+
/* -------------------------------------------------------------------------------------------------
|
|
358
|
+
* MenubarLabel
|
|
359
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$LABEL_NAME = 'MenubarLabel';
|
|
360
|
+
const $f5560139001bae38$export$39935c5b19a4b4e = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
361
|
+
const { __scopeMenubar: __scopeMenubar , ...labelProps } = props;
|
|
362
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
363
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.Label, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, labelProps, {
|
|
364
|
+
ref: forwardedRef
|
|
365
|
+
}));
|
|
366
|
+
});
|
|
367
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$39935c5b19a4b4e, {
|
|
368
|
+
displayName: $f5560139001bae38$var$LABEL_NAME
|
|
369
|
+
});
|
|
370
|
+
/* -------------------------------------------------------------------------------------------------
|
|
371
|
+
* MenubarItem
|
|
372
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$ITEM_NAME = 'MenubarItem';
|
|
373
|
+
const $f5560139001bae38$export$92f903c8c91c291c = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
374
|
+
const { __scopeMenubar: __scopeMenubar , ...itemProps } = props;
|
|
375
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
376
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.Item, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, itemProps, {
|
|
377
|
+
ref: forwardedRef
|
|
378
|
+
}));
|
|
379
|
+
});
|
|
380
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$92f903c8c91c291c, {
|
|
381
|
+
displayName: $f5560139001bae38$var$ITEM_NAME
|
|
382
|
+
});
|
|
383
|
+
/* -------------------------------------------------------------------------------------------------
|
|
384
|
+
* MenubarCheckboxItem
|
|
385
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$CHECKBOX_ITEM_NAME = 'MenubarCheckboxItem';
|
|
386
|
+
const $f5560139001bae38$export$372384eccd27af53 = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
387
|
+
const { __scopeMenubar: __scopeMenubar , ...checkboxItemProps } = props;
|
|
388
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
389
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.CheckboxItem, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, checkboxItemProps, {
|
|
390
|
+
ref: forwardedRef
|
|
391
|
+
}));
|
|
392
|
+
});
|
|
393
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$372384eccd27af53, {
|
|
394
|
+
displayName: $f5560139001bae38$var$CHECKBOX_ITEM_NAME
|
|
395
|
+
});
|
|
396
|
+
/* -------------------------------------------------------------------------------------------------
|
|
397
|
+
* MenubarRadioGroup
|
|
398
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$RADIO_GROUP_NAME = 'MenubarRadioGroup';
|
|
399
|
+
const $f5560139001bae38$export$94dfa2322f330fdb = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
400
|
+
const { __scopeMenubar: __scopeMenubar , ...radioGroupProps } = props;
|
|
401
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
402
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.RadioGroup, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, radioGroupProps, {
|
|
403
|
+
ref: forwardedRef
|
|
404
|
+
}));
|
|
405
|
+
});
|
|
406
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$94dfa2322f330fdb, {
|
|
407
|
+
displayName: $f5560139001bae38$var$RADIO_GROUP_NAME
|
|
408
|
+
});
|
|
409
|
+
/* -------------------------------------------------------------------------------------------------
|
|
410
|
+
* MenubarRadioItem
|
|
411
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$RADIO_ITEM_NAME = 'MenubarRadioItem';
|
|
412
|
+
const $f5560139001bae38$export$7d2f467b4a7f68d8 = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
413
|
+
const { __scopeMenubar: __scopeMenubar , ...radioItemProps } = props;
|
|
414
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
415
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.RadioItem, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, radioItemProps, {
|
|
416
|
+
ref: forwardedRef
|
|
417
|
+
}));
|
|
418
|
+
});
|
|
419
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$7d2f467b4a7f68d8, {
|
|
420
|
+
displayName: $f5560139001bae38$var$RADIO_ITEM_NAME
|
|
421
|
+
});
|
|
422
|
+
/* -------------------------------------------------------------------------------------------------
|
|
423
|
+
* MenubarItemIndicator
|
|
424
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$INDICATOR_NAME = 'MenubarItemIndicator';
|
|
425
|
+
const $f5560139001bae38$export$63e15a0e2af5a57 = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
426
|
+
const { __scopeMenubar: __scopeMenubar , ...itemIndicatorProps } = props;
|
|
427
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
428
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.ItemIndicator, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, itemIndicatorProps, {
|
|
429
|
+
ref: forwardedRef
|
|
430
|
+
}));
|
|
431
|
+
});
|
|
432
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$63e15a0e2af5a57, {
|
|
433
|
+
displayName: $f5560139001bae38$var$INDICATOR_NAME
|
|
434
|
+
});
|
|
435
|
+
/* -------------------------------------------------------------------------------------------------
|
|
436
|
+
* MenubarSeparator
|
|
437
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$SEPARATOR_NAME = 'MenubarSeparator';
|
|
438
|
+
const $f5560139001bae38$export$588aef9e7b5183b5 = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
439
|
+
const { __scopeMenubar: __scopeMenubar , ...separatorProps } = props;
|
|
440
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
441
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.Separator, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, separatorProps, {
|
|
442
|
+
ref: forwardedRef
|
|
443
|
+
}));
|
|
444
|
+
});
|
|
445
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$588aef9e7b5183b5, {
|
|
446
|
+
displayName: $f5560139001bae38$var$SEPARATOR_NAME
|
|
447
|
+
});
|
|
448
|
+
/* -------------------------------------------------------------------------------------------------
|
|
449
|
+
* MenubarArrow
|
|
450
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$ARROW_NAME = 'MenubarArrow';
|
|
451
|
+
const $f5560139001bae38$export$474b9891f5b9e633 = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
452
|
+
const { __scopeMenubar: __scopeMenubar , ...arrowProps } = props;
|
|
453
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
454
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.Arrow, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, arrowProps, {
|
|
455
|
+
ref: forwardedRef
|
|
456
|
+
}));
|
|
457
|
+
});
|
|
458
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$474b9891f5b9e633, {
|
|
459
|
+
displayName: $f5560139001bae38$var$ARROW_NAME
|
|
460
|
+
});
|
|
461
|
+
/* -------------------------------------------------------------------------------------------------
|
|
462
|
+
* MenubarSubMenu
|
|
463
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$export$e19edd7963476d53 = (props)=>{
|
|
464
|
+
const { __scopeMenubar: __scopeMenubar , children: children , open: openProp , onOpenChange: onOpenChange , defaultOpen: defaultOpen } = props;
|
|
465
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
466
|
+
const [open = false, setOpen] = $fIWtd$radixuireactusecontrollablestate.useControllableState({
|
|
467
|
+
prop: openProp,
|
|
468
|
+
defaultProp: defaultOpen,
|
|
469
|
+
onChange: onOpenChange
|
|
470
|
+
});
|
|
471
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.Sub, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, {
|
|
472
|
+
open: open,
|
|
473
|
+
onOpenChange: setOpen
|
|
474
|
+
}), children);
|
|
475
|
+
};
|
|
476
|
+
/* -------------------------------------------------------------------------------------------------
|
|
477
|
+
* MenubarSubTrigger
|
|
478
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$SUB_TRIGGER_NAME = 'MenubarSubTrigger';
|
|
479
|
+
const $f5560139001bae38$export$1820ea18a1dfed3c = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
480
|
+
const { __scopeMenubar: __scopeMenubar , ...subTriggerProps } = props;
|
|
481
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
482
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.SubTrigger, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({
|
|
483
|
+
"data-radix-menubar-subtrigger": ""
|
|
484
|
+
}, menuScope, subTriggerProps, {
|
|
485
|
+
ref: forwardedRef
|
|
486
|
+
}));
|
|
487
|
+
});
|
|
488
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$1820ea18a1dfed3c, {
|
|
489
|
+
displayName: $f5560139001bae38$var$SUB_TRIGGER_NAME
|
|
490
|
+
});
|
|
491
|
+
/* -------------------------------------------------------------------------------------------------
|
|
492
|
+
* MenubarSubContent
|
|
493
|
+
* -----------------------------------------------------------------------------------------------*/ const $f5560139001bae38$var$SUB_CONTENT_NAME = 'MenubarSubContent';
|
|
494
|
+
const $f5560139001bae38$export$1b21e255bb3e4f7f = /*#__PURE__*/ $fIWtd$react.forwardRef((props, forwardedRef)=>{
|
|
495
|
+
const { __scopeMenubar: __scopeMenubar , ...subContentProps } = props;
|
|
496
|
+
const menuScope = $f5560139001bae38$var$useMenuScope(__scopeMenubar);
|
|
497
|
+
return /*#__PURE__*/ $fIWtd$react.createElement($fIWtd$radixuireactmenu.SubContent, ($parcel$interopDefault($fIWtd$babelruntimehelpersextends))({}, menuScope, {
|
|
498
|
+
"data-radix-menubar-content": ""
|
|
499
|
+
}, subContentProps, {
|
|
500
|
+
ref: forwardedRef,
|
|
501
|
+
style: {
|
|
502
|
+
...props.style,
|
|
503
|
+
// re-namespace exposed content custom property
|
|
504
|
+
['--radix-menubar-content-transform-origin']: 'var(--radix-popper-transform-origin)'
|
|
505
|
+
}
|
|
506
|
+
}));
|
|
507
|
+
});
|
|
508
|
+
/*#__PURE__*/ Object.assign($f5560139001bae38$export$1b21e255bb3e4f7f, {
|
|
509
|
+
displayName: $f5560139001bae38$var$SUB_CONTENT_NAME
|
|
510
|
+
});
|
|
511
|
+
/* -----------------------------------------------------------------------------------------------*/ /**
|
|
512
|
+
* Wraps an array around itself at a given start index
|
|
513
|
+
* Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
|
|
514
|
+
*/ function $f5560139001bae38$var$wrapArray(array, startIndex) {
|
|
515
|
+
return array.map((_, index)=>array[(startIndex + index) % array.length]
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
const $f5560139001bae38$export$be92b6f5f03c0fe9 = $f5560139001bae38$export$7d4583da7581e674;
|
|
519
|
+
const $f5560139001bae38$export$d9b273488cd8ce6f = $f5560139001bae38$export$c777b394d551050b;
|
|
520
|
+
const $f5560139001bae38$export$41fb9f06171c75f4 = $f5560139001bae38$export$df05cd234081ebd5;
|
|
521
|
+
const $f5560139001bae38$export$602eac185826482c = $f5560139001bae38$export$a98ed304d621e164;
|
|
522
|
+
const $f5560139001bae38$export$7c6e2c02157bb7d2 = $f5560139001bae38$export$f42a00bc8a46c161;
|
|
523
|
+
const $f5560139001bae38$export$eb2fcfdbd7ba97d4 = $f5560139001bae38$export$7669e79198e0f2eb;
|
|
524
|
+
const $f5560139001bae38$export$b04be29aa201d4f5 = $f5560139001bae38$export$39935c5b19a4b4e;
|
|
525
|
+
const $f5560139001bae38$export$6d08773d2e66f8f2 = $f5560139001bae38$export$92f903c8c91c291c;
|
|
526
|
+
const $f5560139001bae38$export$16ce288f89fa631c = $f5560139001bae38$export$372384eccd27af53;
|
|
527
|
+
const $f5560139001bae38$export$a98f0dcb43a68a25 = $f5560139001bae38$export$94dfa2322f330fdb;
|
|
528
|
+
const $f5560139001bae38$export$371ab307eab489c0 = $f5560139001bae38$export$7d2f467b4a7f68d8;
|
|
529
|
+
const $f5560139001bae38$export$c3468e2714d175fa = $f5560139001bae38$export$63e15a0e2af5a57;
|
|
530
|
+
const $f5560139001bae38$export$1ff3c3f08ae963c0 = $f5560139001bae38$export$588aef9e7b5183b5;
|
|
531
|
+
const $f5560139001bae38$export$21b07c8f274aebd5 = $f5560139001bae38$export$474b9891f5b9e633;
|
|
532
|
+
const $f5560139001bae38$export$a9c522a6d7beb830 = $f5560139001bae38$export$e19edd7963476d53;
|
|
533
|
+
const $f5560139001bae38$export$2ea8a7a591ac5eac = $f5560139001bae38$export$1820ea18a1dfed3c;
|
|
534
|
+
const $f5560139001bae38$export$6d4de93b380beddf = $f5560139001bae38$export$1b21e255bb3e4f7f;
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
//# sourceMappingURL=index.js.map
|