@imengyu/vue3-context-menu 1.3.5 → 1.3.6
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/README.md +1 -1
- package/lib/ContextMenu.vue.d.ts +1 -1
- package/lib/ContextMenuDefine.d.ts +10 -0
- package/lib/ContextMenuGroup.vue.d.ts +1 -1
- package/lib/ContextMenuIconCheck.vue.d.ts +1 -1
- package/lib/ContextMenuIconRight.vue.d.ts +1 -1
- package/lib/ContextMenuInstance.d.ts +59 -0
- package/lib/ContextMenuItem.vue.d.ts +1 -1
- package/lib/ContextMenuSeparator.vue.d.ts +1 -1
- package/lib/ContextMenuUtils.d.ts +34 -6
- package/lib/ContextSubMenu.vue.d.ts +1 -1
- package/lib/ContextSubMenuWrapper.vue.d.ts +1 -1
- package/lib/MenuBar.vue.d.ts +1 -1
- package/lib/MenuBarIconMenu.vue.d.ts +1 -1
- package/lib/vue3-context-menu.es.js +484 -410
- package/lib/vue3-context-menu.es.js.map +1 -1
- package/lib/vue3-context-menu.umd.js +1 -1
- package/lib/vue3-context-menu.umd.js.map +1 -1
- package/package.json +54 -54
package/README.md
CHANGED
package/lib/ContextMenu.vue.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
22
22
|
};
|
|
23
23
|
}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
24
24
|
[key: string]: any;
|
|
25
|
-
}>[], unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:show" | "close")[], "update:show" | "close", import("vue").
|
|
25
|
+
}>[], unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:show" | "close")[], "update:show" | "close", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
26
26
|
/**
|
|
27
27
|
* Menu options
|
|
28
28
|
*/
|
|
@@ -22,6 +22,10 @@ export interface ContextMenuInstance {
|
|
|
22
22
|
* @param fromItem The last clicked menu item, will pass to `MenuOptions.onClose` callback, if user does not click any item, can be `undefined`.
|
|
23
23
|
*/
|
|
24
24
|
closeMenu(fromItem?: MenuItem | undefined): void;
|
|
25
|
+
/**
|
|
26
|
+
* Check if the menu is currently closed.
|
|
27
|
+
*/
|
|
28
|
+
isClosed(): boolean;
|
|
25
29
|
}
|
|
26
30
|
export type MenuPopDirection = 'br' | 'b' | 'bl' | 'tr' | 't' | 'tl' | 'l' | 'r';
|
|
27
31
|
export interface MenuOptions {
|
|
@@ -120,6 +124,12 @@ export interface MenuOptions {
|
|
|
120
124
|
* If your element in menu item has this className, click it will ignore event.
|
|
121
125
|
*/
|
|
122
126
|
ignoreClickClassName?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Set should close menu when the user click on other places.
|
|
129
|
+
*
|
|
130
|
+
* @default true
|
|
131
|
+
*/
|
|
132
|
+
clickCloseOnOutside?: boolean;
|
|
123
133
|
/**
|
|
124
134
|
* If your element in menu item has this className, click it will ignore event and close hole menu.
|
|
125
135
|
*/
|
|
@@ -128,7 +128,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
128
128
|
};
|
|
129
129
|
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
130
130
|
[key: string]: any;
|
|
131
|
-
}>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
131
|
+
}>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
132
132
|
/**
|
|
133
133
|
* Is this menu disabled?
|
|
134
134
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
2
|
export default _default;
|
|
@@ -11,11 +11,70 @@ declare const _default: {
|
|
|
11
11
|
install(app: App<Element>): void;
|
|
12
12
|
/**
|
|
13
13
|
* Show a ContextMenu in page, same as `this.$contextmenu`
|
|
14
|
+
*
|
|
15
|
+
* For example:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* onContextMenu(e : MouseEvent) {
|
|
19
|
+
* //prevent the browser's default menu
|
|
20
|
+
* e.preventDefault();
|
|
21
|
+
* //show your menu
|
|
22
|
+
* ContextMenu.showContextMenu({
|
|
23
|
+
* x: e.x,
|
|
24
|
+
* y: e.y,
|
|
25
|
+
* items: [
|
|
26
|
+
* {
|
|
27
|
+
* label: "A menu item",
|
|
28
|
+
* onClick: () => {
|
|
29
|
+
* alert("You click a menu item");
|
|
30
|
+
* }
|
|
31
|
+
* },
|
|
32
|
+
* {
|
|
33
|
+
* label: "A submenu",
|
|
34
|
+
* children: [
|
|
35
|
+
* { label: "Item1" },
|
|
36
|
+
* { label: "Item2" },
|
|
37
|
+
* { label: "Item3" },
|
|
38
|
+
* ]
|
|
39
|
+
* },
|
|
40
|
+
* ]
|
|
41
|
+
* });
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* You can pass customSlots to custom rendering this menu.
|
|
46
|
+
*
|
|
47
|
+
* For example, custom rendering #itemRender and #separatorRender:
|
|
48
|
+
* ```ts
|
|
49
|
+
* ContextMenu.showContextMenu({
|
|
50
|
+
* ...
|
|
51
|
+
* } as MenuOptions, {
|
|
52
|
+
* //Use slot in function mode
|
|
53
|
+
* itemRender: ({ disabled, label, icon, showRightArrow, onClick, onMouseEnter }) => [ h('div', {
|
|
54
|
+
* class: 'my-menu-item'+(disabled?' disabled':''),
|
|
55
|
+
* onMouseenter: onMouseEnter,
|
|
56
|
+
* onClick: onClick,
|
|
57
|
+
* }, [
|
|
58
|
+
* icon ? h('img', { src: icon }) : h('div', { class: 'icon-place-holder' }),
|
|
59
|
+
* h('span', label),
|
|
60
|
+
* showRightArrow ? h('span', { class: 'right-arraw' }, '>>') : h('div'),
|
|
61
|
+
* ]) ],
|
|
62
|
+
* separatorRender: () => [ h('div', { class: 'my-menu-sperator' }) ]
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
14
66
|
* @param options The options of ContextMenu
|
|
15
67
|
* @param customSlots You can provide some custom slots to customize the rendering style of the menu. These slots are the same as the slots of component ContextMenu.
|
|
16
68
|
* @returns Menu instance
|
|
17
69
|
*/
|
|
18
70
|
showContextMenu(options: MenuOptions, customSlots?: Record<string, Slot>): ContextMenuInstance;
|
|
71
|
+
/**
|
|
72
|
+
* Get if there is a menu open now.
|
|
73
|
+
*/
|
|
74
|
+
isAnyContextMenuOpen(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Close the currently open menu
|
|
77
|
+
*/
|
|
19
78
|
closeContextMenu: typeof closeContextMenu;
|
|
20
79
|
transformMenuPosition: typeof transformMenuPosition;
|
|
21
80
|
};
|
|
@@ -154,7 +154,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
154
154
|
globalIconFontClass: string;
|
|
155
155
|
onMouseEnter: (e?: MouseEvent) => void;
|
|
156
156
|
onClick: (e: MouseEvent | KeyboardEvent) => void;
|
|
157
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "subMenuOpen" | "subMenuClose")[], "click" | "subMenuOpen" | "subMenuClose", import("vue").
|
|
157
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "subMenuOpen" | "subMenuClose")[], "click" | "subMenuOpen" | "subMenuClose", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
158
158
|
/**
|
|
159
159
|
* Is this menu disabled?
|
|
160
160
|
*/
|
|
@@ -2,5 +2,5 @@ import type { GlobalHasSlot, GlobalRenderSlot } from './ContextSubMenuWrapper.vu
|
|
|
2
2
|
declare const _default: import("vue").DefineComponent<{}, {
|
|
3
3
|
globalHasSlot: GlobalHasSlot;
|
|
4
4
|
globalRenderSlot: GlobalRenderSlot;
|
|
5
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
5
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
6
6
|
export default _default;
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import type { VNode } from "vue";
|
|
2
2
|
import type { MenuOptions } from "./ContextMenuDefine";
|
|
3
|
+
/**
|
|
4
|
+
* Get absolute y position of HTMLElement
|
|
5
|
+
* @param e Element
|
|
6
|
+
* @param stopNode Specify the node for recursive termination, default to body
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
3
9
|
export declare function getTop(e: HTMLElement, stopNode?: HTMLElement): number;
|
|
10
|
+
/**
|
|
11
|
+
* Get absolute x position of HTMLElement
|
|
12
|
+
* @param e Element
|
|
13
|
+
* @param stopNode Specify the node for recursive termination, default to body
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
4
16
|
export declare function getLeft(e: HTMLElement, stopNode?: HTMLElement): number;
|
|
5
17
|
/**
|
|
6
18
|
* If your `body` element is in a scaled state (e.g. `transform: scale(0.5)`),
|
|
@@ -34,31 +46,47 @@ export declare function genContainer(options: MenuOptions): {
|
|
|
34
46
|
container: HTMLElement;
|
|
35
47
|
isNew: boolean;
|
|
36
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Number to px string
|
|
51
|
+
* @param value
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
37
54
|
export declare function solveNumberOrStringSize(value: string | number): string;
|
|
38
55
|
/**
|
|
39
56
|
* Render a VNode
|
|
40
57
|
*/
|
|
41
58
|
export declare const VNodeRender: import("vue").DefineComponent<{
|
|
59
|
+
/**
|
|
60
|
+
* Can be VNode or (data: unknown) => VNode
|
|
61
|
+
*/
|
|
42
62
|
vnode: {
|
|
43
|
-
type:
|
|
44
|
-
default: null;
|
|
63
|
+
type: null;
|
|
45
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* If vnode is a callback, this data will be passed to the callback first parameter.
|
|
67
|
+
* @default null
|
|
68
|
+
*/
|
|
46
69
|
data: {
|
|
47
70
|
type: ObjectConstructor;
|
|
48
71
|
default: null;
|
|
49
72
|
};
|
|
50
73
|
}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
51
74
|
[key: string]: any;
|
|
52
|
-
}>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
75
|
+
}>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
76
|
+
/**
|
|
77
|
+
* Can be VNode or (data: unknown) => VNode
|
|
78
|
+
*/
|
|
53
79
|
vnode: {
|
|
54
|
-
type:
|
|
55
|
-
default: null;
|
|
80
|
+
type: null;
|
|
56
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* If vnode is a callback, this data will be passed to the callback first parameter.
|
|
84
|
+
* @default null
|
|
85
|
+
*/
|
|
57
86
|
data: {
|
|
58
87
|
type: ObjectConstructor;
|
|
59
88
|
default: null;
|
|
60
89
|
};
|
|
61
90
|
}>>, {
|
|
62
91
|
data: Record<string, any>;
|
|
63
|
-
vnode: Function | Record<string, any>;
|
|
64
92
|
}, {}>;
|
|
@@ -122,7 +122,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
122
122
|
onMouseWhell: (e: WheelEvent) => void;
|
|
123
123
|
onMouseWhellMx: (e: WheelEvent) => void;
|
|
124
124
|
solveNumberOrStringSize: typeof solveNumberOrStringSize;
|
|
125
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
125
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
126
126
|
/**
|
|
127
127
|
* Items from options
|
|
128
128
|
*/
|
|
@@ -36,7 +36,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
36
36
|
};
|
|
37
37
|
}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
38
38
|
[key: string]: any;
|
|
39
|
-
}>[], unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:show" | "close")[], "update:show" | "close", import("vue").
|
|
39
|
+
}>[], unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:show" | "close")[], "update:show" | "close", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
40
40
|
/**
|
|
41
41
|
* Menu options
|
|
42
42
|
*/
|
package/lib/MenuBar.vue.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
11
11
|
type: PropType<MenuBarOptions>;
|
|
12
12
|
default: null;
|
|
13
13
|
};
|
|
14
|
-
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
14
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
15
15
|
/**
|
|
16
16
|
* Menu options
|
|
17
17
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
2
|
export default _default;
|