1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var index$1 = require('../../icon/index.js');
var iconsVue = require('@element-plus/icons-vue');
require('../../../hooks/index.js');
require('../../../utils/index.js');
var progress = require('./progress2.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
var shared = require('@vue/shared');
const _hoisted_1 = ["aria-valuenow"];
const _hoisted_2 = { viewBox: "0 0 100 100" };
const _hoisted_3 = ["d", "stroke", "stroke-linecap", "stroke-width"];
const _hoisted_4 = ["d", "stroke", "opacity", "stroke-linecap", "stroke-width"];
const _hoisted_5 = { key: 0 };
const __default__ = vue.defineComponent({
name: "ElProgress"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: progress.progressProps,
setup(__props) {
const props = __props;
const STATUS_COLOR_MAP = {
success: "#13ce66",
exception: "#ff4949",
warning: "#e6a23c",
default: "#20a0ff"
};
const ns = index.useNamespace("progress");
const barStyle = vue.computed(() => ({
width: `${props.percentage}%`,
animationDuration: `${props.duration}s`,
background: getCurrentColor(props.percentage)
}));
const relativeStrokeWidth = vue.computed(() => (props.strokeWidth / props.width * 100).toFixed(1));
const radius = vue.computed(() => {
if (["circle", "dashboard"].includes(props.type)) {
return Number.parseInt(`${50 - Number.parseFloat(relativeStrokeWidth.value) / 2}`, 10);
}
return 0;
});
const trackPath = vue.computed(() => {
const r = radius.value;
const isDashboard = props.type === "dashboard";
return `
M 50 50
m 0 ${isDashboard ? "" : "-"}${r}
a ${r} ${r} 0 1 1 0 ${isDashboard ? "-" : ""}${r * 2}
a ${r} ${r} 0 1 1 0 ${isDashboard ? "" : "-"}${r * 2}
`;
});
const perimeter = vue.computed(() => 2 * Math.PI * radius.value);
const rate = vue.computed(() => props.type === "dashboard" ? 0.75 : 1);
const strokeDashoffset = vue.computed(() => {
const offset = -1 * perimeter.value * (1 - rate.value) / 2;
return `${offset}px`;
});
const trailPathStyle = vue.computed(() => ({
strokeDasharray: `${perimeter.value * rate.value}px, ${perimeter.value}px`,
strokeDashoffset: strokeDashoffset.value
}));
const circlePathStyle = vue.computed(() => ({
strokeDasharray: `${perimeter.value * rate.value * (props.percentage / 100)}px, ${perimeter.value}px`,
strokeDashoffset: strokeDashoffset.value,
transition: "stroke-dasharray 0.6s ease 0s, stroke 0.6s ease, opacity ease 0.6s"
}));
const stroke = vue.computed(() => {
let ret;
if (props.color) {
ret = getCurrentColor(props.percentage);
} else {
ret = STATUS_COLOR_MAP[props.status] || STATUS_COLOR_MAP.default;
}
return ret;
});
const statusIcon = vue.computed(() => {
if (props.status === "warning") {
return iconsVue.WarningFilled;
}
if (props.type === "line") {
return props.status === "success" ? iconsVue.CircleCheck : iconsVue.CircleClose;
} else {
return props.status === "success" ? iconsVue.Check : iconsVue.Close;
}
});
const progressTextSize = vue.computed(() => {
return props.type === "line" ? 12 + props.strokeWidth * 0.4 : props.width * 0.111111 + 2;
});
const content = vue.computed(() => props.format(props.percentage));
function getColors(color) {
const span = 100 / color.length;
const seriesColors = color.map((seriesColor, index) => {
if (shared.isString(seriesColor)) {
return {
color: seriesColor,
percentage: (index + 1) * span
};
}
return seriesColor;
});
return seriesColors.sort((a, b) => a.percentage - b.percentage);
}
const getCurrentColor = (percentage) => {
var _a;
const { color } = props;
if (shared.isFunction(color)) {
return color(percentage);
} else if (shared.isString(color)) {
return color;
} else {
const colors = getColors(color);
for (const color2 of colors) {
if (color2.percentage > percentage)
return color2.color;
}
return (_a = colors[colors.length - 1]) == null ? void 0 : _a.color;
}
};
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass([
vue.unref(ns).b(),
vue.unref(ns).m(_ctx.type),
vue.unref(ns).is(_ctx.status),
{
[vue.unref(ns).m("without-text")]: !_ctx.showText,
[vue.unref(ns).m("text-inside")]: _ctx.textInside
}
]),
role: "progressbar",
"aria-valuenow": _ctx.percentage,
"aria-valuemin": "0",
"aria-valuemax": "100"
}, [
_ctx.type === "line" ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass(vue.unref(ns).b("bar"))
}, [
vue.createElementVNode("div", {
class: vue.normalizeClass(vue.unref(ns).be("bar", "outer")),
style: vue.normalizeStyle({ height: `${_ctx.strokeWidth}px` })
}, [
vue.createElementVNode("div", {
class: vue.normalizeClass([
vue.unref(ns).be("bar", "inner"),
{ [vue.unref(ns).bem("bar", "inner", "indeterminate")]: _ctx.indeterminate },
{ [vue.unref(ns).bem("bar", "inner", "striped")]: _ctx.striped },
{ [vue.unref(ns).bem("bar", "inner", "striped-flow")]: _ctx.stripedFlow }
]),
style: vue.normalizeStyle(vue.unref(barStyle))
}, [
(_ctx.showText || _ctx.$slots.default) && _ctx.textInside ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass(vue.unref(ns).be("bar", "innerText"))
}, [
vue.renderSlot(_ctx.$slots, "default", { percentage: _ctx.percentage }, () => [
vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(content)), 1)
])
], 2)) : vue.createCommentVNode("v-if", true)
], 6)
], 6)
], 2)) : (vue.openBlock(), vue.createElementBlock("div", {
key: 1,
class: vue.normalizeClass(vue.unref(ns).b("circle")),
style: vue.normalizeStyle({ height: `${_ctx.width}px`, width: `${_ctx.width}px` })
}, [
(vue.openBlock(), vue.createElementBlock("svg", _hoisted_2, [
vue.createElementVNode("path", {
class: vue.normalizeClass(vue.unref(ns).be("circle", "track")),
d: vue.unref(trackPath),
stroke: `var(${vue.unref(ns).cssVarName("fill-color-light")}, #e5e9f2)`,
"stroke-linecap": _ctx.strokeLinecap,
"stroke-width": vue.unref(relativeStrokeWidth),
fill: "none",
style: vue.normalizeStyle(vue.unref(trailPathStyle))
}, null, 14, _hoisted_3),
vue.createElementVNode("path", {
class: vue.normalizeClass(vue.unref(ns).be("circle", "path")),
d: vue.unref(trackPath),
stroke: vue.unref(stroke),
fill: "none",
opacity: _ctx.percentage ? 1 : 0,
"stroke-linecap": _ctx.strokeLinecap,
"stroke-width": vue.unref(relativeStrokeWidth),
style: vue.normalizeStyle(vue.unref(circlePathStyle))
}, null, 14, _hoisted_4)
]))
], 6)),
(_ctx.showText || _ctx.$slots.default) && !_ctx.textInside ? (vue.openBlock(), vue.createElementBlock("div", {
key: 2,
class: vue.normalizeClass(vue.unref(ns).e("text")),
style: vue.normalizeStyle({ fontSize: `${vue.unref(progressTextSize)}px` })
}, [
vue.renderSlot(_ctx.$slots, "default", { percentage: _ctx.percentage }, () => [
!_ctx.status ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_5, vue.toDisplayString(vue.unref(content)), 1)) : (vue.openBlock(), vue.createBlock(vue.unref(index$1.ElIcon), { key: 1 }, {
default: vue.withCtx(() => [
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(statusIcon))))
]),
_: 1
}))
])
], 6)) : vue.createCommentVNode("v-if", true)
], 10, _hoisted_1);
};
}
});
var Progress = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "progress.vue"]]);
exports["default"] = Progress;
//# sourceMappingURL=progress.js.map