@itwin/itwinui-react
Version:
A react component library for iTwinUI
60 lines (59 loc) • 1.58 kB
JavaScript
import cx from 'classnames';
import * as React from 'react';
import {
SvgCheckmarkSmall,
SvgImportantSmall,
Box,
getBoundedValue,
ShadowRoot,
} from '../../utils/index.js';
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden.js';
export const ProgressRadial = React.forwardRef((props, forwardedRef) => {
let {
value,
indeterminate = void 0 === value,
status,
size,
className,
style,
children,
...rest
} = props;
let statusMap = {
negative: React.createElement(SvgImportantSmall, {
'aria-hidden': true,
}),
positive: React.createElement(SvgCheckmarkSmall, {
'aria-hidden': true,
}),
warning: React.createElement(SvgImportantSmall, {
'aria-hidden': true,
}),
};
return React.createElement(
Box,
{
className: cx('iui-progress-indicator-radial', className),
'data-iui-size': size,
'data-iui-status': status,
'data-iui-indeterminate': indeterminate ? 'true' : void 0,
ref: forwardedRef,
style: {
...(void 0 !== value && {
'--iui-progress-percentage': `${getBoundedValue(value, 0, 100)}%`,
}),
...style,
},
...rest,
},
React.createElement(
ShadowRoot,
null,
100 !== value && React.createElement(VisuallyHidden, null, 'Loading.'),
React.createElement('slot', null),
),
'x-small' !== size ? children ?? (status ? statusMap[status] : null) : null,
);
});
if ('development' === process.env.NODE_ENV)
ProgressRadial.displayName = 'ProgressRadial';