Skip to content

Commit 677dc77

Browse files
authored
fix(radio-option, checkbox, switch): move data-attributes to input (#423)
* chore: fix proptype warnings * fix: move data attributes on toggle, radio and checkbox to their input * chore: fix for typo * chore: fix test proptype warnings
1 parent c05d9da commit 677dc77

File tree

13 files changed

+41
-5
lines changed

13 files changed

+41
-5
lines changed

src/components/inputs/async-creatable-select-input/async-creatable-select-input.spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class TestComponent extends React.Component {
1818
props,
1919
...rest
2020
),
21+
loadOptions: PropTypes.func,
22+
defaultOptions: PropTypes.bool,
23+
isSearchable: PropTypes.bool,
2124
onChange: PropTypes.func,
2225
};
2326
static defaultProps = {

src/components/inputs/async-select-input/async-select-input.spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class TestComponent extends React.Component {
99
static displayName = 'TestComponent';
1010
static propTypes = {
1111
id: PropTypes.string,
12+
defaultOptions: PropTypes.bool.isRequired,
13+
loadOptions: PropTypes.func.isRequired,
1214
value: (props, ...rest) =>
1315
props.isMulti
1416
? PropTypes.arrayOf(PropTypes.object).isRequired(props, ...rest)

src/components/inputs/creatable-select-input/creatable-select-input.spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ class TestComponent extends React.Component {
1818
props,
1919
...rest
2020
),
21+
options: PropTypes.arrayOf(
22+
PropTypes.shape({
23+
value: PropTypes.string,
24+
label: PropTypes.string,
25+
})
26+
),
2127
onChange: PropTypes.func,
2228
};
2329
static defaultProps = {

src/components/inputs/date-range-input/date-range-input.js

+2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ class DateRangeCalendar extends React.Component {
8181
static propTypes = {
8282
intl: PropTypes.shape({
8383
locale: PropTypes.string.isRequired,
84+
formatMessage: PropTypes.func.isRequired,
8485
}).isRequired,
86+
horizontalConstraint: PropTypes.oneOf(['xs', 's', 'm', 'l', 'xl', 'scale']),
8587
value: PropTypes.arrayOf(PropTypes.string).isRequired,
8688
onChange: PropTypes.func.isRequired,
8789
onFocus: PropTypes.func,

src/components/inputs/date-time-input/date-time-input.js

+2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ class DateTimeInput extends React.Component {
5656
static propTypes = {
5757
intl: PropTypes.shape({
5858
locale: PropTypes.string.isRequired,
59+
formatMessage: PropTypes.func.isRequired,
5960
}).isRequired,
61+
horizontalConstraint: PropTypes.oneOf(['xs', 's', 'm', 'l', 'xl', 'scale']),
6062
value: PropTypes.string.isRequired,
6163
onChange: PropTypes.func.isRequired,
6264
onFocus: PropTypes.func,

src/components/inputs/localized-money-input/localized-money-input.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TestComponent extends React.Component {
1010
static propTypes = {
1111
id: PropTypes.string,
1212
value: PropTypes.objectOf(PropTypes.string).isRequired,
13-
onChange: PropTypes.func,
13+
handleChange: PropTypes.func,
1414
selectedCurrency: PropTypes.string.isRequired,
1515
};
1616
static defaultProps = {

src/components/inputs/select-input/select-input.spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ class TestComponent extends React.Component {
1414
? PropTypes.arrayOf(PropTypes.string).isRequired(props, ...rest)
1515
: PropTypes.string(props, ...rest),
1616
onChange: PropTypes.func,
17+
options: PropTypes.arrayOf(
18+
PropTypes.shape({
19+
value: PropTypes.string,
20+
label: PropTypes.string,
21+
})
22+
),
1723
};
1824
static defaultProps = {
1925
id: 'some-id',

src/components/inputs/time-input/time-input-body.js

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default class TimeInputBody extends React.Component {
5959
onClear: PropTypes.func,
6060
onChange: PropTypes.func.isRequired,
6161
onBlur: PropTypes.func.isRequired,
62+
onFocus: PropTypes.func,
6263
placeholder: PropTypes.string,
6364
horizontalConstraint: PropTypes.oneOf(['xs', 's', 'm', 'l', 'xl', 'scale']),
6465
};

src/components/internals/calendar-body/calendar-body.js

+12
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,24 @@ export default class CalendarBody extends React.PureComponent {
3030

3131
static propTypes = {
3232
inputRef: PropTypes.object.isRequired,
33+
icon: PropTypes.string,
3334
id: PropTypes.string,
35+
inputProps: PropTypes.shape({
36+
onBlur: PropTypes.func,
37+
onFocus: PropTypes.func,
38+
}),
39+
toggleButtonProps: PropTypes.shape({
40+
onBlur: PropTypes.func,
41+
onFocus: PropTypes.func,
42+
}),
3443
value: PropTypes.string,
3544
isDisabled: PropTypes.bool,
3645
isOpen: PropTypes.bool,
46+
hasSelection: PropTypes.bool,
47+
hasWarning: PropTypes.bool,
3748
hasError: PropTypes.bool,
3849
onClearPicker: PropTypes.func,
50+
onClear: PropTypes.func,
3951
placeholder: PropTypes.string,
4052
horizontalConstraint: PropTypes.oneOf(['xs', 's', 'm', 'l', 'xl', 'scale']),
4153
};

src/components/internals/calendar-menu/calendar-menu.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default class CalendarMenu extends Component {
1111
hasFooter: PropTypes.bool,
1212
hasError: PropTypes.bool,
1313
hasWarning: PropTypes.bool,
14+
footer: PropTypes.node,
1415
};
1516
render() {
1617
return (

src/components/switches/checkbox/checkbox.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class Checkbox extends React.PureComponent {
5252

5353
render() {
5454
return (
55-
<div {...filterDataAttributes(this.props)}>
55+
<div>
5656
<label
5757
htmlFor={this.state.id}
5858
className={classnames(styles.labelWrapper, {
@@ -94,6 +94,7 @@ export class Checkbox extends React.PureComponent {
9494
disabled={this.props.isDisabled}
9595
checked={this.props.isChecked && !this.props.isIndeterminate}
9696
type="checkbox"
97+
{...filterDataAttributes(this.props)}
9798
/>
9899
</Spacings.Inline>
99100
</label>

src/components/switches/radio/radio-option.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class Option extends React.PureComponent {
3131

3232
render() {
3333
return (
34-
<div {...filterDataAttributes(this.props)}>
34+
<div>
3535
<label
3636
className={classnames(styles.labelWrapper, {
3737
[styles.labelWrapperDisabled]: this.props.isDisabled,
@@ -68,6 +68,7 @@ export class Option extends React.PureComponent {
6868
disabled={this.props.isDisabled}
6969
checked={this.props.isChecked}
7070
type="radio"
71+
{...filterDataAttributes(this.props)}
7172
/>
7273
</Spacings.Inline>
7374
</label>

src/components/switches/toggle/toggle.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ export class Toggle extends React.PureComponent {
2828
className={classnames(styles.labelWrapper, {
2929
[styles.labelWrapperDisabled]: this.props.isDisabled,
3030
})}
31-
{...filterDataAttributes(this.props)}
3231
>
3332
<ToggleSwitch
3433
size={this.props.size}
35-
isMouseOver={this.props.isMouseOver}
3634
isChecked={this.props.isChecked}
3735
isDisabled={this.props.isDisabled}
3836
/>
@@ -44,6 +42,7 @@ export class Toggle extends React.PureComponent {
4442
disabled={this.props.isDisabled}
4543
checked={this.props.isChecked}
4644
type="checkbox"
45+
{...filterDataAttributes(this.props)}
4746
/>
4847
</label>
4948
);

0 commit comments

Comments
 (0)