UNPKG

choo-taro-ui-vue3

Version:

Taro UI Rewritten in Vue 3.0

81 lines (73 loc) 2.15 kB
import { defineComponent, computed, renderSlot, resolveComponent, mergeProps, withCtx, openBlock, createBlock } from 'vue'; const SIZE_CLASS = { normal: "normal", small: "small" }; const TYPE_CLASS = { primary: "primary" }; const AtTag = defineComponent({ name: "AtTag", emits: { "click": (tagInfo, e) => { return !!(tagInfo && typeof tagInfo.name === "string" && typeof tagInfo.active === "boolean"); } }, props: { size: { type: String, default: "normal", validator: (val) => ["normal", "small"].includes(val) }, type: { type: String, default: "", validator: (val) => ["", "primary"].includes(val) }, name: { type: String, default: "" }, circle: Boolean, active: Boolean, disabled: Boolean }, setup(props, { emit }) { const rootClasses = computed(() => ({ [`at-tag--${SIZE_CLASS[props.size]}`]: SIZE_CLASS[props.size], [`at-tag--${props.type}`]: TYPE_CLASS[props.type], "at-tag--disabled": props.disabled, "at-tag--circle": props.circle, "at-tag--active": props.active, "at-tag": true })); function handleClick(event) { if (!props.disabled) { emit("click", { name: props.name, active: Boolean(props.active) }, event); } } return { rootClasses, handleClick }; } }); // Binding optimization for webpack code-split const _renderSlot = renderSlot, _resolveComponent = resolveComponent, _mergeProps = mergeProps, _withCtx = withCtx, _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: _ctx.rootClasses, onTap: _ctx.handleClick }), { default: _withCtx(() => [ _renderSlot(_ctx.$slots, "default") ]), _: 3 /* FORWARDED */ }, 16 /* FULL_PROPS */, ["class", "onTap"])) } AtTag.render = _sfc_render; export default AtTag;