@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
package/dist/placements.js
CHANGED
|
@@ -1,77 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var autoAdjustOverflow = {
|
|
2
|
+
adjustX: 1,
|
|
3
|
+
adjustY: 1
|
|
4
4
|
};
|
|
5
5
|
const placements = {
|
|
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
|
-
|
|
6
|
+
topLeft: {
|
|
7
|
+
points: ["bl", "tl"],
|
|
8
|
+
overflow: autoAdjustOverflow
|
|
9
|
+
},
|
|
10
|
+
topRight: {
|
|
11
|
+
points: ["br", "tr"],
|
|
12
|
+
overflow: autoAdjustOverflow
|
|
13
|
+
},
|
|
14
|
+
bottomLeft: {
|
|
15
|
+
points: ["tl", "bl"],
|
|
16
|
+
overflow: autoAdjustOverflow
|
|
17
|
+
},
|
|
18
|
+
bottomRight: {
|
|
19
|
+
points: ["tr", "br"],
|
|
20
|
+
overflow: autoAdjustOverflow
|
|
21
|
+
},
|
|
22
|
+
leftTop: {
|
|
23
|
+
points: ["tr", "tl"],
|
|
24
|
+
overflow: autoAdjustOverflow
|
|
25
|
+
},
|
|
26
|
+
leftBottom: {
|
|
27
|
+
points: ["br", "bl"],
|
|
28
|
+
overflow: autoAdjustOverflow
|
|
29
|
+
},
|
|
30
|
+
rightTop: {
|
|
31
|
+
points: ["tl", "tr"],
|
|
32
|
+
overflow: autoAdjustOverflow
|
|
33
|
+
},
|
|
34
|
+
rightBottom: {
|
|
35
|
+
points: ["bl", "br"],
|
|
36
|
+
overflow: autoAdjustOverflow
|
|
37
|
+
}
|
|
38
38
|
};
|
|
39
39
|
const placementsRtl = {
|
|
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
|
-
export {
|
|
74
|
-
placements as default,
|
|
75
|
-
placements,
|
|
76
|
-
placementsRtl
|
|
40
|
+
topLeft: {
|
|
41
|
+
points: ["bl", "tl"],
|
|
42
|
+
overflow: autoAdjustOverflow
|
|
43
|
+
},
|
|
44
|
+
topRight: {
|
|
45
|
+
points: ["br", "tr"],
|
|
46
|
+
overflow: autoAdjustOverflow
|
|
47
|
+
},
|
|
48
|
+
bottomLeft: {
|
|
49
|
+
points: ["tl", "bl"],
|
|
50
|
+
overflow: autoAdjustOverflow
|
|
51
|
+
},
|
|
52
|
+
bottomRight: {
|
|
53
|
+
points: ["tr", "br"],
|
|
54
|
+
overflow: autoAdjustOverflow
|
|
55
|
+
},
|
|
56
|
+
rightTop: {
|
|
57
|
+
points: ["tr", "tl"],
|
|
58
|
+
overflow: autoAdjustOverflow
|
|
59
|
+
},
|
|
60
|
+
rightBottom: {
|
|
61
|
+
points: ["br", "bl"],
|
|
62
|
+
overflow: autoAdjustOverflow
|
|
63
|
+
},
|
|
64
|
+
leftTop: {
|
|
65
|
+
points: ["tl", "tr"],
|
|
66
|
+
overflow: autoAdjustOverflow
|
|
67
|
+
},
|
|
68
|
+
leftBottom: {
|
|
69
|
+
points: ["bl", "br"],
|
|
70
|
+
overflow: autoAdjustOverflow
|
|
71
|
+
}
|
|
77
72
|
};
|
|
73
|
+
var placements_default = placements;
|
|
74
|
+
export { placements_default as default, placements, placementsRtl };
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const vue = require("vue");
|
|
1
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
2
|
+
let vue = require("vue");
|
|
3
|
+
let __v_c_util_dist_Children_toArray = require("@v-c/util/dist/Children/toArray");
|
|
5
4
|
function parseChildren(children, keyPath) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
5
|
+
return (0, __v_c_util_dist_Children_toArray.toArray)(children).map((child, index) => {
|
|
6
|
+
if ((0, vue.isVNode)(child)) {
|
|
7
|
+
const key = child.key;
|
|
8
|
+
let eventKey = child.props?.eventKey ?? key;
|
|
9
|
+
const emptyKey = eventKey === null || eventKey === void 0;
|
|
10
|
+
if (emptyKey) eventKey = `tmp_key-${[...keyPath, index].join("-")}`;
|
|
11
|
+
const cloneProps = {
|
|
12
|
+
key: eventKey,
|
|
13
|
+
eventKey
|
|
14
|
+
};
|
|
15
|
+
if (process.env.NODE_ENV !== "production" && emptyKey) cloneProps.warnKey = true;
|
|
16
|
+
return {
|
|
17
|
+
...child,
|
|
18
|
+
props: {
|
|
19
|
+
...child.props,
|
|
20
|
+
...cloneProps
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return child;
|
|
25
|
+
});
|
|
28
26
|
}
|
|
29
27
|
exports.parseChildren = parseChildren;
|
package/dist/utils/commonUtil.js
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import { toArray } from "@v-c/util/dist/Children/toArray";
|
|
2
1
|
import { isVNode } from "vue";
|
|
2
|
+
import { toArray } from "@v-c/util/dist/Children/toArray";
|
|
3
3
|
function parseChildren(children, keyPath) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
4
|
+
return toArray(children).map((child, index) => {
|
|
5
|
+
if (isVNode(child)) {
|
|
6
|
+
const key = child.key;
|
|
7
|
+
let eventKey = child.props?.eventKey ?? key;
|
|
8
|
+
const emptyKey = eventKey === null || eventKey === void 0;
|
|
9
|
+
if (emptyKey) eventKey = `tmp_key-${[...keyPath, index].join("-")}`;
|
|
10
|
+
const cloneProps = {
|
|
11
|
+
key: eventKey,
|
|
12
|
+
eventKey
|
|
13
|
+
};
|
|
14
|
+
if (process.env.NODE_ENV !== "production" && emptyKey) cloneProps.warnKey = true;
|
|
15
|
+
return {
|
|
16
|
+
...child,
|
|
17
|
+
props: {
|
|
18
|
+
...child.props,
|
|
19
|
+
...cloneProps
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return child;
|
|
24
|
+
});
|
|
26
25
|
}
|
|
27
|
-
export {
|
|
28
|
-
parseChildren
|
|
29
|
-
};
|
|
26
|
+
export { parseChildren };
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
1
|
function getMotion(mode, motion, defaultMotions) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
if (defaultMotions) {
|
|
8
|
-
return defaultMotions?.[mode] || defaultMotions?.other;
|
|
9
|
-
}
|
|
10
|
-
return void 0;
|
|
2
|
+
if (motion) return motion;
|
|
3
|
+
if (defaultMotions) return defaultMotions?.[mode] || defaultMotions?.other;
|
|
11
4
|
}
|
|
12
5
|
exports.getMotion = getMotion;
|
package/dist/utils/motionUtil.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
function getMotion(mode, motion, defaultMotions) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
if (defaultMotions) {
|
|
6
|
-
return defaultMotions?.[mode] || defaultMotions?.other;
|
|
7
|
-
}
|
|
8
|
-
return void 0;
|
|
2
|
+
if (motion) return motion;
|
|
3
|
+
if (defaultMotions) return defaultMotions?.[mode] || defaultMotions?.other;
|
|
9
4
|
}
|
|
10
|
-
export {
|
|
11
|
-
getMotion
|
|
12
|
-
};
|
|
5
|
+
export { getMotion };
|
package/dist/utils/nodeUtil.cjs
CHANGED
|
@@ -1,82 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
2
|
+
const require_Divider = require("../Divider.cjs");
|
|
3
|
+
const require_MenuItem = require("../MenuItem.cjs");
|
|
4
|
+
const require_commonUtil = require("./commonUtil.cjs");
|
|
5
|
+
const require_index = require("../SubMenu/index.cjs");
|
|
6
|
+
const require_MenuItemGroup = require("../MenuItemGroup.cjs");
|
|
7
|
+
let vue = require("vue");
|
|
8
|
+
let __v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
9
9
|
function _isSlot(s) {
|
|
10
|
-
|
|
10
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
|
|
11
11
|
}
|
|
12
|
-
function convertItemsToNodes(list, components, prefixCls) {
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
return vue.createVNode(MergedSubMenu, vue.mergeProps({
|
|
43
|
-
"key": mergedKey
|
|
44
|
-
}, restProps, {
|
|
45
|
-
"title": label
|
|
46
|
-
}), _isSlot(_slot2 = convertItemsToNodes(children, components, prefixCls)) ? _slot2 : {
|
|
47
|
-
default: () => [_slot2]
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (type === "divider") {
|
|
51
|
-
return vue.createVNode(MergedDivider, vue.mergeProps({
|
|
52
|
-
"key": mergedKey
|
|
53
|
-
}, restProps), null);
|
|
54
|
-
}
|
|
55
|
-
return vue.createVNode(MergedMenuItem, vue.mergeProps({
|
|
56
|
-
"key": mergedKey
|
|
57
|
-
}, restProps, {
|
|
58
|
-
"extra": extra
|
|
59
|
-
}), {
|
|
60
|
-
default: () => [label, (!!extra || extra === 0) && vue.createVNode("span", {
|
|
61
|
-
"class": `${prefixCls}-item-extra`
|
|
62
|
-
}, [extra])]
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}).filter((opt) => opt);
|
|
12
|
+
function convertItemsToNodes(list, components, prefixCls, slots) {
|
|
13
|
+
const { item: MergedMenuItem, group: MergedMenuItemGroup, submenu: MergedSubMenu, divider: MergedDivider } = components;
|
|
14
|
+
return (list || []).map((opt, index) => {
|
|
15
|
+
if (opt && typeof opt === "object") {
|
|
16
|
+
const { children, key, type,...restProps } = opt;
|
|
17
|
+
const mergedKey = key ?? `tmp-${index}`;
|
|
18
|
+
let label;
|
|
19
|
+
let extra;
|
|
20
|
+
const _labelRender = slots?.labelRender ? slots.labelRender(opt) : null;
|
|
21
|
+
const _extraRender = slots?.extraRender ? slots.extraRender(opt) : null;
|
|
22
|
+
const labelArr = (0, __v_c_util_dist_props_util.filterEmpty)(Array.isArray(_labelRender) ? _labelRender : [_labelRender]);
|
|
23
|
+
const extraArr = (0, __v_c_util_dist_props_util.filterEmpty)(Array.isArray(_extraRender) ? _extraRender : [_extraRender]);
|
|
24
|
+
if (labelArr.length) label = labelArr?.[0];
|
|
25
|
+
if (extraArr.length) extra = extraArr?.[0];
|
|
26
|
+
if (!label) label = opt.label;
|
|
27
|
+
if (!extra) extra = opt.extra;
|
|
28
|
+
if (children || type === "group") {
|
|
29
|
+
let _slot2;
|
|
30
|
+
if (type === "group") {
|
|
31
|
+
let _slot;
|
|
32
|
+
return (0, vue.createVNode)(MergedMenuItemGroup, (0, vue.mergeProps)({ "key": mergedKey }, restProps, { "title": label }), _isSlot(_slot = convertItemsToNodes(children, components, prefixCls)) ? _slot : { default: () => [_slot] });
|
|
33
|
+
}
|
|
34
|
+
return (0, vue.createVNode)(MergedSubMenu, (0, vue.mergeProps)({ "key": mergedKey }, restProps, { "title": label }), _isSlot(_slot2 = convertItemsToNodes(children, components, prefixCls)) ? _slot2 : { default: () => [_slot2] });
|
|
35
|
+
}
|
|
36
|
+
if (type === "divider") return (0, vue.createVNode)(MergedDivider, (0, vue.mergeProps)({ "key": mergedKey }, restProps), null);
|
|
37
|
+
return (0, vue.createVNode)(MergedMenuItem, (0, vue.mergeProps)({ "key": mergedKey }, restProps, { "extra": extra }), { default: () => [label, (!!extra || extra === 0) && (0, vue.createVNode)("span", { "class": `${prefixCls}-item-extra` }, [extra])] });
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}).filter((opt) => opt);
|
|
67
41
|
}
|
|
68
|
-
function parseItems(children, items, keyPath, components, prefixCls) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
return commonUtil.parseChildren(childNodes, keyPath);
|
|
42
|
+
function parseItems(children, items, keyPath, components, prefixCls, slots) {
|
|
43
|
+
let childNodes = children;
|
|
44
|
+
const mergedComponents = {
|
|
45
|
+
divider: require_Divider.default,
|
|
46
|
+
item: require_MenuItem.default,
|
|
47
|
+
group: require_MenuItemGroup.default,
|
|
48
|
+
submenu: require_index.default,
|
|
49
|
+
...components
|
|
50
|
+
};
|
|
51
|
+
if (items) childNodes = convertItemsToNodes(items, mergedComponents, prefixCls, slots);
|
|
52
|
+
return require_commonUtil.parseChildren(childNodes, keyPath);
|
|
81
53
|
}
|
|
82
54
|
exports.parseItems = parseItems;
|
package/dist/utils/nodeUtil.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { VueNode } from '@v-c/util/dist/type';
|
|
2
2
|
import { Components, ItemType } from '../interface';
|
|
3
|
-
export declare function parseItems(children: VueNode | undefined, items: ItemType[] | undefined, keyPath: string[], components: Components, prefixCls?: string
|
|
3
|
+
export declare function parseItems(children: VueNode | undefined, items: ItemType[] | undefined, keyPath: string[], components: Components, prefixCls?: string, slots?: {
|
|
4
|
+
labelRender?: (item: ItemType) => any;
|
|
5
|
+
extraRender?: (item: ItemType) => any;
|
|
6
|
+
}): any[];
|
package/dist/utils/nodeUtil.js
CHANGED
|
@@ -1,82 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import MenuItem from "../MenuItem.js";
|
|
4
|
-
import MenuItemGroup from "../MenuItemGroup.js";
|
|
5
|
-
import SubMenu from "../SubMenu/index.js";
|
|
1
|
+
import Divider_default from "../Divider.js";
|
|
2
|
+
import MenuItem_default from "../MenuItem.js";
|
|
6
3
|
import { parseChildren } from "./commonUtil.js";
|
|
4
|
+
import SubMenu_default from "../SubMenu/index.js";
|
|
5
|
+
import MenuItemGroup_default from "../MenuItemGroup.js";
|
|
6
|
+
import { createVNode, isVNode, mergeProps } from "vue";
|
|
7
|
+
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
7
8
|
function _isSlot(s) {
|
|
8
|
-
|
|
9
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
9
10
|
}
|
|
10
|
-
function convertItemsToNodes(list, components, prefixCls) {
|
|
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
|
-
|
|
39
|
-
}
|
|
40
|
-
return createVNode(MergedSubMenu, mergeProps({
|
|
41
|
-
"key": mergedKey
|
|
42
|
-
}, restProps, {
|
|
43
|
-
"title": label
|
|
44
|
-
}), _isSlot(_slot2 = convertItemsToNodes(children, components, prefixCls)) ? _slot2 : {
|
|
45
|
-
default: () => [_slot2]
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (type === "divider") {
|
|
49
|
-
return createVNode(MergedDivider, mergeProps({
|
|
50
|
-
"key": mergedKey
|
|
51
|
-
}, restProps), null);
|
|
52
|
-
}
|
|
53
|
-
return createVNode(MergedMenuItem, mergeProps({
|
|
54
|
-
"key": mergedKey
|
|
55
|
-
}, restProps, {
|
|
56
|
-
"extra": extra
|
|
57
|
-
}), {
|
|
58
|
-
default: () => [label, (!!extra || extra === 0) && createVNode("span", {
|
|
59
|
-
"class": `${prefixCls}-item-extra`
|
|
60
|
-
}, [extra])]
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return null;
|
|
64
|
-
}).filter((opt) => opt);
|
|
11
|
+
function convertItemsToNodes(list, components, prefixCls, slots) {
|
|
12
|
+
const { item: MergedMenuItem, group: MergedMenuItemGroup, submenu: MergedSubMenu, divider: MergedDivider } = components;
|
|
13
|
+
return (list || []).map((opt, index) => {
|
|
14
|
+
if (opt && typeof opt === "object") {
|
|
15
|
+
const { children, key, type,...restProps } = opt;
|
|
16
|
+
const mergedKey = key ?? `tmp-${index}`;
|
|
17
|
+
let label;
|
|
18
|
+
let extra;
|
|
19
|
+
const _labelRender = slots?.labelRender ? slots.labelRender(opt) : null;
|
|
20
|
+
const _extraRender = slots?.extraRender ? slots.extraRender(opt) : null;
|
|
21
|
+
const labelArr = filterEmpty(Array.isArray(_labelRender) ? _labelRender : [_labelRender]);
|
|
22
|
+
const extraArr = filterEmpty(Array.isArray(_extraRender) ? _extraRender : [_extraRender]);
|
|
23
|
+
if (labelArr.length) label = labelArr?.[0];
|
|
24
|
+
if (extraArr.length) extra = extraArr?.[0];
|
|
25
|
+
if (!label) label = opt.label;
|
|
26
|
+
if (!extra) extra = opt.extra;
|
|
27
|
+
if (children || type === "group") {
|
|
28
|
+
let _slot2;
|
|
29
|
+
if (type === "group") {
|
|
30
|
+
let _slot;
|
|
31
|
+
return createVNode(MergedMenuItemGroup, mergeProps({ "key": mergedKey }, restProps, { "title": label }), _isSlot(_slot = convertItemsToNodes(children, components, prefixCls)) ? _slot : { default: () => [_slot] });
|
|
32
|
+
}
|
|
33
|
+
return createVNode(MergedSubMenu, mergeProps({ "key": mergedKey }, restProps, { "title": label }), _isSlot(_slot2 = convertItemsToNodes(children, components, prefixCls)) ? _slot2 : { default: () => [_slot2] });
|
|
34
|
+
}
|
|
35
|
+
if (type === "divider") return createVNode(MergedDivider, mergeProps({ "key": mergedKey }, restProps), null);
|
|
36
|
+
return createVNode(MergedMenuItem, mergeProps({ "key": mergedKey }, restProps, { "extra": extra }), { default: () => [label, (!!extra || extra === 0) && createVNode("span", { "class": `${prefixCls}-item-extra` }, [extra])] });
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}).filter((opt) => opt);
|
|
65
40
|
}
|
|
66
|
-
function parseItems(children, items, keyPath, components, prefixCls) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
return parseChildren(childNodes, keyPath);
|
|
41
|
+
function parseItems(children, items, keyPath, components, prefixCls, slots) {
|
|
42
|
+
let childNodes = children;
|
|
43
|
+
const mergedComponents = {
|
|
44
|
+
divider: Divider_default,
|
|
45
|
+
item: MenuItem_default,
|
|
46
|
+
group: MenuItemGroup_default,
|
|
47
|
+
submenu: SubMenu_default,
|
|
48
|
+
...components
|
|
49
|
+
};
|
|
50
|
+
if (items) childNodes = convertItemsToNodes(items, mergedComponents, prefixCls, slots);
|
|
51
|
+
return parseChildren(childNodes, keyPath);
|
|
79
52
|
}
|
|
80
|
-
export {
|
|
81
|
-
parseItems
|
|
82
|
-
};
|
|
53
|
+
export { parseItems };
|
package/dist/utils/timeUtil.cjs
CHANGED
package/dist/utils/timeUtil.js
CHANGED
package/dist/utils/warnUtil.cjs
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"`info.item` is deprecated since we will move to function component that not provides React Node instance in future."
|
|
10
|
-
);
|
|
11
|
-
return item;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
return restInfo;
|
|
1
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
2
|
+
let __v_c_util = require("@v-c/util");
|
|
3
|
+
function warnItemProp({ item,...restInfo }) {
|
|
4
|
+
Object.defineProperty(restInfo, "item", { get: () => {
|
|
5
|
+
(0, __v_c_util.warning)(false, "`info.item` is deprecated since we will move to function component that not provides React Node instance in future.");
|
|
6
|
+
return item;
|
|
7
|
+
} });
|
|
8
|
+
return restInfo;
|
|
15
9
|
}
|
|
16
10
|
exports.warnItemProp = warnItemProp;
|
package/dist/utils/warnUtil.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { warning } from "@v-c/util";
|
|
2
|
-
function warnItemProp({ item
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
);
|
|
9
|
-
return item;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
return restInfo;
|
|
2
|
+
function warnItemProp({ item,...restInfo }) {
|
|
3
|
+
Object.defineProperty(restInfo, "item", { get: () => {
|
|
4
|
+
warning(false, "`info.item` is deprecated since we will move to function component that not provides React Node instance in future.");
|
|
5
|
+
return item;
|
|
6
|
+
} });
|
|
7
|
+
return restInfo;
|
|
13
8
|
}
|
|
14
|
-
export {
|
|
15
|
-
warnItemProp
|
|
16
|
-
};
|
|
9
|
+
export { warnItemProp };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/menu",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"description": "menu ui component for vue",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"vue": "^3.0.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@v-c/trigger": "0.0.13",
|
|
28
27
|
"@v-c/overflow": "0.0.1",
|
|
28
|
+
"@v-c/trigger": "0.0.13",
|
|
29
29
|
"@v-c/util": "0.0.13"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|