@octanejs/radix 0.1.31 → 0.1.33
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/cjs/AccessibleIcon.cjs +56 -0
- package/dist/cjs/Accordion.cjs +272 -0
- package/dist/cjs/AlertDialog.cjs +144 -0
- package/dist/cjs/Arrow.cjs +43 -0
- package/dist/cjs/AspectRatio.cjs +56 -0
- package/dist/cjs/Avatar.cjs +150 -0
- package/dist/cjs/Checkbox.cjs +281 -0
- package/dist/cjs/Collapsible.cjs +176 -0
- package/dist/cjs/ContextMenu.cjs +315 -0
- package/dist/cjs/Dialog.cjs +291 -0
- package/dist/cjs/DismissableLayer.cjs +382 -0
- package/dist/cjs/DropdownMenu.cjs +296 -0
- package/dist/cjs/FocusScope.cjs +257 -0
- package/dist/cjs/Form.cjs +537 -0
- package/dist/cjs/HoverCard.cjs +309 -0
- package/dist/cjs/Label.cjs +42 -0
- package/dist/cjs/Menu.cjs +925 -0
- package/dist/cjs/Menubar.cjs +475 -0
- package/dist/cjs/NavigationMenu.cjs +942 -0
- package/dist/cjs/OneTimePasswordField.cjs +729 -0
- package/dist/cjs/PasswordToggleField.cjs +377 -0
- package/dist/cjs/Popover.cjs +340 -0
- package/dist/cjs/Popper.cjs +368 -0
- package/dist/cjs/Portal.cjs +40 -0
- package/dist/cjs/Presence.cjs +183 -0
- package/dist/cjs/Primitive.cjs +63 -0
- package/dist/cjs/Progress.cjs +111 -0
- package/dist/cjs/Radio.cjs +240 -0
- package/dist/cjs/RadioGroup.cjs +216 -0
- package/dist/cjs/RovingFocusGroup.cjs +253 -0
- package/dist/cjs/ScrollArea.cjs +828 -0
- package/dist/cjs/Select.cjs +1429 -0
- package/dist/cjs/Separator.cjs +51 -0
- package/dist/cjs/Slider.cjs +634 -0
- package/dist/cjs/Slot.cjs +97 -0
- package/dist/cjs/Switch.cjs +253 -0
- package/dist/cjs/Tabs.cjs +195 -0
- package/dist/cjs/Toast.cjs +733 -0
- package/dist/cjs/Toggle.cjs +54 -0
- package/dist/cjs/ToggleGroup.cjs +174 -0
- package/dist/cjs/Toolbar.cjs +165 -0
- package/dist/cjs/Tooltip.cjs +628 -0
- package/dist/cjs/VisuallyHidden.cjs +52 -0
- package/dist/cjs/collection.cjs +95 -0
- package/dist/cjs/compose-event-handlers.cjs +35 -0
- package/dist/cjs/compose-refs.cjs +68 -0
- package/dist/cjs/context.cjs +96 -0
- package/dist/cjs/direction.cjs +41 -0
- package/dist/cjs/focus-guards.cjs +76 -0
- package/dist/cjs/index.cjs +174 -0
- package/dist/cjs/internal.cjs +51 -0
- package/dist/cjs/scroll-lock.cjs +67 -0
- package/dist/cjs/use-callback-ref.cjs +47 -0
- package/dist/cjs/use-effect-event.cjs +52 -0
- package/dist/cjs/use-is-hydrated.cjs +43 -0
- package/dist/cjs/use-previous.cjs +47 -0
- package/dist/cjs/use-size.cjs +69 -0
- package/dist/cjs/useControllableState.cjs +80 -0
- package/dist/cjs/useId.cjs +36 -0
- package/package.json +14 -7
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Menubar_exports = {};
|
|
30
|
+
__export(Menubar_exports, {
|
|
31
|
+
Arrow: () => Arrow,
|
|
32
|
+
CheckboxItem: () => CheckboxItem,
|
|
33
|
+
Content: () => Content,
|
|
34
|
+
Group: () => Group,
|
|
35
|
+
Item: () => Item,
|
|
36
|
+
ItemIndicator: () => ItemIndicator,
|
|
37
|
+
Label: () => Label,
|
|
38
|
+
Menu: () => Menu,
|
|
39
|
+
Menubar: () => Root,
|
|
40
|
+
MenubarArrow: () => Arrow,
|
|
41
|
+
MenubarCheckboxItem: () => CheckboxItem,
|
|
42
|
+
MenubarContent: () => Content,
|
|
43
|
+
MenubarGroup: () => Group,
|
|
44
|
+
MenubarItem: () => Item,
|
|
45
|
+
MenubarItemIndicator: () => ItemIndicator,
|
|
46
|
+
MenubarLabel: () => Label,
|
|
47
|
+
MenubarMenu: () => Menu,
|
|
48
|
+
MenubarPortal: () => Portal,
|
|
49
|
+
MenubarRadioGroup: () => RadioGroup,
|
|
50
|
+
MenubarRadioItem: () => RadioItem,
|
|
51
|
+
MenubarSeparator: () => Separator,
|
|
52
|
+
MenubarSub: () => Sub,
|
|
53
|
+
MenubarSubContent: () => SubContent,
|
|
54
|
+
MenubarSubTrigger: () => SubTrigger,
|
|
55
|
+
MenubarTrigger: () => Trigger,
|
|
56
|
+
Portal: () => Portal,
|
|
57
|
+
RadioGroup: () => RadioGroup,
|
|
58
|
+
RadioItem: () => RadioItem,
|
|
59
|
+
Root: () => Root,
|
|
60
|
+
Separator: () => Separator,
|
|
61
|
+
Sub: () => Sub,
|
|
62
|
+
SubContent: () => SubContent,
|
|
63
|
+
SubTrigger: () => SubTrigger,
|
|
64
|
+
Trigger: () => Trigger,
|
|
65
|
+
createMenubarScope: () => createMenubarScope
|
|
66
|
+
});
|
|
67
|
+
module.exports = __toCommonJS(Menubar_exports);
|
|
68
|
+
var import_octane = require("octane");
|
|
69
|
+
var import_collection = require("./collection.cjs");
|
|
70
|
+
var import_compose_event_handlers = require("./compose-event-handlers.cjs");
|
|
71
|
+
var import_compose_refs = require("./compose-refs.cjs");
|
|
72
|
+
var import_context = require("./context.cjs");
|
|
73
|
+
var import_direction = require("./direction.cjs");
|
|
74
|
+
var import_internal = require("./internal.cjs");
|
|
75
|
+
var MenuPrimitive = __toESM(require("./Menu.cjs"), 1);
|
|
76
|
+
var import_Menu = require("./Menu.cjs");
|
|
77
|
+
var import_Primitive = require("./Primitive.cjs");
|
|
78
|
+
var RovingFocusGroup = __toESM(require("./RovingFocusGroup.cjs"), 1);
|
|
79
|
+
var import_RovingFocusGroup = require("./RovingFocusGroup.cjs");
|
|
80
|
+
var import_useControllableState = require("./useControllableState.cjs");
|
|
81
|
+
var import_useId = require("./useId.cjs");
|
|
82
|
+
const MENUBAR_NAME = "Menubar";
|
|
83
|
+
const [Collection, useCollection, createCollectionScope] = (0, import_collection.createCollection)(MENUBAR_NAME);
|
|
84
|
+
const [createMenubarContext, createMenubarScope] = (0, import_context.createContextScope)(MENUBAR_NAME, [
|
|
85
|
+
createCollectionScope,
|
|
86
|
+
import_RovingFocusGroup.createRovingFocusGroupScope
|
|
87
|
+
]);
|
|
88
|
+
const useMenuScope = (0, import_Menu.createMenuScope)();
|
|
89
|
+
const useRovingFocusGroupScope = (0, import_RovingFocusGroup.createRovingFocusGroupScope)();
|
|
90
|
+
const [MenubarContextProvider, useMenubarContext] = createMenubarContext(MENUBAR_NAME);
|
|
91
|
+
function Root(props) {
|
|
92
|
+
const slot = (0, import_internal.S)("Menubar.Root");
|
|
93
|
+
const {
|
|
94
|
+
__scopeMenubar,
|
|
95
|
+
value: valueProp,
|
|
96
|
+
onValueChange,
|
|
97
|
+
defaultValue,
|
|
98
|
+
loop = true,
|
|
99
|
+
dir,
|
|
100
|
+
ref: forwardedRef,
|
|
101
|
+
...menubarProps
|
|
102
|
+
} = props ?? {};
|
|
103
|
+
const direction = (0, import_direction.useDirection)(dir);
|
|
104
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "rfs"));
|
|
105
|
+
const [value, setValue] = (0, import_useControllableState.useControllableState)(
|
|
106
|
+
{ prop: valueProp, onChange: onValueChange, defaultProp: defaultValue ?? "" },
|
|
107
|
+
(0, import_internal.subSlot)(slot, "value")
|
|
108
|
+
);
|
|
109
|
+
const [currentTabStopId, setCurrentTabStopId] = (0, import_octane.useState)(
|
|
110
|
+
null,
|
|
111
|
+
(0, import_internal.subSlot)(slot, "tabStop")
|
|
112
|
+
);
|
|
113
|
+
return (0, import_octane.createElement)(MenubarContextProvider, {
|
|
114
|
+
scope: __scopeMenubar,
|
|
115
|
+
value,
|
|
116
|
+
onMenuOpen: (0, import_octane.useCallback)(
|
|
117
|
+
(value2) => {
|
|
118
|
+
setValue(value2);
|
|
119
|
+
setCurrentTabStopId(value2);
|
|
120
|
+
},
|
|
121
|
+
[setValue],
|
|
122
|
+
(0, import_internal.subSlot)(slot, "open")
|
|
123
|
+
),
|
|
124
|
+
onMenuClose: (0, import_octane.useCallback)(() => setValue(""), [setValue], (0, import_internal.subSlot)(slot, "close")),
|
|
125
|
+
onMenuToggle: (0, import_octane.useCallback)(
|
|
126
|
+
(value2) => {
|
|
127
|
+
setValue((prevValue) => prevValue ? "" : value2);
|
|
128
|
+
setCurrentTabStopId(value2);
|
|
129
|
+
},
|
|
130
|
+
[setValue],
|
|
131
|
+
(0, import_internal.subSlot)(slot, "toggle")
|
|
132
|
+
),
|
|
133
|
+
dir: direction,
|
|
134
|
+
loop,
|
|
135
|
+
children: (0, import_octane.createElement)(Collection.Provider, {
|
|
136
|
+
scope: __scopeMenubar,
|
|
137
|
+
children: (0, import_octane.createElement)(Collection.Slot, {
|
|
138
|
+
scope: __scopeMenubar,
|
|
139
|
+
children: (0, import_octane.createElement)(RovingFocusGroup.Root, {
|
|
140
|
+
asChild: true,
|
|
141
|
+
...rovingFocusGroupScope,
|
|
142
|
+
orientation: "horizontal",
|
|
143
|
+
loop,
|
|
144
|
+
dir: direction,
|
|
145
|
+
currentTabStopId,
|
|
146
|
+
onCurrentTabStopIdChange: setCurrentTabStopId,
|
|
147
|
+
children: (0, import_octane.createElement)(import_Primitive.Primitive.div, {
|
|
148
|
+
role: "menubar",
|
|
149
|
+
...menubarProps,
|
|
150
|
+
ref: forwardedRef
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const MENU_NAME = "MenubarMenu";
|
|
158
|
+
const [MenubarMenuProvider, useMenubarMenuContext] = createMenubarContext(MENU_NAME);
|
|
159
|
+
function Menu(props) {
|
|
160
|
+
const slot = (0, import_internal.S)("Menubar.Menu");
|
|
161
|
+
const { __scopeMenubar, value: valueProp, ...menuProps } = props ?? {};
|
|
162
|
+
const autoValue = (0, import_useId.useId)((0, import_internal.subSlot)(slot, "autoValue"));
|
|
163
|
+
const value = valueProp || autoValue || "LEGACY_REACT_AUTO_VALUE";
|
|
164
|
+
const context = useMenubarContext(MENU_NAME, __scopeMenubar);
|
|
165
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
166
|
+
const triggerRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "triggerRef"));
|
|
167
|
+
const wasKeyboardTriggerOpenRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "wasKeyboard"));
|
|
168
|
+
const open = context.value === value;
|
|
169
|
+
(0, import_octane.useEffect)(
|
|
170
|
+
() => {
|
|
171
|
+
if (!open) wasKeyboardTriggerOpenRef.current = false;
|
|
172
|
+
},
|
|
173
|
+
[open],
|
|
174
|
+
(0, import_internal.subSlot)(slot, "e:open")
|
|
175
|
+
);
|
|
176
|
+
return (0, import_octane.createElement)(MenubarMenuProvider, {
|
|
177
|
+
scope: __scopeMenubar,
|
|
178
|
+
value,
|
|
179
|
+
triggerId: (0, import_useId.useId)((0, import_internal.subSlot)(slot, "triggerId")),
|
|
180
|
+
triggerRef,
|
|
181
|
+
contentId: (0, import_useId.useId)((0, import_internal.subSlot)(slot, "contentId")),
|
|
182
|
+
wasKeyboardTriggerOpenRef,
|
|
183
|
+
children: (0, import_octane.createElement)(MenuPrimitive.Root, {
|
|
184
|
+
...menuScope,
|
|
185
|
+
open,
|
|
186
|
+
onOpenChange: (open2) => {
|
|
187
|
+
if (!open2) context.onMenuClose();
|
|
188
|
+
},
|
|
189
|
+
modal: false,
|
|
190
|
+
dir: context.dir,
|
|
191
|
+
...menuProps
|
|
192
|
+
})
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
const TRIGGER_NAME = "MenubarTrigger";
|
|
196
|
+
function Trigger(props) {
|
|
197
|
+
const slot = (0, import_internal.S)("Menubar.Trigger");
|
|
198
|
+
const { __scopeMenubar, disabled = false, ref: forwardedRef, ...triggerProps } = props ?? {};
|
|
199
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "rfs"));
|
|
200
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
201
|
+
const context = useMenubarContext(TRIGGER_NAME, __scopeMenubar);
|
|
202
|
+
const menuContext = useMenubarMenuContext(TRIGGER_NAME, __scopeMenubar);
|
|
203
|
+
const ref = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "ref"));
|
|
204
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(
|
|
205
|
+
forwardedRef,
|
|
206
|
+
ref,
|
|
207
|
+
menuContext.triggerRef,
|
|
208
|
+
(0, import_internal.subSlot)(slot, "refs")
|
|
209
|
+
);
|
|
210
|
+
const [isFocused, setIsFocused] = (0, import_octane.useState)(false, (0, import_internal.subSlot)(slot, "focused"));
|
|
211
|
+
const open = context.value === menuContext.value;
|
|
212
|
+
return (0, import_octane.createElement)(Collection.ItemSlot, {
|
|
213
|
+
scope: __scopeMenubar,
|
|
214
|
+
value: menuContext.value,
|
|
215
|
+
disabled,
|
|
216
|
+
children: (0, import_octane.createElement)(RovingFocusGroup.Item, {
|
|
217
|
+
asChild: true,
|
|
218
|
+
...rovingFocusGroupScope,
|
|
219
|
+
focusable: !disabled,
|
|
220
|
+
tabStopId: menuContext.value,
|
|
221
|
+
children: (0, import_octane.createElement)(MenuPrimitive.Anchor, {
|
|
222
|
+
asChild: true,
|
|
223
|
+
...menuScope,
|
|
224
|
+
children: (0, import_octane.createElement)(import_Primitive.Primitive.button, {
|
|
225
|
+
type: "button",
|
|
226
|
+
role: "menuitem",
|
|
227
|
+
id: menuContext.triggerId,
|
|
228
|
+
"aria-haspopup": "menu",
|
|
229
|
+
"aria-expanded": open,
|
|
230
|
+
"aria-controls": open ? menuContext.contentId : void 0,
|
|
231
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
232
|
+
"data-state": open ? "open" : "closed",
|
|
233
|
+
"data-disabled": disabled ? "" : void 0,
|
|
234
|
+
disabled,
|
|
235
|
+
...triggerProps,
|
|
236
|
+
ref: composedRefs,
|
|
237
|
+
onPointerDown: (0, import_compose_event_handlers.composeEventHandlers)(props?.onPointerDown, (event) => {
|
|
238
|
+
if (!disabled && event.button === 0 && event.ctrlKey === false) {
|
|
239
|
+
context.onMenuOpen(menuContext.value);
|
|
240
|
+
if (!open) event.preventDefault();
|
|
241
|
+
}
|
|
242
|
+
}),
|
|
243
|
+
onPointerEnter: (0, import_compose_event_handlers.composeEventHandlers)(props?.onPointerEnter, () => {
|
|
244
|
+
const menubarOpen = Boolean(context.value);
|
|
245
|
+
if (menubarOpen && !open) {
|
|
246
|
+
context.onMenuOpen(menuContext.value);
|
|
247
|
+
ref.current?.focus();
|
|
248
|
+
}
|
|
249
|
+
}),
|
|
250
|
+
onKeyDown: (0, import_compose_event_handlers.composeEventHandlers)(props?.onKeyDown, (event) => {
|
|
251
|
+
if (disabled) return;
|
|
252
|
+
if (["Enter", " "].includes(event.key)) context.onMenuToggle(menuContext.value);
|
|
253
|
+
if (event.key === "ArrowDown") context.onMenuOpen(menuContext.value);
|
|
254
|
+
if (["Enter", " ", "ArrowDown"].includes(event.key)) {
|
|
255
|
+
menuContext.wasKeyboardTriggerOpenRef.current = true;
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
}
|
|
258
|
+
}),
|
|
259
|
+
onFocus: (0, import_compose_event_handlers.composeEventHandlers)(props?.onFocus, () => setIsFocused(true)),
|
|
260
|
+
onBlur: (0, import_compose_event_handlers.composeEventHandlers)(props?.onBlur, () => setIsFocused(false))
|
|
261
|
+
})
|
|
262
|
+
})
|
|
263
|
+
})
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function Portal(props) {
|
|
267
|
+
const slot = (0, import_internal.S)("Menubar.Portal");
|
|
268
|
+
const { __scopeMenubar, ...portalProps } = props ?? {};
|
|
269
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
270
|
+
return (0, import_octane.createElement)(MenuPrimitive.Portal, { ...menuScope, ...portalProps });
|
|
271
|
+
}
|
|
272
|
+
const CONTENT_NAME = "MenubarContent";
|
|
273
|
+
function Content(props) {
|
|
274
|
+
const slot = (0, import_internal.S)("Menubar.Content");
|
|
275
|
+
const { __scopeMenubar, align = "start", ref: forwardedRef, ...contentProps } = props ?? {};
|
|
276
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
277
|
+
const context = useMenubarContext(CONTENT_NAME, __scopeMenubar);
|
|
278
|
+
const menuContext = useMenubarMenuContext(CONTENT_NAME, __scopeMenubar);
|
|
279
|
+
const getItems = useCollection(__scopeMenubar, (0, import_internal.subSlot)(slot, "items"));
|
|
280
|
+
const hasInteractedOutsideRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "interacted"));
|
|
281
|
+
return (0, import_octane.createElement)(MenuPrimitive.Content, {
|
|
282
|
+
id: menuContext.contentId,
|
|
283
|
+
"aria-labelledby": menuContext.triggerId,
|
|
284
|
+
"data-radix-menubar-content": "",
|
|
285
|
+
...menuScope,
|
|
286
|
+
...contentProps,
|
|
287
|
+
ref: forwardedRef,
|
|
288
|
+
align,
|
|
289
|
+
onCloseAutoFocus: (0, import_compose_event_handlers.composeEventHandlers)(props?.onCloseAutoFocus, (event) => {
|
|
290
|
+
const menubarOpen = Boolean(context.value);
|
|
291
|
+
if (!menubarOpen && !hasInteractedOutsideRef.current) {
|
|
292
|
+
menuContext.triggerRef.current?.focus();
|
|
293
|
+
}
|
|
294
|
+
hasInteractedOutsideRef.current = false;
|
|
295
|
+
event.preventDefault();
|
|
296
|
+
}),
|
|
297
|
+
onFocusOutside: (0, import_compose_event_handlers.composeEventHandlers)(props?.onFocusOutside, (event) => {
|
|
298
|
+
const target = event.target;
|
|
299
|
+
const isMenubarTrigger = getItems().some((item) => item.ref.current?.contains(target));
|
|
300
|
+
if (isMenubarTrigger) event.preventDefault();
|
|
301
|
+
}),
|
|
302
|
+
onInteractOutside: (0, import_compose_event_handlers.composeEventHandlers)(props?.onInteractOutside, () => {
|
|
303
|
+
hasInteractedOutsideRef.current = true;
|
|
304
|
+
}),
|
|
305
|
+
onEntryFocus: (event) => {
|
|
306
|
+
if (!menuContext.wasKeyboardTriggerOpenRef.current) event.preventDefault();
|
|
307
|
+
},
|
|
308
|
+
onKeyDown: (0, import_compose_event_handlers.composeEventHandlers)(
|
|
309
|
+
props?.onKeyDown,
|
|
310
|
+
(event) => {
|
|
311
|
+
if (["ArrowRight", "ArrowLeft"].includes(event.key)) {
|
|
312
|
+
const target = event.target;
|
|
313
|
+
const targetIsSubTrigger = target.hasAttribute("data-radix-menubar-subtrigger");
|
|
314
|
+
const isKeyDownInsideSubMenu = target.closest("[data-radix-menubar-content]") !== event.currentTarget;
|
|
315
|
+
const prevMenuKey = context.dir === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
316
|
+
const isPrevKey = prevMenuKey === event.key;
|
|
317
|
+
const isNextKey = !isPrevKey;
|
|
318
|
+
if (isNextKey && targetIsSubTrigger) return;
|
|
319
|
+
if (isKeyDownInsideSubMenu && isPrevKey) return;
|
|
320
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
321
|
+
let candidateValues = items.map((item) => item.value);
|
|
322
|
+
if (isPrevKey) candidateValues.reverse();
|
|
323
|
+
const currentIndex = candidateValues.indexOf(menuContext.value);
|
|
324
|
+
candidateValues = context.loop ? wrapArray(candidateValues, currentIndex + 1) : candidateValues.slice(currentIndex + 1);
|
|
325
|
+
const [nextValue] = candidateValues;
|
|
326
|
+
if (nextValue) context.onMenuOpen(nextValue);
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
{ checkForDefaultPrevented: false }
|
|
330
|
+
),
|
|
331
|
+
style: {
|
|
332
|
+
...props?.style,
|
|
333
|
+
// re-namespace exposed content custom properties
|
|
334
|
+
"--radix-menubar-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
335
|
+
"--radix-menubar-content-available-width": "var(--radix-popper-available-width)",
|
|
336
|
+
"--radix-menubar-content-available-height": "var(--radix-popper-available-height)",
|
|
337
|
+
"--radix-menubar-trigger-width": "var(--radix-popper-anchor-width)",
|
|
338
|
+
"--radix-menubar-trigger-height": "var(--radix-popper-anchor-height)"
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
function Group(props) {
|
|
343
|
+
const slot = (0, import_internal.S)("Menubar.Group");
|
|
344
|
+
const { __scopeMenubar, ...groupProps } = props ?? {};
|
|
345
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
346
|
+
return (0, import_octane.createElement)(MenuPrimitive.Group, { ...menuScope, ...groupProps });
|
|
347
|
+
}
|
|
348
|
+
function Label(props) {
|
|
349
|
+
const slot = (0, import_internal.S)("Menubar.Label");
|
|
350
|
+
const { __scopeMenubar, ...labelProps } = props ?? {};
|
|
351
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
352
|
+
return (0, import_octane.createElement)(MenuPrimitive.Label, { ...menuScope, ...labelProps });
|
|
353
|
+
}
|
|
354
|
+
function Item(props) {
|
|
355
|
+
const slot = (0, import_internal.S)("Menubar.Item");
|
|
356
|
+
const { __scopeMenubar, ...itemProps } = props ?? {};
|
|
357
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
358
|
+
return (0, import_octane.createElement)(MenuPrimitive.Item, { ...menuScope, ...itemProps });
|
|
359
|
+
}
|
|
360
|
+
function CheckboxItem(props) {
|
|
361
|
+
const slot = (0, import_internal.S)("Menubar.CheckboxItem");
|
|
362
|
+
const { __scopeMenubar, ...checkboxItemProps } = props ?? {};
|
|
363
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
364
|
+
return (0, import_octane.createElement)(MenuPrimitive.CheckboxItem, { ...menuScope, ...checkboxItemProps });
|
|
365
|
+
}
|
|
366
|
+
function RadioGroup(props) {
|
|
367
|
+
const slot = (0, import_internal.S)("Menubar.RadioGroup");
|
|
368
|
+
const { __scopeMenubar, ...radioGroupProps } = props ?? {};
|
|
369
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
370
|
+
return (0, import_octane.createElement)(MenuPrimitive.RadioGroup, { ...menuScope, ...radioGroupProps });
|
|
371
|
+
}
|
|
372
|
+
function RadioItem(props) {
|
|
373
|
+
const slot = (0, import_internal.S)("Menubar.RadioItem");
|
|
374
|
+
const { __scopeMenubar, ...radioItemProps } = props ?? {};
|
|
375
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
376
|
+
return (0, import_octane.createElement)(MenuPrimitive.RadioItem, { ...menuScope, ...radioItemProps });
|
|
377
|
+
}
|
|
378
|
+
function ItemIndicator(props) {
|
|
379
|
+
const slot = (0, import_internal.S)("Menubar.ItemIndicator");
|
|
380
|
+
const { __scopeMenubar, ...itemIndicatorProps } = props ?? {};
|
|
381
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
382
|
+
return (0, import_octane.createElement)(MenuPrimitive.ItemIndicator, { ...menuScope, ...itemIndicatorProps });
|
|
383
|
+
}
|
|
384
|
+
function Separator(props) {
|
|
385
|
+
const slot = (0, import_internal.S)("Menubar.Separator");
|
|
386
|
+
const { __scopeMenubar, ...separatorProps } = props ?? {};
|
|
387
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
388
|
+
return (0, import_octane.createElement)(MenuPrimitive.Separator, { ...menuScope, ...separatorProps });
|
|
389
|
+
}
|
|
390
|
+
function Arrow(props) {
|
|
391
|
+
const slot = (0, import_internal.S)("Menubar.Arrow");
|
|
392
|
+
const { __scopeMenubar, ...arrowProps } = props ?? {};
|
|
393
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
394
|
+
return (0, import_octane.createElement)(MenuPrimitive.Arrow, { ...menuScope, ...arrowProps });
|
|
395
|
+
}
|
|
396
|
+
function Sub(props) {
|
|
397
|
+
const slot = (0, import_internal.S)("Menubar.Sub");
|
|
398
|
+
const { __scopeMenubar, children, open: openProp, onOpenChange, defaultOpen } = props ?? {};
|
|
399
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
400
|
+
const [open, setOpen] = (0, import_useControllableState.useControllableState)(
|
|
401
|
+
{ prop: openProp, defaultProp: defaultOpen ?? false, onChange: onOpenChange },
|
|
402
|
+
(0, import_internal.subSlot)(slot, "open")
|
|
403
|
+
);
|
|
404
|
+
return (0, import_octane.createElement)(MenuPrimitive.Sub, { ...menuScope, open, onOpenChange: setOpen, children });
|
|
405
|
+
}
|
|
406
|
+
function SubTrigger(props) {
|
|
407
|
+
const slot = (0, import_internal.S)("Menubar.SubTrigger");
|
|
408
|
+
const { __scopeMenubar, ...subTriggerProps } = props ?? {};
|
|
409
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
410
|
+
return (0, import_octane.createElement)(MenuPrimitive.SubTrigger, {
|
|
411
|
+
"data-radix-menubar-subtrigger": "",
|
|
412
|
+
...menuScope,
|
|
413
|
+
...subTriggerProps
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function SubContent(props) {
|
|
417
|
+
const slot = (0, import_internal.S)("Menubar.SubContent");
|
|
418
|
+
const { __scopeMenubar, ...subContentProps } = props ?? {};
|
|
419
|
+
const menuScope = useMenuScope(__scopeMenubar, (0, import_internal.subSlot)(slot, "menu"));
|
|
420
|
+
return (0, import_octane.createElement)(MenuPrimitive.SubContent, {
|
|
421
|
+
...menuScope,
|
|
422
|
+
"data-radix-menubar-content": "",
|
|
423
|
+
...subContentProps,
|
|
424
|
+
style: {
|
|
425
|
+
...props?.style,
|
|
426
|
+
// re-namespace exposed content custom properties
|
|
427
|
+
"--radix-menubar-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
428
|
+
"--radix-menubar-content-available-width": "var(--radix-popper-available-width)",
|
|
429
|
+
"--radix-menubar-content-available-height": "var(--radix-popper-available-height)",
|
|
430
|
+
"--radix-menubar-trigger-width": "var(--radix-popper-anchor-width)",
|
|
431
|
+
"--radix-menubar-trigger-height": "var(--radix-popper-anchor-height)"
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
function wrapArray(array, startIndex) {
|
|
436
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
437
|
+
}
|
|
438
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
439
|
+
0 && (module.exports = {
|
|
440
|
+
Arrow,
|
|
441
|
+
CheckboxItem,
|
|
442
|
+
Content,
|
|
443
|
+
Group,
|
|
444
|
+
Item,
|
|
445
|
+
ItemIndicator,
|
|
446
|
+
Label,
|
|
447
|
+
Menu,
|
|
448
|
+
Menubar,
|
|
449
|
+
MenubarArrow,
|
|
450
|
+
MenubarCheckboxItem,
|
|
451
|
+
MenubarContent,
|
|
452
|
+
MenubarGroup,
|
|
453
|
+
MenubarItem,
|
|
454
|
+
MenubarItemIndicator,
|
|
455
|
+
MenubarLabel,
|
|
456
|
+
MenubarMenu,
|
|
457
|
+
MenubarPortal,
|
|
458
|
+
MenubarRadioGroup,
|
|
459
|
+
MenubarRadioItem,
|
|
460
|
+
MenubarSeparator,
|
|
461
|
+
MenubarSub,
|
|
462
|
+
MenubarSubContent,
|
|
463
|
+
MenubarSubTrigger,
|
|
464
|
+
MenubarTrigger,
|
|
465
|
+
Portal,
|
|
466
|
+
RadioGroup,
|
|
467
|
+
RadioItem,
|
|
468
|
+
Root,
|
|
469
|
+
Separator,
|
|
470
|
+
Sub,
|
|
471
|
+
SubContent,
|
|
472
|
+
SubTrigger,
|
|
473
|
+
Trigger,
|
|
474
|
+
createMenubarScope
|
|
475
|
+
});
|