Skip to content

Commit

Permalink
chore(react19): update react, react-dom, @types/react, @testing-libra…
Browse files Browse the repository at this point in the history
…ry/react, etc to v19 or relevant react 19 flavored version, update peerDependencies of react and react-dom from 17.x to 19.x in all affected packages, update test/setup-test-framework to import directly from @testing-library/jest-dom instead of subfolder
  • Loading branch information
ByronDWall committed Jan 17, 2025
1 parent ca01f2b commit 2a616c9
Show file tree
Hide file tree
Showing 267 changed files with 4,641 additions and 6,264 deletions.
100 changes: 100 additions & 0 deletions .changeset/fast-ligers-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
'@commercetools-uikit/localized-multiline-text-field': major
'@commercetools-uikit/localized-multiline-text-input': major
'@commercetools-uikit/async-creatable-select-field': major
'@commercetools-uikit/async-creatable-select-input': major
'@commercetools-uikit/localized-rich-text-input': major
'@commercetools-uikit/selectable-search-input': major
'@commercetools-uikit/spacings-inset-squish': major
'@commercetools-uikit/secondary-icon-button': major
'@commercetools-uikit/creatable-select-field': major
'@commercetools-uikit/creatable-select-input': major
'@commercetools-uikit/localized-money-input': major
'@commercetools-uikit/localized-text-field': major
'@commercetools-uikit/multiline-text-field': major
'@commercetools-uikit/localized-text-input': major
'@commercetools-uikit/multiline-text-input': major
'@commercetools-uikit/search-select-field': major
'@commercetools-uikit/search-select-input': major
'@commercetools-uikit/accessible-button': major
'@commercetools-uikit/async-select-field': major
'@commercetools-uikit/async-select-input': major
'@commercetools-uikit/secondary-button': major
'@commercetools-uikit/search-text-input': major
'@commercetools-uikit/spacings-inline': major
'@commercetools-uikit/dropdown-menu': major
'@commercetools-uikit/date-range-field': major
'@commercetools-uikit/date-range-input': major
'@commercetools-uikit/primary-action-dropdown': major
'@commercetools-uikit/spacings-inset': major
'@commercetools-uikit/spacings-stack': major
'@commercetools-uikit/primary-button': major
'@commercetools-uikit/date-time-field': major
'@commercetools-uikit/date-time-input': major
'@commercetools-uikit/rich-text-input': major
'@commercetools-uikit/rich-text-utils': major
'@commercetools-uikit/password-field': major
'@commercetools-uikit/checkbox-input': major
'@commercetools-uikit/password-input': major
'@commercetools-uikit/flat-button': major
'@commercetools-uikit/icon-button': major
'@commercetools-uikit/link-button': major
'@commercetools-uikit/number-field': major
'@commercetools-uikit/select-field': major
'@commercetools-uikit/number-input': major
'@commercetools-uikit/select-input': major
'@commercetools-uikit/select-utils': major
'@commercetools-uikit/toggle-input': major
'@commercetools-uikit/collapsible-motion': major
'@commercetools-uikit/data-table-manager': major
'@commercetools-uikit/money-field': major
'@commercetools-uikit/radio-field': major
'@commercetools-uikit/input-utils': major
'@commercetools-uikit/money-input': major
'@commercetools-uikit/radio-input': major
'@commercetools-uikit/accessible-hidden': major
'@commercetools-uikit/collapsible-panel': major
'@commercetools-uikit/date-field': major
'@commercetools-uikit/text-field': major
'@commercetools-uikit/time-field': major
'@commercetools-uikit/date-input': major
'@commercetools-uikit/text-input': major
'@commercetools-uikit/time-input': major
'@commercetools-uikit/loading-spinner': major
'@commercetools-uikit/field-warnings': major
'@commercetools-uikit/notifications': major
'@commercetools-uikit/quick-filters': major
'@commercetools-uikit/view-switcher': major
'@commercetools-uikit/field-errors': major
'@commercetools-uikit/progress-bar': major
'@commercetools-uikit/collapsible': major
'@commercetools-uikit/constraints': major
'@commercetools-uikit/field-label': major
'@commercetools-uikit/data-table': major
'@commercetools-uikit/pagination': major
'@commercetools-uikit/messages': major
'@commercetools-uikit/filters': major
'@commercetools-uikit/tooltip': major
'@commercetools-uikit/avatar': major
'@commercetools-uikit/icons': major
'@commercetools-uikit/label': major
'@commercetools-uikit/stamp': major
'@commercetools-uikit/card': major
'@commercetools-uikit/grid': major
'@commercetools-uikit/link': major
'@commercetools-uikit/text': major
'@commercetools-uikit/calendar-utils': major
'@commercetools-uikit/tag': major
'visual-testing-app': major
'@commercetools-uikit/spacings': major
'@commercetools-uikit/buttons': major
'@commercetools-uikit/hooks': major
'@commercetools-uikit/utils': major
'@commercetools-uikit/fields': major
'@commercetools-uikit/inputs': major
'@commercetools-frontend/ui-kit': major
'@commercetools-uikit/design-system': major
'@commercetools-local/storybook': major
---

