UNPKG

3.5 kBJavaScriptView Raw
1import { createVNode as _createVNode } from "vue";
2
3function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
5function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
6
7import { defineComponent } from 'vue';
8import { Circle as VCCircle } from '../vc-progress';
9import PropTypes from '../_util/vue-types';
10import { validProgress } from './utils';
11import { ProgressProps } from './props';
12
13var CircleProps = _extends(_extends({}, ProgressProps), {
14 progressStatus: PropTypes.string
15});
16
17var statusColorMap = {
18 normal: '#108ee9',
19 exception: '#ff5500',
20 success: '#87d068'
21};
22
23function getPercentage(_ref) {
24 var percent = _ref.percent,
25 successPercent = _ref.successPercent;
26 var ptg = validProgress(percent);
27 if (!successPercent) return ptg;
28 var successPtg = validProgress(successPercent);
29 return [successPercent, validProgress(ptg - successPtg)];
30}
31
32function getStrokeColor(_ref2) {
33 var progressStatus = _ref2.progressStatus,
34 successPercent = _ref2.successPercent,
35 strokeColor = _ref2.strokeColor;
36 var color = strokeColor || statusColorMap[progressStatus];
37 if (!successPercent) return color;
38 return [statusColorMap.success, color];
39}
40
41var Circle = defineComponent({
42 props: CircleProps,
43 setup: function setup(props, _ref3) {
44 var slots = _ref3.slots;
45 return function () {
46 var _wrapperClassName;
47
48 var prefixCls = props.prefixCls,
49 width = props.width,
50 strokeWidth = props.strokeWidth,
51 trailColor = props.trailColor,
52 strokeLinecap = props.strokeLinecap,
53 gapPosition = props.gapPosition,
54 gapDegree = props.gapDegree,
55 type = props.type;
56 var circleSize = width || 120;
57 var circleStyle = {
58 width: typeof circleSize === 'number' ? "".concat(circleSize, "px") : circleSize,
59 height: typeof circleSize === 'number' ? "".concat(circleSize, "px") : circleSize,
60 fontSize: "".concat(circleSize * 0.15 + 6, "px")
61 };
62 var circleWidth = strokeWidth || 6;
63 var gapPos = gapPosition || type === 'dashboard' && 'bottom' || 'top';
64 var gapDeg = gapDegree || type === 'dashboard' && 75;
65 var strokeColor = getStrokeColor(props);
66 var isGradient = Object.prototype.toString.call(strokeColor) === '[object Object]';
67 var wrapperClassName = (_wrapperClassName = {}, _defineProperty(_wrapperClassName, "".concat(prefixCls, "-inner"), true), _defineProperty(_wrapperClassName, "".concat(prefixCls, "-circle-gradient"), isGradient), _wrapperClassName);
68 return _createVNode("div", {
69 "class": wrapperClassName,
70 "style": circleStyle
71 }, [_createVNode(VCCircle, {
72 "percent": getPercentage(props),
73 "strokeWidth": circleWidth,
74 "trailWidth": circleWidth,
75 "strokeColor": strokeColor,
76 "strokeLinecap": strokeLinecap,
77 "trailColor": trailColor,
78 "prefixCls": prefixCls,
79 "gapDegree": gapDeg,
80 "gapPosition": gapPos
81 }, null), slots === null || slots === void 0 ? void 0 : slots.default()]);
82 };
83 }
84});
85export default Circle;
\No newline at end of file