@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
30 lines • 1.37 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import React from 'react';
import { useCheckbox } from '../../hooks/useCheckbox/useCheckbox';
import { CheckboxControlled } from './checkboxControlled';
const CheckboxUnControlledComponent = ({ disabled = false, error = false, required = false, checked = false, onChange, ...props }, ref) => {
const { isChecked, handleToggleIsChecked } = useCheckbox({
initialChecked: checked,
disabled,
});
return (_jsx(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.forwardRef(CheckboxUnControlledComponent);
export { CheckboxUnControlled };
export { CheckboxUnControlled as Checkbox };
//# sourceMappingURL=checkboxUnControlled.js.map