Skip to content

Commit 19cc1df

Browse files
authored
fix: Selection button props split between container and input elements (#207)
1 parent d8a5ed2 commit 19cc1df

File tree

3 files changed

+160
-19
lines changed

3 files changed

+160
-19
lines changed

packages/fuselage/src/components/CheckBox/index.js

+50-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@ import { Box } from '../Box';
66
import { Label } from '../Label';
77

88
export const CheckBox = forwardRef(function CheckBox({
9-
className,
10-
hidden,
9+
autoComplete,
10+
checked,
11+
defaultChecked,
12+
disabled,
13+
form,
14+
id,
1115
indeterminate,
12-
invisible,
13-
style,
16+
name,
17+
required,
18+
tabIndex,
19+
value,
20+
qa,
21+
'data-qa': dataQa,
1422
onChange,
23+
onInput,
24+
onInvalid,
1525
...props
1626
}, ref) {
1727
const innerRef = useRef();
@@ -26,12 +36,46 @@ export const CheckBox = forwardRef(function CheckBox({
2636
onChange && onChange.call(innerRef.current, event);
2737
}, [innerRef, indeterminate, onChange]);
2838

29-
return <Box is={Label} componentClassName='rcx-check-box' className={className} hidden={hidden} invisible={invisible} style={style}>
30-
<Box is='input' componentClassName='rcx-check-box__input' ref={mergedRef} type='checkbox' onChange={handleChange} {...props} />
39+
return <Box is={Label} componentClassName='rcx-check-box' {...props}>
40+
<Box
41+
is='input'
42+
componentClassName='rcx-check-box__input'
43+
autoComplete={autoComplete}
44+
checked={checked}
45+
defaultChecked={defaultChecked}
46+
disabled={disabled}
47+
form={form}
48+
id={id}
49+
name={name}
50+
required={required}
51+
tabIndex={tabIndex}
52+
type='checkbox'
53+
value={value}
54+
data-qa={dataQa || qa}
55+
ref={mergedRef}
56+
onChange={handleChange}
57+
onInput={onInput}
58+
onInvalid={onInvalid}
59+
/>
3160
<Box is='i' componentClassName='rcx-check-box__fake' aria-hidden='true' />
3261
</Box>;
3362
});
3463

3564
CheckBox.propTypes = {
65+
autoComplete: PropTypes.string,
66+
checked: PropTypes.bool,
67+
defaultChecked: PropTypes.bool,
68+
disabled: PropTypes.bool,
69+
form: PropTypes.string,
70+
id: PropTypes.string,
3671
indeterminate: PropTypes.bool,
72+
name: PropTypes.string,
73+
required: PropTypes.bool,
74+
tabIndex: PropTypes.number,
75+
value: PropTypes.string,
76+
qa: PropTypes.string,
77+
'data-qa': PropTypes.string,
78+
onChange: PropTypes.func,
79+
onInput: PropTypes.func,
80+
onInvalid: PropTypes.func,
3781
};
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,66 @@
1+
import PropTypes from 'prop-types';
12
import React, { forwardRef } from 'react';
23

34
import { Box } from '../Box';
45
import { Label } from '../Label';
56

67
export const RadioButton = forwardRef(function RadioButton({
7-
className,
8-
hidden,
9-
invisible,
10-
style,
8+
autoComplete,
9+
checked,
10+
defaultChecked,
11+
disabled,
12+
form,
13+
id,
14+
name,
15+
required,
16+
tabIndex,
17+
value,
18+
qa,
19+
'data-qa': dataQa,
20+
onChange,
21+
onInput,
22+
onInvalid,
1123
...props
1224
}, ref) {
13-
return <Box is={Label} componentClassName='rcx-radio-button' className={className} hidden={hidden} invisible={invisible} style={style}>
14-
<Box is='input' componentClassName='rcx-radio-button__input' ref={ref} type='radio' {...props} />
25+
return <Box is={Label} componentClassName='rcx-radio-button' {...props}>
26+
<Box
27+
is='input'
28+
componentClassName='rcx-radio-button__input'
29+
autoComplete={autoComplete}
30+
checked={checked}
31+
defaultChecked={defaultChecked}
32+
disabled={disabled}
33+
form={form}
34+
id={id}
35+
name={name}
36+
required={required}
37+
tabIndex={tabIndex}
38+
type='radio'
39+
value={value}
40+
data-qa={dataQa || qa}
41+
ref={ref}
42+
onChange={onChange}
43+
onInput={onInput}
44+
onInvalid={onInvalid}
45+
/>
1546
<Box is='i' componentClassName='rcx-radio-button__fake' aria-hidden='true' />
1647
</Box>;
1748
});
49+
50+
RadioButton.propTypes = {
51+
autoComplete: PropTypes.string,
52+
checked: PropTypes.bool,
53+
defaultChecked: PropTypes.bool,
54+
disabled: PropTypes.bool,
55+
form: PropTypes.string,
56+
id: PropTypes.string,
57+
name: PropTypes.string,
58+
required: PropTypes.bool,
59+
tabIndex: PropTypes.number,
60+
value: PropTypes.string,
61+
qa: PropTypes.string,
62+
'data-qa': PropTypes.string,
63+
onChange: PropTypes.func,
64+
onInput: PropTypes.func,
65+
onInvalid: PropTypes.func,
66+
};
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,66 @@
1+
import PropTypes from 'prop-types';
12
import React, { forwardRef } from 'react';
23

34
import { Label } from '../Label';
45
import { Box } from '../Box';
56

67
export const ToggleSwitch = forwardRef(function ToggleSwitch({
7-
className,
8-
hidden,
9-
invisible,
10-
style,
11-
onClick,
8+
autoComplete,
9+
checked,
10+
defaultChecked,
11+
disabled,
12+
form,
13+
id,
14+
name,
15+
required,
16+
tabIndex,
17+
value,
18+
qa,
19+
'data-qa': dataQa,
20+
onChange,
21+
onInput,
22+
onInvalid,
1223
...props
1324
}, ref) {
14-
return <Box is={Label} componentClassName='rcx-toggle-switch' className={className} hidden={hidden} invisible={invisible} style={style} onClick={onClick}>
15-
<Box is='input' componentClassName='rcx-toggle-switch__input' ref={ref} type='checkbox' {...props} />
25+
return <Box is={Label} componentClassName='rcx-toggle-switch' {...props}>
26+
<Box
27+
is='input'
28+
componentClassName='rcx-toggle-switch__input'
29+
autoComplete={autoComplete}
30+
checked={checked}
31+
defaultChecked={defaultChecked}
32+
disabled={disabled}
33+
form={form}
34+
id={id}
35+
name={name}
36+
required={required}
37+
tabIndex={tabIndex}
38+
type='checkbox'
39+
value={value}
40+
data-qa={dataQa || qa}
41+
ref={ref}
42+
onChange={onChange}
43+
onInput={onInput}
44+
onInvalid={onInvalid}
45+
/>
1646
<Box is='i' componentClassName='rcx-toggle-switch__fake' aria-hidden='true' />
1747
</Box>;
1848
});
49+
50+
ToggleSwitch.propTypes = {
51+
autoComplete: PropTypes.string,
52+
checked: PropTypes.bool,
53+
defaultChecked: PropTypes.bool,
54+
disabled: PropTypes.bool,
55+
form: PropTypes.string,
56+
id: PropTypes.string,
57+
name: PropTypes.string,
58+
required: PropTypes.bool,
59+
tabIndex: PropTypes.number,
60+
value: PropTypes.string,
61+
qa: PropTypes.string,
62+
'data-qa': PropTypes.string,
63+
onChange: PropTypes.func,
64+
onInput: PropTypes.func,
65+
onInvalid: PropTypes.func,
66+
};

0 commit comments

Comments
 (0)