chore: Upgrade react-day-picker to v10 and date-fns to v4 (#14608)

Rewrite the calendar styles for the v9+ DOM and handle range selection in DateRangeDialog, as v9 sets both ends of the range on the first click.
This commit is contained in:
Tom Moor authored and GitHub committed 2026-11-16 18:43:44 -05:00
1 parent 69528b16be
commit e463e5565b
4 files changed
+84 -54

No files matched your search

@@ -1,4 +1,4 @@
import { subMonths } from "date-fns";
import { isBefore, subMonths } from "date-fns";
import { useCallback, useState } from "react";
import type { DateRange as DayPickerRange } from "react-day-picker";
import { useTranslation } from "react-i18next";
@@ -42,12 +42,17 @@ export function DateRangeDialog({ defaultRange, onSubmit }: Props) {
// (which cannot be picked) are not shown.
const [defaultMonth] = useState(() => subMonths(range?.to ?? today, 1));
// When a whole range is selected, the next click starts a new range.
// The first click starts a range and the second click ends it.
const handleSelect = useCallback(
(next: DayPickerRange | undefined, selectedDay: Date) => {
setRange((current) =>
current?.from && current.to ? { from: selectedDay } : next
);
(_next: DayPickerRange | undefined, selectedDay: Date) => {
setRange((current) => {
if (!current?.from || current.to) {
return { from: selectedDay };
}
return isBefore(selectedDay, current.from)
? { from: selectedDay, to: current.from }
: { from: current.from, to: selectedDay };
});
},
[]
);
+2 -2
View File
@@ -125,7 +125,7 @@
"cookie": "^0.7.2",
"copy-to-clipboard": "^3.3.3",
"core-js": "^3.51.0",
"date-fns": "^3.6.0",
"date-fns": "^4.4.0",
"dd-trace": "^5.131.1",
"diff": "^9.0.0",
"email-providers": "^2.27.0",
@@ -219,7 +219,7 @@
"react": "^19.3.1",
"react-avatar-editor": "^15.1.0",
"react-colorful": "^5.8.1",
"react-day-picker": "^8.10.2",
"react-day-picker": "^10.0.2",
"react-dom": "^19.3.1",
"react-dropzone": "^20.1.4",
"react-hook-form": "^7.85.0",
+46 -34
View File
@@ -27,25 +27,13 @@ export function Calendar(props: Props) {
const Wrapper = styled.div`
color: ${s("text")};
.rdp {
.rdp-root {
position: relative;
margin: 0;
}
/* Visually-hidden accessibility labels (would otherwise show without the
base stylesheet). */
.rdp-vhidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
appearance: none;
}
.rdp-months {
position: relative;
display: flex;
flex-wrap: wrap;
justify-content: center;
@@ -57,11 +45,11 @@ const Wrapper = styled.div`
flex: 1 1 252px;
}
.rdp-caption {
.rdp-month_caption {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 0 8px;
height: 28px;
margin-bottom: 8px;
}
.rdp-caption_label {
@@ -70,12 +58,20 @@ const Wrapper = styled.div`
color: ${s("text")};
}
/* The navigation is shown once, at the top end of the months. */
.rdp-nav {
position: absolute;
top: 0;
inset-inline-end: 0;
z-index: 1;
display: flex;
align-items: center;
gap: 2px;
height: 28px;
}
.rdp-nav_button {
.rdp-button_previous,
.rdp-button_next {
display: inline-flex;
align-items: center;
justify-content: center;
@@ -89,22 +85,37 @@ const Wrapper = styled.div`
cursor: var(--pointer);
transition: background 100ms ease;
&:hover {
&:hover:not([aria-disabled="true"]) {
background: ${s("listItemHoverBackground")};
}
&:focus-visible {
outline: 2px solid ${s("accent")};
outline-offset: -2px;
}
&[aria-disabled="true"] {
opacity: 0.4;
cursor: default;
}
}
.rdp-nav_icon {
.rdp-chevron {
width: 16px;
height: 16px;
fill: currentColor;
}
.rdp-table {
.rdp-root[dir="rtl"] .rdp-chevron {
transform: rotate(180deg);
}
.rdp-month_grid {
border-collapse: collapse;
width: 100%;
}
.rdp-head_cell {
.rdp-weekday {
font-size: 12px;
font-weight: 500;
text-transform: none;
@@ -113,17 +124,19 @@ const Wrapper = styled.div`
text-align: center;
}
.rdp-cell {
/* Each day cell holds a button, which carries the visual state. */
.rdp-day {
padding: 1px;
text-align: center;
}
.rdp-day {
.rdp-day_button {
display: inline-flex;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
padding: 0;
border: 0;
background: none;
border-radius: 50%;
@@ -134,7 +147,7 @@ const Wrapper = styled.div`
cursor: var(--pointer);
transition: background 100ms ease;
&:hover:not([disabled]):not(.rdp-day_selected) {
&:hover:not([disabled]) {
background: ${s("listItemHoverBackground")};
}
@@ -145,27 +158,26 @@ const Wrapper = styled.div`
}
/* Today, when not selected, is emphasised with the accent colour. */
.rdp-day_today:not(.rdp-day_selected) {
.rdp-today:not(.rdp-selected) .rdp-day_button {
font-weight: 700;
color: ${s("accent")};
}
/* Days belonging to the previous/next month are clearly de-emphasised. */
.rdp-day_outside {
.rdp-outside .rdp-day_button {
color: ${s("textTertiary")};
opacity: 0.5;
}
.rdp-day[disabled] {
.rdp-disabled .rdp-day_button {
color: ${s("textTertiary")};
opacity: 0.4;
cursor: default;
}
/* The selected day is a solid accent-filled circle. */
.rdp-day_selected,
.rdp-day_selected:hover,
.rdp-day_selected:focus-visible {
.rdp-selected .rdp-day_button,
.rdp-selected .rdp-day_button:hover {
background: ${s("accent")};
color: ${s("accentText")};
font-weight: 500;
@@ -173,8 +185,8 @@ const Wrapper = styled.div`
}
/* The days between the start and end of a range are softly highlighted. */
.rdp-day_range_middle.rdp-day_selected,
.rdp-day_range_middle.rdp-day_selected:hover {
.rdp-range_middle .rdp-day_button,
.rdp-range_middle .rdp-day_button:hover {
background: ${s("listItemHoverBackground")};
color: ${s("text")};
font-weight: 400;
+25 -12
View File
@@ -1762,6 +1762,13 @@ __metadata:
languageName: node
linkType: hard
"@date-fns/tz@npm:^1.4.1":
version: 1.5.0
resolution: "@date-fns/tz@npm:1.5.0"
checksum: 10c0/4ef25eedd55924938fa81b23b949a3425201597e2007f5323db54d50fc19283eca5e2a7963c3d82c99b3adf273e9ea9bc7adfd1c9076e15badd99c593a984ffa
languageName: node
linkType: hard
"@dnd-kit/accessibility@npm:^3.1.1":
version: 3.1.1
resolution: "@dnd-kit/accessibility@npm:3.1.1"
@@ -8879,10 +8886,10 @@ __metadata:
languageName: node
linkType: hard
"date-fns@npm:^3.6.0":
version: 3.6.0
resolution: "date-fns@npm:3.6.0"
checksum: 10c0/0b5fb981590ef2f8e5a3ba6cd6d77faece0ea7f7158948f2eaae7bbb7c80a8f63ae30b01236c2923cf89bb3719c33aeb150c715ea4fe4e86e37dcf06bed42fb6
"date-fns@npm:^4.1.0, date-fns@npm:^4.4.0":
version: 4.4.0
resolution: "date-fns@npm:4.4.0"
checksum: 10c0/988f0a13db183f5dfc85c36bbb6847a9c135a9225888bbea4005876ec15539a8613c21a07370a4e7ea543918d5a1cafb423c528b42cdbbde5fdfddb178126b21
languageName: node
linkType: hard
@@ -14116,7 +14123,7 @@ __metadata:
cookie: "npm:^0.7.2"
copy-to-clipboard: "npm:^3.3.3"
core-js: "npm:^3.51.0"
date-fns: "npm:^3.6.0"
date-fns: "npm:^4.4.0"
dd-trace: "npm:^5.131.1"
diff: "npm:^9.0.0"
discord-api-types: "npm:^0.38.48"
@@ -14220,7 +14227,7 @@ __metadata:
react: "npm:^19.3.1"
react-avatar-editor: "npm:^15.1.0"
react-colorful: "npm:^5.8.1"
react-day-picker: "npm:^8.10.2"
react-day-picker: "npm:^10.0.2"
react-dom: "npm:^19.3.1"
react-dropzone: "npm:^20.1.4"
react-hook-form: "npm:^7.85.0"
@@ -15614,13 +15621,19 @@ __metadata:
languageName: node
linkType: hard
"react-day-picker@npm:^8.10.2":
version: 8.10.2
resolution: "react-day-picker@npm:8.10.2"
"react-day-picker@npm:^10.0.2":
version: 10.0.2
resolution: "react-day-picker@npm:10.0.2"
dependencies:
"@date-fns/tz": "npm:^1.4.1"
date-fns: "npm:^4.1.0"
peerDependencies:
date-fns: ^2.28.0 || ^3.0.0
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
checksum: 10c0/701fe6dc0cc2de1430ddbf976c3a9e1f00b8b9970f1d11364047238d34e5f60f8089f505c8d9ec77faeef861b06a3b7b8ed6cc5d11d454abe46fe6b3a46270eb
"@types/react": ">=16.8.0"
react: ">=16.8.0"
peerDependenciesMeta:
"@types/react":
optional: true
checksum: 10c0/3baa75fa21625357656b15425384b21729796c0ae5b2e638d4e7a08f01c3d31db051a1fb21da784f87862ce917383fddfe713164718b3899cc7b47314e46f4ec
languageName: node
linkType: hard