@radix-ui/react-context-menu 0.1.1-rc.9 → 0.1.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/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/package.json +5 -6
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,12 @@ import * as Radix from "@radix-ui/react-primitive";
|
|
|
3
3
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
4
|
import * as MenuPrimitive from "@radix-ui/react-menu";
|
|
5
5
|
type Direction = 'ltr' | 'rtl';
|
|
6
|
+
export const createContextMenuScope: import("@radix-ui/react-context").CreateScope;
|
|
6
7
|
export interface ContextMenuProps {
|
|
7
8
|
onOpenChange?(open: boolean): void;
|
|
8
9
|
dir?: Direction;
|
|
9
10
|
modal?: boolean;
|
|
11
|
+
children?: React.ReactNode;
|
|
10
12
|
}
|
|
11
13
|
export const ContextMenu: React.FC<ContextMenuProps>;
|
|
12
14
|
type PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"A;A;A;A;
|
|
1
|
+
{"mappings":"A;A;A;A;AAWA,iBAAiB,KAAK,GAAG,KAAK,CAAC;AAU/B,OAAA,6FAEE,CAAC;AAaH;IACE,YAAY,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACnC,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,SAAS,CAAC;CAC5B;AAED,OAAA,MAAM,aAAa,MAAM,EAAE,CAAC,gBAAgB,CA8C3C,CAAC;AAWF,0BAA0B,MAAM,wBAAwB,CAAC,OAAO,UAAU,IAAI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wB,CAAC,OAAO,cAAc,aAAa,CAAC,CAAC;AACjG,8CAAwC,SAAQ,sBAAsB;CAAG;AAEzE,OAAA,MAAM,+HAOJ,CAAC;AAWH,0BAA0B,MAAM,wBAAwB,CAAC,OAAO,cAAc,SAAS,CAAC,CAAC;AACzF,0CAAoC,SAAQ,kBAAkB;CAAG;AAEjE,OAAA,MAAM,sHAOJ,CAAC;AAWH,sBAAsB,MAAM,wBAAwB,CAAC,OAAO,cAAc,KAAK,CAAC,CAAC;AACjF,sCAAgC,SAAQ,cAAc;CAAG;AAEzD,OAAA,MAAM,6GAML,CAAC;AAUF,OAAA,MAAM,gCAAkB,CAAC;AACzB,OAAA,MAAM,wGAA4B,CAAC;AACnC,OAAA,MAAM,uGAA4B,CAAC;AACnC,OAAA,MAAM,mGAAwB,CAAC;AAC/B,OAAA,MAAM,mGAAwB,CAAC;AAC/B,OAAA,MAAM,iGAAsB,CAAC;AAC7B,OAAA,MAAM,+GAAoC,CAAC;AAC3C,OAAA,MAAM,iHAAsC,CAAC;AAC7C,OAAA,MAAM,6GAAkC,CAAC;AACzC,OAAA,MAAM,2GAAgC,CAAC;AACvC,OAAA,MAAM,oHAAwC,CAAC;AAC/C,OAAA,MAAM,2GAAgC,CAAC;AACvC,OAAA,MAAM,kGAAwB,CAAC","sources":["./packages/react/context-menu/src/packages/react/context-menu/src/ContextMenu.tsx","./packages/react/context-menu/src/packages/react/context-menu/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e,t=require("@radix-ui/react-use-callback-ref").useCallbackRef,
|
|
1
|
+
var e,t=require("@radix-ui/react-use-callback-ref").useCallbackRef,n=require("@radix-ui/react-menu"),o=p({},n),r=n.createMenuScope,c=require("@radix-ui/react-primitive").Primitive,s=require("@radix-ui/react-context").createContextScope,u=require("@radix-ui/primitive").composeEventHandlers,a=p({},require("react")),i=(e=require("@babel/runtime/helpers/extends"))&&e.__esModule?e.default:e;function p(e,t){return Object.keys(t).forEach((function(n){"default"!==n&&"__esModule"!==n&&Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),e}const[x,l]=s("ContextMenu",[r]);exports.createContextMenuScope=l;const C=r(),[f,d]=x("ContextMenu"),m=e=>{const{__scopeContextMenu:n,children:r,onOpenChange:c,dir:s,modal:u=!0}=e,[p,x]=a.useState(!1),l=R("ContextMenu",n),d=C(n),m=t(c),M=a.useCallback((e=>{x(e),m(e)}),[m]);return l.isInsideContent?/*#__PURE__*/a.createElement(f,{scope:n,isRootMenu:!1,open:p,onOpenChange:M,modal:u},/*#__PURE__*/a.createElement(o.Sub,i({},d,{open:p,onOpenChange:M}),r)):/*#__PURE__*/a.createElement(f,{scope:n,isRootMenu:!0,open:p,onOpenChange:M,modal:u},/*#__PURE__*/a.createElement(o.Root,i({},d,{dir:s,open:p,onOpenChange:M,modal:u}),r))};exports.ContextMenu=m;const M=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,s=d("ContextMenuTrigger",n),p=C(n),x=a.useRef({x:0,y:0}),l=a.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...x.current})}),f=a.useRef(0),m=a.useCallback((()=>window.clearTimeout(f.current)),[]),M=e=>{x.current={x:e.clientX,y:e.clientY},s.onOpenChange(!0)};return a.useEffect((()=>m),[m]),/*#__PURE__*/a.createElement(_,{scope:n,isInsideContent:!1},/*#__PURE__*/a.createElement(o.Anchor,i({},p,{virtualRef:l})),/*#__PURE__*/a.createElement(c.span,i({},r,{ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:u(e.onContextMenu,(e=>{m(),e.preventDefault(),M(e)})),onPointerDown:u(e.onPointerDown,S((e=>{m(),f.current=window.setTimeout((()=>M(e)),700)}))),onPointerMove:u(e.onPointerMove,S(m)),onPointerCancel:u(e.onPointerCancel,S(m)),onPointerUp:u(e.onPointerUp,S(m))})))}));exports.ContextMenuTrigger=M;const[_,R]=x("ContextMenuContent",{isInsideContent:!1}),g=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=d("ContextMenuContent",n),s=C(n),u={...r,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)"}};/*#__PURE__*/return a.createElement(_,{scope:n,isInsideContent:!0},c.isRootMenu?/*#__PURE__*/a.createElement(E,i({__scopeContextMenu:n},u,{ref:t})):/*#__PURE__*/a.createElement(o.Content,i({},s,u,{ref:t})))}));exports.ContextMenuContent=g;const E=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=d("ContextMenuContent",n),s=C(n),u=a.useRef(!1);/*#__PURE__*/return a.createElement(o.Content,i({},s,r,{ref:t,portalled:!0,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var n;null===(n=e.onCloseAutoFocus)||void 0===n||n.call(e,t),!t.defaultPrevented&&u.current&&t.preventDefault(),u.current=!1},onInteractOutside:t=>{var n;null===(n=e.onInteractOutside)||void 0===n||n.call(e,t),t.defaultPrevented||c.modal||(u.current=!0)}}))})),w=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=C(n);/*#__PURE__*/return a.createElement(o.Group,i({},c,r,{ref:t}))}));exports.ContextMenuGroup=w;const I=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=C(n);/*#__PURE__*/return a.createElement(o.Label,i({},c,r,{ref:t}))}));exports.ContextMenuLabel=I;const b=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=C(n);/*#__PURE__*/return a.createElement(o.Item,i({},c,r,{ref:t}))}));exports.ContextMenuItem=b;const h=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=C(n);/*#__PURE__*/return a.createElement(o.SubTrigger,i({},c,r,{ref:t}))}));exports.ContextMenuTriggerItem=h;const v=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=C(n);/*#__PURE__*/return a.createElement(o.CheckboxItem,i({},c,r,{ref:t}))}));exports.ContextMenuCheckboxItem=v;const O=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=C(n);/*#__PURE__*/return a.createElement(o.RadioGroup,i({},c,r,{ref:t}))}));exports.ContextMenuRadioGroup=O;const P=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=C(n);/*#__PURE__*/return a.createElement(o.RadioItem,i({},c,r,{ref:t}))}));exports.ContextMenuRadioItem=P;const T=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=C(n);/*#__PURE__*/return a.createElement(o.ItemIndicator,i({},c,r,{ref:t}))}));exports.ContextMenuItemIndicator=T;const k=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=C(n);/*#__PURE__*/return a.createElement(o.Separator,i({},c,r,{ref:t}))}));exports.ContextMenuSeparator=k;const y=/*#__PURE__*/a.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,c=C(n);/*#__PURE__*/return a.createElement(o.Arrow,i({},c,r,{ref:t}))}));function S(e){return t=>"mouse"!==t.pointerType?e(t):void 0}exports.ContextMenuArrow=y;const q=m;exports.Root=q;const A=M;exports.Trigger=A;const G=g;exports.Content=G;const D=w;exports.Group=D;const L=I;exports.Label=L;const j=b;exports.Item=j;const F=h;exports.TriggerItem=F;const U=v;exports.CheckboxItem=U;const B=O;exports.RadioGroup=B;const H=P;exports.RadioItem=H;const W=T;exports.ItemIndicator=W;const X=k;exports.Separator=X;const Y=y;exports.Arrow=Y;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"IAAgCA,6RAAAA,8CAClBA,E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T,EAAAC,cAACG,EAAcyE,WAAfxC,EAAA,GAA8BrD,EAA9B,CAAqCsD,IAAK7B,uCAQrE,MAMMqE,eAAuBvF,EAAMiB,YAGjC,CAACxB,EAAOyB,iBAAiBT,EAAAC,cAACG,EAAc2E,UAAf1C,EAAA,GAA6BrD,EAA7B,CAAoCsD,IAAK7B,sCAQpE,MAMMuE,eAA2BzF,EAAMiB,YAGrC,CAACxB,EAAOyB,iBAAiBT,EAAAC,cAACG,EAAc6E,cAAf5C,EAAA,GAAiCrD,EAAjC,CAAwCsD,IAAK7B,0CAQxE,MAMMyE,eAAuB3F,EAAMiB,YAGjC,CAACxB,EAAOyB,iBAAiBT,EAAAC,cAACG,EAAc+E,UAAf9C,EAAA,GAA6BrD,EAA7B,CAAoCsD,IAAK7B,sCAQpE,MAMM2E,eAAmB7F,EAAMiB,YAC7B,CAACxB,EAAOyB,iBAAiBT,EAAAC,cAACG,EAAciF,MAAfhD,EAAA,GAAyBrD,EAAzB,CAAgCsD,IAAK7B,OAOhE,SAASoC,EAAkByC,GACzB,OAAQ3D,GAAiC,UAAtBA,EAAM4D,YAA0BD,EAAQ3D,QAAS6D,6BAGtE,MAAMlF,EAAOvB,iBACb,MAAM0G,EAAUlF,oBAChB,MAAM8C,EAAUH,oBAChB,MAAMiB,EAAQD,kBACd,MAAMG,EAAQD,kBACd,MAAMG,EAAOD,iBACb,MAAMoB,EAAclB,wBACpB,MAAMG,EAAeD,yBACrB,MAAMG,EAAaD,uBACnB,MAAMG,EAAYD,sBAClB,MAAMG,EAAgBD,0BACtB,MAAMG,EAAYD,sBAClB,MAAMG,EAAQD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/context-menu/src/ContextMenu.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContext } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as MenuPrimitive from '@radix-ui/react-menu';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\ntype Direction = 'ltr' | 'rtl';\ntype Point = { x: number; y: number };\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenu\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTEXT_MENU_NAME = 'ContextMenu';\n\ntype ContextMenuContextValue = {\n isRootMenu: boolean;\n open: boolean;\n onOpenChange(open: boolean): void;\n modal: boolean;\n};\n\nconst [ContextMenuProvider, useContextMenuContext] =\n createContext<ContextMenuContextValue>(CONTEXT_MENU_NAME);\n\ninterface ContextMenuProps {\n onOpenChange?(open: boolean): void;\n dir?: Direction;\n modal?: boolean;\n}\n\nconst ContextMenu: React.FC<ContextMenuProps> = (props) => {\n const { children, onOpenChange, dir, modal = true } = props;\n const [open, setOpen] = React.useState(false);\n const isInsideContent = React.useContext(ContentContext);\n const handleOpenChangeProp = useCallbackRef(onOpenChange);\n\n const handleOpenChange = React.useCallback(\n (open) => {\n setOpen(open);\n handleOpenChangeProp(open);\n },\n [handleOpenChangeProp]\n );\n\n return isInsideContent ? (\n <ContextMenuProvider\n isRootMenu={false}\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n >\n <MenuPrimitive.Sub open={open} onOpenChange={handleOpenChange}>\n {children}\n </MenuPrimitive.Sub>\n </ContextMenuProvider>\n ) : (\n <ContextMenuProvider\n isRootMenu={true}\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n >\n <MenuPrimitive.Root dir={dir} open={open} onOpenChange={handleOpenChange} modal={modal}>\n {children}\n </MenuPrimitive.Root>\n </ContextMenuProvider>\n );\n};\n\nContextMenu.displayName = CONTEXT_MENU_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'ContextMenuTrigger';\n\ntype ContextMenuTriggerElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface ContextMenuTriggerProps extends PrimitiveSpanProps {}\n\nconst ContextMenuTrigger = React.forwardRef<ContextMenuTriggerElement, ContextMenuTriggerProps>(\n (props, forwardedRef) => {\n const context = useContextMenuContext(TRIGGER_NAME);\n const pointRef = React.useRef<Point>({ x: 0, y: 0 });\n const virtualRef = React.useRef({\n getBoundingClientRect: () => DOMRect.fromRect({ width: 0, height: 0, ...pointRef.current }),\n });\n const longPressTimerRef = React.useRef(0);\n const clearLongPress = React.useCallback(\n () => window.clearTimeout(longPressTimerRef.current),\n []\n );\n const handleOpen = (event: React.MouseEvent | React.PointerEvent) => {\n pointRef.current = { x: event.clientX, y: event.clientY };\n context.onOpenChange(true);\n };\n\n React.useEffect(() => clearLongPress, [clearLongPress]);\n\n return (\n <ContentContext.Provider value={false}>\n <MenuPrimitive.Anchor virtualRef={virtualRef} />\n <Primitive.span\n {...props}\n ref={forwardedRef}\n // prevent iOS context menu from appearing\n style={{ WebkitTouchCallout: 'none', ...props.style }}\n onContextMenu={composeEventHandlers(props.onContextMenu, (event) => {\n // clearing the long press here because some platforms already support\n // long press to trigger a `contextmenu` event\n clearLongPress();\n event.preventDefault();\n handleOpen(event);\n })}\n onPointerDown={composeEventHandlers(\n props.onPointerDown,\n whenTouchOrPen((event) => {\n // clear the long press here in case there's multiple touch points\n clearLongPress();\n longPressTimerRef.current = window.setTimeout(() => handleOpen(event), 700);\n })\n )}\n onPointerMove={composeEventHandlers(props.onPointerMove, whenTouchOrPen(clearLongPress))}\n onPointerCancel={composeEventHandlers(\n props.onPointerCancel,\n whenTouchOrPen(clearLongPress)\n )}\n onPointerUp={composeEventHandlers(props.onPointerUp, whenTouchOrPen(clearLongPress))}\n />\n </ContentContext.Provider>\n );\n }\n);\n\nContextMenuTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'ContextMenuContent';\n\nconst ContentContext = React.createContext(false);\n\ntype ContextMenuContentElement = React.ElementRef<typeof MenuPrimitive.Content>;\ntype MenuContentProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Content>;\ninterface ContextMenuContentProps extends Omit<MenuContentProps, 'portalled' | 'side' | 'align'> {}\n\nconst ContextMenuContent = React.forwardRef<ContextMenuContentElement, ContextMenuContentProps>(\n (props, forwardedRef) => {\n const context = useContextMenuContext(CONTENT_NAME);\n\n const commonProps = {\n ...props,\n style: {\n ...props.style,\n // re-namespace exposed content custom property\n ['--radix-context-menu-content-transform-origin' as any]:\n 'var(--radix-popper-transform-origin)',\n },\n };\n\n return (\n <ContentContext.Provider value={true}>\n {context.isRootMenu ? (\n <ContextMenuRootContent {...commonProps} ref={forwardedRef} />\n ) : (\n <MenuPrimitive.Content {...commonProps} ref={forwardedRef} />\n )}\n </ContentContext.Provider>\n );\n }\n);\n\nContextMenuContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype ContextMenuRootContentElement = React.ElementRef<typeof MenuPrimitive.Content>;\ninterface ContextMenuRootContentProps extends MenuContentProps {}\n\nconst ContextMenuRootContent = React.forwardRef<\n ContextMenuRootContentElement,\n ContextMenuRootContentProps\n>((props, forwardedRef) => {\n const context = useContextMenuContext(CONTENT_NAME);\n const hasInteractedOutsideRef = React.useRef(false);\n return (\n <MenuPrimitive.Content\n {...props}\n ref={forwardedRef}\n portalled\n side=\"right\"\n sideOffset={2}\n align=\"start\"\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented && hasInteractedOutsideRef.current) {\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented && !context.modal) hasInteractedOutsideRef.current = true;\n }}\n />\n );\n});\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst GROUP_NAME = 'ContextMenuGroup';\n\ntype ContextMenuGroupElement = React.ElementRef<typeof MenuPrimitive.Group>;\ntype MenuGroupProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Group>;\ninterface ContextMenuGroupProps extends MenuGroupProps {}\n\nconst ContextMenuGroup = React.forwardRef<ContextMenuGroupElement, ContextMenuGroupProps>(\n (props, forwardedRef) => <MenuPrimitive.Group {...props} ref={forwardedRef} />\n);\n\nContextMenuGroup.displayName = GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuLabel\n * -----------------------------------------------------------------------------------------------*/\n\nconst LABEL_NAME = 'ContextMenuLabel';\n\ntype ContextMenuLabelElement = React.ElementRef<typeof MenuPrimitive.Label>;\ntype MenuLabelProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Label>;\ninterface ContextMenuLabelProps extends MenuLabelProps {}\n\nconst ContextMenuLabel = React.forwardRef<ContextMenuLabelElement, ContextMenuLabelProps>(\n (props, forwardedRef) => <MenuPrimitive.Label {...props} ref={forwardedRef} />\n);\n\nContextMenuLabel.displayName = LABEL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'ContextMenuItem';\n\ntype ContextMenuItemElement = React.ElementRef<typeof MenuPrimitive.Item>;\ntype MenuItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Item>;\ninterface ContextMenuItemProps extends MenuItemProps {}\n\nconst ContextMenuItem = React.forwardRef<ContextMenuItemElement, ContextMenuItemProps>(\n (props, forwardedRef) => <MenuPrimitive.Item {...props} ref={forwardedRef} />\n);\n\nContextMenuItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuTriggerItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_ITEM_NAME = 'ContextMenuTriggerItem';\n\ntype ContextMenuTriggerItemElement = React.ElementRef<typeof MenuPrimitive.SubTrigger>;\ntype MenuSubTriggerProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.SubTrigger>;\ninterface ContextMenuTriggerItemProps extends MenuSubTriggerProps {}\n\nconst ContextMenuTriggerItem = React.forwardRef<\n ContextMenuTriggerItemElement,\n ContextMenuTriggerItemProps\n>((props, forwardedRef) => <MenuPrimitive.SubTrigger {...props} ref={forwardedRef} />);\n\nContextMenuTriggerItem.displayName = TRIGGER_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuCheckboxItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst CHECKBOX_ITEM_NAME = 'ContextMenuCheckboxItem';\n\ntype ContextMenuCheckboxItemElement = React.ElementRef<typeof MenuPrimitive.CheckboxItem>;\ntype MenuCheckboxItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.CheckboxItem>;\ninterface ContextMenuCheckboxItemProps extends MenuCheckboxItemProps {}\n\nconst ContextMenuCheckboxItem = React.forwardRef<\n ContextMenuCheckboxItemElement,\n ContextMenuCheckboxItemProps\n>((props, forwardedRef) => <MenuPrimitive.CheckboxItem {...props} ref={forwardedRef} />);\n\nContextMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuRadioGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_GROUP_NAME = 'ContextMenuRadioGroup';\n\ntype ContextMenuRadioGroupElement = React.ElementRef<typeof MenuPrimitive.RadioGroup>;\ntype MenuRadioGroupProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioGroup>;\ninterface ContextMenuRadioGroupProps extends MenuRadioGroupProps {}\n\nconst ContextMenuRadioGroup = React.forwardRef<\n ContextMenuRadioGroupElement,\n ContextMenuRadioGroupProps\n>((props, forwardedRef) => <MenuPrimitive.RadioGroup {...props} ref={forwardedRef} />);\n\nContextMenuRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuRadioItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_ITEM_NAME = 'ContextMenuRadioItem';\n\ntype ContextMenuRadioItemElement = React.ElementRef<typeof MenuPrimitive.RadioItem>;\ntype MenuRadioItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioItem>;\ninterface ContextMenuRadioItemProps extends MenuRadioItemProps {}\n\nconst ContextMenuRadioItem = React.forwardRef<\n ContextMenuRadioItemElement,\n ContextMenuRadioItemProps\n>((props, forwardedRef) => <MenuPrimitive.RadioItem {...props} ref={forwardedRef} />);\n\nContextMenuRadioItem.displayName = RADIO_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuItemIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ContextMenuItemIndicator';\n\ntype ContextMenuItemIndicatorElement = React.ElementRef<typeof MenuPrimitive.ItemIndicator>;\ntype MenuItemIndicatorProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.ItemIndicator>;\ninterface ContextMenuItemIndicatorProps extends MenuItemIndicatorProps {}\n\nconst ContextMenuItemIndicator = React.forwardRef<\n ContextMenuItemIndicatorElement,\n ContextMenuItemIndicatorProps\n>((props, forwardedRef) => <MenuPrimitive.ItemIndicator {...props} ref={forwardedRef} />);\n\nContextMenuItemIndicator.displayName = INDICATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuSeparator\n * -----------------------------------------------------------------------------------------------*/\n\nconst SEPARATOR_NAME = 'ContextMenuSeparator';\n\ntype ContextMenuSeparatorElement = React.ElementRef<typeof MenuPrimitive.Separator>;\ntype MenuSeparatorProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Separator>;\ninterface ContextMenuSeparatorProps extends MenuSeparatorProps {}\n\nconst ContextMenuSeparator = React.forwardRef<\n ContextMenuSeparatorElement,\n ContextMenuSeparatorProps\n>((props, forwardedRef) => <MenuPrimitive.Separator {...props} ref={forwardedRef} />);\n\nContextMenuSeparator.displayName = SEPARATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'ContextMenuArrow';\n\ntype ContextMenuArrowElement = React.ElementRef<typeof MenuPrimitive.Arrow>;\ntype MenuArrowProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Arrow>;\ninterface ContextMenuArrowProps extends MenuArrowProps {}\n\nconst ContextMenuArrow = React.forwardRef<ContextMenuArrowElement, ContextMenuArrowProps>(\n (props, forwardedRef) => <MenuPrimitive.Arrow {...props} ref={forwardedRef} />\n);\n\nContextMenuArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction whenTouchOrPen<E>(handler: React.PointerEventHandler<E>): React.PointerEventHandler<E> {\n return (event) => (event.pointerType !== 'mouse' ? handler(event) : undefined);\n}\n\nconst Root = ContextMenu;\nconst Trigger = ContextMenuTrigger;\nconst Content = ContextMenuContent;\nconst Group = ContextMenuGroup;\nconst Label = ContextMenuLabel;\nconst Item = ContextMenuItem;\nconst TriggerItem = ContextMenuTriggerItem;\nconst CheckboxItem = ContextMenuCheckboxItem;\nconst RadioGroup = ContextMenuRadioGroup;\nconst RadioItem = ContextMenuRadioItem;\nconst ItemIndicator = ContextMenuItemIndicator;\nconst Separator = ContextMenuSeparator;\nconst Arrow = ContextMenuArrow;\n\nexport {\n ContextMenu,\n ContextMenuTrigger,\n ContextMenuContent,\n ContextMenuGroup,\n ContextMenuLabel,\n ContextMenuItem,\n ContextMenuTriggerItem,\n ContextMenuCheckboxItem,\n ContextMenuRadioGroup,\n ContextMenuRadioItem,\n ContextMenuItemIndicator,\n ContextMenuSeparator,\n ContextMenuArrow,\n //\n Root,\n Trigger,\n Content,\n Group,\n Label,\n Item,\n TriggerItem,\n CheckboxItem,\n RadioGroup,\n RadioItem,\n ItemIndicator,\n Separator,\n Arrow,\n};\nexport type {\n ContextMenuProps,\n ContextMenuTriggerProps,\n ContextMenuContentProps,\n ContextMenuGroupProps,\n ContextMenuLabelProps,\n ContextMenuItemProps,\n ContextMenuTriggerItemProps,\n ContextMenuCheckboxItemProps,\n ContextMenuRadioGroupProps,\n ContextMenuRadioItemProps,\n ContextMenuItemIndicatorProps,\n ContextMenuSeparatorProps,\n ContextMenuArrowProps,\n};\n"],"names":["a","__esModule","default","$parcel$exportWildcard","dest","source","Object","keys","forEach","key","defineProperty","enumerable","get","ContextMenuProvider","useContextMenuContext","createContext","ContextMenu","props","children","onOpenChange","dir","modal","open","setOpen","React","useState","isInsideContent","useContext","ContentContext","handleOpenChangeProp","useCallbackRef","handleOpenChange","useCallback","_react","createElement","$ffc34e43379ee114b0300eebc3d396c$var$ContextMenuProvider","isRootMenu","_radixUiReactMenu","Sub","Root","ContextMenuTrigger","forwardRef","forwardedRef","context","pointRef","useRef","x","y","virtualRef","getBoundingClientRect","DOMRect","fromRect","width","height","current","longPressTimerRef","clearLongPress","window","clearTimeout","handleOpen","event","clientX","clientY","useEffect","$ffc34e43379ee114b0300eebc3d396c$var$ContentContext","Provider","value","Anchor","Primitive","span","_babelRuntimeHelpersExtends","ref","style","WebkitTouchCallout","onContextMenu","composeEventHandlers","preventDefault","onPointerDown","whenTouchOrPen","setTimeout","onPointerMove","onPointerCancel","onPointerUp","ContextMenuContent","commonProps","$ffc34e43379ee114b0300eebc3d396c$var$ContextMenuRootContent","Content","ContextMenuRootContent","hasInteractedOutsideRef","portalled","side","sideOffset","align","onCloseAutoFocus","_props$onCloseAutoFoc","call","defaultPrevented","onInteractOutside","_props$onInteractOuts","ContextMenuGroup","Group","ContextMenuLabel","Label","ContextMenuItem","Item","ContextMenuTriggerItem","SubTrigger","ContextMenuCheckboxItem","CheckboxItem","ContextMenuRadioGroup","RadioGroup","ContextMenuRadioItem","RadioItem","ContextMenuItemIndicator","ItemIndicator","ContextMenuSeparator","Separator","ContextMenuArrow","Arrow","handler","pointerType","undefined","Trigger","TriggerItem"],"version":3,"file":"index.js.map"}
|
|
1
|
+
{"mappings":"IAAgCA,0TAAAA,8CAClBA,EAAEC,WAAaD,EAAEE,QAAUF,EAWzC,SAASG,EAAuBC,EAAMC,GAcpC,OAbAC,OAAOC,KAAKF,GAAQG,SAAQ,SAASC,GACvB,YAARA,GAA6B,eAARA,GAIzBH,OAAOI,eAAeN,EAAMK,EAAK,CAC/BE,YAAY,EACZC,IAAK,WACH,OAAOP,EAAOI,SAKbL,ECRT,MAGOS,EAA0BC,GAA0BC,EAHjC,cAGuE,CAC/FC,qCAEF,MAAMC,EAAeD,KASdE,EAAqBC,GAC1BN,EAhBwB,eAyBpBO,EAA2CC,IAC/C,MAAMC,mBAAEA,EAAFC,SAAsBA,EAAtBC,aAAgCA,EAAhCC,IAA8CA,EAA9CC,MAAmDA,GAAQ,GAASL,GACnEM,EAAMC,GAAWC,EAAMC,UAAS,GACjCC,EAAiBC,EA5BC,cA4BoCV,GACtDW,EAAYhB,EAAaK,GACzBY,EAAuBC,EAAeX,GAEtCY,EAAmBP,EAAMQ,aAC5BV,IACCC,EAAQD,GACRO,EAA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EAAaK,gBAC/B,OAAOiB,EAAAC,cAACI,EAAc4F,MAAf1F,EAAA,GAAyBb,EAAesG,EAAxC,CAAoD1D,IAAK3B,QAQpE,SAASkC,EAAkBqD,GACzB,OAAQpE,GAAiC,UAAtBA,EAAMqE,YAA0BD,EAAQpE,QAASsE,6BAGtE,MAAM5F,EAAO3B,iBACb,MAAMwH,EAAU5F,oBAChB,MAAM8C,EAAUJ,oBAChB,MAAMmB,EAAQF,kBACd,MAAMK,EAAQF,kBACd,MAAMK,EAAOF,iBACb,MAAM4B,EAAczB,wBACpB,MAAMK,EAAeF,yBACrB,MAAMK,EAAaF,uBACnB,MAAMK,EAAYF,sBAClB,MAAMK,EAAgBF,0BACtB,MAAMK,EAAYF,sBAClB,MAAMK,EAAQF","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/context-menu/src/ContextMenu.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as MenuPrimitive from '@radix-ui/react-menu';\nimport { createMenuScope } from '@radix-ui/react-menu';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\ntype Direction = 'ltr' | 'rtl';\ntype Point = { x: number; y: number };\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenu\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTEXT_MENU_NAME = 'ContextMenu';\n\ntype ScopedProps<P> = P & { __scopeContextMenu?: Scope };\nconst [createContextMenuContext, createContextMenuScope] = createContextScope(CONTEXT_MENU_NAME, [\n createMenuScope,\n]);\nconst useMenuScope = createMenuScope();\n\ntype ContextMenuContextValue = {\n isRootMenu: boolean;\n open: boolean;\n onOpenChange(open: boolean): void;\n modal: boolean;\n};\n\nconst [ContextMenuProvider, useContextMenuContext] =\n createContextMenuContext<ContextMenuContextValue>(CONTEXT_MENU_NAME);\n\ninterface ContextMenuProps {\n onOpenChange?(open: boolean): void;\n dir?: Direction;\n modal?: boolean;\n children?: React.ReactNode;\n}\n\nconst ContextMenu: React.FC<ContextMenuProps> = (props: ScopedProps<ContextMenuProps>) => {\n const { __scopeContextMenu, children, onOpenChange, dir, modal = true } = props;\n const [open, setOpen] = React.useState(false);\n const contentContext = useContentContext(CONTEXT_MENU_NAME, __scopeContextMenu);\n const menuScope = useMenuScope(__scopeContextMenu);\n const handleOpenChangeProp = useCallbackRef(onOpenChange);\n\n const handleOpenChange = React.useCallback(\n (open) => {\n setOpen(open);\n handleOpenChangeProp(open);\n },\n [handleOpenChangeProp]\n );\n\n return contentContext.isInsideContent ? (\n <ContextMenuProvider\n scope={__scopeContextMenu}\n isRootMenu={false}\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n >\n <MenuPrimitive.Sub {...menuScope} open={open} onOpenChange={handleOpenChange}>\n {children}\n </MenuPrimitive.Sub>\n </ContextMenuProvider>\n ) : (\n <ContextMenuProvider\n scope={__scopeContextMenu}\n isRootMenu={true}\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n >\n <MenuPrimitive.Root\n {...menuScope}\n dir={dir}\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n >\n {children}\n </MenuPrimitive.Root>\n </ContextMenuProvider>\n );\n};\n\nContextMenu.displayName = CONTEXT_MENU_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'ContextMenuTrigger';\n\ntype ContextMenuTriggerElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface ContextMenuTriggerProps extends PrimitiveSpanProps {}\n\nconst ContextMenuTrigger = React.forwardRef<ContextMenuTriggerElement, ContextMenuTriggerProps>(\n (props: ScopedProps<ContextMenuTriggerProps>, forwardedRef) => {\n const { __scopeContextMenu, ...triggerProps } = props;\n const context = useContextMenuContext(TRIGGER_NAME, __scopeContextMenu);\n const menuScope = useMenuScope(__scopeContextMenu);\n const pointRef = React.useRef<Point>({ x: 0, y: 0 });\n const virtualRef = React.useRef({\n getBoundingClientRect: () => DOMRect.fromRect({ width: 0, height: 0, ...pointRef.current }),\n });\n const longPressTimerRef = React.useRef(0);\n const clearLongPress = React.useCallback(\n () => window.clearTimeout(longPressTimerRef.current),\n []\n );\n const handleOpen = (event: React.MouseEvent | React.PointerEvent) => {\n pointRef.current = { x: event.clientX, y: event.clientY };\n context.onOpenChange(true);\n };\n\n React.useEffect(() => clearLongPress, [clearLongPress]);\n\n return (\n <ContentProvider scope={__scopeContextMenu} isInsideContent={false}>\n <MenuPrimitive.Anchor {...menuScope} virtualRef={virtualRef} />\n <Primitive.span\n {...triggerProps}\n ref={forwardedRef}\n // prevent iOS context menu from appearing\n style={{ WebkitTouchCallout: 'none', ...props.style }}\n onContextMenu={composeEventHandlers(props.onContextMenu, (event) => {\n // clearing the long press here because some platforms already support\n // long press to trigger a `contextmenu` event\n clearLongPress();\n event.preventDefault();\n handleOpen(event);\n })}\n onPointerDown={composeEventHandlers(\n props.onPointerDown,\n whenTouchOrPen((event) => {\n // clear the long press here in case there's multiple touch points\n clearLongPress();\n longPressTimerRef.current = window.setTimeout(() => handleOpen(event), 700);\n })\n )}\n onPointerMove={composeEventHandlers(props.onPointerMove, whenTouchOrPen(clearLongPress))}\n onPointerCancel={composeEventHandlers(\n props.onPointerCancel,\n whenTouchOrPen(clearLongPress)\n )}\n onPointerUp={composeEventHandlers(props.onPointerUp, whenTouchOrPen(clearLongPress))}\n />\n </ContentProvider>\n );\n }\n);\n\nContextMenuTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'ContextMenuContent';\n\nconst [ContentProvider, useContentContext] = createContextMenuContext(CONTENT_NAME, {\n isInsideContent: false,\n});\n\ntype ContextMenuContentElement = React.ElementRef<typeof MenuPrimitive.Content>;\ntype MenuContentProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Content>;\ninterface ContextMenuContentProps extends Omit<MenuContentProps, 'portalled' | 'side' | 'align'> {}\n\nconst ContextMenuContent = React.forwardRef<ContextMenuContentElement, ContextMenuContentProps>(\n (props: ScopedProps<ContextMenuContentProps>, forwardedRef) => {\n const { __scopeContextMenu, ...contentProps } = props;\n const context = useContextMenuContext(CONTENT_NAME, __scopeContextMenu);\n const menuScope = useMenuScope(__scopeContextMenu);\n\n const commonProps = {\n ...contentProps,\n style: {\n ...props.style,\n // re-namespace exposed content custom property\n ['--radix-context-menu-content-transform-origin' as any]:\n 'var(--radix-popper-transform-origin)',\n },\n };\n\n return (\n <ContentProvider scope={__scopeContextMenu} isInsideContent={true}>\n {context.isRootMenu ? (\n <ContextMenuRootContent\n __scopeContextMenu={__scopeContextMenu}\n {...commonProps}\n ref={forwardedRef}\n />\n ) : (\n <MenuPrimitive.Content {...menuScope} {...commonProps} ref={forwardedRef} />\n )}\n </ContentProvider>\n );\n }\n);\n\nContextMenuContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype ContextMenuRootContentElement = React.ElementRef<typeof MenuPrimitive.Content>;\ninterface ContextMenuRootContentProps extends ScopedProps<MenuContentProps> {}\n\nconst ContextMenuRootContent = React.forwardRef<\n ContextMenuRootContentElement,\n ContextMenuRootContentProps\n>((props, forwardedRef) => {\n const { __scopeContextMenu, ...contentProps } = props;\n const context = useContextMenuContext(CONTENT_NAME, __scopeContextMenu);\n const menuScope = useMenuScope(__scopeContextMenu);\n const hasInteractedOutsideRef = React.useRef(false);\n return (\n <MenuPrimitive.Content\n {...menuScope}\n {...contentProps}\n ref={forwardedRef}\n portalled\n side=\"right\"\n sideOffset={2}\n align=\"start\"\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented && hasInteractedOutsideRef.current) {\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented && !context.modal) hasInteractedOutsideRef.current = true;\n }}\n />\n );\n});\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst GROUP_NAME = 'ContextMenuGroup';\n\ntype ContextMenuGroupElement = React.ElementRef<typeof MenuPrimitive.Group>;\ntype MenuGroupProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Group>;\ninterface ContextMenuGroupProps extends MenuGroupProps {}\n\nconst ContextMenuGroup = React.forwardRef<ContextMenuGroupElement, ContextMenuGroupProps>(\n (props: ScopedProps<ContextMenuGroupProps>, forwardedRef) => {\n const { __scopeContextMenu, ...groupProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.Group {...menuScope} {...groupProps} ref={forwardedRef} />;\n }\n);\n\nContextMenuGroup.displayName = GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuLabel\n * -----------------------------------------------------------------------------------------------*/\n\nconst LABEL_NAME = 'ContextMenuLabel';\n\ntype ContextMenuLabelElement = React.ElementRef<typeof MenuPrimitive.Label>;\ntype MenuLabelProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Label>;\ninterface ContextMenuLabelProps extends MenuLabelProps {}\n\nconst ContextMenuLabel = React.forwardRef<ContextMenuLabelElement, ContextMenuLabelProps>(\n (props: ScopedProps<ContextMenuLabelProps>, forwardedRef) => {\n const { __scopeContextMenu, ...labelProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.Label {...menuScope} {...labelProps} ref={forwardedRef} />;\n }\n);\n\nContextMenuLabel.displayName = LABEL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'ContextMenuItem';\n\ntype ContextMenuItemElement = React.ElementRef<typeof MenuPrimitive.Item>;\ntype MenuItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Item>;\ninterface ContextMenuItemProps extends MenuItemProps {}\n\nconst ContextMenuItem = React.forwardRef<ContextMenuItemElement, ContextMenuItemProps>(\n (props: ScopedProps<ContextMenuItemProps>, forwardedRef) => {\n const { __scopeContextMenu, ...itemProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.Item {...menuScope} {...itemProps} ref={forwardedRef} />;\n }\n);\n\nContextMenuItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuTriggerItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_ITEM_NAME = 'ContextMenuTriggerItem';\n\ntype ContextMenuTriggerItemElement = React.ElementRef<typeof MenuPrimitive.SubTrigger>;\ntype MenuSubTriggerProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.SubTrigger>;\ninterface ContextMenuTriggerItemProps extends MenuSubTriggerProps {}\n\nconst ContextMenuTriggerItem = React.forwardRef<\n ContextMenuTriggerItemElement,\n ContextMenuTriggerItemProps\n>((props: ScopedProps<ContextMenuTriggerItemProps>, forwardedRef) => {\n const { __scopeContextMenu, ...triggerItemProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.SubTrigger {...menuScope} {...triggerItemProps} ref={forwardedRef} />;\n});\n\nContextMenuTriggerItem.displayName = TRIGGER_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuCheckboxItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst CHECKBOX_ITEM_NAME = 'ContextMenuCheckboxItem';\n\ntype ContextMenuCheckboxItemElement = React.ElementRef<typeof MenuPrimitive.CheckboxItem>;\ntype MenuCheckboxItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.CheckboxItem>;\ninterface ContextMenuCheckboxItemProps extends MenuCheckboxItemProps {}\n\nconst ContextMenuCheckboxItem = React.forwardRef<\n ContextMenuCheckboxItemElement,\n ContextMenuCheckboxItemProps\n>((props: ScopedProps<ContextMenuCheckboxItemProps>, forwardedRef) => {\n const { __scopeContextMenu, ...checkboxItemProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.CheckboxItem {...menuScope} {...checkboxItemProps} ref={forwardedRef} />;\n});\n\nContextMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuRadioGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_GROUP_NAME = 'ContextMenuRadioGroup';\n\ntype ContextMenuRadioGroupElement = React.ElementRef<typeof MenuPrimitive.RadioGroup>;\ntype MenuRadioGroupProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioGroup>;\ninterface ContextMenuRadioGroupProps extends MenuRadioGroupProps {}\n\nconst ContextMenuRadioGroup = React.forwardRef<\n ContextMenuRadioGroupElement,\n ContextMenuRadioGroupProps\n>((props: ScopedProps<ContextMenuRadioGroupProps>, forwardedRef) => {\n const { __scopeContextMenu, ...radioGroupProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.RadioGroup {...menuScope} {...radioGroupProps} ref={forwardedRef} />;\n});\n\nContextMenuRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuRadioItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_ITEM_NAME = 'ContextMenuRadioItem';\n\ntype ContextMenuRadioItemElement = React.ElementRef<typeof MenuPrimitive.RadioItem>;\ntype MenuRadioItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioItem>;\ninterface ContextMenuRadioItemProps extends MenuRadioItemProps {}\n\nconst ContextMenuRadioItem = React.forwardRef<\n ContextMenuRadioItemElement,\n ContextMenuRadioItemProps\n>((props: ScopedProps<ContextMenuRadioItemProps>, forwardedRef) => {\n const { __scopeContextMenu, ...radioItemProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.RadioItem {...menuScope} {...radioItemProps} ref={forwardedRef} />;\n});\n\nContextMenuRadioItem.displayName = RADIO_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuItemIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ContextMenuItemIndicator';\n\ntype ContextMenuItemIndicatorElement = React.ElementRef<typeof MenuPrimitive.ItemIndicator>;\ntype MenuItemIndicatorProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.ItemIndicator>;\ninterface ContextMenuItemIndicatorProps extends MenuItemIndicatorProps {}\n\nconst ContextMenuItemIndicator = React.forwardRef<\n ContextMenuItemIndicatorElement,\n ContextMenuItemIndicatorProps\n>((props: ScopedProps<ContextMenuItemIndicatorProps>, forwardedRef) => {\n const { __scopeContextMenu, ...itemIndicatorProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.ItemIndicator {...menuScope} {...itemIndicatorProps} ref={forwardedRef} />;\n});\n\nContextMenuItemIndicator.displayName = INDICATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuSeparator\n * -----------------------------------------------------------------------------------------------*/\n\nconst SEPARATOR_NAME = 'ContextMenuSeparator';\n\ntype ContextMenuSeparatorElement = React.ElementRef<typeof MenuPrimitive.Separator>;\ntype MenuSeparatorProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Separator>;\ninterface ContextMenuSeparatorProps extends MenuSeparatorProps {}\n\nconst ContextMenuSeparator = React.forwardRef<\n ContextMenuSeparatorElement,\n ContextMenuSeparatorProps\n>((props: ScopedProps<ContextMenuSeparatorProps>, forwardedRef) => {\n const { __scopeContextMenu, ...separatorProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.Separator {...menuScope} {...separatorProps} ref={forwardedRef} />;\n});\n\nContextMenuSeparator.displayName = SEPARATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'ContextMenuArrow';\n\ntype ContextMenuArrowElement = React.ElementRef<typeof MenuPrimitive.Arrow>;\ntype MenuArrowProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Arrow>;\ninterface ContextMenuArrowProps extends MenuArrowProps {}\n\nconst ContextMenuArrow = React.forwardRef<ContextMenuArrowElement, ContextMenuArrowProps>(\n (props: ScopedProps<ContextMenuArrowProps>, forwardedRef) => {\n const { __scopeContextMenu, ...arrowProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.Arrow {...menuScope} {...arrowProps} ref={forwardedRef} />;\n }\n);\n\nContextMenuArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction whenTouchOrPen<E>(handler: React.PointerEventHandler<E>): React.PointerEventHandler<E> {\n return (event) => (event.pointerType !== 'mouse' ? handler(event) : undefined);\n}\n\nconst Root = ContextMenu;\nconst Trigger = ContextMenuTrigger;\nconst Content = ContextMenuContent;\nconst Group = ContextMenuGroup;\nconst Label = ContextMenuLabel;\nconst Item = ContextMenuItem;\nconst TriggerItem = ContextMenuTriggerItem;\nconst CheckboxItem = ContextMenuCheckboxItem;\nconst RadioGroup = ContextMenuRadioGroup;\nconst RadioItem = ContextMenuRadioItem;\nconst ItemIndicator = ContextMenuItemIndicator;\nconst Separator = ContextMenuSeparator;\nconst Arrow = ContextMenuArrow;\n\nexport {\n createContextMenuScope,\n //\n ContextMenu,\n ContextMenuTrigger,\n ContextMenuContent,\n ContextMenuGroup,\n ContextMenuLabel,\n ContextMenuItem,\n ContextMenuTriggerItem,\n ContextMenuCheckboxItem,\n ContextMenuRadioGroup,\n ContextMenuRadioItem,\n ContextMenuItemIndicator,\n ContextMenuSeparator,\n ContextMenuArrow,\n //\n Root,\n Trigger,\n Content,\n Group,\n Label,\n Item,\n TriggerItem,\n CheckboxItem,\n RadioGroup,\n RadioItem,\n ItemIndicator,\n Separator,\n Arrow,\n};\nexport type {\n ContextMenuProps,\n ContextMenuTriggerProps,\n ContextMenuContentProps,\n ContextMenuGroupProps,\n ContextMenuLabelProps,\n ContextMenuItemProps,\n ContextMenuTriggerItemProps,\n ContextMenuCheckboxItemProps,\n ContextMenuRadioGroupProps,\n ContextMenuRadioItemProps,\n ContextMenuItemIndicatorProps,\n ContextMenuSeparatorProps,\n ContextMenuArrowProps,\n};\n"],"names":["a","__esModule","default","$parcel$exportWildcard","dest","source","Object","keys","forEach","key","defineProperty","enumerable","get","createContextMenuContext","createContextMenuScope","createContextScope","createMenuScope","useMenuScope","ContextMenuProvider","useContextMenuContext","ContextMenu","props","__scopeContextMenu","children","onOpenChange","dir","modal","open","setOpen","React","useState","contentContext","useContentContext","menuScope","handleOpenChangeProp","useCallbackRef","handleOpenChange","useCallback","isInsideContent","_react","createElement","$ffc34e43379ee114b0300eebc3d396c$var$ContextMenuProvider","scope","isRootMenu","_radixUiReactMenu","Sub","_babelRuntimeHelpersExtends","Root","ContextMenuTrigger","forwardRef","forwardedRef","triggerProps","context","pointRef","useRef","x","y","virtualRef","getBoundingClientRect","DOMRect","fromRect","width","height","current","longPressTimerRef","clearLongPress","window","clearTimeout","handleOpen","event","clientX","clientY","useEffect","$ffc34e43379ee114b0300eebc3d396c$var$ContentProvider","Anchor","Primitive","span","ref","style","WebkitTouchCallout","onContextMenu","composeEventHandlers","preventDefault","onPointerDown","whenTouchOrPen","setTimeout","onPointerMove","onPointerCancel","onPointerUp","ContentProvider","ContextMenuContent","contentProps","commonProps","$ffc34e43379ee114b0300eebc3d396c$var$ContextMenuRootContent","Content","ContextMenuRootContent","hasInteractedOutsideRef","portalled","side","sideOffset","align","onCloseAutoFocus","_props$onCloseAutoFoc","call","defaultPrevented","onInteractOutside","_props$onInteractOuts","ContextMenuGroup","groupProps","Group","ContextMenuLabel","labelProps","Label","ContextMenuItem","itemProps","Item","ContextMenuTriggerItem","triggerItemProps","SubTrigger","ContextMenuCheckboxItem","checkboxItemProps","CheckboxItem","ContextMenuRadioGroup","radioGroupProps","RadioGroup","ContextMenuRadioItem","radioItemProps","RadioItem","ContextMenuItemIndicator","itemIndicatorProps","ItemIndicator","ContextMenuSeparator","separatorProps","Separator","ContextMenuArrow","arrowProps","Arrow","handler","pointerType","undefined","Trigger","TriggerItem"],"version":3,"file":"index.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useCallbackRef as e}from"@radix-ui/react-use-callback-ref";import*as t from"@radix-ui/react-menu";import{Primitive as o}from"@radix-ui/react-primitive";import{
|
|
1
|
+
import{useCallbackRef as e}from"@radix-ui/react-use-callback-ref";import*as t from"@radix-ui/react-menu";import{createMenuScope as n}from"@radix-ui/react-menu";import{Primitive as o}from"@radix-ui/react-primitive";import{createContextScope as r}from"@radix-ui/react-context";import{composeEventHandlers as c}from"@radix-ui/primitive";import*as u from"react";import a from"@babel/runtime/helpers/esm/extends";const[s,i]=r("ContextMenu",[n]);export{i as createContextMenuScope};const x=n(),[p,C]=s("ContextMenu");export const ContextMenu=n=>{const{__scopeContextMenu:o,children:r,onOpenChange:c,dir:s,modal:i=!0}=n,[C,m]=u.useState(!1),f=l("ContextMenu",o),d=x(o),M=e(c),R=u.useCallback((e=>{m(e),M(e)}),[M]);return f.isInsideContent?/*#__PURE__*/u.createElement(p,{scope:o,isRootMenu:!1,open:C,onOpenChange:R,modal:i},/*#__PURE__*/u.createElement(t.Sub,a({},d,{open:C,onOpenChange:R}),r)):/*#__PURE__*/u.createElement(p,{scope:o,isRootMenu:!0,open:C,onOpenChange:R,modal:i},/*#__PURE__*/u.createElement(t.Root,a({},d,{dir:s,open:C,onOpenChange:R,modal:i}),r))};/*#__PURE__*/export const ContextMenuTrigger=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:r,...s}=e,i=C("ContextMenuTrigger",r),p=x(r),l=u.useRef({x:0,y:0}),f=u.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),M=u.useRef(0),R=u.useCallback((()=>window.clearTimeout(M.current)),[]),_=e=>{l.current={x:e.clientX,y:e.clientY},i.onOpenChange(!0)};return u.useEffect((()=>R),[R]),/*#__PURE__*/u.createElement(m,{scope:r,isInsideContent:!1},/*#__PURE__*/u.createElement(t.Anchor,a({},p,{virtualRef:f})),/*#__PURE__*/u.createElement(o.span,a({},s,{ref:n,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:c(e.onContextMenu,(e=>{R(),e.preventDefault(),_(e)})),onPointerDown:c(e.onPointerDown,d((e=>{R(),M.current=window.setTimeout((()=>_(e)),700)}))),onPointerMove:c(e.onPointerMove,d(R)),onPointerCancel:c(e.onPointerCancel,d(R)),onPointerUp:c(e.onPointerUp,d(R))})))}));/*#__PURE__*/const[m,l]=s("ContextMenuContent",{isInsideContent:!1});export const ContextMenuContent=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=C("ContextMenuContent",o),s=x(o),i={...r,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)"}};/*#__PURE__*/return u.createElement(m,{scope:o,isInsideContent:!0},c.isRootMenu?/*#__PURE__*/u.createElement(f,a({__scopeContextMenu:o},i,{ref:n})):/*#__PURE__*/u.createElement(t.Content,a({},s,i,{ref:n})))}));/*#__PURE__*/const f=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=C("ContextMenuContent",o),s=x(o),i=u.useRef(!1);/*#__PURE__*/return u.createElement(t.Content,a({},s,r,{ref:n,portalled:!0,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var n;null===(n=e.onCloseAutoFocus)||void 0===n||n.call(e,t),!t.defaultPrevented&&i.current&&t.preventDefault(),i.current=!1},onInteractOutside:t=>{var n;null===(n=e.onInteractOutside)||void 0===n||n.call(e,t),t.defaultPrevented||c.modal||(i.current=!0)}}))}));export const ContextMenuGroup=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=x(o);/*#__PURE__*/return u.createElement(t.Group,a({},c,r,{ref:n}))}));/*#__PURE__*/export const ContextMenuLabel=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=x(o);/*#__PURE__*/return u.createElement(t.Label,a({},c,r,{ref:n}))}));/*#__PURE__*/export const ContextMenuItem=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=x(o);/*#__PURE__*/return u.createElement(t.Item,a({},c,r,{ref:n}))}));/*#__PURE__*/export const ContextMenuTriggerItem=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=x(o);/*#__PURE__*/return u.createElement(t.SubTrigger,a({},c,r,{ref:n}))}));/*#__PURE__*/export const ContextMenuCheckboxItem=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=x(o);/*#__PURE__*/return u.createElement(t.CheckboxItem,a({},c,r,{ref:n}))}));/*#__PURE__*/export const ContextMenuRadioGroup=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=x(o);/*#__PURE__*/return u.createElement(t.RadioGroup,a({},c,r,{ref:n}))}));/*#__PURE__*/export const ContextMenuRadioItem=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=x(o);/*#__PURE__*/return u.createElement(t.RadioItem,a({},c,r,{ref:n}))}));/*#__PURE__*/export const ContextMenuItemIndicator=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=x(o);/*#__PURE__*/return u.createElement(t.ItemIndicator,a({},c,r,{ref:n}))}));/*#__PURE__*/export const ContextMenuSeparator=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=x(o);/*#__PURE__*/return u.createElement(t.Separator,a({},c,r,{ref:n}))}));/*#__PURE__*/export const ContextMenuArrow=/*#__PURE__*/u.forwardRef(((e,n)=>{const{__scopeContextMenu:o,...r}=e,c=x(o);/*#__PURE__*/return u.createElement(t.Arrow,a({},c,r,{ref:n}))}));/*#__PURE__*/function d(e){return t=>"mouse"!==t.pointerType?e(t):void 0}export const Root=ContextMenu;export const Trigger=ContextMenuTrigger;export const Content=ContextMenuContent;export const Group=ContextMenuGroup;export const Label=ContextMenuLabel;export const Item=ContextMenuItem;export const TriggerItem=ContextMenuTriggerItem;export const CheckboxItem=ContextMenuCheckboxItem;export const RadioGroup=ContextMenuRadioGroup;export const RadioItem=ContextMenuRadioItem;export const ItemIndicator=ContextMenuItemIndicator;export const Separator=ContextMenuSeparator;export const Arrow=ContextMenuArrow;
|
|
2
2
|
//# sourceMappingURL=index.module.js.map
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"4VAgBA,MASOA,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sD,IAAK7B,2BAcpE,MAAMuE,sCAA2BzF,EAAMiB,YAGrC,CAACxB,EAAOyB,iBAAiBT,EAAAC,cAACG,EAAc6E,cAAf5C,EAAA,GAAiCrD,EAAjC,CAAwCsD,IAAK7B,2BAcxE,MAAMyE,kCAAuB3F,EAAMiB,YAGjC,CAACxB,EAAOyB,iBAAiBT,EAAAC,cAACG,EAAc+E,UAAf9C,EAAA,GAA6BrD,EAA7B,CAAoCsD,IAAK7B,2BAcpE,MAAM2E,8BAAmB7F,EAAMiB,YAC7B,CAACxB,EAAOyB,iBAAiBT,EAAAC,cAACG,EAAciF,MAAfhD,EAAA,GAAyBrD,EAAzB,CAAgCsD,IAAK7B,oBAOhE,SAASoC,EAAkByC,GACzB,OAAQ3D,GAAiC,UAAtBA,EAAM4D,YAA0BD,EAAQ3D,QAAS6D,SAGtE,MAAMlF,KAAOvB,mBACb,MAAM0G,QAAUlF,0BAChB,MAAM8C,QAAUH,0BAChB,MAAMiB,MAAQD,wBACd,MAAMG,MAAQD,wBACd,MAAMG,KAAOD,uBACb,MAAMoB,YAAclB,8BACpB,MAAMG,aAAeD,+BACrB,MAAMG,WAAaD,6BACnB,MAAMG,UAAYD,4BAClB,MAAMG,cAAgBD,gCACtB,MAAMG,UAAYD,4BAClB,MAAMG,MAAQD","sources":["./packages/react/context-menu/src/ContextMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContext } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as MenuPrimitive from '@radix-ui/react-menu';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\ntype Direction = 'ltr' | 'rtl';\ntype Point = { x: number; y: number };\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenu\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTEXT_MENU_NAME = 'ContextMenu';\n\ntype ContextMenuContextValue = {\n isRootMenu: boolean;\n open: boolean;\n onOpenChange(open: boolean): void;\n modal: boolean;\n};\n\nconst [ContextMenuProvider, useContextMenuContext] =\n createContext<ContextMenuContextValue>(CONTEXT_MENU_NAME);\n\ninterface ContextMenuProps {\n onOpenChange?(open: boolean): void;\n dir?: Direction;\n modal?: boolean;\n}\n\nconst ContextMenu: React.FC<ContextMenuProps> = (props) => {\n const { children, onOpenChange, dir, modal = true } = props;\n const [open, setOpen] = React.useState(false);\n const isInsideContent = React.useContext(ContentContext);\n const handleOpenChangeProp = useCallbackRef(onOpenChange);\n\n const handleOpenChange = React.useCallback(\n (open) => {\n setOpen(open);\n handleOpenChangeProp(open);\n },\n [handleOpenChangeProp]\n );\n\n return isInsideContent ? (\n <ContextMenuProvider\n isRootMenu={false}\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n >\n <MenuPrimitive.Sub open={open} onOpenChange={handleOpenChange}>\n {children}\n </MenuPrimitive.Sub>\n </ContextMenuProvider>\n ) : (\n <ContextMenuProvider\n isRootMenu={true}\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n >\n <MenuPrimitive.Root dir={dir} open={open} onOpenChange={handleOpenChange} modal={modal}>\n {children}\n </MenuPrimitive.Root>\n </ContextMenuProvider>\n );\n};\n\nContextMenu.displayName = CONTEXT_MENU_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'ContextMenuTrigger';\n\ntype ContextMenuTriggerElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface ContextMenuTriggerProps extends PrimitiveSpanProps {}\n\nconst ContextMenuTrigger = React.forwardRef<ContextMenuTriggerElement, ContextMenuTriggerProps>(\n (props, forwardedRef) => {\n const context = useContextMenuContext(TRIGGER_NAME);\n const pointRef = React.useRef<Point>({ x: 0, y: 0 });\n const virtualRef = React.useRef({\n getBoundingClientRect: () => DOMRect.fromRect({ width: 0, height: 0, ...pointRef.current }),\n });\n const longPressTimerRef = React.useRef(0);\n const clearLongPress = React.useCallback(\n () => window.clearTimeout(longPressTimerRef.current),\n []\n );\n const handleOpen = (event: React.MouseEvent | React.PointerEvent) => {\n pointRef.current = { x: event.clientX, y: event.clientY };\n context.onOpenChange(true);\n };\n\n React.useEffect(() => clearLongPress, [clearLongPress]);\n\n return (\n <ContentContext.Provider value={false}>\n <MenuPrimitive.Anchor virtualRef={virtualRef} />\n <Primitive.span\n {...props}\n ref={forwardedRef}\n // prevent iOS context menu from appearing\n style={{ WebkitTouchCallout: 'none', ...props.style }}\n onContextMenu={composeEventHandlers(props.onContextMenu, (event) => {\n // clearing the long press here because some platforms already support\n // long press to trigger a `contextmenu` event\n clearLongPress();\n event.preventDefault();\n handleOpen(event);\n })}\n onPointerDown={composeEventHandlers(\n props.onPointerDown,\n whenTouchOrPen((event) => {\n // clear the long press here in case there's multiple touch points\n clearLongPress();\n longPressTimerRef.current = window.setTimeout(() => handleOpen(event), 700);\n })\n )}\n onPointerMove={composeEventHandlers(props.onPointerMove, whenTouchOrPen(clearLongPress))}\n onPointerCancel={composeEventHandlers(\n props.onPointerCancel,\n whenTouchOrPen(clearLongPress)\n )}\n onPointerUp={composeEventHandlers(props.onPointerUp, whenTouchOrPen(clearLongPress))}\n />\n </ContentContext.Provider>\n );\n }\n);\n\nContextMenuTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'ContextMenuContent';\n\nconst ContentContext = React.createContext(false);\n\ntype ContextMenuContentElement = React.ElementRef<typeof MenuPrimitive.Content>;\ntype MenuContentProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Content>;\ninterface ContextMenuContentProps extends Omit<MenuContentProps, 'portalled' | 'side' | 'align'> {}\n\nconst ContextMenuContent = React.forwardRef<ContextMenuContentElement, ContextMenuContentProps>(\n (props, forwardedRef) => {\n const context = useContextMenuContext(CONTENT_NAME);\n\n const commonProps = {\n ...props,\n style: {\n ...props.style,\n // re-namespace exposed content custom property\n ['--radix-context-menu-content-transform-origin' as any]:\n 'var(--radix-popper-transform-origin)',\n },\n };\n\n return (\n <ContentContext.Provider value={true}>\n {context.isRootMenu ? (\n <ContextMenuRootContent {...commonProps} ref={forwardedRef} />\n ) : (\n <MenuPrimitive.Content {...commonProps} ref={forwardedRef} />\n )}\n </ContentContext.Provider>\n );\n }\n);\n\nContextMenuContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype ContextMenuRootContentElement = React.ElementRef<typeof MenuPrimitive.Content>;\ninterface ContextMenuRootContentProps extends MenuContentProps {}\n\nconst ContextMenuRootContent = React.forwardRef<\n ContextMenuRootContentElement,\n ContextMenuRootContentProps\n>((props, forwardedRef) => {\n const context = useContextMenuContext(CONTENT_NAME);\n const hasInteractedOutsideRef = React.useRef(false);\n return (\n <MenuPrimitive.Content\n {...props}\n ref={forwardedRef}\n portalled\n side=\"right\"\n sideOffset={2}\n align=\"start\"\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented && hasInteractedOutsideRef.current) {\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented && !context.modal) hasInteractedOutsideRef.current = true;\n }}\n />\n );\n});\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst GROUP_NAME = 'ContextMenuGroup';\n\ntype ContextMenuGroupElement = React.ElementRef<typeof MenuPrimitive.Group>;\ntype MenuGroupProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Group>;\ninterface ContextMenuGroupProps extends MenuGroupProps {}\n\nconst ContextMenuGroup = React.forwardRef<ContextMenuGroupElement, ContextMenuGroupProps>(\n (props, forwardedRef) => <MenuPrimitive.Group {...props} ref={forwardedRef} />\n);\n\nContextMenuGroup.displayName = GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuLabel\n * -----------------------------------------------------------------------------------------------*/\n\nconst LABEL_NAME = 'ContextMenuLabel';\n\ntype ContextMenuLabelElement = React.ElementRef<typeof MenuPrimitive.Label>;\ntype MenuLabelProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Label>;\ninterface ContextMenuLabelProps extends MenuLabelProps {}\n\nconst ContextMenuLabel = React.forwardRef<ContextMenuLabelElement, ContextMenuLabelProps>(\n (props, forwardedRef) => <MenuPrimitive.Label {...props} ref={forwardedRef} />\n);\n\nContextMenuLabel.displayName = LABEL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'ContextMenuItem';\n\ntype ContextMenuItemElement = React.ElementRef<typeof MenuPrimitive.Item>;\ntype MenuItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Item>;\ninterface ContextMenuItemProps extends MenuItemProps {}\n\nconst ContextMenuItem = React.forwardRef<ContextMenuItemElement, ContextMenuItemProps>(\n (props, forwardedRef) => <MenuPrimitive.Item {...props} ref={forwardedRef} />\n);\n\nContextMenuItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuTriggerItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_ITEM_NAME = 'ContextMenuTriggerItem';\n\ntype ContextMenuTriggerItemElement = React.ElementRef<typeof MenuPrimitive.SubTrigger>;\ntype MenuSubTriggerProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.SubTrigger>;\ninterface ContextMenuTriggerItemProps extends MenuSubTriggerProps {}\n\nconst ContextMenuTriggerItem = React.forwardRef<\n ContextMenuTriggerItemElement,\n ContextMenuTriggerItemProps\n>((props, forwardedRef) => <MenuPrimitive.SubTrigger {...props} ref={forwardedRef} />);\n\nContextMenuTriggerItem.displayName = TRIGGER_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuCheckboxItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst CHECKBOX_ITEM_NAME = 'ContextMenuCheckboxItem';\n\ntype ContextMenuCheckboxItemElement = React.ElementRef<typeof MenuPrimitive.CheckboxItem>;\ntype MenuCheckboxItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.CheckboxItem>;\ninterface ContextMenuCheckboxItemProps extends MenuCheckboxItemProps {}\n\nconst ContextMenuCheckboxItem = React.forwardRef<\n ContextMenuCheckboxItemElement,\n ContextMenuCheckboxItemProps\n>((props, forwardedRef) => <MenuPrimitive.CheckboxItem {...props} ref={forwardedRef} />);\n\nContextMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuRadioGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_GROUP_NAME = 'ContextMenuRadioGroup';\n\ntype ContextMenuRadioGroupElement = React.ElementRef<typeof MenuPrimitive.RadioGroup>;\ntype MenuRadioGroupProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioGroup>;\ninterface ContextMenuRadioGroupProps extends MenuRadioGroupProps {}\n\nconst ContextMenuRadioGroup = React.forwardRef<\n ContextMenuRadioGroupElement,\n ContextMenuRadioGroupProps\n>((props, forwardedRef) => <MenuPrimitive.RadioGroup {...props} ref={forwardedRef} />);\n\nContextMenuRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuRadioItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_ITEM_NAME = 'ContextMenuRadioItem';\n\ntype ContextMenuRadioItemElement = React.ElementRef<typeof MenuPrimitive.RadioItem>;\ntype MenuRadioItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioItem>;\ninterface ContextMenuRadioItemProps extends MenuRadioItemProps {}\n\nconst ContextMenuRadioItem = React.forwardRef<\n ContextMenuRadioItemElement,\n ContextMenuRadioItemProps\n>((props, forwardedRef) => <MenuPrimitive.RadioItem {...props} ref={forwardedRef} />);\n\nContextMenuRadioItem.displayName = RADIO_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuItemIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ContextMenuItemIndicator';\n\ntype ContextMenuItemIndicatorElement = React.ElementRef<typeof MenuPrimitive.ItemIndicator>;\ntype MenuItemIndicatorProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.ItemIndicator>;\ninterface ContextMenuItemIndicatorProps extends MenuItemIndicatorProps {}\n\nconst ContextMenuItemIndicator = React.forwardRef<\n ContextMenuItemIndicatorElement,\n ContextMenuItemIndicatorProps\n>((props, forwardedRef) => <MenuPrimitive.ItemIndicator {...props} ref={forwardedRef} />);\n\nContextMenuItemIndicator.displayName = INDICATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuSeparator\n * -----------------------------------------------------------------------------------------------*/\n\nconst SEPARATOR_NAME = 'ContextMenuSeparator';\n\ntype ContextMenuSeparatorElement = React.ElementRef<typeof MenuPrimitive.Separator>;\ntype MenuSeparatorProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Separator>;\ninterface ContextMenuSeparatorProps extends MenuSeparatorProps {}\n\nconst ContextMenuSeparator = React.forwardRef<\n ContextMenuSeparatorElement,\n ContextMenuSeparatorProps\n>((props, forwardedRef) => <MenuPrimitive.Separator {...props} ref={forwardedRef} />);\n\nContextMenuSeparator.displayName = SEPARATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'ContextMenuArrow';\n\ntype ContextMenuArrowElement = React.ElementRef<typeof MenuPrimitive.Arrow>;\ntype MenuArrowProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Arrow>;\ninterface ContextMenuArrowProps extends MenuArrowProps {}\n\nconst ContextMenuArrow = React.forwardRef<ContextMenuArrowElement, ContextMenuArrowProps>(\n (props, forwardedRef) => <MenuPrimitive.Arrow {...props} ref={forwardedRef} />\n);\n\nContextMenuArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction whenTouchOrPen<E>(handler: React.PointerEventHandler<E>): React.PointerEventHandler<E> {\n return (event) => (event.pointerType !== 'mouse' ? handler(event) : undefined);\n}\n\nconst Root = ContextMenu;\nconst Trigger = ContextMenuTrigger;\nconst Content = ContextMenuContent;\nconst Group = ContextMenuGroup;\nconst Label = ContextMenuLabel;\nconst Item = ContextMenuItem;\nconst TriggerItem = ContextMenuTriggerItem;\nconst CheckboxItem = ContextMenuCheckboxItem;\nconst RadioGroup = ContextMenuRadioGroup;\nconst RadioItem = ContextMenuRadioItem;\nconst ItemIndicator = ContextMenuItemIndicator;\nconst Separator = ContextMenuSeparator;\nconst Arrow = ContextMenuArrow;\n\nexport {\n ContextMenu,\n ContextMenuTrigger,\n ContextMenuContent,\n ContextMenuGroup,\n ContextMenuLabel,\n ContextMenuItem,\n ContextMenuTriggerItem,\n ContextMenuCheckboxItem,\n ContextMenuRadioGroup,\n ContextMenuRadioItem,\n ContextMenuItemIndicator,\n ContextMenuSeparator,\n ContextMenuArrow,\n //\n Root,\n Trigger,\n Content,\n Group,\n Label,\n Item,\n TriggerItem,\n CheckboxItem,\n RadioGroup,\n RadioItem,\n ItemIndicator,\n Separator,\n Arrow,\n};\nexport type {\n ContextMenuProps,\n ContextMenuTriggerProps,\n ContextMenuContentProps,\n ContextMenuGroupProps,\n ContextMenuLabelProps,\n ContextMenuItemProps,\n ContextMenuTriggerItemProps,\n ContextMenuCheckboxItemProps,\n ContextMenuRadioGroupProps,\n ContextMenuRadioItemProps,\n ContextMenuItemIndicatorProps,\n ContextMenuSeparatorProps,\n ContextMenuArrowProps,\n};\n"],"names":["ContextMenuProvider","useContextMenuContext","createContext","ContextMenu","props","children","onOpenChange","dir","modal","open","setOpen","React","useState","isInsideContent","useContext","ContentContext","handleOpenChangeProp","useCallbackRef","handleOpenChange","useCallback","_react","createElement","$b55f3d34bcc87b2d9b0bc87c90588a09$var$ContextMenuProvider","isRootMenu","_radixUiReactMenu","Sub","Root","ContextMenuTrigger","forwardRef","forwardedRef","context","pointRef","useRef","x","y","virtualRef","getBoundingClientRect","DOMRect","fromRect","width","height","current","longPressTimerRef","clearLongPress","window","clearTimeout","handleOpen","event","clientX","clientY","useEffect","$b55f3d34bcc87b2d9b0bc87c90588a09$var$ContentContext","Provider","value","Anchor","Primitive","span","_babelRuntimeHelpersEsmExtends","ref","style","WebkitTouchCallout","onContextMenu","composeEventHandlers","preventDefault","onPointerDown","whenTouchOrPen","setTimeout","onPointerMove","onPointerCancel","onPointerUp","ContextMenuContent","commonProps","$b55f3d34bcc87b2d9b0bc87c90588a09$var$ContextMenuRootContent","Content","ContextMenuRootContent","hasInteractedOutsideRef","portalled","side","sideOffset","align","onCloseAutoFocus","_props$onCloseAutoFoc","call","defaultPrevented","onInteractOutside","_props$onInteractOuts","ContextMenuGroup","Group","ContextMenuLabel","Label","ContextMenuItem","Item","ContextMenuTriggerItem","SubTrigger","ContextMenuCheckboxItem","CheckboxItem","ContextMenuRadioGroup","RadioGroup","ContextMenuRadioItem","RadioItem","ContextMenuItemIndicator","ItemIndicator","ContextMenuSeparator","Separator","ContextMenuArrow","Arrow","handler","pointerType","undefined","Trigger","TriggerItem"],"version":3,"file":"index.module.js.map"}
|
|
1
|
+
{"mappings":"wZAkBA,MAGOA,EAA0BC,GAA0BC,EAHjC,cAGuE,CAC/FC,wCAEF,MAAMC,EAAeD,KASdE,EAAqBC,GAC1BN,EAhBwB,sBAyB1B,MAAMO,YAA2CC,IAC/C,MAAMC,mBAAEA,EAAFC,SAAsBA,EAAtBC,aAAgCA,EAAhCC,IAA8CA,EAA9CC,MAAmDA,GAAQ,GAASL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,OAAOiB,EAAAC,cAACI,EAAcyF,UAAfvF,EAAA,GAA6Bb,EAAemG,EAA5C,CAA4DvD,IAAK3B,4BAe1E,MAAMoF,8BAAmBzG,EAAMoB,YAC7B,CAAC5B,EAA2C6B,KAC1C,MAAM5B,mBAAEA,KAAuBiH,GAAelH,EACxCY,EAAYhB,EAAaK,gBAC/B,OAAOiB,EAAAC,cAACI,EAAc4F,MAAf1F,EAAA,GAAyBb,EAAesG,EAAxC,CAAoD1D,IAAK3B,qBAQpE,SAASkC,EAAkBqD,GACzB,OAAQpE,GAAiC,UAAtBA,EAAMqE,YAA0BD,EAAQpE,QAASsE,SAGtE,MAAM5F,KAAO3B,mBACb,MAAMwH,QAAU5F,0BAChB,MAAM8C,QAAUJ,0BAChB,MAAMmB,MAAQF,wBACd,MAAMK,MAAQF,wBACd,MAAMK,KAAOF,uBACb,MAAM4B,YAAczB,8BACpB,MAAMK,aAAeF,+BACrB,MAAMK,WAAaF,6BACnB,MAAMK,UAAYF,4BAClB,MAAMK,cAAgBF,gCACtB,MAAMK,UAAYF,4BAClB,MAAMK,MAAQF","sources":["./packages/react/context-menu/src/ContextMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as MenuPrimitive from '@radix-ui/react-menu';\nimport { createMenuScope } from '@radix-ui/react-menu';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\ntype Direction = 'ltr' | 'rtl';\ntype Point = { x: number; y: number };\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenu\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTEXT_MENU_NAME = 'ContextMenu';\n\ntype ScopedProps<P> = P & { __scopeContextMenu?: Scope };\nconst [createContextMenuContext, createContextMenuScope] = createContextScope(CONTEXT_MENU_NAME, [\n createMenuScope,\n]);\nconst useMenuScope = createMenuScope();\n\ntype ContextMenuContextValue = {\n isRootMenu: boolean;\n open: boolean;\n onOpenChange(open: boolean): void;\n modal: boolean;\n};\n\nconst [ContextMenuProvider, useContextMenuContext] =\n createContextMenuContext<ContextMenuContextValue>(CONTEXT_MENU_NAME);\n\ninterface ContextMenuProps {\n onOpenChange?(open: boolean): void;\n dir?: Direction;\n modal?: boolean;\n children?: React.ReactNode;\n}\n\nconst ContextMenu: React.FC<ContextMenuProps> = (props: ScopedProps<ContextMenuProps>) => {\n const { __scopeContextMenu, children, onOpenChange, dir, modal = true } = props;\n const [open, setOpen] = React.useState(false);\n const contentContext = useContentContext(CONTEXT_MENU_NAME, __scopeContextMenu);\n const menuScope = useMenuScope(__scopeContextMenu);\n const handleOpenChangeProp = useCallbackRef(onOpenChange);\n\n const handleOpenChange = React.useCallback(\n (open) => {\n setOpen(open);\n handleOpenChangeProp(open);\n },\n [handleOpenChangeProp]\n );\n\n return contentContext.isInsideContent ? (\n <ContextMenuProvider\n scope={__scopeContextMenu}\n isRootMenu={false}\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n >\n <MenuPrimitive.Sub {...menuScope} open={open} onOpenChange={handleOpenChange}>\n {children}\n </MenuPrimitive.Sub>\n </ContextMenuProvider>\n ) : (\n <ContextMenuProvider\n scope={__scopeContextMenu}\n isRootMenu={true}\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n >\n <MenuPrimitive.Root\n {...menuScope}\n dir={dir}\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n >\n {children}\n </MenuPrimitive.Root>\n </ContextMenuProvider>\n );\n};\n\nContextMenu.displayName = CONTEXT_MENU_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'ContextMenuTrigger';\n\ntype ContextMenuTriggerElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface ContextMenuTriggerProps extends PrimitiveSpanProps {}\n\nconst ContextMenuTrigger = React.forwardRef<ContextMenuTriggerElement, ContextMenuTriggerProps>(\n (props: ScopedProps<ContextMenuTriggerProps>, forwardedRef) => {\n const { __scopeContextMenu, ...triggerProps } = props;\n const context = useContextMenuContext(TRIGGER_NAME, __scopeContextMenu);\n const menuScope = useMenuScope(__scopeContextMenu);\n const pointRef = React.useRef<Point>({ x: 0, y: 0 });\n const virtualRef = React.useRef({\n getBoundingClientRect: () => DOMRect.fromRect({ width: 0, height: 0, ...pointRef.current }),\n });\n const longPressTimerRef = React.useRef(0);\n const clearLongPress = React.useCallback(\n () => window.clearTimeout(longPressTimerRef.current),\n []\n );\n const handleOpen = (event: React.MouseEvent | React.PointerEvent) => {\n pointRef.current = { x: event.clientX, y: event.clientY };\n context.onOpenChange(true);\n };\n\n React.useEffect(() => clearLongPress, [clearLongPress]);\n\n return (\n <ContentProvider scope={__scopeContextMenu} isInsideContent={false}>\n <MenuPrimitive.Anchor {...menuScope} virtualRef={virtualRef} />\n <Primitive.span\n {...triggerProps}\n ref={forwardedRef}\n // prevent iOS context menu from appearing\n style={{ WebkitTouchCallout: 'none', ...props.style }}\n onContextMenu={composeEventHandlers(props.onContextMenu, (event) => {\n // clearing the long press here because some platforms already support\n // long press to trigger a `contextmenu` event\n clearLongPress();\n event.preventDefault();\n handleOpen(event);\n })}\n onPointerDown={composeEventHandlers(\n props.onPointerDown,\n whenTouchOrPen((event) => {\n // clear the long press here in case there's multiple touch points\n clearLongPress();\n longPressTimerRef.current = window.setTimeout(() => handleOpen(event), 700);\n })\n )}\n onPointerMove={composeEventHandlers(props.onPointerMove, whenTouchOrPen(clearLongPress))}\n onPointerCancel={composeEventHandlers(\n props.onPointerCancel,\n whenTouchOrPen(clearLongPress)\n )}\n onPointerUp={composeEventHandlers(props.onPointerUp, whenTouchOrPen(clearLongPress))}\n />\n </ContentProvider>\n );\n }\n);\n\nContextMenuTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'ContextMenuContent';\n\nconst [ContentProvider, useContentContext] = createContextMenuContext(CONTENT_NAME, {\n isInsideContent: false,\n});\n\ntype ContextMenuContentElement = React.ElementRef<typeof MenuPrimitive.Content>;\ntype MenuContentProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Content>;\ninterface ContextMenuContentProps extends Omit<MenuContentProps, 'portalled' | 'side' | 'align'> {}\n\nconst ContextMenuContent = React.forwardRef<ContextMenuContentElement, ContextMenuContentProps>(\n (props: ScopedProps<ContextMenuContentProps>, forwardedRef) => {\n const { __scopeContextMenu, ...contentProps } = props;\n const context = useContextMenuContext(CONTENT_NAME, __scopeContextMenu);\n const menuScope = useMenuScope(__scopeContextMenu);\n\n const commonProps = {\n ...contentProps,\n style: {\n ...props.style,\n // re-namespace exposed content custom property\n ['--radix-context-menu-content-transform-origin' as any]:\n 'var(--radix-popper-transform-origin)',\n },\n };\n\n return (\n <ContentProvider scope={__scopeContextMenu} isInsideContent={true}>\n {context.isRootMenu ? (\n <ContextMenuRootContent\n __scopeContextMenu={__scopeContextMenu}\n {...commonProps}\n ref={forwardedRef}\n />\n ) : (\n <MenuPrimitive.Content {...menuScope} {...commonProps} ref={forwardedRef} />\n )}\n </ContentProvider>\n );\n }\n);\n\nContextMenuContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype ContextMenuRootContentElement = React.ElementRef<typeof MenuPrimitive.Content>;\ninterface ContextMenuRootContentProps extends ScopedProps<MenuContentProps> {}\n\nconst ContextMenuRootContent = React.forwardRef<\n ContextMenuRootContentElement,\n ContextMenuRootContentProps\n>((props, forwardedRef) => {\n const { __scopeContextMenu, ...contentProps } = props;\n const context = useContextMenuContext(CONTENT_NAME, __scopeContextMenu);\n const menuScope = useMenuScope(__scopeContextMenu);\n const hasInteractedOutsideRef = React.useRef(false);\n return (\n <MenuPrimitive.Content\n {...menuScope}\n {...contentProps}\n ref={forwardedRef}\n portalled\n side=\"right\"\n sideOffset={2}\n align=\"start\"\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented && hasInteractedOutsideRef.current) {\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented && !context.modal) hasInteractedOutsideRef.current = true;\n }}\n />\n );\n});\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst GROUP_NAME = 'ContextMenuGroup';\n\ntype ContextMenuGroupElement = React.ElementRef<typeof MenuPrimitive.Group>;\ntype MenuGroupProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Group>;\ninterface ContextMenuGroupProps extends MenuGroupProps {}\n\nconst ContextMenuGroup = React.forwardRef<ContextMenuGroupElement, ContextMenuGroupProps>(\n (props: ScopedProps<ContextMenuGroupProps>, forwardedRef) => {\n const { __scopeContextMenu, ...groupProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.Group {...menuScope} {...groupProps} ref={forwardedRef} />;\n }\n);\n\nContextMenuGroup.displayName = GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuLabel\n * -----------------------------------------------------------------------------------------------*/\n\nconst LABEL_NAME = 'ContextMenuLabel';\n\ntype ContextMenuLabelElement = React.ElementRef<typeof MenuPrimitive.Label>;\ntype MenuLabelProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Label>;\ninterface ContextMenuLabelProps extends MenuLabelProps {}\n\nconst ContextMenuLabel = React.forwardRef<ContextMenuLabelElement, ContextMenuLabelProps>(\n (props: ScopedProps<ContextMenuLabelProps>, forwardedRef) => {\n const { __scopeContextMenu, ...labelProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.Label {...menuScope} {...labelProps} ref={forwardedRef} />;\n }\n);\n\nContextMenuLabel.displayName = LABEL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'ContextMenuItem';\n\ntype ContextMenuItemElement = React.ElementRef<typeof MenuPrimitive.Item>;\ntype MenuItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Item>;\ninterface ContextMenuItemProps extends MenuItemProps {}\n\nconst ContextMenuItem = React.forwardRef<ContextMenuItemElement, ContextMenuItemProps>(\n (props: ScopedProps<ContextMenuItemProps>, forwardedRef) => {\n const { __scopeContextMenu, ...itemProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.Item {...menuScope} {...itemProps} ref={forwardedRef} />;\n }\n);\n\nContextMenuItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuTriggerItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_ITEM_NAME = 'ContextMenuTriggerItem';\n\ntype ContextMenuTriggerItemElement = React.ElementRef<typeof MenuPrimitive.SubTrigger>;\ntype MenuSubTriggerProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.SubTrigger>;\ninterface ContextMenuTriggerItemProps extends MenuSubTriggerProps {}\n\nconst ContextMenuTriggerItem = React.forwardRef<\n ContextMenuTriggerItemElement,\n ContextMenuTriggerItemProps\n>((props: ScopedProps<ContextMenuTriggerItemProps>, forwardedRef) => {\n const { __scopeContextMenu, ...triggerItemProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.SubTrigger {...menuScope} {...triggerItemProps} ref={forwardedRef} />;\n});\n\nContextMenuTriggerItem.displayName = TRIGGER_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuCheckboxItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst CHECKBOX_ITEM_NAME = 'ContextMenuCheckboxItem';\n\ntype ContextMenuCheckboxItemElement = React.ElementRef<typeof MenuPrimitive.CheckboxItem>;\ntype MenuCheckboxItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.CheckboxItem>;\ninterface ContextMenuCheckboxItemProps extends MenuCheckboxItemProps {}\n\nconst ContextMenuCheckboxItem = React.forwardRef<\n ContextMenuCheckboxItemElement,\n ContextMenuCheckboxItemProps\n>((props: ScopedProps<ContextMenuCheckboxItemProps>, forwardedRef) => {\n const { __scopeContextMenu, ...checkboxItemProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.CheckboxItem {...menuScope} {...checkboxItemProps} ref={forwardedRef} />;\n});\n\nContextMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuRadioGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_GROUP_NAME = 'ContextMenuRadioGroup';\n\ntype ContextMenuRadioGroupElement = React.ElementRef<typeof MenuPrimitive.RadioGroup>;\ntype MenuRadioGroupProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioGroup>;\ninterface ContextMenuRadioGroupProps extends MenuRadioGroupProps {}\n\nconst ContextMenuRadioGroup = React.forwardRef<\n ContextMenuRadioGroupElement,\n ContextMenuRadioGroupProps\n>((props: ScopedProps<ContextMenuRadioGroupProps>, forwardedRef) => {\n const { __scopeContextMenu, ...radioGroupProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.RadioGroup {...menuScope} {...radioGroupProps} ref={forwardedRef} />;\n});\n\nContextMenuRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuRadioItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_ITEM_NAME = 'ContextMenuRadioItem';\n\ntype ContextMenuRadioItemElement = React.ElementRef<typeof MenuPrimitive.RadioItem>;\ntype MenuRadioItemProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioItem>;\ninterface ContextMenuRadioItemProps extends MenuRadioItemProps {}\n\nconst ContextMenuRadioItem = React.forwardRef<\n ContextMenuRadioItemElement,\n ContextMenuRadioItemProps\n>((props: ScopedProps<ContextMenuRadioItemProps>, forwardedRef) => {\n const { __scopeContextMenu, ...radioItemProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.RadioItem {...menuScope} {...radioItemProps} ref={forwardedRef} />;\n});\n\nContextMenuRadioItem.displayName = RADIO_ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuItemIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ContextMenuItemIndicator';\n\ntype ContextMenuItemIndicatorElement = React.ElementRef<typeof MenuPrimitive.ItemIndicator>;\ntype MenuItemIndicatorProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.ItemIndicator>;\ninterface ContextMenuItemIndicatorProps extends MenuItemIndicatorProps {}\n\nconst ContextMenuItemIndicator = React.forwardRef<\n ContextMenuItemIndicatorElement,\n ContextMenuItemIndicatorProps\n>((props: ScopedProps<ContextMenuItemIndicatorProps>, forwardedRef) => {\n const { __scopeContextMenu, ...itemIndicatorProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.ItemIndicator {...menuScope} {...itemIndicatorProps} ref={forwardedRef} />;\n});\n\nContextMenuItemIndicator.displayName = INDICATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuSeparator\n * -----------------------------------------------------------------------------------------------*/\n\nconst SEPARATOR_NAME = 'ContextMenuSeparator';\n\ntype ContextMenuSeparatorElement = React.ElementRef<typeof MenuPrimitive.Separator>;\ntype MenuSeparatorProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Separator>;\ninterface ContextMenuSeparatorProps extends MenuSeparatorProps {}\n\nconst ContextMenuSeparator = React.forwardRef<\n ContextMenuSeparatorElement,\n ContextMenuSeparatorProps\n>((props: ScopedProps<ContextMenuSeparatorProps>, forwardedRef) => {\n const { __scopeContextMenu, ...separatorProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.Separator {...menuScope} {...separatorProps} ref={forwardedRef} />;\n});\n\nContextMenuSeparator.displayName = SEPARATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * ContextMenuArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'ContextMenuArrow';\n\ntype ContextMenuArrowElement = React.ElementRef<typeof MenuPrimitive.Arrow>;\ntype MenuArrowProps = Radix.ComponentPropsWithoutRef<typeof MenuPrimitive.Arrow>;\ninterface ContextMenuArrowProps extends MenuArrowProps {}\n\nconst ContextMenuArrow = React.forwardRef<ContextMenuArrowElement, ContextMenuArrowProps>(\n (props: ScopedProps<ContextMenuArrowProps>, forwardedRef) => {\n const { __scopeContextMenu, ...arrowProps } = props;\n const menuScope = useMenuScope(__scopeContextMenu);\n return <MenuPrimitive.Arrow {...menuScope} {...arrowProps} ref={forwardedRef} />;\n }\n);\n\nContextMenuArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction whenTouchOrPen<E>(handler: React.PointerEventHandler<E>): React.PointerEventHandler<E> {\n return (event) => (event.pointerType !== 'mouse' ? handler(event) : undefined);\n}\n\nconst Root = ContextMenu;\nconst Trigger = ContextMenuTrigger;\nconst Content = ContextMenuContent;\nconst Group = ContextMenuGroup;\nconst Label = ContextMenuLabel;\nconst Item = ContextMenuItem;\nconst TriggerItem = ContextMenuTriggerItem;\nconst CheckboxItem = ContextMenuCheckboxItem;\nconst RadioGroup = ContextMenuRadioGroup;\nconst RadioItem = ContextMenuRadioItem;\nconst ItemIndicator = ContextMenuItemIndicator;\nconst Separator = ContextMenuSeparator;\nconst Arrow = ContextMenuArrow;\n\nexport {\n createContextMenuScope,\n //\n ContextMenu,\n ContextMenuTrigger,\n ContextMenuContent,\n ContextMenuGroup,\n ContextMenuLabel,\n ContextMenuItem,\n ContextMenuTriggerItem,\n ContextMenuCheckboxItem,\n ContextMenuRadioGroup,\n ContextMenuRadioItem,\n ContextMenuItemIndicator,\n ContextMenuSeparator,\n ContextMenuArrow,\n //\n Root,\n Trigger,\n Content,\n Group,\n Label,\n Item,\n TriggerItem,\n CheckboxItem,\n RadioGroup,\n RadioItem,\n ItemIndicator,\n Separator,\n Arrow,\n};\nexport type {\n ContextMenuProps,\n ContextMenuTriggerProps,\n ContextMenuContentProps,\n ContextMenuGroupProps,\n ContextMenuLabelProps,\n ContextMenuItemProps,\n ContextMenuTriggerItemProps,\n ContextMenuCheckboxItemProps,\n ContextMenuRadioGroupProps,\n ContextMenuRadioItemProps,\n ContextMenuItemIndicatorProps,\n ContextMenuSeparatorProps,\n ContextMenuArrowProps,\n};\n"],"names":["createContextMenuContext","createContextMenuScope","createContextScope","createMenuScope","useMenuScope","ContextMenuProvider","useContextMenuContext","ContextMenu","props","__scopeContextMenu","children","onOpenChange","dir","modal","open","setOpen","React","useState","contentContext","useContentContext","menuScope","handleOpenChangeProp","useCallbackRef","handleOpenChange","useCallback","isInsideContent","_react","createElement","$b55f3d34bcc87b2d9b0bc87c90588a09$var$ContextMenuProvider","scope","isRootMenu","_radixUiReactMenu","Sub","_babelRuntimeHelpersEsmExtends","Root","ContextMenuTrigger","forwardRef","forwardedRef","triggerProps","context","pointRef","useRef","x","y","virtualRef","getBoundingClientRect","DOMRect","fromRect","width","height","current","longPressTimerRef","clearLongPress","window","clearTimeout","handleOpen","event","clientX","clientY","useEffect","$b55f3d34bcc87b2d9b0bc87c90588a09$var$ContentProvider","Anchor","Primitive","span","ref","style","WebkitTouchCallout","onContextMenu","composeEventHandlers","preventDefault","onPointerDown","whenTouchOrPen","setTimeout","onPointerMove","onPointerCancel","onPointerUp","ContentProvider","ContextMenuContent","contentProps","commonProps","$b55f3d34bcc87b2d9b0bc87c90588a09$var$ContextMenuRootContent","Content","ContextMenuRootContent","hasInteractedOutsideRef","portalled","side","sideOffset","align","onCloseAutoFocus","_props$onCloseAutoFoc","call","defaultPrevented","onInteractOutside","_props$onInteractOuts","ContextMenuGroup","groupProps","Group","ContextMenuLabel","labelProps","Label","ContextMenuItem","itemProps","Item","ContextMenuTriggerItem","triggerItemProps","SubTrigger","ContextMenuCheckboxItem","checkboxItemProps","CheckboxItem","ContextMenuRadioGroup","radioGroupProps","RadioGroup","ContextMenuRadioItem","radioItemProps","RadioItem","ContextMenuItemIndicator","itemIndicatorProps","ItemIndicator","ContextMenuSeparator","separatorProps","Separator","ContextMenuArrow","arrowProps","Arrow","handler","pointerType","undefined","Trigger","TriggerItem"],"version":3,"file":"index.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-context-menu",
|
|
3
|
-
"version": "0.1.1
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime": "^7.13.10",
|
|
20
20
|
"@radix-ui/primitive": "0.1.0",
|
|
21
|
-
"@radix-ui/react-context": "0.1.
|
|
22
|
-
"@radix-ui/react-menu": "0.1.1
|
|
23
|
-
"@radix-ui/react-primitive": "0.1.1
|
|
21
|
+
"@radix-ui/react-context": "0.1.1",
|
|
22
|
+
"@radix-ui/react-menu": "0.1.1",
|
|
23
|
+
"@radix-ui/react-primitive": "0.1.1",
|
|
24
24
|
"@radix-ui/react-use-callback-ref": "0.1.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -34,6 +34,5 @@
|
|
|
34
34
|
},
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/radix-ui/primitives/issues"
|
|
37
|
-
}
|
|
38
|
-
"stableVersion": "0.1.0"
|
|
37
|
+
}
|
|
39
38
|
}
|