diff --git a/src/components/README.md b/src/components/README.md index 1afaf8872..ec26986af 100644 --- a/src/components/README.md +++ b/src/components/README.md @@ -1260,14 +1260,12 @@ A checkbox with state. * [Checkbox](#Form.module_Checkbox) - * [~Checkbox(props)](#Form.module_Checkbox..Checkbox) ⇒ React.ReactNode - * [.propTypes](#Form.module_Checkbox..Checkbox.propTypes) : Object - * [.defaultProps](#Form.module_Checkbox..Checkbox.defaultProps) : Object + * [~Checkbox(props)](#Form.module_Checkbox..Checkbox) ⇒ JSX.Element * ["onCheckboxChange" (checked, event)](#event_onCheckboxChange) -### Checkbox~Checkbox(props) ⇒ React.ReactNode +### Checkbox~Checkbox(props) ⇒ JSX.Element Render a checkbox form element. Provides restructured event data. **Kind**: inner method of [Checkbox](#Form.module_Checkbox) @@ -1275,52 +1273,35 @@ Render a checkbox form element. Provides restructured event data. - + - + - + - + - + - + - + - + - + - + - + - +
ParamTypeParamTypeDefault
propsobjectpropsobject
props.ariaLabelstring[props.ariaLabel]string
props.childrenReact.ReactNode[props.children]React.ReactNode
props.idstring[props.id]string
props.isChecked*[props.isChecked]booleanfalse
props.isDisabledboolean[props.isDisabled]booleanfalse
props.isReadOnlyboolean[props.isReadOnly]booleanfalse
props.labelReact.ReactNode[props.label]React.ReactNode
props.namestring[props.name]string
props.onChangefunction[props.onChange]functionhelpers.noop
props.value*[props.value]string
- -* [~Checkbox(props)](#Form.module_Checkbox..Checkbox) ⇒ React.ReactNode - * [.propTypes](#Form.module_Checkbox..Checkbox.propTypes) : Object - * [.defaultProps](#Form.module_Checkbox..Checkbox.defaultProps) : Object - - - -#### Checkbox.propTypes : Object -Prop types. - -**Kind**: static property of [Checkbox](#Form.module_Checkbox..Checkbox) - - -#### Checkbox.defaultProps : Object -Default props. - -**Kind**: static property of [Checkbox](#Form.module_Checkbox..Checkbox) ### "onCheckboxChange" (checked, event) diff --git a/src/components/form/__tests__/__snapshots__/checkbox.test.js.snap b/src/components/form/__tests__/__snapshots__/checkbox.test.js.snap index 8a0c9173a..830a034aa 100644 --- a/src/components/form/__tests__/__snapshots__/checkbox.test.js.snap +++ b/src/components/form/__tests__/__snapshots__/checkbox.test.js.snap @@ -5,14 +5,7 @@ exports[`Checkbox Component should handle children as a label: children label ch props="{ "children": [ {} - ], - "ariaLabel": null, - "id": null, - "isChecked": false, - "isDisabled": false, - "isReadOnly": false, - "label": "", - "name": null + ] }" >
{ const [check, setCheck] = React.useState(); const updatedChecked = check ?? isChecked ?? false; - const updatedName = name || helpers.generateId(); - const updatedId = id || updatedName; + const updatedId = id || name; /** * onChange event, provide restructured event. @@ -57,7 +55,7 @@ const Checkbox = ({ const mockEvent = { ...createMockEvent(event), id: updatedId, - name: updatedName, + name, value, checked }; @@ -72,53 +70,15 @@ const Checkbox = ({ checked={updatedChecked} id={updatedId} isChecked={updatedChecked} - isDisabled={isDisabled || false} + isDisabled={isDisabled} label={children || label} - name={updatedName} + name={name} onChange={(event, checked) => onCheckboxChange(checked, event)} value={value} - readOnly={isReadOnly || false} + readOnly={isReadOnly} {...props} /> ); }; -/** - * Prop types. - * - * @type {{isReadOnly: boolean, onChange: Function, children: React.ReactNode, name: string, id: string, - * isDisabled: boolean, label: string, isChecked: boolean, value: *, ariaLabel: string}} - */ -Checkbox.propTypes = { - ariaLabel: PropTypes.string, - children: PropTypes.node, - id: PropTypes.string, - isChecked: PropTypes.any, - isDisabled: PropTypes.bool, - isReadOnly: PropTypes.bool, - label: PropTypes.node, - name: PropTypes.string, - onChange: PropTypes.func, - value: PropTypes.any -}; - -/** - * Default props. - * - * @type {{isReadOnly: boolean, onChange: Function, children: React.ReactNode, name: string, id: string, - * isDisabled: boolean, label: string, isChecked: boolean, value: *, ariaLabel: string}} - */ -Checkbox.defaultProps = { - ariaLabel: null, - children: null, - id: null, - isChecked: false, - isDisabled: false, - isReadOnly: false, - label: '', - name: null, - onChange: helpers.noop, - value: undefined -}; - export { Checkbox as default, Checkbox };