mantine-contextmenu 6.0.4 → 6.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Mantine ContextMenu V6
2
2
 
3
- **⚠️ Mantine-ContextMenu V6 is compatible with [Mantine V6](https://v6.mantine.dev).**
4
- **💡 If you're using Mantine V7, please use [Mantine-ContextMenu V7](https://icflorescu.github.io/mantine-contextmenu/).**
3
+ **⚠️ Mantine ContextMenu V6 is compatible with [Mantine V6](https://v6.mantine.dev).**
4
+ **💡 If you're using Mantine V7, please use [Mantine ContextMenu V7](https://icflorescu.github.io/mantine-contextmenu/).**
5
5
 
6
6
  ![Publish NPM & deploy docs workflow](https://github.com/icflorescu/mantine-contextmenu-v6/actions/workflows/publish-and-deploy.yml/badge.svg)
7
7
  [![NPM version][npm-image]][npm-url]
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenu.d.ts","sourceRoot":"","sources":["../ContextMenu.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AActE,MAAM,MAAM,0BAA0B,GAAG;IACvC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,kBAAkB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,GAC/C,0BAA0B,GAAG;IAC3B,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEJ,wBAAgB,WAAW,CAAC,EAC1B,CAAC,EACD,CAAC,EACD,OAAO,EACP,MAAM,EACN,MAAM,EACN,YAAY,EACZ,MAAM,EACN,SAAS,EACT,KAAK,EACL,EAAE,EACF,UAAU,EACV,MAAM,GACP,EAAE,gBAAgB,2CAkElB"}
1
+ {"version":3,"file":"ContextMenu.d.ts","sourceRoot":"","sources":["../ContextMenu.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AActE,MAAM,MAAM,0BAA0B,GAAG;IACvC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,kBAAkB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,GAC/C,0BAA0B,GAAG;IAC3B,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEJ,wBAAgB,WAAW,CAAC,EAC1B,CAAC,EACD,CAAC,EACD,OAAO,EACP,MAAM,EACN,MAAM,EACN,YAAY,EACZ,MAAM,EACN,SAAS,EACT,KAAK,EACL,EAAE,EACF,UAAU,EACV,MAAM,GACP,EAAE,gBAAgB,2CAmElB"}
@@ -1,6 +1,8 @@
1
- import { ContextMenuItemOptions } from './types';
2
- import { WithRequiredProperty } from './utils';
3
- export declare function ContextMenuItem({ className, style, icon, title, color, disabled, onClick, onHide, items, }: WithRequiredProperty<Omit<ContextMenuItemOptions, 'key'>, 'title'> & {
1
+ import { type MantineNumberSize } from '@mantine/core';
2
+ import type { ContextMenuItemOptions } from './types';
3
+ import type { WithRequiredProperty } from './utils';
4
+ export declare function ContextMenuItem({ className, style, icon, title, color, disabled, onClick, onHide, borderRadius, items, }: WithRequiredProperty<Omit<ContextMenuItemOptions, 'key'>, 'title'> & {
5
+ borderRadius: MantineNumberSize | undefined;
4
6
  onHide: () => void;
5
7
  }): import("react/jsx-runtime").JSX.Element;
6
8
  //# sourceMappingURL=ContextMenuItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuItem.d.ts","sourceRoot":"","sources":["../ContextMenuItem.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAsB,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAuC/C,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,KAAK,EACL,IAAI,EACJ,KAAK,EACL,KAAK,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,KAAK,GACN,EAAE,oBAAoB,CAAC,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,2CAoD7F"}
1
+ {"version":3,"file":"ContextMenuItem.d.ts","sourceRoot":"","sources":["../ContextMenuItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvH,OAAO,KAAK,EAAsB,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAuCpD,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,KAAK,EACL,IAAI,EACJ,KAAK,EACL,KAAK,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,YAAY,EACZ,KAAK,GACN,EAAE,oBAAoB,CAAC,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,YAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC5C,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,2CA2DA"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var ne=Object.create;var k=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var o in t)k(e,o,{get:t[o],enumerable:!0})},G=(e,t,o,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of se(t))!ue.call(e,n)&&n!==o&&k(e,n,{get:()=>t[n],enumerable:!(u=re(t,n))||u.enumerable});return e};var de=(e,t,o)=>(o=e!=null?ne(ie(e)):{},G(t||!e||!e.__esModule?k(o,"default",{value:e,enumerable:!0}):o,e)),pe=e=>G(k({},"__esModule",{value:!0}),e);var Ce={};ae(Ce,{ContextMenuDivider:()=>W,ContextMenuItem:()=>L,ContextMenuPortal:()=>$,ContextMenuProvider:()=>me,humanize:()=>R,useContextMenu:()=>fe});module.exports=pe(Ce);var C=de(require("react"),1);var O=require("@mantine/core"),J=require("react/jsx-runtime"),le=(0,O.createStyles)(e=>({root:{height:1,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[1]}}));function W({className:e,sx:t,style:o}){let{cx:u,classes:n}=le();return(0,J.jsx)(O.Box,{className:u(n.root,e),sx:t,style:o})}var i=require("@mantine/core"),z=require("react");var a=require("@mantine/core"),Z=require("@mantine/hooks"),T=require("react");function R(e){let t=e.replace(/([a-z\d])([A-Z]+)/g,"$1 $2").replace(/\W|_/g," ").trim().toLowerCase();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}var I=require("react/jsx-runtime"),X={},ce=(0,a.createStyles)(e=>({root:{position:"fixed",border:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,overflow:"hidden",transition:"all .15s ease"}}));function B({x:e,y:t,content:o,zIndex:u,shadow:n,borderRadius:p,onHide:l,className:y,style:c,sx:r,classNames:s,styles:M}){let[w]=(0,Z.useResizeObserver)(),{width:S,height:b}=w.current?.getBoundingClientRect()||{width:0,height:0},x=0,P=0;typeof window<"u"&&({innerWidth:x,innerHeight:P}=window);let[,h]=(0,T.useState)(!1);(0,T.useEffect)(()=>{h(!0)},[]);let{cx:m,classes:D,theme:q}=ce(),{dir:j,spacing:ee}=q,H=typeof M=="function"?M(q,X,X):M,f=(0,a.px)(ee.md);return(0,I.jsx)(a.Paper,{ref:w,shadow:n,radius:p,className:m(D.root,y,s?.root),style:{...H?.root,...c},sx:[{zIndex:u,top:t+b+f>P?P-b-f:t,left:j==="ltr"?e+S+f>x?x-S-f:e:x-f-(e-S-f<0?S+f:e)},...(0,a.packSx)(r)],children:Array.isArray(o)?o.map(({key:N,className:F,sx:U,style:K,onClick:Y,items:_,title:te,...oe})=>Y||_?(0,I.jsx)(L,{className:m(s?.item,F),sx:U,style:{...H?.item,...K},title:te??R(N),onClick:Y,onHide:l,items:_,...oe},N):(0,I.jsx)(W,{className:m(s?.divider,F),sx:U,style:{...H?.divider,...K}},N)):o(l)})}var d=require("react/jsx-runtime"),xe=(0,i.createStyles)((e,{color:t})=>{let o=(0,i.px)(e.spacing.sm)/2;return{button:{width:"100%",display:"flex",alignItems:"center",paddingTop:o,paddingBottom:o,paddingLeft:e.spacing.sm,paddingRight:e.spacing.sm,color:t&&e.colors[t][6],transition:"background .15s ease","&[disabled]":{cursor:"not-allowed",color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[5]},"&:hover:not([disabled])":{background:e.fn.rgba(t?e.colors[t][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],t?e.colorScheme==="dark"?.15:.08:.25)},"&:active:not([disabled])":{background:e.fn.rgba(t?e.colors[t][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],t?e.colorScheme==="dark"?.3:.2:.5)}},title:{whiteSpace:"nowrap",flexGrow:1}}});function L({className:e,style:t,icon:o,title:u,color:n,disabled:p,onClick:l,onHide:y,items:c}){let r=(0,z.useRef)(null),[s,M]=(0,z.useState)(null),w=l?m=>{y(),l(m)}:void 0,S=()=>{let{top:m,right:D}=r.current.getBoundingClientRect();M({x:D,y:m})},b=()=>{M(null)},x=c&&!p,{cx:P,classes:h}=xe({color:n});return(0,d.jsxs)("div",{onMouseOver:x?S:void 0,onMouseOut:x?b:void 0,children:[(0,d.jsxs)(i.UnstyledButton,{ref:r,className:P(h.button,e),style:t,disabled:p,onClick:w,children:[o&&(0,d.jsx)(i.Box,{fz:0,mr:"xs",children:o}),(0,d.jsx)(i.Text,{className:h.title,size:"sm",children:u}),c&&(0,d.jsx)(i.Box,{fz:10,mt:-2,ml:"xs",children:"\u25B6"})]}),s&&(0,d.jsx)(B,{content:c,onHide:y,...s})]})}var Q=require("@mantine/core"),v=require("@mantine/hooks");var A=require("react/jsx-runtime");function $({onHide:e,...t}){(0,v.useWindowEvent)("resize",e),(0,v.useWindowEvent)("scroll",e);let o=(0,v.useClickOutside)(e);return(0,A.jsx)(Q.Portal,{innerRef:o,children:(0,A.jsx)(B,{...t,onHide:e})})}var g=require("react");var E=require("react/jsx-runtime"),V=(0,g.createContext)(()=>()=>{});function me({zIndex:e=9999,shadow:t="sm",borderRadius:o="xs",children:u}){let[n,p]=(0,g.useState)(null),l=()=>{p(null)},y=(c,r)=>s=>{s.preventDefault(),s.stopPropagation(),p({x:s.clientX,y:s.clientY,content:c,zIndex:r?.zIndex||e,shadow:r?.shadow||t,borderRadius:r?.borderRadius||o,className:r?.className,style:r?.style,sx:r?.sx,classNames:r?.classNames,styles:r?.styles})};return(0,E.jsxs)(V.Provider,{value:y,children:[u,n&&(0,E.jsx)($,{onHide:l,...n})]})}function fe(){return(0,g.useContext)(V)}
1
+ "use strict";var ne=Object.create;var R=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var o in t)R(e,o,{get:t[o],enumerable:!0})},G=(e,t,o,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of se(t))!ue.call(e,n)&&n!==o&&R(e,n,{get:()=>t[n],enumerable:!(u=re(t,n))||u.enumerable});return e};var de=(e,t,o)=>(o=e!=null?ne(ie(e)):{},G(t||!e||!e.__esModule?R(o,"default",{value:e,enumerable:!0}):o,e)),pe=e=>G(R({},"__esModule",{value:!0}),e);var ye={};ae(ye,{ContextMenuDivider:()=>L,ContextMenuItem:()=>A,ContextMenuPortal:()=>q,ContextMenuProvider:()=>me,humanize:()=>I,useContextMenu:()=>fe});module.exports=pe(ye);var x=de(require("react"),1);var O=require("@mantine/core"),J=require("react/jsx-runtime"),le=(0,O.createStyles)(e=>({root:{height:1,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[1]}}));function L({className:e,sx:t,style:o}){let{cx:u,classes:n}=le();return(0,J.jsx)(O.Box,{className:u(n.root,e),sx:t,style:o})}var i=require("@mantine/core"),N=require("react");var d=require("@mantine/core"),Z=require("@mantine/hooks"),T=require("react");function I(e){let t=e.replace(/([a-z\d])([A-Z]+)/g,"$1 $2").replace(/\W|_/g," ").trim().toLowerCase();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}var z=require("react/jsx-runtime"),X={},ce=(0,d.createStyles)(e=>({root:{position:"fixed",border:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,overflow:"hidden",transition:"all .15s ease"}}));function B({x:e,y:t,content:o,zIndex:u,shadow:n,borderRadius:a,onHide:l,className:m,style:P,sx:r,classNames:s,styles:f}){let[b]=(0,Z.useResizeObserver)(),{width:y,height:h}=b.current?.getBoundingClientRect()||{width:0,height:0},C=0,M=0;typeof window<"u"&&({innerWidth:C,innerHeight:M}=window);let[,D]=(0,T.useState)(!1);(0,T.useEffect)(()=>{D(!0)},[]);let{cx:S,classes:v,theme:k}=ce(),{dir:j,spacing:ee}=k,H=typeof f=="function"?f(k,X,X):f,c=(0,d.px)(ee.md);return(0,z.jsx)(d.Paper,{ref:b,shadow:n,radius:a,className:S(v.root,m,s?.root),style:{...H?.root,...P},sx:[{zIndex:u,top:t+h+c>M?M-h-c:t,left:j==="ltr"?e+y+c>C?C-y-c:e:C-c-(e-y-c<0?y+c:e)},...(0,d.packSx)(r)],children:Array.isArray(o)?o.map(({key:W,className:F,sx:U,style:K,onClick:Y,items:_,title:te,...oe})=>Y||_?(0,z.jsx)(A,{className:S(s?.item,F),sx:U,style:{...H?.item,...K},title:te??I(W),onClick:Y,onHide:l,borderRadius:a,items:_,...oe},W):(0,z.jsx)(L,{className:S(s?.divider,F),sx:U,style:{...H?.divider,...K}},W)):o(l)})}var p=require("react/jsx-runtime"),xe=(0,i.createStyles)((e,{color:t})=>{let o=(0,i.px)(e.spacing.sm)/2;return{button:{width:"100%",display:"flex",alignItems:"center",paddingTop:o,paddingBottom:o,paddingLeft:e.spacing.sm,paddingRight:e.spacing.sm,color:t&&e.colors[t][6],transition:"background .15s ease","&[disabled]":{cursor:"not-allowed",color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[5]},"&:hover:not([disabled])":{background:e.fn.rgba(t?e.colors[t][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],t?e.colorScheme==="dark"?.15:.08:.25)},"&:active:not([disabled])":{background:e.fn.rgba(t?e.colors[t][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],t?e.colorScheme==="dark"?.3:.2:.5)}},title:{whiteSpace:"nowrap",flexGrow:1}}});function A({className:e,style:t,icon:o,title:u,color:n,disabled:a,onClick:l,onHide:m,borderRadius:P,items:r}){let s=(0,N.useRef)(null),[f,b]=(0,N.useState)(null),y=l?v=>{m(),l(v)}:void 0,h=()=>{let{top:v,right:k}=s.current.getBoundingClientRect();b({x:k,y:v})},C=()=>{b(null)},M=r&&!a,{cx:D,classes:S}=xe({color:n});return(0,p.jsxs)("div",{onMouseOver:M?h:void 0,onMouseOut:M?C:void 0,children:[(0,p.jsxs)(i.UnstyledButton,{ref:s,className:D(S.button,e),style:t,disabled:a,onClick:y,children:[o&&(0,p.jsx)(i.Box,{fz:0,mr:"xs",children:o}),(0,p.jsx)(i.Text,{className:S.title,size:"sm",children:u}),r&&(0,p.jsx)(i.Box,{fz:10,mt:-2,ml:"xs",children:"\u25B6"})]}),f&&(0,p.jsx)(B,{content:r,borderRadius:P,onHide:m,...f})]})}var Q=require("@mantine/core"),w=require("@mantine/hooks");var $=require("react/jsx-runtime");function q({onHide:e,...t}){(0,w.useWindowEvent)("resize",e),(0,w.useWindowEvent)("scroll",e);let o=(0,w.useClickOutside)(e);return(0,$.jsx)(Q.Portal,{innerRef:o,children:(0,$.jsx)(B,{...t,onHide:e})})}var g=require("react");var E=require("react/jsx-runtime"),V=(0,g.createContext)(()=>()=>{});function me({zIndex:e=9999,shadow:t="sm",borderRadius:o="xs",children:u}){let[n,a]=(0,g.useState)(null),l=()=>{a(null)},m=(P,r)=>s=>{s.preventDefault(),s.stopPropagation(),a({x:s.clientX,y:s.clientY,content:P,zIndex:r?.zIndex||e,shadow:r?.shadow||t,borderRadius:r?.borderRadius||o,className:r?.className,style:r?.style,sx:r?.sx,classNames:r?.classNames,styles:r?.styles})};return(0,E.jsxs)(V.Provider,{value:m,children:[u,n&&(0,E.jsx)(q,{onHide:l,...n})]})}function fe(){return(0,g.useContext)(V)}
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../index.ts", "../react-shim.mjs", "../ContextMenuDivider.tsx", "../ContextMenuItem.tsx", "../ContextMenu.tsx", "../utils.ts", "../ContextMenuPortal.tsx", "../ContextMenuProvider.tsx"],
4
- "sourcesContent": ["export * from './ContextMenuDivider';\nexport * from './ContextMenuItem';\nexport * from './ContextMenuPortal';\nexport * from './ContextMenuProvider';\nexport { humanize } from './utils';\n", "import * as React from 'react';\nexport { React };\n", "import { Box, createStyles, type Sx } from '@mantine/core';\nimport type { CSSProperties } from 'react';\n\nconst useStyles = createStyles((theme) => ({\n root: {\n height: 1,\n background: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],\n },\n}));\n\nexport type ContextMenuDividerProps = {\n className: string;\n sx: Sx | (Sx | undefined)[] | undefined;\n style: CSSProperties;\n};\n\nexport function ContextMenuDivider({ className, sx, style }: ContextMenuDividerProps) {\n const { cx, classes } = useStyles();\n return <Box className={cx(classes.root, className)} sx={sx} style={style} />;\n}\n", "import { Box, Text, UnstyledButton, createStyles, px, type MantineColor } from '@mantine/core';\nimport { MouseEventHandler, useRef, useState } from 'react';\nimport { ContextMenu } from './ContextMenu';\nimport { ContextMenuContent, ContextMenuItemOptions } from './types';\nimport { WithRequiredProperty } from './utils';\n\nconst useStyles = createStyles((theme, { color }: { color?: MantineColor }) => {\n const verticalPadding = px(theme.spacing.sm) / 2;\n return {\n button: {\n width: '100%',\n display: 'flex',\n alignItems: 'center',\n paddingTop: verticalPadding,\n paddingBottom: verticalPadding,\n paddingLeft: theme.spacing.sm,\n paddingRight: theme.spacing.sm,\n color: color && theme.colors[color][6],\n transition: 'background .15s ease',\n '&[disabled]': {\n cursor: 'not-allowed',\n color: theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[5],\n },\n '&:hover:not([disabled])': {\n background: theme.fn.rgba(\n color ? theme.colors[color][6] : theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[4],\n color ? (theme.colorScheme === 'dark' ? 0.15 : 0.08) : 0.25\n ),\n },\n '&:active:not([disabled])': {\n background: theme.fn.rgba(\n color ? theme.colors[color][6] : theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[4],\n color ? (theme.colorScheme === 'dark' ? 0.3 : 0.2) : 0.5\n ),\n },\n },\n title: {\n whiteSpace: 'nowrap',\n flexGrow: 1,\n },\n };\n});\n\nexport function ContextMenuItem({\n className,\n style,\n icon,\n title,\n color,\n disabled,\n onClick,\n onHide,\n items,\n}: WithRequiredProperty<Omit<ContextMenuItemOptions, 'key'>, 'title'> & { onHide: () => void }) {\n const ref = useRef<HTMLButtonElement>(null);\n const [submenuPosition, setSubmenuPosition] = useState<{ x: number; y: number } | null>(null);\n\n const handleClick: MouseEventHandler<HTMLButtonElement> | undefined = onClick\n ? (e) => {\n onHide();\n onClick!(e);\n }\n : undefined;\n\n const showSubmenu = () => {\n const { top: y, right: x } = ref.current!.getBoundingClientRect();\n setSubmenuPosition({ x, y });\n };\n\n const hideSubmenu = () => {\n setSubmenuPosition(null);\n };\n\n const hasItemsAndIsNotDisabled = items && !disabled;\n const { cx, classes } = useStyles({ color });\n\n return (\n <div\n onMouseOver={hasItemsAndIsNotDisabled ? showSubmenu : undefined}\n onMouseOut={hasItemsAndIsNotDisabled ? hideSubmenu : undefined}\n >\n <UnstyledButton\n ref={ref}\n className={cx(classes.button, className)}\n style={style}\n disabled={disabled}\n onClick={handleClick}\n >\n {icon && (\n <Box fz={0} mr=\"xs\">\n {icon}\n </Box>\n )}\n <Text className={classes.title} size=\"sm\">\n {title}\n </Text>\n {items && (\n <Box fz={10} mt={-2} ml=\"xs\">\n \u25B6\n </Box>\n )}\n </UnstyledButton>\n {submenuPosition && <ContextMenu content={items as ContextMenuContent} onHide={onHide} {...submenuPosition} />}\n </div>\n );\n}\n", "import { Paper, createStyles, packSx, px } from '@mantine/core';\nimport { useResizeObserver } from '@mantine/hooks';\nimport { CSSProperties, useEffect, useState } from 'react';\nimport { ContextMenuDivider } from './ContextMenuDivider';\nimport { ContextMenuItem } from './ContextMenuItem';\nimport type { ContextMenuContent, ContextMenuOptions } from './types';\nimport { humanize } from './utils';\n\nconst EMPTY_OBJECT = {};\n\nconst useStyles = createStyles((theme) => ({\n root: {\n position: 'fixed',\n border: `1px solid ${theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`,\n overflow: 'hidden',\n transition: 'all .15s ease',\n },\n}));\n\nexport type ContextMenuInstanceOptions = {\n x: number;\n y: number;\n content: ContextMenuContent;\n};\n\nexport type ContextMenuProps = ContextMenuOptions &\n ContextMenuInstanceOptions & {\n onHide: () => void;\n };\n\nexport function ContextMenu({\n x,\n y,\n content,\n zIndex,\n shadow,\n borderRadius,\n onHide,\n className,\n style,\n sx,\n classNames,\n styles,\n}: ContextMenuProps) {\n const [paperRef] = useResizeObserver<HTMLDivElement>();\n const { width, height } = paperRef.current?.getBoundingClientRect() || { width: 0, height: 0 };\n\n let windowWidth = 0;\n let windowHeight = 0;\n if (typeof window !== 'undefined') ({ innerWidth: windowWidth, innerHeight: windowHeight } = window);\n\n // trigger a rerender to make sure that context menu is positioned correctly\n const [, setRendered] = useState(false);\n useEffect(() => {\n setRendered(true);\n }, []);\n\n const { cx, classes, theme } = useStyles();\n const { dir, spacing } = theme;\n const styleProperties = typeof styles === 'function' ? styles(theme, EMPTY_OBJECT, EMPTY_OBJECT) : styles;\n const mdSpacing = px(spacing.md);\n\n return (\n <Paper\n ref={paperRef}\n shadow={shadow}\n radius={borderRadius}\n className={cx(classes.root, className, classNames?.root)}\n style={{ ...styleProperties?.root, ...style } as CSSProperties}\n sx={[\n {\n zIndex,\n top: y + height + mdSpacing > windowHeight ? windowHeight - height - mdSpacing : y,\n left:\n dir === 'ltr'\n ? x + width + mdSpacing > windowWidth\n ? windowWidth - width - mdSpacing\n : x\n : windowWidth - mdSpacing - (x - width - mdSpacing < 0 ? width + mdSpacing : x),\n },\n ...packSx(sx),\n ]}\n >\n {Array.isArray(content)\n ? content.map(({ key, className, sx, style, onClick, items, title, ...otherOptions }) =>\n onClick || items ? (\n <ContextMenuItem\n key={key}\n className={cx(classNames?.item, className)}\n sx={sx}\n style={{ ...styleProperties?.item, ...style } as CSSProperties}\n title={title ?? humanize(key)}\n onClick={onClick}\n onHide={onHide}\n items={items}\n {...otherOptions}\n />\n ) : (\n <ContextMenuDivider\n key={key}\n className={cx(classNames?.divider, className)}\n sx={sx}\n style={{ ...styleProperties?.divider, ...style } as CSSProperties}\n />\n )\n )\n : content(onHide)}\n </Paper>\n );\n}\n", "export type WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\n/**\n * Utility function that returns a humanized version of a string, e.g. \"camelCase\" -> \"Camel Case\"\n */\nexport function humanize(value: string) {\n const str = value\n .replace(/([a-z\\d])([A-Z]+)/g, '$1 $2')\n .replace(/\\W|_/g, ' ')\n .trim()\n .toLowerCase();\n return `${str.charAt(0).toUpperCase()}${str.slice(1)}`;\n}\n", "import { Portal } from '@mantine/core';\nimport { useClickOutside, useWindowEvent } from '@mantine/hooks';\nimport { ContextMenu, type ContextMenuProps } from './ContextMenu';\n\nexport function ContextMenuPortal({ onHide, ...otherProps }: ContextMenuProps) {\n useWindowEvent('resize', onHide);\n useWindowEvent('scroll', onHide);\n const portalInnerRef = useClickOutside<HTMLDivElement>(onHide);\n\n return (\n <Portal innerRef={portalInnerRef}>\n <ContextMenu {...otherProps} onHide={onHide} />\n </Portal>\n );\n}\n", "import { createContext, useContext, useState } from 'react';\nimport { ContextMenuInstanceOptions } from './ContextMenu';\nimport { ContextMenuPortal } from './ContextMenuPortal';\nimport type { ContextMenuOptions, ContextMenuProviderProps, ShowContextMenuFunction } from './types';\n\nconst MenuContext = createContext<ShowContextMenuFunction>(() => () => undefined);\n\n/**\n * Provider that allows to show a context menu anywhere in your application.\n * If you wrap your application with this provider, you can use the `useContextMenu` hook\n * anywhere in the component tree to access a function that shows the context menu.\n */\nexport function ContextMenuProvider({\n zIndex = 9999,\n shadow = 'sm',\n borderRadius = 'xs',\n children,\n}: ContextMenuProviderProps) {\n const [data, setData] = useState<(ContextMenuInstanceOptions & ContextMenuOptions) | null>(null);\n\n const destroy = () => {\n setData(null);\n };\n\n const showContextMenu: ShowContextMenuFunction = (content, options) => (e) => {\n e.preventDefault();\n e.stopPropagation();\n setData({\n x: e.clientX,\n y: e.clientY,\n content,\n zIndex: options?.zIndex || zIndex,\n shadow: options?.shadow || shadow,\n borderRadius: options?.borderRadius || borderRadius,\n className: options?.className,\n style: options?.style,\n sx: options?.sx,\n classNames: options?.classNames,\n styles: options?.styles,\n });\n };\n\n return (\n <MenuContext.Provider value={showContextMenu}>\n {children}\n {data && <ContextMenuPortal onHide={destroy} {...data} />}\n </MenuContext.Provider>\n );\n}\n\n/**\n * Hook returning a function that shows a context menu.\n */\nexport function useContextMenu() {\n return useContext(MenuContext);\n}\n"],
5
- "mappings": "ukBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,wBAAAE,EAAA,oBAAAC,EAAA,sBAAAC,EAAA,wBAAAC,GAAA,aAAAC,EAAA,mBAAAC,KAAA,eAAAC,GAAAR,ICAA,IAAAS,EAAuB,uBCAvB,IAAAC,EAA2C,yBAkBlCC,EAAA,6BAfHC,M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AAC,UAAO,SAAUE,EAChB,mBAACC,EAAA,CAAa,GAAGF,EAAY,OAAQD,EAAQ,EAC/C,CAEJ,CCdA,IAAAI,EAAoD,iBA2ChD,IAAAC,EAAA,6BAtCEC,KAAc,iBAAuC,IAAM,IAAG,EAAY,EAOzE,SAASC,GAAoB,CAClC,OAAAC,EAAS,KACT,OAAAC,EAAS,KACT,aAAAC,EAAe,KACf,SAAAC,CACF,EAA6B,CAC3B,GAAM,CAACC,EAAMC,CAAO,KAAI,YAAmE,IAAI,EAEzFC,EAAU,IAAM,CACpBD,EAAQ,IAAI,CACd,EAEME,EAA2C,CAACC,EAASC,IAAaC,GAAM,CAC5EA,EAAE,eAAe,EACjBA,EAAE,gBAAgB,EAClBL,EAAQ,CACN,EAAGK,EAAE,QACL,EAAGA,EAAE,QACL,QAAAF,EACA,OAAQC,GAAS,QAAUT,EAC3B,OAAQS,GAAS,QAAUR,EAC3B,aAAcQ,GAAS,cAAgBP,EACvC,UAAWO,GAAS,UACpB,MAAOA,GAAS,MAChB,GAAIA,GAAS,GACb,WAAYA,GAAS,WACrB,OAAQA,GAAS,MACnB,CAAC,CACH,EAEA,SACE,QAACX,EAAY,SAAZ,CAAqB,MAAOS,EAC1B,UAAAJ,EACAC,MAAQ,OAACO,EAAA,CAAkB,OAAQL,EAAU,GAAGF,EAAM,GACzD,CAEJ,CAKO,SAASQ,IAAiB,CAC/B,SAAO,cAAWd,CAAW,CAC/B",
6
- "names": ["package_exports", "__export", "ContextMenuDivider", "ContextMenuItem", "ContextMenuPortal", "ContextMenuProvider", "humanize", "useContextMenu", "__toCommonJS", "React", "import_core", "import_jsx_runtime", "useStyles", "theme", "ContextMenuDivider", "className", "sx", "style", "cx", "classes", "import_core", "import_react", "import_core", "import_hooks", "import_react", "humanize", "value", "str", "import_jsx_runtime", "EMPTY_OBJECT", "useStyles", "theme", "ContextMenu", "x", "y", "content", "zIndex", "shadow", "borderRadius", "onHide", "className", "style", "sx", "classNames", "styles", "paperRef", "width", "height", "windowWidth", "windowHeight", "setRendered", "cx", "classes", "dir", "spacing", "styleProperties", "mdSpacing", "key", "onClick", "items", "title", "otherOptions", "ContextMenuItem", "humanize", "ContextMenuDivider", "import_jsx_runtime", "useStyles", "theme", "color", "verticalPadding", "ContextMenuItem", "className", "style", "icon", "title", "disabled", "onClick", "onHide", "items", "ref", "submenuPosition", "setSubmenuPosition", "handleClick", "e", "showSubmenu", "y", "x", "hideSubmenu", "hasItemsAndIsNotDisabled", "cx", "classes", "ContextMenu", "import_core", "import_hooks", "import_jsx_runtime", "ContextMenuPortal", "onHide", "otherProps", "portalInnerRef", "ContextMenu", "import_react", "import_jsx_runtime", "MenuContext", "ContextMenuProvider", "zIndex", "shadow", "borderRadius", "children", "data", "setData", "destroy", "showContextMenu", "content", "options", "e", "ContextMenuPortal", "useContextMenu"]
4
+ "sourcesContent": ["export * from './ContextMenuDivider';\nexport * from './ContextMenuItem';\nexport * from './ContextMenuPortal';\nexport * from './ContextMenuProvider';\nexport { humanize } from './utils';\n", "import * as React from 'react';\nexport { React };\n", "import { Box, createStyles, type Sx } from '@mantine/core';\nimport type { CSSProperties } from 'react';\n\nconst useStyles = createStyles((theme) => ({\n root: {\n height: 1,\n background: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],\n },\n}));\n\nexport type ContextMenuDividerProps = {\n className: string;\n sx: Sx | (Sx | undefined)[] | undefined;\n style: CSSProperties;\n};\n\nexport function ContextMenuDivider({ className, sx, style }: ContextMenuDividerProps) {\n const { cx, classes } = useStyles();\n return <Box className={cx(classes.root, className)} sx={sx} style={style} />;\n}\n", "import { Box, Text, UnstyledButton, createStyles, px, type MantineColor, type MantineNumberSize } from '@mantine/core';\nimport { useRef, useState, type MouseEventHandler } from 'react';\nimport { ContextMenu } from './ContextMenu';\nimport type { ContextMenuContent, ContextMenuItemOptions } from './types';\nimport type { WithRequiredProperty } from './utils';\n\nconst useStyles = createStyles((theme, { color }: { color?: MantineColor }) => {\n const verticalPadding = px(theme.spacing.sm) / 2;\n return {\n button: {\n width: '100%',\n display: 'flex',\n alignItems: 'center',\n paddingTop: verticalPadding,\n paddingBottom: verticalPadding,\n paddingLeft: theme.spacing.sm,\n paddingRight: theme.spacing.sm,\n color: color && theme.colors[color][6],\n transition: 'background .15s ease',\n '&[disabled]': {\n cursor: 'not-allowed',\n color: theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[5],\n },\n '&:hover:not([disabled])': {\n background: theme.fn.rgba(\n color ? theme.colors[color][6] : theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[4],\n color ? (theme.colorScheme === 'dark' ? 0.15 : 0.08) : 0.25\n ),\n },\n '&:active:not([disabled])': {\n background: theme.fn.rgba(\n color ? theme.colors[color][6] : theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[4],\n color ? (theme.colorScheme === 'dark' ? 0.3 : 0.2) : 0.5\n ),\n },\n },\n title: {\n whiteSpace: 'nowrap',\n flexGrow: 1,\n },\n };\n});\n\nexport function ContextMenuItem({\n className,\n style,\n icon,\n title,\n color,\n disabled,\n onClick,\n onHide,\n borderRadius,\n items,\n}: WithRequiredProperty<Omit<ContextMenuItemOptions, 'key'>, 'title'> & {\n borderRadius: MantineNumberSize | undefined;\n onHide: () => void;\n}) {\n const ref = useRef<HTMLButtonElement>(null);\n const [submenuPosition, setSubmenuPosition] = useState<{ x: number; y: number } | null>(null);\n\n const handleClick: MouseEventHandler<HTMLButtonElement> | undefined = onClick\n ? (e) => {\n onHide();\n onClick!(e);\n }\n : undefined;\n\n const showSubmenu = () => {\n const { top: y, right: x } = ref.current!.getBoundingClientRect();\n setSubmenuPosition({ x, y });\n };\n\n const hideSubmenu = () => {\n setSubmenuPosition(null);\n };\n\n const hasItemsAndIsNotDisabled = items && !disabled;\n const { cx, classes } = useStyles({ color });\n\n return (\n <div\n onMouseOver={hasItemsAndIsNotDisabled ? showSubmenu : undefined}\n onMouseOut={hasItemsAndIsNotDisabled ? hideSubmenu : undefined}\n >\n <UnstyledButton\n ref={ref}\n className={cx(classes.button, className)}\n style={style}\n disabled={disabled}\n onClick={handleClick}\n >\n {icon && (\n <Box fz={0} mr=\"xs\">\n {icon}\n </Box>\n )}\n <Text className={classes.title} size=\"sm\">\n {title}\n </Text>\n {items && (\n <Box fz={10} mt={-2} ml=\"xs\">\n \u25B6\n </Box>\n )}\n </UnstyledButton>\n {submenuPosition && (\n <ContextMenu\n content={items as ContextMenuContent}\n borderRadius={borderRadius}\n onHide={onHide}\n {...submenuPosition}\n />\n )}\n </div>\n );\n}\n", "import { Paper, createStyles, packSx, px } from '@mantine/core';\nimport { useResizeObserver } from '@mantine/hooks';\nimport { CSSProperties, useEffect, useState } from 'react';\nimport { ContextMenuDivider } from './ContextMenuDivider';\nimport { ContextMenuItem } from './ContextMenuItem';\nimport type { ContextMenuContent, ContextMenuOptions } from './types';\nimport { humanize } from './utils';\n\nconst EMPTY_OBJECT = {};\n\nconst useStyles = createStyles((theme) => ({\n root: {\n position: 'fixed',\n border: `1px solid ${theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`,\n overflow: 'hidden',\n transition: 'all .15s ease',\n },\n}));\n\nexport type ContextMenuInstanceOptions = {\n x: number;\n y: number;\n content: ContextMenuContent;\n};\n\nexport type ContextMenuProps = ContextMenuOptions &\n ContextMenuInstanceOptions & {\n onHide: () => void;\n };\n\nexport function ContextMenu({\n x,\n y,\n content,\n zIndex,\n shadow,\n borderRadius,\n onHide,\n className,\n style,\n sx,\n classNames,\n styles,\n}: ContextMenuProps) {\n const [paperRef] = useResizeObserver<HTMLDivElement>();\n const { width, height } = paperRef.current?.getBoundingClientRect() || { width: 0, height: 0 };\n\n let windowWidth = 0;\n let windowHeight = 0;\n if (typeof window !== 'undefined') ({ innerWidth: windowWidth, innerHeight: windowHeight } = window);\n\n // trigger a rerender to make sure that context menu is positioned correctly\n const [, setRendered] = useState(false);\n useEffect(() => {\n setRendered(true);\n }, []);\n\n const { cx, classes, theme } = useStyles();\n const { dir, spacing } = theme;\n const styleProperties = typeof styles === 'function' ? styles(theme, EMPTY_OBJECT, EMPTY_OBJECT) : styles;\n const mdSpacing = px(spacing.md);\n\n return (\n <Paper\n ref={paperRef}\n shadow={shadow}\n radius={borderRadius}\n className={cx(classes.root, className, classNames?.root)}\n style={{ ...styleProperties?.root, ...style } as CSSProperties}\n sx={[\n {\n zIndex,\n top: y + height + mdSpacing > windowHeight ? windowHeight - height - mdSpacing : y,\n left:\n dir === 'ltr'\n ? x + width + mdSpacing > windowWidth\n ? windowWidth - width - mdSpacing\n : x\n : windowWidth - mdSpacing - (x - width - mdSpacing < 0 ? width + mdSpacing : x),\n },\n ...packSx(sx),\n ]}\n >\n {Array.isArray(content)\n ? content.map(({ key, className, sx, style, onClick, items, title, ...otherOptions }) =>\n onClick || items ? (\n <ContextMenuItem\n key={key}\n className={cx(classNames?.item, className)}\n sx={sx}\n style={{ ...styleProperties?.item, ...style } as CSSProperties}\n title={title ?? humanize(key)}\n onClick={onClick}\n onHide={onHide}\n borderRadius={borderRadius}\n items={items}\n {...otherOptions}\n />\n ) : (\n <ContextMenuDivider\n key={key}\n className={cx(classNames?.divider, className)}\n sx={sx}\n style={{ ...styleProperties?.divider, ...style } as CSSProperties}\n />\n )\n )\n : content(onHide)}\n </Paper>\n );\n}\n", "export type WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\n/**\n * Utility function that returns a humanized version of a string, e.g. \"camelCase\" -> \"Camel Case\"\n */\nexport function humanize(value: string) {\n const str = value\n .replace(/([a-z\\d])([A-Z]+)/g, '$1 $2')\n .replace(/\\W|_/g, ' ')\n .trim()\n .toLowerCase();\n return `${str.charAt(0).toUpperCase()}${str.slice(1)}`;\n}\n", "import { Portal } from '@mantine/core';\nimport { useClickOutside, useWindowEvent } from '@mantine/hooks';\nimport { ContextMenu, type ContextMenuProps } from './ContextMenu';\n\nexport function ContextMenuPortal({ onHide, ...otherProps }: ContextMenuProps) {\n useWindowEvent('resize', onHide);\n useWindowEvent('scroll', onHide);\n const portalInnerRef = useClickOutside<HTMLDivElement>(onHide);\n\n return (\n <Portal innerRef={portalInnerRef}>\n <ContextMenu {...otherProps} onHide={onHide} />\n </Portal>\n );\n}\n", "import { createContext, useContext, useState } from 'react';\nimport { ContextMenuInstanceOptions } from './ContextMenu';\nimport { ContextMenuPortal } from './ContextMenuPortal';\nimport type { ContextMenuOptions, ContextMenuProviderProps, ShowContextMenuFunction } from './types';\n\nconst MenuContext = createContext<ShowContextMenuFunction>(() => () => undefined);\n\n/**\n * Provider that allows to show a context menu anywhere in your application.\n * If you wrap your application with this provider, you can use the `useContextMenu` hook\n * anywhere in the component tree to access a function that shows the context menu.\n */\nexport function ContextMenuProvider({\n zIndex = 9999,\n shadow = 'sm',\n borderRadius = 'xs',\n children,\n}: ContextMenuProviderProps) {\n const [data, setData] = useState<(ContextMenuInstanceOptions & ContextMenuOptions) | null>(null);\n\n const destroy = () => {\n setData(null);\n };\n\n const showContextMenu: ShowContextMenuFunction = (content, options) => (e) => {\n e.preventDefault();\n e.stopPropagation();\n setData({\n x: e.clientX,\n y: e.clientY,\n content,\n zIndex: options?.zIndex || zIndex,\n shadow: options?.shadow || shadow,\n borderRadius: options?.borderRadius || borderRadius,\n className: options?.className,\n style: options?.style,\n sx: options?.sx,\n classNames: options?.classNames,\n styles: options?.styles,\n });\n };\n\n return (\n <MenuContext.Provider value={showContextMenu}>\n {children}\n {data && <ContextMenuPortal onHide={destroy} {...data} />}\n </MenuContext.Provider>\n );\n}\n\n/**\n * Hook returning a function that shows a context menu.\n */\nexport function useContextMenu() {\n return useContext(MenuContext);\n}\n"],
5
+ "mappings": "ukBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,wBAAAE,EAAA,oBAAAC,EAAA,sBAAAC,EAAA,wBAAAC,GAAA,aAAAC,EAAA,mBAAAC,KAAA,eAAAC,GAAAR,ICAA,IAAAS,EAAuB,uBCAvB,IA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Ae,SAAUA,CAAM,EAC/B,IAAME,KAAiB,mBAAgCF,CAAM,EAE7D,SACE,OAAC,UAAO,SAAUE,EAChB,mBAACC,EAAA,CAAa,GAAGF,EAAY,OAAQD,EAAQ,EAC/C,CAEJ,CCdA,IAAAI,EAAoD,iBA2ChD,IAAAC,EAAA,6BAtCEC,KAAc,iBAAuC,IAAM,IAAG,EAAY,EAOzE,SAASC,GAAoB,CAClC,OAAAC,EAAS,KACT,OAAAC,EAAS,KACT,aAAAC,EAAe,KACf,SAAAC,CACF,EAA6B,CAC3B,GAAM,CAACC,EAAMC,CAAO,KAAI,YAAmE,IAAI,EAEzFC,EAAU,IAAM,CACpBD,EAAQ,IAAI,CACd,EAEME,EAA2C,CAACC,EAASC,IAAaC,GAAM,CAC5EA,EAAE,eAAe,EACjBA,EAAE,gBAAgB,EAClBL,EAAQ,CACN,EAAGK,EAAE,QACL,EAAGA,EAAE,QACL,QAAAF,EACA,OAAQC,GAAS,QAAUT,EAC3B,OAAQS,GAAS,QAAUR,EAC3B,aAAcQ,GAAS,cAAgBP,EACvC,UAAWO,GAAS,UACpB,MAAOA,GAAS,MAChB,GAAIA,GAAS,GACb,WAAYA,GAAS,WACrB,OAAQA,GAAS,MACnB,CAAC,CACH,EAEA,SACE,QAACX,EAAY,SAAZ,CAAqB,MAAOS,EAC1B,UAAAJ,EACAC,MAAQ,OAACO,EAAA,CAAkB,OAAQL,EAAU,GAAGF,EAAM,GACzD,CAEJ,CAKO,SAASQ,IAAiB,CAC/B,SAAO,cAAWd,CAAW,CAC/B",
6
+ "names": ["package_exports", "__export", "ContextMenuDivider", "ContextMenuItem", "ContextMenuPortal", "ContextMenuProvider", "humanize", "useContextMenu", "__toCommonJS", "React", "import_core", "import_jsx_runtime", "useStyles", "theme", "ContextMenuDivider", "className", "sx", "style", "cx", "classes", "import_core", "import_react", "import_core", "import_hooks", "import_react", "humanize", "value", "str", "import_jsx_runtime", "EMPTY_OBJECT", "useStyles", "theme", "ContextMenu", "x", "y", "content", "zIndex", "shadow", "borderRadius", "onHide", "className", "style", "sx", "classNames", "styles", "paperRef", "width", "height", "windowWidth", "windowHeight", "setRendered", "cx", "classes", "dir", "spacing", "styleProperties", "mdSpacing", "key", "onClick", "items", "title", "otherOptions", "ContextMenuItem", "humanize", "ContextMenuDivider", "import_jsx_runtime", "useStyles", "theme", "color", "verticalPadding", "ContextMenuItem", "className", "style", "icon", "title", "disabled", "onClick", "onHide", "borderRadius", "items", "ref", "submenuPosition", "setSubmenuPosition", "handleClick", "e", "showSubmenu", "y", "x", "hideSubmenu", "hasItemsAndIsNotDisabled", "cx", "classes", "ContextMenu", "import_core", "import_hooks", "import_jsx_runtime", "ContextMenuPortal", "onHide", "otherProps", "portalInnerRef", "ContextMenu", "import_react", "import_jsx_runtime", "MenuContext", "ContextMenuProvider", "zIndex", "shadow", "borderRadius", "children", "data", "setData", "destroy", "showContextMenu", "content", "options", "e", "ContextMenuPortal", "useContextMenu"]
7
7
  }
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import*as x from"react";import{Box as G,createStyles as J}from"@mantine/core";import{jsx as Z}from"react/jsx-runtime";var X=J(e=>({root:{height:1,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[1]}}));function D({className:e,sx:t,style:o}){let{cx:i,classes:s}=X();return Z(G,{className:i(s.root,e),sx:t,style:o})}import{Box as W,Text as se,UnstyledButton as ie,createStyles as ue,px as ae}from"@mantine/core";import{useRef as de,useState as pe}from"react";import{Paper as Q,createStyles as V,packSx as j,px as ee}from"@mantine/core";import{useResizeObserver as te}from"@mantine/hooks";import{useEffect as oe,useState as ne}from"react";function k(e){let t=e.replace(/([a-z\d])([A-Z]+)/g,"$1 $2").replace(/\W|_/g," ").trim().toLowerCase();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}import{jsx as O}from"react/jsx-runtime";var H={},re=V(e=>({root:{position:"fixed",border:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,overflow:"hidden",transition:"all .15s ease"}}));function P({x:e,y:t,content:o,zIndex:i,shadow:s,borderRadius:u,onHide:a,className:m,style:d,sx:n,classNames:r,styles:f}){let[M]=te(),{width:C,height:S}=M.current?.getBoundingClientRect()||{width:0,height:0},p=0,y=0;typeof window<"u"&&({innerWidth:p,innerHeight:y}=window);let[,g]=ne(!1);oe(()=>{g(!0)},[]);let{cx:l,classes:w,theme:R}=re(),{dir:U,spacing:K}=R,b=typeof f=="function"?f(R,H,H):f,c=ee(K.md);return O(Q,{ref:M,shadow:s,radius:u,className:l(w.root,m,r?.root),style:{...b?.root,...d},sx:[{zIndex:i,top:t+S+c>y?y-S-c:t,left:U==="ltr"?e+C+c>p?p-C-c:e:p-c-(e-C-c<0?C+c:e)},...j(n)],children:Array.isArray(o)?o.map(({key:h,className:I,sx:T,style:B,onClick:z,items:E,title:Y,..._})=>z||E?O(N,{className:l(r?.item,I),sx:T,style:{...b?.item,...B},title:Y??k(h),onClick:z,onHide:a,items:E,..._},h):O(D,{className:l(r?.divider,I),sx:T,style:{...b?.divider,...B}},h)):o(a)})}import{jsx as v,jsxs as L}from"react/jsx-runtime";var le=ue((e,{color:t})=>{let o=ae(e.spacing.sm)/2;return{button:{width:"100%",display:"flex",alignItems:"center",paddingTop:o,paddingBottom:o,paddingLeft:e.spacing.sm,paddingRight:e.spacing.sm,color:t&&e.colors[t][6],transition:"background .15s ease","&[disabled]":{cursor:"not-allowed",color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[5]},"&:hover:not([disabled])":{background:e.fn.rgba(t?e.colors[t][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],t?e.colorScheme==="dark"?.15:.08:.25)},"&:active:not([disabled])":{background:e.fn.rgba(t?e.colors[t][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],t?e.colorScheme==="dark"?.3:.2:.5)}},title:{whiteSpace:"nowrap",flexGrow:1}}});function N({className:e,style:t,icon:o,title:i,color:s,disabled:u,onClick:a,onHide:m,items:d}){let n=de(null),[r,f]=pe(null),M=a?l=>{m(),a(l)}:void 0,C=()=>{let{top:l,right:w}=n.current.getBoundingClientRect();f({x:w,y:l})},S=()=>{f(null)},p=d&&!u,{cx:y,classes:g}=le({color:s});return L("div",{onMouseOver:p?C:void 0,onMouseOut:p?S:void 0,children:[L(ie,{ref:n,className:y(g.button,e),style:t,disabled:u,onClick:M,children:[o&&v(W,{fz:0,mr:"xs",children:o}),v(se,{className:g.title,size:"sm",children:i}),d&&v(W,{fz:10,mt:-2,ml:"xs",children:"\u25B6"})]}),r&&v(P,{content:d,onHide:m,...r})]})}import{Portal as ce}from"@mantine/core";import{useClickOutside as xe,useWindowEvent as A}from"@mantine/hooks";import{jsx as $}from"react/jsx-runtime";function q({onHide:e,...t}){A("resize",e),A("scroll",e);let o=xe(e);return $(ce,{innerRef:o,children:$(P,{...t,onHide:e})})}import{createContext as me,useContext as fe,useState as Ce}from"react";import{jsx as ye,jsxs as Me}from"react/jsx-runtime";var F=me(()=>()=>{});function Qe({zIndex:e=9999,shadow:t="sm",borderRadius:o="xs",children:i}){let[s,u]=Ce(null),a=()=>{u(null)},m=(d,n)=>r=>{r.preventDefault(),r.stopPropagation(),u({x:r.clientX,y:r.clientY,content:d,zIndex:n?.zIndex||e,shadow:n?.shadow||t,borderRadius:n?.borderRadius||o,className:n?.className,style:n?.style,sx:n?.sx,classNames:n?.classNames,styles:n?.styles})};return Me(F.Provider,{value:m,children:[i,s&&ye(q,{onHide:a,...s})]})}function Ve(){return fe(F)}export{D as ContextMenuDivider,N as ContextMenuItem,q as ContextMenuPortal,Qe as ContextMenuProvider,k as humanize,Ve as useContextMenu};
1
+ import*as p from"react";import{Box as G,createStyles as J}from"@mantine/core";import{jsx as Z}from"react/jsx-runtime";var X=J(e=>({root:{height:1,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[1]}}));function E({className:e,sx:t,style:o}){let{cx:u,classes:s}=X();return Z(G,{className:u(s.root,e),sx:t,style:o})}import{Box as W,Text as se,UnstyledButton as ie,createStyles as ue,px as ae}from"@mantine/core";import{useRef as de,useState as pe}from"react";import{Paper as Q,createStyles as V,packSx as j,px as ee}from"@mantine/core";import{useResizeObserver as te}from"@mantine/hooks";import{useEffect as oe,useState as ne}from"react";function R(e){let t=e.replace(/([a-z\d])([A-Z]+)/g,"$1 $2").replace(/\W|_/g," ").trim().toLowerCase();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}import{jsx as O}from"react/jsx-runtime";var D={},re=V(e=>({root:{position:"fixed",border:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,overflow:"hidden",transition:"all .15s ease"}}));function b({x:e,y:t,content:o,zIndex:u,shadow:s,borderRadius:i,onHide:a,className:l,style:C,sx:n,classNames:r,styles:c}){let[M]=te(),{width:x,height:g}=M.current?.getBoundingClientRect()||{width:0,height:0},m=0,f=0;typeof window<"u"&&({innerWidth:m,innerHeight:f}=window);let[,w]=ne(!1);oe(()=>{w(!0)},[]);let{cx:y,classes:S,theme:P}=re(),{dir:U,spacing:K}=P,h=typeof c=="function"?c(P,D,D):c,d=ee(K.md);return O(Q,{ref:M,shadow:s,radius:i,className:y(S.root,l,r?.root),style:{...h?.root,...C},sx:[{zIndex:u,top:t+g+d>f?f-g-d:t,left:U==="ltr"?e+x+d>m?m-x-d:e:m-d-(e-x-d<0?x+d:e)},...j(n)],children:Array.isArray(o)?o.map(({key:k,className:I,sx:z,style:T,onClick:B,items:N,title:Y,..._})=>B||N?O(H,{className:y(r?.item,I),sx:z,style:{...h?.item,...T},title:Y??R(k),onClick:B,onHide:a,borderRadius:i,items:N,..._},k):O(E,{className:y(r?.divider,I),sx:z,style:{...h?.divider,...T}},k)):o(a)})}import{jsx as v,jsxs as L}from"react/jsx-runtime";var le=ue((e,{color:t})=>{let o=ae(e.spacing.sm)/2;return{button:{width:"100%",display:"flex",alignItems:"center",paddingTop:o,paddingBottom:o,paddingLeft:e.spacing.sm,paddingRight:e.spacing.sm,color:t&&e.colors[t][6],transition:"background .15s ease","&[disabled]":{cursor:"not-allowed",color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[5]},"&:hover:not([disabled])":{background:e.fn.rgba(t?e.colors[t][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],t?e.colorScheme==="dark"?.15:.08:.25)},"&:active:not([disabled])":{background:e.fn.rgba(t?e.colors[t][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],t?e.colorScheme==="dark"?.3:.2:.5)}},title:{whiteSpace:"nowrap",flexGrow:1}}});function H({className:e,style:t,icon:o,title:u,color:s,disabled:i,onClick:a,onHide:l,borderRadius:C,items:n}){let r=de(null),[c,M]=pe(null),x=a?S=>{l(),a(S)}:void 0,g=()=>{let{top:S,right:P}=r.current.getBoundingClientRect();M({x:P,y:S})},m=()=>{M(null)},f=n&&!i,{cx:w,classes:y}=le({color:s});return L("div",{onMouseOver:f?g:void 0,onMouseOut:f?m:void 0,children:[L(ie,{ref:r,className:w(y.button,e),style:t,disabled:i,onClick:x,children:[o&&v(W,{fz:0,mr:"xs",children:o}),v(se,{className:y.title,size:"sm",children:u}),n&&v(W,{fz:10,mt:-2,ml:"xs",children:"\u25B6"})]}),c&&v(b,{content:n,borderRadius:C,onHide:l,...c})]})}import{Portal as ce}from"@mantine/core";import{useClickOutside as xe,useWindowEvent as A}from"@mantine/hooks";import{jsx as $}from"react/jsx-runtime";function q({onHide:e,...t}){A("resize",e),A("scroll",e);let o=xe(e);return $(ce,{innerRef:o,children:$(b,{...t,onHide:e})})}import{createContext as me,useContext as fe,useState as ye}from"react";import{jsx as Ce,jsxs as Me}from"react/jsx-runtime";var F=me(()=>()=>{});function Ze({zIndex:e=9999,shadow:t="sm",borderRadius:o="xs",children:u}){let[s,i]=ye(null),a=()=>{i(null)},l=(C,n)=>r=>{r.preventDefault(),r.stopPropagation(),i({x:r.clientX,y:r.clientY,content:C,zIndex:n?.zIndex||e,shadow:n?.shadow||t,borderRadius:n?.borderRadius||o,className:n?.className,style:n?.style,sx:n?.sx,classNames:n?.classNames,styles:n?.styles})};return Me(F.Provider,{value:l,children:[u,s&&Ce(q,{onHide:a,...s})]})}function Qe(){return fe(F)}export{E as ContextMenuDivider,H as ContextMenuItem,q as ContextMenuPortal,Ze as ContextMenuProvider,R as humanize,Qe as useContextMenu};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../react-shim.mjs", "../ContextMenuDivider.tsx", "../ContextMenuItem.tsx", "../ContextMenu.tsx", "../utils.ts", "../ContextMenuPortal.tsx", "../ContextMenuProvider.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { Box, createStyles, type Sx } from '@mantine/core';\nimport type { CSSProperties } from 'react';\n\nconst useStyles = createStyles((theme) => ({\n root: {\n height: 1,\n background: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],\n },\n}));\n\nexport type ContextMenuDividerProps = {\n className: string;\n sx: Sx | (Sx | undefined)[] | undefined;\n style: CSSProperties;\n};\n\nexport function ContextMenuDivider({ className, sx, style }: ContextMenuDividerProps) {\n const { cx, classes } = useStyles();\n return <Box className={cx(classes.root, className)} sx={sx} style={style} />;\n}\n", "import { Box, Text, UnstyledButton, createStyles, px, type MantineColor } from '@mantine/core';\nimport { MouseEventHandler, useRef, useState } from 'react';\nimport { ContextMenu } from './ContextMenu';\nimport { ContextMenuContent, ContextMenuItemOptions } from './types';\nimport { WithRequiredProperty } from './utils';\n\nconst useStyles = createStyles((theme, { color }: { color?: MantineColor }) => {\n const verticalPadding = px(theme.spacing.sm) / 2;\n return {\n button: {\n width: '100%',\n display: 'flex',\n alignItems: 'center',\n paddingTop: verticalPadding,\n paddingBottom: verticalPadding,\n paddingLeft: theme.spacing.sm,\n paddingRight: theme.spacing.sm,\n color: color && theme.colors[color][6],\n transition: 'background .15s ease',\n '&[disabled]': {\n cursor: 'not-allowed',\n color: theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[5],\n },\n '&:hover:not([disabled])': {\n background: theme.fn.rgba(\n color ? theme.colors[color][6] : theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[4],\n color ? (theme.colorScheme === 'dark' ? 0.15 : 0.08) : 0.25\n ),\n },\n '&:active:not([disabled])': {\n background: theme.fn.rgba(\n color ? theme.colors[color][6] : theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[4],\n color ? (theme.colorScheme === 'dark' ? 0.3 : 0.2) : 0.5\n ),\n },\n },\n title: {\n whiteSpace: 'nowrap',\n flexGrow: 1,\n },\n };\n});\n\nexport function ContextMenuItem({\n className,\n style,\n icon,\n title,\n color,\n disabled,\n onClick,\n onHide,\n items,\n}: WithRequiredProperty<Omit<ContextMenuItemOptions, 'key'>, 'title'> & { onHide: () => void }) {\n const ref = useRef<HTMLButtonElement>(null);\n const [submenuPosition, setSubmenuPosition] = useState<{ x: number; y: number } | null>(null);\n\n const handleClick: MouseEventHandler<HTMLButtonElement> | undefined = onClick\n ? (e) => {\n onHide();\n onClick!(e);\n }\n : undefined;\n\n const showSubmenu = () => {\n const { top: y, right: x } = ref.current!.getBoundingClientRect();\n setSubmenuPosition({ x, y });\n };\n\n const hideSubmenu = () => {\n setSubmenuPosition(null);\n };\n\n const hasItemsAndIsNotDisabled = items && !disabled;\n const { cx, classes } = useStyles({ color });\n\n return (\n <div\n onMouseOver={hasItemsAndIsNotDisabled ? showSubmenu : undefined}\n onMouseOut={hasItemsAndIsNotDisabled ? hideSubmenu : undefined}\n >\n <UnstyledButton\n ref={ref}\n className={cx(classes.button, className)}\n style={style}\n disabled={disabled}\n onClick={handleClick}\n >\n {icon && (\n <Box fz={0} mr=\"xs\">\n {icon}\n </Box>\n )}\n <Text className={classes.title} size=\"sm\">\n {title}\n </Text>\n {items && (\n <Box fz={10} mt={-2} ml=\"xs\">\n \u25B6\n </Box>\n )}\n </UnstyledButton>\n {submenuPosition && <ContextMenu content={items as ContextMenuContent} onHide={onHide} {...submenuPosition} />}\n </div>\n );\n}\n", "import { Paper, createStyles, packSx, px } from '@mantine/core';\nimport { useResizeObserver } from '@mantine/hooks';\nimport { CSSProperties, useEffect, useState } from 'react';\nimport { ContextMenuDivider } from './ContextMenuDivider';\nimport { ContextMenuItem } from './ContextMenuItem';\nimport type { ContextMenuContent, ContextMenuOptions } from './types';\nimport { humanize } from './utils';\n\nconst EMPTY_OBJECT = {};\n\nconst useStyles = createStyles((theme) => ({\n root: {\n position: 'fixed',\n border: `1px solid ${theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`,\n overflow: 'hidden',\n transition: 'all .15s ease',\n },\n}));\n\nexport type ContextMenuInstanceOptions = {\n x: number;\n y: number;\n content: ContextMenuContent;\n};\n\nexport type ContextMenuProps = ContextMenuOptions &\n ContextMenuInstanceOptions & {\n onHide: () => void;\n };\n\nexport function ContextMenu({\n x,\n y,\n content,\n zIndex,\n shadow,\n borderRadius,\n onHide,\n className,\n style,\n sx,\n classNames,\n styles,\n}: ContextMenuProps) {\n const [paperRef] = useResizeObserver<HTMLDivElement>();\n const { width, height } = paperRef.current?.getBoundingClientRect() || { width: 0, height: 0 };\n\n let windowWidth = 0;\n let windowHeight = 0;\n if (typeof window !== 'undefined') ({ innerWidth: windowWidth, innerHeight: windowHeight } = window);\n\n // trigger a rerender to make sure that context menu is positioned correctly\n const [, setRendered] = useState(false);\n useEffect(() => {\n setRendered(true);\n }, []);\n\n const { cx, classes, theme } = useStyles();\n const { dir, spacing } = theme;\n const styleProperties = typeof styles === 'function' ? styles(theme, EMPTY_OBJECT, EMPTY_OBJECT) : styles;\n const mdSpacing = px(spacing.md);\n\n return (\n <Paper\n ref={paperRef}\n shadow={shadow}\n radius={borderRadius}\n className={cx(classes.root, className, classNames?.root)}\n style={{ ...styleProperties?.root, ...style } as CSSProperties}\n sx={[\n {\n zIndex,\n top: y + height + mdSpacing > windowHeight ? windowHeight - height - mdSpacing : y,\n left:\n dir === 'ltr'\n ? x + width + mdSpacing > windowWidth\n ? windowWidth - width - mdSpacing\n : x\n : windowWidth - mdSpacing - (x - width - mdSpacing < 0 ? width + mdSpacing : x),\n },\n ...packSx(sx),\n ]}\n >\n {Array.isArray(content)\n ? content.map(({ key, className, sx, style, onClick, items, title, ...otherOptions }) =>\n onClick || items ? (\n <ContextMenuItem\n key={key}\n className={cx(classNames?.item, className)}\n sx={sx}\n style={{ ...styleProperties?.item, ...style } as CSSProperties}\n title={title ?? humanize(key)}\n onClick={onClick}\n onHide={onHide}\n items={items}\n {...otherOptions}\n />\n ) : (\n <ContextMenuDivider\n key={key}\n className={cx(classNames?.divider, className)}\n sx={sx}\n style={{ ...styleProperties?.divider, ...style } as CSSProperties}\n />\n )\n )\n : content(onHide)}\n </Paper>\n );\n}\n", "export type WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\n/**\n * Utility function that returns a humanized version of a string, e.g. \"camelCase\" -> \"Camel Case\"\n */\nexport function humanize(value: string) {\n const str = value\n .replace(/([a-z\\d])([A-Z]+)/g, '$1 $2')\n .replace(/\\W|_/g, ' ')\n .trim()\n .toLowerCase();\n return `${str.charAt(0).toUpperCase()}${str.slice(1)}`;\n}\n", "import { Portal } from '@mantine/core';\nimport { useClickOutside, useWindowEvent } from '@mantine/hooks';\nimport { ContextMenu, type ContextMenuProps } from './ContextMenu';\n\nexport function ContextMenuPortal({ onHide, ...otherProps }: ContextMenuProps) {\n useWindowEvent('resize', onHide);\n useWindowEvent('scroll', onHide);\n const portalInnerRef = useClickOutside<HTMLDivElement>(onHide);\n\n return (\n <Portal innerRef={portalInnerRef}>\n <ContextMenu {...otherProps} onHide={onHide} />\n </Portal>\n );\n}\n", "import { createContext, useContext, useState } from 'react';\nimport { ContextMenuInstanceOptions } from './ContextMenu';\nimport { ContextMenuPortal } from './ContextMenuPortal';\nimport type { ContextMenuOptions, ContextMenuProviderProps, ShowContextMenuFunction } from './types';\n\nconst MenuContext = createContext<ShowContextMenuFunction>(() => () => undefined);\n\n/**\n * Provider that allows to show a context menu anywhere in your application.\n * If you wrap your application with this provider, you can use the `useContextMenu` hook\n * anywhere in the component tree to access a function that shows the context menu.\n */\nexport function ContextMenuProvider({\n zIndex = 9999,\n shadow = 'sm',\n borderRadius = 'xs',\n children,\n}: ContextMenuProviderProps) {\n const [data, setData] = useState<(ContextMenuInstanceOptions & ContextMenuOptions) | null>(null);\n\n const destroy = () => {\n setData(null);\n };\n\n const showContextMenu: ShowContextMenuFunction = (content, options) => (e) => {\n e.preventDefault();\n e.stopPropagation();\n setData({\n x: e.clientX,\n y: e.clientY,\n content,\n zIndex: options?.zIndex || zIndex,\n shadow: options?.shadow || shadow,\n borderRadius: options?.borderRadius || borderRadius,\n className: options?.className,\n style: options?.style,\n sx: options?.sx,\n classNames: options?.classNames,\n styles: options?.styles,\n });\n };\n\n return (\n <MenuContext.Provider value={showContextMenu}>\n {children}\n {data && <ContextMenuPortal onHide={destroy} {...data} />}\n </MenuContext.Provider>\n );\n}\n\n/**\n * Hook returning a function that shows a context menu.\n */\nexport function useContextMenu() {\n return useContext(MenuContext);\n}\n"],
5
- "mappings": "AAAA,UAAYA,MAAW,QCAvB,OAAS,OAAAC,EAAK,gBAAAC,MAA6B,gBAkBlC,cAAAC,MAAA,oBAfT,IAAMC,EAAYF,EAAcG,IAAW,CACzC,KAAM,CACJ,OAAQ,EACR,WAAYA,EAAM,cAAgB,OAASA,EAAM,OAAO,KAAK,CAAC,EAAIA,EAAM,OAAO,KAAK,CAAC,CACvF,CACF,EAAE,EAQK,SAASC,EAAmB,CAAE,UAAAC,EAAW,GAAAC,EAAI,MAAAC,CAAM,EAA4B,CACpF,GAAM,CAAE,GAAAC,EAAI,QAAAC,CAAQ,EAAIP,EAAU,EAClC,OAAOD,EAACF,EAAA,CAAI,UAAWS,EAAGC,EAAQ,KAAMJ,CAAS,EAAG,GAAIC,EAAI,M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,EAChB,SAAAL,EAACQ,EAAA,CAAa,GAAGL,EAAY,OAAQD,EAAQ,EAC/C,CAEJ,CCdA,OAAS,iBAAAO,GAAe,cAAAC,GAAY,YAAAC,OAAgB,QA2ChD,OAEW,OAAAC,GAFX,QAAAC,OAAA,oBAtCJ,IAAMC,EAAcC,GAAuC,IAAM,IAAG,EAAY,EAOzE,SAASC,GAAoB,CAClC,OAAAC,EAAS,KACT,OAAAC,EAAS,KACT,aAAAC,EAAe,KACf,SAAAC,CACF,EAA6B,CAC3B,GAAM,CAACC,EAAMC,CAAO,EAAIC,GAAmE,IAAI,EAEzFC,EAAU,IAAM,CACpBF,EAAQ,IAAI,CACd,EAEMG,EAA2C,CAACC,EAASC,IAAaC,GAAM,CAC5EA,EAAE,eAAe,EACjBA,EAAE,gBAAgB,EAClBN,EAAQ,CACN,EAAGM,EAAE,QACL,EAAGA,EAAE,QACL,QAAAF,EACA,OAAQC,GAAS,QAAUV,EAC3B,OAAQU,GAAS,QAAUT,EAC3B,aAAcS,GAAS,cAAgBR,EACvC,UAAWQ,GAAS,UACpB,MAAOA,GAAS,MAChB,GAAIA,GAAS,GACb,WAAYA,GAAS,WACrB,OAAQA,GAAS,MACnB,CAAC,CACH,EAEA,OACEd,GAACC,EAAY,SAAZ,CAAqB,MAAOW,EAC1B,UAAAL,EACAC,GAAQT,GAACiB,EAAA,CAAkB,OAAQL,EAAU,GAAGH,EAAM,GACzD,CAEJ,CAKO,SAASS,IAAiB,CAC/B,OAAOC,GAAWjB,CAAW,CAC/B",
6
- "names": ["React", "Box", "createStyles", "jsx", "useStyles", "theme", "ContextMenuDivider", "className", "sx", "style", "cx", "classes", "Box", "Text", "UnstyledButton", "createStyles", "px", "useRef", "useState", "Paper", "createStyles", "packSx", "px", "useResizeObserver", "useEffect", "useState", "humanize", "value", "str", "jsx", "EMPTY_OBJECT", "useStyles", "createStyles", "theme", "ContextMenu", "x", "y", "content", "zIndex", "shadow", "borderRadius", "onHide", "className", "style", "sx", "classNames", "styles", "paperRef", "useResizeObserver", "width", "height", "windowWidth", "windowHeight", "setRendered", "useState", "useEffect", "cx", "classes", "dir", "spacing", "styleProperties", "mdSpacing", "px", "Paper", "packSx", "key", "onClick", "items", "title", "otherOptions", "ContextMenuItem", "humanize", "ContextMenuDivider", "jsx", "jsxs", "useStyles", "createStyles", "theme", "color", "verticalPadding", "px", "ContextMenuItem", "className", "style", "icon", "title", "disabled", "onClick", "onHide", "items", "ref", "useRef", "submenuPosition", "setSubmenuPosition", "useState", "handleClick", "e", "showSubmenu", "y", "x", "hideSubmenu", "hasItemsAndIsNotDisabled", "cx", "classes", "UnstyledButton", "Box", "Text", "ContextMenu", "Portal", "useClickOutside", "useWindowEvent", "jsx", "ContextMenuPortal", "onHide", "otherProps", "useWindowEvent", "portalInnerRef", "useClickOutside", "Portal", "ContextMenu", "createContext", "useContext", "useState", "jsx", "jsxs", "MenuContext", "createContext", "ContextMenuProvider", "zIndex", "shadow", "borderRadius", "children", "data", "setData", "useState", "destroy", "showContextMenu", "content", "options", "e", "ContextMenuPortal", "useContextMenu", "useContext"]
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { Box, createStyles, type Sx } from '@mantine/core';\nimport type { CSSProperties } from 'react';\n\nconst useStyles = createStyles((theme) => ({\n root: {\n height: 1,\n background: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],\n },\n}));\n\nexport type ContextMenuDividerProps = {\n className: string;\n sx: Sx | (Sx | undefined)[] | undefined;\n style: CSSProperties;\n};\n\nexport function ContextMenuDivider({ className, sx, style }: ContextMenuDividerProps) {\n const { cx, classes } = useStyles();\n return <Box className={cx(classes.root, className)} sx={sx} style={style} />;\n}\n", "import { Box, Text, UnstyledButton, createStyles, px, type MantineColor, type MantineNumberSize } from '@mantine/core';\nimport { useRef, useState, type MouseEventHandler } from 'react';\nimport { ContextMenu } from './ContextMenu';\nimport type { ContextMenuContent, ContextMenuItemOptions } from './types';\nimport type { WithRequiredProperty } from './utils';\n\nconst useStyles = createStyles((theme, { color }: { color?: MantineColor }) => {\n const verticalPadding = px(theme.spacing.sm) / 2;\n return {\n button: {\n width: '100%',\n display: 'flex',\n alignItems: 'center',\n paddingTop: verticalPadding,\n paddingBottom: verticalPadding,\n paddingLeft: theme.spacing.sm,\n paddingRight: theme.spacing.sm,\n color: color && theme.colors[color][6],\n transition: 'background .15s ease',\n '&[disabled]': {\n cursor: 'not-allowed',\n color: theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[5],\n },\n '&:hover:not([disabled])': {\n background: theme.fn.rgba(\n color ? theme.colors[color][6] : theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[4],\n color ? (theme.colorScheme === 'dark' ? 0.15 : 0.08) : 0.25\n ),\n },\n '&:active:not([disabled])': {\n background: theme.fn.rgba(\n color ? theme.colors[color][6] : theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[4],\n color ? (theme.colorScheme === 'dark' ? 0.3 : 0.2) : 0.5\n ),\n },\n },\n title: {\n whiteSpace: 'nowrap',\n flexGrow: 1,\n },\n };\n});\n\nexport function ContextMenuItem({\n className,\n style,\n icon,\n title,\n color,\n disabled,\n onClick,\n onHide,\n borderRadius,\n items,\n}: WithRequiredProperty<Omit<ContextMenuItemOptions, 'key'>, 'title'> & {\n borderRadius: MantineNumberSize | undefined;\n onHide: () => void;\n}) {\n const ref = useRef<HTMLButtonElement>(null);\n const [submenuPosition, setSubmenuPosition] = useState<{ x: number; y: number } | null>(null);\n\n const handleClick: MouseEventHandler<HTMLButtonElement> | undefined = onClick\n ? (e) => {\n onHide();\n onClick!(e);\n }\n : undefined;\n\n const showSubmenu = () => {\n const { top: y, right: x } = ref.current!.getBoundingClientRect();\n setSubmenuPosition({ x, y });\n };\n\n const hideSubmenu = () => {\n setSubmenuPosition(null);\n };\n\n const hasItemsAndIsNotDisabled = items && !disabled;\n const { cx, classes } = useStyles({ color });\n\n return (\n <div\n onMouseOver={hasItemsAndIsNotDisabled ? showSubmenu : undefined}\n onMouseOut={hasItemsAndIsNotDisabled ? hideSubmenu : undefined}\n >\n <UnstyledButton\n ref={ref}\n className={cx(classes.button, className)}\n style={style}\n disabled={disabled}\n onClick={handleClick}\n >\n {icon && (\n <Box fz={0} mr=\"xs\">\n {icon}\n </Box>\n )}\n <Text className={classes.title} size=\"sm\">\n {title}\n </Text>\n {items && (\n <Box fz={10} mt={-2} ml=\"xs\">\n \u25B6\n </Box>\n )}\n </UnstyledButton>\n {submenuPosition && (\n <ContextMenu\n content={items as ContextMenuContent}\n borderRadius={borderRadius}\n onHide={onHide}\n {...submenuPosition}\n />\n )}\n </div>\n );\n}\n", "import { Paper, createStyles, packSx, px } from '@mantine/core';\nimport { useResizeObserver } from '@mantine/hooks';\nimport { CSSProperties, useEffect, useState } from 'react';\nimport { ContextMenuDivider } from './ContextMenuDivider';\nimport { ContextMenuItem } from './ContextMenuItem';\nimport type { ContextMenuContent, ContextMenuOptions } from './types';\nimport { humanize } from './utils';\n\nconst EMPTY_OBJECT = {};\n\nconst useStyles = createStyles((theme) => ({\n root: {\n position: 'fixed',\n border: `1px solid ${theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`,\n overflow: 'hidden',\n transition: 'all .15s ease',\n },\n}));\n\nexport type ContextMenuInstanceOptions = {\n x: number;\n y: number;\n content: ContextMenuContent;\n};\n\nexport type ContextMenuProps = ContextMenuOptions &\n ContextMenuInstanceOptions & {\n onHide: () => void;\n };\n\nexport function ContextMenu({\n x,\n y,\n content,\n zIndex,\n shadow,\n borderRadius,\n onHide,\n className,\n style,\n sx,\n classNames,\n styles,\n}: ContextMenuProps) {\n const [paperRef] = useResizeObserver<HTMLDivElement>();\n const { width, height } = paperRef.current?.getBoundingClientRect() || { width: 0, height: 0 };\n\n let windowWidth = 0;\n let windowHeight = 0;\n if (typeof window !== 'undefined') ({ innerWidth: windowWidth, innerHeight: windowHeight } = window);\n\n // trigger a rerender to make sure that context menu is positioned correctly\n const [, setRendered] = useState(false);\n useEffect(() => {\n setRendered(true);\n }, []);\n\n const { cx, classes, theme } = useStyles();\n const { dir, spacing } = theme;\n const styleProperties = typeof styles === 'function' ? styles(theme, EMPTY_OBJECT, EMPTY_OBJECT) : styles;\n const mdSpacing = px(spacing.md);\n\n return (\n <Paper\n ref={paperRef}\n shadow={shadow}\n radius={borderRadius}\n className={cx(classes.root, className, classNames?.root)}\n style={{ ...styleProperties?.root, ...style } as CSSProperties}\n sx={[\n {\n zIndex,\n top: y + height + mdSpacing > windowHeight ? windowHeight - height - mdSpacing : y,\n left:\n dir === 'ltr'\n ? x + width + mdSpacing > windowWidth\n ? windowWidth - width - mdSpacing\n : x\n : windowWidth - mdSpacing - (x - width - mdSpacing < 0 ? width + mdSpacing : x),\n },\n ...packSx(sx),\n ]}\n >\n {Array.isArray(content)\n ? content.map(({ key, className, sx, style, onClick, items, title, ...otherOptions }) =>\n onClick || items ? (\n <ContextMenuItem\n key={key}\n className={cx(classNames?.item, className)}\n sx={sx}\n style={{ ...styleProperties?.item, ...style } as CSSProperties}\n title={title ?? humanize(key)}\n onClick={onClick}\n onHide={onHide}\n borderRadius={borderRadius}\n items={items}\n {...otherOptions}\n />\n ) : (\n <ContextMenuDivider\n key={key}\n className={cx(classNames?.divider, className)}\n sx={sx}\n style={{ ...styleProperties?.divider, ...style } as CSSProperties}\n />\n )\n )\n : content(onHide)}\n </Paper>\n );\n}\n", "export type WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\n/**\n * Utility function that returns a humanized version of a string, e.g. \"camelCase\" -> \"Camel Case\"\n */\nexport function humanize(value: string) {\n const str = value\n .replace(/([a-z\\d])([A-Z]+)/g, '$1 $2')\n .replace(/\\W|_/g, ' ')\n .trim()\n .toLowerCase();\n return `${str.charAt(0).toUpperCase()}${str.slice(1)}`;\n}\n", "import { Portal } from '@mantine/core';\nimport { useClickOutside, useWindowEvent } from '@mantine/hooks';\nimport { ContextMenu, type ContextMenuProps } from './ContextMenu';\n\nexport function ContextMenuPortal({ onHide, ...otherProps }: ContextMenuProps) {\n useWindowEvent('resize', onHide);\n useWindowEvent('scroll', onHide);\n const portalInnerRef = useClickOutside<HTMLDivElement>(onHide);\n\n return (\n <Portal innerRef={portalInnerRef}>\n <ContextMenu {...otherProps} onHide={onHide} />\n </Portal>\n );\n}\n", "import { createContext, useContext, useState } from 'react';\nimport { ContextMenuInstanceOptions } from './ContextMenu';\nimport { ContextMenuPortal } from './ContextMenuPortal';\nimport type { ContextMenuOptions, ContextMenuProviderProps, ShowContextMenuFunction } from './types';\n\nconst MenuContext = createContext<ShowContextMenuFunction>(() => () => undefined);\n\n/**\n * Provider that allows to show a context menu anywhere in your application.\n * If you wrap your application with this provider, you can use the `useContextMenu` hook\n * anywhere in the component tree to access a function that shows the context menu.\n */\nexport function ContextMenuProvider({\n zIndex = 9999,\n shadow = 'sm',\n borderRadius = 'xs',\n children,\n}: ContextMenuProviderProps) {\n const [data, setData] = useState<(ContextMenuInstanceOptions & ContextMenuOptions) | null>(null);\n\n const destroy = () => {\n setData(null);\n };\n\n const showContextMenu: ShowContextMenuFunction = (content, options) => (e) => {\n e.preventDefault();\n e.stopPropagation();\n setData({\n x: e.clientX,\n y: e.clientY,\n content,\n zIndex: options?.zIndex || zIndex,\n shadow: options?.shadow || shadow,\n borderRadius: options?.borderRadius || borderRadius,\n className: options?.className,\n style: options?.style,\n sx: options?.sx,\n classNames: options?.classNames,\n styles: options?.styles,\n });\n };\n\n return (\n <MenuContext.Provider value={showContextMenu}>\n {children}\n {data && <ContextMenuPortal onHide={destroy} {...data} />}\n </MenuContext.Provider>\n );\n}\n\n/**\n * Hook returning a function that shows a context menu.\n */\nexport function useContextMenu() {\n return useContext(MenuContext);\n}\n"],
5
+ "mappings": "AAAA,UAAYA,MAAW,QCAvB,OAAS,OAAAC,EAAK,gBAAAC,MAA6B,gBAkBlC,cAAAC,MAAA,oBAfT,IAAMC,EAAYF,EAAcG,I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OAAQL,EAAU,GAAGH,EAAM,GACzD,CAEJ,CAKO,SAASS,IAAiB,CAC/B,OAAOC,GAAWjB,CAAW,CAC/B",
6
+ "names": ["React", "Box", "createStyles", "jsx", "useStyles", "theme", "ContextMenuDivider", "className", "sx", "style", "cx", "classes", "Box", "Text", "UnstyledButton", "createStyles", "px", "useRef", "useState", "Paper", "createStyles", "packSx", "px", "useResizeObserver", "useEffect", "useState", "humanize", "value", "str", "jsx", "EMPTY_OBJECT", "useStyles", "createStyles", "theme", "ContextMenu", "x", "y", "content", "zIndex", "shadow", "borderRadius", "onHide", "className", "style", "sx", "classNames", "styles", "paperRef", "useResizeObserver", "width", "height", "windowWidth", "windowHeight", "setRendered", "useState", "useEffect", "cx", "classes", "dir", "spacing", "styleProperties", "mdSpacing", "px", "Paper", "packSx", "key", "onClick", "items", "title", "otherOptions", "ContextMenuItem", "humanize", "ContextMenuDivider", "jsx", "jsxs", "useStyles", "createStyles", "theme", "color", "verticalPadding", "px", "ContextMenuItem", "className", "style", "icon", "title", "disabled", "onClick", "onHide", "borderRadius", "items", "ref", "useRef", "submenuPosition", "setSubmenuPosition", "useState", "handleClick", "e", "showSubmenu", "y", "x", "hideSubmenu", "hasItemsAndIsNotDisabled", "cx", "classes", "UnstyledButton", "Box", "Text", "ContextMenu", "Portal", "useClickOutside", "useWindowEvent", "jsx", "ContextMenuPortal", "onHide", "otherProps", "useWindowEvent", "portalInnerRef", "useClickOutside", "Portal", "ContextMenu", "createContext", "useContext", "useState", "jsx", "jsxs", "MenuContext", "createContext", "ContextMenuProvider", "zIndex", "shadow", "borderRadius", "children", "data", "setData", "useState", "destroy", "showContextMenu", "content", "options", "e", "ContextMenuPortal", "useContextMenu", "useContext"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mantine-contextmenu",
3
- "version": "6.0.4",
3
+ "version": "6.0.6",
4
4
  "description": "Enhance your Mantine UI applications usability with customizable context menus",
5
5
  "keywords": [
6
6
  "ui",
@@ -55,7 +55,7 @@
55
55
  "devDependencies": {
56
56
  "@mantine/core": "^6.0.21",
57
57
  "@mantine/hooks": "^6.0.21",
58
- "@types/react": "^18.2.30",
58
+ "@types/react": "^18.2.31",
59
59
  "@types/react-dom": "^18.2.14",
60
60
  "esbuild": "^0.19.5",
61
61
  "react": "^18.2.0",