You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
17 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, ref, inject, getCurrentInstance, onMounted, watch, onBeforeUnmount, computed, reactive, openBlock, createElementBlock, normalizeStyle, unref, normalizeClass, createCommentVNode, createElementVNode, renderSlot, createBlock, withCtx, resolveDynamicComponent, createVNode, toDisplayString, createTextVNode } from 'vue';\nimport { ElIcon } from '../../icon/index.mjs';\nimport { Check, Close } from '@element-plus/icons-vue';\nimport { stepProps } from './item.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { isNumber } from '../../../utils/types.mjs';\nconst __default__ = defineComponent({\n name: \"ElStep\"\n});\nconst _sfc_main = defineComponent({\n ...__default__,\n props: stepProps,\n setup(__props) {\n const props = __props;\n const ns = useNamespace(\"step\");\n const index = ref(-1);\n const lineStyle = ref({});\n const internalStatus = ref(\"\");\n const parent = inject(\"ElSteps\");\n const currentInstance = getCurrentInstance();\n onMounted(() => {\n watch([() => parent.props.active, () => parent.props.processStatus, () => parent.props.finishStatus], ([active]) => {\n updateStatus(active);\n }, {\n immediate: true\n });\n });\n onBeforeUnmount(() => {\n parent.removeStep(stepItemState.uid);\n });\n const currentStatus = computed(() => {\n return props.status || internalStatus.value;\n });\n const prevStatus = computed(() => {\n const prevStep = parent.steps.value[index.value - 1];\n return prevStep ? prevStep.currentStatus : \"wait\";\n });\n const isCenter = computed(() => {\n return parent.props.alignCenter;\n });\n const isVertical = computed(() => {\n return parent.props.direction === \"vertical\";\n });\n const isSimple = computed(() => {\n return parent.props.simple;\n });\n const stepsCount = computed(() => {\n return parent.steps.value.length;\n });\n const isLast = computed(() => {\n var _a;\n return ((_a = parent.steps.value[stepsCount.value - 1]) == null ? void 0 : _a.uid) === (currentInstance == null ? void 0 : currentInstance.uid);\n });\n const space = computed(() => {\n return isSimple.value ? \"\" : parent.props.space;\n });\n const containerKls = computed(() => {\n return [ns.b(), ns.is(isSimple.value ? \"simple\" : parent.props.direction), ns.is(\"flex\", isLast.value && !space.value && !isCenter.value), ns.is(\"center\", isCenter.value && !isVertical.value && !isSimple.value)];\n });\n const style = computed(() => {\n const style2 = {\n flexBasis: isNumber(space.value) ? `${space.value}px` : space.value ? space.value : `${100 / (stepsCount.value - (isCenter.value ? 0 : 1))}%`\n };\n if (isVertical.value) return style2;\n if (isLast.value) {\n style2.maxWidth = `${100 / stepsCount.value}%`;\n }\n return style2;\n });\n const setIndex = val => {\n index.value = val;\n };\n const calcProgress = status => {\n const isWait = status === \"wait\";\n const style2 = {\n transitionDelay: `${isWait ? \"-\" : \"\"}${150 * index.value}ms`\n };\n const step = status === parent.props.processStatus || isWait ? 0 : 100;\n style2.borderWidth = step && !isSimple.value ? \"1px\" : 0;\n style2[parent.props.direction === \"vertical\" ? \"height\" : \"width\"] = `${step}%`;\n lineStyle.value = style2;\n };\n const updateStatus = activeIndex => {\n if (activeIndex > index.value) {\n internalStatus.value = parent.props.finishStatus;\n } else if (activeIndex === index.value && prevStatus.value !== \"error\") {\n internalStatus.value = parent.props.processStatus;\n } else {\n internalStatus.value = \"wait\";\n }\n const prevChild = parent.steps.value[index.value - 1];\n if (prevChild) prevChild.calcProgress(internalStatus.value);\n