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
19 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, normalizeStyle, renderSlot, toDisplayString, createCommentVNode, createBlock, withCtx, resolveDynamicComponent } from 'vue';\nimport { ElIcon } from '../../icon/index.mjs';\nimport { WarningFilled, CircleCheck, CircleClose, Check, Close } from '@element-plus/icons-vue';\nimport { progressProps } from './progress.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { isFunction, isString } from '@vue/shared';\nconst __default__ = defineComponent({\n name: \"ElProgress\"\n});\nconst _sfc_main = /* @__PURE__ */defineComponent({\n ...__default__,\n props: progressProps,\n setup(__props) {\n const props = __props;\n const STATUS_COLOR_MAP = {\n success: \"#13ce66\",\n exception: \"#ff4949\",\n warning: \"#e6a23c\",\n default: \"#20a0ff\"\n };\n const ns = useNamespace(\"progress\");\n const barStyle = computed(() => {\n const barStyle2 = {\n width: `${props.percentage}%`,\n animationDuration: `${props.duration}s`\n };\n const color = getCurrentColor(props.percentage);\n if (color.includes(\"gradient\")) {\n barStyle2.background = color;\n } else {\n barStyle2.backgroundColor = color;\n }\n return barStyle2;\n });\n const relativeStrokeWidth = computed(() => (props.strokeWidth / props.width * 100).toFixed(1));\n const radius = computed(() => {\n if ([\"circle\", \"dashboard\"].includes(props.type)) {\n return Number.parseInt(`${50 - Number.parseFloat(relativeStrokeWidth.value) / 2}`, 10);\n }\n return 0;\n });\n const trackPath = computed(() => {\n const r = radius.value;\n const isDashboard = props.type === \"dashboard\";\n return `\n M 50 50\n m 0 ${isDashboard ? \"\" : \"-\"}${r}\n a ${r} ${r} 0 1 1 0 ${isDashboard ? \"-\" : \"\"}${r * 2}\n a ${r} ${r} 0 1 1 0 ${isDashboard ? \"\" : \"-\"}${r * 2}\n `;\n });\n const perimeter = computed(() => 2 * Math.PI * radius.value);\n const rate = computed(() => props.type === \"dashboard\" ? 0.75 : 1);\n const strokeDashoffset = computed(() => {\n const offset = -1 * perimeter.value * (1 - rate.value) / 2;\n return `${offset}px`;\n });\n const trailPathStyle = computed(() => ({\n strokeDasharray: `${perimeter.value * rate.value}px, ${perimeter.value}px`,\n strokeDashoffset: strokeDashoffset.value\n }));\n const circlePathStyle = computed(() => ({\n strokeDasharray: `${perimeter.value * rate.value * (props.percentage / 100)}px, ${perimeter.value}px`,\n strokeDashoffset: strokeDashoffset.value,\n transition: \"stroke-dasharray 0.6s ease 0s, stroke 0.6s ease, opacity ease 0.6s\"\n }));\n const stroke = computed(() => {\n let ret;\n if (props.color) {\n ret = getCurrentColor(props.percentage);\n } else {\n ret = STATUS_COLOR_MAP[props.status] || STATUS_COLOR_MAP.default;\n }\n return ret;\n });\n const statusIcon = computed(() => {\n if (props.status === \"warning\") {\n return WarningFilled;\n }\n if (props.type === \"line\") {\n return props.status === \"success\" ? CircleCheck : CircleClose;\n } else {\n return props.status === \"success\" ? Check : Close;\n }\n });\n const progressTextSize = computed(() => {\n return props.type === \"line\" ? 12 + props.strokeWidth * 0.4 : props.width * 0.111111 + 2;\n });\n const content = computed(() => props.format(props.percentage));\n function getColors(color) {\n const span = 100 / color.length;\n const seriesColors = color.map((seriesColor, index) => {\n if (isString(seriesColor)) {\n return {\n color: seriesColor,\n percentage: (index + 1) * span\n };\n }\n return seriesC