tdesign-vue
Version:
288 lines (280 loc) • 11.9 kB
JavaScript
/**
* tdesign v1.12.1
* (c) 2025 tdesign
* @license MIT
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var _typeof = require('@babel/runtime/helpers/typeof');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var tdesignIconsVue = require('tdesign-icons-vue');
var utils_helper = require('../utils/helper.js');
var progress_constants = require('./constants.js');
var progress_props = require('./props.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var configProvider_configReceiver = require('../config-provider/config-receiver.js');
var utils_mixins = require('../utils/mixins.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('../_chunks/dep-bf70543d.js');
require('../_chunks/dep-f895c884.js');
require('../_chunks/dep-e1cc6f64.js');
require('../_chunks/dep-5ea2b00f.js');
require('../_chunks/dep-9b72cbc5.js');
require('../_chunks/dep-7b78e8c3.js');
require('../_chunks/dep-d7270eaf.js');
require('../_chunks/dep-68f48b50.js');
require('../_chunks/dep-051ce30d.js');
require('../_chunks/dep-4b30bfe2.js');
require('@babel/runtime/helpers/readOnlyError');
require('vue');
require('@vue/composition-api');
require('../_chunks/dep-727a349e.js');
require('../_chunks/dep-6247fdbf.js');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-3ed0c42e.js');
require('../_chunks/dep-53935099.js');
require('dayjs');
require('../_chunks/dep-403352a7.js');
require('../_chunks/dep-cca66fee.js');
require('../_chunks/dep-4361b357.js');
require('../_chunks/dep-887c649b.js');
require('../_chunks/dep-411a10dd.js');
require('../_chunks/dep-51fe98f1.js');
require('../_chunks/dep-3d682642.js');
require('../_chunks/dep-dea23841.js');
require('../_chunks/dep-4aa08166.js');
require('../_chunks/dep-ddc1429e.js');
require('../_chunks/dep-65896ff9.js');
require('../_chunks/dep-b65b2f55.js');
require('../_chunks/dep-6e7b8cda.js');
require('../_chunks/dep-98f48ff2.js');
require('../_chunks/dep-80e3757f.js');
require('../_chunks/dep-08d7842c.js');
require('../_chunks/dep-1ca3138c.js');
require('../_chunks/dep-e6ed4b1f.js');
require('../_chunks/dep-c44b2462.js');
require('../_common/js/global-config/t.js');
require('../_chunks/dep-6b60413b.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var classPrefixMixins = configProvider_configReceiver.getClassPrefixMixins("progress");
var _Progress = utils_mixins["default"](classPrefixMixins, configProvider_configReceiver.getGlobalIconMixins()).extend({
name: "TProgress",
props: _objectSpread({}, progress_props["default"]),
computed: {
statusStyle: function statusStyle() {
if (!this.status && this.percentage >= 100) {
return "success";
}
return this.status;
},
themeClass: function themeClass() {
var Line = progress_constants.PRO_THEME.LINE;
if (this.theme === Line) {
return "thin";
}
return this.theme;
},
trackBgStyle: function trackBgStyle() {
var strokeWidth = this.strokeWidth;
var height = typeof strokeWidth === "string" ? strokeWidth : "".concat(strokeWidth, "px");
var Plump = progress_constants.PRO_THEME.PLUMP;
if (this.theme === Plump) {
height = "";
}
return {
height: height,
backgroundColor: this.trackColor,
borderRadius: height
};
},
circleStrokeStyle: function circleStrokeStyle() {
return {
stroke: this.trackColor
};
},
barStyle: function barStyle() {
return {
width: "".concat(this.percentage, "%"),
background: this.color && utils_helper.getBackgroundColor(this.color)
};
},
circlePathStyle: function circlePathStyle() {
var strokeColor = _typeof__default["default"](this.color) === "object" ? "" : this.color;
return {
stroke: strokeColor
};
},
isShowIcon: function isShowIcon() {
return progress_constants.STATUS_ICON.includes(this.status) && typeof this.label === "boolean";
},
diameter: function diameter() {
var diameter = progress_constants.CIRCLE_SIZE_PX.MEDIUM;
if (!this.size) {
return diameter;
}
var SMALL = progress_constants.CIRCLE_SIZE.SMALL,
LARGE = progress_constants.CIRCLE_SIZE.LARGE,
MEDIUM = progress_constants.CIRCLE_SIZE.MEDIUM;
switch (this.size) {
case SMALL:
diameter = progress_constants.CIRCLE_SIZE_PX.SMALL;
break;
case MEDIUM:
diameter = progress_constants.CIRCLE_SIZE_PX.MEDIUM;
break;
case LARGE:
diameter = progress_constants.CIRCLE_SIZE_PX.LARGE;
break;
default:
diameter = Number(this.size);
break;
}
return diameter;
},
rPoints: function rPoints() {
return this.diameter / 2;
},
radius: function radius() {
return this.rPoints - this.circleStrokeWidth / 2;
},
circleStyle: function circleStyle() {
if (this.theme !== progress_constants.PRO_THEME.CIRCLE) {
return {};
}
var fontSize = this.diameter * progress_constants.CIRCLE_FONT_SIZE_RATIO.MEDIUM;
if (this.diameter <= progress_constants.CIRCLE_SIZE_PX.SMALL) {
fontSize = this.diameter * progress_constants.CIRCLE_FONT_SIZE_RATIO.SMALL;
} else if (this.diameter >= progress_constants.CIRCLE_SIZE_PX.LARGE) {
fontSize = this.diameter * progress_constants.CIRCLE_FONT_SIZE_RATIO.LARGE;
}
return {
width: "".concat(this.diameter, "px"),
height: "".concat(this.diameter, "px"),
fontSize: "".concat(fontSize, "px")
};
},
circleStrokeWidth: function circleStrokeWidth() {
var defaultWidth = this.size === progress_constants.CIRCLE_SIZE.SMALL ? 4 : 6;
return this.strokeWidth ? Number(this.strokeWidth) : defaultWidth;
},
strokeDashArr: function strokeDashArr() {
var radius = (this.diameter - this.circleStrokeWidth) / 2;
var perimeter = Math.PI * 2 * radius;
var percent = this.percentage / 100;
return "".concat(perimeter * percent, " ").concat(perimeter * (1 - percent));
},
plumpStyles: function plumpStyles() {
return {};
}
},
methods: {
getIconMap: function getIconMap() {
var _this$useGlobalIcon = this.useGlobalIcon({
CloseCircleFilledIcon: tdesignIconsVue.CloseCircleFilledIcon,
CheckCircleFilledIcon: tdesignIconsVue.CheckCircleFilledIcon,
ErrorCircleFilledIcon: tdesignIconsVue.ErrorCircleFilledIcon,
CloseIcon: tdesignIconsVue.CloseIcon,
CheckIcon: tdesignIconsVue.CheckIcon,
ErrorIcon: tdesignIconsVue.ErrorIcon
}),
CloseCircleFilledIcon = _this$useGlobalIcon.CloseCircleFilledIcon,
CheckCircleFilledIcon = _this$useGlobalIcon.CheckCircleFilledIcon,
ErrorCircleFilledIcon = _this$useGlobalIcon.ErrorCircleFilledIcon,
CloseIcon = _this$useGlobalIcon.CloseIcon,
CheckIcon = _this$useGlobalIcon.CheckIcon,
ErrorIcon = _this$useGlobalIcon.ErrorIcon;
var CIRCLE_ICONS = {
success: CheckIcon,
warning: ErrorIcon,
error: CloseIcon
};
var NORMAL_ICONS = {
success: CheckCircleFilledIcon,
warning: ErrorCircleFilledIcon,
error: CloseCircleFilledIcon
};
return this.theme === progress_constants.PRO_THEME.CIRCLE ? CIRCLE_ICONS : NORMAL_ICONS;
},
getLabelContent: function getLabelContent() {
var h = this.$createElement;
var labelContent = "".concat(this.percentage, "%");
var status = this.status || "";
if (progress_constants.STATUS_ICON.includes(status) && this.theme !== progress_constants.PRO_THEME.PLUMP) {
var components = this.getIconMap();
var component = components[status];
if (component) {
labelContent = h(component, {
"class": ["".concat(this.componentName, "__icon")]
});
}
}
return labelContent;
}
},
render: function render() {
var h = arguments[0];
var labelContent = h("div", {
"class": "".concat(this.componentName, "__info")
}, [utils_renderTnode.renderTNodeJSX(this, "label", this.getLabelContent())]);
var PLUMP_SEPARATE = 10;
var separateClasses = this.percentage > PLUMP_SEPARATE ? "".concat(this.componentName, "--over-ten") : "".concat(this.componentName, "--under-ten");
return h("div", {
"class": this.componentName
}, [this.theme === progress_constants.PRO_THEME.LINE && h("div", {
"class": "".concat(this.componentName, "--thin ").concat(this.componentName, "--status--").concat(this.statusStyle)
}, [h("div", {
"class": "".concat(this.componentName, "__bar"),
"style": this.trackBgStyle
}, [h("div", {
"class": "".concat(this.componentName, "__inner"),
"style": this.barStyle
})]), labelContent]), this.theme === progress_constants.PRO_THEME.PLUMP && h("div", {
"class": ["".concat(this.componentName, "__bar ").concat(this.componentName, "--plump ").concat(separateClasses), _defineProperty__default["default"]({}, "".concat(this.componentName, "--status--").concat(this.statusStyle), this.statusStyle)],
"style": this.trackBgStyle
}, [h("div", {
"class": "".concat(this.componentName, "__inner"),
"style": this.barStyle
}, [this.percentage > PLUMP_SEPARATE && labelContent]), this.percentage <= PLUMP_SEPARATE && labelContent]), this.theme === progress_constants.PRO_THEME.CIRCLE && h("div", {
"class": "".concat(this.componentName, "--circle ").concat(this.componentName, "--status--").concat(this.statusStyle),
"style": this.circleStyle
}, [labelContent, h("svg", {
"attrs": {
"width": this.diameter,
"height": this.diameter,
"viewBox": "0 0 ".concat(this.diameter, " ").concat(this.diameter)
}
}, [h("circle", {
"attrs": {
"cx": this.rPoints,
"cy": this.rPoints,
"r": this.radius,
"stroke-width": this.circleStrokeWidth,
"stroke": this.trackColor,
"fill": "none"
},
"class": "".concat(this.componentName, "__circle-outer"),
"style": this.circleStrokeStyle
}), this.percentage > 0 && h("circle", {
"attrs": {
"cx": this.rPoints,
"cy": this.rPoints,
"r": this.radius,
"stroke-width": this.circleStrokeWidth,
"fill": "none",
"stroke-linecap": "round",
"transform": "matrix(0,-1,1,0,0,".concat(this.diameter, ")"),
"stroke-dasharray": this.strokeDashArr
},
"class": "".concat(this.componentName, "__circle-inner"),
"style": this.circlePathStyle
})])])]);
}
});
exports["default"] = _Progress;
//# sourceMappingURL=progress.js.map