diff --git a/CHANGELOG.md b/CHANGELOG.md index 076226ae9e77..6f4d663ad990 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.3.2 + +- Maintenance: Revert "WebpackBuilder: Remove need for `react` as peerDependency" - [#23882](https://github.com/storybookjs/storybook/pull/23882), thanks [@vanessayuenn](https://github.com/vanessayuenn)! + ## 7.3.1 - Index: Fix `*.story.*` CSF indexing - [#23852](https://github.com/storybookjs/storybook/pull/23852), thanks [@shilman](https://github.com/shilman)! diff --git a/code/builders/builder-webpack5/package.json b/code/builders/builder-webpack5/package.json index be1dedb5a660..9d31c809a045 100644 --- a/code/builders/builder-webpack5/package.json +++ b/code/builders/builder-webpack5/package.json @@ -56,15 +56,23 @@ "prep": "../../../scripts/prepare/bundle.ts" }, "dependencies": { - "@babel/core": "^7.22.0", + "@babel/core": "^7.22.9", + "@storybook/addons": "workspace:*", "@storybook/channels": "workspace:*", + "@storybook/client-api": "workspace:*", "@storybook/client-logger": "workspace:*", + "@storybook/components": "workspace:*", "@storybook/core-common": "workspace:*", "@storybook/core-events": "workspace:*", "@storybook/core-webpack": "workspace:*", + "@storybook/global": "^5.0.0", + "@storybook/manager-api": "workspace:*", "@storybook/node-logger": "workspace:*", "@storybook/preview": "workspace:*", "@storybook/preview-api": "workspace:*", + "@storybook/router": "workspace:*", + "@storybook/store": "workspace:*", + "@storybook/theming": "workspace:*", "@swc/core": "^1.3.49", "@types/node": "^16.0.0", "@types/semver": "^7.3.4", @@ -102,6 +110,10 @@ "slash": "^5.0.0", "typescript": "~4.9.3" }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + }, "peerDependenciesMeta": { "typescript": { "optional": true diff --git a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts index 704d8fe2b98b..c99a1df1da81 100644 --- a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts +++ b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts @@ -36,29 +36,19 @@ const storybookPaths: Record = { `@storybook/components` )}/dist/experimental`, ...[ - // these packages are not pre-bundled because of react dependencies. - // these are not dependencies of the builder anymore, thus resolving them can fail. - // we should remove the aliases in 8.0, I'm not sure why they are here in the first place. + // these packages are not pre-bundled because of react dependencies 'components', 'global', 'manager-api', 'router', 'theming', - ].reduce((acc, sbPackage) => { - let packagePath; - try { - packagePath = getAbsolutePath(`@storybook/${sbPackage}`); - } catch (e) { - // ignore - } - if (packagePath) { - return { - ...acc, - [`@storybook/${sbPackage}`]: getAbsolutePath(`@storybook/${sbPackage}`), - }; - } - return acc; - }, {}), + ].reduce( + (acc, sbPackage) => ({ + ...acc, + [`@storybook/${sbPackage}`]: getAbsolutePath(`@storybook/${sbPackage}`), + }), + {} + ), // deprecated, remove in 8.0 [`@storybook/api`]: getAbsolutePath(`@storybook/manager-api`), }; diff --git a/code/yarn.lock b/code/yarn.lock index 88afaae488c0..a576cddaf7a5 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -453,7 +453,7 @@ __metadata: languageName: node linkType: hard -"@babel/core@npm:^7.11.6, @babel/core@npm:^7.12.0, @babel/core@npm:^7.12.3, @babel/core@npm:^7.13.16, @babel/core@npm:^7.19.6, @babel/core@npm:^7.20.12, @babel/core@npm:^7.22.0, @babel/core@npm:^7.22.1, @babel/core@npm:^7.22.9, @babel/core@npm:^7.3.4, @babel/core@npm:^7.7.5": +"@babel/core@npm:^7.11.6, @babel/core@npm:^7.12.0, @babel/core@npm:^7.12.3, @babel/core@npm:^7.13.16, @babel/core@npm:^7.19.6, @babel/core@npm:^7.20.12, @babel/core@npm:^7.22.1, @babel/core@npm:^7.22.9, @babel/core@npm:^7.3.4, @babel/core@npm:^7.7.5": version: 7.22.9 resolution: "@babel/core@npm:7.22.9" dependencies: @@ -6466,15 +6466,23 @@ __metadata: version: 0.0.0-use.local resolution: "@storybook/builder-webpack5@workspace:builders/builder-webpack5" dependencies: - "@babel/core": ^7.22.0 + "@babel/core": ^7.22.9 + "@storybook/addons": "workspace:*" "@storybook/channels": "workspace:*" + "@storybook/client-api": "workspace:*" "@storybook/client-logger": "workspace:*" + "@storybook/components": "workspace:*" "@storybook/core-common": "workspace:*" "@storybook/core-events": "workspace:*" "@storybook/core-webpack": "workspace:*" + "@storybook/global": ^5.0.0 + "@storybook/manager-api": "workspace:*" "@storybook/node-logger": "workspace:*" "@storybook/preview": "workspace:*" "@storybook/preview-api": "workspace:*" + "@storybook/router": "workspace:*" + "@storybook/store": "workspace:*" + "@storybook/theming": "workspace:*" "@swc/core": ^1.3.49 "@types/node": ^16.0.0 "@types/pretty-hrtime": ^1.0.0 @@ -6509,6 +6517,9 @@ __metadata: webpack-dev-middleware: ^6.1.1 webpack-hot-middleware: ^2.25.1 webpack-virtual-modules: ^0.5.0 + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 peerDependenciesMeta: typescript: optional: true diff --git a/docs/essentials/controls.md b/docs/essentials/controls.md index 5266c0760f02..cc0f937ec97b 100644 --- a/docs/essentials/controls.md +++ b/docs/essentials/controls.md @@ -123,26 +123,26 @@ If you haven't used the CLI to setup the configuration, or if you want to define ## Fully custom args -Until now, we only used auto-generated controls based on the component we're writing stories for. If we are writing [complex stories](../writing-stories/stories-for-multiple-components.md), we may want to add controls for args that aren’t part of the component. +Until now, we only used auto-generated controls based on the component we're writing stories for. If we are writing [complex stories](../writing-stories/stories-for-multiple-components.md), we may want to add controls for args that aren’t part of the component. For example, here's how you could use a `footer` arg to populate a child component: diff --git a/docs/snippets/angular/page-story-slots.ts.mdx b/docs/snippets/angular/page-story-slots.ts.mdx index 2b79a6caa3e3..63ac7f3309cc 100644 --- a/docs/snippets/angular/page-story-slots.ts.mdx +++ b/docs/snippets/angular/page-story-slots.ts.mdx @@ -5,26 +5,23 @@ import type { Meta, StoryObj } from '@storybook/angular'; import { Page } from './page.component'; -const meta: Meta = { - component: Page, -}; - -export default meta; -type Story = StoryObj; +type PagePropsAndCustomArgs = Page & { footer?: string }; -/* - *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. - * See https://storybook.js.org/docs/angular/api/csf - * to learn how to use render functions. - */ -export const CustomFooter: Story = { - render: (args) => ({ +const meta: Meta = { + component: Page, + render: ({ footer, ...args }) => ({ props: args, template: ` - ${args.footer} + ${footer} `, }), +}; +export default meta; + +type Story = StoryObj; + +export const CustomFooter: Story = { args: { footer: 'Built with Storybook', }, diff --git a/docs/snippets/angular/table-story-fully-customize-controls.ts.mdx b/docs/snippets/angular/table-story-fully-customize-controls.ts.mdx deleted file mode 100644 index 387ca9506c93..000000000000 --- a/docs/snippets/angular/table-story-fully-customize-controls.ts.mdx +++ /dev/null @@ -1,39 +0,0 @@ -```ts -// Table.stories.ts - -import type { Meta, StoryObj } from '@storybook/angular'; - -import { Table } from './Table.component'; - -const meta: Meta = { - component: Table, -}; - -export default meta; -type Story = StoryObj
; - -export const Numeric: Story = { - render: (args) => ({ - props: args, - template: ` -
- - - - - -
- {{data[i][j]}} -
- `, - }), - args: { - data: [ - [1, 2, 3], - [4, 5, 6], - ], - //πŸ‘‡ The remaining args get passed to the `Table` component - size: 'large', - }, -}; -``` diff --git a/docs/snippets/angular/typed-csf-file.ts.mdx b/docs/snippets/angular/typed-csf-file.ts.mdx new file mode 100644 index 000000000000..6ac8b473a93b --- /dev/null +++ b/docs/snippets/angular/typed-csf-file.ts.mdx @@ -0,0 +1,22 @@ +```ts +// Button.stories.ts + +import type { Meta, StoryObj } from '@storybook/angular'; + +import { Button } from './button.component'; + +const meta: Meta + + +``` + +The same setup works with Svelte stories files too, providing both type safety and autocompletion. + +