@v-c/menu 0.0.1 → 0.0.3
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/dist/Divider.cjs +33 -36
- package/dist/Divider.js +28 -34
- package/dist/Icon.cjs +39 -38
- package/dist/Icon.js +36 -38
- package/dist/Menu.cjs +506 -575
- package/dist/Menu.d.ts +2 -0
- package/dist/Menu.js +495 -570
- package/dist/MenuItem.cjs +314 -344
- package/dist/MenuItem.js +303 -339
- package/dist/MenuItemGroup.cjs +98 -116
- package/dist/MenuItemGroup.js +91 -113
- package/dist/SubMenu/InlineSubMenuList.cjs +58 -82
- package/dist/SubMenu/InlineSubMenuList.js +54 -81
- package/dist/SubMenu/PopupTrigger.cjs +133 -167
- package/dist/SubMenu/PopupTrigger.d.ts +2 -2
- package/dist/SubMenu/PopupTrigger.js +126 -165
- package/dist/SubMenu/SubMenuList.cjs +18 -26
- package/dist/SubMenu/SubMenuList.js +14 -25
- package/dist/SubMenu/index.cjs +479 -526
- package/dist/SubMenu/index.js +469 -521
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/context/IdContext.cjs +15 -23
- package/dist/context/IdContext.js +15 -27
- package/dist/context/MenuContext.cjs +183 -174
- package/dist/context/MenuContext.js +180 -177
- package/dist/context/PathContext.cjs +54 -79
- package/dist/context/PathContext.js +54 -90
- package/dist/context/PrivateContext.cjs +11 -17
- package/dist/context/PrivateContext.js +11 -20
- package/dist/hooks/useAccessibility.cjs +171 -191
- package/dist/hooks/useAccessibility.js +168 -193
- package/dist/hooks/useActive.cjs +25 -28
- package/dist/hooks/useActive.js +23 -28
- package/dist/hooks/useDirectionStyle.cjs +11 -17
- package/dist/hooks/useDirectionStyle.js +9 -17
- package/dist/hooks/useKeyRecords.cjs +70 -88
- package/dist/hooks/useKeyRecords.js +68 -89
- package/dist/hooks/useMemoCallback.cjs +9 -9
- package/dist/hooks/useMemoCallback.js +7 -9
- package/dist/index.cjs +21 -21
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -20
- package/dist/interface.cjs +0 -1
- package/dist/interface.js +0 -1
- package/dist/placements.cjs +70 -70
- package/dist/placements.js +69 -72
- package/dist/utils/commonUtil.cjs +24 -26
- package/dist/utils/commonUtil.js +23 -26
- package/dist/utils/motionUtil.cjs +2 -9
- package/dist/utils/motionUtil.js +3 -10
- package/dist/utils/nodeUtil.cjs +49 -77
- package/dist/utils/nodeUtil.d.ts +4 -1
- package/dist/utils/nodeUtil.js +48 -77
- package/dist/utils/timeUtil.cjs +2 -3
- package/dist/utils/timeUtil.js +3 -4
- package/dist/utils/warnUtil.cjs +8 -14
- package/dist/utils/warnUtil.js +7 -14
- package/package.json +2 -2
|
@@ -1,168 +1,129 @@
|
|
|
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
1
|
import { useMenuContext } from "../context/MenuContext.js";
|
|
6
|
-
import { placementsRtl, placements } from "../placements.js";
|
|
7
2
|
import { getMotion } from "../utils/motionUtil.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
3
|
+
import placements_default, { placementsRtl } from "../placements.js";
|
|
4
|
+
import { computed, createVNode, defineComponent, shallowRef, watch } from "vue";
|
|
5
|
+
import { clsx } from "@v-c/util";
|
|
6
|
+
import Trigger from "@v-c/trigger";
|
|
7
|
+
import raf from "@v-c/util/dist/raf";
|
|
8
|
+
var popupPlacementMap = {
|
|
9
|
+
"horizontal": "bottomLeft",
|
|
10
|
+
"vertical": "rightTop",
|
|
11
|
+
"vertical-left": "rightTop",
|
|
12
|
+
"vertical-right": "leftTop"
|
|
168
13
|
};
|
|
14
|
+
var PopupTrigger_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
15
|
+
const menuContext = useMenuContext();
|
|
16
|
+
const innerVisible = shallowRef(props.visible ?? false);
|
|
17
|
+
const placement = computed(() => {
|
|
18
|
+
const rtl = menuContext?.value?.rtl;
|
|
19
|
+
const builtinPlacements = menuContext?.value?.builtinPlacements;
|
|
20
|
+
return rtl ? {
|
|
21
|
+
...placementsRtl,
|
|
22
|
+
...builtinPlacements
|
|
23
|
+
} : {
|
|
24
|
+
...placements_default,
|
|
25
|
+
...builtinPlacements
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
const triggerMode = computed(() => props.mode);
|
|
29
|
+
const popupPlacement = computed(() => {
|
|
30
|
+
return popupPlacementMap[triggerMode.value];
|
|
31
|
+
});
|
|
32
|
+
const defaultMotions = computed(() => menuContext?.value?.defaultMotions);
|
|
33
|
+
const motion = computed(() => menuContext?.value?.motion);
|
|
34
|
+
const targetMotion = computed(() => {
|
|
35
|
+
return { ...getMotion(triggerMode.value, motion.value, defaultMotions.value) };
|
|
36
|
+
});
|
|
37
|
+
const targetMotionRef = shallowRef(targetMotion.value);
|
|
38
|
+
watch(triggerMode, (mode) => {
|
|
39
|
+
if (mode !== "inline") targetMotionRef.value = targetMotion.value;
|
|
40
|
+
}, { immediate: true });
|
|
41
|
+
watch([motion, defaultMotions], () => {
|
|
42
|
+
if (triggerMode.value !== "inline") targetMotionRef.value = targetMotion.value;
|
|
43
|
+
});
|
|
44
|
+
const mergedMotion = computed(() => {
|
|
45
|
+
return {
|
|
46
|
+
...targetMotionRef.value,
|
|
47
|
+
appear: true
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
const visibleRef = shallowRef();
|
|
51
|
+
watch(() => props.visible, (visible, _, onCleanup) => {
|
|
52
|
+
visibleRef.value = raf(() => {
|
|
53
|
+
innerVisible.value = visible;
|
|
54
|
+
});
|
|
55
|
+
onCleanup(() => {
|
|
56
|
+
if (visibleRef.value !== void 0) raf.cancel(visibleRef.value);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
return () => {
|
|
60
|
+
const { popupClassName, popup, popupStyle, popupOffset, disabled, onVisibleChange, prefixCls } = props;
|
|
61
|
+
const { rtl, rootClassName, mode, getPopupContainer, triggerSubMenuAction, subMenuCloseDelay, subMenuOpenDelay, forceSubMenuRender } = menuContext?.value ?? {};
|
|
62
|
+
return createVNode(Trigger, {
|
|
63
|
+
"prefixCls": prefixCls,
|
|
64
|
+
"popupClassName": clsx(`${prefixCls}-popup`, { [`${prefixCls}-rtl`]: rtl }, popupClassName, rootClassName),
|
|
65
|
+
"stretch": mode === "horizontal" ? "minWidth" : void 0,
|
|
66
|
+
"getPopupContainer": getPopupContainer,
|
|
67
|
+
"builtinPlacements": placement.value,
|
|
68
|
+
"popupPlacement": popupPlacement.value,
|
|
69
|
+
"popupVisible": innerVisible.value,
|
|
70
|
+
"popup": popup,
|
|
71
|
+
"popupStyle": popupStyle,
|
|
72
|
+
"popupAlign": popupOffset && { offset: popupOffset },
|
|
73
|
+
"action": disabled ? [] : [triggerSubMenuAction],
|
|
74
|
+
"mouseEnterDelay": subMenuOpenDelay,
|
|
75
|
+
"mouseLeaveDelay": subMenuCloseDelay,
|
|
76
|
+
"onOpenChange": onVisibleChange,
|
|
77
|
+
"forceRender": forceSubMenuRender,
|
|
78
|
+
"popupMotion": mergedMotion.value,
|
|
79
|
+
"fresh": true
|
|
80
|
+
}, { default: () => [slots?.default?.()] });
|
|
81
|
+
};
|
|
82
|
+
}, { props: {
|
|
83
|
+
prefixCls: {
|
|
84
|
+
type: String,
|
|
85
|
+
required: true,
|
|
86
|
+
default: void 0
|
|
87
|
+
},
|
|
88
|
+
mode: {
|
|
89
|
+
type: String,
|
|
90
|
+
required: true,
|
|
91
|
+
default: void 0
|
|
92
|
+
},
|
|
93
|
+
visible: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
required: true,
|
|
96
|
+
default: void 0
|
|
97
|
+
},
|
|
98
|
+
popup: {
|
|
99
|
+
type: null,
|
|
100
|
+
required: true,
|
|
101
|
+
default: void 0
|
|
102
|
+
},
|
|
103
|
+
popupStyle: {
|
|
104
|
+
type: null,
|
|
105
|
+
required: false,
|
|
106
|
+
default: void 0
|
|
107
|
+
},
|
|
108
|
+
popupClassName: {
|
|
109
|
+
type: String,
|
|
110
|
+
required: false,
|
|
111
|
+
default: void 0
|
|
112
|
+
},
|
|
113
|
+
popupOffset: {
|
|
114
|
+
type: Array,
|
|
115
|
+
required: false,
|
|
116
|
+
default: void 0
|
|
117
|
+
},
|
|
118
|
+
disabled: {
|
|
119
|
+
type: Boolean,
|
|
120
|
+
required: true,
|
|
121
|
+
default: void 0
|
|
122
|
+
},
|
|
123
|
+
onVisibleChange: {
|
|
124
|
+
type: Function,
|
|
125
|
+
required: true,
|
|
126
|
+
default: void 0
|
|
127
|
+
}
|
|
128
|
+
} });
|
|
129
|
+
export { PopupTrigger_default as default };
|
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
};
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
|
+
const require_MenuContext = require("../context/MenuContext.cjs");
|
|
4
|
+
let vue = require("vue");
|
|
5
|
+
let __v_c_util = require("@v-c/util");
|
|
6
|
+
var InternalSubMenuList = /* @__PURE__ */ (0, vue.defineComponent)((_, { attrs, slots }) => {
|
|
7
|
+
const menuContext = require_MenuContext.useMenuContext();
|
|
8
|
+
return () => {
|
|
9
|
+
const { prefixCls, mode, rtl } = menuContext?.value ?? {};
|
|
10
|
+
return (0, vue.createVNode)("ul", (0, vue.mergeProps)({
|
|
11
|
+
"class": (0, __v_c_util.clsx)(prefixCls, !!rtl && `${prefixCls}-rtl`, `${prefixCls}-sub`, `${prefixCls}-${mode === "inline" ? "inline" : "vertical"}`),
|
|
12
|
+
"role": "menu"
|
|
13
|
+
}, attrs, { "data-menu-list": true }), [slots?.default?.()]);
|
|
14
|
+
};
|
|
24
15
|
}, {
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
name: "InlineSubMenuList",
|
|
17
|
+
inheritAttrs: false
|
|
27
18
|
});
|
|
28
|
-
|
|
19
|
+
var SubMenuList_default = InternalSubMenuList;
|
|
20
|
+
exports.default = SubMenuList_default;
|
|
@@ -1,28 +1,17 @@
|
|
|
1
|
-
import { defineComponent, createVNode, mergeProps } from "vue";
|
|
2
|
-
import { clsx } from "@v-c/util";
|
|
3
1
|
import { useMenuContext } from "../context/MenuContext.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
};
|
|
2
|
+
import { createVNode, defineComponent, mergeProps } from "vue";
|
|
3
|
+
import { clsx } from "@v-c/util";
|
|
4
|
+
var SubMenuList_default = /* @__PURE__ */ defineComponent((_, { attrs, slots }) => {
|
|
5
|
+
const menuContext = useMenuContext();
|
|
6
|
+
return () => {
|
|
7
|
+
const { prefixCls, mode, rtl } = menuContext?.value ?? {};
|
|
8
|
+
return createVNode("ul", mergeProps({
|
|
9
|
+
"class": clsx(prefixCls, !!rtl && `${prefixCls}-rtl`, `${prefixCls}-sub`, `${prefixCls}-${mode === "inline" ? "inline" : "vertical"}`),
|
|
10
|
+
"role": "menu"
|
|
11
|
+
}, attrs, { "data-menu-list": true }), [slots?.default?.()]);
|
|
12
|
+
};
|
|
22
13
|
}, {
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
name: "InlineSubMenuList",
|
|
15
|
+
inheritAttrs: false
|
|
25
16
|
});
|
|
26
|
-
export {
|
|
27
|
-
InternalSubMenuList as default
|
|
28
|
-
};
|
|
17
|
+
export { SubMenuList_default as default };
|