@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 +319 -360
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +315 -356
- package/esm/index.mjs.map +1 -1
- package/lib/components/ContextMenu/ContextMenu.vue.d.ts +9 -0
- package/lib/components/ContextMenu/index.d.ts +2 -0
- package/lib/components/ContextMenuDivider/ContextMenuDivider.vue.d.ts +5 -0
- package/lib/components/ContextMenuDivider/index.d.ts +2 -0
- package/lib/components/ContextMenuItem/ContextMenuItem.vue.d.ts +9 -0
- package/lib/components/ContextMenuItem/index.d.ts +2 -0
- package/lib/components/ContextMenuOverlay/ContextMenuOverlay.vue.d.ts +21 -0
- package/lib/components/ContextMenuOverlay/index.d.ts +1 -0
- package/lib/components/ContextMenuPortal/ContextMenuPortal.vue.d.ts +8 -0
- package/lib/components/ContextMenuPortal/index.d.ts +2 -0
- package/lib/components/ContextMenuProvider/ContextMenuProvider.vue.d.ts +14 -0
- package/lib/components/ContextMenuProvider/index.d.ts +4 -0
- package/lib/index.d.mts +6 -6
- package/lib/index.d.ts +6 -6
- package/lib/types.d.ts +11 -2
- package/lib/utils.d.ts +1 -1
- package/package.json +3 -3
- package/lib/ContextMenu.d.ts +0 -4
- package/lib/ContextMenuDivider.d.ts +0 -14
- package/lib/ContextMenuItem.d.ts +0 -9
- package/lib/ContextMenuOverlay.d.ts +0 -25
- package/lib/ContextMenuPortal.d.ts +0 -33
- package/lib/ContextMenuProvider.d.ts +0 -93
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.
|
|
19
|
-
var
|
|
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
|
-
|
|
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(
|
|
26
|
+
setup(__props) {
|
|
27
|
+
const props = __props;
|
|
32
28
|
const theme = (0, _mantine_vue_core.useMantineTheme)();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
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
|
-
|
|
65
|
+
__name: "ContextMenuItem",
|
|
64
66
|
props: {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
87
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
126
|
+
}
|
|
127
|
+
function hideSubmenu() {
|
|
132
128
|
showSubmenuTimeout.clear();
|
|
133
129
|
hideSubmenuTimeout.start();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
})
|
|
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.
|
|
202
|
-
var
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
},
|
|
213
|
-
|
|
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
|
-
|
|
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
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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.
|
|
335
|
-
var
|
|
331
|
+
//#region src/components/ContextMenuOverlay/ContextMenuOverlay.vue
|
|
332
|
+
var ContextMenuOverlay_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
336
333
|
name: "ContextMenuOverlay",
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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
|
-
|
|
341
|
+
function click(event) {
|
|
350
342
|
event.preventDefault();
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
|
|
343
|
+
emit("hide");
|
|
344
|
+
}
|
|
345
|
+
function contextmenu(event) {
|
|
354
346
|
event.preventDefault();
|
|
355
347
|
if (!settings.value.repositionOnRepeat) {
|
|
356
|
-
|
|
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.
|
|
377
|
-
var
|
|
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
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
},
|
|
388
|
-
|
|
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
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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.
|
|
444
|
-
var
|
|
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
|
-
|
|
454
|
-
|
|
455
|
-
|
|
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:
|
|
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
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
441
|
+
zIndex: { default: 9999 },
|
|
442
|
+
className: {},
|
|
443
|
+
style: {},
|
|
444
|
+
classNames: {},
|
|
445
|
+
styles: {}
|
|
489
446
|
},
|
|
490
|
-
setup(
|
|
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
|
-
|
|
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 (
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
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 =
|
|
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.
|
|
538
|
-
exports.
|
|
539
|
-
exports.
|
|
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;
|