diff --git a/components/progress/index.en-US.md b/components/progress/index.en-US.md index c5e6ded3ef..023c3066e8 100644 --- a/components/progress/index.en-US.md +++ b/components/progress/index.en-US.md @@ -50,7 +50,7 @@ Properties that shared by all types. | success | Configs of successfully progress bar | { percent: number, strokeColor: string } | - | - | | trailColor | The color of unfilled part | string | - | - | | type | To set the type, options: `line` `circle` `dashboard` | string | `line` | -| size | Progress size | number \| \[number, number] \| "small" \| "default" | "default" | v5.3.0 | +| size | Progress size | number \| \[number \| string, number] \| "small" \| "default" | "default" | v5.3.0 | ### `type="line"` diff --git a/components/progress/index.zh-CN.md b/components/progress/index.zh-CN.md index 43a803350a..61a9cc9b35 100644 --- a/components/progress/index.zh-CN.md +++ b/components/progress/index.zh-CN.md @@ -51,7 +51,7 @@ demo: | success | 成功进度条相关配置 | { percent: number, strokeColor: string } | - | - | | trailColor | 未完成的分段的颜色 | string | - | - | | type | 类型,可选 `line` `circle` `dashboard` | string | `line` | - | -| size | 进度条的尺寸 | number \| \[number, number] \| "small" \| "default" | "default" | v5.3.0 | +| size | 进度条的尺寸 | number \| \[number \| string, number] \| "small" \| "default" | "default" | v5.3.0 | ### `type="line"` diff --git a/components/progress/progress.tsx b/components/progress/progress.tsx index 9f7ea96b2e..dcc31c6465 100644 --- a/components/progress/progress.tsx +++ b/components/progress/progress.tsx @@ -50,7 +50,7 @@ export interface ProgressProps extends ProgressAriaProps { style?: React.CSSProperties; gapDegree?: number; gapPosition?: 'top' | 'bottom' | 'left' | 'right'; - size?: number | [number, number] | ProgressSize; + size?: number | [number | string, number] | ProgressSize; steps?: number; /** @deprecated Use `success` instead */ successPercent?: number; diff --git a/components/progress/utils.ts b/components/progress/utils.ts index 60c5f41453..9ea719e35f 100644 --- a/components/progress/utils.ts +++ b/components/progress/utils.ts @@ -1,7 +1,7 @@ import { presetPrimaryColors } from '@ant-design/colors'; +import warning from '../_util/warning'; import type { CircleProps } from './Circle'; import type { ProgressProps } from './progress'; -import warning from '../_util/warning'; export function validProgress(progress?: number) { if (!progress || progress < 0) { @@ -35,10 +35,10 @@ export const getPercentage = ({ percent, success, successPercent }: ProgressProp return [realSuccessPercent, validProgress(validProgress(percent) - realSuccessPercent)]; }; -export const getStrokeColor = ({ success = {}, strokeColor }: Partial): ( - | string - | Record -)[] => { +export const getStrokeColor = ({ + success = {}, + strokeColor, +}: Partial): (string | Record)[] => { const { strokeColor: successColor } = success; return [successColor || presetPrimaryColors.green, strokeColor || null!]; }; @@ -62,7 +62,7 @@ export const getSize = ( } else if (typeof size === 'number') { [width, height] = [size, size]; } else { - [width = 14, height = 8] = size; + [width = 14, height = 8] = size as [number, number]; } width *= steps; } else if (type === 'line') { @@ -72,7 +72,7 @@ export const getSize = ( } else if (typeof size === 'number') { [width, height] = [size, size]; } else { - [width = -1, height = 8] = size; + [width = -1, height = 8] = size as [number, number]; } } else if (type === 'circle' || type === 'dashboard') { if (typeof size === 'string' || typeof size === 'undefined') { @@ -88,8 +88,8 @@ export const getSize = ( ); } - width = size[0] ?? size[1] ?? 120; - height = size[0] ?? size[1] ?? 120; + width = (size[0] ?? size[1] ?? 120) as number; + height = (size[0] ?? size[1] ?? 120) as number; } } return [width, height];