@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
28 lines • 1.64 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import React from 'react';
import { STYLES_NAME } from '../../constants/stylesName/stylesName';
import { useStyles } from '../../hooks/useStyles/useStyles';
import { ErrorBoundary } from '../../provider/errorBoundary/errorBoundary';
import { FallbackComponent } from '../../provider/errorBoundary/fallbackComponent';
import { CheckboxStandAlone } from './checkboxStandAlone';
import { getCheckBoxState } from './utils/state.utils';
const CheckboxControlledComponent = React.forwardRef((props, ref) => {
const styles = useStyles(STYLES_NAME.CHECKBOX, props.variant, props.ctv);
const state = getCheckBoxState(props.checked, props.disabled, props.error, styles);
return _jsx(CheckboxStandAlone, { ref: ref, state: state, styles: styles[state], ...props });
});
CheckboxControlledComponent.displayName = 'CheckboxControlledComponent';
const CheckboxBoundary = (props, ref) => (_jsx(ErrorBoundary, { fallBackComponent: _jsx(FallbackComponent, { children: _jsx(CheckboxStandAlone, { ...props, ref: ref }) }), children: _jsx(CheckboxControlledComponent, { ...props, ref: ref }) }));
/**
* @description
* Checkbox component is a input component that can be used to select one or more options from a list of options.
* It can be used to create a list of options that can be selected.
* @param {React.PropsWithChildren<ICheckboxControlled<V>>} props
* @returns {JSX.Element}
* @constructor
* @example
* <Checkbox variant="checkbox" />
*/
const CheckboxControlled = React.forwardRef(CheckboxBoundary);
export { CheckboxControlled };
//# sourceMappingURL=checkboxControlled.js.map