@v-c/menu 1.0.7 → 1.0.8
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/Menu.d.ts +1 -0
- package/dist/Menu.js +14 -7
- package/dist/interface.d.ts +3 -1
- package/dist/utils/commonUtil.js +2 -8
- package/dist/utils/nodeUtil.d.ts +1 -0
- package/dist/utils/nodeUtil.js +3 -0
- package/package.json +2 -2
- package/dist/Divider.cjs +0 -38
- package/dist/Icon.cjs +0 -45
- package/dist/Menu.cjs +0 -531
- package/dist/MenuItem.cjs +0 -338
- package/dist/MenuItemGroup.cjs +0 -124
- package/dist/SubMenu/InlineSubMenuList.cjs +0 -63
- package/dist/SubMenu/PopupTrigger.cjs +0 -145
- package/dist/SubMenu/SubMenuList.cjs +0 -23
- package/dist/SubMenu/index.cjs +0 -522
- package/dist/_virtual/rolldown_runtime.cjs +0 -21
- package/dist/context/IdContext.cjs +0 -26
- package/dist/context/MenuContext.cjs +0 -196
- package/dist/context/PathContext.cjs +0 -76
- package/dist/context/PrivateContext.cjs +0 -19
- package/dist/hooks/useAccessibility.cjs +0 -193
- package/dist/hooks/useActive.cjs +0 -31
- package/dist/hooks/useDirectionStyle.cjs +0 -17
- package/dist/hooks/useKeyRecords.cjs +0 -78
- package/dist/hooks/useMemoCallback.cjs +0 -15
- package/dist/index.cjs +0 -24
- package/dist/interface.cjs +0 -1
- package/dist/placements.cjs +0 -80
- package/dist/utils/commonUtil.cjs +0 -28
- package/dist/utils/motionUtil.cjs +0 -6
- package/dist/utils/nodeUtil.cjs +0 -55
- package/dist/utils/timeUtil.cjs +0 -6
- package/dist/utils/warnUtil.cjs +0 -11
package/dist/Menu.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ export interface MenuProps {
|
|
|
74
74
|
id?: string;
|
|
75
75
|
labelRender?: (item: ItemType) => any;
|
|
76
76
|
extraRender?: (item: ItemType) => any;
|
|
77
|
+
iconRender?: (item: ItemType) => any;
|
|
77
78
|
}
|
|
78
79
|
declare const Menu: import('vue').DefineSetupFnComponent<MenuProps, {}, {}, MenuProps & {}, import('vue').PublicProps>;
|
|
79
80
|
export default Menu;
|
package/dist/Menu.js
CHANGED
|
@@ -179,7 +179,7 @@ var Menu_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attr
|
|
|
179
179
|
}));
|
|
180
180
|
useMenuContextProvider(computed(() => {
|
|
181
181
|
return {
|
|
182
|
-
prefixCls: props.prefixCls
|
|
182
|
+
prefixCls: props.prefixCls,
|
|
183
183
|
rootClass: props.rootClass,
|
|
184
184
|
classes: props.classes,
|
|
185
185
|
styles: props.styles,
|
|
@@ -225,10 +225,12 @@ var Menu_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attr
|
|
|
225
225
|
}
|
|
226
226
|
});
|
|
227
227
|
return () => {
|
|
228
|
+
const { prefixCls, rootClass } = props;
|
|
228
229
|
const children = filterEmpty(slots.default?.());
|
|
229
230
|
childList.value = parseItems(children, props?.items, EMPTY_LIST, props?._internalComponents || {}, props?.prefixCls || defaults.prefixCls, {
|
|
230
231
|
labelRender: props?.labelRender,
|
|
231
|
-
extraRender: props?.extraRender
|
|
232
|
+
extraRender: props?.extraRender,
|
|
233
|
+
iconRender: props?.iconRender
|
|
232
234
|
});
|
|
233
235
|
const measureChildList = parseItems(children, props?.items, EMPTY_LIST, {}, props?.prefixCls || defaults.prefixCls);
|
|
234
236
|
const wrappedChildList = internalMode.value !== "horizontal" || props?.disabledOverflow ? childList.value : childList.value.map((child, index) => createVNode(MenuContext_default, {
|
|
@@ -239,13 +241,13 @@ var Menu_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attr
|
|
|
239
241
|
}, _isSlot(child) ? child : { default: () => [child] }));
|
|
240
242
|
const container = createVNode(Overflow, mergeProps({
|
|
241
243
|
"ref": containerRef,
|
|
242
|
-
"prefixCls": `${
|
|
244
|
+
"prefixCls": `${prefixCls}-overflow`,
|
|
243
245
|
"component": "ul",
|
|
244
246
|
"itemComponent": MenuItem_default,
|
|
245
|
-
"class": classNames(
|
|
246
|
-
[`${
|
|
247
|
-
[`${
|
|
248
|
-
},
|
|
247
|
+
"class": classNames(prefixCls, `${prefixCls}-root`, `${prefixCls}-${internalMode.value}`, _attrs.class || "", {
|
|
248
|
+
[`${prefixCls}-inline-collapsed`]: internalInlineCollapsed.value,
|
|
249
|
+
[`${prefixCls}-rtl`]: isRtl.value
|
|
250
|
+
}, rootClass),
|
|
249
251
|
"style": _attrs.style,
|
|
250
252
|
"data": wrappedChildList
|
|
251
253
|
}, {
|
|
@@ -514,6 +516,11 @@ var Menu_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attr
|
|
|
514
516
|
type: Function,
|
|
515
517
|
required: false,
|
|
516
518
|
default: void 0
|
|
519
|
+
},
|
|
520
|
+
iconRender: {
|
|
521
|
+
type: Function,
|
|
522
|
+
required: false,
|
|
523
|
+
default: void 0
|
|
517
524
|
}
|
|
518
525
|
}, defaults),
|
|
519
526
|
name: "VcMenu",
|
package/dist/interface.d.ts
CHANGED
|
@@ -89,7 +89,9 @@ export interface MenuRef {
|
|
|
89
89
|
export type ComponentType = 'submenu' | 'item' | 'group' | 'divider';
|
|
90
90
|
export type Components = Partial<Record<ComponentType, any>>;
|
|
91
91
|
export type PopupRender = (node: any, info: {
|
|
92
|
-
item: SubMenuProps
|
|
92
|
+
item: SubMenuProps & {
|
|
93
|
+
key?: any;
|
|
94
|
+
};
|
|
93
95
|
keys: string[];
|
|
94
96
|
}) => VueNode;
|
|
95
97
|
export {};
|
package/dist/utils/commonUtil.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isVNode } from "vue";
|
|
1
|
+
import { cloneVNode, isVNode } from "vue";
|
|
2
2
|
import { toArray } from "@v-c/util/dist/Children/toArray";
|
|
3
3
|
function parseChildren(children, keyPath) {
|
|
4
4
|
return toArray(children).map((child, index) => {
|
|
@@ -12,13 +12,7 @@ function parseChildren(children, keyPath) {
|
|
|
12
12
|
eventKey
|
|
13
13
|
};
|
|
14
14
|
if (process.env.NODE_ENV !== "production" && emptyKey) cloneProps.warnKey = true;
|
|
15
|
-
return {
|
|
16
|
-
...child,
|
|
17
|
-
props: {
|
|
18
|
-
...child.props,
|
|
19
|
-
...cloneProps
|
|
20
|
-
}
|
|
21
|
-
};
|
|
15
|
+
return cloneVNode(child, { ...cloneProps });
|
|
22
16
|
}
|
|
23
17
|
return child;
|
|
24
18
|
});
|
package/dist/utils/nodeUtil.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ import { Components, ItemType } from '../interface';
|
|
|
3
3
|
export declare function parseItems(children: VueNode | undefined, items: ItemType[] | undefined, keyPath: string[], components: Components, prefixCls?: string, slots?: {
|
|
4
4
|
labelRender?: (item: ItemType) => any;
|
|
5
5
|
extraRender?: (item: ItemType) => any;
|
|
6
|
+
iconRender?: (item: ItemType) => any;
|
|
6
7
|
}): any[];
|
package/dist/utils/nodeUtil.js
CHANGED
|
@@ -18,8 +18,11 @@ function convertItemsToNodes(list, components, prefixCls, slots) {
|
|
|
18
18
|
let extra;
|
|
19
19
|
const _labelRender = slots?.labelRender ? slots.labelRender(opt) : null;
|
|
20
20
|
const _extraRender = slots?.extraRender ? slots.extraRender(opt) : null;
|
|
21
|
+
const _iconRender = slots?.iconRender ? slots.iconRender(opt) : null;
|
|
21
22
|
const labelArr = filterEmpty(Array.isArray(_labelRender) ? _labelRender : [_labelRender]);
|
|
22
23
|
const extraArr = filterEmpty(Array.isArray(_extraRender) ? _extraRender : [_extraRender]);
|
|
24
|
+
const iconArr = filterEmpty(Array.isArray(_iconRender) ? _iconRender : [_iconRender]);
|
|
25
|
+
if (iconArr.length) restProps.icon = iconArr?.[0];
|
|
23
26
|
if (labelArr.length) label = labelArr?.[0];
|
|
24
27
|
if (extraArr.length) extra = extraArr?.[0];
|
|
25
28
|
if (!label) label = opt.label;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/menu",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"description": "menu ui component for vue",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"import": "./dist/index.js",
|
|
10
|
-
"
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
11
|
},
|
|
12
12
|
"./dist/*.js": "./dist/*.js",
|
|
13
13
|
"./dist/*.d.ts": "./dist/*.d.ts",
|
package/dist/Divider.cjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_MenuContext = require("./context/MenuContext.cjs");
|
|
7
|
-
const require_PathContext = require("./context/PathContext.cjs");
|
|
8
|
-
let vue = require("vue");
|
|
9
|
-
let _v_c_util = require("@v-c/util");
|
|
10
|
-
var Divider = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
11
|
-
const menuContext = require_MenuContext.useMenuContext();
|
|
12
|
-
const measure = require_PathContext.useMeasure();
|
|
13
|
-
return () => {
|
|
14
|
-
const { prefixCls } = menuContext?.value ?? {};
|
|
15
|
-
if (measure) return null;
|
|
16
|
-
return (0, vue.createVNode)("li", {
|
|
17
|
-
"role": "separator",
|
|
18
|
-
"class": (0, _v_c_util.clsx)(`${prefixCls}-item-divider`, props.class),
|
|
19
|
-
"style": props.style
|
|
20
|
-
}, null);
|
|
21
|
-
};
|
|
22
|
-
}, {
|
|
23
|
-
props: {
|
|
24
|
-
style: {
|
|
25
|
-
type: Object,
|
|
26
|
-
required: false,
|
|
27
|
-
default: void 0
|
|
28
|
-
},
|
|
29
|
-
class: {
|
|
30
|
-
type: String,
|
|
31
|
-
required: false,
|
|
32
|
-
default: void 0
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
name: "Divider"
|
|
36
|
-
});
|
|
37
|
-
var Divider_default = Divider;
|
|
38
|
-
exports.default = Divider_default;
|
package/dist/Icon.cjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
6
|
-
let vue = require("vue");
|
|
7
|
-
let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
8
|
-
var Icon = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
9
|
-
return () => {
|
|
10
|
-
const { icon, props: iconProps } = props;
|
|
11
|
-
const children = slots.default?.();
|
|
12
|
-
let iconNode;
|
|
13
|
-
if (icon === null || icon === false) return null;
|
|
14
|
-
if (typeof icon === "function") {
|
|
15
|
-
const childIcons = icon(iconProps);
|
|
16
|
-
if (!childIcons) {
|
|
17
|
-
iconNode = null;
|
|
18
|
-
return children;
|
|
19
|
-
}
|
|
20
|
-
iconNode = (0, _v_c_util_dist_props_util.filterEmpty)(childIcons ? Array.isArray(childIcons) ? childIcons : [childIcons] : []);
|
|
21
|
-
} else if (typeof icon !== "boolean") iconNode = icon;
|
|
22
|
-
return iconNode || children || null;
|
|
23
|
-
};
|
|
24
|
-
}, { props: {
|
|
25
|
-
icon: {
|
|
26
|
-
type: [
|
|
27
|
-
Object,
|
|
28
|
-
Function,
|
|
29
|
-
String,
|
|
30
|
-
Number,
|
|
31
|
-
null,
|
|
32
|
-
Boolean,
|
|
33
|
-
Array
|
|
34
|
-
],
|
|
35
|
-
required: false,
|
|
36
|
-
default: void 0
|
|
37
|
-
},
|
|
38
|
-
props: {
|
|
39
|
-
type: Object,
|
|
40
|
-
required: false,
|
|
41
|
-
default: void 0
|
|
42
|
-
}
|
|
43
|
-
} });
|
|
44
|
-
var Icon_default = Icon;
|
|
45
|
-
exports.default = Icon_default;
|