@mantine-vue/contextmenu 3.0.0 → 3.1.0

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/esm/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/utils.ts","../src/ContextMenuDivider.ts","../src/context.ts","../src/ContextMenuItem.ts","../src/ContextMenu.ts","../src/ContextMenuOverlay.ts","../src/ContextMenuPortal.ts","../src/ContextMenuProvider.ts"],"sourcesContent":["import type { ContextMenuStyle, ContextMenuStyles } from './types'\nimport type { MantineStyle, MantineTheme } from '@mantine-vue/core'\n\n/** Returns a humanized version of a string, for example \"camelCase\" becomes \"Camel Case\". */\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\n return `${str.charAt(0).toUpperCase()}${str.slice(1)}`\n}\n\nexport function resolveContextMenuStyle(\n style: ContextMenuStyle | undefined,\n theme: MantineTheme,\n): MantineStyle | undefined {\n return typeof style === 'function' ? style(theme) : style\n}\n\nexport function resolveContextMenuStyles(\n styles: ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles) | undefined,\n theme: MantineTheme,\n) {\n return typeof styles === 'function' ? styles(theme) : styles\n}\n","import { defineComponent, h, type PropType } from 'vue'\nimport { Box, useMantineTheme } from '@mantine-vue/core'\nimport { resolveContextMenuStyle } from './utils'\nimport type { ContextMenuDividerProps, ContextMenuStyle } from './types'\nimport './ContextMenuDivider.css'\n\nexport const ContextMenuDivider = defineComponent({\n name: 'ContextMenuDivider',\n props: {\n className: { type: String, default: undefined },\n style: {\n type: [Object, Function] as PropType<ContextMenuStyle>,\n default: undefined,\n },\n },\n setup(props: ContextMenuDividerProps) {\n const theme = useMantineTheme()\n\n return () =>\n h(Box, {\n class: ['mantine-contextmenu-divider', props.className],\n style: resolveContextMenuStyle(props.style, theme.value),\n })\n },\n})\n","import { inject, readonly, ref, type InjectionKey, type Ref } from 'vue'\nimport type { ContextMenuContextValue, ContextMenuSettings } from './types'\n\nexport interface ResolvedContextMenuSettings {\n shadow: NonNullable<ContextMenuSettings['shadow']>\n borderRadius: NonNullable<ContextMenuSettings['borderRadius']>\n submenuDelay: number\n repositionOnRepeat: boolean\n}\n\nexport const ContextMenuSettingsKey = Symbol('ContextMenuSettings') as InjectionKey<\n Ref<ResolvedContextMenuSettings>\n>\n\nexport const ContextMenuKey = Symbol('ContextMenu') as InjectionKey<ContextMenuContextValue>\n\nconst hidden = readonly(ref(false))\nconst fallback: ContextMenuContextValue = {\n showContextMenu: () => () => undefined,\n hideContextMenu: () => undefined,\n isContextMenuVisible: hidden,\n}\n\nexport function useContextMenu() {\n return inject(ContextMenuKey, fallback)\n}\n\nexport function useContextMenuSettings() {\n return inject(ContextMenuSettingsKey, {\n value: {\n shadow: 'sm',\n borderRadius: 'xs',\n submenuDelay: 500,\n repositionOnRepeat: false,\n },\n } as Ref<ResolvedContextMenuSettings>)\n}\n","import {\n defineComponent,\n h,\n ref,\n type DefineComponent,\n type PropType,\n type SlotsType,\n type VNode,\n type VNodeChild,\n} from 'vue'\nimport {\n Box,\n parseThemeColor,\n resolveNode,\n rgba,\n UnstyledButton,\n useMantineTheme,\n type MantineColor,\n type MantineNode,\n} from '@mantine-vue/core'\nimport { useMediaQuery, useTimeout } from '@mantine-vue/hooks'\nimport { ContextMenu } from './ContextMenu'\nimport { useContextMenuSettings } from './context'\nimport { resolveContextMenuStyle } from './utils'\nimport type {\n ContextMenuItemOptions,\n ContextMenuItemProps,\n ContextMenuSubmenuProps,\n ContextMenuStyle,\n} from './types'\nimport './ContextMenuItem.css'\n\nexport interface ContextMenuItemSlots {\n title?: () => VNodeChild\n icon?: () => VNodeChild\n iconRight?: () => VNodeChild\n}\n\nexport const ContextMenuItem = defineComponent({\n name: 'ContextMenuItem',\n slots: Object as SlotsType<ContextMenuItemSlots>,\n props: {\n title: {\n type: null as unknown as PropType<MantineNode>,\n default: undefined,\n },\n icon: {\n type: null as unknown as PropType<MantineNode>,\n default: undefined,\n },\n iconRight: {\n type: null as unknown as PropType<MantineNode>,\n default: undefined,\n },\n color: {\n type: String as PropType<MantineColor>,\n default: undefined,\n },\n disabled: { type: Boolean, default: false },\n onClick: {\n type: Function as PropType<(event: MouseEvent) => void>,\n default: undefined,\n },\n items: {\n type: Array as PropType<ContextMenuItemOptions[]>,\n default: undefined,\n },\n onHide: {\n type: Function as PropType<() => void>,\n required: true,\n },\n submenuProps: {\n type: Object as PropType<ContextMenuSubmenuProps>,\n required: true,\n },\n className: { type: String, default: undefined },\n style: {\n type: [Object, Function] as PropType<ContextMenuStyle>,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n const button = ref<HTMLElement | null>(null)\n const submenuPosition = ref<{ x: number; y: number } | null>(null)\n const settings = useContextMenuSettings()\n const theme = useMantineTheme()\n const hoverAvailable = useMediaQuery('(hover: hover)')\n\n const showSubmenuTimeout = useTimeout(() => {\n if (!button.value) {\n return\n }\n\n const rect = button.value.getBoundingClientRect()\n submenuPosition.value = {\n x: (props.submenuProps.dir || 'ltr') === 'ltr' ? rect.right : rect.left,\n y: rect.top,\n }\n }, settings.value.submenuDelay)\n\n const hideSubmenuTimeout = useTimeout(() => {\n submenuPosition.value = null\n }, settings.value.submenuDelay)\n\n const showSubmenu = () => {\n hideSubmenuTimeout.clear()\n showSubmenuTimeout.start()\n }\n\n const hideSubmenu = () => {\n showSubmenuTimeout.clear()\n hideSubmenuTimeout.start()\n }\n\n const handleSubmenuClick = (event: MouseEvent) => {\n event.stopPropagation()\n showSubmenu()\n }\n\n const handleActionClick = (event: MouseEvent) => {\n props.onHide()\n props.onClick?.(event)\n }\n\n const setButtonRef = (node: any) => {\n button.value = node?.$el ?? node ?? null\n }\n\n return (): VNode => {\n const hasSubmenu = Boolean(props.items && !props.disabled)\n const parsed = props.color\n ? parseThemeColor({ color: props.color, theme: theme.value })\n : null\n const itemColor = parsed?.value ?? 'var(--mantine-color-text)'\n const colorValue = parsed?.value\n const icon = resolveNode(props.icon, slots.icon)\n const title = resolveNode(props.title, slots.title)\n const iconRight = resolveNode(props.iconRight, slots.iconRight)\n\n return h(\n 'div',\n {\n onMouseenter: hasSubmenu && hoverAvailable.value ? showSubmenu : undefined,\n onMouseleave: hasSubmenu && hoverAvailable.value ? hideSubmenu : undefined,\n },\n [\n h(\n UnstyledButton,\n {\n ref: setButtonRef,\n dir: props.submenuProps.dir || 'ltr',\n class: ['mantine-contextmenu-item-button', props.className],\n disabled: props.disabled,\n style: {\n '--mantine-contextmenu-item-button-color': itemColor,\n '--mantine-contextmenu-item-button-hover-bg-color-light': colorValue\n ? rgba(colorValue, 0.08)\n : rgba(theme.value.colors.gray[4], 0.25),\n '--mantine-contextmenu-item-button-hover-bg-color-dark': colorValue\n ? rgba(colorValue, 0.15)\n : rgba(theme.value.colors.dark[3], 0.25),\n '--mantine-contextmenu-item-button-pressed-bg-color-light': colorValue\n ? rgba(colorValue, 0.2)\n : rgba(theme.value.colors.gray[4], 0.5),\n '--mantine-contextmenu-item-button-pressed-bg-color-dark': colorValue\n ? rgba(colorValue, 0.3)\n : rgba(theme.value.colors.dark[3], 0.5),\n ...resolveContextMenuStyle(props.style, theme.value),\n },\n onClick: hasSubmenu\n ? handleSubmenuClick\n : props.onClick\n ? handleActionClick\n : undefined,\n },\n () => [\n icon ? h(Box, { fz: 0, me: 'xs', mt: -2 }, () => icon) : null,\n h('div', { class: 'mantine-contextmenu-item-button-title' }, [title]),\n iconRight\n ? h(Box, { fz: 0, ms: 'xs', mt: -2 }, () => iconRight)\n : props.items\n ? h(Box, { mt: -1, ms: 'xs' }, () =>\n (props.submenuProps.dir || 'ltr') === 'rtl' ? '‹' : '›',\n )\n : null,\n ],\n ),\n submenuPosition.value && props.items\n ? h(ContextMenu, {\n ...props.submenuProps,\n x: submenuPosition.value.x,\n y: submenuPosition.value.y,\n content: props.items,\n onHide: props.onHide,\n dir: props.submenuProps.dir || 'ltr',\n })\n : null,\n ],\n )\n }\n },\n}) as unknown as DefineComponent<ContextMenuItemProps>\n","import {\n computed,\n defineComponent,\n h,\n onBeforeUnmount,\n ref,\n watch,\n type DefineComponent,\n type PropType,\n type VNode,\n type VNodeChild,\n} from 'vue'\nimport {\n Paper,\n px,\n useMantineTheme,\n type MantineRadius,\n type MantineTheme,\n} from '@mantine-vue/core'\nimport { useResizeObserver } from '@mantine-vue/hooks'\nimport { ContextMenuDivider } from './ContextMenuDivider'\nimport { ContextMenuItem } from './ContextMenuItem'\nimport { useContextMenuSettings } from './context'\nimport { resolveContextMenuStyle, resolveContextMenuStyles, humanize } from './utils'\nimport type {\n ContextMenuContent,\n ContextMenuOptions,\n ContextMenuProps,\n ContextMenuSubmenuProps,\n ContextMenuStyles,\n ContextMenuStyle,\n} from './types'\nimport './ContextMenu.css'\n\nexport const ContextMenu = defineComponent({\n name: 'ContextMenu',\n props: {\n x: { type: Number, required: true },\n y: { type: Number, required: true },\n content: {\n type: [Array, Function] as PropType<ContextMenuContent>,\n required: true,\n },\n onHide: {\n type: Function as PropType<() => void>,\n required: true,\n },\n zIndex: { type: Number, default: undefined },\n dir: {\n type: String as PropType<'ltr' | 'rtl'>,\n default: 'ltr',\n },\n className: { type: String, default: undefined },\n style: {\n type: [Object, Function] as PropType<ContextMenuStyle>,\n default: undefined,\n },\n classNames: {\n type: Object as PropType<ContextMenuOptions['classNames']>,\n default: undefined,\n },\n styles: {\n type: [Object, Function] as PropType<\n ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles)\n >,\n default: undefined,\n },\n },\n setup(props: ContextMenuProps) {\n const settings = useContextMenuSettings()\n const theme = useMantineTheme()\n const { ref: menuRef, rect } = useResizeObserver<HTMLElement>()\n const mounted = ref(false)\n let frameId = 0\n\n watch(\n () => [rect.value.width, rect.value.height],\n ([width, height]) => {\n if (width > 0 && height > 0) {\n cancelAnimationFrame(frameId)\n frameId = requestAnimationFrame(() => {\n mounted.value = true\n })\n }\n },\n { immediate: true },\n )\n\n onBeforeUnmount(() => cancelAnimationFrame(frameId))\n\n const position = computed(() => {\n const spacing = px(theme.value.spacing.md)\n const windowWidth = typeof window === 'undefined' ? 0 : window.innerWidth\n const windowHeight = typeof window === 'undefined' ? 0 : window.innerHeight\n const top =\n props.y + rect.value.height + spacing > windowHeight\n ? windowHeight - rect.value.height - spacing\n : props.y\n const left =\n props.dir === 'rtl'\n ? props.x - rect.value.width < spacing\n ? spacing\n : props.x - rect.value.width\n : props.x + rect.value.width + spacing > windowWidth\n ? windowWidth - rect.value.width - spacing\n : props.x\n\n return { zIndex: props.zIndex, top: `${top}px`, left: `${left}px` }\n })\n\n const setMenuRef = (node: any) => {\n menuRef.value = node?.$el ?? node ?? null\n }\n\n return (): VNode => {\n const resolvedStyles = resolveContextMenuStyles(props.styles, theme.value)\n const submenuProps: ContextMenuSubmenuProps = {\n className: props.className,\n style: props.style,\n classNames: props.classNames,\n styles: props.styles,\n dir: props.dir,\n }\n\n const content: VNodeChild =\n typeof props.content === 'function'\n ? props.content(props.onHide)\n : props.content.map((item): VNodeChild => {\n if (item.hidden) {\n return null\n }\n\n if (item.onClick || item.items) {\n return h(ContextMenuItem, {\n key: item.key,\n className: [props.classNames?.item, item.className].filter(Boolean).join(' '),\n style: {\n ...resolveContextMenuStyle(resolvedStyles?.item, theme.value),\n ...resolveContextMenuStyle(item.style, theme.value),\n },\n title: item.title ?? humanize(item.key),\n icon: item.icon,\n iconRight: item.iconRight,\n color: item.color,\n disabled: item.disabled,\n onClick: item.onClick,\n items: item.items,\n onHide: props.onHide,\n submenuProps,\n })\n }\n\n return h(ContextMenuDivider, {\n key: item.key,\n className: [props.classNames?.divider, item.className].filter(Boolean).join(' '),\n style: {\n ...resolveContextMenuStyle(resolvedStyles?.divider, theme.value),\n ...resolveContextMenuStyle(item.style, theme.value),\n },\n })\n })\n\n return h(\n Paper,\n {\n ref: setMenuRef,\n shadow: settings.value.shadow,\n radius: settings.value.borderRadius as MantineRadius,\n dir: props.dir,\n class: [\n 'mantine-contextmenu',\n mounted.value && 'mantine-contextmenu-mounted',\n props.className,\n props.classNames?.root,\n ],\n style: {\n ...position.value,\n ...resolveContextMenuStyle(props.style, theme.value),\n ...resolveContextMenuStyle(resolvedStyles?.root, theme.value),\n },\n },\n () => content,\n )\n }\n },\n}) as unknown as DefineComponent<ContextMenuProps>\n","import { defineComponent, h, type PropType } from 'vue'\nimport { useContextMenuSettings } from './context'\nimport './ContextMenuOverlay.css'\n\nexport const ContextMenuOverlay = defineComponent({\n name: 'ContextMenuOverlay',\n props: {\n zIndex: { type: Number, default: undefined },\n onHide: {\n type: Function as PropType<() => void>,\n required: true,\n },\n },\n setup(props, { slots }) {\n const settings = useContextMenuSettings()\n\n const handleClick = (event: MouseEvent) => {\n event.preventDefault()\n props.onHide()\n }\n\n const handleContextMenu = (event: MouseEvent) => {\n event.preventDefault()\n\n if (!settings.value.repositionOnRepeat) {\n props.onHide()\n return\n }\n\n try {\n document.elementsFromPoint(event.clientX, event.clientY)[1]?.dispatchEvent(\n new MouseEvent('contextmenu', {\n bubbles: true,\n clientX: event.clientX,\n clientY: event.clientY,\n }),\n )\n } catch {\n // Ignore dispatch errors from elements that disappear during the event.\n }\n }\n\n return () =>\n h(\n 'div',\n {\n class: 'mantine-contextmenu-overlay',\n style: { zIndex: props.zIndex },\n onClick: handleClick,\n onContextmenu: handleContextMenu,\n },\n slots.default?.(),\n )\n },\n})\n","import { defineComponent, h, type PropType } from 'vue'\nimport { Portal, type Direction, type MantineTheme } from '@mantine-vue/core'\nimport { useHotkeys, useWindowEvent } from '@mantine-vue/hooks'\nimport { ContextMenu } from './ContextMenu'\nimport { ContextMenuOverlay } from './ContextMenuOverlay'\nimport type {\n ContextMenuContent,\n ContextMenuOptions,\n ContextMenuPortalProps,\n ContextMenuStyles,\n ContextMenuStyle,\n} from './types'\n\nexport const ContextMenuPortal = defineComponent({\n name: 'ContextMenuPortal',\n props: {\n x: { type: Number, required: true },\n y: { type: Number, required: true },\n content: {\n type: [Array, Function] as PropType<ContextMenuContent>,\n required: true,\n },\n onHide: {\n type: Function as PropType<() => void>,\n required: true,\n },\n zIndex: { type: Number, default: undefined },\n dir: {\n type: String as PropType<Direction>,\n required: true,\n },\n className: { type: String, default: undefined },\n style: {\n type: [Object, Function] as PropType<ContextMenuStyle>,\n default: undefined,\n },\n classNames: {\n type: Object as PropType<ContextMenuOptions['classNames']>,\n default: undefined,\n },\n styles: {\n type: [Object, Function] as PropType<\n ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles)\n >,\n default: undefined,\n },\n },\n setup(props: ContextMenuPortalProps) {\n useWindowEvent('resize', props.onHide)\n useWindowEvent('scroll', props.onHide)\n useHotkeys([['Escape', props.onHide]])\n\n return () =>\n h(Portal, null, () =>\n h(ContextMenuOverlay, { zIndex: props.zIndex, onHide: props.onHide }, () =>\n h(ContextMenu, {\n x: props.x,\n y: props.y,\n content: props.content,\n onHide: props.onHide,\n dir: props.dir,\n zIndex: props.zIndex,\n className: props.className,\n style: props.style,\n classNames: props.classNames,\n styles: props.styles,\n }),\n ),\n )\n },\n})\n","import {\n Fragment,\n computed,\n defineComponent,\n h,\n provide,\n shallowRef,\n toRef,\n type PropType,\n} from 'vue'\nimport {\n useDirection,\n type MantineRadius,\n type MantineShadow,\n type MantineTheme,\n} from '@mantine-vue/core'\nimport { ContextMenuPortal } from './ContextMenuPortal'\nimport { ContextMenuKey, ContextMenuSettingsKey, useContextMenu } from './context'\nimport type {\n ContextMenuInstanceOptions,\n ContextMenuOptions,\n ContextMenuStyles,\n ContextMenuStyle,\n ShowContextMenuFunction,\n} from './types'\n\nconst DEFAULT_SETTINGS = {\n shadow: 'sm',\n borderRadius: 'xs',\n submenuDelay: 500,\n repositionOnRepeat: false,\n} as const\n\nexport const ContextMenuProvider = defineComponent({\n name: 'ContextMenuProvider',\n props: {\n zIndex: { type: Number, default: 9999 },\n shadow: {\n type: String as PropType<MantineShadow>,\n default: DEFAULT_SETTINGS.shadow,\n },\n borderRadius: {\n type: [String, Number] as PropType<MantineRadius>,\n default: DEFAULT_SETTINGS.borderRadius,\n },\n submenuDelay: { type: Number, default: DEFAULT_SETTINGS.submenuDelay },\n repositionOnRepeat: {\n type: Boolean,\n default: DEFAULT_SETTINGS.repositionOnRepeat,\n },\n className: { type: String, default: undefined },\n style: {\n type: [Object, Function] as PropType<ContextMenuStyle>,\n default: undefined,\n },\n classNames: {\n type: Object as PropType<ContextMenuOptions['classNames']>,\n default: undefined,\n },\n styles: {\n type: [Object, Function] as PropType<\n ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles)\n >,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n const data = shallowRef<(ContextMenuInstanceOptions & ContextMenuOptions) | null>(null)\n const { dir } = useDirection()\n\n const hideContextMenu = () => {\n data.value = null\n }\n\n const showContextMenu: ShowContextMenuFunction = (content, options) => (event) => {\n event.preventDefault()\n event.stopPropagation()\n\n const position =\n 'touches' in event\n ? {\n x: event.touches.item(0)!.clientX,\n y: event.touches.item(0)!.clientY,\n }\n : { x: event.clientX, y: event.clientY }\n\n data.value = {\n ...position,\n content,\n zIndex: options?.zIndex || props.zIndex,\n className: options?.className,\n style: options?.style,\n classNames: options?.classNames,\n styles: options?.styles,\n }\n }\n\n provide(\n ContextMenuSettingsKey,\n computed(() => ({\n shadow: props.shadow,\n borderRadius: props.borderRadius,\n submenuDelay: props.submenuDelay,\n repositionOnRepeat: props.repositionOnRepeat,\n })),\n )\n provide(ContextMenuKey, {\n showContextMenu,\n hideContextMenu,\n isContextMenuVisible: toRef(() => Boolean(data.value)),\n })\n\n return () =>\n h(Fragment, null, [\n slots.default?.(),\n data.value\n ? h(ContextMenuPortal, {\n ...data.value,\n onHide: hideContextMenu,\n dir: dir.value,\n })\n : null,\n ])\n },\n})\n\nexport { ContextMenuKey, ContextMenuSettingsKey, useContextMenu }\nexport { ContextMenuKey as ContextMenuCtx, ContextMenuSettingsKey as ContextMenuSettingsCtx }\n"],"mappings":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AM;KAAS,GAAG,MAAM;IAAQ;IAIzC;IACA,QAAQ,SAAS,UAAU,MAAM;IACjC,WAAW,SAAS;IACpB,OAAO,SAAS;IAChB,YAAY,SAAS;IACrB,QAAQ,SAAS;GACnB;EACF;EAEA,QACE,wBACA,gBAAgB;GACd,QAAQ,MAAM;GACd,cAAc,MAAM;GACpB,cAAc,MAAM;GACpB,oBAAoB,MAAM;EAC5B,EAAE,CACJ;EACA,QAAQ,gBAAgB;GACtB;GACA;GACA,sBAAsB,YAAY,QAAQ,KAAK,KAAK,CAAC;EACvD,CAAC;EAED,aACE,EAAE,UAAU,MAAM,CAChB,MAAM,UAAU,GAChB,KAAK,QACD,EAAE,mBAAmB;GACnB,GAAG,KAAK;GACR,QAAQ;GACR,KAAK,IAAI;EACX,CAAC,IACD,IACN,CAAC;CACL;AACF,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/utils.ts","../src/components/ContextMenuDivider/ContextMenuDivider.vue","../src/components/ContextMenuDivider/ContextMenuDivider.vue","../src/context.ts","../src/components/ContextMenuItem/ContextMenuItem.vue","../src/components/ContextMenuItem/ContextMenuItem.vue","../src/components/ContextMenu/ContextMenu.vue","../src/components/ContextMenu/ContextMenu.vue","../src/components/ContextMenuOverlay/ContextMenuOverlay.vue","../src/components/ContextMenuOverlay/ContextMenuOverlay.vue","../src/components/ContextMenuPortal/ContextMenuPortal.vue","../src/components/ContextMenuPortal/ContextMenuPortal.vue","../src/components/ContextMenuProvider/ContextMenuProvider.vue","../src/components/ContextMenuProvider/ContextMenuProvider.vue"],"sourcesContent":["import type { ContextMenuStyle, ContextMenuStyles } from './types'\nimport type { MantineStyle, MantineTheme } from '@mantine-vue/core'\n\n/** Returns a humanized version of a string, for example \"camelCase\" becomes \"Camel Case\". */\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\n return `${str.charAt(0).toUpperCase()}${str.slice(1)}`\n}\n\nexport function resolveContextMenuStyle(\n style: ContextMenuStyle | undefined,\n theme: MantineTheme,\n): MantineStyle | undefined {\n return typeof style === 'function' ? style(theme) : style\n}\n\nexport function resolveContextMenuStyles(\n styles: ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles) | undefined,\n theme: MantineTheme,\n) {\n return typeof styles === 'function' ? styles(theme) : styles\n}\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { Box, useMantineTheme } from '@mantine-vue/core'\nimport { resolveContextMenuStyle } from '../../utils'\nimport type { ContextMenuDividerProps } from '../../types'\nimport '../../ContextMenuDivider.css'\n\ndefineOptions({ name: 'ContextMenuDivider' })\nconst props = defineProps<ContextMenuDividerProps>()\nconst theme = useMantineTheme()\nconst resolvedStyle = computed(() => resolveContextMenuStyle(props.style, theme.value))\n</script>\n\n<template>\n <Box :class=\"['mantine-contextmenu-divider', props.className]\" :style=\"resolvedStyle\" />\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { Box, useMantineTheme } from '@mantine-vue/core'\nimport { resolveContextMenuStyle } from '../../utils'\nimport type { ContextMenuDividerProps } from '../../types'\nimport '../../ContextMenuDivider.css'\n\ndefineOptions({ name: 'ContextMenuDivider' })\nconst props = defineProps<ContextMenuDividerProps>()\nconst theme = useMantineTheme()\nconst resolvedStyle = computed(() => resolveContextMenuStyle(props.style, theme.value))\n</script>\n\n<template>\n <Box :class=\"['mantine-contextmenu-divider', props.className]\" :style=\"resolvedStyle\" />\n</template>\n","import { inject, readonly, ref, type InjectionKey, type Ref } from 'vue'\nimport type { ContextMenuContextValue, ContextMenuSettings } from './types'\n\nexport interface ResolvedContextMenuSettings {\n shadow: NonNullable<ContextMenuSettings['shadow']>\n borderRadius: NonNullable<ContextMenuSettings['borderRadius']>\n submenuDelay: number\n repositionOnRepeat: boolean\n}\n\nexport const ContextMenuSettingsKey = Symbol('ContextMenuSettings') as InjectionKey<\n Ref<ResolvedContextMenuSettings>\n>\n\nexport const ContextMenuKey = Symbol('ContextMenu') as InjectionKey<ContextMenuContextValue>\n\nconst hidden = readonly(ref(false))\nconst fallback: ContextMenuContextValue = {\n showContextMenu: () => () => undefined,\n hideContextMenu: () => undefined,\n isContextMenuVisible: hidden,\n}\n\nexport function useContextMenu() {\n return inject(ContextMenuKey, fallback)\n}\n\nexport function useContextMenuSettings() {\n return inject(ContextMenuSettingsKey, {\n value: {\n shadow: 'sm',\n borderRadius: 'xs',\n submenuDelay: 500,\n repositionOnRepeat: false,\n },\n } as Ref<ResolvedContextMenuSettings>)\n}\n","<script setup lang=\"ts\">\nimport { computed, ref, useSlots } from 'vue'\nimport {\n Box,\n UnstyledButton,\n parseThemeColor,\n resolveNode,\n rgba,\n useMantineTheme,\n} from '@mantine-vue/core'\nimport { useMediaQuery, useTimeout } from '@mantine-vue/hooks'\nimport ContextMenu from '../ContextMenu/ContextMenu.vue'\nimport { useContextMenuSettings } from '../../context'\nimport { resolveContextMenuStyle } from '../../utils'\nimport type { ContextMenuItemEmits, ContextMenuItemProps } from '../../types'\nimport '../../ContextMenuItem.css'\n\ndefineOptions({ name: 'ContextMenuItem' })\nconst props = withDefaults(defineProps<ContextMenuItemProps>(), { disabled: false })\nconst emit = defineEmits<ContextMenuItemEmits>()\nconst slots = useSlots()\nconst button = ref<HTMLElement | null>(null)\nconst submenuPosition = ref<{ x: number; y: number } | null>(null)\nconst settings = useContextMenuSettings()\nconst theme = useMantineTheme()\nconst hoverAvailable = useMediaQuery('(hover: hover)')\nconst hasSubmenu = computed(() => Boolean(props.items && !props.disabled))\nconst parsedColor = computed(() =>\n props.color ? parseThemeColor({ color: props.color, theme: theme.value }) : null,\n)\nconst itemStyle = computed(() => {\n const color = parsedColor.value?.value\n return {\n '--mantine-contextmenu-item-button-color': color ?? 'var(--mantine-color-text)',\n '--mantine-contextmenu-item-button-hover-bg-color-light': color\n ? rgba(color, 0.08)\n : rgba(theme.value.colors.gray[4], 0.25),\n '--mantine-contextmenu-item-button-hover-bg-color-dark': color\n ? rgba(color, 0.15)\n : rgba(theme.value.colors.dark[3], 0.25),\n '--mantine-contextmenu-item-button-pressed-bg-color-light': color\n ? rgba(color, 0.2)\n : rgba(theme.value.colors.gray[4], 0.5),\n '--mantine-contextmenu-item-button-pressed-bg-color-dark': color\n ? rgba(color, 0.3)\n : rgba(theme.value.colors.dark[3], 0.5),\n ...resolveContextMenuStyle(props.style, theme.value),\n }\n})\nconst icon = computed(() => resolveNode(props.icon, slots.icon))\nconst title = computed(() => resolveNode(props.title, slots.title))\nconst iconRight = computed(() => resolveNode(props.iconRight, slots.iconRight))\nconst renderIcon = () => icon.value\nconst renderTitle = () => title.value\nconst renderIconRight = () => iconRight.value\n\nconst showSubmenuTimeout = useTimeout(() => {\n if (!button.value) return\n const rect = button.value.getBoundingClientRect()\n submenuPosition.value = {\n x: (props.submenuProps.dir || 'ltr') === 'ltr' ? rect.right : rect.left,\n y: rect.top,\n }\n}, settings.value.submenuDelay)\nconst hideSubmenuTimeout = useTimeout(\n () => (submenuPosition.value = null),\n settings.value.submenuDelay,\n)\n\nfunction showSubmenu() {\n hideSubmenuTimeout.clear()\n showSubmenuTimeout.start()\n}\nfunction hideSubmenu() {\n showSubmenuTimeout.clear()\n hideSubmenuTimeout.start()\n}\nfunction mouseenter() {\n if (hasSubmenu.value && hoverAvailable.value) showSubmenu()\n}\nfunction mouseleave() {\n if (hasSubmenu.value && hoverAvailable.value) hideSubmenu()\n}\nfunction click(event: MouseEvent) {\n if (hasSubmenu.value) {\n event.stopPropagation()\n showSubmenu()\n } else if (props.onClick) {\n emit('hide')\n props.onClick(event)\n }\n}\n</script>\n\n<template>\n <div @mouseenter=\"mouseenter\" @mouseleave=\"mouseleave\">\n <UnstyledButton\n :ref=\"(node: any) => (button = node?.$el ?? node ?? null)\"\n :dir=\"props.submenuProps.dir || 'ltr'\"\n :class=\"['mantine-contextmenu-item-button', props.className]\"\n :disabled=\"props.disabled\"\n :style=\"itemStyle\"\n @click=\"click\"\n >\n <Box v-if=\"icon\" :fz=\"0\" me=\"xs\" :mt=\"-2\"><component :is=\"renderIcon\" /></Box>\n <div class=\"mantine-contextmenu-item-button-title\"><component :is=\"renderTitle\" /></div>\n <Box v-if=\"iconRight\" :fz=\"0\" ms=\"xs\" :mt=\"-2\"><component :is=\"renderIconRight\" /></Box>\n <Box v-else-if=\"props.items\" :mt=\"-1\" ms=\"xs\">\n {{ (props.submenuProps.dir || 'ltr') === 'rtl' ? '‹' : '›' }}\n </Box>\n </UnstyledButton>\n <ContextMenu\n v-if=\"submenuPosition && props.items\"\n v-bind=\"props.submenuProps\"\n :x=\"submenuPosition.x\"\n :y=\"submenuPosition.y\"\n :content=\"props.items\"\n :dir=\"props.submenuProps.dir || 'ltr'\"\n @hide=\"emit('hide')\"\n />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, ref, useSlots } from 'vue'\nimport {\n Box,\n UnstyledButton,\n parseThemeColor,\n resolveNode,\n rgba,\n useMantineTheme,\n} from '@mantine-vue/core'\nimport { useMediaQuery, useTimeout } from '@mantine-vue/hooks'\nimport ContextMenu from '../ContextMenu/ContextMenu.vue'\nimport { useContextMenuSettings } from '../../context'\nimport { resolveContextMenuStyle } from '../../utils'\nimport type { ContextMenuItemEmits, ContextMenuItemProps } from '../../types'\nimport '../../ContextMenuItem.css'\n\ndefineOptions({ name: 'ContextMenuItem' })\nconst props = withDefaults(defineProps<ContextMenuItemProps>(), { disabled: false })\nconst emit = defineEmits<ContextMenuItemEmits>()\nconst slots = useSlots()\nconst button = ref<HTMLElement | null>(null)\nconst submenuPosition = ref<{ x: number; y: number } | null>(null)\nconst settings = useContextMenuSettings()\nconst theme = useMantineTheme()\nconst hoverAvailable = useMediaQuery('(hover: hover)')\nconst hasSubmenu = computed(() => Boolean(props.items && !props.disabled))\nconst parsedColor = computed(() =>\n props.color ? parseThemeColor({ color: props.color, theme: theme.value }) : null,\n)\nconst itemStyle = computed(() => {\n const color = parsedColor.value?.value\n return {\n '--mantine-contextmenu-item-button-color': color ?? 'var(--mantine-color-text)',\n '--mantine-contextmenu-item-button-hover-bg-color-light': color\n ? rgba(color, 0.08)\n : rgba(theme.value.colors.gray[4], 0.25),\n '--mantine-contextmenu-item-button-hover-bg-color-dark': color\n ? rgba(color, 0.15)\n : rgba(theme.value.colors.dark[3], 0.25),\n '--mantine-contextmenu-item-button-pressed-bg-color-light': color\n ? rgba(color, 0.2)\n : rgba(theme.value.colors.gray[4], 0.5),\n '--mantine-contextmenu-item-button-pressed-bg-color-dark': color\n ? rgba(color, 0.3)\n : rgba(theme.value.colors.dark[3], 0.5),\n ...resolveContextMenuStyle(props.style, theme.value),\n }\n})\nconst icon = computed(() => resolveNode(props.icon, slots.icon))\nconst title = computed(() => resolveNode(props.title, slots.title))\nconst iconRight = computed(() => resolveNode(props.iconRight, slots.iconRight))\nconst renderIcon = () => icon.value\nconst renderTitle = () => title.value\nconst renderIconRight = () => iconRight.value\n\nconst showSubmenuTimeout = useTimeout(() => {\n if (!button.value) return\n const rect = button.value.getBoundingClientRect()\n submenuPosition.value = {\n x: (props.submenuProps.dir || 'ltr') === 'ltr' ? rect.right : rect.left,\n y: rect.top,\n }\n}, settings.value.submenuDelay)\nconst hideSubmenuTimeout = useTimeout(\n () => (submenuPosition.value = null),\n settings.value.submenuDelay,\n)\n\nfunction showSubmenu() {\n hideSubmenuTimeout.clear()\n showSubmenuTimeout.start()\n}\nfunction hideSubmenu() {\n showSubmenuTimeout.clear()\n hideSubmenuTimeout.start()\n}\nfunction mouseenter() {\n if (hasSubmenu.value && hoverAvailable.value) showSubmenu()\n}\nfunction mouseleave() {\n if (hasSubmenu.value && hoverAvailable.value) hideSubmenu()\n}\nfunction click(event: MouseEvent) {\n if (hasSubmenu.value) {\n event.stopPropagation()\n showSubmenu()\n } else if (props.onClick) {\n emit('hide')\n props.onClick(event)\n }\n}\n</script>\n\n<template>\n <div @mouseenter=\"mouseenter\" @mouseleave=\"mouseleave\">\n <UnstyledButton\n :ref=\"(node: any) => (button = node?.$el ?? node ?? null)\"\n :dir=\"props.submenuProps.dir || 'ltr'\"\n :class=\"['mantine-contextmenu-item-button', props.className]\"\n :disabled=\"props.disabled\"\n :style=\"itemStyle\"\n @click=\"click\"\n >\n <Box v-if=\"icon\" :fz=\"0\" me=\"xs\" :mt=\"-2\"><component :is=\"renderIcon\" /></Box>\n <div class=\"mantine-contextmenu-item-button-title\"><component :is=\"renderTitle\" /></div>\n <Box v-if=\"iconRight\" :fz=\"0\" ms=\"xs\" :mt=\"-2\"><component :is=\"renderIconRight\" /></Box>\n <Box v-else-if=\"props.items\" :mt=\"-1\" ms=\"xs\">\n {{ (props.submenuProps.dir || 'ltr') === 'rtl' ? '‹' : '›' }}\n </Box>\n </UnstyledButton>\n <ContextMenu\n v-if=\"submenuPosition && props.items\"\n v-bind=\"props.submenuProps\"\n :x=\"submenuPosition.x\"\n :y=\"submenuPosition.y\"\n :content=\"props.items\"\n :dir=\"props.submenuProps.dir || 'ltr'\"\n @hide=\"emit('hide')\"\n />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport { Paper, px, useMantineTheme, type MantineRadius } from '@mantine-vue/core'\nimport { useResizeObserver } from '@mantine-vue/hooks'\nimport ContextMenuDivider from '../ContextMenuDivider/ContextMenuDivider.vue'\nimport ContextMenuItem from '../ContextMenuItem/ContextMenuItem.vue'\nimport { useContextMenuSettings } from '../../context'\nimport { humanize, resolveContextMenuStyle, resolveContextMenuStyles } from '../../utils'\nimport type { ContextMenuEmits, ContextMenuItemOptions, ContextMenuProps } from '../../types'\nimport '../../ContextMenu.css'\n\ndefineOptions({ name: 'ContextMenu' })\nconst props = withDefaults(defineProps<ContextMenuProps>(), { dir: 'ltr' })\nconst emit = defineEmits<ContextMenuEmits>()\nconst settings = useContextMenuSettings()\nconst theme = useMantineTheme()\nconst { ref: menuRef, rect } = useResizeObserver<HTMLElement>()\nconst mounted = ref(false)\nlet frameId = 0\n\nwatch(\n () => [rect.value.width, rect.value.height],\n ([width, height]) => {\n if (width > 0 && height > 0) {\n cancelAnimationFrame(frameId)\n frameId = requestAnimationFrame(() => (mounted.value = true))\n }\n },\n { immediate: true },\n)\nonBeforeUnmount(() => cancelAnimationFrame(frameId))\n\nconst position = computed(() => {\n const spacing = px(theme.value.spacing.md)\n const windowWidth = typeof window === 'undefined' ? 0 : window.innerWidth\n const windowHeight = typeof window === 'undefined' ? 0 : window.innerHeight\n const top =\n props.y + rect.value.height + spacing > windowHeight\n ? windowHeight - rect.value.height - spacing\n : props.y\n const left =\n props.dir === 'rtl'\n ? props.x - rect.value.width < spacing\n ? spacing\n : props.x - rect.value.width\n : props.x + rect.value.width + spacing > windowWidth\n ? windowWidth - rect.value.width - spacing\n : props.x\n return { zIndex: props.zIndex, top: `${top}px`, left: `${left}px` }\n})\nconst resolvedStyles = computed(() => resolveContextMenuStyles(props.styles, theme.value))\nconst rootStyle = computed(() => ({\n ...position.value,\n ...resolveContextMenuStyle(props.style, theme.value),\n ...resolveContextMenuStyle(resolvedStyles.value?.root, theme.value),\n}))\nconst submenuProps = computed(() => ({\n className: props.className,\n style: props.style,\n classNames: props.classNames,\n styles: props.styles,\n dir: props.dir,\n}))\n\nfunction itemClass(item: ContextMenuItemOptions, part: 'item' | 'divider') {\n return [props.classNames?.[part], item.className].filter(Boolean).join(' ')\n}\nfunction itemStyle(item: ContextMenuItemOptions, part: 'item' | 'divider') {\n return {\n ...resolveContextMenuStyle(resolvedStyles.value?.[part], theme.value),\n ...resolveContextMenuStyle(item.style, theme.value),\n }\n}\nconst renderCustomContent = () =>\n typeof props.content === 'function' ? props.content(() => emit('hide')) : null\n</script>\n\n<template>\n <Paper\n :ref=\"(node: any) => (menuRef = node?.$el ?? node ?? null)\"\n :shadow=\"settings.shadow\"\n :radius=\"settings.borderRadius as MantineRadius\"\n :dir=\"props.dir\"\n :class=\"[\n 'mantine-contextmenu',\n mounted && 'mantine-contextmenu-mounted',\n props.className,\n props.classNames?.root,\n ]\"\n :style=\"rootStyle\"\n >\n <component v-if=\"typeof props.content === 'function'\" :is=\"renderCustomContent\" />\n <template v-else>\n <template v-for=\"item in props.content\" :key=\"item.key\">\n <ContextMenuItem\n v-if=\"!item.hidden && (item.onClick || item.items)\"\n :class-name=\"itemClass(item, 'item')\"\n :style=\"itemStyle(item, 'item')\"\n :title=\"item.title ?? humanize(item.key)\"\n :icon=\"item.icon\"\n :icon-right=\"item.iconRight\"\n :color=\"item.color\"\n :disabled=\"item.disabled\"\n :on-click=\"item.onClick\"\n :items=\"item.items\"\n :submenu-props=\"submenuProps\"\n @hide=\"emit('hide')\"\n />\n <ContextMenuDivider\n v-else-if=\"!item.hidden\"\n :class-name=\"itemClass(item, 'divider')\"\n :style=\"itemStyle(item, 'divider')\"\n />\n </template>\n </template>\n </Paper>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport { Paper, px, useMantineTheme, type MantineRadius } from '@mantine-vue/core'\nimport { useResizeObserver } from '@mantine-vue/hooks'\nimport ContextMenuDivider from '../ContextMenuDivider/ContextMenuDivider.vue'\nimport ContextMenuItem from '../ContextMenuItem/ContextMenuItem.vue'\nimport { useContextMenuSettings } from '../../context'\nimport { humanize, resolveContextMenuStyle, resolveContextMenuStyles } from '../../utils'\nimport type { ContextMenuEmits, ContextMenuItemOptions, ContextMenuProps } from '../../types'\nimport '../../ContextMenu.css'\n\ndefineOptions({ name: 'ContextMenu' })\nconst props = withDefaults(defineProps<ContextMenuProps>(), { dir: 'ltr' })\nconst emit = defineEmits<ContextMenuEmits>()\nconst settings = useContextMenuSettings()\nconst theme = useMantineTheme()\nconst { ref: menuRef, rect } = useResizeObserver<HTMLElement>()\nconst mounted = ref(false)\nlet frameId = 0\n\nwatch(\n () => [rect.value.width, rect.value.height],\n ([width, height]) => {\n if (width > 0 && height > 0) {\n cancelAnimationFrame(frameId)\n frameId = requestAnimationFrame(() => (mounted.value = true))\n }\n },\n { immediate: true },\n)\nonBeforeUnmount(() => cancelAnimationFrame(frameId))\n\nconst position = computed(() => {\n const spacing = px(theme.value.spacing.md)\n const windowWidth = typeof window === 'undefined' ? 0 : window.innerWidth\n const windowHeight = typeof window === 'undefined' ? 0 : window.innerHeight\n const top =\n props.y + rect.value.height + spacing > windowHeight\n ? windowHeight - rect.value.height - spacing\n : props.y\n const left =\n props.dir === 'rtl'\n ? props.x - rect.value.width < spacing\n ? spacing\n : props.x - rect.value.width\n : props.x + rect.value.width + spacing > windowWidth\n ? windowWidth - rect.value.width - spacing\n : props.x\n return { zIndex: props.zIndex, top: `${top}px`, left: `${left}px` }\n})\nconst resolvedStyles = computed(() => resolveContextMenuStyles(props.styles, theme.value))\nconst rootStyle = computed(() => ({\n ...position.value,\n ...resolveContextMenuStyle(props.style, theme.value),\n ...resolveContextMenuStyle(resolvedStyles.value?.root, theme.value),\n}))\nconst submenuProps = computed(() => ({\n className: props.className,\n style: props.style,\n classNames: props.classNames,\n styles: props.styles,\n dir: props.dir,\n}))\n\nfunction itemClass(item: ContextMenuItemOptions, part: 'item' | 'divider') {\n return [props.classNames?.[part], item.className].filter(Boolean).join(' ')\n}\nfunction itemStyle(item: ContextMenuItemOptions, part: 'item' | 'divider') {\n return {\n ...resolveContextMenuStyle(resolvedStyles.value?.[part], theme.value),\n ...resolveContextMenuStyle(item.style, theme.value),\n }\n}\nconst renderCustomContent = () =>\n typeof props.content === 'function' ? props.content(() => emit('hide')) : null\n</script>\n\n<template>\n <Paper\n :ref=\"(node: any) => (menuRef = node?.$el ?? node ?? null)\"\n :shadow=\"settings.shadow\"\n :radius=\"settings.borderRadius as MantineRadius\"\n :dir=\"props.dir\"\n :class=\"[\n 'mantine-contextmenu',\n mounted && 'mantine-contextmenu-mounted',\n props.className,\n props.classNames?.root,\n ]\"\n :style=\"rootStyle\"\n >\n <component v-if=\"typeof props.content === 'function'\" :is=\"renderCustomContent\" />\n <template v-else>\n <template v-for=\"item in props.content\" :key=\"item.key\">\n <ContextMenuItem\n v-if=\"!item.hidden && (item.onClick || item.items)\"\n :class-name=\"itemClass(item, 'item')\"\n :style=\"itemStyle(item, 'item')\"\n :title=\"item.title ?? humanize(item.key)\"\n :icon=\"item.icon\"\n :icon-right=\"item.iconRight\"\n :color=\"item.color\"\n :disabled=\"item.disabled\"\n :on-click=\"item.onClick\"\n :items=\"item.items\"\n :submenu-props=\"submenuProps\"\n @hide=\"emit('hide')\"\n />\n <ContextMenuDivider\n v-else-if=\"!item.hidden\"\n :class-name=\"itemClass(item, 'divider')\"\n :style=\"itemStyle(item, 'divider')\"\n />\n </template>\n </template>\n </Paper>\n</template>\n","<script setup lang=\"ts\">\nimport { useContextMenuSettings } from '../../context'\nimport type { ContextMenuOverlayEmits } from '../../types'\nimport '../../ContextMenuOverlay.css'\n\ndefineOptions({ name: 'ContextMenuOverlay' })\nconst props = defineProps<{ zIndex?: number }>()\nconst emit = defineEmits<ContextMenuOverlayEmits>()\nconst settings = useContextMenuSettings()\n\nfunction click(event: MouseEvent) {\n event.preventDefault()\n emit('hide')\n}\n\nfunction contextmenu(event: MouseEvent) {\n event.preventDefault()\n if (!settings.value.repositionOnRepeat) {\n emit('hide')\n return\n }\n try {\n document.elementsFromPoint(event.clientX, event.clientY)[1]?.dispatchEvent(\n new MouseEvent('contextmenu', {\n bubbles: true,\n clientX: event.clientX,\n clientY: event.clientY,\n }),\n )\n } catch {\n // The target may disappear while the event is dispatched.\n }\n}\n</script>\n\n<template>\n <div\n class=\"mantine-contextmenu-overlay\"\n :style=\"{ zIndex: props.zIndex }\"\n @click=\"click\"\n @contextmenu=\"contextmenu\"\n >\n <slot />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { useContextMenuSettings } from '../../context'\nimport type { ContextMenuOverlayEmits } from '../../types'\nimport '../../ContextMenuOverlay.css'\n\ndefineOptions({ name: 'ContextMenuOverlay' })\nconst props = defineProps<{ zIndex?: number }>()\nconst emit = defineEmits<ContextMenuOverlayEmits>()\nconst settings = useContextMenuSettings()\n\nfunction click(event: MouseEvent) {\n event.preventDefault()\n emit('hide')\n}\n\nfunction contextmenu(event: MouseEvent) {\n event.preventDefault()\n if (!settings.value.repositionOnRepeat) {\n emit('hide')\n return\n }\n try {\n document.elementsFromPoint(event.clientX, event.clientY)[1]?.dispatchEvent(\n new MouseEvent('contextmenu', {\n bubbles: true,\n clientX: event.clientX,\n clientY: event.clientY,\n }),\n )\n } catch {\n // The target may disappear while the event is dispatched.\n }\n}\n</script>\n\n<template>\n <div\n class=\"mantine-contextmenu-overlay\"\n :style=\"{ zIndex: props.zIndex }\"\n @click=\"click\"\n @contextmenu=\"contextmenu\"\n >\n <slot />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { Portal } from '@mantine-vue/core'\nimport { useHotkeys, useWindowEvent } from '@mantine-vue/hooks'\nimport ContextMenu from '../ContextMenu/ContextMenu.vue'\nimport ContextMenuOverlay from '../ContextMenuOverlay/ContextMenuOverlay.vue'\nimport type { ContextMenuPortalEmits, ContextMenuPortalProps } from '../../types'\n\ndefineOptions({ name: 'ContextMenuPortal' })\nconst props = defineProps<ContextMenuPortalProps>()\nconst emit = defineEmits<ContextMenuPortalEmits>()\nconst hide = () => emit('hide')\nuseWindowEvent('resize', hide)\nuseWindowEvent('scroll', hide)\nuseHotkeys([['Escape', hide]])\n</script>\n\n<template>\n <Portal>\n <ContextMenuOverlay :z-index=\"props.zIndex\" @hide=\"hide\">\n <ContextMenu\n :x=\"props.x\"\n :y=\"props.y\"\n :content=\"props.content\"\n :dir=\"props.dir\"\n :z-index=\"props.zIndex\"\n :class-name=\"props.className\"\n :style=\"props.style\"\n :class-names=\"props.classNames\"\n :styles=\"props.styles\"\n @hide=\"hide\"\n />\n </ContextMenuOverlay>\n </Portal>\n</template>\n","<script setup lang=\"ts\">\nimport { Portal } from '@mantine-vue/core'\nimport { useHotkeys, useWindowEvent } from '@mantine-vue/hooks'\nimport ContextMenu from '../ContextMenu/ContextMenu.vue'\nimport ContextMenuOverlay from '../ContextMenuOverlay/ContextMenuOverlay.vue'\nimport type { ContextMenuPortalEmits, ContextMenuPortalProps } from '../../types'\n\ndefineOptions({ name: 'ContextMenuPortal' })\nconst props = defineProps<ContextMenuPortalProps>()\nconst emit = defineEmits<ContextMenuPortalEmits>()\nconst hide = () => emit('hide')\nuseWindowEvent('resize', hide)\nuseWindowEvent('scroll', hide)\nuseHotkeys([['Escape', hide]])\n</script>\n\n<template>\n <Portal>\n <ContextMenuOverlay :z-index=\"props.zIndex\" @hide=\"hide\">\n <ContextMenu\n :x=\"props.x\"\n :y=\"props.y\"\n :content=\"props.content\"\n :dir=\"props.dir\"\n :z-index=\"props.zIndex\"\n :class-name=\"props.className\"\n :style=\"props.style\"\n :class-names=\"props.classNames\"\n :styles=\"props.styles\"\n @hide=\"hide\"\n />\n </ContextMenuOverlay>\n </Portal>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, provide, shallowRef, toRef } from 'vue'\nimport { useDirection } from '@mantine-vue/core'\nimport ContextMenuPortal from '../ContextMenuPortal/ContextMenuPortal.vue'\nimport { ContextMenuKey, ContextMenuSettingsKey } from '../../context'\nimport type {\n ContextMenuInstanceOptions,\n ContextMenuOptions,\n ContextMenuProviderProps,\n ShowContextMenuFunction,\n} from '../../types'\n\ndefineOptions({ name: 'ContextMenuProvider' })\nconst props = withDefaults(defineProps<ContextMenuProviderProps>(), {\n zIndex: 9999,\n shadow: 'sm',\n borderRadius: 'xs',\n submenuDelay: 500,\n repositionOnRepeat: false,\n})\nconst data = shallowRef<(ContextMenuInstanceOptions & ContextMenuOptions) | null>(null)\nconst { dir } = useDirection()\n\nfunction hideContextMenu() {\n data.value = null\n}\n\nconst showContextMenu: ShowContextMenuFunction = (content, options) => (event) => {\n event.preventDefault()\n event.stopPropagation()\n const position =\n 'touches' in event\n ? { x: event.touches.item(0)!.clientX, y: event.touches.item(0)!.clientY }\n : { x: event.clientX, y: event.clientY }\n data.value = {\n ...position,\n content,\n zIndex: options?.zIndex || props.zIndex,\n className: options?.className,\n style: options?.style,\n classNames: options?.classNames,\n styles: options?.styles,\n }\n}\n\nprovide(\n ContextMenuSettingsKey,\n computed(() => ({\n shadow: props.shadow,\n borderRadius: props.borderRadius,\n submenuDelay: props.submenuDelay,\n repositionOnRepeat: props.repositionOnRepeat,\n })),\n)\nprovide(ContextMenuKey, {\n showContextMenu,\n hideContextMenu,\n isContextMenuVisible: toRef(() => Boolean(data.value)),\n})\n</script>\n\n<template>\n <slot />\n <ContextMenuPortal v-if=\"data\" v-bind=\"data\" :dir=\"dir\" @hide=\"hideContextMenu\" />\n</template>\n","<script setup lang=\"ts\">\nimport { computed, provide, shallowRef, toRef } from 'vue'\nimport { useDirection } from '@mantine-vue/core'\nimport ContextMenuPortal from '../ContextMenuPortal/ContextMenuPortal.vue'\nimport { ContextMenuKey, ContextMenuSettingsKey } from '../../context'\nimport type {\n ContextMenuInstanceOptions,\n ContextMenuOptions,\n ContextMenuProviderProps,\n ShowContextMenuFunction,\n} from '../../types'\n\ndefineOptions({ name: 'ContextMenuProvider' })\nconst props = withDefaults(defineProps<ContextMenuProviderProps>(), {\n zIndex: 9999,\n shadow: 'sm',\n borderRadius: 'xs',\n submenuDelay: 500,\n repositionOnRepeat: false,\n})\nconst data = shallowRef<(ContextMenuInstanceOptions & ContextMenuOptions) | null>(null)\nconst { dir } = useDirection()\n\nfunction hideContextMenu() {\n data.value = null\n}\n\nconst showContextMenu: ShowContextMenuFunction = (content, options) => (event) => {\n event.preventDefault()\n event.stopPropagation()\n const position =\n 'touches' in event\n ? { x: event.touches.item(0)!.clientX, y: event.touches.item(0)!.clientY }\n : { x: event.clientX, y: event.clientY }\n data.value = {\n ...position,\n content,\n zIndex: options?.zIndex || props.zIndex,\n className: options?.className,\n style: options?.style,\n classNames: options?.classNames,\n styles: options?.styles,\n }\n}\n\nprovide(\n ContextMenuSettingsKey,\n computed(() => ({\n shadow: props.shadow,\n borderRadius: props.borderRadius,\n submenuDelay: props.submenuDelay,\n repositionOnRepeat: props.repositionOnRepeat,\n })),\n)\nprovide(ContextMenuKey, {\n showContextMenu,\n hideContextMenu,\n isContextMenuVisible: toRef(() => Boolean(data.value)),\n})\n</script>\n\n<template>\n <slot />\n <ContextMenuPortal v-if=\"data\" v-bind=\"data\" :dir=\"dir\" @hide=\"hideContextMenu\" />\n</template>\n"],"mappings":";;;;;AAIA,SAAgB,SAAS,OAAe;CACtC,MAAM,MAAM,MACT,QAAQ,sBAAsB,OAAO,EACrC,QAAQ,SAAS,GAAG,EACpB,KAAK,EACL,YAAY;CAEf,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AACrD;AAEA,SAAgB,wBACd,OACA,OAC0B;CAC1B,OAAO,OAAO,UAAU,aAAa,MAAM,KAAK,IAAI;AACtD;AAEA,SAAgB,yBACd,QACA,OACA;CACA,OAAO,OAAO,WAAW,aAAa,OAAO,KAAK,IAAI;AACxD;;;;;;;;;;;EClBA,MAAM,QAAQ;EACd,MAAM,QAAQ,gBAAgB;EAC9B,MAAM,gBAAgB,eAAe,wBAAwB,MAAM,OAAO,MAAM,KAAK,CAAC;;uBAIpF,YAAwF,MAAA,GAAA,GAAA;IAAlF,OAAK,eAAA,CAAA,+BAAkC,MAAM,SAAS,CAAA;IAAI,OAAK,eAAE,cAAA,KAAa;;;;;;;AEJtF,IAAa,yBAAyB,OAAO,qBAAqB;AAIlE,IAAa,iBAAiB,OAAO,aAAa;AAGlD,IAAM,WAAoC;CACxC,6BAA6B,KAAA;CAC7B,uBAAuB,KAAA;CACvB,sBAJa,SAAS,IAAI,KAAK,CAIT;AACxB;AAEA,SAAgB,iBAAiB;CAC/B,OAAO,OAAO,gBAAgB,QAAQ;AACxC;AAEA,SAAgB,yBAAyB;CACvC,OAAO,OAAO,wBAAwB,EACpC,OAAO;EACL,QAAQ;EACR,cAAc;EACd,cAAc;EACd,oBAAoB;CACtB,EACF,CAAqC;AACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;EClBA,MAA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wBACA,gBAAgB;GACd,QAAQ,MAAM;GACd,cAAc,MAAM;GACpB,cAAc,MAAM;GACpB,oBAAoB,MAAM;EAC5B,EAAE,CACJ;EACA,QAAQ,gBAAgB;GACtB;GACA;GACA,sBAAsB,YAAY,QAAQ,KAAK,KAAK,CAAC;EACvD,CAAC;;2DAIC,WAAQ,KAAA,QAAA,SAAA,GACiB,KAAA,SAAA,UAAA,GAAzB,YAAkF,2BAAlF,WAAkF,EAAA,KAAA,EAAA,GAA3C,KAAA,OAAI;IAAG,KAAK,MAAA,GAAA;IAAM,QAAM"}
@@ -0,0 +1,9 @@
1
+ import type { ContextMenuProps } from '../../types';
2
+ import '../../ContextMenu.css';
3
+ declare const __VLS_export: import("vue").DefineComponent<ContextMenuProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
4
+ hide: () => any;
5
+ }, string, import("vue").PublicProps, Readonly<ContextMenuProps> & Readonly<{
6
+ onHide?: (() => any) | undefined;
7
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default as ContextMenu } from './ContextMenu.vue';
2
+ export type { ContextMenuProps } from '../../types';
@@ -0,0 +1,5 @@
1
+ import type { ContextMenuDividerProps } from '../../types';
2
+ import '../../ContextMenuDivider.css';
3
+ declare const __VLS_export: import("vue").DefineComponent<ContextMenuDividerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ContextMenuDividerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default as ContextMenuDivider } from './ContextMenuDivider.vue';
2
+ export type { ContextMenuDividerProps } from '../../types';
@@ -0,0 +1,9 @@
1
+ import type { ContextMenuItemProps } from '../../types';
2
+ import '../../ContextMenuItem.css';
3
+ declare const __VLS_export: import("vue").DefineComponent<ContextMenuItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
4
+ hide: () => any;
5
+ }, string, import("vue").PublicProps, Readonly<ContextMenuItemProps> & Readonly<{
6
+ onHide?: (() => any) | undefined;
7
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default as ContextMenuItem } from './ContextMenuItem.vue';
2
+ export type { ContextMenuItemProps } from '../../types';
@@ -0,0 +1,21 @@
1
+ import '../../ContextMenuOverlay.css';
2
+ type __VLS_Props = {
3
+ zIndex?: number;
4
+ };
5
+ declare var __VLS_1: {};
6
+ type __VLS_Slots = {} & {
7
+ default?: (props: typeof __VLS_1) => any;
8
+ };
9
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ hide: () => any;
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ onHide?: (() => any) | undefined;
13
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
15
+ declare const _default: typeof __VLS_export;
16
+ export default _default;
17
+ type __VLS_WithSlots<T, S> = T & {
18
+ new (): {
19
+ $slots: S;
20
+ };
21
+ };
@@ -0,0 +1 @@
1
+ export { default as ContextMenuOverlay } from './ContextMenuOverlay.vue';
@@ -0,0 +1,8 @@
1
+ import type { ContextMenuPortalProps } from '../../types';
2
+ declare const __VLS_export: import("vue").DefineComponent<ContextMenuPortalProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
3
+ hide: () => any;
4
+ }, string, import("vue").PublicProps, Readonly<ContextMenuPortalProps> & Readonly<{
5
+ onHide?: (() => any) | undefined;
6
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default as ContextMenuPortal } from './ContextMenuPortal.vue';
2
+ export type { ContextMenuPortalProps } from '../../types';
@@ -0,0 +1,14 @@
1
+ import type { ContextMenuProviderProps } from '../../types';
2
+ declare var __VLS_1: {};
3
+ type __VLS_Slots = {} & {
4
+ default?: (props: typeof __VLS_1) => any;
5
+ };
6
+ declare const __VLS_base: import("vue").DefineComponent<ContextMenuProviderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ContextMenuProviderProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
10
+ type __VLS_WithSlots<T, S> = T & {
11
+ new (): {
12
+ $slots: S;
13
+ };
14
+ };
@@ -0,0 +1,4 @@
1
+ export { default as ContextMenuProvider } from './ContextMenuProvider.vue';
2
+ export { ContextMenuKey, ContextMenuSettingsKey, useContextMenu } from '../../context';
3
+ export { ContextMenuKey as ContextMenuCtx, ContextMenuSettingsKey as ContextMenuSettingsCtx, } from '../../context';
4
+ export type { ContextMenuProviderProps } from '../../types';
package/lib/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import './styles.css';
2
- export * from './ContextMenu';
3
- export * from './ContextMenuDivider';
4
- export * from './ContextMenuItem';
5
- export * from './ContextMenuOverlay';
6
- export * from './ContextMenuPortal';
7
- export * from './ContextMenuProvider';
2
+ export * from './components/ContextMenu';
3
+ export * from './components/ContextMenuDivider';
4
+ export * from './components/ContextMenuItem';
5
+ export * from './components/ContextMenuOverlay';
6
+ export * from './components/ContextMenuPortal';
7
+ export * from './components/ContextMenuProvider';
8
8
  export * from './types';
9
9
  export * from './utils';
package/lib/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import './styles.css';
2
- export * from './ContextMenu';
3
- export * from './ContextMenuDivider';
4
- export * from './ContextMenuItem';
5
- export * from './ContextMenuOverlay';
6
- export * from './ContextMenuPortal';
7
- export * from './ContextMenuProvider';
2
+ export * from './components/ContextMenu';
3
+ export * from './components/ContextMenuDivider';
4
+ export * from './components/ContextMenuItem';
5
+ export * from './components/ContextMenuOverlay';
6
+ export * from './components/ContextMenuPortal';
7
+ export * from './components/ContextMenuProvider';
8
8
  export * from './types';
9
9
  export * from './utils';
package/lib/types.d.ts CHANGED
@@ -73,20 +73,29 @@ export interface ContextMenuInstanceOptions {
73
73
  content: ContextMenuContent;
74
74
  }
75
75
  export interface ContextMenuProps extends ContextMenuInstanceOptions, ContextMenuOptions {
76
- onHide: HideContextMenuFunction;
77
76
  dir?: 'ltr' | 'rtl';
78
77
  }
78
+ /** Events emitted by `ContextMenu`. */
79
+ export interface ContextMenuEmits {
80
+ /** Emitted when the menu should be hidden. */
81
+ hide: [];
82
+ }
79
83
  export interface ContextMenuPortalProps extends ContextMenuProps {
80
84
  zIndex?: number;
81
85
  dir: 'ltr' | 'rtl';
82
86
  }
87
+ /** Events emitted by `ContextMenuPortal`. */
88
+ export type ContextMenuPortalEmits = ContextMenuEmits;
89
+ /** Events emitted by `ContextMenuOverlay`. */
90
+ export type ContextMenuOverlayEmits = ContextMenuEmits;
83
91
  export type ContextMenuSubmenuProps = Pick<ContextMenuOptions, 'className' | 'classNames' | 'style' | 'styles'> & {
84
92
  dir?: 'ltr' | 'rtl';
85
93
  };
86
94
  export type ContextMenuItemProps = Omit<ContextMenuItemOptions, 'key'> & {
87
- onHide: HideContextMenuFunction;
88
95
  submenuProps: ContextMenuSubmenuProps;
89
96
  };
97
+ /** Events emitted by `ContextMenuItem`. */
98
+ export type ContextMenuItemEmits = ContextMenuEmits;
90
99
  export interface ContextMenuDividerProps {
91
100
  className?: string;
92
101
  style?: ContextMenuStyle;
package/lib/utils.d.ts CHANGED
@@ -3,4 +3,4 @@ import type { MantineStyle, MantineTheme } from '@mantine-vue/core';
3
3
  /** Returns a humanized version of a string, for example "camelCase" becomes "Camel Case". */
4
4
  export declare function humanize(value: string): string;
5
5
  export declare function resolveContextMenuStyle(style: ContextMenuStyle | undefined, theme: MantineTheme): MantineStyle | undefined;
6
- export declare function resolveContextMenuStyles(styles: ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles) | undefined, theme: MantineTheme): Partial<Record<"root" | "item" | "divider", ContextMenuStyle>> | undefined;
6
+ export declare function resolveContextMenuStyles(styles: ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles) | undefined, theme: MantineTheme): Partial<Record<"item" | "root" | "divider", ContextMenuStyle>> | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine-vue/contextmenu",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Desktop-grade context menu extension for Mantine Vue",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -39,8 +39,8 @@
39
39
  "vue": "^3.5.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "@mantine-vue/core": "3.0.0",
