Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WNMGDS-2757] Upgrade react-day-picker library #3064

Merged
merged 19 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c3a7dad
This is the minimum version that causes the issue in Preact Storybook
pwolfert Feb 29, 2024
009a128
Discovered that our SingleInputDateField doesn't work in native Preac…
pwolfert Feb 29, 2024
5436596
Upgrade to the version of RDP that gives us date-fns 3.0 with ES Modu…
pwolfert Mar 4, 2024
3508592
Upgrade date-fns too. It all works in the Astro example
pwolfert Mar 4, 2024
82e955d
Merge branch 'main' into pwolfert/troubleshooting-react-day-picker-up…
pwolfert Apr 16, 2024
843dd8b
Upgrade to fixed version
pwolfert Apr 16, 2024
e2d2420
Merge branch 'main' into pwolfert/upgrade-day-picker
pwolfert Apr 23, 2024
422fa6f
Fix `preact-app` example
pwolfert Apr 23, 2024
65cee1a
Update CSS because of `aria-disabled` to `disabled` change upstream
pwolfert Apr 23, 2024
0b481a9
Merge branch 'main' into pwolfert/upgrade-day-picker
pwolfert Apr 23, 2024
693255e
Fix selectors
pwolfert Apr 23, 2024
0692ac0
Address color-contrast issues with design changes
pwolfert Apr 30, 2024
9710e8b
Fix strike-through in forced-colors mode
pwolfert Apr 30, 2024
d5f73f4
Update VRT refs
pwolfert Apr 30, 2024
e3a61b7
Add it to the astro example too
pwolfert Apr 30, 2024
bd34043
Remove from examples where it isn't needed now that we've tested it
pwolfert Apr 30, 2024
7bd8774
Update VRT refs of astro example where we added the date field
pwolfert Apr 30, 2024
4edf126
Merge branch 'main' into pwolfert/upgrade-day-picker
pwolfert Apr 30, 2024
a107aa5
Now that these buttons are actually disabled, we don't need to disabl…
pwolfert May 1, 2024
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
4 changes: 2 additions & 2 deletions examples/astro/src/pages/react.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AutocompleteExample from '../components/react/AutocompleteExample';
import BadgeExample from '../components/react/BadgeExample';
import ButtonExample from '../components/react/ButtonExample';
import ChoiceListExample from '../components/react/ChoiceListExample';
// import SingleInputDateFieldExample from '../components/react/SingleInputDateFieldExample';
import SingleInputDateFieldExample from '../components/react/SingleInputDateFieldExample';
import MultiInputDateFieldExample from '../components/react/MultiInputDateFieldExample';
import DropdownExample from '../components/react/DropdownExample';
import FilterChipExample from '../components/react/FilterChipExample';
Expand Down Expand Up @@ -39,7 +39,7 @@ import { SkipNav, UsaBanner } from '@cmsgov/design-system';
<BadgeExample client:visible />
<ButtonExample client:visible />
<ChoiceListExample client:visible />
<!-- <SingleInputDateFieldExample client:visible /> -->
<SingleInputDateFieldExample client:visible />
<MultiInputDateFieldExample client:visible />
<DropdownExample client:visible />
<FilterChipExample client:visible />
Expand Down
9 changes: 9 additions & 0 deletions examples/preact-app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ const config = {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist/scripts'),
},
resolve: {
alias: {
// These aliases are necessary because we use React-based libraries in some of the
// design-system components
react: 'preact/compat',
'react-dom': 'preact/compat',
'react/jsx-runtime': 'preact/jsx-runtime',
},
},
module: {
rules: [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
"@types/react-transition-group": "^4.4.5",
"case-it": "^1.0.1",
"classnames": "^2.2.5",
"date-fns": "^2.28.0",
"date-fns": "^3.0.6",
"ev-emitter": "^1.1.1",
"focus-trap-react": "^10.0.0",
"lodash": "^4.17.21",
"preactement": "1.8.5",
"prop-types": "^15.8.1",
"react-aria": "^3.27.0",
"react-day-picker": "8.0.5",
"react-day-picker": "8.10.1",
"react-stately": "^3.25.0",
"react-transition-group": "^4.4.5"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CustomDayPickerCaption from './CustomDayPickerCaption';
import format from 'date-fns/format';
import { format } from 'date-fns';
import { DayPicker, DayPickerSingleProps } from 'react-day-picker';
import { ArrowsStackedIcon } from '../Icons';
import { t } from '../i18n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CustomDayPicker from './CustomDayPicker';
import classNames from 'classnames';
import cleanFieldProps from '../utilities/cleanFieldProps';
import describeField from '../utilities/describeField';
import isMatch from 'date-fns/isMatch';
import { isMatch } from 'date-fns';
import mergeIds from '../utilities/mergeIds';
import useLabelMask from '../TextField/useLabelMask';
import useClickOutsideHandler from '../utilities/useClickOutsideHandler';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@
border: 2px solid transparent;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, see my comment below on the cursor pointer, but this rdp-button_reset class is doing a lot of redundant things too. I think we only need the background: none bit but this could use a deeper dive to ensure that doesn't introduce regressions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above. I think this is out of scope for this work right now, but we should follow up on it.

}

.rdp-button[aria-disabled='true'] {
opacity: 0.25;
pointer-events: none;
}

.rdp-button:not([aria-disabled='true']) {
.rdp-button:not(:disabled) {
cursor: pointer;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an odd rule - our buttons have this set in our reset file so this must be undoing another style this library has set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be redundant; I'll check

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they have a button reset rule of their own. That could be something to revisit later—whether we want to try to optimize their CSS. At the beginning, our strategy was to try to keep their original CSS mostly intact and add overrides to it so it would be easy to upgrade the library as time went on. With that strategy, though, we do include a lot more rules than we need.

}

Expand All @@ -83,7 +78,7 @@
color: inherit;
}

.rdp-button:hover:not([aria-disabled='true']) {
.rdp-button:hover:not(:disabled) {
background-color: var(--rdp-background-color);
}

Expand Down Expand Up @@ -207,13 +202,13 @@
z-index: 2;
}

.rdp-dropdown[disabled] {
.rdp-dropdown:disabled {
color: unset;
opacity: unset;
}

.rdp-dropdown:focus:not([disabled]) + .rdp-caption_label,
.rdp-dropdown:active:not([disabled]) + .rdp-caption_label {
.rdp-dropdown:focus:not(:disabled) + .rdp-caption_label,
.rdp-dropdown:active:not(:disabled) + .rdp-caption_label {
background-color: var(--rdp-background-color);
border: var(--rdp-outline);
border-radius: 6px;
Expand Down Expand Up @@ -282,18 +277,37 @@
font-weight: bold;
}

.rdp-day_selected:not([aria-disabled='true']),
.rdp-day_selected:focus:not([aria-disabled='true']),
.rdp-day_selected:active:not([aria-disabled='true']),
.rdp-day_selected:hover:not([aria-disabled='true']) {
.rdp-day_selected:not(:disabled),
.rdp-day_selected:focus:not(:disabled),
.rdp-day_selected:active:not(:disabled),
.rdp-day_selected:hover:not(:disabled) {
background-color: var(--rdp-accent-color);
color: white;
}

.rdp-day_selected:focus:not([aria-disabled='true']) {
.rdp-day_selected:focus:not(:disabled) {
border: var(--rdp-outline-selected);
}

.rdp-day_disabled {
overflow: visible;
color: var(--color-muted);

&::after {
background: var(--color-muted);
content: '';
display: block;
position: absolute;
width: calc(100% + 4px);
height: 2px;

@media (forced-colors: active) {
background-color: GrayText;
cursor: not-allowed;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this has point-events:none I don't think cursor: not-allowed will work

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's interesting! Good catch. When I go back and look at their PR that switched back from aria-disabled to disabled, it looks like they removed the pointer-events: none because it's not needed when the browser already knows the button is disabled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a107aa5

}
}
}

.rdp:not([dir='rtl']) .rdp-day_range_start:not(.rdp-day_range_end) {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
Expand Down Expand Up @@ -358,24 +372,24 @@
}

.rdp-button:active,
.rdp-button:active:hover:not([aria-disabled='true']),
.rdp-day_selected:active:not([aria-disabled='true']),
.rdp-day_selected:active:hover:not([aria-disabled='true']) {
.rdp-button:active:hover:not(:disabled),
.rdp-day_selected:active:not(:disabled),
.rdp-day_selected:active:hover:not(:disabled) {
background-color: var(--rdp-active-color);
color: white;
}

@media (forced-colors: active) {
.rdp-button[aria-disabled='true'] {
.rdp-button:disabled {
border-color: GrayText;
color: GrayText;
opacity: 1;
}

.rdp-day_selected:not([aria-disabled='true']),
.rdp-day_selected:focus:not([aria-disabled='true']),
.rdp-day_selected:active:not([aria-disabled='true']),
.rdp-day_selected:hover:not([aria-disabled='true']) {
.rdp-day_selected:not(:disabled),
.rdp-day_selected:focus:not(:disabled),
.rdp-day_selected:active:not(:disabled),
.rdp-day_selected:hover:not(:disabled) {
background-color: Highlight;
border-color: Highlight;
color: Field;
Expand All @@ -391,8 +405,8 @@
padding: 0 $spacer-1;
}

.rdp-dropdown:focus:not([disabled]) + .rdp-caption_label,
.rdp-dropdown:active:not([disabled]) + .rdp-caption_label {
.rdp-dropdown:focus:not(:disabled) + .rdp-caption_label,
.rdp-dropdown:active:not(:disabled) + .rdp-caption_label {
@include mixins.focus-styles;

background-color: initial;
Expand Down Expand Up @@ -436,25 +450,8 @@
}

&:disabled {
color: var(--pagination-link__color--disabled);
pointer-events: none;

@media (forced-colors: active) {
border: 0;
color: GrayText;
cursor: not-allowed;

.ds-c-icon {
color: GrayText;
fill: GrayText;

path {
color: GrayText;
fill: GrayText;
stroke: GrayText;
}
}
}
visibility: hidden;
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/components/content/PublishDate.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import format from 'date-fns/format';
import { format } from 'date-fns';

export interface PublishDateProps {
date: string;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 10 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4992,22 +4992,6 @@
"@prefresh/utils" "^1.2.0"
"@rollup/pluginutils" "^4.2.1"

"@reach/[email protected]":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@reach/auto-id/-/auto-id-0.16.0.tgz#dfabc3227844e8c04f8e6e45203a8e14a8edbaed"
integrity sha512-5ssbeP5bCkM39uVsfQCwBBL+KT8YColdnMN5/Eto6Rj7929ql95R3HZUOkKIvj7mgPtEb60BLQxd1P3o6cjbmg==
dependencies:
"@reach/utils" "0.16.0"
tslib "^2.3.0"

"@reach/[email protected]":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@reach/utils/-/utils-0.16.0.tgz#5b0777cf16a7cab1ddd4728d5d02762df0ba84ce"
integrity sha512-PCggBet3qaQmwFNcmQ/GqHSefadAFyNCUekq9RrWoaU9hh/S4iaFgf2MBMdM47eQj5i/Bk0Mm07cP/XPFlkN+Q==
dependencies:
tiny-warning "^1.0.3"
tslib "^2.3.0"

"@react-aria/breadcrumbs@^3.5.4":
version "3.5.4"
resolved "https://registry.yarnpkg.com/@react-aria/breadcrumbs/-/breadcrumbs-3.5.4.tgz#fbd4e213adf84bde39e126ea62c389de9dc00e20"
Expand Down Expand Up @@ -11458,13 +11442,18 @@ dataloader@^1.4.0:
resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-1.4.0.tgz#bca11d867f5d3f1b9ed9f737bd15970c65dff5c8"
integrity sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw==

date-fns@^2.25.0, date-fns@^2.28.0:
date-fns@^2.25.0:
version "2.30.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.30.0.tgz#f367e644839ff57894ec6ac480de40cae4b0f4d0"
integrity sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==
dependencies:
"@babel/runtime" "^7.21.0"

date-fns@^3.0.6:
version "3.3.1"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-3.3.1.tgz#7581daca0892d139736697717a168afbb908cfed"
integrity sha512-y8e109LYGgoQDveiEBD3DYXKba1jWf5BA8YU1FL5Tvm0BTdEfy54WLCwnuYWZNnzzvALy/QQ4Hov+Q9RVRv+Zw==

dateformat@^3.0.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
Expand Down Expand Up @@ -21975,12 +21964,10 @@ react-colorful@^5.1.2:
resolved "https://registry.yarnpkg.com/react-colorful/-/react-colorful-5.6.1.tgz#7dc2aed2d7c72fac89694e834d179e32f3da563b"
integrity sha512-1exovf0uGTGyq5mXQT0zgQ80uvj2PCwvF8zY1RN9/vbJVSjSo3fsB/4L3ObbF7u70NduSiK4xu4Y6q1MHoUGEw==

[email protected]:
version "8.0.5"
resolved "https://registry.yarnpkg.com/react-day-picker/-/react-day-picker-8.0.5.tgz#079f21ebdc353b66a97ef4258062f27c10b55145"
integrity sha512-qw5t2zJB1ob7p0yhbuVY0kzu08qePrpYW1kldrhTJ0nHN/z5Jb90MeCAi2889z8h2NJ/Flh5gLR9XcJIsr4ijQ==
dependencies:
"@reach/auto-id" "0.16.0"
[email protected]:
version "8.10.1"
resolved "https://registry.yarnpkg.com/react-day-picker/-/react-day-picker-8.10.1.tgz#4762ec298865919b93ec09ba69621580835b8e80"
integrity sha512-TMx7fNbhLk15eqcMt+7Z7S2KF7mfTId/XJDjKE8f+IUcFn0l08/kI4FiYTL/0yuOLmEcbR4Fwe3GJf/NiiMnPA==

react-dev-utils@^12.0.1:
version "12.0.1"
Expand Down Expand Up @@ -24855,11 +24842,6 @@ tiny-invariant@^1.3.1:
resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.3.1.tgz#8560808c916ef02ecfd55e66090df23a4b7aa642"
integrity sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==

tiny-warning@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754"
integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==

title-case@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/title-case/-/title-case-2.1.1.tgz#3e127216da58d2bc5becf137ab91dae3a7cd8faa"
Expand Down