@v-c/menu 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/Divider.cjs +38 -0
- package/dist/Divider.d.ts +4 -0
- package/dist/Divider.js +38 -0
- package/dist/Icon.cjs +38 -0
- package/dist/Icon.d.ts +7 -0
- package/dist/Icon.js +38 -0
- package/dist/Menu.cjs +580 -0
- package/dist/Menu.d.ts +77 -0
- package/dist/Menu.js +580 -0
- package/dist/MenuItem.cjs +350 -0
- package/dist/MenuItem.d.ts +14 -0
- package/dist/MenuItem.js +350 -0
- package/dist/MenuItemGroup.cjs +120 -0
- package/dist/MenuItemGroup.d.ts +16 -0
- package/dist/MenuItemGroup.js +120 -0
- package/dist/SubMenu/InlineSubMenuList.cjs +84 -0
- package/dist/SubMenu/InlineSubMenuList.d.ts +7 -0
- package/dist/SubMenu/InlineSubMenuList.js +84 -0
- package/dist/SubMenu/PopupTrigger.cjs +168 -0
- package/dist/SubMenu/PopupTrigger.d.ts +16 -0
- package/dist/SubMenu/PopupTrigger.js +168 -0
- package/dist/SubMenu/SubMenuList.cjs +28 -0
- package/dist/SubMenu/SubMenuList.d.ts +2 -0
- package/dist/SubMenu/SubMenuList.js +28 -0
- package/dist/SubMenu/index.cjs +532 -0
- package/dist/SubMenu/index.d.ts +18 -0
- package/dist/SubMenu/index.js +532 -0
- package/dist/context/IdContext.cjs +33 -0
- package/dist/context/IdContext.d.ts +12 -0
- package/dist/context/IdContext.js +33 -0
- package/dist/context/MenuContext.cjs +184 -0
- package/dist/context/MenuContext.d.ts +42 -0
- package/dist/context/MenuContext.js +184 -0
- package/dist/context/PathContext.cjs +100 -0
- package/dist/context/PathContext.d.ts +33 -0
- package/dist/context/PathContext.js +100 -0
- package/dist/context/PrivateContext.cjs +24 -0
- package/dist/context/PrivateContext.d.ts +8 -0
- package/dist/context/PrivateContext.js +24 -0
- package/dist/hooks/useAccessibility.cjs +210 -0
- package/dist/hooks/useAccessibility.d.ts +12 -0
- package/dist/hooks/useAccessibility.js +210 -0
- package/dist/hooks/useActive.cjs +31 -0
- package/dist/hooks/useActive.d.ts +9 -0
- package/dist/hooks/useActive.js +31 -0
- package/dist/hooks/useDirectionStyle.cjs +20 -0
- package/dist/hooks/useDirectionStyle.d.ts +2 -0
- package/dist/hooks/useDirectionStyle.js +20 -0
- package/dist/hooks/useKeyRecords.cjs +93 -0
- package/dist/hooks/useKeyRecords.d.ts +10 -0
- package/dist/hooks/useKeyRecords.js +93 -0
- package/dist/hooks/useMemoCallback.cjs +12 -0
- package/dist/hooks/useMemoCallback.d.ts +4 -0
- package/dist/hooks/useMemoCallback.js +12 -0
- package/dist/index.cjs +21 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +21 -0
- package/dist/interface.cjs +1 -0
- package/dist/interface.d.ts +94 -0
- package/dist/interface.js +1 -0
- package/dist/placements.cjs +77 -0
- package/dist/placements.d.ts +117 -0
- package/dist/placements.js +77 -0
- package/dist/utils/commonUtil.cjs +29 -0
- package/dist/utils/commonUtil.d.ts +1 -0
- package/dist/utils/commonUtil.js +29 -0
- package/dist/utils/motionUtil.cjs +12 -0
- package/dist/utils/motionUtil.d.ts +2 -0
- package/dist/utils/motionUtil.js +12 -0
- package/dist/utils/nodeUtil.cjs +82 -0
- package/dist/utils/nodeUtil.d.ts +3 -0
- package/dist/utils/nodeUtil.js +82 -0
- package/dist/utils/timeUtil.cjs +6 -0
- package/dist/utils/timeUtil.d.ts +1 -0
- package/dist/utils/timeUtil.js +6 -0
- package/dist/utils/warnUtil.cjs +16 -0
- package/dist/utils/warnUtil.d.ts +7 -0
- package/dist/utils/warnUtil.js +16 -0
- package/package.json +37 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const Divider = require("../Divider.cjs");
|
|
5
|
+
const MenuItem = require("../MenuItem.cjs");
|
|
6
|
+
const MenuItemGroup = require("../MenuItemGroup.cjs");
|
|
7
|
+
const index = require("../SubMenu/index.cjs");
|
|
8
|
+
const commonUtil = require("./commonUtil.cjs");
|
|
9
|
+
function _isSlot(s) {
|
|
10
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
|
|
11
|
+
}
|
|
12
|
+
function convertItemsToNodes(list, components, prefixCls) {
|
|
13
|
+
const {
|
|
14
|
+
item: MergedMenuItem,
|
|
15
|
+
group: MergedMenuItemGroup,
|
|
16
|
+
submenu: MergedSubMenu,
|
|
17
|
+
divider: MergedDivider
|
|
18
|
+
} = components;
|
|
19
|
+
return (list || []).map((opt, index2) => {
|
|
20
|
+
if (opt && typeof opt === "object") {
|
|
21
|
+
const {
|
|
22
|
+
label,
|
|
23
|
+
children,
|
|
24
|
+
key,
|
|
25
|
+
type,
|
|
26
|
+
extra,
|
|
27
|
+
...restProps
|
|
28
|
+
} = opt;
|
|
29
|
+
const mergedKey = key ?? `tmp-${index2}`;
|
|
30
|
+
if (children || type === "group") {
|
|
31
|
+
let _slot2;
|
|
32
|
+
if (type === "group") {
|
|
33
|
+
let _slot;
|
|
34
|
+
return vue.createVNode(MergedMenuItemGroup, vue.mergeProps({
|
|
35
|
+
"key": mergedKey
|
|
36
|
+
}, restProps, {
|
|
37
|
+
"title": label
|
|
38
|
+
}), _isSlot(_slot = convertItemsToNodes(children, components, prefixCls)) ? _slot : {
|
|
39
|
+
default: () => [_slot]
|
|
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);
|
|
67
|
+
}
|
|
68
|
+
function parseItems(children, items, keyPath, components, prefixCls) {
|
|
69
|
+
let childNodes = children;
|
|
70
|
+
const mergedComponents = {
|
|
71
|
+
divider: Divider.default,
|
|
72
|
+
item: MenuItem.default,
|
|
73
|
+
group: MenuItemGroup.default,
|
|
74
|
+
submenu: index.default,
|
|
75
|
+
...components
|
|
76
|
+
};
|
|
77
|
+
if (items) {
|
|
78
|
+
childNodes = convertItemsToNodes(items, mergedComponents, prefixCls);
|
|
79
|
+
}
|
|
80
|
+
return commonUtil.parseChildren(childNodes, keyPath);
|
|
81
|
+
}
|
|
82
|
+
exports.parseItems = parseItems;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createVNode, mergeProps, isVNode } from "vue";
|
|
2
|
+
import Divider from "../Divider.js";
|
|
3
|
+
import MenuItem from "../MenuItem.js";
|
|
4
|
+
import MenuItemGroup from "../MenuItemGroup.js";
|
|
5
|
+
import SubMenu from "../SubMenu/index.js";
|
|
6
|
+
import { parseChildren } from "./commonUtil.js";
|
|
7
|
+
function _isSlot(s) {
|
|
8
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
9
|
+
}
|
|
10
|
+
function convertItemsToNodes(list, components, prefixCls) {
|
|
11
|
+
const {
|
|
12
|
+
item: MergedMenuItem,
|
|
13
|
+
group: MergedMenuItemGroup,
|
|
14
|
+
submenu: MergedSubMenu,
|
|
15
|
+
divider: MergedDivider
|
|
16
|
+
} = components;
|
|
17
|
+
return (list || []).map((opt, index) => {
|
|
18
|
+
if (opt && typeof opt === "object") {
|
|
19
|
+
const {
|
|
20
|
+
label,
|
|
21
|
+
children,
|
|
22
|
+
key,
|
|
23
|
+
type,
|
|
24
|
+
extra,
|
|
25
|
+
...restProps
|
|
26
|
+
} = opt;
|
|
27
|
+
const mergedKey = key ?? `tmp-${index}`;
|
|
28
|
+
if (children || type === "group") {
|
|
29
|
+
let _slot2;
|
|
30
|
+
if (type === "group") {
|
|
31
|
+
let _slot;
|
|
32
|
+
return createVNode(MergedMenuItemGroup, mergeProps({
|
|
33
|
+
"key": mergedKey
|
|
34
|
+
}, restProps, {
|
|
35
|
+
"title": label
|
|
36
|
+
}), _isSlot(_slot = convertItemsToNodes(children, components, prefixCls)) ? _slot : {
|
|
37
|
+
default: () => [_slot]
|
|
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);
|
|
65
|
+
}
|
|
66
|
+
function parseItems(children, items, keyPath, components, prefixCls) {
|
|
67
|
+
let childNodes = children;
|
|
68
|
+
const mergedComponents = {
|
|
69
|
+
divider: Divider,
|
|
70
|
+
item: MenuItem,
|
|
71
|
+
group: MenuItemGroup,
|
|
72
|
+
submenu: SubMenu,
|
|
73
|
+
...components
|
|
74
|
+
};
|
|
75
|
+
if (items) {
|
|
76
|
+
childNodes = convertItemsToNodes(items, mergedComponents, prefixCls);
|
|
77
|
+
}
|
|
78
|
+
return parseChildren(childNodes, keyPath);
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
parseItems
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function nextSlice(callback: () => void): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const util = require("@v-c/util");
|
|
4
|
+
function warnItemProp({ item, ...restInfo }) {
|
|
5
|
+
Object.defineProperty(restInfo, "item", {
|
|
6
|
+
get: () => {
|
|
7
|
+
util.warning(
|
|
8
|
+
false,
|
|
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;
|
|
15
|
+
}
|
|
16
|
+
exports.warnItemProp = warnItemProp;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { warning } from "@v-c/util";
|
|
2
|
+
function warnItemProp({ item, ...restInfo }) {
|
|
3
|
+
Object.defineProperty(restInfo, "item", {
|
|
4
|
+
get: () => {
|
|
5
|
+
warning(
|
|
6
|
+
false,
|
|
7
|
+
"`info.item` is deprecated since we will move to function component that not provides React Node instance in future."
|
|
8
|
+
);
|
|
9
|
+
return item;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return restInfo;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
warnItemProp
|
|
16
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@v-c/menu",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "menu ui component for vue",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
11
|
+
},
|
|
12
|
+
"./dist/*": "./dist/*",
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"package.json"
|
|
21
|
+
],
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"vue": "^3.0.0"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@v-c/trigger": "0.0.13",
|
|
28
|
+
"@v-c/overflow": "0.0.1",
|
|
29
|
+
"@v-c/util": "0.0.13"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "vite build",
|
|
33
|
+
"prepublish": "pnpm build",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"bump": "bumpp --release patch"
|
|
36
|
+
}
|
|
37
|
+
}
|