import { defineComponent, inject } from 'vue';
import classNames from '../_util/classNames';
import { getOptionProps } from '../_util/props-util';
import initDefaultProps from '../_util/props-util/initDefaultProps';
import { defaultConfigProvider } from '../config-provider';
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
import CheckOutlined from '@ant-design/icons-vue/CheckOutlined';
import CheckCircleFilled from '@ant-design/icons-vue/CheckCircleFilled';
import CloseCircleFilled from '@ant-design/icons-vue/CloseCircleFilled';
import Line from './line';
import Circle from './circle';
import { validProgress } from './utils';
import { ProgressProps, ProgressStatuses } from './props';
export default defineComponent({
name: 'AProgress',
props: initDefaultProps(ProgressProps, {
type: 'line',
percent: 0,
showInfo: true,
// null for different theme definition
trailColor: null,
size: 'default',
gapDegree: 0,
strokeLinecap: 'round',
}),
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
};
},
methods: {
getPercentNumber() {
const { successPercent, percent = 0 } = this.$props;
return parseInt(
successPercent !== undefined ? successPercent.toString() : percent.toString(),
10,
);
},
getProgressStatus() {
const { status } = this.$props;
if (ProgressStatuses.indexOf(status) < 0 && this.getPercentNumber() >= 100) {
return 'success';
}
return status || 'normal';
},
renderProcessInfo(prefixCls: string, progressStatus: typeof ProgressStatuses[number]) {
const { showInfo, format, type, percent, successPercent } = this.$props;
if (!showInfo) return null;
let text;
const textFormatter = format || this.$slots.format || (percentNumber => `${percentNumber}%`);
const isLineType = type === 'line';
if (
format ||
this.$slots.format ||
(progressStatus !== 'exception' && progressStatus !== 'success')
) {
text = textFormatter(validProgress(percent), validProgress(successPercent));
} else if (progressStatus === 'exception') {
text = isLineType ?