react-day-picker 9.3.2 → 9.4.0
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 +2 -1
- package/dist/cjs/DayPicker.js +3 -2
- package/dist/cjs/DayPicker.js.map +1 -1
- package/dist/cjs/classes/DateLib.d.ts +16 -0
- package/dist/cjs/classes/DateLib.js +24 -0
- package/dist/cjs/classes/DateLib.js.map +1 -1
- package/dist/cjs/helpers/endOfBroadcastWeek.d.ts +7 -0
- package/dist/cjs/helpers/endOfBroadcastWeek.js +17 -0
- package/dist/cjs/helpers/endOfBroadcastWeek.js.map +1 -0
- package/dist/cjs/helpers/getBroadcastWeeksInMonth.d.ts +7 -0
- package/dist/cjs/helpers/getBroadcastWeeksInMonth.js +23 -0
- package/dist/cjs/helpers/getBroadcastWeeksInMonth.js.map +1 -0
- package/dist/cjs/helpers/getDataAttributes.js +2 -1
- package/dist/cjs/helpers/getDataAttributes.js.map +1 -1
- package/dist/cjs/helpers/getDates.d.ts +1 -3
- package/dist/cjs/helpers/getDates.js +14 -12
- package/dist/cjs/helpers/getDates.js.map +1 -1
- package/dist/cjs/helpers/getFocusableDate.d.ts +1 -1
- package/dist/cjs/helpers/getFocusableDate.js +12 -4
- package/dist/cjs/helpers/getFocusableDate.js.map +1 -1
- package/dist/cjs/helpers/getMonths.d.ts +1 -1
- package/dist/cjs/helpers/getMonths.js +14 -10
- package/dist/cjs/helpers/getMonths.js.map +1 -1
- package/dist/cjs/helpers/getWeekdays.d.ts +3 -1
- package/dist/cjs/helpers/getWeekdays.js +8 -4
- package/dist/cjs/helpers/getWeekdays.js.map +1 -1
- package/dist/cjs/helpers/startOfBroadcastWeek.d.ts +7 -0
- package/dist/cjs/helpers/startOfBroadcastWeek.js +22 -0
- package/dist/cjs/helpers/startOfBroadcastWeek.js.map +1 -0
- package/dist/cjs/types/props.d.ts +12 -0
- package/dist/cjs/useCalendar.d.ts +1 -1
- package/dist/cjs/useCalendar.js.map +1 -1
- package/dist/cjs/useGetModifiers.js +4 -2
- package/dist/cjs/useGetModifiers.js.map +1 -1
- package/dist/esm/DayPicker.js +3 -2
- package/dist/esm/DayPicker.js.map +1 -1
- package/dist/esm/classes/DateLib.d.ts +16 -0
- package/dist/esm/classes/DateLib.js +24 -0
- package/dist/esm/classes/DateLib.js.map +1 -1
- package/dist/esm/helpers/endOfBroadcastWeek.d.ts +7 -0
- package/dist/esm/helpers/endOfBroadcastWeek.js +14 -0
- package/dist/esm/helpers/endOfBroadcastWeek.js.map +1 -0
- package/dist/esm/helpers/getBroadcastWeeksInMonth.d.ts +7 -0
- package/dist/esm/helpers/getBroadcastWeeksInMonth.js +20 -0
- package/dist/esm/helpers/getBroadcastWeeksInMonth.js.map +1 -0
- package/dist/esm/helpers/getDataAttributes.js +2 -1
- package/dist/esm/helpers/getDataAttributes.js.map +1 -1
- package/dist/esm/helpers/getDates.d.ts +1 -3
- package/dist/esm/helpers/getDates.js +14 -11
- package/dist/esm/helpers/getDates.js.map +1 -1
- package/dist/esm/helpers/getFocusableDate.d.ts +1 -1
- package/dist/esm/helpers/getFocusableDate.js +12 -4
- package/dist/esm/helpers/getFocusableDate.js.map +1 -1
- package/dist/esm/helpers/getMonths.d.ts +1 -1
- package/dist/esm/helpers/getMonths.js +14 -10
- package/dist/esm/helpers/getMonths.js.map +1 -1
- package/dist/esm/helpers/getWeekdays.d.ts +3 -1
- package/dist/esm/helpers/getWeekdays.js +8 -4
- package/dist/esm/helpers/getWeekdays.js.map +1 -1
- package/dist/esm/helpers/startOfBroadcastWeek.d.ts +7 -0
- package/dist/esm/helpers/startOfBroadcastWeek.js +19 -0
- package/dist/esm/helpers/startOfBroadcastWeek.js.map +1 -0
- package/dist/esm/types/props.d.ts +12 -0
- package/dist/esm/useCalendar.d.ts +1 -1
- package/dist/esm/useCalendar.js.map +1 -1
- package/dist/esm/useGetModifiers.js +4 -2
- package/dist/esm/useGetModifiers.js.map +1 -1
- package/examples/BroadcastCalendar.tsx +7 -0
- package/examples/index.ts +1 -0
- package/package.json +1 -1
- package/src/DayPicker.tsx +3 -2
- package/src/classes/DateLib.ts +28 -0
- package/src/helpers/broadcastCalendar.test.ts +43 -0
- package/src/helpers/endOfBroadcastWeek.test.ts +25 -0
- package/src/helpers/endOfBroadcastWeek.ts +16 -0
- package/src/helpers/getBroadcastWeeksInMonth.test.ts +23 -0
- package/src/helpers/getBroadcastWeeksInMonth.ts +31 -0
- package/src/helpers/getDataAttributes.tsx +2 -1
- package/src/helpers/getDates.ts +21 -17
- package/src/helpers/getFocusableDate.ts +19 -8
- package/src/helpers/getMonths.ts +25 -17
- package/src/helpers/getWeekdays.ts +9 -4
- package/src/helpers/startOfBroadcastWeek.test.ts +24 -0
- package/src/helpers/startOfBroadcastWeek.ts +19 -0
- package/src/style.css +13 -4
- package/src/style.module.css +13 -4
- package/src/types/props.ts +12 -0
- package/src/useCalendar.ts +1 -0
- package/src/useGetModifiers.tsx +11 -2
- package/website/docs/docs/localization.mdx +23 -7
- package/website/docs/docs/styling.mdx +4 -4
- package/website/docs/intro.mdx +2 -1
package/src/style.module.css
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
--rdp-accent-color: blue; /* The accent color used for selected days and UI elements. */
|
|
5
5
|
--rdp-accent-background-color: #f0f0ff; /* The accent background color used for selected days and UI elements. */
|
|
6
6
|
|
|
7
|
-
--rdp-day-height:
|
|
8
|
-
--rdp-day-width:
|
|
7
|
+
--rdp-day-height: 44px; /* The height of the day cells. */
|
|
8
|
+
--rdp-day-width: 44px; /* The width of the day cells. */
|
|
9
9
|
|
|
10
10
|
--rdp-day_button-border-radius: 100%; /* The border radius of the day cells. */
|
|
11
11
|
--rdp-day_button-border: 2px solid transparent; /* The border of the day cells. */
|
|
12
|
-
--rdp-day_button-height:
|
|
13
|
-
--rdp-day_button-width:
|
|
12
|
+
--rdp-day_button-height: 42px; /* The height of the day cells. */
|
|
13
|
+
--rdp-day_button-width: 42px; /* The width of the day cells. */
|
|
14
14
|
|
|
15
15
|
--rdp-selected-border: 2px solid var(--rdp-accent-color); /* The border of the selected days. */
|
|
16
16
|
--rdp-disabled-opacity: 0.5; /* The opacity of the disabled days. */
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
--rdp-gradient-direction: -90deg;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
.root[data-broadcast-calendar="true"] {
|
|
61
|
+
--rdp-outside-opacity: unset;
|
|
62
|
+
}
|
|
63
|
+
|
|
60
64
|
/* Root of the component. */
|
|
61
65
|
.root {
|
|
62
66
|
position: relative; /* Required to position the navigation toolbar. */
|
|
@@ -105,6 +109,11 @@
|
|
|
105
109
|
border: 0;
|
|
106
110
|
}
|
|
107
111
|
|
|
112
|
+
.dropdown:focus-visible ~ .caption_label {
|
|
113
|
+
outline: 5px auto Highlight;
|
|
114
|
+
outline: 5px auto -webkit-focus-ring-color;
|
|
115
|
+
}
|
|
116
|
+
|
|
108
117
|
.button_next,
|
|
109
118
|
.button_previous {
|
|
110
119
|
border: none;
|
package/src/types/props.ts
CHANGED
|
@@ -230,6 +230,8 @@ export interface PropsBase {
|
|
|
230
230
|
/**
|
|
231
231
|
* Show the outside days (days falling in the next or the previous month).
|
|
232
232
|
*
|
|
233
|
+
* **Note:** when {@link broadcastCalendar} is set, this prop defaults to true.
|
|
234
|
+
*
|
|
233
235
|
* @see https://daypicker.dev/docs/customization#outside-days
|
|
234
236
|
*/
|
|
235
237
|
showOutsideDays?: boolean;
|
|
@@ -243,6 +245,16 @@ export interface PropsBase {
|
|
|
243
245
|
* @see https://daypicker.dev/docs/customization#showweeknumber
|
|
244
246
|
*/
|
|
245
247
|
showWeekNumber?: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Display the weeks in the month following the broadcast calendar. Setting
|
|
250
|
+
* this prop will ignore {@link weekStartsOn} (always Monday) and
|
|
251
|
+
* {@link showOutsideDays} will default to true.
|
|
252
|
+
*
|
|
253
|
+
* @since 9.4.0
|
|
254
|
+
* @see https://daypicker.dev/docs/localization#broadcast-calendar
|
|
255
|
+
* @see https://en.wikipedia.org/wiki/Broadcast_calendar
|
|
256
|
+
*/
|
|
257
|
+
broadcastCalendar?: boolean;
|
|
246
258
|
/**
|
|
247
259
|
* Use ISO week dates instead of the locale setting. Setting this prop will
|
|
248
260
|
* ignore `weekStartsOn` and `firstWeekContainsDate`.
|
package/src/useCalendar.ts
CHANGED
package/src/useGetModifiers.tsx
CHANGED
|
@@ -17,7 +17,14 @@ export function useGetModifiers(
|
|
|
17
17
|
props: DayPickerProps,
|
|
18
18
|
dateLib: DateLib
|
|
19
19
|
) {
|
|
20
|
-
const {
|
|
20
|
+
const {
|
|
21
|
+
disabled,
|
|
22
|
+
hidden,
|
|
23
|
+
modifiers,
|
|
24
|
+
showOutsideDays,
|
|
25
|
+
broadcastCalendar,
|
|
26
|
+
today
|
|
27
|
+
} = props;
|
|
21
28
|
|
|
22
29
|
const {
|
|
23
30
|
isSameDay,
|
|
@@ -60,7 +67,9 @@ export function useGetModifiers(
|
|
|
60
67
|
Boolean(hidden && dateMatchModifiers(date, hidden, dateLib)) ||
|
|
61
68
|
isBeforeStartMonth ||
|
|
62
69
|
isAfterEndMonth ||
|
|
63
|
-
|
|
70
|
+
// Broadcast calendar will show outside days as default
|
|
71
|
+
(!broadcastCalendar && !showOutsideDays && isOutside) ||
|
|
72
|
+
(broadcastCalendar && showOutsideDays === false && isOutside);
|
|
64
73
|
|
|
65
74
|
const isToday = isSameDay(
|
|
66
75
|
date,
|
|
@@ -6,13 +6,15 @@ sidebar_position: 6
|
|
|
6
6
|
|
|
7
7
|
DayPicker provides various options to customize the calendar for different languages and regions.
|
|
8
8
|
|
|
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
|
-
| `
|
|
15
|
-
| `
|
|
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
|
+
| `timeZone` | `string` | The time zone (IANA or UTC offset) to use in the calendar. |
|
|
15
|
+
| `ISOWeek` | `boolean` | Switch to [ISO Week Dates](https://en.wikipedia.org/wiki/ISO_week_date). |
|
|
16
|
+
| `broadcastCalendar` | `boolean` | Switch to the [US Broadcast Calendar](https://en.wikipedia.org/wiki/Broadcast_calendar). |
|
|
17
|
+
| `jalali` | `boolean` | Switch to the Jalali calendar. |
|
|
16
18
|
|
|
17
19
|
## Setting the Locale
|
|
18
20
|
|
|
@@ -94,6 +96,20 @@ Use the `ISOWeek` prop to switch to [ISO Week Dates](https://en.wikipedia.org/wi
|
|
|
94
96
|
<Examples.WeeknumberIso />
|
|
95
97
|
</BrowserWindow>
|
|
96
98
|
|
|
99
|
+
## Broadcast Calendar
|
|
100
|
+
|
|
101
|
+
Switch to the [US Broadcast Calendar](https://en.wikipedia.org/wiki/Broadcast_calendar) by setting the `broadcastCalendar` prop.
|
|
102
|
+
|
|
103
|
+
In the broadcast calendar, weeks start on Monday and end on Sunday. Each month has either 28 or 35 days.
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<DayPicker broadcastCalendar />
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
<BrowserWindow>
|
|
110
|
+
<Examples.BroadcastCalendar />
|
|
111
|
+
</BrowserWindow>
|
|
112
|
+
|
|
97
113
|
## Jalali Calendar
|
|
98
114
|
|
|
99
115
|
DayPicker supports the Jalali calendar through the [date-fns-jalali](https://www.npmjs.com/package/date-fns-jalali) package. To switch to the Jalali calendar, add `date-fns-jalali` to your dependencies and import `DayPicker` from `react-day-picker/jalali`.
|
|
@@ -56,13 +56,13 @@ The following table lists the CSS variables used by DayPicker within the `.rdp-r
|
|
|
56
56
|
| ----------------------------------------- | -------------------------------------------------------------------- |
|
|
57
57
|
| `--rdp-accent-color` | The accent color used for selected days and UI elements. |
|
|
58
58
|
| `--rdp-accent-background-color` | The accent background color used for selected days and UI elements. |
|
|
59
|
-
| `--rdp-day-height` | The height of the day cells.
|
|
60
|
-
| `--rdp-day-width` | The width of the day cells.
|
|
59
|
+
| `--rdp-day-height` | The height of the day cells (default: `44px`). |
|
|
60
|
+
| `--rdp-day-width` | The width of the day cells (default: `44px`). |
|
|
61
61
|
| `--rdp-chevron-disabled-opacity` | The opacity of the chevron when its container is disabled. |
|
|
62
62
|
| `--rdp-day_button-border-radius` | The border radius of the day cells. |
|
|
63
63
|
| `--rdp-day_button-border` | The border of the day cells. |
|
|
64
|
-
| `--rdp-day_button-height` | The height of the day cells.
|
|
65
|
-
| `--rdp-day_button-width` | The width of the day cells.
|
|
64
|
+
| `--rdp-day_button-height` | The height of the day cells (default: `42px`). |
|
|
65
|
+
| `--rdp-day_button-width` | The width of the day cells (default: `42px`). |
|
|
66
66
|
| `--rdp-selected-border` | The border of the selected days. |
|
|
67
67
|
| `--rdp-disabled-opacity` | The opacity of the disabled days. |
|
|
68
68
|
| `--rdp-outside-opacity` | The opacity of the days outside the current month. |
|
package/website/docs/intro.mdx
CHANGED
|
@@ -14,7 +14,8 @@ DayPicker is a [React](https://react.dev) component for creating date pickers, c
|
|
|
14
14
|
- 🛠 Extensive set of props for [customizing](./docs/customization.mdx) the calendar.
|
|
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
|
-
- 🌍 Can be [localized](
|
|
17
|
+
- 🌍 Can be [localized](https://daypicker.dev/docs/localization) into any language and [time zones](https://daypicker.dev/docs/localization#time-zone).
|
|
18
|
+
- 🌐 Support for [ISO 8601 dates](https://daypicker.dev/docs/localization#iso-week-dates), [Jalali](https://daypicker.dev/docs/localization#jalali-calendar), and [broadcast](https://daypicker.dev/docs/localization#broadcast-calendar) calendar.
|
|
18
19
|
- 🦮 Complies with WCAG 2.1 AA requirements for [accessibility](./guides/accessibility.mdx).
|
|
19
20
|
- ⚙️ [Customizable components](./guides/custom-components.mdx) to extend the rendered elements.
|
|
20
21
|
- 🔤 Easy integration [with input fields](./guides/input-fields.mdx).
|