react-day-picker 9.4.0 → 9.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/DayPicker.js +18 -16
- package/dist/cjs/DayPicker.js.map +1 -1
- package/dist/cjs/components/Weekdays.js +1 -1
- package/dist/cjs/types/props.d.ts +14 -0
- package/dist/esm/DayPicker.js +18 -16
- package/dist/esm/DayPicker.js.map +1 -1
- package/dist/esm/components/Weekdays.js +1 -1
- package/dist/esm/types/props.d.ts +14 -0
- package/examples/FixedWeeks.test.tsx +1 -1
- package/examples/Input.test.tsx +1 -1
- package/examples/ModifiersHidden.test.tsx +1 -1
- package/examples/Range.test.tsx +1 -1
- package/examples/TestCase2511.test.tsx +3 -1
- package/examples/TestCase2585.test.tsx +3 -1
- package/examples/WeeknumberCustom.test.tsx +5 -1
- package/examples/__snapshots__/Range.test.tsx.snap +86 -112
- package/examples/__snapshots__/StylingCssModules.test.tsx.snap +43 -56
- package/package.json +1 -1
- package/src/DayPicker.test.tsx +6 -2
- package/src/DayPicker.tsx +36 -41
- package/src/components/Weekdays.tsx +1 -1
- package/src/style.css +0 -1
- package/src/style.module.css +0 -1
- package/src/types/props.ts +14 -0
- package/website/docs/docs/anatomy.mdx +1 -1
- package/website/docs/docs/styling.mdx +1 -5
- package/website/docs/docs/time-zone.mdx +1 -1
- package/website/docs/guides/accessibility.mdx +14 -46
|
@@ -8,61 +8,29 @@ DayPicker follows the [ARIA Authoring Practices Guide](https://www.w3.org/WAI/AR
|
|
|
8
8
|
|
|
9
9
|
Depending on your design, you might need to add more accessibility features. For example, when using [Input Fields](../guides/input-fields), there may be some limitations based on your accessibility goals. Keep up with best practices by following the [ARIA Patterns](https://www.w3.org/WAI/ARIA/apg/patterns/).
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
:::tip Accessibility Tips
|
|
12
12
|
|
|
13
13
|
- Test your date picker regularly with a screen reader to ensure accessibility.
|
|
14
|
-
- Use an `aria-live` region to announce when a date is selected,
|
|
14
|
+
- Use an `aria-live` region to announce when a date is selected, like using the `footer` prop.
|
|
15
15
|
- Customize ARIA labels with the [`labels`](../api/interfaces/PropsBase.md#labels) prop for better user feedback.
|
|
16
|
-
- Ensure the date picker is fully navigable with just the keyboard.
|
|
17
|
-
- Provide clear focus indicators for keyboard users.
|
|
18
16
|
- Maintain sufficient color contrast between text and background.
|
|
19
17
|
- Offer instructions for first-time users or those unfamiliar with the date picker.
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```tsx title="./AccessibleDatePicker.tsx"
|
|
26
|
-
import { format } from "date-fns";
|
|
27
|
-
import { DayPicker } from "react-day-picker";
|
|
28
|
-
|
|
29
|
-
export function AccessibleDatePicker() {
|
|
30
|
-
const [meetingDate, setMeetingDate] = React.useState<Date | undefined>(
|
|
31
|
-
undefined
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const footer = meetingDate
|
|
35
|
-
? `Meeting date is set to ${format(meetingDate, "PPPP")}`
|
|
36
|
-
: "Please pick a date for the meeting.";
|
|
37
|
-
|
|
38
|
-
const labels = {
|
|
39
|
-
labelCaption: () => "Select a date for the meeting",
|
|
40
|
-
labelDay: (date, modifiers) => {
|
|
41
|
-
return modifiers.selected
|
|
42
|
-
? `Selected Meeting Date: ${format(date, "PPP")}`
|
|
43
|
-
: "";
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<DayPicker
|
|
49
|
-
mode="single"
|
|
50
|
-
onSelect={setMeetingDate}
|
|
51
|
-
selected={meetingDate}
|
|
52
|
-
labels={labels}
|
|
53
|
-
footer={footer}
|
|
54
|
-
/>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
```
|
|
19
|
+
:::
|
|
20
|
+
|
|
21
|
+
## Accessibility Props
|
|
58
22
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
23
|
+
| Prop Name | Type | Description |
|
|
24
|
+
| ------------ | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| `labels` | [`Labels`](../api/type-aliases/Labels.md) | Map of the ARIA labels used within DayPicker for better accessibility. |
|
|
26
|
+
| `footer` | `ReactNode` \| `string` | Add a footer to the calendar, which can act as a [live region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) to announce updates. |
|
|
27
|
+
| `role` | `application` \| `dialog` | Set the ARIA role for the container. Use `application` for a more interactive widget or `dialog` for a modal-like date picker. |
|
|
28
|
+
| `aria-label` | `string` | The label to use for the container when a `role` is set, providing a descriptive text for screen readers. |
|
|
29
|
+
| `autoFocus` | `boolean` | Autofocus the calendar when it opens, improving keyboard navigation. |
|
|
62
30
|
|
|
63
|
-
|
|
31
|
+
### Autofocusing the Calendar {#autofocus}
|
|
64
32
|
|
|
65
|
-
DayPicker manages focus
|
|
33
|
+
DayPicker automatically manages focus when users interact with the calendar. To enhance accessibility, you can autofocus the calendar when it opens by using the `autoFocus` prop:
|
|
66
34
|
|
|
67
35
|
```tsx
|
|
68
36
|
<DayPicker mode="single" autoFocus />
|