ant-design/components/progress/utils.ts

38 lines
769 B
TypeScript
Raw Normal View History

import warning from '../_util/warning';
export function validProgress(progress: number | undefined) {
if (!progress || progress < 0) {
return 0;
2019-08-14 18:21:24 +08:00
}
if (progress > 100) {
return 100;
}
return progress;
2019-03-06 13:45:40 +08:00
}
export function getSuccessPercent({
success,
successPercent,
}: {
success?: {
progress?: number;
percent?: number;
};
successPercent?: number;
}) {
let percent = successPercent;
/** @deprecated Use `percent` instead */
if (success && 'progress' in success) {
warning(
false,
'Progress',
'`success.progress` is deprecated. Please use `success.percent` instead.',
);
percent = success.progress;
}
if (success && 'percent' in success) {
percent = success.percent;
}
return percent;
}