@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,168 @@
|
|
|
1
|
+
import { defineComponent, shallowRef, computed, watch, createVNode } from "vue";
|
|
2
|
+
import Trigger from "@v-c/trigger";
|
|
3
|
+
import { clsx } from "@v-c/util";
|
|
4
|
+
import raf from "@v-c/util/dist/raf.ts";
|
|
5
|
+
import { useMenuContext } from "../context/MenuContext.js";
|
|
6
|
+
import { placementsRtl, placements } from "../placements.js";
|
|
7
|
+
import { getMotion } from "../utils/motionUtil.js";
|
|
8
|
+
const popupPlacementMap = {
|
|
9
|
+
"horizontal": "bottomLeft",
|
|
10
|
+
"vertical": "rightTop",
|
|
11
|
+
"vertical-left": "rightTop",
|
|
12
|
+
"vertical-right": "leftTop"
|
|
13
|
+
};
|
|
14
|
+
const PopupTrigger = /* @__PURE__ */ defineComponent((props, {
|
|
15
|
+
slots
|
|
16
|
+
}) => {
|
|
17
|
+
const menuContext = useMenuContext();
|
|
18
|
+
const innerVisible = shallowRef(props.visible ?? false);
|
|
19
|
+
const placement = computed(() => {
|
|
20
|
+
const rtl = menuContext?.value?.rtl;
|
|
21
|
+
const builtinPlacements = menuContext?.value?.builtinPlacements;
|
|
22
|
+
return rtl ? {
|
|
23
|
+
...placementsRtl,
|
|
24
|
+
...builtinPlacements
|
|
25
|
+
} : {
|
|
26
|
+
...placements,
|
|
27
|
+
...builtinPlacements
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
const triggerMode = computed(() => props.mode);
|
|
31
|
+
const popupPlacement = computed(() => {
|
|
32
|
+
return popupPlacementMap[triggerMode.value];
|
|
33
|
+
});
|
|
34
|
+
const defaultMotions = computed(() => menuContext?.value?.defaultMotions);
|
|
35
|
+
const motion = computed(() => menuContext?.value?.motion);
|
|
36
|
+
const targetMotion = computed(() => {
|
|
37
|
+
return {
|
|
38
|
+
...getMotion(triggerMode.value, motion.value, defaultMotions.value)
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
const targetMotionRef = shallowRef(targetMotion.value);
|
|
42
|
+
watch(triggerMode, (mode) => {
|
|
43
|
+
if (mode !== "inline") {
|
|
44
|
+
targetMotionRef.value = targetMotion.value;
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
immediate: true
|
|
48
|
+
});
|
|
49
|
+
watch([motion, defaultMotions], () => {
|
|
50
|
+
if (triggerMode.value !== "inline") {
|
|
51
|
+
targetMotionRef.value = targetMotion.value;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const mergedMotion = computed(() => {
|
|
55
|
+
return {
|
|
56
|
+
...targetMotionRef.value,
|
|
57
|
+
appear: true
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
const visibleRef = shallowRef();
|
|
61
|
+
watch(() => props.visible, (visible, _, onCleanup) => {
|
|
62
|
+
visibleRef.value = raf(() => {
|
|
63
|
+
innerVisible.value = visible;
|
|
64
|
+
});
|
|
65
|
+
onCleanup(() => {
|
|
66
|
+
if (visibleRef.value !== void 0) {
|
|
67
|
+
raf.cancel(visibleRef.value);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
return () => {
|
|
72
|
+
const {
|
|
73
|
+
popupClassName,
|
|
74
|
+
popup,
|
|
75
|
+
popupStyle,
|
|
76
|
+
popupOffset,
|
|
77
|
+
disabled,
|
|
78
|
+
onVisibleChange,
|
|
79
|
+
prefixCls
|
|
80
|
+
} = props;
|
|
81
|
+
const {
|
|
82
|
+
rtl,
|
|
83
|
+
rootClassName,
|
|
84
|
+
mode,
|
|
85
|
+
getPopupContainer,
|
|
86
|
+
triggerSubMenuAction,
|
|
87
|
+
subMenuCloseDelay,
|
|
88
|
+
subMenuOpenDelay,
|
|
89
|
+
forceSubMenuRender
|
|
90
|
+
} = menuContext?.value ?? {};
|
|
91
|
+
return createVNode(Trigger, {
|
|
92
|
+
"prefixCls": prefixCls,
|
|
93
|
+
"popupClassName": clsx(`${prefixCls}-popup`, {
|
|
94
|
+
[`${prefixCls}-rtl`]: rtl
|
|
95
|
+
}, popupClassName, rootClassName),
|
|
96
|
+
"stretch": mode === "horizontal" ? "minWidth" : void 0,
|
|
97
|
+
"getPopupContainer": getPopupContainer,
|
|
98
|
+
"builtinPlacements": placement.value,
|
|
99
|
+
"popupPlacement": popupPlacement.value,
|
|
100
|
+
"popupVisible": innerVisible.value,
|
|
101
|
+
"popup": popup,
|
|
102
|
+
"popupStyle": popupStyle,
|
|
103
|
+
"popupAlign": popupOffset && {
|
|
104
|
+
offset: popupOffset
|
|
105
|
+
},
|
|
106
|
+
"action": disabled ? [] : [triggerSubMenuAction],
|
|
107
|
+
"mouseEnterDelay": subMenuOpenDelay,
|
|
108
|
+
"mouseLeaveDelay": subMenuCloseDelay,
|
|
109
|
+
"onOpenChange": onVisibleChange,
|
|
110
|
+
"forceRender": forceSubMenuRender,
|
|
111
|
+
"popupMotion": mergedMotion.value,
|
|
112
|
+
"fresh": true
|
|
113
|
+
}, {
|
|
114
|
+
default: () => [slots?.default?.()]
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
}, {
|
|
118
|
+
props: {
|
|
119
|
+
prefixCls: {
|
|
120
|
+
type: String,
|
|
121
|
+
required: true,
|
|
122
|
+
default: void 0
|
|
123
|
+
},
|
|
124
|
+
mode: {
|
|
125
|
+
type: String,
|
|
126
|
+
required: true,
|
|
127
|
+
default: void 0
|
|
128
|
+
},
|
|
129
|
+
visible: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
required: true,
|
|
132
|
+
default: void 0
|
|
133
|
+
},
|
|
134
|
+
popup: {
|
|
135
|
+
type: null,
|
|
136
|
+
required: true,
|
|
137
|
+
default: void 0
|
|
138
|
+
},
|
|
139
|
+
popupStyle: {
|
|
140
|
+
type: null,
|
|
141
|
+
required: false,
|
|
142
|
+
default: void 0
|
|
143
|
+
},
|
|
144
|
+
popupClassName: {
|
|
145
|
+
type: String,
|
|
146
|
+
required: false,
|
|
147
|
+
default: void 0
|
|
148
|
+
},
|
|
149
|
+
popupOffset: {
|
|
150
|
+
type: Array,
|
|
151
|
+
required: false,
|
|
152
|
+
default: void 0
|
|
153
|
+
},
|
|
154
|
+
disabled: {
|
|
155
|
+
type: Boolean,
|
|
156
|
+
required: true,
|
|
157
|
+
default: void 0
|
|
158
|
+
},
|
|
159
|
+
onVisibleChange: {
|
|
160
|
+
type: Function,
|
|
161
|
+
required: true,
|
|
162
|
+
default: void 0
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
export {
|
|
167
|
+
PopupTrigger as default
|
|
168
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
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 MenuContext = require("../context/MenuContext.cjs");
|
|
6
|
+
const InternalSubMenuList = /* @__PURE__ */ vue.defineComponent((_, {
|
|
7
|
+
attrs,
|
|
8
|
+
slots
|
|
9
|
+
}) => {
|
|
10
|
+
const menuContext = MenuContext.useMenuContext();
|
|
11
|
+
return () => {
|
|
12
|
+
const {
|
|
13
|
+
prefixCls,
|
|
14
|
+
mode,
|
|
15
|
+
rtl
|
|
16
|
+
} = menuContext?.value ?? {};
|
|
17
|
+
return vue.createVNode("ul", vue.mergeProps({
|
|
18
|
+
"class": util.clsx(prefixCls, !!rtl && `${prefixCls}-rtl`, `${prefixCls}-sub`, `${prefixCls}-${mode === "inline" ? "inline" : "vertical"}`),
|
|
19
|
+
"role": "menu"
|
|
20
|
+
}, attrs, {
|
|
21
|
+
"data-menu-list": true
|
|
22
|
+
}), [slots?.default?.()]);
|
|
23
|
+
};
|
|
24
|
+
}, {
|
|
25
|
+
name: "InlineSubMenuList",
|
|
26
|
+
inheritAttrs: false
|
|
27
|
+
});
|
|
28
|
+
exports.default = InternalSubMenuList;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineComponent, createVNode, mergeProps } from "vue";
|
|
2
|
+
import { clsx } from "@v-c/util";
|
|
3
|
+
import { useMenuContext } from "../context/MenuContext.js";
|
|
4
|
+
const InternalSubMenuList = /* @__PURE__ */ defineComponent((_, {
|
|
5
|
+
attrs,
|
|
6
|
+
slots
|
|
7
|
+
}) => {
|
|
8
|
+
const menuContext = useMenuContext();
|
|
9
|
+
return () => {
|
|
10
|
+
const {
|
|
11
|
+
prefixCls,
|
|
12
|
+
mode,
|
|
13
|
+
rtl
|
|
14
|
+
} = menuContext?.value ?? {};
|
|
15
|
+
return createVNode("ul", mergeProps({
|
|
16
|
+
"class": clsx(prefixCls, !!rtl && `${prefixCls}-rtl`, `${prefixCls}-sub`, `${prefixCls}-${mode === "inline" ? "inline" : "vertical"}`),
|
|
17
|
+
"role": "menu"
|
|
18
|
+
}, attrs, {
|
|
19
|
+
"data-menu-list": true
|
|
20
|
+
}), [slots?.default?.()]);
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
name: "InlineSubMenuList",
|
|
24
|
+
inheritAttrs: false
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
InternalSubMenuList as default
|
|
28
|
+
};
|