@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,84 +1,57 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getTransitionProps } from "@v-c/util/dist/utils/transition";
|
|
3
|
-
import InheritableContextProvider, { useMenuContext } from "../context/MenuContext.js";
|
|
1
|
+
import MenuContext_default, { useMenuContext } from "../context/MenuContext.js";
|
|
4
2
|
import { getMotion } from "../utils/motionUtil.js";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
};
|
|
3
|
+
import SubMenuList_default from "./SubMenuList.js";
|
|
4
|
+
import { Transition, computed, createVNode, defineComponent, shallowRef, watch, watchEffect } from "vue";
|
|
5
|
+
import { getTransitionProps } from "@v-c/util/dist/utils/transition";
|
|
6
|
+
var InlineSubMenuList_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
7
|
+
const fixedMode = "inline";
|
|
8
|
+
const menuContext = useMenuContext();
|
|
9
|
+
const sameModeRef = shallowRef(false);
|
|
10
|
+
watchEffect(() => {
|
|
11
|
+
sameModeRef.value = menuContext?.value?.mode === fixedMode;
|
|
12
|
+
});
|
|
13
|
+
const destroy = shallowRef(!sameModeRef.value);
|
|
14
|
+
watch(() => menuContext?.value?.mode, () => {
|
|
15
|
+
if (sameModeRef.value) destroy.value = false;
|
|
16
|
+
}, { immediate: true });
|
|
17
|
+
const mergedOpen = computed(() => sameModeRef.value ? props?.open : false);
|
|
18
|
+
const mergedMotion = computed(() => {
|
|
19
|
+
const { motion, defaultMotions } = menuContext?.value ?? {};
|
|
20
|
+
const motionData = { ...getMotion(fixedMode, motion, defaultMotions) };
|
|
21
|
+
if (props.keyPath && props.keyPath.length > 1) motionData.appear = false;
|
|
22
|
+
const _onAfterLeave = motionData.onAfterLeave;
|
|
23
|
+
motionData.onAfterLeave = (el) => {
|
|
24
|
+
if (!sameModeRef.value) destroy.value = true;
|
|
25
|
+
return _onAfterLeave?.(el);
|
|
26
|
+
};
|
|
27
|
+
return motionData;
|
|
28
|
+
});
|
|
29
|
+
return () => {
|
|
30
|
+
if (destroy.value) return null;
|
|
31
|
+
return createVNode(MenuContext_default, {
|
|
32
|
+
"mode": fixedMode,
|
|
33
|
+
"locked": !sameModeRef.value
|
|
34
|
+
}, { default: () => [createVNode(Transition, getTransitionProps(mergedMotion.value?.name, mergedMotion.value), { default: () => [mergedOpen.value && createVNode(SubMenuList_default, { "id": props.id }, { default: () => [slots?.default?.()] })] })] });
|
|
35
|
+
};
|
|
61
36
|
}, {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
37
|
+
props: {
|
|
38
|
+
id: {
|
|
39
|
+
type: String,
|
|
40
|
+
required: false,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
open: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
required: true,
|
|
46
|
+
default: void 0
|
|
47
|
+
},
|
|
48
|
+
keyPath: {
|
|
49
|
+
type: Array,
|
|
50
|
+
required: true,
|
|
51
|
+
default: void 0
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
name: "InlineSubMenuList",
|
|
55
|
+
inheritAttrs: false
|
|
81
56
|
});
|
|
82
|
-
export {
|
|
83
|
-
InlineSubMenuList as default
|
|
84
|
-
};
|
|
57
|
+
export { InlineSubMenuList_default as default };
|
|
@@ -1,168 +1,134 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
const require_motionUtil = require("../utils/motionUtil.cjs");
|
|
5
|
+
const require_placements = require("../placements.cjs");
|
|
6
|
+
let vue = require("vue");
|
|
7
|
+
let __v_c_util = require("@v-c/util");
|
|
8
|
+
let __v_c_trigger = require("@v-c/trigger");
|
|
9
|
+
__v_c_trigger = require_rolldown_runtime.__toESM(__v_c_trigger);
|
|
10
|
+
let __v_c_util_dist_raf = require("@v-c/util/dist/raf");
|
|
11
|
+
__v_c_util_dist_raf = require_rolldown_runtime.__toESM(__v_c_util_dist_raf);
|
|
12
|
+
var popupPlacementMap = {
|
|
13
|
+
"horizontal": "bottomLeft",
|
|
14
|
+
"vertical": "rightTop",
|
|
15
|
+
"vertical-left": "rightTop",
|
|
16
|
+
"vertical-right": "leftTop"
|
|
15
17
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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;
|
|
18
|
+
var PopupTrigger = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
19
|
+
const menuContext = require_MenuContext.useMenuContext();
|
|
20
|
+
const innerVisible = (0, vue.shallowRef)(props.visible ?? false);
|
|
21
|
+
const placement = (0, vue.computed)(() => {
|
|
22
|
+
const rtl = menuContext?.value?.rtl;
|
|
23
|
+
const builtinPlacements = menuContext?.value?.builtinPlacements;
|
|
24
|
+
return rtl ? {
|
|
25
|
+
...require_placements.placementsRtl,
|
|
26
|
+
...builtinPlacements
|
|
27
|
+
} : {
|
|
28
|
+
...require_placements.default,
|
|
29
|
+
...builtinPlacements
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
const triggerMode = (0, vue.computed)(() => props.mode);
|
|
33
|
+
const popupPlacement = (0, vue.computed)(() => {
|
|
34
|
+
return popupPlacementMap[triggerMode.value];
|
|
35
|
+
});
|
|
36
|
+
const defaultMotions = (0, vue.computed)(() => menuContext?.value?.defaultMotions);
|
|
37
|
+
const motion = (0, vue.computed)(() => menuContext?.value?.motion);
|
|
38
|
+
const targetMotion = (0, vue.computed)(() => {
|
|
39
|
+
return { ...require_motionUtil.getMotion(triggerMode.value, motion.value, defaultMotions.value) };
|
|
40
|
+
});
|
|
41
|
+
const targetMotionRef = (0, vue.shallowRef)(targetMotion.value);
|
|
42
|
+
(0, vue.watch)(triggerMode, (mode) => {
|
|
43
|
+
if (mode !== "inline") targetMotionRef.value = targetMotion.value;
|
|
44
|
+
}, { immediate: true });
|
|
45
|
+
(0, vue.watch)([motion, defaultMotions], () => {
|
|
46
|
+
if (triggerMode.value !== "inline") targetMotionRef.value = targetMotion.value;
|
|
47
|
+
});
|
|
48
|
+
const mergedMotion = (0, vue.computed)(() => {
|
|
49
|
+
return {
|
|
50
|
+
...targetMotionRef.value,
|
|
51
|
+
appear: true
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
const visibleRef = (0, vue.shallowRef)();
|
|
55
|
+
(0, vue.watch)(() => props.visible, (visible, _, onCleanup) => {
|
|
56
|
+
visibleRef.value = (0, __v_c_util_dist_raf.default)(() => {
|
|
57
|
+
innerVisible.value = visible;
|
|
58
|
+
});
|
|
59
|
+
onCleanup(() => {
|
|
60
|
+
if (visibleRef.value !== void 0) __v_c_util_dist_raf.default.cancel(visibleRef.value);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
return () => {
|
|
64
|
+
const { popupClassName, popup, popupStyle, popupOffset, disabled, onVisibleChange, prefixCls } = props;
|
|
65
|
+
const { rtl, rootClassName, mode, getPopupContainer, triggerSubMenuAction, subMenuCloseDelay, subMenuOpenDelay, forceSubMenuRender } = menuContext?.value ?? {};
|
|
66
|
+
return (0, vue.createVNode)(__v_c_trigger.default, {
|
|
67
|
+
"prefixCls": prefixCls,
|
|
68
|
+
"popupClassName": (0, __v_c_util.clsx)(`${prefixCls}-popup`, { [`${prefixCls}-rtl`]: rtl }, popupClassName, rootClassName),
|
|
69
|
+
"stretch": mode === "horizontal" ? "minWidth" : void 0,
|
|
70
|
+
"getPopupContainer": getPopupContainer,
|
|
71
|
+
"builtinPlacements": placement.value,
|
|
72
|
+
"popupPlacement": popupPlacement.value,
|
|
73
|
+
"popupVisible": innerVisible.value,
|
|
74
|
+
"popup": popup,
|
|
75
|
+
"popupStyle": popupStyle,
|
|
76
|
+
"popupAlign": popupOffset && { offset: popupOffset },
|
|
77
|
+
"action": disabled ? [] : [triggerSubMenuAction],
|
|
78
|
+
"mouseEnterDelay": subMenuOpenDelay,
|
|
79
|
+
"mouseLeaveDelay": subMenuCloseDelay,
|
|
80
|
+
"onOpenChange": onVisibleChange,
|
|
81
|
+
"forceRender": forceSubMenuRender,
|
|
82
|
+
"popupMotion": mergedMotion.value,
|
|
83
|
+
"fresh": true
|
|
84
|
+
}, { default: () => [slots?.default?.()] });
|
|
85
|
+
};
|
|
86
|
+
}, { props: {
|
|
87
|
+
prefixCls: {
|
|
88
|
+
type: String,
|
|
89
|
+
required: true,
|
|
90
|
+
default: void 0
|
|
91
|
+
},
|
|
92
|
+
mode: {
|
|
93
|
+
type: String,
|
|
94
|
+
required: true,
|
|
95
|
+
default: void 0
|
|
96
|
+
},
|
|
97
|
+
visible: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
required: true,
|
|
100
|
+
default: void 0
|
|
101
|
+
},
|
|
102
|
+
popup: {
|
|
103
|
+
type: null,
|
|
104
|
+
required: true,
|
|
105
|
+
default: void 0
|
|
106
|
+
},
|
|
107
|
+
popupStyle: {
|
|
108
|
+
type: null,
|
|
109
|
+
required: false,
|
|
110
|
+
default: void 0
|
|
111
|
+
},
|
|
112
|
+
popupClassName: {
|
|
113
|
+
type: String,
|
|
114
|
+
required: false,
|
|
115
|
+
default: void 0
|
|
116
|
+
},
|
|
117
|
+
popupOffset: {
|
|
118
|
+
type: Array,
|
|
119
|
+
required: false,
|
|
120
|
+
default: void 0
|
|
121
|
+
},
|
|
122
|
+
disabled: {
|
|
123
|
+
type: Boolean,
|
|
124
|
+
required: true,
|
|
125
|
+
default: void 0
|
|
126
|
+
},
|
|
127
|
+
onVisibleChange: {
|
|
128
|
+
type: Function,
|
|
129
|
+
required: true,
|
|
130
|
+
default: void 0
|
|
131
|
+
}
|
|
132
|
+
} });
|
|
133
|
+
var PopupTrigger_default = PopupTrigger;
|
|
134
|
+
exports.default = PopupTrigger_default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { VueNode } from '@v-c/util/dist/type
|
|
1
|
+
import { VueNode } from '@v-c/util/dist/type';
|
|
2
2
|
import { CSSProperties } from 'vue';
|
|
3
|
-
import { MenuMode } from '../interface
|
|
3
|
+
import { MenuMode } from '../interface';
|
|
4
4
|
export interface PopupTriggerProps {
|
|
5
5
|
prefixCls: string;
|
|
6
6
|
mode: MenuMode;
|