@radix-ui/react-menu 2.1.24 → 2.1.25-rc.1785253136758
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.mts +8 -20
- package/dist/index.d.ts +8 -20
- package/dist/index.js +44 -36
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +50 -37
- package/dist/index.mjs.map +3 -3
- package/package.json +17 -17
package/dist/index.d.mts
CHANGED
|
@@ -3,11 +3,15 @@ import * as React from 'react';
|
|
|
3
3
|
import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
|
|
4
4
|
import { FocusScope } from '@radix-ui/react-focus-scope';
|
|
5
5
|
import * as PopperPrimitive from '@radix-ui/react-popper';
|
|
6
|
-
import { Portal
|
|
6
|
+
import { Portal } from '@radix-ui/react-portal';
|
|
7
7
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
8
8
|
import * as RovingFocusGroup from '@radix-ui/react-roving-focus';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
declare const Direction: {
|
|
11
|
+
readonly LTR: "ltr";
|
|
12
|
+
readonly RTL: "rtl";
|
|
13
|
+
};
|
|
14
|
+
type Direction = (typeof Direction)[keyof typeof Direction];
|
|
11
15
|
declare const createMenuScope: _radix_ui_react_context.CreateScope;
|
|
12
16
|
interface MenuProps {
|
|
13
17
|
children?: React.ReactNode;
|
|
@@ -21,7 +25,7 @@ type PopperAnchorProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.A
|
|
|
21
25
|
interface MenuAnchorProps extends PopperAnchorProps {
|
|
22
26
|
}
|
|
23
27
|
declare const MenuAnchor: React.ForwardRefExoticComponent<MenuAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
|
24
|
-
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal
|
|
28
|
+
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal>;
|
|
25
29
|
interface MenuPortalProps {
|
|
26
30
|
children?: React.ReactNode;
|
|
27
31
|
/**
|
|
@@ -155,21 +159,5 @@ interface MenuSubContentProps extends Omit<MenuContentImplProps, keyof MenuConte
|
|
|
155
159
|
align?: AlignSubContent;
|
|
156
160
|
}
|
|
157
161
|
declare const MenuSubContent: React.ForwardRefExoticComponent<MenuSubContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
158
|
-
declare const Root: React.FC<MenuProps>;
|
|
159
|
-
declare const Anchor: React.ForwardRefExoticComponent<MenuAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
|
160
|
-
declare const Portal: React.FC<MenuPortalProps>;
|
|
161
|
-
declare const Content: React.ForwardRefExoticComponent<MenuContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
162
|
-
declare const Group: React.ForwardRefExoticComponent<MenuGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
163
|
-
declare const Label: React.ForwardRefExoticComponent<MenuLabelProps & React.RefAttributes<HTMLDivElement>>;
|
|
164
|
-
declare const Item: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
165
|
-
declare const CheckboxItem: React.ForwardRefExoticComponent<MenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
166
|
-
declare const RadioGroup: React.ForwardRefExoticComponent<MenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
167
|
-
declare const RadioItem: React.ForwardRefExoticComponent<MenuRadioItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
168
|
-
declare const ItemIndicator: React.ForwardRefExoticComponent<MenuItemIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
|
|
169
|
-
declare const Separator: React.ForwardRefExoticComponent<MenuSeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
170
|
-
declare const Arrow: React.ForwardRefExoticComponent<MenuArrowProps & React.RefAttributes<SVGSVGElement>>;
|
|
171
|
-
declare const Sub: React.FC<MenuSubProps>;
|
|
172
|
-
declare const SubTrigger: React.ForwardRefExoticComponent<MenuSubTriggerProps & React.RefAttributes<HTMLDivElement>>;
|
|
173
|
-
declare const SubContent: React.ForwardRefExoticComponent<MenuSubContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
174
162
|
|
|
175
|
-
export { Anchor, Arrow, CheckboxItem, Content, Group, Item, ItemIndicator, Label, Menu, MenuAnchor, type MenuAnchorProps, MenuArrow, type MenuArrowProps, MenuCheckboxItem, type MenuCheckboxItemProps, MenuContent, type MenuContentProps, MenuGroup, type MenuGroupProps, MenuItem, MenuItemIndicator, type MenuItemIndicatorProps, type MenuItemProps, MenuLabel, type MenuLabelProps, MenuPortal, type MenuPortalProps, type MenuProps, MenuRadioGroup, type MenuRadioGroupProps, MenuRadioItem, type MenuRadioItemProps, MenuSeparator, type MenuSeparatorProps, MenuSub, MenuSubContent, type MenuSubContentProps, type MenuSubProps, MenuSubTrigger, type MenuSubTriggerProps, Portal, RadioGroup, RadioItem, Root, Separator, Sub, SubContent, SubTrigger, createMenuScope };
|
|
163
|
+
export { MenuAnchor as Anchor, MenuArrow as Arrow, MenuCheckboxItem as CheckboxItem, MenuContent as Content, MenuGroup as Group, MenuItem as Item, MenuItemIndicator as ItemIndicator, MenuLabel as Label, Menu, MenuAnchor, type MenuAnchorProps, MenuArrow, type MenuArrowProps, MenuCheckboxItem, type MenuCheckboxItemProps, MenuContent, type MenuContentProps, MenuGroup, type MenuGroupProps, MenuItem, MenuItemIndicator, type MenuItemIndicatorProps, type MenuItemProps, MenuLabel, type MenuLabelProps, MenuPortal, type MenuPortalProps, type MenuProps, MenuRadioGroup, type MenuRadioGroupProps, MenuRadioItem, type MenuRadioItemProps, MenuSeparator, type MenuSeparatorProps, MenuSub, MenuSubContent, type MenuSubContentProps, type MenuSubProps, MenuSubTrigger, type MenuSubTriggerProps, MenuPortal as Portal, MenuRadioGroup as RadioGroup, MenuRadioItem as RadioItem, Menu as Root, MenuSeparator as Separator, MenuSub as Sub, MenuSubContent as SubContent, MenuSubTrigger as SubTrigger, createMenuScope };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,15 @@ import * as React from 'react';
|
|
|
3
3
|
import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
|
|
4
4
|
import { FocusScope } from '@radix-ui/react-focus-scope';
|
|
5
5
|
import * as PopperPrimitive from '@radix-ui/react-popper';
|
|
6
|
-
import { Portal
|
|
6
|
+
import { Portal } from '@radix-ui/react-portal';
|
|
7
7
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
8
8
|
import * as RovingFocusGroup from '@radix-ui/react-roving-focus';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
declare const Direction: {
|
|
11
|
+
readonly LTR: "ltr";
|
|
12
|
+
readonly RTL: "rtl";
|
|
13
|
+
};
|
|
14
|
+
type Direction = (typeof Direction)[keyof typeof Direction];
|
|
11
15
|
declare const createMenuScope: _radix_ui_react_context.CreateScope;
|
|
12
16
|
interface MenuProps {
|
|
13
17
|
children?: React.ReactNode;
|
|
@@ -21,7 +25,7 @@ type PopperAnchorProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.A
|
|
|
21
25
|
interface MenuAnchorProps extends PopperAnchorProps {
|
|
22
26
|
}
|
|
23
27
|
declare const MenuAnchor: React.ForwardRefExoticComponent<MenuAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
|
24
|
-
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal
|
|
28
|
+
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal>;
|
|
25
29
|
interface MenuPortalProps {
|
|
26
30
|
children?: React.ReactNode;
|
|
27
31
|
/**
|
|
@@ -155,21 +159,5 @@ interface MenuSubContentProps extends Omit<MenuContentImplProps, keyof MenuConte
|
|
|
155
159
|
align?: AlignSubContent;
|
|
156
160
|
}
|
|
157
161
|
declare const MenuSubContent: React.ForwardRefExoticComponent<MenuSubContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
158
|
-
declare const Root: React.FC<MenuProps>;
|
|
159
|
-
declare const Anchor: React.ForwardRefExoticComponent<MenuAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
|
160
|
-
declare const Portal: React.FC<MenuPortalProps>;
|
|
161
|
-
declare const Content: React.ForwardRefExoticComponent<MenuContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
162
|
-
declare const Group: React.ForwardRefExoticComponent<MenuGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
163
|
-
declare const Label: React.ForwardRefExoticComponent<MenuLabelProps & React.RefAttributes<HTMLDivElement>>;
|
|
164
|
-
declare const Item: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
165
|
-
declare const CheckboxItem: React.ForwardRefExoticComponent<MenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
166
|
-
declare const RadioGroup: React.ForwardRefExoticComponent<MenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
167
|
-
declare const RadioItem: React.ForwardRefExoticComponent<MenuRadioItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
168
|
-
declare const ItemIndicator: React.ForwardRefExoticComponent<MenuItemIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
|
|
169
|
-
declare const Separator: React.ForwardRefExoticComponent<MenuSeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
170
|
-
declare const Arrow: React.ForwardRefExoticComponent<MenuArrowProps & React.RefAttributes<SVGSVGElement>>;
|
|
171
|
-
declare const Sub: React.FC<MenuSubProps>;
|
|
172
|
-
declare const SubTrigger: React.ForwardRefExoticComponent<MenuSubTriggerProps & React.RefAttributes<HTMLDivElement>>;
|
|
173
|
-
declare const SubContent: React.ForwardRefExoticComponent<MenuSubContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
174
162
|
|
|
175
|
-
export { Anchor, Arrow, CheckboxItem, Content, Group, Item, ItemIndicator, Label, Menu, MenuAnchor, type MenuAnchorProps, MenuArrow, type MenuArrowProps, MenuCheckboxItem, type MenuCheckboxItemProps, MenuContent, type MenuContentProps, MenuGroup, type MenuGroupProps, MenuItem, MenuItemIndicator, type MenuItemIndicatorProps, type MenuItemProps, MenuLabel, type MenuLabelProps, MenuPortal, type MenuPortalProps, type MenuProps, MenuRadioGroup, type MenuRadioGroupProps, MenuRadioItem, type MenuRadioItemProps, MenuSeparator, type MenuSeparatorProps, MenuSub, MenuSubContent, type MenuSubContentProps, type MenuSubProps, MenuSubTrigger, type MenuSubTriggerProps, Portal, RadioGroup, RadioItem, Root, Separator, Sub, SubContent, SubTrigger, createMenuScope };
|
|
163
|
+
export { MenuAnchor as Anchor, MenuArrow as Arrow, MenuCheckboxItem as CheckboxItem, MenuContent as Content, MenuGroup as Group, MenuItem as Item, MenuItemIndicator as ItemIndicator, MenuLabel as Label, Menu, MenuAnchor, type MenuAnchorProps, MenuArrow, type MenuArrowProps, MenuCheckboxItem, type MenuCheckboxItemProps, MenuContent, type MenuContentProps, MenuGroup, type MenuGroupProps, MenuItem, MenuItemIndicator, type MenuItemIndicatorProps, type MenuItemProps, MenuLabel, type MenuLabelProps, MenuPortal, type MenuPortalProps, type MenuProps, MenuRadioGroup, type MenuRadioGroupProps, MenuRadioItem, type MenuRadioItemProps, MenuSeparator, type MenuSeparatorProps, MenuSub, MenuSubContent, type MenuSubContentProps, type MenuSubProps, MenuSubTrigger, type MenuSubTriggerProps, MenuPortal as Portal, MenuRadioGroup as RadioGroup, MenuRadioItem as RadioItem, Menu as Root, MenuSeparator as Separator, MenuSub as Sub, MenuSubContent as SubContent, MenuSubTrigger as SubTrigger, createMenuScope };
|
package/dist/index.js
CHANGED
|
@@ -32,14 +32,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
// src/index.ts
|
|
33
33
|
var index_exports = {};
|
|
34
34
|
__export(index_exports, {
|
|
35
|
-
Anchor: () =>
|
|
36
|
-
Arrow: () =>
|
|
37
|
-
CheckboxItem: () =>
|
|
38
|
-
Content: () =>
|
|
39
|
-
Group: () =>
|
|
40
|
-
Item: () =>
|
|
41
|
-
ItemIndicator: () =>
|
|
42
|
-
Label: () =>
|
|
35
|
+
Anchor: () => MenuAnchor,
|
|
36
|
+
Arrow: () => MenuArrow,
|
|
37
|
+
CheckboxItem: () => MenuCheckboxItem,
|
|
38
|
+
Content: () => MenuContent,
|
|
39
|
+
Group: () => MenuGroup,
|
|
40
|
+
Item: () => MenuItem,
|
|
41
|
+
ItemIndicator: () => MenuItemIndicator,
|
|
42
|
+
Label: () => MenuLabel,
|
|
43
43
|
Menu: () => Menu,
|
|
44
44
|
MenuAnchor: () => MenuAnchor,
|
|
45
45
|
MenuArrow: () => MenuArrow,
|
|
@@ -56,14 +56,14 @@ __export(index_exports, {
|
|
|
56
56
|
MenuSub: () => MenuSub,
|
|
57
57
|
MenuSubContent: () => MenuSubContent,
|
|
58
58
|
MenuSubTrigger: () => MenuSubTrigger,
|
|
59
|
-
Portal: () =>
|
|
60
|
-
RadioGroup: () =>
|
|
61
|
-
RadioItem: () =>
|
|
62
|
-
Root: () =>
|
|
63
|
-
Separator: () =>
|
|
64
|
-
Sub: () =>
|
|
65
|
-
SubContent: () =>
|
|
66
|
-
SubTrigger: () =>
|
|
59
|
+
Portal: () => MenuPortal,
|
|
60
|
+
RadioGroup: () => MenuRadioGroup,
|
|
61
|
+
RadioItem: () => MenuRadioItem,
|
|
62
|
+
Root: () => Menu,
|
|
63
|
+
Separator: () => MenuSeparator,
|
|
64
|
+
Sub: () => MenuSub,
|
|
65
|
+
SubContent: () => MenuSubContent,
|
|
66
|
+
SubTrigger: () => MenuSubTrigger,
|
|
67
67
|
createMenuScope: () => createMenuScope
|
|
68
68
|
});
|
|
69
69
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -91,6 +91,10 @@ var import_react_use_callback_ref = require("@radix-ui/react-use-callback-ref");
|
|
|
91
91
|
var import_aria_hidden = require("aria-hidden");
|
|
92
92
|
var import_react_remove_scroll = require("react-remove-scroll");
|
|
93
93
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
94
|
+
var Direction = {
|
|
95
|
+
LTR: "ltr",
|
|
96
|
+
RTL: "rtl"
|
|
97
|
+
};
|
|
94
98
|
var SELECTION_KEYS = ["Enter", " "];
|
|
95
99
|
var FIRST_KEYS = ["ArrowDown", "PageUp", "Home"];
|
|
96
100
|
var LAST_KEYS = ["ArrowUp", "PageDown", "End"];
|
|
@@ -252,6 +256,7 @@ var MenuContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
252
256
|
onInteractOutside,
|
|
253
257
|
onDismiss,
|
|
254
258
|
disableOutsideScroll,
|
|
259
|
+
children,
|
|
255
260
|
...contentProps
|
|
256
261
|
} = props;
|
|
257
262
|
const context = useMenuContext(CONTENT_NAME, __scopeMenu);
|
|
@@ -261,15 +266,32 @@ var MenuContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
261
266
|
const getItems = useCollection(__scopeMenu);
|
|
262
267
|
const [currentItemId, setCurrentItemId] = React.useState(null);
|
|
263
268
|
const contentRef = React.useRef(null);
|
|
264
|
-
const
|
|
269
|
+
const [branchNode, setBranchNode] = React.useState(null);
|
|
270
|
+
(0, import_react_focus_scope.useFocusScopeBranch)(branchNode);
|
|
271
|
+
const { nodes: branchNodes, registry: branchRegistry } = (0, import_react_focus_scope.useFocusScopeBranchRegistry)();
|
|
272
|
+
const isModal = Boolean(trapFocus || disableOutsideScroll);
|
|
273
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(
|
|
274
|
+
forwardedRef,
|
|
275
|
+
contentRef,
|
|
276
|
+
context.onContentChange,
|
|
277
|
+
setBranchNode
|
|
278
|
+
);
|
|
265
279
|
const timerRef = React.useRef(0);
|
|
266
280
|
const searchRef = React.useRef("");
|
|
267
281
|
const pointerGraceTimerRef = React.useRef(0);
|
|
268
282
|
const pointerGraceIntentRef = React.useRef(null);
|
|
269
283
|
const pointerDirRef = React.useRef("right");
|
|
270
284
|
const lastPointerXRef = React.useRef(0);
|
|
285
|
+
const shards = React.useMemo(
|
|
286
|
+
() => disableOutsideScroll ? [contentRef, ...branchNodes.map((node) => ({ current: node }))] : [],
|
|
287
|
+
[contentRef, branchNodes, disableOutsideScroll]
|
|
288
|
+
);
|
|
271
289
|
const ScrollLockWrapper = disableOutsideScroll ? import_react_remove_scroll.RemoveScroll : React.Fragment;
|
|
272
|
-
const scrollLockWrapperProps = disableOutsideScroll ? {
|
|
290
|
+
const scrollLockWrapperProps = disableOutsideScroll ? {
|
|
291
|
+
as: Slot,
|
|
292
|
+
allowPinchZoom: true,
|
|
293
|
+
shards
|
|
294
|
+
} : void 0;
|
|
273
295
|
const handleTypeaheadSearch = /* @__PURE__ */ __name((key) => {
|
|
274
296
|
const search = searchRef.current + key;
|
|
275
297
|
const items = getItems().filter((item) => !item.disabled);
|
|
@@ -329,6 +351,7 @@ var MenuContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
329
351
|
{
|
|
330
352
|
asChild: true,
|
|
331
353
|
trapped: trapFocus,
|
|
354
|
+
branches: branchNodes,
|
|
332
355
|
onMountAutoFocus: (0, import_primitive.composeEventHandlers)(onOpenAutoFocus, (event) => {
|
|
333
356
|
event.preventDefault();
|
|
334
357
|
contentRef.current?.focus({ preventScroll: true });
|
|
@@ -405,7 +428,8 @@ var MenuContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
405
428
|
lastPointerXRef.current = event.clientX;
|
|
406
429
|
}
|
|
407
430
|
})
|
|
408
|
-
)
|
|
431
|
+
),
|
|
432
|
+
children: isModal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_focus_scope.FocusScopeBranchProvider, { value: branchRegistry, children }) : children
|
|
409
433
|
}
|
|
410
434
|
)
|
|
411
435
|
}
|
|
@@ -804,7 +828,7 @@ var MenuSubContent = /* @__PURE__ */ React.forwardRef(
|
|
|
804
828
|
...subContentProps,
|
|
805
829
|
ref: composedRefs,
|
|
806
830
|
align,
|
|
807
|
-
side: rootContext.dir ===
|
|
831
|
+
side: rootContext.dir === Direction.RTL ? "left" : "right",
|
|
808
832
|
disableOutsidePointerEvents: false,
|
|
809
833
|
disableOutsideScroll: false,
|
|
810
834
|
trapFocus: false,
|
|
@@ -897,20 +921,4 @@ function whenMouse(handler) {
|
|
|
897
921
|
return (event) => event.pointerType === "mouse" ? handler(event) : void 0;
|
|
898
922
|
}
|
|
899
923
|
__name(whenMouse, "whenMouse");
|
|
900
|
-
var Root3 = Menu;
|
|
901
|
-
var Anchor2 = MenuAnchor;
|
|
902
|
-
var Portal = MenuPortal;
|
|
903
|
-
var Content2 = MenuContent;
|
|
904
|
-
var Group = MenuGroup;
|
|
905
|
-
var Label = MenuLabel;
|
|
906
|
-
var Item2 = MenuItem;
|
|
907
|
-
var CheckboxItem = MenuCheckboxItem;
|
|
908
|
-
var RadioGroup = MenuRadioGroup;
|
|
909
|
-
var RadioItem = MenuRadioItem;
|
|
910
|
-
var ItemIndicator = MenuItemIndicator;
|
|
911
|
-
var Separator = MenuSeparator;
|
|
912
|
-
var Arrow2 = MenuArrow;
|
|
913
|
-
var Sub = MenuSub;
|
|
914
|
-
var SubTrigger = MenuSubTrigger;
|
|
915
|
-
var SubContent = MenuSubContent;
|
|
916
924
|
//# sourceMappingURL=index.js.map
|