import * as React from 'react'; import * as PropTypes from 'prop-types'; // @ts-ignore import _omit from 'lodash/omit'; import Checkbox, { LocalCheckboxProps, CheckboxProps, checkboxDefaultProps, checkboxPropTypes } from './Checkbox'; import FieldWrapper, { LocalFieldWrapperProps, fieldWrapperDefaultProps, fieldWrapperPropTypes } from '../FieldWrapper/FieldWrapper'; import { Omit } from '../types'; import { formikField, reduxFormField } from '../adaptors/fields'; export type LocalCheckboxFieldProps = Omit & LocalCheckboxProps & { checkboxLabel?: string; checkboxProps?: LocalCheckboxProps; }; export type CheckboxFieldProps = LocalCheckboxFieldProps & CheckboxProps; export type CheckboxFieldComponents = { Formik: React.FunctionComponent; ReduxForm: React.FunctionComponent; }; export const CheckboxField: React.FunctionComponent & CheckboxFieldComponents = ({ a11yId, autoFocus, checkboxLabel, checkboxProps, checkboxRef, checked, className, defaultChecked, description, disabled, hint, label, indeterminate, id, isOptional, isRequired, onBlur, onChange, onFocus, name, state, validationText, value, ...props }) => ( {({ elementProps }) => ( )} ); CheckboxField.Formik = formikField(CheckboxField, { hasFieldWrapper: true, isCheckbox: true }); CheckboxField.ReduxForm = reduxFormField(CheckboxField, { hasFieldWrapper: true, isCheckbox: true }); CheckboxField.propTypes = { checkboxLabel: PropTypes.string, checkboxProps: PropTypes.shape(checkboxPropTypes), ...checkboxPropTypes, ..._omit(fieldWrapperPropTypes, 'children') }; CheckboxField.defaultProps = { checkboxProps: {}, ...checkboxDefaultProps, ...fieldWrapperDefaultProps }; // @ts-ignore const C: React.FunctionComponent & CheckboxFieldComponents = CheckboxField; export default C;