@v-c/menu 0.0.1
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/LICENSE +21 -0
- package/dist/Divider.cjs +38 -0
- package/dist/Divider.d.ts +4 -0
- package/dist/Divider.js +38 -0
- package/dist/Icon.cjs +38 -0
- package/dist/Icon.d.ts +7 -0
- package/dist/Icon.js +38 -0
- package/dist/Menu.cjs +580 -0
- package/dist/Menu.d.ts +77 -0
- package/dist/Menu.js +580 -0
- package/dist/MenuItem.cjs +350 -0
- package/dist/MenuItem.d.ts +14 -0
- package/dist/MenuItem.js +350 -0
- package/dist/MenuItemGroup.cjs +120 -0
- package/dist/MenuItemGroup.d.ts +16 -0
- package/dist/MenuItemGroup.js +120 -0
- package/dist/SubMenu/InlineSubMenuList.cjs +84 -0
- package/dist/SubMenu/InlineSubMenuList.d.ts +7 -0
- package/dist/SubMenu/InlineSubMenuList.js +84 -0
- package/dist/SubMenu/PopupTrigger.cjs +168 -0
- package/dist/SubMenu/PopupTrigger.d.ts +16 -0
- package/dist/SubMenu/PopupTrigger.js +168 -0
- package/dist/SubMenu/SubMenuList.cjs +28 -0
- package/dist/SubMenu/SubMenuList.d.ts +2 -0
- package/dist/SubMenu/SubMenuList.js +28 -0
- package/dist/SubMenu/index.cjs +532 -0
- package/dist/SubMenu/index.d.ts +18 -0
- package/dist/SubMenu/index.js +532 -0
- package/dist/context/IdContext.cjs +33 -0
- package/dist/context/IdContext.d.ts +12 -0
- package/dist/context/IdContext.js +33 -0
- package/dist/context/MenuContext.cjs +184 -0
- package/dist/context/MenuContext.d.ts +42 -0
- package/dist/context/MenuContext.js +184 -0
- package/dist/context/PathContext.cjs +100 -0
- package/dist/context/PathContext.d.ts +33 -0
- package/dist/context/PathContext.js +100 -0
- package/dist/context/PrivateContext.cjs +24 -0
- package/dist/context/PrivateContext.d.ts +8 -0
- package/dist/context/PrivateContext.js +24 -0
- package/dist/hooks/useAccessibility.cjs +210 -0
- package/dist/hooks/useAccessibility.d.ts +12 -0
- package/dist/hooks/useAccessibility.js +210 -0
- package/dist/hooks/useActive.cjs +31 -0
- package/dist/hooks/useActive.d.ts +9 -0
- package/dist/hooks/useActive.js +31 -0
- package/dist/hooks/useDirectionStyle.cjs +20 -0
- package/dist/hooks/useDirectionStyle.d.ts +2 -0
- package/dist/hooks/useDirectionStyle.js +20 -0
- package/dist/hooks/useKeyRecords.cjs +93 -0
- package/dist/hooks/useKeyRecords.d.ts +10 -0
- package/dist/hooks/useKeyRecords.js +93 -0
- package/dist/hooks/useMemoCallback.cjs +12 -0
- package/dist/hooks/useMemoCallback.d.ts +4 -0
- package/dist/hooks/useMemoCallback.js +12 -0
- package/dist/index.cjs +21 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +21 -0
- package/dist/interface.cjs +1 -0
- package/dist/interface.d.ts +94 -0
- package/dist/interface.js +1 -0
- package/dist/placements.cjs +77 -0
- package/dist/placements.d.ts +117 -0
- package/dist/placements.js +77 -0
- package/dist/utils/commonUtil.cjs +29 -0
- package/dist/utils/commonUtil.d.ts +1 -0
- package/dist/utils/commonUtil.js +29 -0
- package/dist/utils/motionUtil.cjs +12 -0
- package/dist/utils/motionUtil.d.ts +2 -0
- package/dist/utils/motionUtil.js +12 -0
- package/dist/utils/nodeUtil.cjs +82 -0
- package/dist/utils/nodeUtil.d.ts +3 -0
- package/dist/utils/nodeUtil.js +82 -0
- package/dist/utils/timeUtil.cjs +6 -0
- package/dist/utils/timeUtil.d.ts +1 -0
- package/dist/utils/timeUtil.js +6 -0
- package/dist/utils/warnUtil.cjs +16 -0
- package/dist/utils/warnUtil.d.ts +7 -0
- package/dist/utils/warnUtil.js +16 -0
- package/package.json +37 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const util = require("@v-c/util");
|
|
5
|
+
const omit = require("@v-c/util/dist/omit.ts");
|
|
6
|
+
const propsUtil = require("@v-c/util/dist/props-util");
|
|
7
|
+
const MenuContext = require("./context/MenuContext.cjs");
|
|
8
|
+
const PathContext = require("./context/PathContext.cjs");
|
|
9
|
+
const commonUtil = require("./utils/commonUtil.cjs");
|
|
10
|
+
function _isSlot(s) {
|
|
11
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
|
|
12
|
+
}
|
|
13
|
+
const InternalMenuItemGroup = /* @__PURE__ */ vue.defineComponent((props, {
|
|
14
|
+
slots
|
|
15
|
+
}) => {
|
|
16
|
+
const context = MenuContext.useMenuContext();
|
|
17
|
+
return () => {
|
|
18
|
+
const {
|
|
19
|
+
class: className,
|
|
20
|
+
title,
|
|
21
|
+
eventKey,
|
|
22
|
+
...restProps
|
|
23
|
+
} = props;
|
|
24
|
+
const {
|
|
25
|
+
prefixCls,
|
|
26
|
+
classNames: menuClassNames,
|
|
27
|
+
styles
|
|
28
|
+
} = context?.value ?? {};
|
|
29
|
+
const groupPrefixCls = `${prefixCls}-item-group`;
|
|
30
|
+
return vue.createVNode("li", vue.mergeProps({
|
|
31
|
+
"role": "presentation"
|
|
32
|
+
}, restProps, {
|
|
33
|
+
"onClick": (e) => e.stopPropagation(),
|
|
34
|
+
"class": util.clsx(groupPrefixCls, className)
|
|
35
|
+
}), [vue.createVNode("div", {
|
|
36
|
+
"role": "presentation",
|
|
37
|
+
"class": util.clsx(`${groupPrefixCls}-title`, menuClassNames?.listTitle),
|
|
38
|
+
"style": styles?.listTitle,
|
|
39
|
+
"title": typeof title === "string" ? title : void 0
|
|
40
|
+
}, [title]), vue.createVNode("ul", {
|
|
41
|
+
"role": "group",
|
|
42
|
+
"class": util.clsx(`${groupPrefixCls}-list`, menuClassNames?.list),
|
|
43
|
+
"style": styles?.list
|
|
44
|
+
}, [slots?.default ? slots.default() : null])]);
|
|
45
|
+
};
|
|
46
|
+
}, {
|
|
47
|
+
props: {
|
|
48
|
+
title: {
|
|
49
|
+
type: null,
|
|
50
|
+
required: false,
|
|
51
|
+
default: void 0
|
|
52
|
+
},
|
|
53
|
+
eventKey: {
|
|
54
|
+
type: String,
|
|
55
|
+
required: false,
|
|
56
|
+
default: void 0
|
|
57
|
+
},
|
|
58
|
+
warnKey: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
required: false,
|
|
61
|
+
default: void 0
|
|
62
|
+
},
|
|
63
|
+
style: {
|
|
64
|
+
type: null,
|
|
65
|
+
required: false,
|
|
66
|
+
default: void 0
|
|
67
|
+
},
|
|
68
|
+
class: {
|
|
69
|
+
type: String,
|
|
70
|
+
required: false,
|
|
71
|
+
default: void 0
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const MenuItemGroup = /* @__PURE__ */ vue.defineComponent((props, ctx) => {
|
|
76
|
+
const connectedKeyPath = PathContext.useFullPath(vue.computed(() => props.eventKey));
|
|
77
|
+
const measure = PathContext.useMeasure();
|
|
78
|
+
return () => {
|
|
79
|
+
const slots = ctx.slots;
|
|
80
|
+
const children = propsUtil.filterEmpty(slots.default ? slots.default() : []);
|
|
81
|
+
const childList = commonUtil.parseChildren(children, connectedKeyPath.value);
|
|
82
|
+
if (measure) {
|
|
83
|
+
return childList;
|
|
84
|
+
}
|
|
85
|
+
return vue.createVNode(InternalMenuItemGroup, omit(props, ["warnKey"]), _isSlot(childList) ? childList : {
|
|
86
|
+
default: () => [childList]
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
}, {
|
|
90
|
+
props: {
|
|
91
|
+
title: {
|
|
92
|
+
type: null,
|
|
93
|
+
required: false,
|
|
94
|
+
default: void 0
|
|
95
|
+
},
|
|
96
|
+
eventKey: {
|
|
97
|
+
type: String,
|
|
98
|
+
required: false,
|
|
99
|
+
default: void 0
|
|
100
|
+
},
|
|
101
|
+
warnKey: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
required: false,
|
|
104
|
+
default: void 0
|
|
105
|
+
},
|
|
106
|
+
style: {
|
|
107
|
+
type: null,
|
|
108
|
+
required: false,
|
|
109
|
+
default: void 0
|
|
110
|
+
},
|
|
111
|
+
class: {
|
|
112
|
+
type: String,
|
|
113
|
+
required: false,
|
|
114
|
+
default: void 0
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
name: "MenuItemGroup",
|
|
118
|
+
inheritAttrs: false
|
|
119
|
+
});
|
|
120
|
+
exports.default = MenuItemGroup;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VueNode } from '@v-c/util/dist/type';
|
|
2
|
+
import { MenuItemGroupType } from './interface';
|
|
3
|
+
export interface MenuItemGroupProps extends Omit<MenuItemGroupType, 'type' | 'children' | 'label'> {
|
|
4
|
+
title?: VueNode;
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
eventKey?: string;
|
|
10
|
+
/**
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
warnKey?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const MenuItemGroup: import('vue').DefineSetupFnComponent<MenuItemGroupProps, {}, {}, MenuItemGroupProps & {}, import('vue').PublicProps>;
|
|
16
|
+
export default MenuItemGroup;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { defineComponent, computed, createVNode, mergeProps, isVNode } from "vue";
|
|
2
|
+
import { clsx } from "@v-c/util";
|
|
3
|
+
import omit from "@v-c/util/dist/omit.ts";
|
|
4
|
+
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
5
|
+
import { useMenuContext } from "./context/MenuContext.js";
|
|
6
|
+
import { useFullPath, useMeasure } from "./context/PathContext.js";
|
|
7
|
+
import { parseChildren } from "./utils/commonUtil.js";
|
|
8
|
+
function _isSlot(s) {
|
|
9
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
10
|
+
}
|
|
11
|
+
const InternalMenuItemGroup = /* @__PURE__ */ defineComponent((props, {
|
|
12
|
+
slots
|
|
13
|
+
}) => {
|
|
14
|
+
const context = useMenuContext();
|
|
15
|
+
return () => {
|
|
16
|
+
const {
|
|
17
|
+
class: className,
|
|
18
|
+
title,
|
|
19
|
+
eventKey,
|
|
20
|
+
...restProps
|
|
21
|
+
} = props;
|
|
22
|
+
const {
|
|
23
|
+
prefixCls,
|
|
24
|
+
classNames: menuClassNames,
|
|
25
|
+
styles
|
|
26
|
+
} = context?.value ?? {};
|
|
27
|
+
const groupPrefixCls = `${prefixCls}-item-group`;
|
|
28
|
+
return createVNode("li", mergeProps({
|
|
29
|
+
"role": "presentation"
|
|
30
|
+
}, restProps, {
|
|
31
|
+
"onClick": (e) => e.stopPropagation(),
|
|
32
|
+
"class": clsx(groupPrefixCls, className)
|
|
33
|
+
}), [createVNode("div", {
|
|
34
|
+
"role": "presentation",
|
|
35
|
+
"class": clsx(`${groupPrefixCls}-title`, menuClassNames?.listTitle),
|
|
36
|
+
"style": styles?.listTitle,
|
|
37
|
+
"title": typeof title === "string" ? title : void 0
|
|
38
|
+
}, [title]), createVNode("ul", {
|
|
39
|
+
"role": "group",
|
|
40
|
+
"class": clsx(`${groupPrefixCls}-list`, menuClassNames?.list),
|
|
41
|
+
"style": styles?.list
|
|
42
|
+
}, [slots?.default ? slots.default() : null])]);
|
|
43
|
+
};
|
|
44
|
+
}, {
|
|
45
|
+
props: {
|
|
46
|
+
title: {
|
|
47
|
+
type: null,
|
|
48
|
+
required: false,
|
|
49
|
+
default: void 0
|
|
50
|
+
},
|
|
51
|
+
eventKey: {
|
|
52
|
+
type: String,
|
|
53
|
+
required: false,
|
|
54
|
+
default: void 0
|
|
55
|
+
},
|
|
56
|
+
warnKey: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
required: false,
|
|
59
|
+
default: void 0
|
|
60
|
+
},
|
|
61
|
+
style: {
|
|
62
|
+
type: null,
|
|
63
|
+
required: false,
|
|
64
|
+
default: void 0
|
|
65
|
+
},
|
|
66
|
+
class: {
|
|
67
|
+
type: String,
|
|
68
|
+
required: false,
|
|
69
|
+
default: void 0
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const MenuItemGroup = /* @__PURE__ */ defineComponent((props, ctx) => {
|
|
74
|
+
const connectedKeyPath = useFullPath(computed(() => props.eventKey));
|
|
75
|
+
const measure = useMeasure();
|
|
76
|
+
return () => {
|
|
77
|
+
const slots = ctx.slots;
|
|
78
|
+
const children = filterEmpty(slots.default ? slots.default() : []);
|
|
79
|
+
const childList = parseChildren(children, connectedKeyPath.value);
|
|
80
|
+
if (measure) {
|
|
81
|
+
return childList;
|
|
82
|
+
}
|
|
83
|
+
return createVNode(InternalMenuItemGroup, omit(props, ["warnKey"]), _isSlot(childList) ? childList : {
|
|
84
|
+
default: () => [childList]
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
}, {
|
|
88
|
+
props: {
|
|
89
|
+
title: {
|
|
90
|
+
type: null,
|
|
91
|
+
required: false,
|
|
92
|
+
default: void 0
|
|
93
|
+
},
|
|
94
|
+
eventKey: {
|
|
95
|
+
type: String,
|
|
96
|
+
required: false,
|
|
97
|
+
default: void 0
|
|
98
|
+
},
|
|
99
|
+
warnKey: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
required: false,
|
|
102
|
+
default: void 0
|
|
103
|
+
},
|
|
104
|
+
style: {
|
|
105
|
+
type: null,
|
|
106
|
+
required: false,
|
|
107
|
+
default: void 0
|
|
108
|
+
},
|
|
109
|
+
class: {
|
|
110
|
+
type: String,
|
|
111
|
+
required: false,
|
|
112
|
+
default: void 0
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
name: "MenuItemGroup",
|
|
116
|
+
inheritAttrs: false
|
|
117
|
+
});
|
|
118
|
+
export {
|
|
119
|
+
MenuItemGroup as default
|
|
120
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const transition = require("@v-c/util/dist/utils/transition");
|
|
5
|
+
const MenuContext = require("../context/MenuContext.cjs");
|
|
6
|
+
const motionUtil = require("../utils/motionUtil.cjs");
|
|
7
|
+
const SubMenuList = require("./SubMenuList.cjs");
|
|
8
|
+
const InlineSubMenuList = /* @__PURE__ */ vue.defineComponent((props, {
|
|
9
|
+
slots
|
|
10
|
+
}) => {
|
|
11
|
+
const fixedMode = "inline";
|
|
12
|
+
const menuContext = MenuContext.useMenuContext();
|
|
13
|
+
const sameModeRef = vue.shallowRef(false);
|
|
14
|
+
vue.watchEffect(() => {
|
|
15
|
+
sameModeRef.value = menuContext?.value?.mode === fixedMode;
|
|
16
|
+
});
|
|
17
|
+
const destroy = vue.shallowRef(!sameModeRef.value);
|
|
18
|
+
vue.watch(() => menuContext?.value?.mode, () => {
|
|
19
|
+
if (sameModeRef.value) {
|
|
20
|
+
destroy.value = false;
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
immediate: true
|
|
24
|
+
});
|
|
25
|
+
const mergedOpen = vue.computed(() => sameModeRef.value ? props?.open : false);
|
|
26
|
+
const mergedMotion = vue.computed(() => {
|
|
27
|
+
const {
|
|
28
|
+
motion,
|
|
29
|
+
defaultMotions
|
|
30
|
+
} = menuContext?.value ?? {};
|
|
31
|
+
const motionData = {
|
|
32
|
+
...motionUtil.getMotion(fixedMode, motion, defaultMotions)
|
|
33
|
+
};
|
|
34
|
+
if (props.keyPath && props.keyPath.length > 1) {
|
|
35
|
+
motionData.appear = false;
|
|
36
|
+
}
|
|
37
|
+
const _onAfterLeave = motionData.onAfterLeave;
|
|
38
|
+
motionData.onAfterLeave = (el) => {
|
|
39
|
+
if (!sameModeRef.value) {
|
|
40
|
+
destroy.value = true;
|
|
41
|
+
}
|
|
42
|
+
return _onAfterLeave?.(el);
|
|
43
|
+
};
|
|
44
|
+
return motionData;
|
|
45
|
+
});
|
|
46
|
+
return () => {
|
|
47
|
+
if (destroy.value) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return vue.createVNode(MenuContext.default, {
|
|
51
|
+
"mode": fixedMode,
|
|
52
|
+
"locked": !sameModeRef.value
|
|
53
|
+
}, {
|
|
54
|
+
default: () => [vue.createVNode(vue.Transition, transition.getTransitionProps(mergedMotion.value?.name, mergedMotion.value), {
|
|
55
|
+
default: () => [mergedOpen.value && vue.createVNode(SubMenuList.default, {
|
|
56
|
+
"id": props.id
|
|
57
|
+
}, {
|
|
58
|
+
default: () => [slots?.default?.()]
|
|
59
|
+
})]
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
}, {
|
|
64
|
+
props: {
|
|
65
|
+
id: {
|
|
66
|
+
type: String,
|
|
67
|
+
required: false,
|
|
68
|
+
default: void 0
|
|
69
|
+
},
|
|
70
|
+
open: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
required: true,
|
|
73
|
+
default: void 0
|
|
74
|
+
},
|
|
75
|
+
keyPath: {
|
|
76
|
+
type: Array,
|
|
77
|
+
required: true,
|
|
78
|
+
default: void 0
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
name: "InlineSubMenuList",
|
|
82
|
+
inheritAttrs: false
|
|
83
|
+
});
|
|
84
|
+
exports.default = InlineSubMenuList;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface InlineSubMenuListProps {
|
|
2
|
+
id?: string;
|
|
3
|
+
open: boolean;
|
|
4
|
+
keyPath: string[];
|
|
5
|
+
}
|
|
6
|
+
declare const InlineSubMenuList: import('vue').DefineSetupFnComponent<InlineSubMenuListProps, {}, {}, InlineSubMenuListProps & {}, import('vue').PublicProps>;
|
|
7
|
+
export default InlineSubMenuList;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { defineComponent, shallowRef, watchEffect, watch, computed, createVNode, Transition } from "vue";
|
|
2
|
+
import { getTransitionProps } from "@v-c/util/dist/utils/transition";
|
|
3
|
+
import InheritableContextProvider, { useMenuContext } from "../context/MenuContext.js";
|
|
4
|
+
import { getMotion } from "../utils/motionUtil.js";
|
|
5
|
+
import InternalSubMenuList from "./SubMenuList.js";
|
|
6
|
+
const InlineSubMenuList = /* @__PURE__ */ defineComponent((props, {
|
|
7
|
+
slots
|
|
8
|
+
}) => {
|
|
9
|
+
const fixedMode = "inline";
|
|
10
|
+
const menuContext = useMenuContext();
|
|
11
|
+
const sameModeRef = shallowRef(false);
|
|
12
|
+
watchEffect(() => {
|
|
13
|
+
sameModeRef.value = menuContext?.value?.mode === fixedMode;
|
|
14
|
+
});
|
|
15
|
+
const destroy = shallowRef(!sameModeRef.value);
|
|
16
|
+
watch(() => menuContext?.value?.mode, () => {
|
|
17
|
+
if (sameModeRef.value) {
|
|
18
|
+
destroy.value = false;
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
immediate: true
|
|
22
|
+
});
|
|
23
|
+
const mergedOpen = computed(() => sameModeRef.value ? props?.open : false);
|
|
24
|
+
const mergedMotion = computed(() => {
|
|
25
|
+
const {
|
|
26
|
+
motion,
|
|
27
|
+
defaultMotions
|
|
28
|
+
} = menuContext?.value ?? {};
|
|
29
|
+
const motionData = {
|
|
30
|
+
...getMotion(fixedMode, motion, defaultMotions)
|
|
31
|
+
};
|
|
32
|
+
if (props.keyPath && props.keyPath.length > 1) {
|
|
33
|
+
motionData.appear = false;
|
|
34
|
+
}
|
|
35
|
+
const _onAfterLeave = motionData.onAfterLeave;
|
|
36
|
+
motionData.onAfterLeave = (el) => {
|
|
37
|
+
if (!sameModeRef.value) {
|
|
38
|
+
destroy.value = true;
|
|
39
|
+
}
|
|
40
|
+
return _onAfterLeave?.(el);
|
|
41
|
+
};
|
|
42
|
+
return motionData;
|
|
43
|
+
});
|
|
44
|
+
return () => {
|
|
45
|
+
if (destroy.value) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return createVNode(InheritableContextProvider, {
|
|
49
|
+
"mode": fixedMode,
|
|
50
|
+
"locked": !sameModeRef.value
|
|
51
|
+
}, {
|
|
52
|
+
default: () => [createVNode(Transition, getTransitionProps(mergedMotion.value?.name, mergedMotion.value), {
|
|
53
|
+
default: () => [mergedOpen.value && createVNode(InternalSubMenuList, {
|
|
54
|
+
"id": props.id
|
|
55
|
+
}, {
|
|
56
|
+
default: () => [slots?.default?.()]
|
|
57
|
+
})]
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
}, {
|
|
62
|
+
props: {
|
|
63
|
+
id: {
|
|
64
|
+
type: String,
|
|
65
|
+
required: false,
|
|
66
|
+
default: void 0
|
|
67
|
+
},
|
|
68
|
+
open: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
required: true,
|
|
71
|
+
default: void 0
|
|
72
|
+
},
|
|
73
|
+
keyPath: {
|
|
74
|
+
type: Array,
|
|
75
|
+
required: true,
|
|
76
|
+
default: void 0
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
name: "InlineSubMenuList",
|
|
80
|
+
inheritAttrs: false
|
|
81
|
+
});
|
|
82
|
+
export {
|
|
83
|
+
InlineSubMenuList as default
|
|
84
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const Trigger = require("@v-c/trigger");
|
|
5
|
+
const util = require("@v-c/util");
|
|
6
|
+
const raf = require("@v-c/util/dist/raf.ts");
|
|
7
|
+
const MenuContext = require("../context/MenuContext.cjs");
|
|
8
|
+
const placements = require("../placements.cjs");
|
|
9
|
+
const motionUtil = require("../utils/motionUtil.cjs");
|
|
10
|
+
const popupPlacementMap = {
|
|
11
|
+
"horizontal": "bottomLeft",
|
|
12
|
+
"vertical": "rightTop",
|
|
13
|
+
"vertical-left": "rightTop",
|
|
14
|
+
"vertical-right": "leftTop"
|
|
15
|
+
};
|
|
16
|
+
const PopupTrigger = /* @__PURE__ */ vue.defineComponent((props, {
|
|
17
|
+
slots
|
|
18
|
+
}) => {
|
|
19
|
+
const menuContext = MenuContext.useMenuContext();
|
|
20
|
+
const innerVisible = vue.shallowRef(props.visible ?? false);
|
|
21
|
+
const placement = vue.computed(() => {
|
|
22
|
+
const rtl = menuContext?.value?.rtl;
|
|
23
|
+
const builtinPlacements = menuContext?.value?.builtinPlacements;
|
|
24
|
+
return rtl ? {
|
|
25
|
+
...placements.placementsRtl,
|
|
26
|
+
...builtinPlacements
|
|
27
|
+
} : {
|
|
28
|
+
...placements.placements,
|
|
29
|
+
...builtinPlacements
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
const triggerMode = vue.computed(() => props.mode);
|
|
33
|
+
const popupPlacement = vue.computed(() => {
|
|
34
|
+
return popupPlacementMap[triggerMode.value];
|
|
35
|
+
});
|
|
36
|
+
const defaultMotions = vue.computed(() => menuContext?.value?.defaultMotions);
|
|
37
|
+
const motion = vue.computed(() => menuContext?.value?.motion);
|
|
38
|
+
const targetMotion = vue.computed(() => {
|
|
39
|
+
return {
|
|
40
|
+
...motionUtil.getMotion(triggerMode.value, motion.value, defaultMotions.value)
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const targetMotionRef = vue.shallowRef(targetMotion.value);
|
|
44
|
+
vue.watch(triggerMode, (mode) => {
|
|
45
|
+
if (mode !== "inline") {
|
|
46
|
+
targetMotionRef.value = targetMotion.value;
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
immediate: true
|
|
50
|
+
});
|
|
51
|
+
vue.watch([motion, defaultMotions], () => {
|
|
52
|
+
if (triggerMode.value !== "inline") {
|
|
53
|
+
targetMotionRef.value = targetMotion.value;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const mergedMotion = vue.computed(() => {
|
|
57
|
+
return {
|
|
58
|
+
...targetMotionRef.value,
|
|
59
|
+
appear: true
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
const visibleRef = vue.shallowRef();
|
|
63
|
+
vue.watch(() => props.visible, (visible, _, onCleanup) => {
|
|
64
|
+
visibleRef.value = raf(() => {
|
|
65
|
+
innerVisible.value = visible;
|
|
66
|
+
});
|
|
67
|
+
onCleanup(() => {
|
|
68
|
+
if (visibleRef.value !== void 0) {
|
|
69
|
+
raf.cancel(visibleRef.value);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return () => {
|
|
74
|
+
const {
|
|
75
|
+
popupClassName,
|
|
76
|
+
popup,
|
|
77
|
+
popupStyle,
|
|
78
|
+
popupOffset,
|
|
79
|
+
disabled,
|
|
80
|
+
onVisibleChange,
|
|
81
|
+
prefixCls
|
|
82
|
+
} = props;
|
|
83
|
+
const {
|
|
84
|
+
rtl,
|
|
85
|
+
rootClassName,
|
|
86
|
+
mode,
|
|
87
|
+
getPopupContainer,
|
|
88
|
+
triggerSubMenuAction,
|
|
89
|
+
subMenuCloseDelay,
|
|
90
|
+
subMenuOpenDelay,
|
|
91
|
+
forceSubMenuRender
|
|
92
|
+
} = menuContext?.value ?? {};
|
|
93
|
+
return vue.createVNode(Trigger, {
|
|
94
|
+
"prefixCls": prefixCls,
|
|
95
|
+
"popupClassName": util.clsx(`${prefixCls}-popup`, {
|
|
96
|
+
[`${prefixCls}-rtl`]: rtl
|
|
97
|
+
}, popupClassName, rootClassName),
|
|
98
|
+
"stretch": mode === "horizontal" ? "minWidth" : void 0,
|
|
99
|
+
"getPopupContainer": getPopupContainer,
|
|
100
|
+
"builtinPlacements": placement.value,
|
|
101
|
+
"popupPlacement": popupPlacement.value,
|
|
102
|
+
"popupVisible": innerVisible.value,
|
|
103
|
+
"popup": popup,
|
|
104
|
+
"popupStyle": popupStyle,
|
|
105
|
+
"popupAlign": popupOffset && {
|
|
106
|
+
offset: popupOffset
|
|
107
|
+
},
|
|
108
|
+
"action": disabled ? [] : [triggerSubMenuAction],
|
|
109
|
+
"mouseEnterDelay": subMenuOpenDelay,
|
|
110
|
+
"mouseLeaveDelay": subMenuCloseDelay,
|
|
111
|
+
"onOpenChange": onVisibleChange,
|
|
112
|
+
"forceRender": forceSubMenuRender,
|
|
113
|
+
"popupMotion": mergedMotion.value,
|
|
114
|
+
"fresh": true
|
|
115
|
+
}, {
|
|
116
|
+
default: () => [slots?.default?.()]
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
}, {
|
|
120
|
+
props: {
|
|
121
|
+
prefixCls: {
|
|
122
|
+
type: String,
|
|
123
|
+
required: true,
|
|
124
|
+
default: void 0
|
|
125
|
+
},
|
|
126
|
+
mode: {
|
|
127
|
+
type: String,
|
|
128
|
+
required: true,
|
|
129
|
+
default: void 0
|
|
130
|
+
},
|
|
131
|
+
visible: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
required: true,
|
|
134
|
+
default: void 0
|
|
135
|
+
},
|
|
136
|
+
popup: {
|
|
137
|
+
type: null,
|
|
138
|
+
required: true,
|
|
139
|
+
default: void 0
|
|
140
|
+
},
|
|
141
|
+
popupStyle: {
|
|
142
|
+
type: null,
|
|
143
|
+
required: false,
|
|
144
|
+
default: void 0
|
|
145
|
+
},
|
|
146
|
+
popupClassName: {
|
|
147
|
+
type: String,
|
|
148
|
+
required: false,
|
|
149
|
+
default: void 0
|
|
150
|
+
},
|
|
151
|
+
popupOffset: {
|
|
152
|
+
type: Array,
|
|
153
|
+
required: false,
|
|
154
|
+
default: void 0
|
|
155
|
+
},
|
|
156
|
+
disabled: {
|
|
157
|
+
type: Boolean,
|
|
158
|
+
required: true,
|
|
159
|
+
default: void 0
|
|
160
|
+
},
|
|
161
|
+
onVisibleChange: {
|
|
162
|
+
type: Function,
|
|
163
|
+
required: true,
|
|
164
|
+
default: void 0
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
exports.default = PopupTrigger;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VueNode } from '@v-c/util/dist/type.ts';
|
|
2
|
+
import { CSSProperties } from 'vue';
|
|
3
|
+
import { MenuMode } from '../interface.ts';
|
|
4
|
+
export interface PopupTriggerProps {
|
|
5
|
+
prefixCls: string;
|
|
6
|
+
mode: MenuMode;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
popup: VueNode;
|
|
9
|
+
popupStyle?: CSSProperties;
|
|
10
|
+
popupClassName?: string;
|
|
11
|
+
popupOffset?: number[];
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
onVisibleChange: (visible: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const PopupTrigger: import('vue').DefineSetupFnComponent<PopupTriggerProps, {}, {}, PopupTriggerProps & {}, import('vue').PublicProps>;
|
|
16
|
+
export default PopupTrigger;
|