Skip to content

Commit 08e4e6a

Browse files
committed
Simplify passing aria-label
1 parent ff2ed80 commit 08e4e6a

File tree

11 files changed

+22
-25
lines changed

11 files changed

+22
-25
lines changed

src/DateInput.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ export default class DateInput extends PureComponent {
445445
<DayInput
446446
key="day"
447447
{...this.commonInputProps}
448-
dayAriaLabel={dayAriaLabel}
448+
ariaLabel={dayAriaLabel}
449449
month={month}
450450
placeholder={dayPlaceholder}
451451
showLeadingZeros={showLeadingZerosFromFormat || showLeadingZeros}
@@ -473,8 +473,8 @@ export default class DateInput extends PureComponent {
473473
<MonthSelect
474474
key="month"
475475
{...this.commonInputProps}
476+
ariaLabel={monthAriaLabel}
476477
locale={locale}
477-
monthAriaLabel={monthAriaLabel}
478478
placeholder={monthPlaceholder}
479479
short={currentMatch.length === 3}
480480
value={month}
@@ -489,7 +489,7 @@ export default class DateInput extends PureComponent {
489489
<MonthInput
490490
key="month"
491491
{...this.commonInputProps}
492-
monthAriaLabel={monthAriaLabel}
492+
ariaLabel={monthAriaLabel}
493493
placeholder={monthPlaceholder}
494494
showLeadingZeros={showLeadingZerosFromFormat || showLeadingZeros}
495495
value={month}
@@ -506,10 +506,10 @@ export default class DateInput extends PureComponent {
506506
<YearInput
507507
key="year"
508508
{...this.commonInputProps}
509+
ariaLabel={yearAriaLabel}
509510
placeholder={yearPlaceholder}
510511
value={year}
511512
valueType={this.valueType}
512-
yearAriaLabel={yearAriaLabel}
513513
/>
514514
);
515515
}
@@ -546,7 +546,7 @@ export default class DateInput extends PureComponent {
546546
maxDate={maxDate || defaultMaxDate}
547547
minDate={minDate || defaultMinDate}
548548
name={name}
549-
nativeInputAriaLabel={nativeInputAriaLabel}
549+
ariaLabel={nativeInputAriaLabel}
550550
onChange={this.onChangeNative}
551551
required={required}
552552
value={value}

src/DateInput/DayInput.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { isMaxDate, isMinDate } from '../shared/propTypes';
1313
import { min, max } from '../shared/utils';
1414

1515
export default function DayInput({
16-
dayAriaLabel,
1716
maxDate,
1817
minDate,
1918
month,
@@ -40,7 +39,6 @@ export default function DayInput({
4039
return (
4140
<Input
4241
name="day"
43-
ariaLabel={dayAriaLabel}
4442
max={maxDay}
4543
min={minDay}
4644
{...otherProps}
@@ -49,8 +47,8 @@ export default function DayInput({
4947
}
5048

5149
DayInput.propTypes = {
50+
ariaLabel: PropTypes.string,
5251
className: PropTypes.string.isRequired,
53-
dayAriaLabel: PropTypes.string,
5452
disabled: PropTypes.bool,
5553
itemRef: PropTypes.func,
5654
maxDate: isMaxDate,
@@ -59,6 +57,7 @@ DayInput.propTypes = {
5957
onChange: PropTypes.func,
6058
onKeyDown: PropTypes.func,
6159
onKeyUp: PropTypes.func,
60+
placeholder: PropTypes.string,
6261
required: PropTypes.bool,
6362
showLeadingZeros: PropTypes.bool,
6463
value: PropTypes.number,

src/DateInput/MonthInput.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { min, max } from '../shared/utils';
1010
export default function MonthInput({
1111
maxDate,
1212
minDate,
13-
monthAriaLabel,
1413
year,
1514
...otherProps
1615
}) {
@@ -20,7 +19,6 @@ export default function MonthInput({
2019
return (
2120
<Input
2221
name="month"
23-
ariaLabel={monthAriaLabel}
2422
max={maxMonth}
2523
min={minMonth}
2624
{...otherProps}
@@ -29,15 +27,16 @@ export default function MonthInput({
2927
}
3028

3129
MonthInput.propTypes = {
30+
ariaLabel: PropTypes.string,
3231
className: PropTypes.string.isRequired,
3332
disabled: PropTypes.bool,
3433
itemRef: PropTypes.func,
3534
maxDate: isMaxDate,
3635
minDate: isMinDate,
37-
monthAriaLabel: PropTypes.string,
3836
onChange: PropTypes.func,
3937
onKeyDown: PropTypes.func,
4038
onKeyUp: PropTypes.func,
39+
placeholder: PropTypes.string,
4140
required: PropTypes.bool,
4241
showLeadingZeros: PropTypes.bool,
4342
value: PropTypes.number,

src/DateInput/MonthSelect.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { isMaxDate, isMinDate } from '../shared/propTypes';
88
import { min, max } from '../shared/utils';
99

1010
export default function MonthSelect({
11+
ariaLabel,
1112
className,
1213
itemRef,
1314
locale,
1415
maxDate,
1516
minDate,
16-
monthAriaLabel,
1717
short,
1818
year,
1919
value,
@@ -27,7 +27,7 @@ export default function MonthSelect({
2727

2828
return (
2929
<select
30-
aria-label={monthAriaLabel}
30+
aria-label={ariaLabel}
3131
className={mergeClassNames(
3232
`${className}__input`,
3333
`${className}__${name}`,
@@ -65,16 +65,17 @@ export default function MonthSelect({
6565
}
6666

6767
MonthSelect.propTypes = {
68+
ariaLabel: PropTypes.string,
6869
className: PropTypes.string.isRequired,
6970
disabled: PropTypes.bool,
7071
itemRef: PropTypes.func,
7172
locale: PropTypes.string,
7273
maxDate: isMaxDate,
7374
minDate: isMinDate,
74-
monthAriaLabel: PropTypes.string,
7575
onChange: PropTypes.func,
7676
onKeyDown: PropTypes.func,
7777
onKeyUp: PropTypes.func,
78+
placeholder: PropTypes.string,
7879
required: PropTypes.bool,
7980
short: PropTypes.bool,
8081
value: PropTypes.number,

src/DateInput/NativeInput.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import {
99
import { isMaxDate, isMinDate, isValueType } from '../shared/propTypes';
1010

1111
export default function NativeInput({
12+
ariaLabel,
1213
disabled,
1314
maxDate,
1415
minDate,
1516
name,
16-
nativeInputAriaLabel,
1717
onChange,
1818
required,
1919
value,
@@ -55,7 +55,7 @@ export default function NativeInput({
5555
return (
5656
<input
5757
type={nativeInputType}
58-
aria-label={nativeInputAriaLabel}
58+
aria-label={ariaLabel}
5959
disabled={disabled}
6060
max={maxDate ? nativeValueParser(maxDate) : null}
6161
min={minDate ? nativeValueParser(minDate) : null}
@@ -75,11 +75,11 @@ export default function NativeInput({
7575
}
7676

7777
NativeInput.propTypes = {
78+
ariaLabel: PropTypes.string,
7879
disabled: PropTypes.bool,
7980
maxDate: isMaxDate,
8081
minDate: isMinDate,
8182
name: PropTypes.string,
82-
nativeInputAriaLabel: PropTypes.string,
8383
onChange: PropTypes.func,
8484
required: PropTypes.bool,
8585
value: PropTypes.oneOfType([

src/DateInput/YearInput.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export default function YearInput({
1111
maxDate,
1212
minDate,
1313
valueType,
14-
yearAriaLabel,
1514
...otherProps
1615
}) {
1716
const maxYear = min(275760, maxDate && getYear(maxDate));
@@ -28,7 +27,6 @@ export default function YearInput({
2827
return (
2928
<Input
3029
name="year"
31-
ariaLabel={yearAriaLabel}
3230
max={maxYear}
3331
min={minYear}
3432
step={yearStep}
@@ -38,6 +36,7 @@ export default function YearInput({
3836
}
3937

4038
YearInput.propTypes = {
39+
ariaLabel: PropTypes.string,
4140
className: PropTypes.string.isRequired,
4241
disabled: PropTypes.bool,
4342
itemRef: PropTypes.func,
@@ -50,7 +49,6 @@ YearInput.propTypes = {
5049
required: PropTypes.bool,
5150
value: PropTypes.number,
5251
valueType: isValueType,
53-
yearAriaLabel: PropTypes.string,
5452
};
5553

5654
YearInput.defaultProps = {

src/DateInput/__tests__/DayInput.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('DayInput', () => {
7171
const component = mount(
7272
<DayInput
7373
{...defaultProps}
74-
dayAriaLabel={dayAriaLabel}
74+
ariaLabel={dayAriaLabel}
7575
/>
7676
);
7777

src/DateInput/__tests__/MonthInput.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('MonthInput', () => {
7171
const component = mount(
7272
<MonthInput
7373
{...defaultProps}
74-
monthAriaLabel={monthAriaLabel}
74+
ariaLabel={monthAriaLabel}
7575
/>
7676
);
7777

src/DateInput/__tests__/MonthSelect.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('MonthSelect', () => {
2929
const component = mount(
3030
<MonthSelect
3131
{...defaultProps}
32-
monthAriaLabel={monthAriaLabel}
32+
ariaLabel={monthAriaLabel}
3333
/>
3434
);
3535

src/DateInput/__tests__/NativeInput.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('NativeInput', () => {
2727
const component = shallow(
2828
<NativeInput
2929
{...defaultProps}
30-
nativeInputAriaLabel={nativeInputAriaLabel}
30+
ariaLabel={nativeInputAriaLabel}
3131
/>
3232
);
3333

0 commit comments

Comments
 (0)