UNPKG

choo-taro-ui-vue3

Version:

Taro UI Rewritten in Vue 3.0

82 lines (74 loc) 2.6 kB
import { defineComponent, computed, toRef, renderSlot, resolveComponent, normalizeClass, createVNode, withCtx, mergeProps, openBlock, createBlock } from 'vue'; const AtCurtain = defineComponent({ name: "AtCurtain", emits: ["close"], props: { isOpened: Boolean, closeBtnPosition: { type: String, default: "bottom", validator: (pos) => [ "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right" ].includes(pos) } }, setup(props, { emit }) { const closeBtnClasses = computed(() => { const pos = [ "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right" ].includes(props.closeBtnPosition) ? props.closeBtnPosition : "top-right"; return { [`at-curtain__btn-close--${pos}`]: Boolean(props.closeBtnPosition) }; }); function handleClose(e) { e.stopPropagation(); emit("close", e); } return { isOpened: toRef(props, "isOpened"), handleClose, closeBtnClasses }; } }); // Binding optimization for webpack code-split const _renderSlot = renderSlot, _resolveComponent = resolveComponent, _normalizeClass = normalizeClass, _createVNode = createVNode, _withCtx = withCtx, _mergeProps = mergeProps, _openBlock = openBlock, _createBlock = createBlock; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_taro_view = process.env.TARO_ENV === "h5" ? _resolveComponent("taro-view") : "view"; return (_openBlock(), _createBlock(_component_taro_view, _mergeProps(_ctx.$attrs, { class: ['at-curtain', { 'at-curtain--closed': !_ctx.isOpened }], onTap: _cache[0] || (_cache[0] = (e) => { e.stopPropagation(); }) }), { default: _withCtx(() => [ _createVNode(_component_taro_view, { class: "at-curtain__container" }, { default: _withCtx(() => [ _createVNode(_component_taro_view, { class: "at-curtain__body" }, { default: _withCtx(() => [ _renderSlot(_ctx.$slots, "default"), _createVNode(_component_taro_view, { class: _normalizeClass(['at-curtain__btn-close', _ctx.closeBtnClasses]), onTap: _ctx.handleClose }, null, 8 /* PROPS */, ["class", "onTap"]) ]), _: 3 /* FORWARDED */ }) ]), _: 3 /* FORWARDED */ }) ]), _: 3 /* FORWARDED */ }, 16 /* FULL_PROPS */, ["class"])) } AtCurtain.render = _sfc_render; export default AtCurtain;