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

Core: Improve type compatibility with React 19 #30031

Merged
merged 15 commits into from
Jan 27, 2025
Merged
Changes from all commits
Commits
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 code/addons/a11y/src/components/VisionSimulator.tsx
Original file line number Diff line number Diff line change
@@ -42,13 +42,13 @@ const getFilter = (filterName: string) => {
return `url('#${filterName}')`;
};

const Hidden = styled.div(() => ({
const Hidden = styled.div({
'&, & svg': {
position: 'absolute',
width: 0,
height: 0,
},
}));
});

const ColorIcon = styled.span<{ filter: string }>(
{
4 changes: 2 additions & 2 deletions code/addons/interactions/src/components/Interaction.tsx
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@ import { MatcherResult } from './MatcherResult';
import { MethodCall } from './MethodCall';
import { StatusIcon } from './StatusIcon';

const MethodCallWrapper = styled.div(() => ({
const MethodCallWrapper = styled.div({
fontFamily: typography.fonts.mono,
fontSize: typography.size.s1,
overflowWrap: 'break-word',
inlineSize: 'calc( 100% - 40px )',
}));
});

const RowContainer = styled('div', {
shouldForwardProp: (prop) => !['call', 'pausedAt'].includes(prop.toString()),
4 changes: 2 additions & 2 deletions code/addons/onboarding/src/components/List/List.styled.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { styled } from 'storybook/internal/theming';

export const ListWrapper = styled.ul(() => ({
export const ListWrapper = styled.ul({
display: 'flex',
flexDirection: 'column',
rowGap: 16,
padding: 0,
margin: 0,
}));
});
4 changes: 2 additions & 2 deletions code/addons/test/src/components/Interaction.tsx
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@ import { MatcherResult } from './MatcherResult';
import { MethodCall } from './MethodCall';
import { StatusIcon } from './StatusIcon';

const MethodCallWrapper = styled.div(() => ({
const MethodCallWrapper = styled.div({
fontFamily: typography.fonts.mono,
fontSize: typography.size.s1,
overflowWrap: 'break-word',
inlineSize: 'calc( 100% - 40px )',
}));
});

const RowContainer = styled('div', {
shouldForwardProp: (prop) => !['call', 'pausedAt'].includes(prop.toString()),
2 changes: 1 addition & 1 deletion code/addons/test/src/components/TestProviderRender.tsx
Original file line number Diff line number Diff line change
@@ -379,7 +379,7 @@ export const TestProviderRender: FC<TestProviderRenderProps> = ({
icon={
state.crashed ? (
<TestStatusIcon status="critical" aria-label="status: crashed" />
) : // @ts-expect-error: TODO: Fix types
) : // @ts-expect-error @ghengeveld should check whether this is a bug or not
status === 'unknown' ? (
Comment on lines +382 to 383
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The ts-expect-error here suggests there may be a legitimate type mismatch between the status types. This should be investigated to determine if it's a bug or if the types need to be aligned.

<TestStatusIcon status="unknown" aria-label="status: unknown" />
) : (
4 changes: 2 additions & 2 deletions code/addons/viewport/src/legacy/ToolLegacy.tsx
Original file line number Diff line number Diff line change
@@ -74,10 +74,10 @@ const flip = ({ width, height, ...styles }: ViewportStyles) => ({
width: height,
});

const ActiveViewportSize = styled.div(() => ({
const ActiveViewportSize = styled.div({
display: 'inline-flex',
alignItems: 'center',
}));
});

const ActiveViewportLabel = styled.div(({ theme }) => ({
display: 'inline-block',
4 changes: 2 additions & 2 deletions code/addons/viewport/src/utils.tsx
Original file line number Diff line number Diff line change
@@ -7,10 +7,10 @@ import { BrowserIcon, MobileIcon, TabletIcon } from '@storybook/icons';

import type { Viewport, ViewportMap } from './types';

export const ActiveViewportSize = styled.div(() => ({
export const ActiveViewportSize = styled.div({
display: 'inline-flex',
alignItems: 'center',
}));
});

export const ActiveViewportLabel = styled.div(({ theme }) => ({
display: 'inline-block',
14 changes: 7 additions & 7 deletions code/core/package.json
Original file line number Diff line number Diff line change
@@ -296,16 +296,16 @@
"@babel/traverse": "^7.24.1",
"@babel/types": "^7.24.0",
"@discoveryjs/json-ext": "^0.5.3",
"@emotion/cache": "^11.11.0",
"@emotion/is-prop-valid": "^1.2.2",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@emotion/use-insertion-effect-with-fallbacks": "^1.0.1",
"@emotion/cache": "^11.14.0",
"@emotion/is-prop-valid": "^1.3.1",
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@emotion/use-insertion-effect-with-fallbacks": "^1.2.0",
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
"@ndelangen/get-tarball": "^3.0.7",
"@polka/compression": "^1.0.0-next.28",
"@popperjs/core": "^2.6.0",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-scroll-area": "1.2.0-rc.7",
"@radix-ui/react-slot": "^1.0.2",
"@storybook/docs-mdx": "4.0.0-next.1",
@@ -369,7 +369,7 @@
"js-yaml": "^4.1.0",
"lazy-universal-dotenv": "^4.0.0",
"leven": "^4.0.0",
"markdown-to-jsx": "^7.4.5",
"markdown-to-jsx": "^7.7.2",
"memfs": "^4.11.1",
"memoizerific": "^1.11.3",
"nanoid": "^4.0.2",
4 changes: 2 additions & 2 deletions code/core/src/components/components/bar/button.tsx
Original file line number Diff line number Diff line change
@@ -140,11 +140,11 @@ const IconPlaceholder = styled.div(({ theme }) => ({
animation: `${theme.animation.glow} 1.5s ease-in-out infinite`,
}));

const IconButtonSkeletonWrapper = styled.div(() => ({
const IconButtonSkeletonWrapper = styled.div({
marginTop: 6,
padding: 7,
height: 28,
}));
});

/** @deprecated This component will be removed in Storybook 9.0 */
export const IconButtonSkeleton = () => (
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ const NotificationWithInteractiveStates = styled(Notification)({
const NotificationButton = NotificationWithInteractiveStates.withComponent('div');
const NotificationLink = NotificationWithInteractiveStates.withComponent(Link);

const NotificationIconWrapper = styled.div(() => ({
const NotificationIconWrapper = styled.div({
display: 'flex',
marginRight: 10,
alignItems: 'center',
@@ -102,7 +102,7 @@ const NotificationIconWrapper = styled.div(() => ({
width: 16,
height: 16,
},
}));
});

const NotificationTextWrapper = styled.div(({ theme }) => ({
width: '100%',
2 changes: 1 addition & 1 deletion code/lib/blocks/package.json
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@
"@types/color-convert": "^2.0.0",
"color-convert": "^2.0.1",
"es-toolkit": "^1.22.0",
"markdown-to-jsx": "^7.4.5",
"markdown-to-jsx": "^7.7.2",
"memoizerific": "^1.11.3",
"polished": "^4.2.2",
"react-colorful": "^5.1.2",
19 changes: 11 additions & 8 deletions code/lib/blocks/src/blocks/mdx.tsx
Original file line number Diff line number Diff line change
@@ -156,14 +156,17 @@ const OcticonHeaders = SUPPORTED_MDX_HEADERS.reduce(
{}
);

const OcticonAnchor = styled.a(() => ({
float: 'left',
lineHeight: 'inherit',
paddingRight: '10px',
marginLeft: '-24px',
// Allow the theme's text color to override the default link color.
color: 'inherit',
}));
const OcticonAnchor = styled.a(
() =>
({
float: 'left',
lineHeight: 'inherit',
paddingRight: '10px',
marginLeft: '-24px',
// Allow the theme's text color to override the default link color.
color: 'inherit',
}) as const
);

interface HeaderWithOcticonAnchorProps {
as: string;
8 changes: 4 additions & 4 deletions code/lib/blocks/src/components/ArgsTable/SectionRow.tsx
Original file line number Diff line number Diff line change
@@ -74,9 +74,9 @@ const Subsection = styled.td(({ theme }) => ({
background: theme.background.app,
}));

const StyledTd = styled.td(() => ({
const StyledTd = styled.td({
position: 'relative',
}));
});

const StyledTr = styled.tr(({ theme }) => ({
'&:hover > td': {
@@ -86,7 +86,7 @@ const StyledTr = styled.tr(({ theme }) => ({
},
}));

const ClickIntercept = styled.button(() => ({
const ClickIntercept = styled.button({
// reset button style
background: 'none',
border: 'none',
@@ -103,7 +103,7 @@ const ClickIntercept = styled.button(() => ({
width: '100%',
color: 'transparent',
cursor: 'row-resize !important',
}));
});

export const SectionRow: FC<SectionRowProps> = ({
level = 'section',
2 changes: 1 addition & 1 deletion code/renderers/react/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentType } from 'react';
import type { ComponentType, JSX } from 'react';

import type { Canvas, WebRenderer } from 'storybook/internal/types';

1 change: 1 addition & 0 deletions code/vitest-setup.ts
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ const ignoreList = [
/React will try to recreate this component tree from scratch using the error boundary you provided/
),
(error: any) => error.message.includes('Lit is in dev mode. Not recommended for production!'),
(error: any) => error.message.includes('error: `DialogContent` requires a `DialogTitle`'),
];

const throwMessage = (type: any, message: any) => {
396 changes: 309 additions & 87 deletions code/yarn.lock

Large diffs are not rendered by default.