@mantine-vue/contextmenu 2.3.0 → 2.4.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/cjs/index.cjs CHANGED
@@ -60,10 +60,11 @@ function useContextMenuSettings() {
60
60
  //#region src/ContextMenuItem.ts
61
61
  var ContextMenuItem = (0, vue.defineComponent)({
62
62
  name: "ContextMenuItem",
63
+ slots: Object,
63
64
  props: {
64
65
  title: {
65
66
  type: null,
66
- required: true
67
+ default: void 0
67
68
  },
68
69
  icon: {
69
70
  type: null,
@@ -106,7 +107,7 @@ var ContextMenuItem = (0, vue.defineComponent)({
106
107
  default: void 0
107
108
  }
108
109
  },
109
- setup(props) {
110
+ setup(props, { slots }) {
110
111
  const button = (0, vue.ref)(null);
111
112
  const submenuPosition = (0, vue.ref)(null);
112
113
  const settings = useContextMenuSettings();
@@ -150,6 +151,9 @@ var ContextMenuItem = (0, vue.defineComponent)({
150
151
  }) : null;
151
152
  const itemColor = parsed?.value ?? "var(--mantine-color-text)";
152
153
  const colorValue = parsed?.value;
154
+ const icon = (0, _mantine_vue_core.resolveNode)(props.icon, slots.icon);
155
+ const title = (0, _mantine_vue_core.resolveNode)(props.title, slots.title);
156
+ const iconRight = (0, _mantine_vue_core.resolveNode)(props.iconRight, slots.iconRight);
153
157
  return (0, vue.h)("div", {
154
158
  onMouseenter: hasSubmenu && hoverAvailable.value ? showSubmenu : void 0,
155
159
  onMouseleave: hasSubmenu && hoverAvailable.value ? hideSubmenu : void 0
@@ -168,17 +172,17 @@ var ContextMenuItem = (0, vue.defineComponent)({
168
172
  },
169
173
  onClick: hasSubmenu ? handleSubmenuClick : props.onClick ? handleActionClick : void 0
170
174
  }, () => [
171
- props.icon ? (0, vue.h)(_mantine_vue_core.Box, {
175
+ icon ? (0, vue.h)(_mantine_vue_core.Box, {
172
176
  fz: 0,
173
177
  me: "xs",
174
178
  mt: -2
175
- }, () => (0, _mantine_vue_core.resolveNode)(props.icon)) : null,
176
- (0, vue.h)("div", { class: "mantine-contextmenu-item-button-title" }, [(0, _mantine_vue_core.resolveNode)(props.title)]),
177
- props.iconRight ? (0, vue.h)(_mantine_vue_core.Box, {
179
+ }, () => icon) : null,
180
+ (0, vue.h)("div", { class: "mantine-contextmenu-item-button-title" }, [title]),
181
+ iconRight ? (0, vue.h)(_mantine_vue_core.Box, {
178
182
  fz: 0,
179
183
  ms: "xs",
180
184
  mt: -2
181
- }, () => (0, _mantine_vue_core.resolveNode)(props.iconRight)) : props.items ? (0, vue.h)(_mantine_vue_core.Box, {
185
+ }, () => iconRight) : props.items ? (0, vue.h)(_mantine_vue_core.Box, {
182
186
  mt: -1,
183
187
  ms: "xs"
184
188
  }, () => (props.submenuProps.dir || "ltr") === "rtl" ? "‹" : "›") : null
package/cjs/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","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 { defineComponent, h, ref, type DefineComponent, type PropType, type VNode } 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 const ContextMenuItem = defineComponent({\n name: 'ContextMenuItem',\n props: {\n title: {\n type: null as unknown as PropType<MantineNode>,\n required: true,\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) {\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\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 props.icon\n ? h(Box, { fz: 0, me: 'xs', mt: -2 }, () => resolveNode(props.icon))\n : null,\n h('div', { class: 'mantine-contextmenu-item-button-title' }, [\n resolveNode(props.title),\n ]),\n props.iconRight\n ? h(Box, { fz: 0, ms: 'xs', mt: -2 }, () => resolveNode(props.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":";;;;;;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;;;ACpBA,IAAa,sBAAA,GAAA,IAAA,iBAAqC;CAChD,MAAM;CACN,OAAO;EACL,WAAW;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EAC9C,OAAO;GACL,MAAM,CAAC,QAAQ,QAAQ;GACvB,SAAS,KAAA;EACX;CACF;CACA,MAAM,OAAgC;EACpC,MAAM,SAAA,GAAA,kBAAA,iBAAwB;EAE9B,cAAA,GAAA,IAAA,GACI,kBAAA,KAAK;GACL,OAAO,CAAC,+BAA+B,MAAM,SAAS;GACtD,OAAO,wBAAwB,MAAM,OAAO,MAAM,KAAK;EACzD,CAAC;CACL;AACF,CAAC;;;ACdD,IAAa,yBAAyB,OAAO,qBAAqB;AAIlE,IAAa,iBAAiB,OAAO,aAAa;AAGlD,IAAM,WAAoC;CACxC,6BAA6B,KAAA;CAC7B,uBAAuB,KAAA;CACvB,uBAAA,GAAA,IAAA,WAAA,GAAA,IAAA,KAJ0B,KAAK,CAIT;AACxB;AAEA,SAAgB,iBAAiB;CAC/B,QAAA,GAAA,IAAA,QAAc,gBAAgB,QAAQ;AACxC;AAEA,SAAgB,y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AC;EAED,cAAA,GAAA,IAAA,GACI,IAAA,UAAU,MAAM,CAChB,MAAM,UAAU,GAChB,KAAK,SAAA,GAAA,IAAA,GACC,mBAAmB;GACnB,GAAG,KAAK;GACR,QAAQ;GACR,KAAK,IAAI;EACX,CAAC,IACD,IACN,CAAC;CACL;AACF,CAAC"}
1
+ {"version":3,"file":"index.cjs","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 ContextM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,cAAA,GAAA,IAAA,GACI,IAAA,UAAU,MAAM,CAChB,MAAM,UAAU,GAChB,KAAK,SAAA,GAAA,IAAA,GACC,mBAAmB;GACnB,GAAG,KAAK;GACR,QAAQ;GACR,KAAK,IAAI;EACX,CAAC,IACD,IACN,CAAC;CACL;AACF,CAAC"}
package/esm/index.mjs CHANGED
@@ -59,10 +59,11 @@ function useContextMenuSettings() {
59
59
  //#region src/ContextMenuItem.ts
60
60
  var ContextMenuItem = defineComponent({
61
61
  name: "ContextMenuItem",
62
+ slots: Object,
62
63
  props: {
63
64
  title: {
64
65
  type: null,
65
- required: true
66
+ default: void 0
66
67
  },
67
68
  icon: {
68
69
  type: null,
@@ -105,7 +106,7 @@ var ContextMenuItem = defineComponent({
105
106
  default: void 0
106
107
  }
107
108
  },
108
- setup(props) {
109
+ setup(props, { slots }) {
109
110
  const button = ref(null);
110
111
  const submenuPosition = ref(null);
111
112
  const settings = useContextMenuSettings();
@@ -149,6 +150,9 @@ var ContextMenuItem = defineComponent({
149
150
  }) : null;
150
151
  const itemColor = parsed?.value ?? "var(--mantine-color-text)";
151
152
  const colorValue = parsed?.value;
153
+ const icon = resolveNode(props.icon, slots.icon);
154
+ const title = resolveNode(props.title, slots.title);
155
+ const iconRight = resolveNode(props.iconRight, slots.iconRight);
152
156
  return h("div", {
153
157
  onMouseenter: hasSubmenu && hoverAvailable.value ? showSubmenu : void 0,
154
158
  onMouseleave: hasSubmenu && hoverAvailable.value ? hideSubmenu : void 0
@@ -167,17 +171,17 @@ var ContextMenuItem = defineComponent({
167
171
  },
168
172
  onClick: hasSubmenu ? handleSubmenuClick : props.onClick ? handleActionClick : void 0
169
173
  }, () => [
170
- props.icon ? h(Box, {
174
+ icon ? h(Box, {
171
175
  fz: 0,
172
176
  me: "xs",
173
177
  mt: -2
174
- }, () => resolveNode(props.icon)) : null,
175
- h("div", { class: "mantine-contextmenu-item-button-title" }, [resolveNode(props.title)]),
176
- props.iconRight ? h(Box, {
178
+ }, () => icon) : null,
179
+ h("div", { class: "mantine-contextmenu-item-button-title" }, [title]),
180
+ iconRight ? h(Box, {
177
181
  fz: 0,
178
182
  ms: "xs",
179
183
  mt: -2
180
- }, () => resolveNode(props.iconRight)) : props.items ? h(Box, {
184
+ }, () => iconRight) : props.items ? h(Box, {
181
185
  mt: -1,
182
186
  ms: "xs"
183
187
  }, () => (props.submenuProps.dir || "ltr") === "rtl" ? "‹" : "›") : null
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 { defineComponent, h, ref, type DefineComponent, type PropType, type VNode } 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 const ContextMenuItem = defineComponent({\n name: 'ContextMenuItem',\n props: {\n title: {\n type: null as unknown as PropType<MantineNode>,\n required: true,\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) {\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\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 props.icon\n ? h(Box, { fz: 0, me: 'xs', mt: -2 }, () => resolveNode(props.icon))\n : null,\n h('div', { class: 'mantine-contextmenu-item-button-title' }, [\n resolveNode(props.title),\n ]),\n props.iconRight\n ? h(Box, { fz: 0, ms: 'xs', mt: -2 }, () => resolveNode(props.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":";;;;;AAIA,SAAgB,SAAS,OAAe;CACtC,MAAM,MAAM,MACT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A,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/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":";;;;;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;;;ACpBA,IAAa,qBAAqB,gBAAgB;CAChD,MAAM;CACN,OAAO;EACL,WAAW;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EAC9C,OAAO;GACL,MAAM,CAAC,QAAQ,QAAQ;GACvB,SAAS,KAAA;EACX;CACF;CACA,MAAM,OAAgC;EACpC,MAAM,QAAQ,gBAAgB;EAE9B,aACE,EAAE,KAAK;GACL,OAAO,CAAC,+BAA+B,MAAM,SAAS;GACtD,OAAO,wBAAwB,MAAM,OAAO,MAAM,KAAK;EACzD,CAAC;CACL;AACF,CAAC;;;ACdD,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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AS,aAAa,UAAU;GAChF,MAAM,eAAe;GACrB,MAAM,gBAAgB;GAUtB,KAAK,QAAQ;IACX,GARA,aAAa,QACT;KACE,GAAG,MAAM,QAAQ,KAAK,CAAC,EAAG;KAC1B,GAAG,MAAM,QAAQ,KAAK,CAAC,EAAG;IAC5B,IACA;KAAE,GAAG,MAAM;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,4 +1,9 @@
1
- import { type DefineComponent } from 'vue';
1
+ import { type DefineComponent, type VNodeChild } from 'vue';
2
2
  import type { ContextMenuItemProps } from './types';
3
3
  import './ContextMenuItem.css';
4
+ export interface ContextMenuItemSlots {
5
+ title?: () => VNodeChild;
6
+ icon?: () => VNodeChild;
7
+ iconRight?: () => VNodeChild;
8
+ }
4
9
  export declare const ContextMenuItem: DefineComponent<ContextMenuItemProps>;
package/lib/types.d.ts CHANGED
@@ -83,7 +83,7 @@ export interface ContextMenuPortalProps extends ContextMenuProps {
83
83
  export type ContextMenuSubmenuProps = Pick<ContextMenuOptions, 'className' | 'classNames' | 'style' | 'styles'> & {
84
84
  dir?: 'ltr' | 'rtl';
85
85
  };
86
- export type ContextMenuItemProps = WithRequiredProperty<Omit<ContextMenuItemOptions, 'key'>, 'title'> & {
86
+ export type ContextMenuItemProps = Omit<ContextMenuItemOptions, 'key'> & {
87
87
  onHide: HideContextMenuFunction;
88
88
  submenuProps: ContextMenuSubmenuProps;
89
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine-vue/contextmenu",
3
- "version": "2.3.0",
3
+ "version": "2.4.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": "2.3.0",
43
- "@mantine-vue/hooks": "2.3.0",
42
+ "@mantine-vue/core": "2.4.0",
43
+ "@mantine-vue/hooks": "2.4.0",
44
44
  "vue": "^3.5.0"
45
45
  },
46
46
  "mantineVue": {