Skip to content

Commit 2b6715a

Browse files
committed
refactor: progress
1 parent 01fb7f1 commit 2b6715a

File tree

7 files changed

+16
-19
lines changed

7 files changed

+16
-19
lines changed

components/progress/Circle.tsx

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
import type { CSSProperties, ExtractPropTypes } from 'vue';
1+
import type { CSSProperties } from 'vue';
22
import { computed, defineComponent } from 'vue';
33
import { presetPrimaryColors } from '@ant-design/colors';
44
import { Circle as VCCircle } from '../vc-progress';
55
import { getSuccessPercent, validProgress } from './utils';
6+
import type { ProgressProps } from './props';
67
import { progressProps } from './props';
7-
import PropTypes from '../_util/vue-types';
88

9-
const circleProps = {
10-
...progressProps,
11-
prefixCls: PropTypes.string,
12-
// progressStatus: PropTypes.string,
13-
};
14-
export type CircleProps = Partial<ExtractPropTypes<typeof circleProps>>;
9+
export type CircleProps = ProgressProps;
1510

1611
function getPercentage({ percent, success, successPercent }: CircleProps) {
1712
const realSuccessPercent = validProgress(getSuccessPercent({ success, successPercent }));
1813
return [realSuccessPercent, validProgress(validProgress(percent) - realSuccessPercent)];
1914
}
2015

2116
export default defineComponent({
22-
props: progressProps,
2317
inheritAttrs: false,
18+
props: progressProps(),
2419
setup(props, { slots }) {
2520
const gapDeg = computed(() => {
2621
// Support gapDeg = 0 when type = 'dashboard'

components/progress/Line.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { progressProps } from './props';
77
import { getSuccessPercent, validProgress } from './utils';
88

99
const lineProps = {
10-
...progressProps,
10+
...progressProps(),
1111
prefixCls: PropTypes.string,
1212
direction: {
1313
type: String as PropType<Direction>,
@@ -68,8 +68,8 @@ export const handleGradient = (strokeColor: ProgressGradient, directionConfig: D
6868
};
6969

7070
export default defineComponent({
71-
props: lineProps,
7271
name: 'Line',
72+
props: lineProps,
7373
setup(props, { slots }) {
7474
const backgroundProps = computed(() => {
7575
const { strokeColor, direction } = props;

components/progress/Steps.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { computed, ExtractPropTypes, PropType, VNodeChild } from 'vue';
1+
import type { ExtractPropTypes, PropType, VNodeChild } from 'vue';
2+
import { computed } from 'vue';
23
import { defineComponent } from 'vue';
34
import PropTypes from '../_util/vue-types';
45
import type { ProgressSize } from './props';
56
import { progressProps } from './props';
67

78
const stepsProps = {
8-
...progressProps,
9+
...progressProps(),
910
steps: PropTypes.number,
1011
size: {
1112
type: String as PropType<ProgressSize>,

components/progress/progress.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { progressProps, progressStatuses } from './props';
1515

1616
export default defineComponent({
1717
name: 'AProgress',
18-
props: initDefaultProps(progressProps, {
18+
props: initDefaultProps(progressProps(), {
1919
type: 'line',
2020
percent: 0,
2121
showInfo: true,

components/progress/props.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface SuccessProps {
1717
strokeColor?: string;
1818
}
1919

20-
export const progressProps = {
20+
export const progressProps = () => ({
2121
prefixCls: PropTypes.string,
2222
type: PropTypes.oneOf(ProgressType),
2323
percent: PropTypes.number,
@@ -41,6 +41,6 @@ export const progressProps = {
4141
steps: PropTypes.number,
4242
/** @deprecated Use `success` instead */
4343
successPercent: PropTypes.number,
44-
};
44+
});
4545

46-
export type ProgressProps = Partial<ExtractPropTypes<typeof progressProps>>;
46+
export type ProgressProps = Partial<ExtractPropTypes<ReturnType<typeof progressProps>>>;

components/vc-progress/src/Circle.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useTransitionDuration, defaultProps } from './common';
2-
import { propTypes, GapPositionType } from './types';
2+
import type { GapPositionType } from './types';
3+
import { propTypes } from './types';
34
import { computed, defineComponent, ref } from 'vue';
45
import initDefaultProps from '../../_util/props-util/initDefaultProps';
56
import { useRef } from '../../_util/hooks/useRef';

v2-doc

0 commit comments

Comments
 (0)