@coreui/react-pro
Version:
UI Components Library for React.js
42 lines (39 loc) • 2.16 kB
JavaScript
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
import React, { forwardRef, useContext } from 'react';
import PropTypes from 'prop-types';
import classNames from '../../_virtual/index.js';
import { CProgressStackedContext } from './CProgressStackedContext.js';
import { CProgressBar } from './CProgressBar.js';
const CProgress = forwardRef((_a, ref) => {
var { children, className, height, progressBarClassName, thin, value, white } = _a, rest = __rest(_a, ["children", "className", "height", "progressBarClassName", "thin", "value", "white"]);
const { stacked } = useContext(CProgressStackedContext);
return (React.createElement("div", Object.assign({ className: classNames('progress', {
'progress-thin': thin,
'progress-white': white,
}, className) }, (value !== undefined && {
role: 'progressbar',
'aria-valuenow': value,
'aria-valuemin': 0,
'aria-valuemax': 100,
}), { style: Object.assign(Object.assign({}, (height ? { height: `${height}px` } : {})), (stacked ? { width: `${value}%` } : {})), ref: ref }), React.Children.toArray(children).some(
// @ts-expect-error displayName is set in the CProgressBar component
(child) => child.type && child.type.displayName === 'CProgressBar') ? (React.Children.map(children, (child) => {
// @ts-expect-error displayName is set in the CProgressBar component
if (React.isValidElement(child) && child.type.displayName === 'CProgressBar') {
return React.cloneElement(child, Object.assign(Object.assign({}, (value && { value: value })), rest));
}
return;
})) : (React.createElement(CProgressBar, Object.assign({}, (progressBarClassName && { className: progressBarClassName }), { value: value }, rest), children))));
});
CProgress.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
height: PropTypes.number,
progressBarClassName: PropTypes.string,
thin: PropTypes.bool,
value: PropTypes.number,
white: PropTypes.bool,
};
CProgress.displayName = 'CProgress';
export { CProgress };
//# sourceMappingURL=CProgress.js.map