UNPKG

choo-taro-ui-vue3

Version:

Taro UI Rewritten in Vue 3.0

105 lines (97 loc) 4.61 kB
import { defineComponent, computed, toRef, renderList, Fragment, openBlock, createElementBlock, resolveComponent, createVNode, normalizeClass, createBlock, createCommentVNode, withCtx, toDisplayString, createTextVNode, mergeProps } from 'vue'; const AtTimeline = defineComponent({ name: "AtTimeline", props: { pending: Boolean, items: { type: Array, default: [] } }, setup(props) { const rootClasses = computed(() => ({ "at-timeline": true, "at-timeline--pending": props.pending })); const genIconClasses = (item) => ({ "at-icon": true, [`at-icon-${item.icon}`]: Boolean(item.icon) }); const genItemRootClasses = (item) => ({ "at-timeline-item": true, [`${`at-timeline-item--${item.color}`}`]: Boolean(item.color) }); const genDotClasses = (item) => ({ "at-timeline-item__icon": Boolean(item.icon), "at-timeline-item__dot": !Boolean(item.icon) }); return { items: toRef(props, "items"), rootClasses, genDotClasses, genIconClasses, genItemRootClasses }; } }); // Binding optimization for webpack code-split const _renderList = renderList, _Fragment = Fragment, _openBlock = openBlock, _createElementBlock = createElementBlock, _resolveComponent = resolveComponent, _createVNode = createVNode, _normalizeClass = normalizeClass, _createBlock = createBlock, _createCommentVNode = createCommentVNode, _withCtx = withCtx, _toDisplayString = toDisplayString, _createTextVNode = createTextVNode, _mergeProps = mergeProps; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_taro_view = process.env.TARO_ENV === "h5" ? _resolveComponent("taro-view") : "view"; const _component_taro_text = process.env.TARO_ENV === "h5" ? _resolveComponent("taro-text") : "text"; return (_openBlock(), _createBlock(_component_taro_view, _mergeProps(_ctx.$attrs, { class: _ctx.rootClasses }), { default: _withCtx(() => [ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.items, (item, index) => { return (_openBlock(), _createBlock(_component_taro_view, { key: `at-timeline-item-${index}`, class: _normalizeClass(_ctx.genItemRootClasses(item)) }, { default: _withCtx(() => [ _createVNode(_component_taro_view, { class: "at-timeline-item__tail" }), _createVNode(_component_taro_view, { class: _normalizeClass(_ctx.genDotClasses(item)) }, { default: _withCtx(() => [ (item.icon) ? (_openBlock(), _createBlock(_component_taro_text, { key: 0, class: _normalizeClass(_ctx.genIconClasses(item)) }, null, 8 /* PROPS */, ["class"])) : _createCommentVNode("v-if", true) ]), _: 2 /* DYNAMIC */ }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["class"]), _createVNode(_component_taro_view, { class: "at-timeline-item__content" }, { default: _withCtx(() => [ _createVNode(_component_taro_view, { class: "at-timeline-item__content-item" }, { default: _withCtx(() => [ _createTextVNode(_toDisplayString(item.title), 1 /* TEXT */) ]), _: 2 /* DYNAMIC */ }, 1024 /* DYNAMIC_SLOTS */), (item.content && item.content.length > 0) ? (_openBlock(true), _createElementBlock(_Fragment, { key: 0 }, _renderList(item.content, (content, subIndex) => { return (_openBlock(), _createBlock(_component_taro_view, { key: subIndex, class: "at-timeline-item__content-item at-timeline-item__content--sub" }, { default: _withCtx(() => [ _createTextVNode(_toDisplayString(content), 1 /* TEXT */) ]), _: 2 /* DYNAMIC */ }, 1024 /* DYNAMIC_SLOTS */)) }), 128 /* KEYED_FRAGMENT */)) : _createCommentVNode("v-if", true) ]), _: 2 /* DYNAMIC */ }, 1024 /* DYNAMIC_SLOTS */) ]), _: 2 /* DYNAMIC */ }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["class"])) }), 128 /* KEYED_FRAGMENT */)) ]), _: 1 /* STABLE */ }, 16 /* FULL_PROPS */, ["class"])) } AtTimeline.render = _sfc_render; export default AtTimeline;