@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
32 lines • 2.49 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProgressBarStandalone = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importDefault(require("react"));
const slider_1 = require("../slider/slider");
const type_1 = require("../slider/types/type");
const progressBar_styled_1 = require("./progressBar.styled");
const SLIDER_MAX_VALUE = 1000;
const SLIDER_MIN_VALUE = 0;
const SLIDER_PERCENTAGE_CONVERSION = 10;
const ProgressBarStandaloneComponent = ({ dataTestIdBar = 'bar', dataTestIdProgressBar = 'progress-bar', ...props }, ref) => {
return ((0, jsx_runtime_1.jsx)(progressBar_styled_1.ParentContainerStyled, { ref: ref, styles: props.styles, children: (0, jsx_runtime_1.jsx)(progressBar_styled_1.BarContainerStyled, { styles: props.styles, children: props.styles.useAsSlider && props.styles.sliderVariant ? ((0, jsx_runtime_1.jsx)(slider_1.Slider, { ariaLabel: props.barAriaLabel, max: SLIDER_MAX_VALUE, min: SLIDER_MIN_VALUE, tooltip: props.tooltip, type: type_1.SliderType.CONTINUOUS,
// Convert 0-100 values to 0 - 1000
value: props.progressCompleted * SLIDER_PERCENTAGE_CONVERSION, variant: props.styles.sliderVariant, onChange: (newValue) => {
if (props.onChange && !Array.isArray(newValue)) {
// in order to retun a value 0 - 100
props.onChange(newValue / SLIDER_PERCENTAGE_CONVERSION);
}
}, onDragEnd: props.onDragEnd, onDragStart: props.onDragStart })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(progressBar_styled_1.BarStyled, { "data-testid": dataTestIdBar, sizeStyles: props.sizeStyles, styles: props.styles }), (0, jsx_runtime_1.jsx)(progressBar_styled_1.ProgressBarStyled, { "data-testid": dataTestIdProgressBar, progressAnimation: props.progressAnimation, progressCompleted: props.progressCompleted, sizeStyles: props.sizeStyles, styles: props.styles })] })) }) }));
};
/**
* @description
* ProgressBar component is used to show a progress bar.
* @param {React.PropsWithChildren<IProgressBarStandAlone>} props
* @returns {JSX.Element}
*/
exports.ProgressBarStandalone = react_1.default.forwardRef(ProgressBarStandaloneComponent);
//# sourceMappingURL=progressBarStandAlone.js.map