react-day-picker 9.1.2 → 9.1.3

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/README.md CHANGED
@@ -10,7 +10,7 @@ DayPicker is a [React](https://react.dev) component for creating date pickers, c
10
10
  - 🎨 Minimal design that can be [easily styled](https://daypicker.dev/docs/styling) with CSS or any CSS framework.
11
11
  - 📅 Supports [selections](https://daypicker.dev/docs/selection-modes) of single days, multiple days, ranges of days, or [custom selections](https://daypicker.dev/guides/custom-selections).
12
12
  - 🌍 Can be [localized](https://daypicker.dev/docs/localization) into any language, supports [ISO 8601 dates](https://daypicker.dev/docs/localization#iso-week-dates), [time zones](https://daypicker.dev/docs/localization#time-zone), and the [Jalali calendar](https://daypicker.dev/docs/localization#jalali-calendar).
13
- - 🦮 Complies with WCAG 2.1 AA requirements for [accessibility](https://daypicker.dev/docs/accessibility).
13
+ - 🦮 Complies with WCAG 2.1 AA requirements for [accessibility](https://daypicker.dev/guides/accessibility).
14
14
  - ⚙️ [Customizable components](https://daypicker.dev/guides/custom-components) to extend the rendered elements.
15
15
  - 🔤 Easy integration [with input fields](https://daypicker.dev/guides/input-fields).
16
16
 
@@ -240,7 +240,7 @@ export interface PropsBase {
240
240
  *
241
241
  * @since 9.1.1
242
242
  * @experimental
243
- * @see https://daypicker.dev/docs/localization#time-zone
243
+ * @see https://daypicker.dev/docs/time-zone
244
244
  */
245
245
  timeZone?: string | undefined;
246
246
  /**
@@ -255,7 +255,7 @@ export interface PropsBase {
255
255
  * Use this prop to communicate the calendar's status to screen readers.
256
256
  * Prefer strings over complex UI elements.
257
257
  *
258
- * @see https://daypicker.dev/docs/accessibility#footer
258
+ * @see https://daypicker.dev/guides/accessibility#footer
259
259
  */
260
260
  footer?: React.ReactNode | string;
261
261
  /**
@@ -265,7 +265,7 @@ export interface PropsBase {
265
265
  * Use this prop when you need to focus DayPicker after a user action, for
266
266
  * improved accessibility.
267
267
  *
268
- * @see https://daypicker.dev/docs/accessibility#autofocus
268
+ * @see https://daypicker.dev/guides/accessibility#autofocus
269
269
  */
270
270
  autoFocus?: boolean;
271
271
  /**
@@ -240,7 +240,7 @@ export interface PropsBase {
240
240
  *
241
241
  * @since 9.1.1
242
242
  * @experimental
243
- * @see https://daypicker.dev/docs/localization#time-zone
243
+ * @see https://daypicker.dev/docs/time-zone
244
244
  */
245
245
  timeZone?: string | undefined;
246
246
  /**
@@ -255,7 +255,7 @@ export interface PropsBase {
255
255
  * Use this prop to communicate the calendar's status to screen readers.
256
256
  * Prefer strings over complex UI elements.
257
257
  *
258
- * @see https://daypicker.dev/docs/accessibility#footer
258
+ * @see https://daypicker.dev/guides/accessibility#footer
259
259
  */
260
260
  footer?: React.ReactNode | string;
261
261
  /**
@@ -265,7 +265,7 @@ export interface PropsBase {
265
265
  * Use this prop when you need to focus DayPicker after a user action, for
266
266
  * improved accessibility.
267
267
  *
268
- * @see https://daypicker.dev/docs/accessibility#autofocus
268
+ * @see https://daypicker.dev/guides/accessibility#autofocus
269
269
  */
270
270
  autoFocus?: boolean;
271
271
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-day-picker",
3
- "version": "9.1.2",
3
+ "version": "9.1.3",
4
4
  "description": "Customizable Date Picker for React",
5
5
  "author": "Giampaolo Bellavite <io@gpbl.dev>",
6
6
  "homepage": "https://daypicker.dev",
@@ -141,10 +141,11 @@
141
141
  "src",
142
142
  "examples",
143
143
  "website/docs",
144
- "tsconfig.json"
144
+ "tsconfig.json",
145
+ "tsconfig-base.json"
145
146
  ],
146
147
  "dependencies": {
147
- "@date-fns/tz": "^1.1.0",
148
+ "@date-fns/tz": "^1.1.2",
148
149
  "date-fns": "^4.1.0"
149
150
  },
150
151
  "devDependencies": {
@@ -157,10 +158,10 @@
157
158
  "@trivago/prettier-plugin-sort-imports": "^4.3.0",
158
159
  "@types/jest": "^29.5.12",
159
160
  "@types/node": "^22.5.4",
160
- "@types/react": "^18.3.6",
161
+ "@types/react": "^18.3.8",
161
162
  "@types/react-dom": "^18.3.0",
162
163
  "@typescript-eslint/eslint-plugin": "^8.4.0",
163
- "@typescript-eslint/parser": "^8.5.0",
164
+ "@typescript-eslint/parser": "^8.6.0",
164
165
  "date-fns": "^3.6.0",
165
166
  "date-fns-jalali": "3.6.0-1",
166
167
  "eslint": "^8.57.0",
@@ -173,7 +174,7 @@
173
174
  "eslint-plugin-react-hooks": "^4.6.2",
174
175
  "eslint-plugin-require-extensions": "^0.1.3",
175
176
  "eslint-plugin-testing-library": "^6.3.0",
176
- "html-validate": "^8.22.0",
177
+ "html-validate": "^8.23.0",
177
178
  "jest": "^29.7.0",
178
179
  "jest-environment-jsdom": "^29.7.0",
179
180
  "mockdate": "^3.0.5",
@@ -267,7 +267,7 @@ export interface PropsBase {
267
267
  *
268
268
  * @since 9.1.1
269
269
  * @experimental
270
- * @see https://daypicker.dev/docs/localization#time-zone
270
+ * @see https://daypicker.dev/docs/time-zone
271
271
  */
272
272
  timeZone?: string | undefined;
273
273
  /**
@@ -282,7 +282,7 @@ export interface PropsBase {
282
282
  * Use this prop to communicate the calendar's status to screen readers.
283
283
  * Prefer strings over complex UI elements.
284
284
  *
285
- * @see https://daypicker.dev/docs/accessibility#footer
285
+ * @see https://daypicker.dev/guides/accessibility#footer
286
286
  */
287
287
  footer?: React.ReactNode | string;
288
288
  /**
@@ -292,7 +292,7 @@ export interface PropsBase {
292
292
  * Use this prop when you need to focus DayPicker after a user action, for
293
293
  * improved accessibility.
294
294
  *
295
- * @see https://daypicker.dev/docs/accessibility#autofocus
295
+ * @see https://daypicker.dev/guides/accessibility#autofocus
296
296
  */
297
297
  autoFocus?: boolean;
298
298
  /**
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["DOM", "ES2020", "DOM.Iterable"],
5
+ "jsx": "react", // Keep this to allow overriding React with Preact
6
+ "module": "ES2020",
7
+ "moduleResolution": "Node",
8
+ "sourceMap": true,
9
+ "declaration": true,
10
+ "outDir": "./dist",
11
+ "esModuleInterop": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "strict": true,
14
+ "alwaysStrict": true,
15
+ "skipLibCheck": true,
16
+ "noUnusedLocals": true
17
+ }
18
+ }
@@ -145,7 +145,7 @@ In [selection mode](./selection-modes.mdx), you can create a [custom selection](
145
145
 
146
146
  ## Footer as Live Region
147
147
 
148
- Use the `footer` prop to display a footer below the calendar. The footer acts as a [live region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) to announce changes to screen readers. For more information on making the calendar accessible, see the [Accessibility guide](./accessibility.mdx).
148
+ Use the `footer` prop to display a footer below the calendar. The footer acts as a [live region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) to announce changes to screen readers. For more information on making the calendar accessible, see the [Accessibility guide](../guides/accessibility.mdx).
149
149
 
150
150
  ```tsx
151
151
  export function Footer() {
@@ -1,18 +1,22 @@
1
1
  ---
2
- sidebar_position: 5
2
+ sidebar_position: 6
3
3
  ---
4
4
 
5
5
  # Localization
6
6
 
7
- Learn how to set the locale, changing the time zone, and adjust other calendar options.
7
+ DayPicker provides various options to customize the calendar for different languages and regions.
8
8
 
9
- ## Setting the Locale
9
+ | Prop Name | Type | Description |
10
+ | ----------------------- | --------------------------------------------- | ------------------------------------------------------------------------ |
11
+ | `locale` | [`Locale`](https://date-fns.org/docs/I18n) | Set the locale. Default is `en-US`. |
12
+ | `weekStartsOn` | `1` \| `2` \| `3` \| `4` \| `5` \| `6` \| `7` | Change the first day of the week. |
13
+ | `firstWeekContainsDate` | `1` \| `4` | Configure the first date in the first week of the year. |
14
+ | `ISOWeek` | `boolean` | Switch to [ISO Week Dates](https://en.wikipedia.org/wiki/ISO_week_date). |
15
+ | `timeZone` | `string` | The time zone (IANA or UTC offset) to use in the calendar. |
10
16
 
11
- | Prop Name | Type | Description |
12
- | --------- | ------------------------------------------ | ----------------------------------- |
13
- | `locale` | [`Locale`](https://date-fns.org/docs/I18n) | Set the locale. Default is `en-US`. |
17
+ ## Setting the Locale
14
18
 
15
- To set a different locale, import the locale object from `react-day-picker/locale`and pass it to the`locale` prop.
19
+ To change the default `en-US` to another locale, import a locale object from `react-day-picker/locale` and pass it to the`locale` prop.
16
20
 
17
21
  ```tsx
18
22
  // import the locale object
@@ -49,60 +53,9 @@ import { DayPicker, defaultLocale } from "react-day-picker";
49
53
 
50
54
  ## Changing the Time Zone {#time-zone}
51
55
 
52
- :::warning Experimental Feature (since v9.1.1)
53
-
54
- DayPicker supports time zones through the `date-fns` library. For more information, refer to the [date-fns time zones documentation](https://date-fns.org/v4.1.0/docs/Time-Zones). If you encounter any issues, please [report them on GitHub](https://github.com/gpbl/react-day-picker/issues). Thank you!
55
-
56
- :::
57
-
58
- | Prop Name | Type | Description |
59
- | ---------- | -------- | ---------------------------------------------- |
60
- | `timeZone` | `string` | Set a time zone for the dates in the calendar. |
61
-
62
- Use the `timeZone` prop to set a different time zone for the calendar. See [Wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
63
- for a list of the possible values.
64
-
65
- ```tsx
66
- <DayPicker timeZone="UTC" /> // Use Coordinated Universal Time
67
- <DayPicker timeZone="Pacific/Kiritimati" /> // Use Line Islands Time
68
- ```
69
-
70
- <BrowserWindow bodyStyle={{ justifyContent: "start" }}>
71
- <Examples.TimeZone />
72
- </BrowserWindow>
73
-
74
- ### Working with Time-Zoned Dates
75
-
76
- When working with time zones, make sure to use the `TZDate` object instead of the native `Date` object. The `TZDate` object is exported from [@date-fns/tz](https://github.com/date-fns/date-fns-tz). Refer to their documentation for more information.
56
+ See [Time Zone docs](./time-zone.mdx) for more information.
77
57
 
78
- - To initialize a date in a specific time zone, create a `new TZDate()` object or the `TZDate.tz`.
79
-
80
- ```tsx
81
- import { DayPicker, TZDate } from "react-day-picker";
82
-
83
- export function TimeZone() {
84
- const timeZone = "America/New_York";
85
- const [selected, setSelected] = useState<Date | undefined>(
86
- new TZDate(2024, 12, 10, timeZone) // Make sure you use `TZDate` instead of `Date`
87
- );
88
- return (
89
- <DayPicker
90
- mode="single"
91
- timeZone={timeZone}
92
- selected={selected}
93
- onSelect={setSelected}
94
- />
95
- );
96
- }
97
- ```
98
-
99
- ## Calendar Options
100
-
101
- | Prop Name | Type | Description |
102
- | ----------------------- | --------------------------------------------- | ------------------------------------------------------------------------ |
103
- | `weekStartsOn` | `1` \| `2` \| `3` \| `4` \| `5` \| `6` \| `7` | Change the first day of the week. |
104
- | `firstWeekContainsDate` | `1` \| `4` | Configure the first date in the first week of the year. |
105
- | `ISOWeek` | `boolean` | Switch to [ISO Week Dates](https://en.wikipedia.org/wiki/ISO_week_date). |
58
+ ## Localization Options
106
59
 
107
60
  ### First Date of the Week
108
61
 
@@ -6,9 +6,9 @@ sidebar_position: 4
6
6
 
7
7
  DayPicker offers predefined rules for day selection:
8
8
 
9
- - **[Single mode](#single-mode)**: Allows the selection of a single day.
10
- - **[Multiple mode](#multiple-mode)**: Enables the selection of multiple individual days.
11
- - **[Range mode](#range-mode)**: Allows the selection of a continuous range of days.
9
+ - [Single mode](#single-mode): allows the selection of a single day.
10
+ - [Multiple mode](#multiple-mode): allows the selection of multiple individual days.
11
+ - [Range mode](#range-mode): allows the selection of a continuous range of days.
12
12
 
13
13
  The `mode` prop determines the selection mode. Use the `disabled` prop to prevent the selection of specific days. The `selected` and `onSelect` props provide customization options for the selection process.
14
14
 
@@ -0,0 +1,46 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
5
+ # Time Zone
6
+
7
+ Use the `timeZone` prop to set the time zone for the calendar.
8
+
9
+ | Prop Name | Type | Description |
10
+ | ---------- | -------- | ------------------------------------- |
11
+ | `timeZone` | `string` | The time zone to use in the calendar. |
12
+
13
+ The time zone can be specified as either an [IANA time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) identifier or a UTC offset.
14
+
15
+ ```tsx
16
+ <DayPicker timeZone="UTC" /> // Use Coordinated Universal Time
17
+ <DayPicker timeZone="Pacific/Kiritimati" /> // Use Line Islands Time
18
+ <DayPicker timeZone="+02:00" /> // Use UTC+2
19
+ ```
20
+
21
+ <BrowserWindow bodyStyle={{ justifyContent: "start" }}>
22
+ <Examples.TimeZone />
23
+ </BrowserWindow>
24
+
25
+ ### Working with Time-Zoned Dates
26
+
27
+ When working with time zones, make sure to use the `TZDate` object exported by `react-day-picker` instead of the native `Date` object. For more information, refer to the [date-fns doc](https://date-fns.org/v4.1.0/docs/Time-Zones).
28
+
29
+ ```tsx
30
+ import { DayPicker, TZDate } from "react-day-picker";
31
+
32
+ export function TimeZone() {
33
+ const timeZone = "America/New_York";
34
+ const [selected, setSelected] = useState<Date | undefined>(
35
+ new TZDate(2024, 12, 10, timeZone) // Make sure you use `TZDate` instead of `Date`
36
+ );
37
+ return (
38
+ <DayPicker
39
+ mode="single"
40
+ timeZone={timeZone}
41
+ selected={selected}
42
+ onSelect={setSelected}
43
+ />
44
+ );
45
+ }
46
+ ```
@@ -1,5 +1,5 @@
1
1
  ---
2
- sidebar_position: 6
2
+ sidebar_position: 7
3
3
  ---
4
4
 
5
5
  # Translating DayPicker
@@ -24,7 +24,7 @@ Get help and provide suggestions for translating DayPicker into your language. V
24
24
 
25
25
  ## ARIA Labels
26
26
 
27
- The `labels` prop allows you to customize the [ARIA labels](./accessibility.mdx).
27
+ The `labels` prop allows you to customize the [ARIA labels](../guides/accessibility.mdx).
28
28
 
29
29
  ### Example: Italian labels
30
30
 
@@ -1,22 +1,22 @@
1
1
  ---
2
- sidebar_position: 7
2
+ sidebar_position: 2
3
3
  ---
4
4
 
5
5
  # Accessible Date Pickers
6
6
 
7
- DayPicker is designed to adhere to the [ARIA Authoring Practices Guide](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/datepicker-dialog/) for date pickers. This includes features such as keyboard navigation, focus management, and labeling.
7
+ DayPicker follows the [ARIA Authoring Practices Guide](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/datepicker-dialog/) for date pickers, including features like keyboard navigation, focus management, and labeling.
8
8
 
9
- Depending on your design, you may need to add additional accessibility features. For instance, when working with [Input Fields](../guides/input-fields), there could be some restrictions depending on the level of accessibility you aim to achieve. Stay updated with best practices by following the [ARIA Patterns](https://www.w3.org/WAI/ARIA/apg/patterns/).
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
  ## Accessibility Tips
12
12
 
13
- - Regularly test your date picker with a screen reader to ensure it's accessible to all users.
14
- - Use an `aria-live` region in your user interface to audibly announce when a date is selected. You can use the `footer` prop for this purpose.
15
- - Customize the ARIA labels with the [`labels`](../api/interfaces/PropsBase.md#labels) prop to improve user feedback.
16
- - Ensure that your date picker is fully navigable using only the keyboard.
17
- - Use clear indicators for focus states to assist users who rely on keyboard navigation.
18
- - Ensure sufficient color contrast between text and background colors.
19
- - Consider providing instructions on how to use the date picker for first-time users or those unfamiliar with the interface.
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, utilizing the `footer` prop.
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
+ - Maintain sufficient color contrast between text and background.
19
+ - Offer instructions for first-time users or those unfamiliar with the date picker.
20
20
 
21
21
  ## Announcing the Selected Date {#footer}
22
22
 
@@ -62,7 +62,7 @@ export function AccessibleDatePicker() {
62
62
 
63
63
  ## Autofocusing the Calendar {#autofocus}
64
64
 
65
- DayPicker manages focus automatically when the user interacts with the calendar. However, for better accessibility, you may need to autofocus the calendar when it opens. To do this, use the `autoFocus` prop:
65
+ DayPicker manages focus automatically when users interact with the calendar. For better accessibility, you might want to autofocus the calendar when it opens. Use the `autoFocus` prop to achieve this:
66
66
 
67
67
  ```tsx
68
68
  <DayPicker mode="single" autoFocus />
@@ -18,7 +18,7 @@ You may need to use custom components in advanced applications to:
18
18
  - Implement buttons or dropdowns using your own design system components
19
19
  - Wrap an element with another element, like adding a tooltip to a day cell
20
20
 
21
- When customizing components, familiarize yourself with the [API Reference](../api#components) and the [DayPicker Anatomy](../docs/anatomy.mdx). Ensure you maintain [accessibility](../docs/accessibility.mdx).
21
+ When customizing components, familiarize yourself with the [API Reference](../api#components) and the [DayPicker Anatomy](../docs/anatomy.mdx). Ensure you maintain [accessibility](../guides/accessibility.mdx).
22
22
 
23
23
  :::note Custom Components vs Formatters
24
24
 
@@ -15,7 +15,7 @@ DayPicker is a [React](https://react.dev) component for creating date pickers, c
15
15
  - 🎨 Minimal design that can be [easily styled](./docs/styling.mdx) with CSS or any CSS framework.
16
16
  - 📅 Supports [selections](./docs/selection-modes.mdx) of single days, multiple days, ranges of days, or [custom selections](./guides/custom-selections.mdx).
17
17
  - 🌍 Can be [localized](./docs/localization.mdx) into any language, supports [ISO 8601 dates](./docs/localization.mdx#iso-week-dates), [time zones](./docs/localization.mdx#time-zone), and the [Jalali calendar](./docs/localization.mdx#jalali-calendar).
18
- - 🦮 Complies with WCAG 2.1 AA requirements for [accessibility](./docs/accessibility.mdx).
18
+ - 🦮 Complies with WCAG 2.1 AA requirements for [accessibility](./guides/accessibility.mdx).
19
19
  - ⚙️ [Customizable components](./guides/custom-components.mdx) to extend the rendered elements.
20
20
  - 🔤 Easy integration [with input fields](./guides/input-fields.mdx).
21
21
 
@@ -59,7 +59,7 @@ export function MyDatePicker() {
59
59
  - 📅 [Selection Modes](./docs/selection-modes.mdx) - Enable users to select days with single, multiple, or range selections.
60
60
  - 🌍 [Localization](./docs/localization.mdx) - Configure DayPicker to display the calendar in different languages and date formats.
61
61
  - 🈳 [Translating DayPicker](./docs/translation.mdx) - Translate the labels and messages of the calendar.
62
- - 🦮 [Accessible Date Pickers](./docs/accessibility.mdx) - Make your date picker accessible to all users.
62
+ - 🦮 [Accessible Date Pickers](./guides/accessibility.mdx) - Make your date picker accessible to all users.
63
63
 
64
64
  ### Guides
65
65