mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 08:59:15 +08:00
38 lines
778 B
TypeScript
38 lines
778 B
TypeScript
import devWarning from '../_util/devWarning';
|
|
|
|
export function validProgress(progress: number | undefined) {
|
|
if (!progress || progress < 0) {
|
|
return 0;
|
|
}
|
|
if (progress > 100) {
|
|
return 100;
|
|
}
|
|
return progress;
|
|
}
|
|
|
|
export function getSuccessPercent({
|
|
success,
|
|
successPercent,
|
|
}: {
|
|
success?: {
|
|
progress?: number;
|
|
percent?: number;
|
|
};
|
|
successPercent?: number;
|
|
}) {
|
|
let percent = successPercent;
|
|
/** @deprecated Use `percent` instead */
|
|
if (success && 'progress' in success) {
|
|
devWarning(
|
|
false,
|
|
'Progress',
|
|
'`success.progress` is deprecated. Please use `success.percent` instead.',
|
|
);
|
|
percent = success.progress;
|
|
}
|
|
if (success && 'percent' in success) {
|
|
percent = success.percent;
|
|
}
|
|
return percent;
|
|
}
|