UNPKG

@radix-ui/themes

Version:

[![Radix Themes Logo](https://radix-ui.com/social/themes.png)](https://radix-ui.com/themes)

3 lines (2 loc) 5.37 kB
"use client";import*as e from"react";import a from"classnames";import*as r from"@radix-ui/react-context-menu";import{Slottable as P}from"@radix-ui/react-slot";import{ScrollArea as d}from"./scroll-area.js";import{contextMenuContentPropDefs as p,contextMenuItemPropDefs as D,contextMenuCheckboxItemPropDefs as O,contextMenuRadioItemPropDefs as V}from"./context-menu.props.js";import{extractProps as f,requireReactElement as z}from"../helpers/index.js";import{Theme as I,useThemeContext as A}from"./theme.js";import{ThickCheckIcon as b,ThickChevronRightIcon as j}from"./icons.js";const h=t=>e.createElement(r.Root,{...t});h.displayName="ContextMenu.Root";const g=e.forwardRef(({children:t,...n},o)=>e.createElement(r.Trigger,{...n,ref:o,asChild:!0},z(t)));g.displayName="ContextMenu.Trigger";const v=e.createContext({}),y=e.forwardRef((t,n)=>{const o=A(),{size:s=p.size.default,variant:u=p.variant.default,highContrast:i=p.highContrast.default}=t,{className:C,children:m,color:x,container:M,forceMount:l,...L}=f(t,p),c=x||o.accentColor;return e.createElement(r.Portal,{container:M,forceMount:l},e.createElement(I,{asChild:!0},e.createElement(r.Content,{"data-accent-color":c,alignOffset:-Number(s)*4,collisionPadding:10,...L,asChild:!1,ref:n,className:a("rt-PopperContent","rt-BaseMenuContent","rt-ContextMenuContent",C)},e.createElement(d,{type:"auto"},e.createElement("div",{className:a("rt-BaseMenuViewport","rt-ContextMenuViewport")},e.createElement(v.Provider,{value:e.useMemo(()=>({size:s,variant:u,color:c,highContrast:i}),[s,u,c,i])},m))))))});y.displayName="ContextMenu.Content";const S=e.forwardRef(({className:t,...n},o)=>e.createElement(r.Label,{...n,asChild:!1,ref:o,className:a("rt-BaseMenuLabel","rt-ContextMenuLabel",t)}));S.displayName="ContextMenu.Label";const R=e.forwardRef((t,n)=>{const{className:o,children:s,color:u=D.color.default,shortcut:i,...C}=t;return e.createElement(r.Item,{"data-accent-color":u,...C,ref:n,className:a("rt-reset","rt-BaseMenuItem","rt-ContextMenuItem",o)},e.createElement(P,null,s),i&&e.createElement("div",{className:"rt-BaseMenuShortcut rt-ContextMenuShortcut"},i))});R.displayName="ContextMenu.Item";const N=e.forwardRef(({className:t,...n},o)=>e.createElement(r.Group,{...n,asChild:!1,ref:o,className:a("rt-BaseMenuGroup","rt-ContextMenuGroup",t)}));N.displayName="ContextMenu.Group";const T=e.forwardRef(({className:t,...n},o)=>e.createElement(r.RadioGroup,{...n,asChild:!1,ref:o,className:a("rt-BaseMenuRadioGroup","rt-ContextMenuRadioGroup",t)}));T.displayName="ContextMenu.RadioGroup";const E=e.forwardRef((t,n)=>{const{children:o,className:s,color:u=V.color.default,...i}=t;return e.createElement(r.RadioItem,{...i,asChild:!1,ref:n,"data-accent-color":u,className:a("rt-BaseMenuItem","rt-BaseMenuRadioItem","rt-ContextMenuItem","rt-ContextMenuRadioItem",s)},e.createElement(P,null,o),e.createElement(r.ItemIndicator,{className:"rt-BaseMenuItemIndicator rt-ContextMenuItemIndicator"},e.createElement(b,{className:"rt-BaseMenuItemIndicatorIcon rt-ContextMenuItemIndicatorIcon"})))});E.displayName="ContextMenu.RadioItem";const G=e.forwardRef((t,n)=>{const{children:o,className:s,shortcut:u,color:i=O.color.default,...C}=t;return e.createElement(r.CheckboxItem,{...C,asChild:!1,ref:n,"data-accent-color":i,className:a("rt-BaseMenuItem","rt-BaseMenuCheckboxItem","rt-ContextMenuItem","rt-ContextMenuCheckboxItem",s)},e.createElement(P,null,o),e.createElement(r.ItemIndicator,{className:"rt-BaseMenuItemIndicator rt-ContextMenuItemIndicator"},e.createElement(b,{className:"rt-BaseMenuItemIndicatorIcon rt-ContextMenuItemIndicatorIcon"})),u&&e.createElement("div",{className:"rt-BaseMenuShortcut rt-ContextMenuShortcut"},u))});G.displayName="ContextMenu.CheckboxItem";const w=t=>e.createElement(r.Sub,{...t});w.displayName="ContextMenu.Sub";const B=e.forwardRef((t,n)=>{const{className:o,children:s,...u}=t;return e.createElement(r.SubTrigger,{...u,asChild:!1,ref:n,className:a("rt-BaseMenuItem","rt-BaseMenuSubTrigger","rt-ContextMenuItem","rt-ContextMenuSubTrigger",o)},s,e.createElement("div",{className:"rt-BaseMenuShortcut rt-ContextMenuShortcut"},e.createElement(j,{className:"rt-BaseMenuSubTriggerIcon rt-ContextMenuSubTriggerIcon"})))});B.displayName="ContextMenu.SubTrigger";const k=e.forwardRef((t,n)=>{const{size:o,variant:s,color:u,highContrast:i}=e.useContext(v),{className:C,children:m,container:x,forceMount:M,...l}=f({size:o,variant:s,color:u,highContrast:i,...t},p);return e.createElement(r.Portal,{container:x,forceMount:M},e.createElement(I,{asChild:!0},e.createElement(r.SubContent,{"data-accent-color":u,alignOffset:-Number(o)*4,sideOffset:1,collisionPadding:10,...l,asChild:!1,ref:n,className:a("rt-PopperContent","rt-BaseMenuContent","rt-BaseMenuSubContent","rt-ContextMenuContent","rt-ContextMenuSubContent",C)},e.createElement(d,{type:"auto"},e.createElement("div",{className:a("rt-BaseMenuViewport","rt-ContextMenuViewport")},m)))))});k.displayName="ContextMenu.SubContent";const W=e.forwardRef(({className:t,...n},o)=>e.createElement(r.Separator,{...n,asChild:!1,ref:o,className:a("rt-BaseMenuSeparator","rt-ContextMenuSeparator",t)}));W.displayName="ContextMenu.Separator";export{G as CheckboxItem,y as Content,N as Group,R as Item,S as Label,T as RadioGroup,E as RadioItem,h as Root,W as Separator,w as Sub,k as SubContent,B as SubTrigger,g as Trigger}; //# sourceMappingURL=context-menu.js.map