UNPKG

@opensig/opendesign

Version:

<p align="center"><img src="../docs/public/opendesign-logo-light.png"/></p> <h1 align="center">opendesign</h1> <p align="center">一个 Vue 3 组件库</p> <p align="center"><b>皮肤可定制,使用 TypeScript</b></p>

80 lines (79 loc) 2.56 kB
"use strict"; const vue = require("vue"); const index = require("../popup/index.js"); const types = require("./types.js"); const provide = require("./provide.js"); const is = require("../_utils/is.js"); const _sfc_main = /* @__PURE__ */ vue.defineComponent({ __name: "ODropdown", props: types.dropdownProps, emits: ["update:visible", "visible-change"], setup(__props, { emit: __emit }) { const props = __props; const emits = __emit; const dropdownRef = vue.ref(); const isVisible = vue.ref(props.visible ?? props.defaultVisible); vue.watch( () => props.visible, (val) => { if (!is.isUndefined(val)) { isVisible.value = val; } } ); const updateVisible = (val) => { isVisible.value = val; emits("update:visible", val); emits("visible-change", val); }; vue.watch(isVisible, (val) => { updateVisible(val); }); vue.provide(provide.dropdownInjectKey, { updateVisible }); return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock( "div", { ref_key: "dropdownRef", ref: dropdownRef, class: "o-dropdown" }, [ vue.renderSlot(_ctx.$slots, "default"), vue.createVNode(vue.unref(index.OPopup), { visible: isVisible.value, "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => isVisible.value = $event), transition: props.transition, "unmount-on-hide": props.unmountOnHide, position: props.optionPosition, wrapper: props.optionsWrapper, target: dropdownRef.value, trigger: props.trigger, offset: 4, "adjust-min-width": props.optionWidthMode === "min-width", "adjust-width": props.optionWidthMode === "width" }, { default: vue.withCtx(() => [ vue.createElementVNode( "ul", { class: vue.normalizeClass(["o-dropdown-list", [props.optionWrapClass]]) }, [ vue.renderSlot(_ctx.$slots, "dropdown") ], 2 /* CLASS */ ) ]), _: 3 /* FORWARDED */ }, 8, ["visible", "transition", "unmount-on-hide", "position", "wrapper", "target", "trigger", "adjust-min-width", "adjust-width"]) ], 512 /* NEED_PATCH */ ); }; } }); module.exports = _sfc_main;