Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/react-date-picker/src/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ type DateInputProps = {
value?: LooseValuePiece;
yearAriaLabel?: string;
yearPlaceholder?: string;
ariaDescribedBy?: string;
ariaLabelledBy?: string;
ariaRequired?: boolean;
};

export default function DateInput({
Expand All @@ -224,6 +227,9 @@ export default function DateInput({
value: valueProps,
yearAriaLabel,
yearPlaceholder,
ariaDescribedBy,
ariaLabelledBy,
ariaRequired,
}: DateInputProps): React.ReactElement {
const [year, setYear] = useState<string | null>(null);
const [month, setMonth] = useState<string | null>(null);
Expand Down Expand Up @@ -658,6 +664,9 @@ export default function DateInput({
required={required}
value={value}
valueType={valueType}
ariaDescribedBy={ariaDescribedBy}
ariaLabelledBy={ariaLabelledBy}
ariaRequired={ariaRequired}
/>
);
}
Expand Down
9 changes: 9 additions & 0 deletions packages/react-date-picker/src/DateInput/NativeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ type NativeInputProps = {
required?: boolean;
value?: Date | null;
valueType: 'century' | 'decade' | 'year' | 'month' | 'day';
ariaDescribedBy?: string;
ariaLabelledBy?: string;
ariaRequired?: boolean | 'true' | 'false';
};

export default function NativeInput({
Expand All @@ -22,6 +25,9 @@ export default function NativeInput({
required,
value,
valueType,
ariaDescribedBy,
ariaLabelledBy,
ariaRequired,
}: NativeInputProps): React.ReactElement {
const nativeInputType = (() => {
switch (valueType) {
Expand Down Expand Up @@ -73,6 +79,9 @@ export default function NativeInput({
}}
type={nativeInputType}
value={value ? nativeValueParser(value) : ''}
aria-describedby={ariaDescribedBy}
aria-labelledby={ariaLabelledBy}
aria-required={ariaRequired}
/>
);
}
18 changes: 18 additions & 0 deletions packages/react-date-picker/src/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ export type DatePickerProps = {
* @example 'dd'
*/
dayPlaceholder?: string;
/**
* Identifies the element that labels this input.
*/
ariaLabelledBy?: string;
/**
* Identifies the element(s) that describe this input.
*/
ariaDescribedBy?: string;
/**
* Indicates that the input is required.
*/
ariaRequired?: boolean;
/**
* When set to `true`, will remove the calendar and the button toggling its visibility.
*
Expand Down Expand Up @@ -365,6 +377,9 @@ export default function DatePicker(props: DatePickerProps): React.ReactElement {
value,
yearAriaLabel,
yearPlaceholder,
ariaDescribedBy,
ariaLabelledBy,
ariaRequired,
...otherProps
} = props;

Expand Down Expand Up @@ -517,6 +532,9 @@ export default function DatePicker(props: DatePickerProps): React.ReactElement {
monthAriaLabel,
nativeInputAriaLabel,
yearAriaLabel,
ariaDescribedBy,
ariaLabelledBy,
ariaRequired,
};

const placeholderProps = {
Expand Down
3 changes: 3 additions & 0 deletions test/Test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ export default function Test() {
returnValue={returnValue}
showLeadingZeros={showLeadingZeros}
value={value}
ariaDescribedBy="my-describedby-id"
ariaLabelledBy="my-labelledby-id"
ariaRequired={required}
/>
<div ref={portalContainer} />
<br />
Expand Down