UNPKG

song-ui-u

Version:

vue3 + js的PC前端组件库

72 lines (68 loc) 1.59 kB
'use strict'; var vue = require('vue'); var index = require('../../../hook/use-namespace/index.cjs'); require('song-ui-pro-icon'); require('../../../hook/use-zindex/index.cjs'); var constant = require('./constant.cjs'); var menu = /* @__PURE__ */ vue.defineComponent({ name: "x-menu", props: { defaultActive: { type: String, default: "" }, mode: { type: String, default: "vertical" }, width: { type: String, default: "auto" } }, setup(props, { slots, emit }) { const change = (index) => { emit("change", index); }; const leave = (index) => { emit("leave", index); }; const enter = (index) => { emit("enter", index); }; const toggle = (index) => { emit("toggle", index); }; const currentIndex = vue.ref(props.defaultActive); const width = vue.computed(() => { if (props.mode == "horizontal") return "auto"; return props.width; }); const setCurrentIndex = (index) => { currentIndex.value = index; }; vue.provide(constant.MENU_KEY, { props, currentIndex, setCurrentIndex, change, leave, enter, toggle }); const ns = index.useNamespace("menu"); return () => vue.createVNode("ul", { "class": [ns.b(), ns.m("mode", props.mode)], "style": { backgroundColor: props.backgroundColor, color: props.textColor, width: width.value + "px" } }, [slots.default?.()]); } }); module.exports = menu; //# sourceMappingURL=menu.cjs.map