@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
36 lines • 1.76 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Checkbox = exports.CheckboxUnControlled = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importDefault(require("react"));
const useCheckbox_1 = require("../../hooks/useCheckbox/useCheckbox");
const checkboxControlled_1 = require("./checkboxControlled");
const CheckboxUnControlledComponent = ({ disabled = false, error = false, required = false, checked = false, onChange, ...props }, ref) => {
const { isChecked, handleToggleIsChecked } = (0, useCheckbox_1.useCheckbox)({
initialChecked: checked,
disabled,
});
return ((0, jsx_runtime_1.jsx)(checkboxControlled_1.CheckboxControlled, { ...props, ref: ref, checked: isChecked, disabled: disabled, error: error, required: required, variant: props.variant, onChange: e => onChange
? (() => {
onChange(e);
handleToggleIsChecked();
})()
: handleToggleIsChecked() }));
};
/**
* @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<ICheckboxUnControlled<V>>} props
* @returns {JSX.Element}
* @constructor
* @example
* <Checkbox variant="checkbox" />
*/
const CheckboxUnControlled = react_1.default.forwardRef(CheckboxUnControlledComponent);
exports.CheckboxUnControlled = CheckboxUnControlled;
exports.Checkbox = CheckboxUnControlled;
//# sourceMappingURL=checkboxUnControlled.js.map