@mantine-vue/contextmenu 2.4.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 CHANGED
@@ -1,4 +1,4 @@
1
- import { Fragment, computed, defineComponent, h, inject, onBeforeUnmount, provide, readonly, ref, shallowRef, toRef, watch } from "vue";
1
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, provide, readonly, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toRef, unref, useSlots, watch, withCtx } from "vue";
2
2
  import { Box, Paper, Portal, UnstyledButton, parseThemeColor, px, resolveNode, rgba, useDirection, useMantineTheme } from "@mantine-vue/core";
3
3
  import { useHotkeys, useMediaQuery, useResizeObserver, useTimeout, useWindowEvent } from "@mantine-vue/hooks";
4
4
  //#region src/utils.ts
@@ -14,25 +14,24 @@ function resolveContextMenuStyles(styles, theme) {
14
14
  return typeof styles === "function" ? styles(theme) : styles;
15
15
  }
16
16
  //#endregion
17
- //#region src/ContextMenuDivider.ts
18
- var ContextMenuDivider = defineComponent({
17
+ //#region src/components/ContextMenuDivider/ContextMenuDivider.vue
18
+ var ContextMenuDivider_default = /* @__PURE__ */ defineComponent({
19
19
  name: "ContextMenuDivider",
20
+ __name: "ContextMenuDivider",
20
21
  props: {
21
- className: {
22
- type: String,
23
- default: void 0
24
- },
25
- style: {
26
- type: [Object, Function],
27
- default: void 0
28
- }
22
+ className: {},
23
+ style: { type: Function }
29
24
  },
30
- setup(props) {
25
+ setup(__props) {
26
+ const props = __props;
31
27
  const theme = useMantineTheme();
32
- return () => h(Box, {
33
- class: ["mantine-contextmenu-divider", props.className],
34
- style: resolveContextMenuStyle(props.style, theme.value)
35
- });
28
+ const resolvedStyle = computed(() => resolveContextMenuStyle(props.style, theme.value));
29
+ return (_ctx, _cache) => {
30
+ return openBlock(), createBlock(unref(Box), {
31
+ class: normalizeClass(["mantine-contextmenu-divider", props.className]),
32
+ style: normalizeStyle(resolvedStyle.value)
33
+ }, null, 8, ["class", "style"]);
34
+ };
36
35
  }
37
36
  });
38
37
  //#endregion
@@ -56,62 +55,61 @@ function useContextMenuSettings() {
56
55
  } });
57
56
  }
58
57
  //#endregion
