jobiqo-cl
Version:
[](https://circleci.com/gh/jobiqo/jobiqo-cl)
30 lines (27 loc) • 1.51 kB
JavaScript
import { __rest } from '../../../../../node_modules/tslib/tslib.es6.js';
import React__default from 'react';
import { CheckboxWrapper, Checkbox as Checkbox$1, CheckboxLabel, CheckboxRequiredMark } from './styles.js';
/**
* @file index.tsx
*
* @fileoverview Checkbox component. Renders a checkbox together with a label.
*/
/**
* A checkbox is an input of type checkbox.
* Will have a label next to it and styling will come from the theme property.
* The component inherits props from the "InputHTMLAttributes" so any property for a checkbox can be used with this component.
*/
const Checkbox = (_a) => {
var { id, checkboxStyle, label, onChange, error = false, required = false, disabled = false } = _a, props = __rest(_a, ["id", "checkboxStyle", "label", "onChange", "error", "required", "disabled"]);
return (React__default.createElement(CheckboxWrapper, null,
React__default.createElement(Checkbox$1, Object.assign({ type: "checkbox", id: id, disabled: disabled, onChange: onChange, checkboxStyle: checkboxStyle }, props)),
React__default.createElement(CheckboxLabel, { disabled: disabled, error: error, required: required, checkboxStyle: checkboxStyle, htmlFor: id },
label,
React__default.createElement(React__default.Fragment, null, required && React__default.createElement(CheckboxRequiredMark, null, "*")))));
};
Checkbox.defaultProps = {
label: '',
checkboxStyle: 'primary',
theme: null
};
export { Checkbox };