refactor: progress
parent
a0d9372f46
commit
25eea2a63b
|
@ -1,17 +1,12 @@
|
||||||
import type { CSSProperties, ExtractPropTypes } from 'vue';
|
import type { CSSProperties } from 'vue';
|
||||||
import { computed, defineComponent } from 'vue';
|
import { computed, defineComponent } from 'vue';
|
||||||
import { presetPrimaryColors } from '@ant-design/colors';
|
import { presetPrimaryColors } from '@ant-design/colors';
|
||||||
import { Circle as VCCircle } from '../vc-progress';
|
import { Circle as VCCircle } from '../vc-progress';
|
||||||
import { getSuccessPercent, validProgress } from './utils';
|
import { getSuccessPercent, validProgress } from './utils';
|
||||||
|
import type { ProgressProps } from './props';
|
||||||
import { progressProps } from './props';
|
import { progressProps } from './props';
|
||||||
import PropTypes from '../_util/vue-types';
|
|
||||||
|
|
||||||
const circleProps = {
|
export type CircleProps = ProgressProps;
|
||||||
...progressProps,
|
|
||||||
prefixCls: PropTypes.string,
|
|
||||||
// progressStatus: PropTypes.string,
|
|
||||||
};
|
|
||||||
export type CircleProps = Partial<ExtractPropTypes<typeof circleProps>>;
|
|
||||||
|
|
||||||
function getPercentage({ percent, success, successPercent }: CircleProps) {
|
function getPercentage({ percent, success, successPercent }: CircleProps) {
|
||||||
const realSuccessPercent = validProgress(getSuccessPercent({ success, successPercent }));
|
const realSuccessPercent = validProgress(getSuccessPercent({ success, successPercent }));
|
||||||
|
@ -19,8 +14,8 @@ function getPercentage({ percent, success, successPercent }: CircleProps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: progressProps,
|
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
props: progressProps(),
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const gapDeg = computed(() => {
|
const gapDeg = computed(() => {
|
||||||
// Support gapDeg = 0 when type = 'dashboard'
|
// Support gapDeg = 0 when type = 'dashboard'
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { progressProps } from './props';
|
||||||
import { getSuccessPercent, validProgress } from './utils';
|
import { getSuccessPercent, validProgress } from './utils';
|
||||||
|
|
||||||
const lineProps = {
|
const lineProps = {
|
||||||
...progressProps,
|
...progressProps(),
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
direction: {
|
direction: {
|
||||||
type: String as PropType<Direction>,
|
type: String as PropType<Direction>,
|
||||||
|
@ -68,8 +68,8 @@ export const handleGradient = (strokeColor: ProgressGradient, directionConfig: D
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: lineProps,
|
|
||||||
name: 'Line',
|
name: 'Line',
|
||||||
|
props: lineProps,
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const backgroundProps = computed(() => {
|
const backgroundProps = computed(() => {
|
||||||
const { strokeColor, direction } = props;
|
const { strokeColor, direction } = props;
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { computed, ExtractPropTypes, PropType, VNodeChild } from 'vue';
|
import type { ExtractPropTypes, PropType, VNodeChild } from 'vue';
|
||||||
|
import { computed } from 'vue';
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import type { ProgressSize } from './props';
|
import type { ProgressSize } from './props';
|
||||||
import { progressProps } from './props';
|
import { progressProps } from './props';
|
||||||
|
|
||||||
const stepsProps = {
|
const stepsProps = {
|
||||||
...progressProps,
|
...progressProps(),
|
||||||
steps: PropTypes.number,
|
steps: PropTypes.number,
|
||||||
size: {
|
size: {
|
||||||
type: String as PropType<ProgressSize>,
|
type: String as PropType<ProgressSize>,
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { progressProps, progressStatuses } from './props';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'AProgress',
|
name: 'AProgress',
|
||||||
props: initDefaultProps(progressProps, {
|
props: initDefaultProps(progressProps(), {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
percent: 0,
|
percent: 0,
|
||||||
showInfo: true,
|
showInfo: true,
|
||||||
|
|
|
@ -17,7 +17,7 @@ export interface SuccessProps {
|
||||||
strokeColor?: string;
|
strokeColor?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const progressProps = {
|
export const progressProps = () => ({
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
type: PropTypes.oneOf(ProgressType),
|
type: PropTypes.oneOf(ProgressType),
|
||||||
percent: PropTypes.number,
|
percent: PropTypes.number,
|
||||||
|
@ -41,6 +41,6 @@ export const progressProps = {
|
||||||
steps: PropTypes.number,
|
steps: PropTypes.number,
|
||||||
/** @deprecated Use `success` instead */
|
/** @deprecated Use `success` instead */
|
||||||
successPercent: PropTypes.number,
|
successPercent: PropTypes.number,
|
||||||
};
|
});
|
||||||
|
|
||||||
export type ProgressProps = Partial<ExtractPropTypes<typeof progressProps>>;
|
export type ProgressProps = Partial<ExtractPropTypes<ReturnType<typeof progressProps>>>;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { useTransitionDuration, defaultProps } from './common';
|
import { useTransitionDuration, defaultProps } from './common';
|
||||||
import { propTypes, GapPositionType } from './types';
|
import type { GapPositionType } from './types';
|
||||||
|
import { propTypes } from './types';
|
||||||
import { computed, defineComponent, ref } from 'vue';
|
import { computed, defineComponent, ref } from 'vue';
|
||||||
import initDefaultProps from '../../_util/props-util/initDefaultProps';
|
import initDefaultProps from '../../_util/props-util/initDefaultProps';
|
||||||
import { useRef } from '../../_util/hooks/useRef';
|
import { useRef } from '../../_util/hooks/useRef';
|
||||||
|
|
2
v2-doc
2
v2-doc
|
@ -1 +1 @@
|
||||||
Subproject commit d2c096476ee3e8d27fbb9e1cb7933887501b1fab
|
Subproject commit 57c08127bf0e3e826b03f845df3e1332820964e5
|
Loading…
Reference in New Issue