UNPKG

@cqmcui/cqmcui

Version:

轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)

104 lines (103 loc) 3.64 kB
import { getCurrentInstance, inject, reactive, computed, toRefs, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, Fragment, toDisplayString, createCommentVNode } from "vue"; import { c as createComponent } from "./component-81a4c1d0.js"; import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js"; import "../locale/lang"; const { create, componentName } = createComponent("step"); const _sfc_main = create({ props: { title: { type: String, default: "" }, content: { type: String, default: "" } }, emits: ["click-step"], setup() { const { proxy } = getCurrentInstance(); const parent = inject("parent"); parent["relation"](proxy); const state = reactive({ dot: parent.props.progressDot }); const index2 = computed(() => parent.state.children.indexOf(proxy) + 1); const getCurrentStatus = () => { const activeIndex = index2.value; if (activeIndex < +parent.props.current) return "finish"; return activeIndex === +parent.props.current ? "process" : "wait"; }; const status = computed(() => { return getCurrentStatus(); }); const classes = computed(() => { const prefixCls = componentName; return { [prefixCls]: true, [`${prefixCls}-${status.value}`]: true }; }); const handleClickStep = () => { parent["onEmit"](index2.value); }; return { ...toRefs(state), index: index2, classes, handleClickStep }; } }); const _hoisted_1 = { class: "cqmc-step-head" }; const _hoisted_2 = /* @__PURE__ */ createElementVNode("view", { class: "cqmc-step-line" }, null, -1); const _hoisted_3 = { class: "cqmc-step-icon-inner" }; const _hoisted_4 = { key: 1, class: "cqmc-step-inner" }; const _hoisted_5 = { class: "cqmc-step-main" }; const _hoisted_6 = { class: "cqmc-step-title" }; const _hoisted_7 = { key: 0 }; const _hoisted_8 = { key: 0, class: "cqmc-step-content" }; const _hoisted_9 = ["innerHTML"]; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("view", { class: normalizeClass(_ctx.classes), onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClickStep && _ctx.handleClickStep(...args)) }, [ createElementVNode("view", _hoisted_1, [ _hoisted_2, createElementVNode("view", { class: normalizeClass(["cqmc-step-icon", [!_ctx.dot ? "is-icon" : ""]]) }, [ createElementVNode("view", _hoisted_3, [ renderSlot(_ctx.$slots, "icon", {}, () => [ _ctx.dot ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [], 64)) : (openBlock(), createElementBlock("view", _hoisted_4, toDisplayString(_ctx.index), 1)) ]) ]) ], 2) ]), createElementVNode("view", _hoisted_5, [ createElementVNode("view", _hoisted_6, [ !_ctx.$slots.title ? (openBlock(), createElementBlock("span", _hoisted_7, toDisplayString(_ctx.title), 1)) : createCommentVNode("", true), renderSlot(_ctx.$slots, "title") ]), _ctx.content || _ctx.$slots.content ? (openBlock(), createElementBlock("view", _hoisted_8, [ !_ctx.$slots.content ? (openBlock(), createElementBlock("span", { key: 0, innerHTML: _ctx.content }, null, 8, _hoisted_9)) : createCommentVNode("", true), renderSlot(_ctx.$slots, "content") ])) : createCommentVNode("", true) ]) ], 2); } const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { index as default };