@v-c/menu 1.0.6 → 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 +20 -8
- package/dist/SubMenu/index.d.ts +1 -2
- package/dist/SubMenu/index.js +25 -11
- package/dist/context/MenuContext.js +1 -1
- package/dist/interface.d.ts +4 -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 +5 -5
- package/dist/Divider.cjs +0 -38
- package/dist/Icon.cjs +0 -45
- package/dist/Menu.cjs +0 -526
- 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 -508
- 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,15 +241,20 @@ 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
|
-
"data": wrappedChildList
|
|
252
|
+
"data": wrappedChildList
|
|
253
|
+
}, {
|
|
254
|
+
dir: props.direction,
|
|
255
|
+
role: "menu",
|
|
256
|
+
tabindex: _attrs.tabindex ?? 0
|
|
257
|
+
}, {
|
|
251
258
|
"renderRawItem": (node) => {
|
|
252
259
|
return node;
|
|
253
260
|
},
|
|
@@ -509,6 +516,11 @@ var Menu_default = /* @__PURE__ */ defineComponent((props, { slots, expose, attr
|
|
|
509
516
|
type: Function,
|
|
510
517
|
required: false,
|
|
511
518
|
default: void 0
|
|
519
|
+
},
|
|
520
|
+
iconRender: {
|
|
521
|
+
type: Function,
|
|
522
|
+
required: false,
|
|
523
|
+
default: void 0
|
|
512
524
|
}
|
|
513
525
|
}, defaults),
|
|
514
526
|
name: "VcMenu",
|
package/dist/SubMenu/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { SubMenuType } from '../interface';
|
|
1
2
|
import { VueNode } from '@v-c/util/dist/type';
|
|
2
3
|
import { CSSProperties } from 'vue';
|
|
3
|
-
import { PopupRender, SubMenuType } from '../interface';
|
|
4
4
|
export type SemanticName = 'list' | 'listTitle';
|
|
5
5
|
export interface SubMenuProps extends Omit<SubMenuType, 'key' | 'children' | 'label'> {
|
|
6
6
|
classes?: Partial<Record<SemanticName, string>>;
|
|
@@ -12,7 +12,6 @@ export interface SubMenuProps extends Omit<SubMenuType, 'key' | 'children' | 'la
|
|
|
12
12
|
eventKey?: string;
|
|
13
13
|
/** @private Do not use. Private warning empty usage */
|
|
14
14
|
warnKey?: boolean;
|
|
15
|
-
popupRender?: PopupRender;
|
|
16
15
|
}
|
|
17
16
|
declare const SubMenu: import('vue').DefineSetupFnComponent<SubMenuProps, {}, {}, SubMenuProps & {}, import('vue').PublicProps>;
|
|
18
17
|
export default SubMenu;
|
package/dist/SubMenu/index.js
CHANGED
|
@@ -3,8 +3,10 @@ import { PathTrackerContext, useFullPath, useMeasure, usePathUserContext } from
|
|
|
3
3
|
import Icon_default from "../Icon.js";
|
|
4
4
|
import { useMenuId } from "../context/IdContext.js";
|
|
5
5
|
import { usePrivateContext } from "../context/PrivateContext.js";
|
|
6
|
+
import useMemoCallback from "../hooks/useMemoCallback.js";
|
|
6
7
|
import useActive from "../hooks/useActive.js";
|
|
7
8
|
import useDirectionStyle from "../hooks/useDirectionStyle.js";
|
|
9
|
+
import { warnItemProp } from "../utils/warnUtil.js";
|
|
8
10
|
import { parseChildren } from "../utils/commonUtil.js";
|
|
9
11
|
import SubMenuList_default from "./SubMenuList.js";
|
|
10
12
|
import InlineSubMenuList_default from "./InlineSubMenuList.js";
|
|
@@ -41,6 +43,7 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
41
43
|
const subMenuPrefixCls = computed(() => `${prefixCls.value}-submenu`);
|
|
42
44
|
const mergedDisabled = computed(() => !!(contextDisabled.value || props?.disabled));
|
|
43
45
|
if (process.env.NODE_ENV !== "production" && props?.warnKey) warning$1(false, "SubMenu should not leave undefined `key`.");
|
|
46
|
+
const mergedItemIcon = computed(() => props?.itemIcon ?? menuContext?.value?.itemIcon);
|
|
44
47
|
const mergedExpandIcon = computed(() => props?.expandIcon ?? contextExpandIcon.value);
|
|
45
48
|
const originOpen = computed(() => {
|
|
46
49
|
const key = props?.eventKey;
|
|
@@ -89,6 +92,10 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
89
92
|
});
|
|
90
93
|
if (mode.value === "inline" && key) onOpenChange(key, !originOpen.value);
|
|
91
94
|
};
|
|
95
|
+
const onMergedItemClick = useMemoCallback((info) => {
|
|
96
|
+
props?.onClick?.(warnItemProp(info));
|
|
97
|
+
menuContext?.value?.onItemClick?.(info);
|
|
98
|
+
});
|
|
92
99
|
const onPopupVisibleChange = (newVisible) => {
|
|
93
100
|
const key = props?.eventKey;
|
|
94
101
|
if (mode.value !== "inline" && key) onOpenChange(key, newVisible);
|
|
@@ -186,7 +193,14 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
186
193
|
open: open.value,
|
|
187
194
|
disabled: mergedDisabled.value
|
|
188
195
|
});
|
|
189
|
-
return
|
|
196
|
+
return createVNode(MenuContext_default, {
|
|
197
|
+
"classes": classes,
|
|
198
|
+
"styles": styles,
|
|
199
|
+
"onItemClick": onMergedItemClick,
|
|
200
|
+
"mode": mode.value === "horizontal" ? "vertical" : mode.value,
|
|
201
|
+
"itemIcon": mergedItemIcon.value,
|
|
202
|
+
"expandIcon": mergedExpandIcon.value
|
|
203
|
+
}, _isSlot(listNode) ? listNode : { default: () => [listNode] });
|
|
190
204
|
};
|
|
191
205
|
}, {
|
|
192
206
|
props: {
|
|
@@ -228,11 +242,6 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
228
242
|
required: false,
|
|
229
243
|
default: void 0
|
|
230
244
|
},
|
|
231
|
-
popupRender: {
|
|
232
|
-
type: Function,
|
|
233
|
-
required: false,
|
|
234
|
-
default: void 0
|
|
235
|
-
},
|
|
236
245
|
type: {
|
|
237
246
|
type: String,
|
|
238
247
|
required: false,
|
|
@@ -299,6 +308,11 @@ var InternalSubMenu = /* @__PURE__ */ defineComponent((props, { slots, attrs })
|
|
|
299
308
|
required: false,
|
|
300
309
|
default: void 0
|
|
301
310
|
},
|
|
311
|
+
popupRender: {
|
|
312
|
+
type: Function,
|
|
313
|
+
required: false,
|
|
314
|
+
default: void 0
|
|
315
|
+
},
|
|
302
316
|
onClick: {
|
|
303
317
|
type: Function,
|
|
304
318
|
required: false,
|
|
@@ -392,11 +406,6 @@ var SubMenu_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
392
406
|
required: false,
|
|
393
407
|
default: void 0
|
|
394
408
|
},
|
|
395
|
-
popupRender: {
|
|
396
|
-
type: Function,
|
|
397
|
-
required: false,
|
|
398
|
-
default: void 0
|
|
399
|
-
},
|
|
400
409
|
type: {
|
|
401
410
|
type: String,
|
|
402
411
|
required: false,
|
|
@@ -463,6 +472,11 @@ var SubMenu_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
463
472
|
required: false,
|
|
464
473
|
default: void 0
|
|
465
474
|
},
|
|
475
|
+
popupRender: {
|
|
476
|
+
type: Function,
|
|
477
|
+
required: false,
|
|
478
|
+
default: void 0
|
|
479
|
+
},
|
|
466
480
|
onClick: {
|
|
467
481
|
type: Function,
|
|
468
482
|
required: false,
|
package/dist/interface.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface SubMenuType extends ItemSharedProps {
|
|
|
19
19
|
popupClassName?: string;
|
|
20
20
|
popupOffset?: number[];
|
|
21
21
|
popupStyle?: CSSProperties;
|
|
22
|
+
popupRender?: PopupRender;
|
|
22
23
|
onClick?: MenuClickEventHandler;
|
|
23
24
|
onTitleClick?: (info: MenuTitleInfo) => void;
|
|
24
25
|
onTitleMouseEnter?: MenuHoverEventHandler;
|
|
@@ -88,7 +89,9 @@ export interface MenuRef {
|
|
|
88
89
|
export type ComponentType = 'submenu' | 'item' | 'group' | 'divider';
|
|
89
90
|
export type Components = Partial<Record<ComponentType, any>>;
|
|
90
91
|
export type PopupRender = (node: any, info: {
|
|
91
|
-
item: SubMenuProps
|
|
92
|
+
item: SubMenuProps & {
|
|
93
|
+
key?: any;
|
|
94
|
+
};
|
|
92
95
|
keys: string[];
|
|
93
96
|
}) => VueNode;
|
|
94
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",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"vue": "^3.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@v-c/
|
|
29
|
-
"@v-c/
|
|
30
|
-
"@v-c/util": "^1.0.
|
|
28
|
+
"@v-c/overflow": "^1.0.3",
|
|
29
|
+
"@v-c/trigger": "^1.0.6",
|
|
30
|
+
"@v-c/util": "^1.0.9"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "vite build",
|
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;
|