59
- //#region src/ContextMenuItem.ts
60
- var ContextMenuItem = defineComponent({
58
+ //#region src/components/ContextMenuItem/ContextMenuItem.vue?vue&type=script&setup=true&lang.ts
59
+ var _hoisted_1 = { class: "mantine-contextmenu-item-button-title" };
60
+ //#endregion
61
+ //#region src/components/ContextMenuItem/ContextMenuItem.vue
62
+ var ContextMenuItem_default = /* @__PURE__ */ defineComponent({
61
63
  name: "ContextMenuItem",
62
- slots: Object,
64
+ __name: "ContextMenuItem",
63
65
  props: {
64
- title: {
65
- type: null,
66
- default: void 0
67
- },
68
- icon: {
69
- type: null,
70
- default: void 0
71
- },
72
- iconRight: {
73
- type: null,
74
- default: void 0
75
- },
76
- color: {
77
- type: String,
78
- default: void 0
79
- },
66
+ className: {},
67
+ style: {},
68
+ hidden: { type: Boolean },
69
+ icon: {},
70
+ iconRight: {},
71
+ title: {},
72
+ color: {},
80
73
  disabled: {
81
74
  type: Boolean,
82
75
  default: false
83
76
  },
84
- onClick: {
85
- type: Function,
86
- default: void 0
87
- },
88
- items: {
89
- type: Array,
90
- default: void 0
91
- },
92
- onHide: {
93
- type: Function,
94
- required: true
95
- },
96
- submenuProps: {
97
- type: Object,
98
- required: true
99
- },
100
- className: {
101
- type: String,
102
- default: void 0
103
- },
104
- style: {
105
- type: [Object, Function],
106
- default: void 0
107
- }
77
+ onClick: {},
78
+ items: {},
79
+ submenuProps: {}
108
80
  },
109
- setup(props, { slots }) {
81
+ emits: ["hide"],
82
+ setup(__props, { emit: __emit }) {
83
+ const props = __props;
84
+ const emit = __emit;
85
+ const slots = useSlots();
110
86
  const button = ref(null);
111
87
  const submenuPosition = ref(null);
112
88
  const settings = useContextMenuSettings();
113
89
  const theme = useMantineTheme();
114
90
  const hoverAvailable = useMediaQuery("(hover: hover)");
91
+ const hasSubmenu = computed(() => Boolean(props.items && !props.disabled));
92
+ const parsedColor = computed(() => props.color ? parseThemeColor({
93
+ color: props.color,
94
+ theme: theme.value
95
+ }) : null);
96
+ const itemStyle = computed(() => {
97
+ const color = parsedColor.value?.value;
98
+ return {
99
+ "--mantine-contextmenu-item-button-color": color ?? "var(--mantine-color-text)",
100
+ "--mantine-contextmenu-item-button-hover-bg-color-light": color ? rgba(color, .08) : rgba(theme.value.colors.gray[4], .25),
101
+ "--mantine-contextmenu-item-button-hover-bg-color-dark": color ? rgba(color, .15) : rgba(theme.value.colors.dark[3], .25),
102
+ "--mantine-contextmenu-item-button-pressed-bg-color-light": color ? rgba(color, .2) : rgba(theme.value.colors.gray[4], .5),
103
+ "--mantine-contextmenu-item-button-pressed-bg-color-dark": color ? rgba(color, .3) : rgba(theme.value.colors.dark[3], .5),
104
+ ...resolveContextMenuStyle(props.style, theme.value)
105
+ };
106
+ });
107
+ const icon = computed(() => resolveNode(props.icon, slots.icon));
108
+ const title = computed(() => resolveNode(props.title, slots.title));
109
+ const iconRight = computed(() => resolveNode(props.iconRight, slots.iconRight));
110
+ const renderIcon = () => icon.value;
111
+ const renderTitle = () => title.value;
112
+ const renderIconRight = () => iconRight.value;
115
113
  const showSubmenuTimeout = useTimeout(() => {
116
114
  if (!button.value) return;
117
115
  const rect = button.value.getBoundingClientRect();
@@ -120,129 +118,111 @@ var ContextMenuItem = defineComponent({
120
118
  y: rect.top
121
119
  };
122
120
  }, settings.value.submenuDelay);
123
- const hideSubmenuTimeout = useTimeout(() => {
124
- submenuPosition.value = null;
125
- }, settings.value.submenuDelay);
126
- const showSubmenu = () => {
121
+ const hideSubmenuTimeout = useTimeout(() => submenuPosition.value = null, settings.value.submenuDelay);
122
+ function showSubmenu() {
127
123
  hideSubmenuTimeout.clear();
128
124
  showSubmenuTimeout.start();
129
- };
130
- const hideSubmenu = () => {
125
+ }
126
+ function hideSubmenu() {
131
127
  showSubmenuTimeout.clear();
132
128
  hideSubmenuTimeout.start();
133
- };
134
- const handleSubmenuClick = (event) => {
135
- event.stopPropagation();
136
- showSubmenu();
137
- };
138
- const handleActionClick = (event) => {
139
- props.onHide();
140
- props.onClick?.(event);
141
- };
142
- const setButtonRef = (node) => {
143
- button.value = node?.$el ?? node ?? null;
144
- };
145
- return () => {
146
- const hasSubmenu = Boolean(props.items && !props.disabled);
147
- const parsed = props.color ? parseThemeColor({
148
- color: props.color,
149
- theme: theme.value
150
- }) : null;
151
- const itemColor = parsed?.value ?? "var(--mantine-color-text)";
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);
156
- return h("div", {
157
- onMouseenter: hasSubmenu && hoverAvailable.value ? showSubmenu : void 0,
158
- onMouseleave: hasSubmenu && hoverAvailable.value ? hideSubmenu : void 0
159
- }, [h(UnstyledButton, {
160
- ref: setButtonRef,
129
+ }
130
+ function mouseenter() {
131
+ if (hasSubmenu.value && hoverAvailable.value) showSubmenu();
132
+ }
133
+ function mouseleave() {
134
+ if (hasSubmenu.value && hoverAvailable.value) hideSubmenu();
135
+ }
136
+ function click(event) {
137
+ if (hasSubmenu.value) {
138
+ event.stopPropagation();
139
+ showSubmenu();
140
+ } else if (props.onClick) {
141
+ emit("hide");
142
+ props.onClick(event);
143
+ }
144
+ }
145
+ return (_ctx, _cache) => {
146
+ return openBlock(), createElementBlock("div", {
147
+ onMouseenter: mouseenter,
148
+ onMouseleave: mouseleave
149
+ }, [createVNode(unref(UnstyledButton), {
150
+ ref: (node) => button.value = node?.$el ?? node ?? null,
161
151
  dir: props.submenuProps.dir || "ltr",
162
- class: ["mantine-contextmenu-item-button", props.className],
152
+ class: normalizeClass(["mantine-contextmenu-item-button", props.className]),
163
153
  disabled: props.disabled,
164
- style: {
165
- "--mantine-contextmenu-item-button-color": itemColor,
166
- "--mantine-contextmenu-item-button-hover-bg-color-light": colorValue ? rgba(colorValue, .08) : rgba(theme.value.colors.gray[4], .25),
167
- "--mantine-contextmenu-item-button-hover-bg-color-dark": colorValue ? rgba(colorValue, .15) : rgba(theme.value.colors.dark[3], .25),
168
- "--mantine-contextmenu-item-button-pressed-bg-color-light": colorValue ? rgba(colorValue, .2) : rgba(theme.value.colors.gray[4], .5),
169
- "--mantine-contextmenu-item-button-pressed-bg-color-dark": colorValue ? rgba(colorValue, .3) : rgba(theme.value.colors.dark[3], .5),
170
- ...resolveContextMenuStyle(props.style, theme.value)
171
- },
172
- onClick: hasSubmenu ? handleSubmenuClick : props.onClick ? handleActionClick : void 0
173
- }, () => [
174
- icon ? h(Box, {
175
- fz: 0,
176
- me: "xs",
177
- mt: -2
178
- }, () => icon) : null,
179
- h("div", { class: "mantine-contextmenu-item-button-title" }, [title]),
180
- iconRight ? h(Box, {
181
- fz: 0,
182
- ms: "xs",
183
- mt: -2
184
- }, () => iconRight) : props.items ? h(Box, {
185
- mt: -1,
186
- ms: "xs"
187
- }, () => (props.submenuProps.dir || "ltr") === "rtl" ? "‹" : "›") : null
188
- ]), submenuPosition.value && props.items ? h(ContextMenu, {
189
- ...props.submenuProps,
154
+ style: normalizeStyle(itemStyle.value),
155
+ onClick: click
156
+ }, {
157
+ default: withCtx(() => [
158
+ icon.value ? (openBlock(), createBlock(unref(Box), {
159
+ key: 0,
160
+ fz: 0,
161
+ me: "xs",
162
+ mt: -2
163
+ }, {
164
+ default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(renderIcon)))]),
165
+ _: 1
166
+ })) : createCommentVNode("", true),
167
+ createElementVNode("div", _hoisted_1, [(openBlock(), createBlock(resolveDynamicComponent(renderTitle)))]),
168
+ iconRight.value ? (openBlock(), createBlock(unref(Box), {
169
+ key: 1,
170
+ fz: 0,
171
+ ms: "xs",
172
+ mt: -2
173
+ }, {
174
+ default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(renderIconRight)))]),
175
+ _: 1
176
+ })) : props.items ? (openBlock(), createBlock(unref(Box), {
177
+ key: 2,
178
+ mt: -1,
179
+ ms: "xs"
180
+ }, {
181
+ default: withCtx(() => [createTextVNode(toDisplayString((props.submenuProps.dir || "ltr") === "rtl" ? "‹" : "›"), 1)]),
182
+ _: 1
183
+ })) : createCommentVNode("", true)
184
+ ]),
185
+ _: 1
186
+ }, 8, [
187
+ "dir",
188
+ "class",
189
+ "disabled",
190
+ "style"
191
+ ]), submenuPosition.value && props.items ? (openBlock(), createBlock(ContextMenu_default, mergeProps({ key: 0 }, props.submenuProps, {
190
192
  x: submenuPosition.value.x,
191
193
  y: submenuPosition.value.y,
192
194
  content: props.items,
193
- onHide: props.onHide,
194
- dir: props.submenuProps.dir || "ltr"
195
- }) : null]);
195
+ dir: props.submenuProps.dir || "ltr",
196
+ onHide: _cache[0] || (_cache[0] = ($event) => emit("hide"))
197
+ }), null, 16, [
198
+ "x",
199
+ "y",
200
+ "content",
201
+ "dir"
202
+ ])) : createCommentVNode("", true)], 32);
196
203
  };