Upgrade UI Kit to React 19
6 changes: 1 addition & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ module.exports = {
'@commercetools-frontend/babel-preset-mc-app',
{
runtime: 'automatic',
keepPropTypes: true,
},
],
],
plugins: [
'babel-plugin-typescript-to-proptypes',
require('./babel-plugin-package-version'),
],
plugins: [require('./babel-plugin-package-version')],
};
3 changes: 1 addition & 2 deletions design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"@commercetools-uikit/hooks": "19.22.0",
"@emotion/react": "^11.10.5",
"lodash": "4.17.21",
"prop-types": "15.8.1",
"react": "17.0.2"
"react": "19.0.0"
},
"devDependencies": {
"nodemon": "^3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion design-system/src/icon-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { css } from '@emotion/react';
import designTokens from './design-tokens';

export type TIconProps = {
export type TIconProps = Record<string, unknown> & {
color?:
| 'solid'
| 'neutral60'
Expand Down
23 changes: 14 additions & 9 deletions design-system/src/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const ThemeProvider = ({
...props
}: ThemeProviderProps) => {
const parentSelectorRef = useRef(parentSelector);
const themeNameRef = useRef<string>();
const themeOverridesRef = useRef<Record<string, string>>();
const themeNameRef = useRef<string>(undefined);
const themeOverridesRef = useRef<Record<string, string>>(undefined);

useLayoutEffect(() => {
// We want to make sure we don't really apply the change when the props
Expand All @@ -88,7 +88,7 @@ const ThemeProvider = ({
!isEqual(themeOverridesRef.current, props.themeOverrides)
) {
themeNameRef.current = theme;
themeOverridesRef.current = props.themeOverrides!;
themeOverridesRef.current = props.themeOverrides;

applyTheme({
newTheme: theme,
Expand Down Expand Up @@ -118,12 +118,17 @@ const useTheme = (parentSelector = defaultParentSelector): TUseThemeResult => {
const [theme, setTheme] = useState<ThemeName>('default');
const parentSelectorRef = useRef(parentSelector);

const mutationChangeCallback = useCallback((mutationList) => {
// We expect only a single element in the mutation list as we configured the
// observer to only listen to `data-theme` changes.
const [mutationEvent] = mutationList;
setTheme((mutationEvent.target as HTMLElement).dataset.theme as ThemeName);
}, []);
const mutationChangeCallback = useCallback(
(mutationList: MutationRecord[]) => {
// We expect only a single element in the mutation list as we configured the
// observer to only listen to `data-theme` changes.
const [mutationEvent] = mutationList;
setTheme(
(mutationEvent.target as HTMLElement).dataset.theme as ThemeName
);
},
[]
);

useMutationObserver(parentSelector(), mutationChangeCallback, {
attributes: true,
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
"@babel/preset-env": "^7.18.6",
"@jest/types": "29.6.3",
"@types/eslint": "^9.0.0",
"@types/react": "17.0.83",
"@types/react-dom": "17.0.26",
"@types/react": "19.0.0",
"@types/react-dom": "19.0.0",
"@types/react-router": "5.1.20",
"@types/unist": "3.0.3",
"@typescript-eslint/eslint-plugin": "8.18.0",
Expand Down Expand Up @@ -114,17 +114,17 @@
"@svgr/core": "8.1.0",
"@svgr/plugin-jsx": "8.1.0",
"@svgr/plugin-svgo": "8.1.0",
"@testing-library/jest-dom": "5.17.0",
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/react": "16.1.0",
"@types/is-hotkey": "^0.1.7",
"@types/jest": "^29.5.14",
"@types/node": "18.19.68",
"@types/prettier": "^2.7.3",
"@types/react-dom": "^19.0.2",
"@typescript-eslint/eslint-plugin": "8.18.0",
"@typescript-eslint/parser": "8.18.0",
"babel-jest": "29.7.0",
"babel-loader": "9.2.1",
"babel-plugin-typescript-to-proptypes": "1.4.2",
"browserslist": "4.24.3",
"bundlesize": "0.18.2",
"cac": "6.7.14",
Expand All @@ -134,7 +134,7 @@
"eslint": "8.57.1",
"eslint-formatter-pretty": "4.1.0",
"execa": "6.1.0",
"formik": "^2.2.9",
"formik": "^2.4.6",
"glob": "8.1.0",
"global": "4.4.0",
"husky": "8.0.3",
Expand All @@ -153,21 +153,21 @@
"moment": "2.30.1",
"moment-timezone": "0.5.46",
"omit-empty-es": "1.2.0",
"patch-package": "6.5.1",
"patch-package": "^8.0.0",
"postcss": "8.4.49",
"postcss-styled-syntax": "^0.7.0",
"postcss-syntax": "^0.36.2",
"postcss-value-parser": "4.2.0",
"pptr-testing-library": "0.8.0",
"prettier": "2.8.8",
"prop-types": "^15.8.1",
"puppeteer": "22.15.0",
"qs": "6.13.1",
"rcfile": "1.0.3",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-intl": "^6.3.2",
"react-router-dom": "5.3.4",
"react-test-renderer": "17.0.2",
"react-value": "0.2.0",
"replace": "1.2.2",
"rimraf": "3.0.2",
Expand Down
9 changes: 4 additions & 5 deletions packages/calendar-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"lodash": "4.17.21",
"prop-types": "15.8.1",
"react-select": "5.9.0"
},
"devDependencies": {
"moment": "2.30.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-intl": "^6.3.2"
},
"peerDependencies": {
"moment": "2.x",
"react": "17.x",
"react-dom": "17.x",
"react": "19.x",
"react-dom": "19.x",
"react-intl": "6.x"
}
}
8 changes: 4 additions & 4 deletions packages/calendar-utils/src/calendar-body/calendar-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const CalendarBody = ({

const onInputFocus = props.inputProps?.onFocus;

const handleInputFocus = useCallback(
const handleInputFocus: FocusEventHandler = useCallback(
(event) => {
toggleIsFocused(true);
if (onInputFocus) onInputFocus(event);
Expand All @@ -97,7 +97,7 @@ export const CalendarBody = ({

const onInputBlur = props.inputProps?.onBlur;

const handleInputBlur = useCallback(
const handleInputBlur: FocusEventHandler = useCallback(
(event) => {
toggleIsFocused(false);
if (onInputBlur) onInputBlur(event);
Expand All @@ -107,7 +107,7 @@ export const CalendarBody = ({

const onToggleFocus = props.toggleButtonProps?.onFocus;

const handleToggleFocus = useCallback(
const handleToggleFocus: FocusEventHandler = useCallback(
(event) => {
toggleIsFocused(true);
if (onToggleFocus) onToggleFocus(event);
Expand All @@ -117,7 +117,7 @@ export const CalendarBody = ({

const onToggleBlur = props.toggleButtonProps?.onBlur;

const handleToggleBlur = useCallback(
const handleToggleBlur: FocusEventHandler = useCallback(
(event) => {
toggleIsFocused(false);
if (onToggleBlur) onToggleBlur(event);
Expand Down
11 changes: 7 additions & 4 deletions packages/calendar-utils/src/calendar-header/calendar-header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback } from 'react';
import { MouseEventHandler, useCallback } from 'react';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { useIntl } from 'react-intl';
Expand Down Expand Up @@ -34,9 +34,12 @@ const CalendarHeader = (props: TCalendarHeader) => {

// we prevent all our defined onClicks inside of the CalendarHeader
// from blurring our input.
const onMouseDown = useCallback((event) => {
event.preventDefault();
}, []);
const onMouseDown: MouseEventHandler<HTMLDivElement> = useCallback(
(event) => {
event.preventDefault();
},
[]
);
return (
<div
onMouseDown={onMouseDown}
Expand Down
7 changes: 3 additions & 4 deletions packages/components/accessible-hidden/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
"dependencies": {
"@babel/runtime": "^7.20.13",
"@babel/runtime-corejs3": "^7.20.13",
"@emotion/react": "^11.10.5",
"prop-types": "15.8.1"
"@emotion/react": "^11.10.5"
},
"devDependencies": {
"react": "17.0.2"
"react": "19.0.0"
},
"peerDependencies": {
"react": "17.x"
"react": "19.x"
}
}
7 changes: 3 additions & 4 deletions packages/components/avatar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
"@commercetools-uikit/utils": "19.22.0",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"lodash": "4.17.21",
"prop-types": "15.8.1"
"lodash": "4.17.21"
},
"devDependencies": {
"react": "17.0.2"
"react": "19.0.0"
},
"peerDependencies": {
"react": "17.x"
"react": "19.x"
}
}
Loading

0 comments on commit 2a616c9

Please sign in to comment.