fix: progress borderRadius reactive #6409
parent
7db4265616
commit
58998c4978
|
@ -28,8 +28,8 @@ export default defineComponent({
|
||||||
props: initDefaultProps(circleProps(), {
|
props: initDefaultProps(circleProps(), {
|
||||||
trailColor: null as unknown as string,
|
trailColor: null as unknown as string,
|
||||||
}),
|
}),
|
||||||
setup(props, { slots }) {
|
setup(props, { slots, attrs }) {
|
||||||
const originWidth = computed(() => props.width || 120);
|
const originWidth = computed(() => props.width ?? 120);
|
||||||
const mergedSize = computed(() => props.size ?? [originWidth.value, originWidth.value]);
|
const mergedSize = computed(() => props.size ?? [originWidth.value, originWidth.value]);
|
||||||
|
|
||||||
const sizeRef = computed(() => getSize(mergedSize.value as ProgressProps['size'], 'circle'));
|
const sizeRef = computed(() => getSize(mergedSize.value as ProgressProps['size'], 'circle'));
|
||||||
|
@ -87,7 +87,11 @@ export default defineComponent({
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<div class={wrapperClassName.value} style={circleStyle.value}>
|
<div
|
||||||
|
{...attrs}
|
||||||
|
class={[wrapperClassName.value, attrs.class]}
|
||||||
|
style={[attrs.style as CSSProperties, circleStyle.value]}
|
||||||
|
>
|
||||||
{sizeRef.value.width <= 20 ? (
|
{sizeRef.value.width <= 20 ? (
|
||||||
<Tooltip v-slots={{ title: slots.default }}>
|
<Tooltip v-slots={{ title: slots.default }}>
|
||||||
<span>{circleContent}</span>
|
<span>{circleContent}</span>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { CSSProperties, ExtractPropTypes, PropType } from 'vue';
|
import type { CSSProperties, ExtractPropTypes } from 'vue';
|
||||||
import { presetPrimaryColors } from '@ant-design/colors';
|
import { presetPrimaryColors } from '@ant-design/colors';
|
||||||
import { computed, defineComponent } from 'vue';
|
import { computed, defineComponent } from 'vue';
|
||||||
import type { Direction } from '../config-provider';
|
import type { Direction } from '../config-provider';
|
||||||
|
@ -6,14 +6,12 @@ import type { StringGradients, ProgressGradient, ProgressSize } from './props';
|
||||||
import { progressProps } from './props';
|
import { progressProps } from './props';
|
||||||
import { getSize, getSuccessPercent, validProgress } from './utils';
|
import { getSize, getSuccessPercent, validProgress } from './utils';
|
||||||
import devWarning from '../vc-util/devWarning';
|
import devWarning from '../vc-util/devWarning';
|
||||||
import { anyType } from '../_util/type';
|
import { anyType, stringType } from '../_util/type';
|
||||||
|
|
||||||
export const lineProps = () => ({
|
export const lineProps = () => ({
|
||||||
...progressProps(),
|
...progressProps(),
|
||||||
strokeColor: anyType<string | ProgressGradient>(),
|
strokeColor: anyType<string | ProgressGradient>(),
|
||||||
direction: {
|
direction: stringType<Direction>(),
|
||||||
type: String as PropType<Direction>,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type LineProps = Partial<ExtractPropTypes<ReturnType<typeof lineProps>>>;
|
export type LineProps = Partial<ExtractPropTypes<ReturnType<typeof lineProps>>>;
|
||||||
|
@ -86,8 +84,9 @@ export default defineComponent({
|
||||||
backgroundColor: strokeColor as string,
|
backgroundColor: strokeColor as string,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const borderRadius =
|
const borderRadius = computed(() =>
|
||||||
props.strokeLinecap === 'square' || props.strokeLinecap === 'butt' ? 0 : undefined;
|
props.strokeLinecap === 'square' || props.strokeLinecap === 'butt' ? 0 : undefined,
|
||||||
|
);
|
||||||
|
|
||||||
const trailStyle = computed<CSSProperties>(() =>
|
const trailStyle = computed<CSSProperties>(() =>
|
||||||
props.trailColor
|
props.trailColor
|
||||||
|
@ -118,7 +117,7 @@ export default defineComponent({
|
||||||
return {
|
return {
|
||||||
width: `${validProgress(percent)}%`,
|
width: `${validProgress(percent)}%`,
|
||||||
height: `${sizeRef.value.height}px`,
|
height: `${sizeRef.value.height}px`,
|
||||||
borderRadius,
|
borderRadius: borderRadius.value,
|
||||||
...backgroundProps.value,
|
...backgroundProps.value,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -131,7 +130,7 @@ export default defineComponent({
|
||||||
return {
|
return {
|
||||||
width: `${validProgress(successPercent.value)}%`,
|
width: `${validProgress(successPercent.value)}%`,
|
||||||
height: `${sizeRef.value.height}px`,
|
height: `${sizeRef.value.height}px`,
|
||||||
borderRadius,
|
borderRadius: borderRadius.value,
|
||||||
backgroundColor: success?.strokeColor,
|
backgroundColor: success?.strokeColor,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -143,7 +142,11 @@ export default defineComponent({
|
||||||
|
|
||||||
return () => (
|
return () => (
|
||||||
<>
|
<>
|
||||||
<div {...attrs} class={[`${props.prefixCls}-outer`, attrs.class]} style={outerStyle}>
|
<div
|
||||||
|
{...attrs}
|
||||||
|
class={[`${props.prefixCls}-outer`, attrs.class]}
|
||||||
|
style={[attrs.style as CSSProperties, outerStyle]}
|
||||||
|
>
|
||||||
<div class={`${props.prefixCls}-inner`} style={trailStyle.value}>
|
<div class={`${props.prefixCls}-inner`} style={trailStyle.value}>
|
||||||
<div class={`${props.prefixCls}-bg`} style={percentStyle.value} />
|
<div class={`${props.prefixCls}-bg`} style={percentStyle.value} />
|
||||||
{successPercent.value !== undefined ? (
|
{successPercent.value !== undefined ? (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { ExtractPropTypes, PropType } from 'vue';
|
import type { ExtractPropTypes } from 'vue';
|
||||||
import { computed, defineComponent } from 'vue';
|
import { computed, defineComponent } from 'vue';
|
||||||
import type { VueNode } from '../_util/type';
|
import type { VueNode } from '../_util/type';
|
||||||
import PropTypes from '../_util/vue-types';
|
import { someType } from '../_util/type';
|
||||||
import type { ProgressSize } from './props';
|
import type { ProgressSize } from './props';
|
||||||
import { progressProps } from './props';
|
import { progressProps } from './props';
|
||||||
import { getSize } from './utils';
|
import { getSize } from './utils';
|
||||||
|
@ -9,10 +9,7 @@ import { getSize } from './utils';
|
||||||
export const stepsProps = () => ({
|
export const stepsProps = () => ({
|
||||||
...progressProps(),
|
...progressProps(),
|
||||||
steps: Number,
|
steps: Number,
|
||||||
size: {
|
strokeColor: someType<string | string[]>(),
|
||||||
type: String as PropType<ProgressSize>,
|
|
||||||
},
|
|
||||||
strokeColor: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
|
||||||
trailColor: String,
|
trailColor: String,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
import type { VueNode } from '../_util/type';
|
import type { VueNode } from '../_util/type';
|
||||||
import { someType, functionType, stringType, anyType, objectType } from '../_util/type';
|
import {
|
||||||
|
booleanType,
|
||||||
|
someType,
|
||||||
|
functionType,
|
||||||
|
stringType,
|
||||||
|
anyType,
|
||||||
|
objectType,
|
||||||
|
} from '../_util/type';
|
||||||
import type { ExtractPropTypes } from 'vue';
|
import type { ExtractPropTypes } from 'vue';
|
||||||
|
|
||||||
export const progressStatuses = ['normal', 'exception', 'active', 'success'] as const;
|
export const progressStatuses = ['normal', 'exception', 'active', 'success'] as const;
|
||||||
|
@ -25,7 +32,7 @@ export const progressProps = () => ({
|
||||||
percent: Number,
|
percent: Number,
|
||||||
format: functionType<(percent?: number, successPercent?: number) => VueNode>(),
|
format: functionType<(percent?: number, successPercent?: number) => VueNode>(),
|
||||||
status: stringType<ProgressStatusesType>(),
|
status: stringType<ProgressStatusesType>(),
|
||||||
showInfo: { type: Boolean, default: undefined },
|
showInfo: booleanType(),
|
||||||
strokeWidth: Number,
|
strokeWidth: Number,
|
||||||
strokeLinecap: stringType<'butt' | 'square' | 'round'>(),
|
strokeLinecap: stringType<'butt' | 'square' | 'round'>(),
|
||||||
strokeColor: anyType<string | string[] | ProgressGradient>(),
|
strokeColor: anyType<string | string[] | ProgressGradient>(),
|
||||||
|
@ -35,7 +42,7 @@ export const progressProps = () => ({
|
||||||
success: objectType<SuccessProps>(),
|
success: objectType<SuccessProps>(),
|
||||||
gapDegree: Number,
|
gapDegree: Number,
|
||||||
gapPosition: stringType<'top' | 'bottom' | 'left' | 'right'>(),
|
gapPosition: stringType<'top' | 'bottom' | 'left' | 'right'>(),
|
||||||
size: someType<ProgressSize>([String, Number, Array]),
|
size: someType<ProgressSize | number | [number, number]>([String, Number, Array]),
|
||||||
steps: Number,
|
steps: Number,
|
||||||
/** @deprecated Use `success` instead */
|
/** @deprecated Use `success` instead */
|
||||||
successPercent: Number,
|
successPercent: Number,
|
||||||
|
|
Loading…
Reference in New Issue