UNPKG

@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

34 lines 2.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CheckboxControlled = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = __importDefault(require("react")); const stylesName_1 = require("../../constants/stylesName/stylesName"); const useStyles_1 = require("../../hooks/useStyles/useStyles"); const errorBoundary_1 = require("../../provider/errorBoundary/errorBoundary"); const fallbackComponent_1 = require("../../provider/errorBoundary/fallbackComponent"); const checkboxStandAlone_1 = require("./checkboxStandAlone"); const state_utils_1 = require("./utils/state.utils"); const CheckboxControlledComponent = react_1.default.forwardRef((props, ref) => { const styles = (0, useStyles_1.useStyles)(stylesName_1.STYLES_NAME.CHECKBOX, props.variant, props.ctv); const state = (0, state_utils_1.getCheckBoxState)(props.checked, props.disabled, props.error, styles); return (0, jsx_runtime_1.jsx)(checkboxStandAlone_1.CheckboxStandAlone, { ref: ref, state: state, styles: styles[state], ...props }); }); CheckboxControlledComponent.displayName = 'CheckboxControlledComponent'; const CheckboxBoundary = (props, ref) => ((0, jsx_runtime_1.jsx)(errorBoundary_1.ErrorBoundary, { fallBackComponent: (0, jsx_runtime_1.jsx)(fallbackComponent_1.FallbackComponent, { children: (0, jsx_runtime_1.jsx)(checkboxStandAlone_1.CheckboxStandAlone, { ...props, ref: ref }) }), children: (0, jsx_runtime_1.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_1.default.forwardRef(CheckboxBoundary); exports.CheckboxControlled = CheckboxControlled; //# sourceMappingURL=checkboxControlled.js.map