@v-c/menu 1.0.12 → 1.0.14
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.js +4 -2
- package/dist/Icon.js +4 -2
- package/dist/Menu.js +25 -8
- package/dist/MenuItem.js +13 -4
- package/dist/MenuItemGroup.js +4 -2
- package/dist/SubMenu/InlineSubMenuList.js +11 -11
- package/dist/SubMenu/PopupTrigger.js +18 -17
- package/dist/SubMenu/SubMenuList.js +4 -2
- package/dist/SubMenu/index.js +17 -15
- package/dist/context/IdContext.js +7 -3
- package/dist/context/MenuContext.js +4 -2
- package/dist/context/PathContext.js +12 -14
- package/dist/context/PrivateContext.js +3 -1
- package/dist/hooks/useAccessibility.js +16 -0
- package/dist/hooks/useActive.js +2 -0
- package/dist/hooks/useDirectionStyle.js +2 -0
- package/dist/hooks/useKeyRecords.js +6 -1
- package/dist/hooks/useMemoCallback.js +5 -0
- package/dist/index.js +13 -12
- package/dist/placements.js +5 -4
- package/dist/utils/commonUtil.js +2 -0
- package/dist/utils/motionUtil.js +2 -0
- package/dist/utils/nodeUtil.js +10 -8
- package/dist/utils/timeUtil.js +2 -0
- package/dist/utils/warnUtil.js +6 -0
- package/package.json +4 -4
package/dist/Divider.js
CHANGED
|
@@ -2,7 +2,8 @@ import { useMenuContext } from "./context/MenuContext.js";
|
|
|
2
2
|
import { useMeasure } from "./context/PathContext.js";
|
|
3
3
|
import { createVNode, defineComponent } from "vue";
|
|
4
4
|
import { clsx } from "@v-c/util";
|
|
5
|
-
|
|
5
|
+
//#region src/Divider.tsx
|
|
6
|
+
var Divider = /* @__PURE__ */ defineComponent((props) => {
|
|
6
7
|
const menuContext = useMenuContext();
|
|
7
8
|
const measure = useMeasure();
|
|
8
9
|
return () => {
|
|
@@ -29,4 +30,5 @@ var Divider_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
29
30
|
},
|
|
30
31
|
name: "Divider"
|
|
31
32
|
});
|
|
32
|
-
|
|
33
|
+
//#endregion
|
|
34
|
+
export { Divider as default };
|
package/dist/Icon.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineComponent } from "vue";
|
|
2
2
|
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
3
|
-
|
|
3
|
+
//#region src/Icon.tsx
|
|
4
|
+
var Icon = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
4
5
|
return () => {
|
|
5
6
|
const { icon, props: iconProps } = props;
|
|
6
7
|
const children = slots.default?.();
|
|
@@ -36,4 +37,5 @@ var Icon_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
36
37
|
default: void 0
|
|
37
38
|
}
|
|
38
39
|
} });
|
|
39
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Icon as default };
|
package/dist/Menu.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import InheritableContextProvider, { useMenuContextProvider } from "./context/MenuContext.js";
|
|
2
2
|
import { MeasureProvider, PathUserProvider } from "./context/PathContext.js";
|
|
3
3
|
import { useIdContextProvide } from "./context/IdContext.js";
|
|
4
4
|
import { PrivateContextProvider } from "./context/PrivateContext.js";
|
|
@@ -6,8 +6,8 @@ import useAccessibility, { getFocusableElements, refreshElements } from "./hooks
|
|
|
6
6
|
import useKeyRecords, { OVERFLOW_KEY } from "./hooks/useKeyRecords.js";
|
|
7
7
|
import useMemoCallback from "./hooks/useMemoCallback.js";
|
|
8
8
|
import { warnItemProp } from "./utils/warnUtil.js";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import MenuItem from "./MenuItem.js";
|
|
10
|
+
import SubMenu from "./SubMenu/index.js";
|
|
11
11
|
import { parseItems } from "./utils/nodeUtil.js";
|
|
12
12
|
import { computed, createVNode, defineComponent, isVNode, mergeDefaults, mergeProps, nextTick, onMounted, onUnmounted, ref, shallowRef, watch } from "vue";
|
|
13
13
|
import { classNames } from "@v-c/util";
|
|
@@ -15,6 +15,19 @@ import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
|
15
15
|
import Overflow from "@v-c/overflow";
|
|
16
16
|
import useId from "@v-c/util/dist/hooks/useId";
|
|
17
17
|
import isEqual from "@v-c/util/dist/isEqual";
|
|
18
|
+
//#region src/Menu.tsx
|
|
19
|
+
/**
|
|
20
|
+
* Menu modify after refactor:
|
|
21
|
+
* ## Add
|
|
22
|
+
* - disabled
|
|
23
|
+
*
|
|
24
|
+
* ## Remove
|
|
25
|
+
* - openTransitionName
|
|
26
|
+
* - openAnimation
|
|
27
|
+
* - onDestroy
|
|
28
|
+
* - siderCollapsed: Seems antd do not use this prop (Need test in antd)
|
|
29
|
+
* - collapsedWidth: Seems this logic should be handle by antd Layout.Sider
|
|
30
|
+
*/
|
|
18
31
|
function _isSlot(s) {
|
|
19
32
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
20
33
|
}
|
|
@@ -30,7 +43,7 @@ var defaults = {
|
|
|
30
43
|
triggerSubMenuAction: "hover",
|
|
31
44
|
overflowedIndicator: "..."
|
|
32
45
|
};
|
|
33
|
-
var
|
|
46
|
+
var Menu = /* @__PURE__ */ defineComponent((props, { slots, expose, attrs: _attrs }) => {
|
|
34
47
|
const containerRef = shallowRef();
|
|
35
48
|
const uuid = useId(props?.id ? `vc-menu-uuid-${props.id}` : "vc-menu-uuid");
|
|
36
49
|
const isRtl = computed(() => props?.direction === "rtl");
|
|
@@ -135,6 +148,9 @@ var Menu_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attr
|
|
|
135
148
|
}
|
|
136
149
|
if (!props.multiple && mergedOpenKeys.value.length && internalMode.value !== "inline") triggerOpenKeys(EMPTY_LIST);
|
|
137
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* Click for item. SubMenu do not have selection status
|
|
153
|
+
*/
|
|
138
154
|
const onInternalClick = (info) => {
|
|
139
155
|
props.onClick?.(warnItemProp(info));
|
|
140
156
|
triggerSelection(info);
|
|
@@ -233,7 +249,7 @@ var Menu_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attr
|
|
|
233
249
|
iconRender: props?.iconRender
|
|
234
250
|
});
|
|
235
251
|
const measureChildList = parseItems(children, props?.items, EMPTY_LIST, {}, props?.prefixCls || defaults.prefixCls);
|
|
236
|
-
const wrappedChildList = internalMode.value !== "horizontal" || props?.disabledOverflow ? childList.value : childList.value.map((child, index) => createVNode(
|
|
252
|
+
const wrappedChildList = internalMode.value !== "horizontal" || props?.disabledOverflow ? childList.value : childList.value.map((child, index) => createVNode(InheritableContextProvider, {
|
|
237
253
|
"key": child.key,
|
|
238
254
|
"overflowDisabled": index > lastVisibleIndex.value,
|
|
239
255
|
"classes": props.classes,
|
|
@@ -243,7 +259,7 @@ var Menu_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attr
|
|
|
243
259
|
"ref": containerRef,
|
|
244
260
|
"prefixCls": `${prefixCls}-overflow`,
|
|
245
261
|
"component": "ul",
|
|
246
|
-
"itemComponent":
|
|
262
|
+
"itemComponent": MenuItem,
|
|
247
263
|
"class": classNames(prefixCls, `${prefixCls}-root`, `${prefixCls}-${internalMode.value}`, _attrs.class || "", {
|
|
248
264
|
[`${prefixCls}-inline-collapsed`]: internalInlineCollapsed.value,
|
|
249
265
|
[`${prefixCls}-rtl`]: isRtl.value
|
|
@@ -261,7 +277,7 @@ var Menu_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attr
|
|
|
261
277
|
"renderRawRest": (omitItems) => {
|
|
262
278
|
const len = omitItems.length;
|
|
263
279
|
const originOmitItems = len ? childList.value.slice(-len) : null;
|
|
264
|
-
return createVNode(
|
|
280
|
+
return createVNode(SubMenu, {
|
|
265
281
|
"eventKey": OVERFLOW_KEY,
|
|
266
282
|
"title": mergedOverflowIndicator.value,
|
|
267
283
|
"disabled": allVisible.value,
|
|
@@ -526,4 +542,5 @@ var Menu_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attr
|
|
|
526
542
|
name: "VcMenu",
|
|
527
543
|
inheritAttrs: false
|
|
528
544
|
});
|
|
529
|
-
|
|
545
|
+
//#endregion
|
|
546
|
+
export { Menu as default };
|
package/dist/MenuItem.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMenuContext } from "./context/MenuContext.js";
|
|
2
2
|
import { useFullPath, useMeasure } from "./context/PathContext.js";
|
|
3
|
-
import
|
|
3
|
+
import Icon from "./Icon.js";
|
|
4
4
|
import { useMenuId } from "./context/IdContext.js";
|
|
5
5
|
import { usePrivateContext } from "./context/PrivateContext.js";
|
|
6
6
|
import useActive from "./hooks/useActive.js";
|
|
@@ -12,6 +12,7 @@ import omit from "@v-c/util/dist/omit";
|
|
|
12
12
|
import { toPropsRefs } from "@v-c/util/dist/props-util";
|
|
13
13
|
import Overflow from "@v-c/overflow";
|
|
14
14
|
import KeyCode from "@v-c/util/dist/KeyCode";
|
|
15
|
+
//#region src/MenuItem.tsx
|
|
15
16
|
var LegacyMenuItem = /* @__PURE__ */ defineComponent((props, { slots, attrs }) => {
|
|
16
17
|
return () => {
|
|
17
18
|
const { title, attribute, ...restProps } = attrs;
|
|
@@ -33,6 +34,9 @@ var LegacyMenuItem = /* @__PURE__ */ defineComponent((props, { slots, attrs }) =
|
|
|
33
34
|
name: "LegacyMenuItem",
|
|
34
35
|
inheritAttrs: false
|
|
35
36
|
});
|
|
37
|
+
/**
|
|
38
|
+
* Real Menu Item component
|
|
39
|
+
*/
|
|
36
40
|
var InternalMenuItem = /* @__PURE__ */ defineComponent((props, { slots, attrs }) => {
|
|
37
41
|
const { eventKey } = toPropsRefs(props, "eventKey");
|
|
38
42
|
const domDataId = useMenuId(eventKey);
|
|
@@ -69,6 +73,10 @@ var InternalMenuItem = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
69
73
|
menuContext?.value?.onItemClick?.(info);
|
|
70
74
|
}
|
|
71
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Used for accessibility. Helper will focus element without key board.
|
|
78
|
+
* We should manually trigger an active
|
|
79
|
+
*/
|
|
72
80
|
const onInternalFocus = (e) => {
|
|
73
81
|
menuContext?.value?.onActive?.(eventKey.value);
|
|
74
82
|
props?.onFocus?.(e);
|
|
@@ -105,7 +113,7 @@ var InternalMenuItem = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
105
113
|
"onClick": onInternalClick,
|
|
106
114
|
"onKeydown": onInternalKeyDown,
|
|
107
115
|
"onFocus": onInternalFocus
|
|
108
|
-
}), { default: () => [slots?.default?.(), createVNode(
|
|
116
|
+
}), { default: () => [slots?.default?.(), createVNode(Icon, {
|
|
109
117
|
"props": {
|
|
110
118
|
...props,
|
|
111
119
|
isSelected: selected.value
|
|
@@ -212,7 +220,7 @@ var InternalMenuItem = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
212
220
|
name: "InternalMenuItem",
|
|
213
221
|
inheritAttrs: false
|
|
214
222
|
});
|
|
215
|
-
var
|
|
223
|
+
var MenuItem = /* @__PURE__ */ defineComponent((props, { slots, attrs }) => {
|
|
216
224
|
const { eventKey } = toPropsRefs(props, "eventKey");
|
|
217
225
|
const measure = useMeasure();
|
|
218
226
|
const connectedKeyPath = useFullPath(eventKey);
|
|
@@ -326,4 +334,5 @@ var MenuItem_default = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
326
334
|
name: "MenuItem",
|
|
327
335
|
inheritAttrs: false
|
|
328
336
|
});
|
|
329
|
-
|
|
337
|
+
//#endregion
|
|
338
|
+
export { MenuItem as default };
|
package/dist/MenuItemGroup.js
CHANGED
|
@@ -5,6 +5,7 @@ import { computed, createVNode, defineComponent, isVNode, mergeProps } from "vue
|
|
|
5
5
|
import { clsx } from "@v-c/util";
|
|
6
6
|
import omit from "@v-c/util/dist/omit";
|
|
7
7
|
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
8
|
+
//#region src/MenuItemGroup.tsx
|
|
8
9
|
function _isSlot(s) {
|
|
9
10
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
10
11
|
}
|
|
@@ -66,7 +67,7 @@ var InternalMenuItemGroup = /* @__PURE__ */ defineComponent((props, { slots }) =
|
|
|
66
67
|
},
|
|
67
68
|
name: "InternalMenuItemGroup"
|
|
68
69
|
});
|
|
69
|
-
var
|
|
70
|
+
var MenuItemGroup = /* @__PURE__ */ defineComponent((props, ctx) => {
|
|
70
71
|
const connectedKeyPath = useFullPath(computed(() => props.eventKey));
|
|
71
72
|
const measure = useMeasure();
|
|
72
73
|
return () => {
|
|
@@ -114,4 +115,5 @@ var MenuItemGroup_default = /* @__PURE__ */ defineComponent((props, ctx) => {
|
|
|
114
115
|
name: "MenuItemGroup",
|
|
115
116
|
inheritAttrs: false
|
|
116
117
|
});
|
|
117
|
-
|
|
118
|
+
//#endregion
|
|
119
|
+
export { MenuItemGroup as default };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import InheritableContextProvider, { useMenuContext } from "../context/MenuContext.js";
|
|
2
2
|
import { getMotion } from "../utils/motionUtil.js";
|
|
3
|
-
import
|
|
4
|
-
import { Transition, computed, createVNode, defineComponent, shallowRef, watch, watchEffect } from "vue";
|
|
3
|
+
import InternalSubMenuList from "./SubMenuList.js";
|
|
4
|
+
import { Transition, computed, createVNode, defineComponent, shallowRef, vShow, watch, watchEffect, withDirectives } from "vue";
|
|
5
5
|
import { getTransitionProps } from "@v-c/util/dist/utils/transition";
|
|
6
|
-
|
|
6
|
+
//#region src/SubMenu/InlineSubMenuList.tsx
|
|
7
|
+
var InlineSubMenuList = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
7
8
|
const fixedMode = "inline";
|
|
8
9
|
const menuContext = useMenuContext();
|
|
9
10
|
const sameModeRef = shallowRef(false);
|
|
@@ -28,10 +29,10 @@ var InlineSubMenuList_default = /* @__PURE__ */ defineComponent((props, { slots
|
|
|
28
29
|
});
|
|
29
30
|
return () => {
|
|
30
31
|
if (destroy.value) return null;
|
|
31
|
-
return createVNode(
|
|
32
|
+
return createVNode(InheritableContextProvider, {
|
|
32
33
|
"mode": fixedMode,
|
|
33
34
|
"locked": !sameModeRef.value
|
|
34
|
-
}, { default: () => [createVNode(Transition, getTransitionProps(mergedMotion.value?.name, mergedMotion.value), { default: () => [
|
|
35
|
+
}, { default: () => [createVNode(Transition, getTransitionProps(mergedMotion.value?.name, mergedMotion.value), { default: () => [withDirectives(createVNode(InternalSubMenuList, { "id": props.id }, { default: () => [slots?.default?.()] }), [[vShow, mergedOpen.value]])] })] });
|
|
35
36
|
};
|
|
36
37
|
}, {
|
|
37
38
|
props: {
|
|
@@ -42,16 +43,15 @@ var InlineSubMenuList_default = /* @__PURE__ */ defineComponent((props, { slots
|
|
|
42
43
|
},
|
|
43
44
|
open: {
|
|
44
45
|
type: Boolean,
|
|
45
|
-
required: true
|
|
46
|
-
default: void 0
|
|
46
|
+
required: true
|
|
47
47
|
},
|
|
48
48
|
keyPath: {
|
|
49
49
|
type: Array,
|
|
50
|
-
required: true
|
|
51
|
-
default: void 0
|
|
50
|
+
required: true
|
|
52
51
|
}
|
|
53
52
|
},
|
|
54
53
|
name: "InlineSubMenuList",
|
|
55
54
|
inheritAttrs: false
|
|
56
55
|
});
|
|
57
|
-
|
|
56
|
+
//#endregion
|
|
57
|
+
export { InlineSubMenuList as default };
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { useMenuContext } from "../context/MenuContext.js";
|
|
2
2
|
import { getMotion } from "../utils/motionUtil.js";
|
|
3
|
-
import
|
|
3
|
+
import placements, { placementsRtl } from "../placements.js";
|
|
4
4
|
import { computed, createVNode, defineComponent, shallowRef, watch } from "vue";
|
|
5
5
|
import { clsx } from "@v-c/util";
|
|
6
6
|
import Trigger from "@v-c/trigger";
|
|
7
7
|
import raf from "@v-c/util/dist/raf";
|
|
8
|
+
//#region src/SubMenu/PopupTrigger.tsx
|
|
8
9
|
var popupPlacementMap = {
|
|
9
10
|
"horizontal": "bottomLeft",
|
|
10
11
|
"vertical": "rightTop",
|
|
11
12
|
"vertical-left": "rightTop",
|
|
12
13
|
"vertical-right": "leftTop"
|
|
13
14
|
};
|
|
14
|
-
var
|
|
15
|
+
var PopupTrigger = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
15
16
|
const menuContext = useMenuContext();
|
|
16
17
|
const innerVisible = shallowRef(props.visible ?? false);
|
|
17
18
|
const placement = computed(() => {
|
|
@@ -21,7 +22,7 @@ var PopupTrigger_default = /* @__PURE__ */ defineComponent((props, { slots }) =>
|
|
|
21
22
|
...placementsRtl,
|
|
22
23
|
...builtinPlacements
|
|
23
24
|
} : {
|
|
24
|
-
...
|
|
25
|
+
...placements,
|
|
25
26
|
...builtinPlacements
|
|
26
27
|
};
|
|
27
28
|
});
|
|
@@ -36,7 +37,12 @@ var PopupTrigger_default = /* @__PURE__ */ defineComponent((props, { slots }) =>
|
|
|
36
37
|
});
|
|
37
38
|
const targetMotionRef = shallowRef(targetMotion.value);
|
|
38
39
|
watch(triggerMode, (mode) => {
|
|
39
|
-
if (mode !== "inline")
|
|
40
|
+
if (mode !== "inline")
|
|
41
|
+
/**
|
|
42
|
+
* PopupTrigger is only used for vertical and horizontal types.
|
|
43
|
+
* When collapsed is unfolded, the inline animation will destroy the vertical animation.
|
|
44
|
+
*/
|
|
45
|
+
targetMotionRef.value = targetMotion.value;
|
|
40
46
|
}, { immediate: true });
|
|
41
47
|
watch([motion, defaultMotions], () => {
|
|
42
48
|
if (triggerMode.value !== "inline") targetMotionRef.value = targetMotion.value;
|
|
@@ -82,18 +88,15 @@ var PopupTrigger_default = /* @__PURE__ */ defineComponent((props, { slots }) =>
|
|
|
82
88
|
}, { props: {
|
|
83
89
|
prefixCls: {
|
|
84
90
|
type: String,
|
|
85
|
-
required: true
|
|
86
|
-
default: void 0
|
|
91
|
+
required: true
|
|
87
92
|
},
|
|
88
93
|
mode: {
|
|
89
94
|
type: String,
|
|
90
|
-
required: true
|
|
91
|
-
default: void 0
|
|
95
|
+
required: true
|
|
92
96
|
},
|
|
93
97
|
visible: {
|
|
94
98
|
type: Boolean,
|
|
95
|
-
required: true
|
|
96
|
-
default: void 0
|
|
99
|
+
required: true
|
|
97
100
|
},
|
|
98
101
|
popup: {
|
|
99
102
|
type: [
|
|
@@ -105,8 +108,7 @@ var PopupTrigger_default = /* @__PURE__ */ defineComponent((props, { slots }) =>
|
|
|
105
108
|
Boolean,
|
|
106
109
|
Array
|
|
107
110
|
],
|
|
108
|
-
required: true
|
|
109
|
-
default: void 0
|
|
111
|
+
required: true
|
|
110
112
|
},
|
|
111
113
|
popupStyle: {
|
|
112
114
|
type: Object,
|
|
@@ -125,13 +127,12 @@ var PopupTrigger_default = /* @__PURE__ */ defineComponent((props, { slots }) =>
|
|
|
125
127
|
},
|
|
126
128
|
disabled: {
|
|
127
129
|
type: Boolean,
|
|
128
|
-
required: true
|
|
129
|
-
default: void 0
|
|
130
|
+
required: true
|
|
130
131
|
},
|
|
131
132
|
onVisibleChange: {
|
|
132
133
|
type: Function,
|
|
133
|
-
required: true
|
|
134
|
-
default: void 0
|
|
134
|
+
required: true
|
|
135
135
|
}
|
|
136
136
|
} });
|
|
137
|
-
|
|
137
|
+
//#endregion
|
|
138
|
+
export { PopupTrigger as default };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useMenuContext } from "../context/MenuContext.js";
|
|
2
2
|
import { createVNode, defineComponent, mergeProps } from "vue";
|
|
3
3
|
import { clsx } from "@v-c/util";
|
|
4
|
-
|
|
4
|
+
//#region src/SubMenu/SubMenuList.tsx
|
|
5
|
+
var InternalSubMenuList = /* @__PURE__ */ defineComponent((_, { attrs, slots }) => {
|
|
5
6
|
const menuContext = useMenuContext();
|
|
6
7
|
return () => {
|
|
7
8
|
const { prefixCls, mode, rtl } = menuContext?.value ?? {};
|
|
@@ -14,4 +15,5 @@ var SubMenuList_default = /* @__PURE__ */ defineComponent((_, { attrs, slots })
|
|
|
14
15
|
name: "InlineSubMenuList",
|
|
15
16
|
inheritAttrs: false
|
|
16
17
|
});
|
|
17
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
export { InternalSubMenuList as default };
|
package/dist/SubMenu/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import InheritableContextProvider, { useMenuContext } from "../context/MenuContext.js";
|
|
2
2
|
import { PathTrackerContext, useFullPath, useMeasure, usePathUserContext } from "../context/PathContext.js";
|
|
3
|
-
import
|
|
3
|
+
import Icon from "../Icon.js";
|
|
4
4
|
import { useMenuId } from "../context/IdContext.js";
|
|
5
5
|
import { usePrivateContext } from "../context/PrivateContext.js";
|
|
6
6
|
import useMemoCallback from "../hooks/useMemoCallback.js";
|
|
@@ -8,13 +8,14 @@ import useActive from "../hooks/useActive.js";
|
|
|
8
8
|
import useDirectionStyle from "../hooks/useDirectionStyle.js";
|
|
9
9
|
import { warnItemProp } from "../utils/warnUtil.js";
|
|
10
10
|
import { parseChildren } from "../utils/commonUtil.js";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
11
|
+
import InternalSubMenuList from "./SubMenuList.js";
|
|
12
|
+
import InlineSubMenuList from "./InlineSubMenuList.js";
|
|
13
|
+
import PopupTrigger from "./PopupTrigger.js";
|
|
14
14
|
import { computed, createVNode, defineComponent, isVNode, mergeProps, ref, watch } from "vue";
|
|
15
15
|
import { classNames } from "@v-c/util";
|
|
16
16
|
import Overflow from "@v-c/overflow";
|
|
17
17
|
import warning$1 from "@v-c/util/dist/warning";
|
|
18
|
+
//#region src/SubMenu/index.tsx
|
|
18
19
|
function _isSlot(s) {
|
|
19
20
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
20
21
|
}
|
|
@@ -34,8 +35,8 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
34
35
|
const selectedKeys = computed(() => menuContext?.value?.selectedKeys || []);
|
|
35
36
|
const contextExpandIcon = computed(() => menuContext?.value?.expandIcon);
|
|
36
37
|
const contextPopupRender = computed(() => menuContext?.value?.popupRender);
|
|
37
|
-
const onOpenChange = (key, open
|
|
38
|
-
menuContext?.value?.onOpenChange?.(key, open
|
|
38
|
+
const onOpenChange = (key, open) => {
|
|
39
|
+
menuContext?.value?.onOpenChange?.(key, open);
|
|
39
40
|
};
|
|
40
41
|
const onActive = (key) => {
|
|
41
42
|
menuContext?.value?.onActive?.(key);
|
|
@@ -119,7 +120,7 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
119
120
|
isSubMenu: true,
|
|
120
121
|
disabled: mergedDisabled.value
|
|
121
122
|
};
|
|
122
|
-
const expandIconNode = createVNode(
|
|
123
|
+
const expandIconNode = createVNode(Icon, {
|
|
123
124
|
"icon": mode.value !== "horizontal" ? mergedExpandIcon.value : void 0,
|
|
124
125
|
"props": {
|
|
125
126
|
...props,
|
|
@@ -142,11 +143,11 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
142
143
|
}, activeProps), [title, expandIconNode]);
|
|
143
144
|
const popupContentTriggerMode = triggerModeRef.value;
|
|
144
145
|
const renderPopupContent = () => {
|
|
145
|
-
const originNode = createVNode(
|
|
146
|
+
const originNode = createVNode(InheritableContextProvider, {
|
|
146
147
|
"classes": classes,
|
|
147
148
|
"styles": styles,
|
|
148
149
|
"mode": popupContentTriggerMode === "horizontal" ? "vertical" : popupContentTriggerMode
|
|
149
|
-
}, { default: () => [createVNode(
|
|
150
|
+
}, { default: () => [createVNode(InternalSubMenuList, { "id": popupId }, _isSlot(children) ? children : { default: () => [children] })] });
|
|
150
151
|
const mergedPopupRender = props?.popupRender || contextPopupRender.value;
|
|
151
152
|
if (mergedPopupRender) return mergedPopupRender(originNode, {
|
|
152
153
|
item: props,
|
|
@@ -159,7 +160,7 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
159
160
|
const _titleNode = function() {
|
|
160
161
|
return titleNode;
|
|
161
162
|
}();
|
|
162
|
-
titleNode = createVNode(
|
|
163
|
+
titleNode = createVNode(PopupTrigger, {
|
|
163
164
|
"mode": triggerMode,
|
|
164
165
|
"prefixCls": subMenuPrefixCls.value,
|
|
165
166
|
"visible": !props?.internalPopupClose && open.value && mode.value !== "inline",
|
|
@@ -182,7 +183,7 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
182
183
|
}),
|
|
183
184
|
"onMouseenter": onInternalMouseEnter,
|
|
184
185
|
"onMouseleave": onInternalMouseLeave
|
|
185
|
-
}), { default: () => [titleNode, !overflowDisabled.value && createVNode(
|
|
186
|
+
}), { default: () => [titleNode, !overflowDisabled.value && createVNode(InlineSubMenuList, {
|
|
186
187
|
"id": popupId,
|
|
187
188
|
"open": open.value,
|
|
188
189
|
"keyPath": validConnectedPath.value
|
|
@@ -193,7 +194,7 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
193
194
|
open: open.value,
|
|
194
195
|
disabled: mergedDisabled.value
|
|
195
196
|
});
|
|
196
|
-
return createVNode(
|
|
197
|
+
return createVNode(InheritableContextProvider, {
|
|
197
198
|
"classes": classes,
|
|
198
199
|
"styles": styles,
|
|
199
200
|
"onItemClick": onMergedItemClick,
|
|
@@ -347,7 +348,7 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
347
348
|
name: "InternalSubMenu",
|
|
348
349
|
inheritAttrs: false
|
|
349
350
|
});
|
|
350
|
-
var
|
|
351
|
+
var SubMenu = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
351
352
|
const eventKey = computed(() => props?.eventKey);
|
|
352
353
|
const connectedKeyPath = useFullPath(eventKey);
|
|
353
354
|
const measure = useMeasure();
|
|
@@ -511,4 +512,5 @@ var SubMenu_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
511
512
|
name: "SubMenu",
|
|
512
513
|
inheritAttrs: false
|
|
513
514
|
});
|
|
514
|
-
|
|
515
|
+
//#endregion
|
|
516
|
+
export { SubMenu as default };
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { computed, defineComponent, inject, provide, ref } from "vue";
|
|
2
|
+
//#region src/context/IdContext.tsx
|
|
2
3
|
var IdContextKey = Symbol("IdContext");
|
|
3
4
|
function useIdContextProvide(id) {
|
|
4
5
|
provide(IdContextKey, id);
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
+
var IdContextProvider = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
7
8
|
useIdContextProvide(computed(() => props.id));
|
|
8
9
|
return () => slots?.default?.();
|
|
9
10
|
}, { props: { id: {
|
|
10
11
|
type: String,
|
|
11
|
-
required: true
|
|
12
|
-
default: void 0
|
|
12
|
+
required: true
|
|
13
13
|
} } });
|
|
14
14
|
function getMenuId(uuid, eventKey) {
|
|
15
15
|
return `${uuid}-${eventKey}`;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Get `data-menu-id`
|
|
19
|
+
*/
|
|
17
20
|
function useMenuId(eventKey) {
|
|
18
21
|
const id = inject(IdContextKey, ref(""));
|
|
19
22
|
return computed(() => getMenuId(id.value, eventKey.value));
|
|
20
23
|
}
|
|
24
|
+
//#endregion
|
|
21
25
|
export { IdContextProvider, getMenuId, useIdContextProvide, useMenuId };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed, defineComponent, inject, provide } from "vue";
|
|
2
2
|
import omit from "@v-c/util/dist/omit";
|
|
3
|
+
//#region src/context/MenuContext.tsx
|
|
3
4
|
var MenuContextKey = Symbol("MenuContextKey");
|
|
4
5
|
function mergeProps$1(origin, target) {
|
|
5
6
|
const clone = { ...origin };
|
|
@@ -15,7 +16,7 @@ function useMenuContext() {
|
|
|
15
16
|
function useMenuContextProvider(context) {
|
|
16
17
|
provide(MenuContextKey, context);
|
|
17
18
|
}
|
|
18
|
-
var
|
|
19
|
+
var InheritableContextProvider = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
19
20
|
const context = useMenuContext();
|
|
20
21
|
useMenuContextProvider(computed(() => {
|
|
21
22
|
return mergeProps$1(context?.value ?? {}, omit(props, ["locked"]));
|
|
@@ -184,4 +185,5 @@ var MenuContext_default = /* @__PURE__ */ defineComponent((props, { slots }) =>
|
|
|
184
185
|
},
|
|
185
186
|
inheritAttrs: false
|
|
186
187
|
});
|
|
187
|
-
|
|
188
|
+
//#endregion
|
|
189
|
+
export { InheritableContextProvider as default, useMenuContext, useMenuContextProvider };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { computed, defineComponent, inject, provide, ref } from "vue";
|
|
2
|
+
//#region src/context/PathContext.tsx
|
|
2
3
|
var EmptyList = [];
|
|
3
4
|
var PathRegisterContextKey = Symbol("PathRegisterContext");
|
|
4
5
|
function useMeasure() {
|
|
@@ -7,7 +8,7 @@ function useMeasure() {
|
|
|
7
8
|
function useMeasureProvider(context) {
|
|
8
9
|
provide(PathRegisterContextKey, context);
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
var MeasureProvider = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
11
12
|
useMeasureProvider(props);
|
|
12
13
|
return () => {
|
|
13
14
|
return slots?.default?.();
|
|
@@ -15,13 +16,11 @@ const MeasureProvider = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
15
16
|
}, { props: {
|
|
16
17
|
registerPath: {
|
|
17
18
|
type: Function,
|
|
18
|
-
required: true
|
|
19
|
-
default: void 0
|
|
19
|
+
required: true
|
|
20
20
|
},
|
|
21
21
|
unregisterPath: {
|
|
22
22
|
type: Function,
|
|
23
|
-
required: true
|
|
24
|
-
default: void 0
|
|
23
|
+
required: true
|
|
25
24
|
}
|
|
26
25
|
} });
|
|
27
26
|
var PathTrackerContextKey = Symbol("PathTrackerContext");
|
|
@@ -31,15 +30,14 @@ function useFullPath(eventKey) {
|
|
|
31
30
|
return eventKey !== void 0 ? [...parentKeyPath.value, eventKey.value] : parentKeyPath.value;
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
|
-
|
|
33
|
+
var PathTrackerProvider = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
35
34
|
provide(PathTrackerContextKey, computed(() => props.value));
|
|
36
35
|
return () => {
|
|
37
36
|
return slots?.default?.();
|
|
38
37
|
};
|
|
39
38
|
}, { props: { value: {
|
|
40
39
|
type: Array,
|
|
41
|
-
required: true
|
|
42
|
-
default: void 0
|
|
40
|
+
required: true
|
|
43
41
|
} } });
|
|
44
42
|
var PathUserContextKey = Symbol("PathUserContext");
|
|
45
43
|
function usePathUserContextProvider(context) {
|
|
@@ -48,17 +46,17 @@ function usePathUserContextProvider(context) {
|
|
|
48
46
|
function usePathUserContext() {
|
|
49
47
|
return inject(PathUserContextKey, { isSubPathKey: () => false });
|
|
50
48
|
}
|
|
51
|
-
|
|
49
|
+
var PathUserProvider = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
52
50
|
usePathUserContextProvider(props);
|
|
53
51
|
return () => {
|
|
54
52
|
return slots?.default?.();
|
|
55
53
|
};
|
|
56
54
|
}, { props: { isSubPathKey: {
|
|
57
55
|
type: Function,
|
|
58
|
-
required: true
|
|
59
|
-
default: void 0
|
|
56
|
+
required: true
|
|
60
57
|
} } });
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
var PathTrackerContext = { Provider: PathTrackerProvider };
|
|
59
|
+
var PathRegisterContext = { Provider: MeasureProvider };
|
|
60
|
+
var PathUserContext = { Provider: PathUserProvider };
|
|
61
|
+
//#endregion
|
|
64
62
|
export { MeasureProvider, PathRegisterContext, PathTrackerContext, PathTrackerProvider, PathUserContext, PathUserProvider, useFullPath, useMeasure, useMeasureProvider, usePathUserContext, usePathUserContextProvider };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineComponent, inject, provide } from "vue";
|
|
2
|
+
//#region src/context/PrivateContext.ts
|
|
2
3
|
var PrivateContextKey = Symbol("PrivateContext");
|
|
3
4
|
function usePrivateProvider(context) {
|
|
4
5
|
provide(PrivateContextKey, context);
|
|
@@ -6,10 +7,11 @@ function usePrivateProvider(context) {
|
|
|
6
7
|
function usePrivateContext() {
|
|
7
8
|
return inject(PrivateContextKey, {});
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
var PrivateContextProvider = defineComponent((props, { slots }) => {
|
|
10
11
|
usePrivateProvider(props);
|
|
11
12
|
return () => {
|
|
12
13
|
return slots?.default?.();
|
|
13
14
|
};
|
|
14
15
|
}, { props: ["_internalRenderMenuItem", "_internalRenderSubMenuItem"] });
|
|
16
|
+
//#endregion
|
|
15
17
|
export { PrivateContextProvider, usePrivateContext, usePrivateProvider };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getMenuId } from "../context/IdContext.js";
|
|
2
2
|
import { onBeforeUnmount, shallowRef } from "vue";
|
|
3
3
|
import KeyCode from "@v-c/util/dist/KeyCode";
|
|
4
|
+
//#region src/hooks/useAccessibility.ts
|
|
4
5
|
var { LEFT, RIGHT, UP, DOWN, ENTER, ESC, HOME, END } = KeyCode;
|
|
5
6
|
var ArrowKeys = [
|
|
6
7
|
UP,
|
|
@@ -67,10 +68,16 @@ function findContainerUL(element) {
|
|
|
67
68
|
}
|
|
68
69
|
return null;
|
|
69
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Get focusable node list from container
|
|
73
|
+
*/
|
|
70
74
|
function getFocusNodeList(container, includeDisabled) {
|
|
71
75
|
const selector = includeDisabled ? "[tabindex]" : "[tabindex]:not([tabindex=\"-1\"]):not([disabled]):not([aria-disabled=\"true\"])";
|
|
72
76
|
return Array.from(container.querySelectorAll(selector));
|
|
73
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Find focused element within element set provided
|
|
80
|
+
*/
|
|
74
81
|
function getFocusElement(activeElement, elements) {
|
|
75
82
|
let current = activeElement || document.activeElement;
|
|
76
83
|
while (current) {
|
|
@@ -79,6 +86,9 @@ function getFocusElement(activeElement, elements) {
|
|
|
79
86
|
}
|
|
80
87
|
return null;
|
|
81
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Get focusable elements from the element set under provided container
|
|
91
|
+
*/
|
|
82
92
|
function getFocusableElements(container, elements) {
|
|
83
93
|
if (!container) return [];
|
|
84
94
|
return getFocusNodeList(container, true).filter((ele) => elements.has(ele));
|
|
@@ -146,6 +156,11 @@ function useAccessibility(mode, activeKey, isRtl, id, containerRef, getKeys, get
|
|
|
146
156
|
if (link?.getAttribute("href")) focusTargetElement = link;
|
|
147
157
|
const targetKey = element2key.get(menuElement);
|
|
148
158
|
if (targetKey) triggerActiveKey(targetKey);
|
|
159
|
+
/**
|
|
160
|
+
* Do not use immediate here since `tryFocus` may trigger async
|
|
161
|
+
* which makes Vue sync update the `activeKey`
|
|
162
|
+
* that force render before `ref` set the next activeKey
|
|
163
|
+
*/
|
|
149
164
|
cleanRaf();
|
|
150
165
|
rafRef.value = requestAnimationFrame(() => {
|
|
151
166
|
if (activeRef.value === targetKey) focusTargetElement.focus();
|
|
@@ -182,4 +197,5 @@ function useAccessibility(mode, activeKey, isRtl, id, containerRef, getKeys, get
|
|
|
182
197
|
originOnKeyDown?.(e);
|
|
183
198
|
};
|
|
184
199
|
}
|
|
200
|
+
//#endregion
|
|
185
201
|
export { useAccessibility as default, getFocusableElements, refreshElements };
|
package/dist/hooks/useActive.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMenuContext } from "../context/MenuContext.js";
|
|
2
2
|
import { computed, watchEffect } from "vue";
|
|
3
|
+
//#region src/hooks/useActive.ts
|
|
3
4
|
function useActive(eventKey, disabled, onMouseEnter, onMouseLeave) {
|
|
4
5
|
const menuContext = useMenuContext();
|
|
5
6
|
const ret = { active: computed(() => menuContext?.value?.activeKey === eventKey.value) };
|
|
@@ -23,4 +24,5 @@ function useActive(eventKey, disabled, onMouseEnter, onMouseLeave) {
|
|
|
23
24
|
});
|
|
24
25
|
return ret;
|
|
25
26
|
}
|
|
27
|
+
//#endregion
|
|
26
28
|
export { useActive as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMenuContext } from "../context/MenuContext.js";
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
+
//#region src/hooks/useDirectionStyle.ts
|
|
3
4
|
function useDirectionStyle(level) {
|
|
4
5
|
const menuContext = useMenuContext();
|
|
5
6
|
return computed(() => {
|
|
@@ -9,4 +10,5 @@ function useDirectionStyle(level) {
|
|
|
9
10
|
return rtl ? { paddingRight: `${len * inlineIndent}px` } : { paddingLeft: `${len * inlineIndent}px` };
|
|
10
11
|
});
|
|
11
12
|
}
|
|
13
|
+
//#endregion
|
|
12
14
|
export { useDirectionStyle as default };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { nextSlice } from "../utils/timeUtil.js";
|
|
2
2
|
import { onBeforeUnmount, ref, shallowRef, triggerRef } from "vue";
|
|
3
|
+
//#region src/hooks/useKeyRecords.ts
|
|
3
4
|
var PATH_SPLIT = "__VC_UTIL_PATH_SPLIT__";
|
|
4
5
|
var getPathStr = (keyPath) => keyPath.join(PATH_SPLIT);
|
|
5
6
|
var getPathKeys = (keyPathStr) => keyPathStr.split(PATH_SPLIT);
|
|
6
|
-
|
|
7
|
+
var OVERFLOW_KEY = "vc-menu-more";
|
|
7
8
|
function useKeyRecords() {
|
|
8
9
|
const key2pathRef = shallowRef(/* @__PURE__ */ new Map());
|
|
9
10
|
const path2keyRef = shallowRef(/* @__PURE__ */ new Map());
|
|
@@ -51,6 +52,9 @@ function useKeyRecords() {
|
|
|
51
52
|
if (overflowKeys.value.length) keys.push(OVERFLOW_KEY);
|
|
52
53
|
return keys;
|
|
53
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Find current key related child path keys
|
|
57
|
+
*/
|
|
54
58
|
const getSubPathKeys = (key) => {
|
|
55
59
|
const connectedPath = `${key2pathRef.value.get(key)}${PATH_SPLIT}`;
|
|
56
60
|
const pathKeys = /* @__PURE__ */ new Set();
|
|
@@ -72,4 +76,5 @@ function useKeyRecords() {
|
|
|
72
76
|
getSubPathKeys
|
|
73
77
|
};
|
|
74
78
|
}
|
|
79
|
+
//#endregion
|
|
75
80
|
export { OVERFLOW_KEY, useKeyRecords as default };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ref } from "vue";
|
|
2
|
+
//#region src/hooks/useMemoCallback.ts
|
|
3
|
+
/**
|
|
4
|
+
* Memoize a callback function to keep reference stable
|
|
5
|
+
*/
|
|
2
6
|
function useMemoCallback(callback) {
|
|
3
7
|
const fnRef = ref(callback);
|
|
4
8
|
fnRef.value = callback;
|
|
@@ -7,4 +11,5 @@ function useMemoCallback(callback) {
|
|
|
7
11
|
});
|
|
8
12
|
return memoFn;
|
|
9
13
|
}
|
|
14
|
+
//#endregion
|
|
10
15
|
export { useMemoCallback as default };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { useFullPath } from "./context/PathContext.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
ExportMenu
|
|
9
|
-
ExportMenu.
|
|
10
|
-
ExportMenu.
|
|
11
|
-
ExportMenu.
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import Divider from "./Divider.js";
|
|
3
|
+
import MenuItem from "./MenuItem.js";
|
|
4
|
+
import SubMenu from "./SubMenu/index.js";
|
|
5
|
+
import MenuItemGroup from "./MenuItemGroup.js";
|
|
6
|
+
import Menu from "./Menu.js";
|
|
7
|
+
//#region src/index.ts
|
|
8
|
+
var ExportMenu = Menu;
|
|
9
|
+
ExportMenu.Item = MenuItem;
|
|
10
|
+
ExportMenu.SubMenu = SubMenu;
|
|
11
|
+
ExportMenu.ItemGroup = MenuItemGroup;
|
|
12
|
+
ExportMenu.Divider = Divider;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { Divider, MenuItem as Item, MenuItem, MenuItemGroup as ItemGroup, MenuItemGroup, SubMenu, ExportMenu as default, useFullPath };
|
package/dist/placements.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
//#region src/placements.ts
|
|
1
2
|
var autoAdjustOverflow = {
|
|
2
3
|
adjustX: 1,
|
|
3
4
|
adjustY: 1
|
|
4
5
|
};
|
|
5
|
-
|
|
6
|
+
var placements = {
|
|
6
7
|
topLeft: {
|
|
7
8
|
points: ["bl", "tl"],
|
|
8
9
|
overflow: autoAdjustOverflow
|
|
@@ -36,7 +37,7 @@ const placements = {
|
|
|
36
37
|
overflow: autoAdjustOverflow
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
|
-
|
|
40
|
+
var placementsRtl = {
|
|
40
41
|
topLeft: {
|
|
41
42
|
points: ["bl", "tl"],
|
|
42
43
|
overflow: autoAdjustOverflow
|
|
@@ -70,5 +71,5 @@ const placementsRtl = {
|
|
|
70
71
|
overflow: autoAdjustOverflow
|
|
71
72
|
}
|
|
72
73
|
};
|
|
73
|
-
|
|
74
|
-
export {
|
|
74
|
+
//#endregion
|
|
75
|
+
export { placements as default, placements, placementsRtl };
|
package/dist/utils/commonUtil.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cloneVNode, isVNode } from "vue";
|
|
2
2
|
import { toArray } from "@v-c/util/dist/Children/toArray";
|
|
3
|
+
//#region src/utils/commonUtil.ts
|
|
3
4
|
function parseChildren(children, keyPath) {
|
|
4
5
|
return toArray(children).map((child, index) => {
|
|
5
6
|
if (isVNode(child)) {
|
|
@@ -17,4 +18,5 @@ function parseChildren(children, keyPath) {
|
|
|
17
18
|
return child;
|
|
18
19
|
});
|
|
19
20
|
}
|
|
21
|
+
//#endregion
|
|
20
22
|
export { parseChildren };
|
package/dist/utils/motionUtil.js
CHANGED
package/dist/utils/nodeUtil.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import Divider from "../Divider.js";
|
|
2
|
+
import MenuItem from "../MenuItem.js";
|
|
3
3
|
import { parseChildren } from "./commonUtil.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import SubMenu from "../SubMenu/index.js";
|
|
5
|
+
import MenuItemGroup from "../MenuItemGroup.js";
|
|
6
6
|
import { createVNode, isVNode, mergeProps } from "vue";
|
|
7
7
|
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
8
|
+
//#region src/utils/nodeUtil.tsx
|
|
8
9
|
function _isSlot(s) {
|
|
9
10
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
10
11
|
}
|
|
@@ -55,13 +56,14 @@ function convertItemsToNodes(list, components, prefixCls, slots) {
|
|
|
55
56
|
function parseItems(children, items, keyPath, components, prefixCls, slots) {
|
|
56
57
|
let childNodes = children;
|
|
57
58
|
const mergedComponents = {
|
|
58
|
-
divider:
|
|
59
|
-
item:
|
|
60
|
-
group:
|
|
61
|
-
submenu:
|
|
59
|
+
divider: Divider,
|
|
60
|
+
item: MenuItem,
|
|
61
|
+
group: MenuItemGroup,
|
|
62
|
+
submenu: SubMenu,
|
|
62
63
|
...components
|
|
63
64
|
};
|
|
64
65
|
if (items) childNodes = convertItemsToNodes(items, mergedComponents, prefixCls, slots);
|
|
65
66
|
return parseChildren(childNodes, keyPath);
|
|
66
67
|
}
|
|
68
|
+
//#endregion
|
|
67
69
|
export { parseItems };
|
package/dist/utils/timeUtil.js
CHANGED
package/dist/utils/warnUtil.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { warning } from "@v-c/util";
|
|
2
|
+
//#region src/utils/warnUtil.ts
|
|
3
|
+
/**
|
|
4
|
+
* `onClick` event return `info.item` which point to react node directly.
|
|
5
|
+
* We should warning this since it will not work on FC.
|
|
6
|
+
*/
|
|
2
7
|
function warnItemProp({ item, ...restInfo }) {
|
|
3
8
|
Object.defineProperty(restInfo, "item", { get: () => {
|
|
4
9
|
warning(false, "`info.item` is deprecated since we will move to function component that not provides React Node instance in future.");
|
|
@@ -6,4 +11,5 @@ function warnItemProp({ item, ...restInfo }) {
|
|
|
6
11
|
} });
|
|
7
12
|
return restInfo;
|
|
8
13
|
}
|
|
14
|
+
//#endregion
|
|
9
15
|
export { warnItemProp };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/menu",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.14",
|
|
5
5
|
"description": "menu ui component for vue",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"vue": "^3.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@v-c/overflow": "^1.0.
|
|
29
|
-
"@v-c/
|
|
30
|
-
"@v-c/
|
|
28
|
+
"@v-c/overflow": "^1.0.5",
|
|
29
|
+
"@v-c/util": "^1.0.19",
|
|
30
|
+
"@v-c/trigger": "^1.0.14"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "vite build",
|