import { c, classy, cssVars, m, ProgressProps as BaseProps, } from '@onfido/castor'; import React, { useMemo } from 'react'; import { withRef } from '../../utils'; export const Progress = withRef(function Progress( { value, min = 0, max = 100, size = 'regular', hideLabel, children, style, className, 'aria-valuetext': ariaValuetext, ...restProps }: ProgressProps, ref: ProgressProps['ref'] ) { const percentValue = useMemo( () => `${Math.round(((value - min) * 100) / (max - min))}%`, [value, min, max] ); return (
{!hideLabel && (children || percentValue)}
); }); export type ProgressProps = BaseProps & Omit< JSX.IntrinsicElements['div'], 'aria-valuemax' | 'aria-valuemin' | 'aria-valuenow' | 'role' >;