197
204
  }
198
205
  });
199
206
  //#endregion
200
- //#region src/ContextMenu.ts
201
- var ContextMenu = defineComponent({
207
+ //#region src/components/ContextMenu/ContextMenu.vue
208
+ var ContextMenu_default = /* @__PURE__ */ defineComponent({
202
209
  name: "ContextMenu",
210
+ __name: "ContextMenu",
203
211
  props: {
204
- x: {
205
- type: Number,
206
- required: true
207
- },
208
- y: {
209
- type: Number,
210
- required: true
211
- },
212
- content: {
213
- type: [Array, Function],
214
- required: true
215
- },
216
- onHide: {
217
- type: Function,
218
- required: true
219
- },
220
- zIndex: {
221
- type: Number,
222
- default: void 0
223
- },
224
- dir: {
225
- type: String,
226
- default: "ltr"
227
- },
228
- className: {
229
- type: String,
230
- default: void 0
231
- },
232
- style: {
233
- type: [Object, Function],
234
- default: void 0
235
- },
236
- classNames: {
237
- type: Object,
238
- default: void 0
239
- },
240
- styles: {
241
- type: [Object, Function],
242
- default: void 0
243
- }
212
+ dir: { default: "ltr" },
213
+ x: {},
214
+ y: {},
215
+ content: {},
216
+ zIndex: {},
217
+ className: {},
218
+ style: {},
219
+ classNames: {},
220
+ styles: {}
244
221
  },
245
- setup(props) {
222
+ emits: ["hide"],
223
+ setup(__props, { emit: __emit }) {
224
+ const props = __props;
225
+ const emit = __emit;
246
226
  const settings = useContextMenuSettings();
247
227
  const theme = useMantineTheme();
248
228
  const { ref: menuRef, rect } = useResizeObserver();
@@ -251,9 +231,7 @@ var ContextMenu = defineComponent({
251
231
  watch(() => [rect.value.width, rect.value.height], ([width, height]) => {
252
232
  if (width > 0 && height > 0) {
253
233
  cancelAnimationFrame(frameId);
254
- frameId = requestAnimationFrame(() => {
255
- mounted.value = true;
256
- });
234
+ frameId = requestAnimationFrame(() => mounted.value = true);
257
235
  }
258
236
  }, { immediate: true });
259
237
  onBeforeUnmount(() => cancelAnimationFrame(frameId));
@@ -269,90 +247,104 @@ var ContextMenu = defineComponent({
269
247
  left: `${left}px`
270
248
  };
271
249
  });
272
- const setMenuRef = (node) => {
273
- menuRef.value = node?.$el ?? node ?? null;
274
- };
275
- return () => {
276
- const resolvedStyles = resolveContextMenuStyles(props.styles, theme.value);
277
- const submenuProps = {
278
- className: props.className,
279
- style: props.style,
280
- classNames: props.classNames,
281
- styles: props.styles,
282
- dir: props.dir
250
+ const resolvedStyles = computed(() => resolveContextMenuStyles(props.styles, theme.value));
251
+ const rootStyle = computed(() => ({
252
+ ...position.value,
253
+ ...resolveContextMenuStyle(props.style, theme.value),
254
+ ...resolveContextMenuStyle(resolvedStyles.value?.root, theme.value)
255
+ }));
256
+ const submenuProps = computed(() => ({
257
+ className: props.className,
258
+ style: props.style,
259
+ classNames: props.classNames,
260
+ styles: props.styles,
261
+ dir: props.dir
262
+ }));
263
+ function itemClass(item, part) {
264
+ return [props.classNames?.[part], item.className].filter(Boolean).join(" ");
265
+ }
266
+ function itemStyle(item, part) {
267
+ return {
268
+ ...resolveContextMenuStyle(resolvedStyles.value?.[part], theme.value),
269
+ ...resolveContextMenuStyle(item.style, theme.value)
283
270
  };
284
- const content = typeof props.content === "function" ? props.content(props.onHide) : props.content.map((item) => {
285
- if (item.hidden) return null;
286
- if (item.onClick || item.items) return h(ContextMenuItem, {
287
- key: item.key,
288
- className: [props.classNames?.item, item.className].filter(Boolean).join(" "),
289
- style: {
290
- ...resolveContextMenuStyle(resolvedStyles?.item, theme.value),
291
- ...resolveContextMenuStyle(item.style, theme.value)
292
- },
293
- title: item.title ?? humanize(item.key),
294
- icon: item.icon,
295
- iconRight: item.iconRight,
296
- color: item.color,
297
- disabled: item.disabled,
298
- onClick: item.onClick,
299
- items: item.items,
300
- onHide: props.onHide,
301
- submenuProps
302
- });
303
- return h(ContextMenuDivider, {
304
- key: item.key,
305
- className: [props.classNames?.divider, item.className].filter(Boolean).join(" "),
306
- style: {
307
- ...resolveContextMenuStyle(resolvedStyles?.divider, theme.value),
308
- ...resolveContextMenuStyle(item.style, theme.value)
309
- }
310
- });
311
- });
312
- return h(Paper, {
313
- ref: setMenuRef,
314
- shadow: settings.value.shadow,
315
- radius: settings.value.borderRadius,
271
+ }
272
+ const renderCustomContent = () => typeof props.content === "function" ? props.content(() => emit("hide")) : null;
273
+ return (_ctx, _cache) => {
274
+ return openBlock(), createBlock(unref(Paper), {
275
+ ref: (node) => menuRef.value = node?.$el ?? node ?? null,
276
+ shadow: unref(settings).shadow,
277
+ radius: unref(settings).borderRadius,
316
278
  dir: props.dir,
317
- class: [
279
+ class: normalizeClass([
318
280
  "mantine-contextmenu",
319
281
  mounted.value && "mantine-contextmenu-mounted",
320
282
  props.className,
321
283
  props.classNames?.root
322
- ],
323
- style: {
324
- ...position.value,
325
- ...resolveContextMenuStyle(props.style, theme.value),
326
- ...resolveContextMenuStyle(resolvedStyles?.root, theme.value)
327
- }
328
- }, () => content);
284
+ ]),
285
+ style: normalizeStyle(rootStyle.value)
286
+ }, {
287
+ default: withCtx(() => [typeof props.content === "function" ? (openBlock(), createBlock(resolveDynamicComponent(renderCustomContent), { key: 0 })) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(props.content, (item) => {
288
+ return openBlock(), createElementBlock(Fragment, { key: item.key }, [!item.hidden && (item.onClick || item.items) ? (openBlock(), createBlock(ContextMenuItem_default, {
289
+ key: 0,
290
+ "class-name": itemClass(item, "item"),
291
+ style: normalizeStyle(itemStyle(item, "item")),
292
+ title: item.title ?? unref(humanize)(item.key),
293
+ icon: item.icon,
294
+ "icon-right": item.iconRight,
295
+ color: item.color,
296
+ disabled: item.disabled,
297
+ "on-click": item.onClick,
298
+ items: item.items,
299
+ "submenu-props": submenuProps.value,
300
+ onHide: _cache[0] || (_cache[0] = ($event) => emit("hide"))
301
+ }, null, 8, [
302
+ "class-name",
303
+ "style",
304
+ "title",
305
+ "icon",
306
+ "icon-right",
307
+ "color",
308
+ "disabled",
309
+ "on-click",
310
+ "items",
311
+ "submenu-props"
312
+ ])) : !item.hidden ? (openBlock(), createBlock(ContextMenuDivider_default, {
313
+ key: 1,
314
+ "class-name": itemClass(item, "divider"),
315
+ style: normalizeStyle(itemStyle(item, "divider"))
316
+ }, null, 8, ["class-name", "style"])) : createCommentVNode("", true)], 64);
317
+ }), 128))]),
318
+ _: 1
319
+ }, 8, [
320
+ "shadow",
321
+ "radius",
322
+ "dir",
323
+ "class",
324
+ "style"
325
+ ]);
329
326
  };
330
327
  }
331
328
  });
332
329
  //#endregion
333
- //#region src/ContextMenuOverlay.ts
334
- var ContextMenuOverlay = defineComponent({
330
+ //#region src/components/ContextMenuOverlay/ContextMenuOverlay.vue
331
+ var ContextMenuOverlay_default = /* @__PURE__ */ defineComponent({
335
332
  name: "ContextMenuOverlay",
336
- props: {
337
- zIndex: {
338
- type: Number,
339
- default: void 0
340
- },
341
- onHide: {
342
- type: Function,
343
- required: true
344
- }
345
- },
346
- setup(props, { slots }) {
333
+ __name: "ContextMenuOverlay",
334
+ props: { zIndex: {} },
335
+ emits: ["hide"],
336
+ setup(__props, { emit: __emit }) {
337
+ const props = __props;
338
+ const emit = __emit;
347
339
  const settings = useContextMenuSettings();
348
- const handleClick = (event) => {
340
+ function click(event) {
349
341
  event.preventDefault();
350
- props.onHide();
351
- };
352
- const handleContextMenu = (event) => {
342
+ emit("hide");
343
+ }
344
+ function contextmenu(event) {
353
345
  event.preventDefault();
354
346
  if (!settings.value.repositionOnRepeat) {
355
- props.onHide();
347
+ emit("hide");
356
348
  return;
357
349
  }
358
350
  try {
@@ -362,136 +354,102 @@ var ContextMenuOverlay = defineComponent({
362
354
  clientY: event.clientY
363
355
  }));
364
356
  } catch {}
357
+ }
358
+ return (_ctx, _cache) => {
359
+ return openBlock(), createElementBlock("div", {
360
+ class: "mantine-contextmenu-overlay",
361
+ style: normalizeStyle({ zIndex: props.zIndex }),
362
+ onClick: click,
363
+ onContextmenu: contextmenu
364
+ }, [renderSlot(_ctx.$slots, "default")], 36);
365
365
  };
366
- return () => h("div", {
367
- class: "mantine-contextmenu-overlay",
368
- style: { zIndex: props.zIndex },
369
- onClick: handleClick,
370
- onContextmenu: handleContextMenu
371
- }, slots.default?.());
372
366
  }
373
367
  });
374
368
  //#endregion
375
- //#region src/ContextMenuPortal.ts
376
- var ContextMenuPortal = defineComponent({
369
+ //#region src/components/ContextMenuPortal/ContextMenuPortal.vue
370
+ var ContextMenuPortal_default = /* @__PURE__ */ defineComponent({
377
371
  name: "ContextMenuPortal",
372
+ __name: "ContextMenuPortal",
378
373
  props: {
379
- x: {
380
- type: Number,
381
- required: true
382
- },
383
- y: {
384
- type: Number,
385
- required: true
386
- },
387
- content: {
388
- type: [Array, Function],
389
- required: true
390
- },
391
- onHide: {
392
- type: Function,
393
- required: true
394
- },
395
- zIndex: {
396
- type: Number,
397
- default: void 0
398
- },
399
- dir: {
400
- type: String,
401
- required: true
402
- },
403
- className: {
404
- type: String,
405
- default: void 0
406
- },
407
- style: {
408
- type: [Object, Function],
409
- default: void 0
410
- },
411
- classNames: {
412
- type: Object,
413
- default: void 0
414
- },
415
- styles: {
416
- type: [Object, Function],
417
- default: void 0
418
- }
374
+ zIndex: {},
375
+ dir: {},
376
+ x: {},
377
+ y: {},
378
+ content: { type: [Array, Function] },
379
+ className: {},
380
+ style: { type: Function },
381
+ classNames: {},
382
+ styles: { type: [Object, Function] }
419
383
  },
420
- setup(props) {
421
- useWindowEvent("resize", props.onHide);
422
- useWindowEvent("scroll", props.onHide);
423
- useHotkeys([["Escape", props.onHide]]);
424
- return () => h(Portal, null, () => h(ContextMenuOverlay, {
425
- zIndex: props.zIndex,
426
- onHide: props.onHide
427
- }, () => h(ContextMenu, {
428
- x: props.x,
429
- y: props.y,
430
- content: props.content,
431
- onHide: props.onHide,
432
- dir: props.dir,
433
- zIndex: props.zIndex,
434
- className: props.className,
435
- style: props.style,
436
- classNames: props.classNames,
437
- styles: props.styles
438
- })));
384
+ emits: ["hide"],
385
+ setup(__props, { emit: __emit }) {
386
+ const props = __props;
387
+ const emit = __emit;
388
+ const hide = () => emit("hide");
389
+ useWindowEvent("resize", hide);
390
+ useWindowEvent("scroll", hide);
391
+ useHotkeys([["Escape", hide]]);
392
+ return (_ctx, _cache) => {
393
+ return openBlock(), createBlock(unref(Portal), null, {
394
+ default: withCtx(() => [createVNode(ContextMenuOverlay_default, {
395
+ "z-index": props.zIndex,
396
+ onHide: hide
397
+ }, {
398
+ default: withCtx(() => [createVNode(ContextMenu_default, {
399
+ x: props.x,
400
+ y: props.y,
401
+ content: props.content,
402
+ dir: props.dir,
403
+ "z-index": props.zIndex,
404
+ "class-name": props.className,
405
+ style: normalizeStyle(props.style),
406
+ "class-names": props.classNames,
407
+ styles: props.styles,
408
+ onHide: hide
409
+ }, null, 8, [
410
+ "x",
411
+ "y",
412
+ "content",
413
+ "dir",
414
+ "z-index",
415
+ "class-name",
416
+ "style",
417
+ "class-names",
418
+ "styles"
419
+ ])]),
420
+ _: 1
421
+ }, 8, ["z-index"])]),
422
+ _: 1
423
+ });
424
+ };
439
425
  }
440
426
  });
441
427
  //#endregion
442
- //#region src/ContextMenuProvider.ts
443
- var DEFAULT_SETTINGS = {
444
- shadow: "sm",
445
- borderRadius: "xs",
446
- submenuDelay: 500,
447
- repositionOnRepeat: false
448
- };
449
- var ContextMenuProvider = defineComponent({
428
+ //#region src/components/ContextMenuProvider/ContextMenuProvider.vue
429
+ var ContextMenuProvider_default = /* @__PURE__ */ defineComponent({
450
430
  name: "ContextMenuProvider",
431
+ __name: "ContextMenuProvider",
451
432
  props: {
452
- zIndex: {
453
- type: Number,
454
- default: 9999
455
- },
456
- shadow: {
457
- type: String,
458
- default: DEFAULT_SETTINGS.shadow
459
- },
460
- borderRadius: {
461
- type: [String, Number],
462
- default: DEFAULT_SETTINGS.borderRadius
463
- },
464
- submenuDelay: {
465
- type: Number,
466
- default: DEFAULT_SETTINGS.submenuDelay
467
- },
433
+ shadow: { default: "sm" },
434
+ borderRadius: { default: "xs" },
435
+ submenuDelay: { default: 500 },
468
436
  repositionOnRepeat: {
469
437
  type: Boolean,
470
- default: DEFAULT_SETTINGS.repositionOnRepeat
471
- },
472
- className: {
473
- type: String,
474
- default: void 0
475
- },
476
- style: {
477
- type: [Object, Function],
478
- default: void 0
479
- },
480
- classNames: {
481
- type: Object,
482
- default: void 0
438
+ default: false
483
439
  },
484
- styles: {
485
- type: [Object, Function],
486
- default: void 0
487
- }
440
+ zIndex: { default: 9999 },
441
+ className: {},
442
+ style: {},
443
+ classNames: {},
444
+ styles: {}
488
445
  },
489
- setup(props, { slots }) {
446
+ setup(__props) {
447
+ const props = __props;
490
448
  const data = shallowRef(null);
491
449
  const { dir } = useDirection();
492
- const hideContextMenu = () => {
450
+ function hideContextMenu() {
493
451
  data.value = null;
494
- };
452
+ }
495
453
  const showContextMenu = (content, options) => (event) => {
496
454
  event.preventDefault();
497
455
  event.stopPropagation();
@@ -522,14 +480,15 @@ var ContextMenuProvider = defineComponent({
522
480
  hideContextMenu,
523
481
  isContextMenuVisible: toRef(() => Boolean(data.value))
524
482
  });
525
- return () => h(Fragment, null, [slots.default?.(), data.value ? h(ContextMenuPortal, {
526
- ...data.value,
527
- onHide: hideContextMenu,
528
- dir: dir.value
529
- }) : null]);
483
+ return (_ctx, _cache) => {
484
+ return openBlock(), createElementBlock(Fragment, null, [renderSlot(_ctx.$slots, "default"), data.value ? (openBlock(), createBlock(ContextMenuPortal_default, mergeProps({ key: 0 }, data.value, {
485
+ dir: unref(dir),
486
+ onHide: hideContextMenu
487
+ }), null, 16, ["dir"])) : createCommentVNode("", true)], 64);
488
+ };
530
489
  }
531
490
  });
532
491
  //#endregion
533
- export { ContextMenu, ContextMenuKey as ContextMenuCtx, ContextMenuKey, ContextMenuDivider, ContextMenuItem, ContextMenuOverlay, ContextMenuPortal, ContextMenuProvider, ContextMenuSettingsKey as ContextMenuSettingsCtx, ContextMenuSettingsKey, humanize, resolveContextMenuStyle, resolveContextMenuStyles, useContextMenu };
492
+ export { ContextMenu_default as ContextMenu, ContextMenuKey as ContextMenuCtx, ContextMenuKey, ContextMenuDivider_default as ContextMenuDivider, ContextMenuItem_default as ContextMenuItem, ContextMenuOverlay_default as ContextMenuOverlay, ContextMenuPortal_default as ContextMenuPortal, ContextMenuProvider_default as ContextMenuProvider, ContextMenuSettingsKey as ContextMenuSettingsCtx, ContextMenuSettingsKey, humanize, resolveContextMenuStyle, resolveContextMenuStyles, useContextMenu };
534
493
 
535
494
  //# sourceMappingURL=index.mjs.map