43
- "@mantine-vue/hooks": "3.0.0",
42
+ "@mantine-vue/core": "3.1.0",
43
+ "@mantine-vue/hooks": "3.1.0",
44
44
  "vue": "^3.5.0"
45
45
  },
46
46
  "mantineVue": {
@@ -1,4 +0,0 @@
1
- import { type DefineComponent } from 'vue';
2
- import type { ContextMenuProps } from './types';
3
- import './ContextMenu.css';
4
- export declare const ContextMenu: DefineComponent<ContextMenuProps>;
@@ -1,14 +0,0 @@
1
- import type { ContextMenuStyle } from './types';
2
- import './ContextMenuDivider.css';
3
- export declare const ContextMenuDivider: import("vue").DefineComponent<{
4
- className?: string | undefined;
5
- style?: ContextMenuStyle | undefined;
6
- }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
7
- [key: string]: any;
8
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
9
- className?: string | undefined;
10
- style?: ContextMenuStyle | undefined;
11
- }> & Readonly<{}>, {
12
- style: ContextMenuStyle;
13
- className: string;
14
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1,9 +0,0 @@
1
- import { type DefineComponent, type VNodeChild } from 'vue';
2
- import type { ContextMenuItemProps } from './types';
3
- import './ContextMenuItem.css';
4
- export interface ContextMenuItemSlots {
5
- title?: () => VNodeChild;
6
- icon?: () => VNodeChild;
7
- iconRight?: () => VNodeChild;
8
- }
9
- export declare const ContextMenuItem: DefineComponent<ContextMenuItemProps>;
@@ -1,25 +0,0 @@
1
- import { type PropType } from 'vue';
2
- import './ContextMenuOverlay.css';
3
- export declare const ContextMenuOverlay: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
- zIndex: {
5
- type: NumberConstructor;
6
- default: undefined;
7
- };
8
- onHide: {
9
- type: PropType<() => void>;
10
- required: true;
11
- };
12
- }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
13
- [key: string]: any;
14
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
15
- zIndex: {
16
- type: NumberConstructor;
17
- default: undefined;
18
- };
19
- onHide: {
20
- type: PropType<() => void>;
21
- required: true;
22
- };
23
- }>> & Readonly<{}>, {
24
- zIndex: number;
25
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1,33 +0,0 @@
1
- import { type MantineTheme } from '@mantine-vue/core';
2
- import type { ContextMenuContent, ContextMenuStyles, ContextMenuStyle } from './types';
3
- export declare const ContextMenuPortal: import("vue").DefineComponent<{
4
- zIndex?: number | undefined;
5
- dir: "ltr" | "rtl";
6
- onHide: import("./types").HideContextMenuFunction;
7
- x: number;
8
- y: number;
9
- content: ContextMenuContent;
10
- className?: string | undefined;
11
- style?: ContextMenuStyle | undefined;
12
- classNames?: Partial<Record<"root" | "item" | "divider", string>> | undefined;
13
- styles?: (ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles)) | undefined;
14
- }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
15
- [key: string]: any;
16
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
17
- zIndex?: number | undefined;
18
- dir: "ltr" | "rtl";
19
- onHide: import("./types").HideContextMenuFunction;
20
- x: number;
21
- y: number;
22
- content: ContextMenuContent;
23
- className?: string | undefined;
24
- style?: ContextMenuStyle | undefined;
25
- classNames?: Partial<Record<"root" | "item" | "divider", string>> | undefined;
26
- styles?: (ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles)) | undefined;
27
- }> & Readonly<{}>, {
28
- style: ContextMenuStyle;
29
- classNames: Partial<Record<"root" | "item" | "divider", string>> | undefined;
30
- styles: Partial<Record<"root" | "item" | "divider", ContextMenuStyle>> | ((theme: MantineTheme) => ContextMenuStyles);
31
- zIndex: number;
32
- className: string;
33
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1,93 +0,0 @@
1
- import { type PropType } from 'vue';
2
- import { type MantineRadius, type MantineShadow, type MantineTheme } from '@mantine-vue/core';
3
- import { ContextMenuKey, ContextMenuSettingsKey, useContextMenu } from './context';
4
- import type { ContextMenuOptions, ContextMenuStyles, ContextMenuStyle } from './types';
5
- export declare const ContextMenuProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
6
- zIndex: {
7
- type: NumberConstructor;
8
- default: number;
9
- };
10
- shadow: {
11
- type: PropType<MantineShadow>;
12
- default: "sm";
13
- };
14
- borderRadius: {
15
- type: PropType<MantineRadius>;
16
- default: "xs";
17
- };
18
- submenuDelay: {
19
- type: NumberConstructor;
20
- default: 500;
21
- };
22
- repositionOnRepeat: {
23
- type: BooleanConstructor;
24
- default: false;
25
- };
26
- className: {
27
- type: StringConstructor;
28
- default: undefined;
29
- };
30
- style: {
31
- type: PropType<ContextMenuStyle>;
32
- default: undefined;
33
- };
34
- classNames: {
35
- type: PropType<ContextMenuOptions["classNames"]>;
36
- default: undefined;
37
- };
38
- styles: {
39
- type: PropType<ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles)>;
40
- default: undefined;
41
- };
42
- }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
43
- [key: string]: any;
44
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
45
- zIndex: {
46
- type: NumberConstructor;
47
- default: number;
48
- };
49
- shadow: {
50
- type: PropType<MantineShadow>;
51
- default: "sm";
52
- };
53
- borderRadius: {
54
- type: PropType<MantineRadius>;
55
- default: "xs";
56
- };
57
- submenuDelay: {
58
- type: NumberConstructor;
59
- default: 500;
60
- };
61
- repositionOnRepeat: {
62
- type: BooleanConstructor;
63
- default: false;
64
- };
65
- className: {
66
- type: StringConstructor;
67
- default: undefined;
68
- };
69
- style: {
70
- type: PropType<ContextMenuStyle>;
71
- default: undefined;
72
- };
73
- classNames: {
74
- type: PropType<ContextMenuOptions["classNames"]>;
75
- default: undefined;
76
- };
77
- styles: {
78
- type: PropType<ContextMenuStyles | ((theme: MantineTheme) => ContextMenuStyles)>;
79
- default: undefined;
80
- };
81
- }>> & Readonly<{}>, {
82
- style: ContextMenuStyle;
83
- shadow: MantineShadow;
84
- classNames: Partial<Record<"root" | "item" | "divider", string>> | undefined;
85
- styles: Partial<Record<"root" | "item" | "divider", ContextMenuStyle>> | ((theme: MantineTheme) => ContextMenuStyles);
86
- zIndex: number;
87
- borderRadius: MantineRadius;
88
- className: string;
89
- submenuDelay: number;
90
- repositionOnRepeat: boolean;
91
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
92
- export { ContextMenuKey, ContextMenuSettingsKey, useContextMenu };
93
- export { ContextMenuKey as ContextMenuCtx, ContextMenuSettingsKey as ContextMenuSettingsCtx };