UNPKG

song-ui-u

Version:

vue3 + js的PC前端组件库

70 lines (67 loc) 1.6 kB
import { defineComponent, ref, computed, provide, createVNode } from 'vue'; import { useNamespace } from '../../../hook/use-namespace/index.mjs'; import 'song-ui-pro-icon'; import '../../../hook/use-zindex/index.mjs'; import { MENU_KEY } from './constant.mjs'; var menu = /* @__PURE__ */ 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 = ref(props.defaultActive); const width = computed(() => { if (props.mode == "horizontal") return "auto"; return props.width; }); const setCurrentIndex = (index) => { currentIndex.value = index; }; provide(MENU_KEY, { props, currentIndex, setCurrentIndex, change, leave, enter, toggle }); const ns = useNamespace("menu"); return () => createVNode("ul", { "class": [ns.b(), ns.m("mode", props.mode)], "style": { backgroundColor: props.backgroundColor, color: props.textColor, width: width.value + "px" } }, [slots.default?.()]); } }); export { menu as default }; //# sourceMappingURL=menu.mjs.map