yuang-framework-ui-pc
Version:
yuang-framework-ui-pc Library
111 lines (110 loc) • 3.73 kB
JavaScript
"use strict";
const vue = require("vue");
const DropdownMenuItem = require("./dropdown-menu-item");
const _sfc_main = vue.defineComponent({
name: "DropdownMenus",
components: { DropdownMenuItem },
props: {
/** 下拉菜单数据 */
items: {
type: Array,
required: true
},
/** 选中的菜单 */
selected: [String, Number, Object],
/** 自定义下拉菜单样式 */
menuStyle: Object,
/** 自定义图标属性 */
iconProps: Object,
/** 尺寸 */
size: String
},
emits: {
itemClick: (_item) => true,
wrapperContext: (_e) => true
},
setup(_props, { emit }) {
const handleItemClick = (item) => {
if (item.disabled) {
return;
}
emit("itemClick", item);
};
const handleWrapperContext = (e) => {
emit("wrapperContext", e);
};
return {
handleItemClick,
handleWrapperContext
};
}
});
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_DropdownMenus = vue.resolveComponent("DropdownMenus", true);
const _component_DropdownMenuItem = vue.resolveComponent("DropdownMenuItem");
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass([
"ele-dropdown-menu",
{ "is-small": _ctx.size === "small" },
{ "is-large": _ctx.size === "large" }
]),
style: vue.normalizeStyle(_ctx.menuStyle)
}, [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.items, (item) => {
return vue.openBlock(), vue.createBlock(_component_DropdownMenuItem, {
key: item.key == null ? JSON.stringify(item.command) : item.key,
item,
selected: _ctx.selected,
iconProps: _ctx.iconProps,
onItemClick: _ctx.handleItemClick,
onWrapperContext: _ctx.handleWrapperContext
}, vue.createSlots({ _: 2 }, [
vue.renderList(Object.keys(_ctx.$slots).filter(
(k) => "default" !== k && "subMenus" !== k
), (name) => {
return {
name,
fn: vue.withCtx((slotProps) => [
vue.renderSlot(_ctx.$slots, name, vue.mergeProps({ ref_for: true }, slotProps || {}))
])
};
}),
item.children && item.children.length ? {
name: "subMenus",
fn: vue.withCtx(() => [
vue.createVNode(_component_DropdownMenus, {
items: item.children,
selected: _ctx.selected,
menuStyle: _ctx.menuStyle,
iconProps: _ctx.iconProps,
size: _ctx.size,
onItemClick: _ctx.handleItemClick,
onWrapperContext: _ctx.handleWrapperContext
}, vue.createSlots({ _: 2 }, [
vue.renderList(Object.keys(_ctx.$slots).filter(
(k) => "default" !== k && "subMenus" !== k
), (name) => {
return {
name,
fn: vue.withCtx((slotProps) => [
vue.renderSlot(_ctx.$slots, name, vue.mergeProps({ ref_for: true }, slotProps || {}))
])
};
})
]), 1032, ["items", "selected", "menuStyle", "iconProps", "size", "onItemClick", "onWrapperContext"])
]),
key: "0"
} : void 0
]), 1032, ["item", "selected", "iconProps", "onItemClick", "onWrapperContext"]);
}), 128))
], 6);
}
const dropdownMenus = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
module.exports = dropdownMenus;