@mantine-vue/contextmenu 3.0.0 → 3.1.0

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