diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f3f5db4ef8..14ec5e5f638 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,70 @@ +## 6.4.0-beta.31 (November 10, 2021) + +### Features + +* Core: Add feature flag to stop storybook from aliasing emotion ([#16613](https://github.com/storybookjs/storybook/pull/16613)) + +### Bug Fixes + +* Core: Fix `staticDirs` and `-s` conflict check ([#16649](https://github.com/storybookjs/storybook/pull/16649)) + +### Maintenance + +* Build: Add node-gyp for M1 macs ([#16645](https://github.com/storybookjs/storybook/pull/16645)) + +## 6.4.0-beta.30 (November 8, 2021) + +### Features + +- Args: Add ability to specific argType "targets" ([#16333](https://github.com/storybookjs/storybook/pull/16333)) + +### Bug Fixes + +- Core: Fix sorting by `__namedExportsOrder` ([#16626](https://github.com/storybookjs/storybook/pull/16626)) +- Angular: Fix zonejs imports in framework preset ([#16631](https://github.com/storybookjs/storybook/pull/16631)) +- Core: Change CSF loading problems from warning to error ([#16632](https://github.com/storybookjs/storybook/pull/16632)) +- Core: Fix args values updated from url to control ([#16508](https://github.com/storybookjs/storybook/pull/16508)) +- CLI: Fix upgrade error state ([#16622](https://github.com/storybookjs/storybook/pull/16622)) + +## 6.4.0-beta.29 (November 6, 2021) + +### Features + +- CSFFile: Handle re-exported stories ([#16607](https://github.com/storybookjs/storybook/pull/16607)) + +### Bug Fixes + +- StoryIndex: Skip files with no default export ([#16606](https://github.com/storybookjs/storybook/pull/16606)) +- Addon-docs/Source: Fix disabling show code with null ([#16615](https://github.com/storybookjs/storybook/pull/16615)) +- Core: Handle missing websocket in production build ([#16590](https://github.com/storybookjs/storybook/pull/16590)) +- Core: Ensure we set `parameters.filePath` in v7 mode ([#16566](https://github.com/storybookjs/storybook/pull/16566)) +- Core: Fix behavior around missing stories to be more clear ([#16608](https://github.com/storybookjs/storybook/pull/16608)) + +## 6.4.0-beta.28 (November 5, 2021) + +### Bug Fixes + +- Interactions: Fix README link ([#16596](https://github.com/storybookjs/storybook/pull/16596)) + +## 6.4.0-beta.27 (November 4, 2021) + +### Features + +- Core: Add 'staticDirs' config option ([#15969](https://github.com/storybookjs/storybook/pull/15969)) + +### Bug Fixes + +- TS: Fix type for Refs so they can be disabled ([#16582](https://github.com/storybookjs/storybook/pull/16582)) +- CLI: Add a check for source-dir in `sb extract` ([#16505](https://github.com/storybookjs/storybook/pull/16505)) +- UI: Fix links that have no onClick handler ([#16581](https://github.com/storybookjs/storybook/pull/16581)) +- Core: Continue running play function on rerender ([#16574](https://github.com/storybookjs/storybook/pull/16574)) +- Ensure we always initialize the story store, even when the index errors. ([#16537](https://github.com/storybookjs/storybook/pull/16537)) +- Interactions: Fix panel tab icon/count ([#16578](https://github.com/storybookjs/storybook/pull/16578)) + +### Dependency Upgrades + +- Pin the version of `history` for `react-router-dom` compat ([#16560](https://github.com/storybookjs/storybook/pull/16560)) + ## 6.4.0-beta.26 (November 2, 2021) ### Bug Fixes diff --git a/MIGRATION.md b/MIGRATION.md index e8a52225216..845393ade0c 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -16,6 +16,8 @@ - [Babel mode v7](#babel-mode-v7) - [Loader behavior with args changes](#loader-behavior-with-args-changes) - [Angular component parameter removed](#angular-component-parameter-removed) + - [6.4 deprecations](#64-deprecations) + - [Deprecated --static-dir CLI flag](#deprecated---static-dir-cli-flag) - [From version 6.2.x to 6.3.0](#from-version-62x-to-630) - [Webpack 5](#webpack-5) - [Fixing hoisting issues](#fixing-hoisting-issues) @@ -189,7 +191,7 @@ Storybook 6.3 supports CRA5 out of the box when you install it fresh. However, i upgrade the configuration. You can do this automatically by running: ``` -npx sb@next fix +npx sb@next automigrate ``` Or you can do the following steps manually to force Storybook to use webpack 5 for building your project: @@ -452,6 +454,29 @@ export const MyStory = () => ({ component: MyComponent, ... }) [More discussion here.](https://github.com/storybookjs/storybook/pull/16010#issuecomment-917378595) +### 6.4 deprecations + +#### Deprecated --static-dir CLI flag + +In 6.4 we've replaced the `--static-dir` CLI flag with the the `staticDirs` field in `.storybook/main.js`. Note that the CLI directories are relative to the current working directory, whereas the `staticDirs` are relative to the location of `main.js`. + +Before: + +```sh +start-storybook --static-dir ./public,./static,./foo/assets:/assets +``` + +After: + +```js +// .storybook/main.js +module.exports = { + staticDirs: ['../public', '../static', { from: '../foo/assets', to: '/assets' }], +}; +``` + +The `--static-dir` flag has been deprecated and will be removed in Storybook 7.0. + ## From version 6.2.x to 6.3.0 ### Webpack 5 @@ -610,7 +635,7 @@ export const Basic = () => ({ }); ``` -The new convention is consistent with how other frameworks and addons work in Storybook. The old way will be supported until 7.0. For a full discussion see https://github.com/storybookjs/storybook/issues/8673. +The new convention is consistent with how other frameworks and addons work in Storybook. The old way will be supported until 7.0. For a full discussion see . #### New Angular renderer @@ -647,7 +672,7 @@ Instead of continuing to include PostCSS inside the core library, it has been mo If you require PostCSS support, please install `@storybook/addon-postcss` in your project, add it to your list of addons inside `.storybook/main.js`, and configure a `postcss.config.js` file. -Further information is available at https://github.com/storybookjs/storybook/issues/12668 and https://github.com/storybookjs/storybook/pull/13669. +Further information is available at and . If you're not using Postcss and you don't want to see the warning, you can disable it by adding the following to your `.storybook/main.js`: @@ -788,7 +813,7 @@ Starting in 6.1, `react` and `react-dom` are required peer dependencies of `@sto Error: Cannot find module 'react-dom/package.json' ``` -They were also peer dependencies in earlier versions, but due to the package structure they would be installed by Storybook if they were not required by the user's project. For more discussion: https://github.com/storybookjs/storybook/issues/13269 +They were also peer dependencies in earlier versions, but due to the package structure they would be installed by Storybook if they were not required by the user's project. For more discussion: ### 6.1 deprecations @@ -817,7 +842,7 @@ console.log(unboundStoryFn(context)); If you're not using loaders, `storyFn` will work as before. If you are, you'll need to use the new approach. -> NOTE: If you're using `@storybook/addon-docs`, this deprecation warning is triggered by the Docs tab in 6.1. It's safe to ignore and we will be providing a proper fix in a future release. You can track the issue at https://github.com/storybookjs/storybook/issues/13074. +> NOTE: If you're using `@storybook/addon-docs`, this deprecation warning is triggered by the Docs tab in 6.1. It's safe to ignore and we will be providing a proper fix in a future release. You can track the issue at . #### Deprecated onBeforeRender @@ -2287,16 +2312,16 @@ The `@storybook/react-native` had built-in addons (`addon-actions` and `addon-li ### Storyshots Changes -1. `imageSnapshot` test function was extracted from `addon-storyshots` - and moved to a new package - `addon-storyshots-puppeteer` that now will - be dependant on puppeteer. [README](https://github.com/storybookjs/storybook/tree/master/addons/storyshots/storyshots-puppeteer) -2. `getSnapshotFileName` export was replaced with the `Stories2SnapsConverter` - class that now can be overridden for a custom implementation of the - snapshot-name generation. [README](https://github.com/storybookjs/storybook/tree/master/addons/storyshots/storyshots-core#stories2snapsconverter) -3. Storybook that was configured with Webpack's `require.context()` feature - will need to add a babel plugin to polyfill this functionality. - A possible plugin might be [babel-plugin-require-context-hook](https://github.com/smrq/babel-plugin-require-context-hook). - [README](https://github.com/storybookjs/storybook/tree/master/addons/storyshots/storyshots-core#configure-jest-to-work-with-webpacks-requirecontext) +1. `imageSnapshot` test function was extracted from `addon-storyshots` + and moved to a new package - `addon-storyshots-puppeteer` that now will + be dependant on puppeteer. [README](https://github.com/storybookjs/storybook/tree/master/addons/storyshots/storyshots-puppeteer) +2. `getSnapshotFileName` export was replaced with the `Stories2SnapsConverter` + class that now can be overridden for a custom implementation of the + snapshot-name generation. [README](https://github.com/storybookjs/storybook/tree/master/addons/storyshots/storyshots-core#stories2snapsconverter) +3. Storybook that was configured with Webpack's `require.context()` feature + will need to add a babel plugin to polyfill this functionality. + A possible plugin might be [babel-plugin-require-context-hook](https://github.com/smrq/babel-plugin-require-context-hook). + [README](https://github.com/storybookjs/storybook/tree/master/addons/storyshots/storyshots-core#configure-jest-to-work-with-webpacks-requirecontext) ### Webpack 4 @@ -2307,9 +2332,11 @@ Storybook now uses webpack 4. If you have a [custom webpack config](https://stor Storybook now uses Babel 7. There's a couple of cases when it can break with your app: - If you aren't using Babel yourself, and don't have .babelrc, install following dependencies: + ``` npm i -D @babel/core babel-loader@next ``` + - If you're using Babel 6, make sure that you have direct dependencies on `babel-core@6` and `babel-loader@7` and that you have a `.babelrc` in your project directory. ### Create-react-app @@ -2560,11 +2587,14 @@ If you **are** using these addons, it takes two steps to migrate: - add the addons you use to your `package.json`. - update your code: change `addons.js` like so: + ```js import '@storybook/addon-actions/register'; import '@storybook/addon-links/register'; ``` + change `x.story.js` like so: + ```js import React from 'react'; import { storiesOf } from '@storybook/react'; diff --git a/addons/a11y/package.json b/addons/a11y/package.json index 4d643ba5536..45915f73bc3 100644 --- a/addons/a11y/package.json +++ b/addons/a11y/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-a11y", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Test component compliance with web accessibility standards", "keywords": [ "a11y", @@ -45,14 +45,14 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/channels": "6.4.0-beta.26", - "@storybook/client-logger": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/channels": "6.4.0-beta.31", + "@storybook/client-logger": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/theming": "6.4.0-beta.31", "axe-core": "^4.2.0", "core-js": "^3.8.2", "global": "^4.4.0", @@ -81,7 +81,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js", "storybook": { "displayName": "Accessibility", diff --git a/addons/actions/package.json b/addons/actions/package.json index ee770643a1b..6985c87be63 100644 --- a/addons/actions/package.json +++ b/addons/actions/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-actions", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Get UI feedback when an action is performed on an interactive element", "keywords": [ "storybook", @@ -41,12 +41,12 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/theming": "6.4.0-beta.31", "core-js": "^3.8.2", "fast-deep-equal": "^3.1.3", "global": "^4.4.0", @@ -79,7 +79,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js", "storybook": { "displayName": "Actions", diff --git a/addons/backgrounds/package.json b/addons/backgrounds/package.json index f5c7d37acab..068d91ff2eb 100644 --- a/addons/backgrounds/package.json +++ b/addons/backgrounds/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-backgrounds", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Switch backgrounds to view components in different settings", "keywords": [ "addon", @@ -45,13 +45,13 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/client-logger": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/client-logger": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/theming": "6.4.0-beta.31", "core-js": "^3.8.2", "global": "^4.4.0", "memoizerific": "^1.11.3", @@ -77,7 +77,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js", "storybook": { "displayName": "Backgrounds", diff --git a/addons/controls/package.json b/addons/controls/package.json index 4fe9a7a9fe4..2a656a7e6c7 100644 --- a/addons/controls/package.json +++ b/addons/controls/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-controls", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Interact with component inputs dynamically in the Storybook UI", "keywords": [ "addon", @@ -45,15 +45,15 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/client-logger": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/client-logger": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/node-logger": "6.4.0-beta.26", - "@storybook/store": "6.4.0-beta.26", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/node-logger": "6.4.0-beta.31", + "@storybook/store": "6.4.0-beta.31", + "@storybook/theming": "6.4.0-beta.31", "core-js": "^3.8.2", "lodash": "^4.17.20", "ts-dedent": "^2.0.0" @@ -73,7 +73,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/register.js", "storybook": { "displayName": "Controls", diff --git a/addons/docs/package.json b/addons/docs/package.json index d263ed8be2e..d00cedc9a8b 100644 --- a/addons/docs/package.json +++ b/addons/docs/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-docs", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Document component usage and properties in Markdown", "keywords": [ "addon", @@ -63,21 +63,21 @@ "@mdx-js/loader": "^1.6.22", "@mdx-js/mdx": "^1.6.22", "@mdx-js/react": "^1.6.22", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/builder-webpack4": "6.4.0-beta.26", - "@storybook/client-logger": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/builder-webpack4": "6.4.0-beta.31", + "@storybook/client-logger": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/csf-tools": "6.4.0-beta.26", - "@storybook/node-logger": "6.4.0-beta.26", - "@storybook/postinstall": "6.4.0-beta.26", - "@storybook/preview-web": "6.4.0-beta.26", - "@storybook/source-loader": "6.4.0-beta.26", - "@storybook/store": "6.4.0-beta.26", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/csf-tools": "6.4.0-beta.31", + "@storybook/node-logger": "6.4.0-beta.31", + "@storybook/postinstall": "6.4.0-beta.31", + "@storybook/preview-web": "6.4.0-beta.31", + "@storybook/source-loader": "6.4.0-beta.31", + "@storybook/store": "6.4.0-beta.31", + "@storybook/theming": "6.4.0-beta.31", "acorn": "^7.4.1", "acorn-jsx": "^5.3.1", "acorn-walk": "^7.2.0", @@ -106,11 +106,11 @@ "@babel/core": "^7.12.10", "@emotion/core": "^10.1.1", "@emotion/styled": "^10.0.27", - "@storybook/angular": "6.4.0-beta.26", - "@storybook/html": "6.4.0-beta.26", - "@storybook/react": "6.4.0-beta.26", - "@storybook/vue": "6.4.0-beta.26", - "@storybook/web-components": "6.4.0-beta.26", + "@storybook/angular": "6.4.0-beta.31", + "@storybook/html": "6.4.0-beta.31", + "@storybook/react": "6.4.0-beta.31", + "@storybook/vue": "6.4.0-beta.31", + "@storybook/web-components": "6.4.0-beta.31", "@types/cross-spawn": "^6.0.2", "@types/doctrine": "^0.0.3", "@types/enzyme": "^3.10.8", @@ -140,12 +140,12 @@ "zone.js": "^0.11.3" }, "peerDependencies": { - "@storybook/angular": "6.4.0-beta.26", - "@storybook/html": "6.4.0-beta.26", - "@storybook/react": "6.4.0-beta.26", - "@storybook/vue": "6.4.0-beta.26", - "@storybook/vue3": "6.4.0-beta.26", - "@storybook/web-components": "6.4.0-beta.26", + "@storybook/angular": "6.4.0-beta.31", + "@storybook/html": "6.4.0-beta.31", + "@storybook/react": "6.4.0-beta.31", + "@storybook/vue": "6.4.0-beta.31", + "@storybook/vue3": "6.4.0-beta.31", + "@storybook/web-components": "6.4.0-beta.31", "lit": "^2.0.0-rc.1", "lit-html": "^1.4.1 || ^2.0.0-rc.3", "react": "^16.8.0 || ^17.0.0", @@ -202,7 +202,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js", "storybook": { "displayName": "Docs", diff --git a/addons/docs/src/blocks/Source.tsx b/addons/docs/src/blocks/Source.tsx index 2fa59005525..29e81215ae8 100644 --- a/addons/docs/src/blocks/Source.tsx +++ b/addons/docs/src/blocks/Source.tsx @@ -69,7 +69,7 @@ const getSnippet = (snippet: string, story?: Story): string => { // if user has hard-coded the snippet, that takes precedence const userCode = parameters.docs?.source?.code; - if (userCode) { + if (userCode !== undefined) { return userCode; } diff --git a/addons/essentials/package.json b/addons/essentials/package.json index f8dae2dcd2c..7ea25c5bc7c 100644 --- a/addons/essentials/package.json +++ b/addons/essentials/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-essentials", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Curated addons to bring out the best of Storybook", "keywords": [ "addon", @@ -39,31 +39,31 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addon-actions": "6.4.0-beta.26", - "@storybook/addon-backgrounds": "6.4.0-beta.26", - "@storybook/addon-controls": "6.4.0-beta.26", - "@storybook/addon-docs": "6.4.0-beta.26", - "@storybook/addon-measure": "6.4.0-beta.26", - "@storybook/addon-outline": "6.4.0-beta.26", - "@storybook/addon-toolbars": "6.4.0-beta.26", - "@storybook/addon-viewport": "6.4.0-beta.26", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/node-logger": "6.4.0-beta.26", + "@storybook/addon-actions": "6.4.0-beta.31", + "@storybook/addon-backgrounds": "6.4.0-beta.31", + "@storybook/addon-controls": "6.4.0-beta.31", + "@storybook/addon-docs": "6.4.0-beta.31", + "@storybook/addon-measure": "6.4.0-beta.31", + "@storybook/addon-outline": "6.4.0-beta.31", + "@storybook/addon-toolbars": "6.4.0-beta.31", + "@storybook/addon-viewport": "6.4.0-beta.31", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/node-logger": "6.4.0-beta.31", "core-js": "^3.8.2", "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "devDependencies": { "@babel/core": "^7.12.10", - "@storybook/vue": "6.4.0-beta.26", + "@storybook/vue": "6.4.0-beta.31", "@types/jest": "^26.0.16", "@types/webpack-env": "^1.16.0" }, "peerDependencies": { "@babel/core": "^7.9.6", - "@storybook/vue": "6.4.0-beta.26", - "@storybook/web-components": "6.4.0-beta.26", + "@storybook/vue": "6.4.0-beta.31", + "@storybook/web-components": "6.4.0-beta.31", "babel-loader": "^8.0.0", "lit-html": "^1.4.1 || ^2.0.0-rc.3", "react": "^16.8.0 || ^17.0.0", @@ -93,6 +93,6 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js" } diff --git a/addons/interactions/README.md b/addons/interactions/README.md index 680d48e6bef..d3687e084f3 100644 --- a/addons/interactions/README.md +++ b/addons/interactions/README.md @@ -22,6 +22,19 @@ module.exports = { Note that `@storybook/addon-interactions` must be listed **after** `@storybook/addon-actions` or `@storybook/addon-essentials`. +## Experimental step debugging + +Step debugging features are experimental and disabled by default. To enable them: + +```js +// main.js +module.exports = { + features: { + interactionsDebugger: true, + }, +}; +``` + ## Usage Interactions relies on "instrumented" versions of Jest and Testing Library, that you import from `@storybook/jest` and @@ -43,8 +56,8 @@ export const Demo = { const canvas = within(canvasElement); await userEvent.click(canvas.getByRole('button')); await expect(args.onClick).toHaveBeenCalled(); - } -} + }, +}; ``` In order to enable step-through debugging, calls to `userEvent.*`, `fireEvent`, `findBy*`, `waitFor*` and `expect` have to diff --git a/addons/interactions/package.json b/addons/interactions/package.json index 562179c9a72..b8b0099bb0c 100644 --- a/addons/interactions/package.json +++ b/addons/interactions/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-interactions", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Automate, test and debug user interactions", "keywords": [ "storybook-addons", @@ -41,14 +41,14 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/instrumenter": "6.4.0-beta.26", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/instrumenter": "6.4.0-beta.31", + "@storybook/theming": "6.4.0-beta.31", "global": "^4.4.0", "jest-mock": "^27.0.6", "polished": "^4.0.5", @@ -74,7 +74,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js", "storybook": { "displayName": "Interactions", diff --git a/addons/interactions/src/Panel.tsx b/addons/interactions/src/Panel.tsx index 266a9212b80..8b21f905059 100644 --- a/addons/interactions/src/Panel.tsx +++ b/addons/interactions/src/Panel.tsx @@ -19,7 +19,6 @@ interface AddonPanelProps { interface InteractionsPanelProps { active: boolean; - showTabIcon?: boolean; interactions: (Call & { state?: CallStates })[]; isDisabled?: boolean; hasPrevious?: boolean; @@ -45,9 +44,13 @@ const TabIcon = styled(StatusIcon)({ marginLeft: 5, }); +const TabStatus = ({ children }: { children: React.ReactChild }) => { + const container = global.document.getElementById('tabbutton-interactions'); + return container && ReactDOM.createPortal(children, container); +}; + export const AddonPanelPure: React.FC = React.memo( ({ - showTabIcon, interactions, isDisabled, hasPrevious, @@ -65,57 +68,50 @@ export const AddonPanelPure: React.FC = React.memo( endRef, isDebuggingEnabled, ...panelProps - }) => { - return ( - - {showTabIcon && - ReactDOM.createPortal( - , - global.document.getElementById('tabbutton-interactions') - )} - {isDebuggingEnabled && interactions.length > 0 && ( - - )} - {interactions.map((call) => ( - onInteractionClick(call.id)} - /> - ))} -
- {!isPlaying && interactions.length === 0 && ( - - No interactions found - - Learn how to add interactions to your story - - - )} - - ); - } + }) => ( + + {isDebuggingEnabled && interactions.length > 0 && ( + + )} + {interactions.map((call) => ( + onInteractionClick(call.id)} + /> + ))} +
+ {!isPlaying && interactions.length === 0 && ( + + No interactions found + + Learn how to add interactions to your story + + + )} + + ) ); export const Panel: React.FC = (props) => { @@ -156,6 +152,7 @@ export const Panel: React.FC = (props) => { const isDebuggingEnabled = FEATURES.interactionsDebugger === true; + const showStatus = log.length > 0 && !isPlaying; const isDebugging = log.some((item) => pendingStates.includes(item.state)); const hasPrevious = log.some((item) => completedStates.includes(item.state)); const hasNext = log.some((item) => item.state === CallStates.WAITING); @@ -165,8 +162,6 @@ export const Panel: React.FC = (props) => { ? hasActive || isLocked || (isPlaying && !isDebugging) : true; - const showTabIcon = isDebugging || (!isPlaying && hasException); - const onStart = React.useCallback(() => emit(EVENTS.START, { storyId }), [storyId]); const onPrevious = React.useCallback(() => emit(EVENTS.BACK, { storyId }), [storyId]); const onNext = React.useCallback(() => emit(EVENTS.NEXT, { storyId }), [storyId]); @@ -177,25 +172,30 @@ export const Panel: React.FC = (props) => { ); return ( - + + + {showStatus && + (hasException ? : ` (${interactions.length})`)} + + + ); }; diff --git a/addons/interactions/src/components/AccountForm/addon-interactions.stories.tsx b/addons/interactions/src/components/AccountForm/addon-interactions.stories.tsx index cf3ffc6a4e9..962f09543db 100644 --- a/addons/interactions/src/components/AccountForm/addon-interactions.stories.tsx +++ b/addons/interactions/src/components/AccountForm/addon-interactions.stories.tsx @@ -8,7 +8,11 @@ import { AccountForm } from './AccountForm'; export default { title: 'Addons/Interactions/AccountForm', component: AccountForm, - parameters: { layout: 'centered', theme: 'light' }, + parameters: { + layout: 'centered', + theme: 'light', + options: { selectedPanel: 'storybook/interactions/panel' }, + }, argTypes: { onSubmit: { action: true }, }, @@ -58,15 +62,11 @@ export const StandardEmailFailed: CSF3Story = { ...Standard, play: async ({ args, canvasElement }) => { const canvas = within(canvasElement); - await userEvent.type(canvas.getByTestId('email'), 'me'); - await userEvent.type(canvas.getByTestId('password1'), 'helloyou'); + await userEvent.type(canvas.getByTestId('email'), 'gert@chromatic'); + await userEvent.type(canvas.getByTestId('password1'), 'supersecret'); await userEvent.click(canvas.getByRole('button', { name: /create account/i })); - await canvas.findByText( - 'Please enter a correctly formatted email address', - {}, - { timeout: 2000 } - ); + await canvas.findByText('Please enter a correctly formatted email address'); expect(args.onSubmit).not.toHaveBeenCalled(); }, }; diff --git a/addons/interactions/src/components/StatusIcon/StatusIcon.tsx b/addons/interactions/src/components/StatusIcon/StatusIcon.tsx index d7b0c843eb7..9aed8af4df2 100644 --- a/addons/interactions/src/components/StatusIcon/StatusIcon.tsx +++ b/addons/interactions/src/components/StatusIcon/StatusIcon.tsx @@ -31,12 +31,19 @@ const StyledStatusIcon = styled(Icons)(({ theme, status }) => { }; }); -export const StatusIcon: React.FC = ({ status }) => { +export const StatusIcon: React.FC = ({ status, className }) => { const icon = { [CallStates.DONE]: 'check', [CallStates.ERROR]: 'stopalt', [CallStates.ACTIVE]: 'play', [CallStates.WAITING]: 'circle', }[status] as IconsProps['icon']; - return ; + return ( + + ); }; diff --git a/addons/jest/package.json b/addons/jest/package.json index f7a1e7dc551..e603c31f409 100644 --- a/addons/jest/package.json +++ b/addons/jest/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-jest", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "React storybook addon that show component jest report", "keywords": [ "addon", @@ -47,11 +47,11 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", + "@storybook/theming": "6.4.0-beta.31", "core-js": "^3.8.2", "global": "^4.4.0", "react-sizeme": "^3.0.1", @@ -76,7 +76,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js", "storybook": { "displayName": "Jest", diff --git a/addons/links/package.json b/addons/links/package.json index 9238880239e..8027c2e22f1 100644 --- a/addons/links/package.json +++ b/addons/links/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-links", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Link stories together to build demos and prototypes with your UI components", "keywords": [ "addon", @@ -41,11 +41,11 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/client-logger": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/client-logger": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/router": "6.4.0-beta.26", + "@storybook/router": "6.4.0-beta.31", "@types/qs": "^6.9.5", "core-js": "^3.8.2", "global": "^4.4.0", @@ -72,7 +72,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js", "storybook": { "displayName": "Links", diff --git a/addons/measure/package.json b/addons/measure/package.json index a652b35a283..93e338ccbe3 100644 --- a/addons/measure/package.json +++ b/addons/measure/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-measure", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Inspect layouts by visualizing the box model", "keywords": [ "storybook-addons", @@ -44,11 +44,11 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/client-logger": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/client-logger": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", "core-js": "^3.8.2", "global": "^4.4.0" @@ -71,7 +71,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js", "storybook": { "displayName": "Measure", diff --git a/addons/outline/package.json b/addons/outline/package.json index 51c92676d09..bfdb8ddaf07 100644 --- a/addons/outline/package.json +++ b/addons/outline/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-outline", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Outline all elements with CSS to help with layout placement and alignment", "keywords": [ "storybook-addons", @@ -47,11 +47,11 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/client-logger": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/client-logger": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", "core-js": "^3.8.2", "global": "^4.4.0", @@ -76,7 +76,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js", "storybook": { "displayName": "Outline", diff --git a/addons/storyshots/storyshots-core/package.json b/addons/storyshots/storyshots-core/package.json index a292d35ca39..67bcacdf0f7 100644 --- a/addons/storyshots/storyshots-core/package.json +++ b/addons/storyshots/storyshots-core/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-storyshots", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Take a code snapshot of every story automatically with Jest", "keywords": [ "addon", @@ -45,11 +45,11 @@ }, "dependencies": { "@jest/transform": "^26.6.2", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/client-api": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-client": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/client-api": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-client": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", "@types/glob": "^7.1.3", "@types/jest": "^26.0.16", @@ -69,11 +69,11 @@ "devDependencies": { "@angular/core": "^11.2.0", "@angular/platform-browser-dynamic": "^11.2.0", - "@storybook/addon-docs": "6.4.0-beta.26", - "@storybook/angular": "6.4.0-beta.26", - "@storybook/react": "6.4.0-beta.26", - "@storybook/vue": "6.4.0-beta.26", - "@storybook/vue3": "6.4.0-beta.26", + "@storybook/addon-docs": "6.4.0-beta.31", + "@storybook/angular": "6.4.0-beta.31", + "@storybook/react": "6.4.0-beta.31", + "@storybook/vue": "6.4.0-beta.31", + "@storybook/vue3": "6.4.0-beta.31", "babel-loader": "^8.0.0", "enzyme": "^3.11.0", "enzyme-to-json": "^3.6.1", @@ -151,7 +151,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "storybook": { "displayName": "Storyshots", "icon": "https://user-images.githubusercontent.com/263385/101991676-48cdf300-3c7c-11eb-8aa1-944dab6ab29b.png", diff --git a/addons/storyshots/storyshots-puppeteer/package.json b/addons/storyshots/storyshots-puppeteer/package.json index 79252e39962..58223364919 100644 --- a/addons/storyshots/storyshots-puppeteer/package.json +++ b/addons/storyshots/storyshots-puppeteer/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-storyshots-puppeteer", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Image snapshots addition to StoryShots based on puppeteer", "keywords": [ "addon", @@ -42,7 +42,7 @@ "dependencies": { "@axe-core/puppeteer": "^4.2.0", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/node-logger": "6.4.0-beta.26", + "@storybook/node-logger": "6.4.0-beta.31", "@types/jest-image-snapshot": "^4.1.3", "core-js": "^3.8.2", "jest-image-snapshot": "^4.3.0", @@ -53,7 +53,7 @@ "@types/puppeteer": "^5.4.0" }, "peerDependencies": { - "@storybook/addon-storyshots": "6.4.0-beta.26", + "@storybook/addon-storyshots": "6.4.0-beta.31", "puppeteer": "^2.0.0 || ^3.0.0" }, "peerDependenciesMeta": { @@ -64,5 +64,5 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e" + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267" } diff --git a/addons/storysource/package.json b/addons/storysource/package.json index f2848ae1f87..ae0a90d839d 100644 --- a/addons/storysource/package.json +++ b/addons/storysource/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-storysource", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "View a story’s source code to see how it works and paste into your app", "keywords": [ "addon", @@ -41,13 +41,13 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/client-logger": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/router": "6.4.0-beta.26", - "@storybook/source-loader": "6.4.0-beta.26", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/client-logger": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/router": "6.4.0-beta.31", + "@storybook/source-loader": "6.4.0-beta.31", + "@storybook/theming": "6.4.0-beta.31", "core-js": "^3.8.2", "estraverse": "^5.2.0", "loader-utils": "^2.0.0", @@ -75,7 +75,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/index.js", "storybook": { "displayName": "Storysource", diff --git a/addons/toolbars/package.json b/addons/toolbars/package.json index 02f7c161206..a7fcc7ea221 100644 --- a/addons/toolbars/package.json +++ b/addons/toolbars/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-toolbars", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Create your own toolbar items that control story rendering", "keywords": [ "addon", @@ -45,10 +45,10 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/theming": "6.4.0-beta.31", "core-js": "^3.8.2", "regenerator-runtime": "^0.13.7" }, @@ -67,7 +67,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/register.js", "storybook": { "displayName": "Toolbars", diff --git a/addons/viewport/package.json b/addons/viewport/package.json index ef42c36a8f7..1f3d9078d3e 100644 --- a/addons/viewport/package.json +++ b/addons/viewport/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-viewport", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Build responsive components by adjusting Storybook’s viewport size and orientation", "keywords": [ "addon", @@ -42,12 +42,12 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/client-logger": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/client-logger": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", + "@storybook/theming": "6.4.0-beta.31", "core-js": "^3.8.2", "global": "^4.4.0", "memoizerific": "^1.11.3", @@ -69,7 +69,7 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/preview.js", "storybook": { "displayName": "Viewport", diff --git a/app/angular/package.json b/app/angular/package.json index 0c26c6622d0..4e49217f709 100644 --- a/app/angular/package.json +++ b/app/angular/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/angular", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Storybook for Angular: Develop Angular Components in isolation with Hot Reloading.", "keywords": [ "storybook" @@ -45,14 +45,14 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/node-logger": "6.4.0-beta.26", - "@storybook/store": "6.4.0-beta.26", + "@storybook/node-logger": "6.4.0-beta.31", + "@storybook/store": "6.4.0-beta.31", "@types/webpack-env": "^1.16.0", "autoprefixer": "^9.8.6", "core-js": "^3.8.2", @@ -131,5 +131,5 @@ "access": "public" }, "builders": "dist/ts3.9/builders/builders.json", - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e" + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267" } diff --git a/app/angular/src/client/preview/config.ts b/app/angular/src/client/preview/config.ts index f6f8d190dc7..4f80f032131 100644 --- a/app/angular/src/client/preview/config.ts +++ b/app/angular/src/client/preview/config.ts @@ -1,3 +1,5 @@ +import './globals'; + export { render, renderToDOM } from './render'; export { decorateStory } from './decorateStory'; diff --git a/app/ember/package.json b/app/ember/package.json index f42f4c3e2a0..554914f4e00 100644 --- a/app/ember/package.json +++ b/app/ember/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/ember", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Storybook for Ember: Develop Ember Component in isolation with Hot Reloading.", "homepage": "https://github.com/storybookjs/storybook/tree/main/app/ember", "bugs": { @@ -43,9 +43,9 @@ }, "dependencies": { "@ember/test-helpers": "^2.1.4", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", - "@storybook/store": "6.4.0-beta.26", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", + "@storybook/store": "6.4.0-beta.31", "core-js": "^3.8.2", "global": "^4.4.0", "react": "16.14.0", @@ -66,6 +66,6 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/client/index.js" } diff --git a/app/html/package.json b/app/html/package.json index e35b2597b13..1934e5d6c55 100644 --- a/app/html/package.json +++ b/app/html/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/html", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Storybook for HTML: View HTML snippets in isolation with Hot Reloading.", "keywords": [ "storybook" @@ -45,13 +45,13 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/client-api": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/client-api": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/preview-web": "6.4.0-beta.26", - "@storybook/store": "6.4.0-beta.26", + "@storybook/preview-web": "6.4.0-beta.31", + "@storybook/store": "6.4.0-beta.31", "@types/webpack-env": "^1.16.0", "core-js": "^3.8.2", "global": "^4.4.0", @@ -71,6 +71,6 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/client/index.js" } diff --git a/app/preact/package.json b/app/preact/package.json index 6417c8143cc..72626ae100e 100644 --- a/app/preact/package.json +++ b/app/preact/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/preact", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Storybook for Preact: Develop Preact Component in isolation.", "keywords": [ "storybook" @@ -46,11 +46,11 @@ }, "dependencies": { "@babel/plugin-transform-react-jsx": "^7.12.12", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/store": "6.4.0-beta.26", + "@storybook/store": "6.4.0-beta.31", "@types/webpack-env": "^1.16.0", "core-js": "^3.8.2", "global": "^4.4.0", @@ -74,6 +74,6 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/client/index.js" } diff --git a/app/react/package.json b/app/react/package.json index ac9899e468e..38e879971bf 100644 --- a/app/react/package.json +++ b/app/react/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/react", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Storybook for React: Develop React Component in isolation with Hot Reloading.", "keywords": [ "storybook" @@ -49,14 +49,14 @@ "@babel/preset-flow": "^7.12.1", "@babel/preset-react": "^7.12.10", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.1", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/node-logger": "6.4.0-beta.26", + "@storybook/node-logger": "6.4.0-beta.31", "@storybook/react-docgen-typescript-plugin": "1.0.2-canary.253f8c1.0", "@storybook/semver": "^7.3.2", - "@storybook/store": "6.4.0-beta.26", + "@storybook/store": "6.4.0-beta.31", "@types/webpack-env": "^1.16.0", "babel-plugin-add-react-displayname": "^0.0.5", "babel-plugin-named-asset-import": "^0.3.1", @@ -73,7 +73,7 @@ "webpack": "4" }, "devDependencies": { - "@storybook/client-api": "6.4.0-beta.26", + "@storybook/client-api": "6.4.0-beta.31", "@types/node": "^14.14.20", "@types/prompts": "^2.0.9" }, @@ -96,6 +96,6 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/client/index.js" } diff --git a/app/react/src/client/preview/render.tsx b/app/react/src/client/preview/render.tsx index d006aa4fdf3..1a5e10e556b 100644 --- a/app/react/src/client/preview/render.tsx +++ b/app/react/src/client/preview/render.tsx @@ -15,12 +15,14 @@ import { ReactFramework } from './types-6-0'; const { FRAMEWORK_OPTIONS } = global; -export const render: ArgsStoryFn = (args, { id, component: Component }) => { +export const render: ArgsStoryFn = (args, context) => { + const { id, component: Component } = context; if (!Component) { throw new Error( `Unable to render story ${id} as the component annotation is missing from the default export` ); } + return ; }; diff --git a/app/server/README.md b/app/server/README.md index f4762564b70..3421377c873 100644 --- a/app/server/README.md +++ b/app/server/README.md @@ -130,7 +130,7 @@ Static parameters can be defined using the `params` story parameter. For example } ``` -The Red and Green story HTML will be fetched from the urls `server.url/controls/button?color=red&label=Stopr` and `server.url/controls/button?color=green&label=OK` +The Red and Green story HTML will be fetched from the urls `server.url/controls/button?color=red&label=Stop` and `server.url/controls/button?color=green&label=OK` Like all story parameters server params can be defined in the default export and overridden in stories. diff --git a/app/server/package.json b/app/server/package.json index ab86dace737..137dd24cec6 100644 --- a/app/server/package.json +++ b/app/server/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/server", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Storybook for Server: View HTML snippets from a server in isolation with Hot Reloading.", "keywords": [ "storybook" @@ -45,15 +45,15 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/api": "6.4.0-beta.26", - "@storybook/client-api": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/api": "6.4.0-beta.31", + "@storybook/client-api": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/node-logger": "6.4.0-beta.26", - "@storybook/preview-web": "6.4.0-beta.26", - "@storybook/store": "6.4.0-beta.26", + "@storybook/node-logger": "6.4.0-beta.31", + "@storybook/preview-web": "6.4.0-beta.31", + "@storybook/store": "6.4.0-beta.31", "@types/webpack-env": "^1.16.0", "core-js": "^3.8.2", "global": "^4.4.0", @@ -75,6 +75,6 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/client/index.js" } diff --git a/app/svelte/package.json b/app/svelte/package.json index f73b0153cbc..30165f2ace4 100644 --- a/app/svelte/package.json +++ b/app/svelte/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/svelte", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Storybook for Svelte: Develop Svelte Component in isolation with Hot Reloading.", "keywords": [ "storybook" @@ -45,11 +45,11 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/store": "6.4.0-beta.26", + "@storybook/store": "6.4.0-beta.31", "core-js": "^3.8.2", "global": "^4.4.0", "react": "16.14.0", @@ -75,6 +75,6 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/client/index.js" } diff --git a/app/vue/package.json b/app/vue/package.json index e799667e022..ddcb0c54d97 100644 --- a/app/vue/package.json +++ b/app/vue/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/vue", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Storybook for Vue: Develop Vue Component in isolation with Hot Reloading.", "keywords": [ "storybook" @@ -45,11 +45,11 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/store": "6.4.0-beta.26", + "@storybook/store": "6.4.0-beta.31", "@types/webpack-env": "^1.16.0", "core-js": "^3.8.2", "global": "^4.4.0", @@ -83,6 +83,6 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/client/index.js" } diff --git a/app/vue3/package.json b/app/vue3/package.json index 5dc74b1dfe9..35eeafa5188 100644 --- a/app/vue3/package.json +++ b/app/vue3/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/vue3", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Storybook for Vue 3: Develop Vue 3 Components in isolation with Hot Reloading.", "keywords": [ "storybook" @@ -45,11 +45,11 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "@storybook/addons": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/store": "6.4.0-beta.26", + "@storybook/store": "6.4.0-beta.31", "@types/webpack-env": "^1.16.0", "core-js": "^3.8.2", "global": "^4.4.0", @@ -81,6 +81,6 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/client/index.js" } diff --git a/app/web-components/package.json b/app/web-components/package.json index a10405960e7..4b43f2d54e3 100644 --- a/app/web-components/package.json +++ b/app/web-components/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/web-components", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "description": "Storybook for web-components: View web components snippets in isolation with Hot Reloading.", "keywords": [ "lit-html", @@ -50,13 +50,13 @@ "@babel/plugin-syntax-dynamic-import": "^7.8.3", "@babel/plugin-syntax-import-meta": "^7.10.4", "@babel/preset-env": "^7.12.11", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/client-api": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-common": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/client-api": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-common": "6.4.0-beta.31", "@storybook/csf": "0.0.2--canary.87bc651.0", - "@storybook/preview-web": "6.4.0-beta.26", - "@storybook/store": "6.4.0-beta.26", + "@storybook/preview-web": "6.4.0-beta.31", + "@storybook/store": "6.4.0-beta.31", "@types/webpack-env": "^1.16.0", "babel-plugin-bundled-import-meta": "^0.3.1", "core-js": "^3.8.2", @@ -79,6 +79,6 @@ "publishConfig": { "access": "public" }, - "gitHead": "ddc43c3b4cf4ae8463a2e284b290e5014e33780e", + "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267", "sbmodern": "dist/modern/client/index.js" } diff --git a/docs/api/cli-options.md b/docs/api/cli-options.md index 0a22c6a2203..1011f5c4a1e 100644 --- a/docs/api/cli-options.md +++ b/docs/api/cli-options.md @@ -18,7 +18,7 @@ Usage: start-storybook [options] | -V, --version | Output the version number | `start-storybook -V` | | -p, --port [number] | Port to run Storybook | `start-storybook -p 9009` | | -h, --host [string] | Host to run Storybook | `start-storybook -h my-host.com` | -| -s, --static-dir `` | Directory where to load static files from, comma-separated list | `start-storybook -s public` | +| -s, --static-dir `` | **[DEPRECATED]** Directory where to load static files from, comma-separated list | `start-storybook -s public` | | -c, --config-dir [dir-name] | Directory where to load Storybook configurations from | `start-storybook -c .storybook` | | --https | Serve Storybook over HTTPS. Note: You must provide your own certificate information. | `start-storybook --https` | | --ssl-ca `` | Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate) | `start-storybook --ssl-ca my-certificate` | @@ -26,7 +26,7 @@ Usage: start-storybook [options] | --ssl-key `` | Provide an SSL key. (Required with --https) | `start-storybook --ssl-key my-ssl-key` | | --smoke-test | Exit after successful start | `start-storybook --smoke-test` | | --ci | CI mode (skip interactive prompts, don't open browser) | `start-storybook --ci` | -| --no-open | Do not open Storybook automatically in the browser | `start-storybook --no-open` | +| --no-open | Do not open Storybook automatically in the browser | `start-storybook --no-open` | | --quiet | Suppress verbose build output | `start-storybook --quiet` | | --no-dll | Do not use dll reference (no-op) | `start-storybook --no-dll` | | --debug-webpack | Display final webpack configurations for debugging purposes | `start-storybook --debug-webpack` | @@ -44,19 +44,19 @@ Usage: start-storybook [options] Usage: build-storybook [options] ``` -| Options | Description | Example | -| ---------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------- | -| -h, --help | Output usage information | `build-storybook --help` | -| -V, --version | Output the version number | `build-storybook -V` | -| -s, --static-dir `` | Directory where to load static files from, comma-separated list | `build-storybook -s public` | -| -o, --output-dir [dir-name] | Directory where to store built files | `build-storybook -o /my-deployed-storybook` | -| -c, --config-dir [dir-name] | Directory where to load Storybook configurations from | `build-storybook -c .storybook` | -| --loglevel [level] | Controls level of logging during build. Can be one of: [silly, verbose, info (default), warn, error, silent] | `build-storybook --loglevel warn` | -| --quiet | Suppress verbose build output | `build-storybook --quiet` | -| --no-dll | Do not use dll reference (no-op) | `build-storybook --no-dll` | -| --debug-webpack | Display final webpack configurations for debugging purposes | `build-storybook --debug-webpack` | +| Options | Description | Example | +| ---------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------- | +| -h, --help | Output usage information | `build-storybook --help` | +| -V, --version | Output the version number | `build-storybook -V` | +| -s, --static-dir `` | **[DEPRECATED]** Directory where to load static files from, comma-separated list | `build-storybook -s public` | +| -o, --output-dir [dir-name] | Directory where to store built files | `build-storybook -o /my-deployed-storybook` | +| -c, --config-dir [dir-name] | Directory where to load Storybook configurations from | `build-storybook -c .storybook` | +| --loglevel [level] | Controls level of logging during build. Can be one of: [silly, verbose, info (default), warn, error, silent] | `build-storybook --loglevel warn` | +| --quiet | Suppress verbose build output | `build-storybook --quiet` | +| --no-dll | Do not use dll reference (no-op) | `build-storybook --no-dll` | +| --debug-webpack | Display final webpack configurations for debugging purposes | `build-storybook --debug-webpack` | | `--webpack-stats-json ` | Write Webpack Stats JSON to disk | `build-storybook --webpack-stats-json /my-storybook/webpack-stats` | -| --docs | Builds Storybook in documentation mode. Learn more about it in [here](../writing-docs/build-documentation.md#publish-storybooks-documentation)) | `build-storybook --docs` | +| --docs | Builds Storybook in documentation mode. Learn more about it in [here](../writing-docs/build-documentation.md#publish-storybooks-documentation)) | `build-storybook --docs` |
💡 NOTE: If you're using npm instead of yarn to publish Storybook, the commands work slightly different. For example, npm run build-storybook -- -o ./path/to/build. diff --git a/docs/configure/images-and-assets.md b/docs/configure/images-and-assets.md index 0ecc8b4e807..a680ed3a8a2 100644 --- a/docs/configure/images-and-assets.md +++ b/docs/configure/images-and-assets.md @@ -30,27 +30,27 @@ Afterwards you can use any asset in your stories: -### Serving static files via Storybook +### Serving static files via Storybook Configuration We recommend serving static files via Storybook to ensure that your components always have the assets they need to load. This technique is recommended for assets that your components often use like logos, fonts, and icons. -Configure a directory (or a list of directories) where your assets live when starting Storybook. Use the`-s` flag in your npm script like so: +Configure a directory (or a list of directories) where your assets live in your Storybook configuration. Use the `staticDirs` property in your `main.js` or `main.ts` configuration file like so: -```json +```js { - "scripts": { - "start-storybook": "start-storybook -s ./public -p 9001" - } + ... + staticDirs: ['./public']; + ... } ``` -Or when building your Storybook with `build-storybook`: +You can map your local static directories to a different path like this: -```json +```js { - "scripts": { - "build-storybook": "build-storybook -s public" - } + ... + staticDirs: [{ from: './public', to: '/assets' }]; + ... } ``` @@ -76,23 +76,33 @@ Here `./public` is your static directory. Now use it in a component or story lik You can also pass a list of directories separated by commas without spaces instead of a single directory. -```json +```js { - "scripts": { - "start-storybook": "start-storybook -s ./public,./static -p 9001" - } + ... + staticDirs: ['./public', './statics']; + ... } ``` -The same can be applied when you're building your Storybook. -```json +Or you can map each of them to different paths: + +You can map your local static directories to a different path like this: + +```js { - "scripts": { - "build-storybook": "build-storybook -s ./public,./static -p 9001" - } + ... + staticDirs: [ + { from: './public', to: '/assets' }, + { from: './statics', to: '/resources' } + ]; + ... } ``` +### **[⚠️ Deprecated]** Serving static files via Storybook CLI + +Using `--static-dir` or `-s` option with Storybook CLI is deprecated. It is recommended to use [Storybook static directory configuration option](#serving-static-files-via-storybook-configuration) instead. + ### Reference assets from a CDN Upload your files to an online CDN and reference them. In this example we’re using a placeholder image service. @@ -123,4 +133,4 @@ In this case, you need to have all your images and media files with relative pat If you load static content via importing, this is automatic and you do not have to do anything. -If you are serving assets in a [static directory](#serving-static-files-via-storybook) along with your Storybook, then you need to use relative paths to load images or use the base element. \ No newline at end of file +If you are serving assets in a [static directory](#serving-static-files-via-storybook) along with your Storybook, then you need to use relative paths to load images or use the base element. diff --git a/docs/essentials/addon-interactions-installed-registered.png b/docs/essentials/addon-interactions-installed-registered.png new file mode 100644 index 00000000000..f61c71c770e Binary files /dev/null and b/docs/essentials/addon-interactions-installed-registered.png differ diff --git a/docs/essentials/interactions.md b/docs/essentials/interactions.md new file mode 100644 index 00000000000..a7dba42aceb --- /dev/null +++ b/docs/essentials/interactions.md @@ -0,0 +1,65 @@ +--- +title: 'Interactions' +--- + +The `play` function in Storybook allows you to simulate user interactions to run after a story renders. With the Interactions addon, you have a way to visualize and debug these interactions. + +## Play function for interactions + +Stories isolate and capture component states in a structured manner. While developing a component, you can quickly cycle through the stories to verify the look and feel. Each story specifies all the inputs required to reproduce a specific state. You can even mock context and API calls. That allows you to handle most use cases of a component. But what about states that require user interaction? + +For example, clicking a button to open/close a dialog box, dragging a list item to reorder it or filling out a form to check for validation errors. To test those behaviours, you have to interact with the components as a user would. Interactive stories enable you to automate these interactions using a play function. These are small snippets of code that script out the exact steps a human would take to interact with the component. It's then executed as soon as the story is rendered. + +### Powered by Testing Library and Jest + +The interactions are written using a Storybook-instrumented versions of Testing Library and Jest. That gives you a familiar developer-friendly syntax to interact with the DOM and make assertions, but with extra telemetry to help with debugging. + +## Installation + +Since Interactions is still experimental, it doesn't yet ship with Storybook by default. As such, you'll have to install it. You may also want to add our wrappers for Testing Library and Jest. + +```shell +yarn add -D @storybook/addon-interactions @storybook/jest @storybook/testing-library +``` + +Next, update [`.storybook/main.js`](../configure/overview.md#configure-story-rendering) to the following: + + + + + + + +
+⚠️ Note: Make sure to list `@storybook/addon-interactions` **after** `addon-essentials` (or `addon-actions`). +
+ +Now when you run Storybook the Interactions addon will be enabled. + +![Storybook Interactions installed and registered](./storybook-interactions-installed-registered.png) + +## Writing interactions + +Interactions run as part of the `play` function on your stories. We rely on Testing Library to do the heavy lifting. + +Make sure to import the Storybook wrappers for Jest and Testing Library rather than importing Jest and Testing Library directly. + + + + + + + +The above example uses the `canvasElement` to scope your element queries to the current story. This is important if you want your play functions to eventually be compatible with Storybook Docs, which renders multiple components on the same page. + +While you can refer to the [Testing Library documentation](https://testing-library.com/docs/) for details on how to use it, there's an important detail that's different when using the Storybook wrapper: **method invocations must be `await`-ed**. This allows you to step back and forth through your interactions using the debugger. + +Any `args` that have been marked as an Action, either using the [argTypes annotation](./actions.md#action-argtype-annotation) or the [argTypesRegex](./actions.md#automatically-matching-args), will be automatically converted to a [Jest mock function](https://jestjs.io/docs/mock-function-api) (spy). This allows you to make assertions about calls to these functions. diff --git a/docs/get-started/installation-problems/preact.mdx b/docs/get-started/installation-problems/preact.mdx index 8341dc81cf1..8297d30fa51 100644 --- a/docs/get-started/installation-problems/preact.mdx +++ b/docs/get-started/installation-problems/preact.mdx @@ -1,2 +1,2 @@ -- You can also setup Storybook manually through the Storybook CLI. Add the `--type mithril` flag when you initialize Storybook in your project. +- You can also setup Storybook manually through the Storybook CLI. Add the `--type preact` flag when you initialize Storybook in your project. - If there's an installation problem, check the [README for the Preact framework](../../app/preact/README.md). diff --git a/docs/snippets/common/storybook-interactions-addon-registration.js.mdx b/docs/snippets/common/storybook-interactions-addon-registration.js.mdx new file mode 100644 index 00000000000..3cdcdfec05e --- /dev/null +++ b/docs/snippets/common/storybook-interactions-addon-registration.js.mdx @@ -0,0 +1,11 @@ +```js +// .storybook/main.js + +module.exports = { + stories: [], + addons: [ + // Other Storybook addons + '@storybook/addon-interactions', // 👈 Register the addon + ], +}; +``` diff --git a/docs/snippets/common/storybook-interactions-play-function.js.mdx b/docs/snippets/common/storybook-interactions-play-function.js.mdx new file mode 100644 index 00000000000..b449defce27 --- /dev/null +++ b/docs/snippets/common/storybook-interactions-play-function.js.mdx @@ -0,0 +1,27 @@ +```js +// MyForm.stories.js +import { expect } from '@storybook/jest'; +import { userEvent, waitFor, within } from '@storybook/testing-library'; +import { MyForm } from './MyForm' + +export default { + title: 'MyForm', + component: MyForm, + argTypes: { + onSubmit: { action: true }, + }, +}; + +const Template = (args) => ; + +const Submitted = Template.bind({}); +Submitted.play = async ({ args, canvasElement }) => { + const canvas = within(canvasElement); + + await userEvent.type(canvas.getByTestId('email'), 'hi@example.com'); + await userEvent.type(canvas.getByTestId('password'), 'supersecret'); + await userEvent.click(canvas.getByRole('button')); + + await waitFor(() => expect(args.onSubmit).toHaveBeenCalled()); +}; +``` diff --git a/docs/versions/next.json b/docs/versions/next.json index 496bb7645ad..3ebe4fc08c5 100644 --- a/docs/versions/next.json +++ b/docs/versions/next.json @@ -1 +1 @@ -{"version":"6.4.0-beta.26","info":{"plain":"### Bug Fixes\n\n- Core: Replace SSE with websockets ([#16504](https://github.com/storybookjs/storybook/pull/16504))\n- UI: Upgrade react-router ([#16554](https://github.com/storybookjs/storybook/pull/16554))\n- Addon-docs/HTML: Fix source snippetization for DOM elements ([#16553](https://github.com/storybookjs/storybook/pull/16553))"}} \ No newline at end of file +{"version":"6.4.0-beta.31","info":{"plain":"### Features\n\n* Core: Add feature flag to stop storybook from aliasing emotion ([#16613](https://github.com/storybookjs/storybook/pull/16613))\n\n### Bug Fixes\n\n* Core: Fix `staticDirs` and `-s` conflict check ([#16649](https://github.com/storybookjs/storybook/pull/16649))\n\n### Maintenance\n\n* Build: Add node-gyp for M1 macs ([#16645](https://github.com/storybookjs/storybook/pull/16645))"}} \ No newline at end of file diff --git a/docs/workflows/storybook-composition.md b/docs/workflows/storybook-composition.md index 06a03c6dff4..ee7596641f1 100644 --- a/docs/workflows/storybook-composition.md +++ b/docs/workflows/storybook-composition.md @@ -64,7 +64,7 @@ You can also compose Storybooks based on the current development environment. Fo ### Improve your Storybook composition -So far we've covered how we can use composition with local or published Storybooks. One thing worth mentioning as your Storybook will grow in time with your own stories, or through composition with other Storybooks, is that you can optimize the deployment process by including the following command in your workflow: +So far we've covered how we can use composition with local or published Storybooks. One thing worth mentioning as your Storybook will grow in time with your own stories, or through composition with other Storybooks, is that you can optimize the deployment process by including the following command in your workflow, run from your project root: ```shell npx sb extract diff --git a/examples/angular-cli/.storybook/main.js b/examples/angular-cli/.storybook/main.js index efadbeac44a..0357685dd98 100644 --- a/examples/angular-cli/.storybook/main.js +++ b/examples/angular-cli/.storybook/main.js @@ -39,4 +39,5 @@ module.exports = { url: 'https://storybookjs.netlify.app/cra-ts-essentials', }, }, + staticDirs: ['../src/assets'], }; diff --git a/examples/angular-cli/package.json b/examples/angular-cli/package.json index 95a70847e17..05d10d47d2d 100644 --- a/examples/angular-cli/package.json +++ b/examples/angular-cli/package.json @@ -1,16 +1,16 @@ { "name": "angular-cli", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "license": "MIT", "scripts": { "build": "ng build", - "build-storybook": "yarn storybook-prebuild && build-storybook -s src/assets", + "build-storybook": "yarn storybook-prebuild && build-storybook", "docs:json": "compodoc -p ./tsconfig.json -e json -d .", "e2e": "ng e2e", "ng": "ng", "start": "ng serve", - "storybook": "yarn storybook-prebuild && start-storybook -p 9008 -s src/assets --no-manager-cache", + "storybook": "yarn storybook-prebuild && start-storybook -p 9008 --no-manager-cache", "storybook-prebuild": "yarn test:generate-output && yarn docs:json", "test": "jest", "test:coverage": "jest --coverage", @@ -39,20 +39,20 @@ "@angular/compiler-cli": "^11.2.14", "@angular/elements": "^11.2.14", "@compodoc/compodoc": "^1.1.14", - "@storybook/addon-a11y": "6.4.0-beta.26", - "@storybook/addon-actions": "6.4.0-beta.26", - "@storybook/addon-backgrounds": "6.4.0-beta.26", - "@storybook/addon-controls": "6.4.0-beta.26", - "@storybook/addon-docs": "6.4.0-beta.26", - "@storybook/addon-interactions": "6.4.0-beta.26", - "@storybook/addon-jest": "6.4.0-beta.26", - "@storybook/addon-links": "6.4.0-beta.26", - "@storybook/addon-storyshots": "6.4.0-beta.26", - "@storybook/addon-storysource": "6.4.0-beta.26", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/angular": "6.4.0-beta.26", + "@storybook/addon-a11y": "6.4.0-beta.31", + "@storybook/addon-actions": "6.4.0-beta.31", + "@storybook/addon-backgrounds": "6.4.0-beta.31", + "@storybook/addon-controls": "6.4.0-beta.31", + "@storybook/addon-docs": "6.4.0-beta.31", + "@storybook/addon-interactions": "6.4.0-beta.31", + "@storybook/addon-jest": "6.4.0-beta.31", + "@storybook/addon-links": "6.4.0-beta.31", + "@storybook/addon-storyshots": "6.4.0-beta.31", + "@storybook/addon-storysource": "6.4.0-beta.31", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/angular": "6.4.0-beta.31", "@storybook/jest": "^0.0.2", - "@storybook/source-loader": "6.4.0-beta.26", + "@storybook/source-loader": "6.4.0-beta.31", "@storybook/testing-library": "^0.0.3", "@types/core-js": "^2.5.4", "@types/jest": "^26.0.16", diff --git a/examples/cra-kitchen-sink/.storybook/main.js b/examples/cra-kitchen-sink/.storybook/main.js index cefc73a0fe2..0179e07dd64 100644 --- a/examples/cra-kitchen-sink/.storybook/main.js +++ b/examples/cra-kitchen-sink/.storybook/main.js @@ -33,4 +33,5 @@ module.exports = { core: { builder: 'webpack4', }, + staticDirs: ['../public'], }; diff --git a/examples/cra-kitchen-sink/package.json b/examples/cra-kitchen-sink/package.json index d1656493ba6..2a2f0850837 100644 --- a/examples/cra-kitchen-sink/package.json +++ b/examples/cra-kitchen-sink/package.json @@ -1,17 +1,17 @@ { "name": "cra-kitchen-sink", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "scripts": { "build": "react-scripts build", - "build-storybook": "build-storybook -s public", + "build-storybook": "build-storybook", "eject": "react-scripts eject", "start": "react-scripts start", - "storybook": "start-storybook -p 9010 -s public --no-manager-cache", + "storybook": "start-storybook -p 9010 --no-manager-cache", "test": "react-scripts test --env=jsdom" }, "dependencies": { - "@storybook/client-logger": "6.4.0-beta.26", + "@storybook/client-logger": "6.4.0-beta.31", "global": "^4.4.0", "prop-types": "^15.7.2", "react": "16.14.0", @@ -21,19 +21,19 @@ }, "devDependencies": { "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3", - "@storybook/addon-a11y": "6.4.0-beta.26", - "@storybook/addon-actions": "6.4.0-beta.26", - "@storybook/addon-backgrounds": "6.4.0-beta.26", - "@storybook/addon-docs": "6.4.0-beta.26", + "@storybook/addon-a11y": "6.4.0-beta.31", + "@storybook/addon-actions": "6.4.0-beta.31", + "@storybook/addon-backgrounds": "6.4.0-beta.31", + "@storybook/addon-docs": "6.4.0-beta.31", "@storybook/addon-ie11": "0.0.7--canary.5e87b64.0", - "@storybook/addon-jest": "6.4.0-beta.26", - "@storybook/addon-links": "6.4.0-beta.26", - "@storybook/addon-storyshots": "6.4.0-beta.26", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/builder-webpack4": "6.4.0-beta.26", + "@storybook/addon-jest": "6.4.0-beta.31", + "@storybook/addon-links": "6.4.0-beta.31", + "@storybook/addon-storyshots": "6.4.0-beta.31", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/builder-webpack4": "6.4.0-beta.31", "@storybook/preset-create-react-app": "^3.1.6", - "@storybook/react": "6.4.0-beta.26", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/react": "6.4.0-beta.31", + "@storybook/theming": "6.4.0-beta.31", "webpack": "4" }, "storybook": { diff --git a/examples/cra-react15/.storybook/main.js b/examples/cra-react15/.storybook/main.js index 520bcd3a706..76fdcb43fa9 100644 --- a/examples/cra-react15/.storybook/main.js +++ b/examples/cra-react15/.storybook/main.js @@ -21,4 +21,5 @@ module.exports = { core: { builder: 'webpack4', }, + staticDirs: ['../public'], }; diff --git a/examples/cra-react15/package.json b/examples/cra-react15/package.json index 6e160804e7c..f42376d03a4 100644 --- a/examples/cra-react15/package.json +++ b/examples/cra-react15/package.json @@ -1,13 +1,13 @@ { "name": "cra-react15", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "scripts": { "build": "react-scripts build", - "build-storybook": "build-storybook -s public", + "build-storybook": "build-storybook", "eject": "react-scripts eject", "start": "react-scripts start", - "storybook": "start-storybook -p 9009 -s public --no-manager-cache", + "storybook": "start-storybook -p 9009 --no-manager-cache", "test": "react-scripts test --env=jsdom" }, "dependencies": { @@ -19,14 +19,14 @@ "react-scripts": "3.4.4" }, "devDependencies": { - "@storybook/addon-actions": "6.4.0-beta.26", + "@storybook/addon-actions": "6.4.0-beta.31", "@storybook/addon-ie11": "0.0.7--canary.5e87b64.0", - "@storybook/addon-links": "6.4.0-beta.26", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/builder-webpack4": "6.4.0-beta.26", + "@storybook/addon-links": "6.4.0-beta.31", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/builder-webpack4": "6.4.0-beta.31", "@storybook/preset-create-react-app": "^3.1.6", - "@storybook/react": "6.4.0-beta.26", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/react": "6.4.0-beta.31", + "@storybook/theming": "6.4.0-beta.31", "babel-core": "6", "babel-runtime": "6", "webpack": "4" diff --git a/examples/cra-ts-essentials/.storybook/main.js b/examples/cra-ts-essentials/.storybook/main.js index 630d249ef46..2ddcf7a8e5b 100644 --- a/examples/cra-ts-essentials/.storybook/main.js +++ b/examples/cra-ts-essentials/.storybook/main.js @@ -25,4 +25,5 @@ module.exports = { core: { builder: 'webpack4', }, + staticDirs: ['../public'], }; diff --git a/examples/cra-ts-essentials/package.json b/examples/cra-ts-essentials/package.json index 8f4993817a9..f1c50a262be 100644 --- a/examples/cra-ts-essentials/package.json +++ b/examples/cra-ts-essentials/package.json @@ -1,13 +1,13 @@ { "name": "cra-ts-essentials", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "scripts": { "build": "react-scripts build", - "build-storybook": "build-storybook -s public", + "build-storybook": "build-storybook", "eject": "react-scripts eject", "start": "react-scripts start", - "storybook": "start-storybook -p 9009 -s public --no-manager-cache", + "storybook": "start-storybook -p 9009 --no-manager-cache", "test": "react-scripts test" }, "browserslist": { @@ -34,12 +34,12 @@ "typescript": "^3.9.7" }, "devDependencies": { - "@storybook/addon-essentials": "6.4.0-beta.26", + "@storybook/addon-essentials": "6.4.0-beta.31", "@storybook/addon-ie11": "0.0.7--canary.5e87b64.0", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/builder-webpack4": "6.4.0-beta.26", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/builder-webpack4": "6.4.0-beta.31", "@storybook/preset-create-react-app": "^3.1.6", - "@storybook/react": "6.4.0-beta.26", + "@storybook/react": "6.4.0-beta.31", "webpack": "4" }, "storybook": { diff --git a/examples/cra-ts-kitchen-sink/.storybook/main.ts b/examples/cra-ts-kitchen-sink/.storybook/main.ts index f0c7ca3dc3c..2f33809ea75 100644 --- a/examples/cra-ts-kitchen-sink/.storybook/main.ts +++ b/examples/cra-ts-kitchen-sink/.storybook/main.ts @@ -29,4 +29,5 @@ module.exports = { core: { builder: 'webpack4', }, + staticDirs: ['../public'], }; diff --git a/examples/cra-ts-kitchen-sink/package.json b/examples/cra-ts-kitchen-sink/package.json index 04ccd02332e..2338b932779 100644 --- a/examples/cra-ts-kitchen-sink/package.json +++ b/examples/cra-ts-kitchen-sink/package.json @@ -1,13 +1,13 @@ { "name": "cra-ts-kitchen-sink", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "scripts": { "build": "react-scripts build", - "build-storybook": "build-storybook -s public", + "build-storybook": "build-storybook", "eject": "react-scripts eject", "start": "react-scripts start", - "storybook": "start-storybook -p 9009 -s public --no-manager-cache", + "storybook": "start-storybook -p 9009 --no-manager-cache", "test": "react-scripts test" }, "browserslist": { @@ -34,15 +34,15 @@ "typescript": "^3.9.7" }, "devDependencies": { - "@storybook/addon-a11y": "6.4.0-beta.26", - "@storybook/addon-actions": "6.4.0-beta.26", - "@storybook/addon-docs": "6.4.0-beta.26", + "@storybook/addon-a11y": "6.4.0-beta.31", + "@storybook/addon-actions": "6.4.0-beta.31", + "@storybook/addon-docs": "6.4.0-beta.31", "@storybook/addon-ie11": "0.0.7--canary.5e87b64.0", - "@storybook/addon-links": "6.4.0-beta.26", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/builder-webpack4": "6.4.0-beta.26", + "@storybook/addon-links": "6.4.0-beta.31", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/builder-webpack4": "6.4.0-beta.31", "@storybook/preset-create-react-app": "^3.1.6", - "@storybook/react": "6.4.0-beta.26", + "@storybook/react": "6.4.0-beta.31", "@types/enzyme": "^3.10.8", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.9.1", diff --git a/examples/ember-cli/.storybook/main.js b/examples/ember-cli/.storybook/main.js index 46578f66d04..a1eb7ba54fa 100644 --- a/examples/ember-cli/.storybook/main.js +++ b/examples/ember-cli/.storybook/main.js @@ -29,4 +29,5 @@ module.exports = { core: { builder: 'webpack4', }, + staticDirs: ['../ember-output'], }; diff --git a/examples/ember-cli/package.json b/examples/ember-cli/package.json index 136056930ec..08853858c98 100644 --- a/examples/ember-cli/package.json +++ b/examples/ember-cli/package.json @@ -1,14 +1,14 @@ { "name": "ember-example", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "scripts": { "build": "ember build --output-path ember-output", - "build-storybook": "yarn storybook-prebuild && build-storybook -s ember-output", + "build-storybook": "yarn storybook-prebuild && build-storybook", "dev": "ember serve", - "storybook": "yarn build && start-storybook -p 9009 -s ember-output --no-manager-cache", + "storybook": "yarn build && start-storybook -p 9009 --no-manager-cache", "storybook-prebuild": "yarn build && shx cp -r public/* ember-output", - "storybook:dev": "yarn dev & start-storybook -p 9009 -s ember-output" + "storybook:dev": "yarn dev & start-storybook -p 9009" }, "dependencies": { "ember-named-blocks-polyfill": "^0.2.3", @@ -17,18 +17,18 @@ "devDependencies": { "@babel/core": "^7.12.10", "@ember/optional-features": "^2.0.0", - "@storybook/addon-a11y": "6.4.0-beta.26", - "@storybook/addon-actions": "6.4.0-beta.26", - "@storybook/addon-backgrounds": "6.4.0-beta.26", - "@storybook/addon-controls": "6.4.0-beta.26", - "@storybook/addon-docs": "6.4.0-beta.26", - "@storybook/addon-links": "6.4.0-beta.26", - "@storybook/addon-storysource": "6.4.0-beta.26", - "@storybook/addon-viewport": "6.4.0-beta.26", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/ember": "6.4.0-beta.26", + "@storybook/addon-a11y": "6.4.0-beta.31", + "@storybook/addon-actions": "6.4.0-beta.31", + "@storybook/addon-backgrounds": "6.4.0-beta.31", + "@storybook/addon-controls": "6.4.0-beta.31", + "@storybook/addon-docs": "6.4.0-beta.31", + "@storybook/addon-links": "6.4.0-beta.31", + "@storybook/addon-storysource": "6.4.0-beta.31", + "@storybook/addon-viewport": "6.4.0-beta.31", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/ember": "6.4.0-beta.31", "@storybook/ember-cli-storybook": "^0.2.1", - "@storybook/source-loader": "6.4.0-beta.26", + "@storybook/source-loader": "6.4.0-beta.31", "babel-loader": "^8.0.0", "broccoli-asset-rev": "^3.0.0", "cross-env": "^7.0.3", @@ -45,6 +45,7 @@ "ember-resolver": "^7.0.0", "ember-source": "~3.24.0", "loader.js": "^4.7.0", + "shx": "^0.3.2", "webpack": "4", "webpack-cli": "^4.2.0" }, diff --git a/examples/html-kitchen-sink/package.json b/examples/html-kitchen-sink/package.json index 54d01f001f6..8f4b8f1ed5c 100644 --- a/examples/html-kitchen-sink/package.json +++ b/examples/html-kitchen-sink/package.json @@ -1,6 +1,6 @@ { "name": "html-kitchen-sink", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "description": "", "keywords": [], @@ -13,23 +13,23 @@ "storybook": "start-storybook -p 9006 --no-manager-cache" }, "devDependencies": { - "@storybook/addon-a11y": "6.4.0-beta.26", - "@storybook/addon-actions": "6.4.0-beta.26", - "@storybook/addon-backgrounds": "6.4.0-beta.26", - "@storybook/addon-controls": "6.4.0-beta.26", - "@storybook/addon-docs": "6.4.0-beta.26", - "@storybook/addon-jest": "6.4.0-beta.26", - "@storybook/addon-links": "6.4.0-beta.26", + "@storybook/addon-a11y": "6.4.0-beta.31", + "@storybook/addon-actions": "6.4.0-beta.31", + "@storybook/addon-backgrounds": "6.4.0-beta.31", + "@storybook/addon-controls": "6.4.0-beta.31", + "@storybook/addon-docs": "6.4.0-beta.31", + "@storybook/addon-jest": "6.4.0-beta.31", + "@storybook/addon-links": "6.4.0-beta.31", "@storybook/addon-postcss": "^2.0.0", - "@storybook/addon-storyshots": "6.4.0-beta.26", - "@storybook/addon-storysource": "6.4.0-beta.26", - "@storybook/addon-viewport": "6.4.0-beta.26", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/client-api": "6.4.0-beta.26", - "@storybook/core": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", - "@storybook/html": "6.4.0-beta.26", - "@storybook/source-loader": "6.4.0-beta.26", + "@storybook/addon-storyshots": "6.4.0-beta.31", + "@storybook/addon-storysource": "6.4.0-beta.31", + "@storybook/addon-viewport": "6.4.0-beta.31", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/client-api": "6.4.0-beta.31", + "@storybook/core": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", + "@storybook/html": "6.4.0-beta.31", + "@storybook/source-loader": "6.4.0-beta.31", "autoprefixer": "^10.0.1", "eventemitter3": "^4.0.7", "format-json": "^1.0.3", diff --git a/examples/official-storybook/main.ts b/examples/official-storybook/main.ts index d4861400a64..846261c69e7 100644 --- a/examples/official-storybook/main.ts +++ b/examples/official-storybook/main.ts @@ -40,6 +40,11 @@ const config: StorybookConfig = { modernInlineRender: true, interactionsDebugger: true, }, + staticDirs: [ + './statics/public', + { from: './statics/examples/example1', to: '/example1' }, + { from: './statics/examples/example2', to: '/example2' }, + ], }; module.exports = config; diff --git a/examples/official-storybook/package.json b/examples/official-storybook/package.json index ce0a3d34c1a..e0103f795fe 100644 --- a/examples/official-storybook/package.json +++ b/examples/official-storybook/package.json @@ -1,6 +1,6 @@ { "name": "official-storybook", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "scripts": { "build-storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true build-storybook -c ./", @@ -14,31 +14,31 @@ "devDependencies": { "@packtracker/webpack-plugin": "^2.3.0", "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3", - "@storybook/addon-a11y": "6.4.0-beta.26", - "@storybook/addon-actions": "6.4.0-beta.26", - "@storybook/addon-backgrounds": "6.4.0-beta.26", - "@storybook/addon-controls": "6.4.0-beta.26", - "@storybook/addon-docs": "6.4.0-beta.26", - "@storybook/addon-interactions": "6.4.0-beta.26", - "@storybook/addon-jest": "6.4.0-beta.26", - "@storybook/addon-links": "6.4.0-beta.26", - "@storybook/addon-storyshots": "6.4.0-beta.26", - "@storybook/addon-storyshots-puppeteer": "6.4.0-beta.26", - "@storybook/addon-storysource": "6.4.0-beta.26", - "@storybook/addon-toolbars": "6.4.0-beta.26", - "@storybook/addon-viewport": "6.4.0-beta.26", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/cli": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/core-events": "6.4.0-beta.26", + "@storybook/addon-a11y": "6.4.0-beta.31", + "@storybook/addon-actions": "6.4.0-beta.31", + "@storybook/addon-backgrounds": "6.4.0-beta.31", + "@storybook/addon-controls": "6.4.0-beta.31", + "@storybook/addon-docs": "6.4.0-beta.31", + "@storybook/addon-interactions": "6.4.0-beta.31", + "@storybook/addon-jest": "6.4.0-beta.31", + "@storybook/addon-links": "6.4.0-beta.31", + "@storybook/addon-storyshots": "6.4.0-beta.31", + "@storybook/addon-storyshots-puppeteer": "6.4.0-beta.31", + "@storybook/addon-storysource": "6.4.0-beta.31", + "@storybook/addon-toolbars": "6.4.0-beta.31", + "@storybook/addon-viewport": "6.4.0-beta.31", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/cli": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/core-events": "6.4.0-beta.31", "@storybook/design-system": "^5.4.7", "@storybook/jest": "^0.0.2", - "@storybook/node-logger": "6.4.0-beta.26", - "@storybook/react": "6.4.0-beta.26", - "@storybook/router": "6.4.0-beta.26", - "@storybook/source-loader": "6.4.0-beta.26", + "@storybook/node-logger": "6.4.0-beta.31", + "@storybook/react": "6.4.0-beta.31", + "@storybook/router": "6.4.0-beta.31", + "@storybook/source-loader": "6.4.0-beta.31", "@storybook/testing-library": "^0.0.3", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/theming": "6.4.0-beta.31", "@testing-library/dom": "^7.31.2", "@testing-library/user-event": "^13.1.9", "chromatic": "^6.0.2", diff --git a/examples/official-storybook/statics/examples/example1/example1.txt b/examples/official-storybook/statics/examples/example1/example1.txt new file mode 100644 index 00000000000..b01a2ca4d50 --- /dev/null +++ b/examples/official-storybook/statics/examples/example1/example1.txt @@ -0,0 +1 @@ +example1! \ No newline at end of file diff --git a/examples/official-storybook/statics/examples/example2/example2.txt b/examples/official-storybook/statics/examples/example2/example2.txt new file mode 100644 index 00000000000..760014c6d2f --- /dev/null +++ b/examples/official-storybook/statics/examples/example2/example2.txt @@ -0,0 +1 @@ +example2! \ No newline at end of file diff --git a/examples/official-storybook/statics/public/public.txt b/examples/official-storybook/statics/public/public.txt new file mode 100644 index 00000000000..e043990393f --- /dev/null +++ b/examples/official-storybook/statics/public/public.txt @@ -0,0 +1 @@ +public! \ No newline at end of file diff --git a/examples/official-storybook/stories/addon-docs/source.stories.tsx b/examples/official-storybook/stories/addon-docs/source.stories.tsx index 8fce2c7422f..e9a671086f9 100644 --- a/examples/official-storybook/stories/addon-docs/source.stories.tsx +++ b/examples/official-storybook/stories/addon-docs/source.stories.tsx @@ -30,3 +30,7 @@ ForceCodeSource.parameters = { docs: { source: { type: 'code' } } }; export const CustomSource = Template.bind({}); CustomSource.args = { ...Basic.args }; CustomSource.parameters = { docs: { source: { code: 'custom source' } } }; + +export const NoSource = Template.bind({}); +NoSource.args = { ...Basic.args }; +NoSource.parameters = { docs: { source: { code: null } } }; diff --git a/examples/official-storybook/stories/core/sideloaded.stories.tsx b/examples/official-storybook/stories/core/sideloaded.stories.tsx new file mode 100644 index 00000000000..8c81d843a94 --- /dev/null +++ b/examples/official-storybook/stories/core/sideloaded.stories.tsx @@ -0,0 +1,32 @@ +import React from 'react'; + +const Component = (props: Record) =>
{JSON.stringify(props)}
; + +export default { + component: Component, + argTypes: { + a: { target: 'somewhere' }, + }, + parameters: { + argTypeTarget: true, + }, +}; + +export const StoryOne = { + args: { + a: 1, + b: 2, + c: 3, + }, +}; + +export const StoryTwo = { + args: { + a: 1, + b: 2, + c: 3, + }, + argTypes: { + c: { target: 'somewhere' }, + }, +}; diff --git a/examples/preact-kitchen-sink/.storybook/main.js b/examples/preact-kitchen-sink/.storybook/main.js index 8cb9b23eb71..781d93b00a9 100644 --- a/examples/preact-kitchen-sink/.storybook/main.js +++ b/examples/preact-kitchen-sink/.storybook/main.js @@ -24,4 +24,5 @@ module.exports = { core: { builder: 'webpack4', }, + staticDirs: ['../public'], }; diff --git a/examples/preact-kitchen-sink/package.json b/examples/preact-kitchen-sink/package.json index 260c612ec71..eedf7610c1f 100644 --- a/examples/preact-kitchen-sink/package.json +++ b/examples/preact-kitchen-sink/package.json @@ -1,12 +1,12 @@ { "name": "preact-example", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "scripts": { "build": "cross-env NODE_ENV=production webpack --progress --hide-modules", - "build-storybook": "build-storybook -s public", + "build-storybook": "build-storybook", "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot", - "storybook": "start-storybook -p 9009 -s public --no-manager-cache" + "storybook": "start-storybook -p 9009 --no-manager-cache" }, "dependencies": { "global": "^4.4.0", @@ -15,16 +15,16 @@ "devDependencies": { "@babel/core": "^7.12.10", "@babel/plugin-transform-runtime": "^7.12.10", - "@storybook/addon-a11y": "6.4.0-beta.26", - "@storybook/addon-actions": "6.4.0-beta.26", - "@storybook/addon-backgrounds": "6.4.0-beta.26", - "@storybook/addon-links": "6.4.0-beta.26", - "@storybook/addon-storyshots": "6.4.0-beta.26", - "@storybook/addon-storysource": "6.4.0-beta.26", - "@storybook/addon-viewport": "6.4.0-beta.26", - "@storybook/addons": "6.4.0-beta.26", - "@storybook/preact": "6.4.0-beta.26", - "@storybook/source-loader": "6.4.0-beta.26", + "@storybook/addon-a11y": "6.4.0-beta.31", + "@storybook/addon-actions": "6.4.0-beta.31", + "@storybook/addon-backgrounds": "6.4.0-beta.31", + "@storybook/addon-links": "6.4.0-beta.31", + "@storybook/addon-storyshots": "6.4.0-beta.31", + "@storybook/addon-storysource": "6.4.0-beta.31", + "@storybook/addon-viewport": "6.4.0-beta.31", + "@storybook/addons": "6.4.0-beta.31", + "@storybook/preact": "6.4.0-beta.31", + "@storybook/source-loader": "6.4.0-beta.31", "@types/prop-types": "^15.7.3", "@types/react": "^17", "@types/react-dom": "^17", diff --git a/examples/react-ts-webpack4/package.json b/examples/react-ts-webpack4/package.json index 31a3bf822db..f8beb0117d2 100644 --- a/examples/react-ts-webpack4/package.json +++ b/examples/react-ts-webpack4/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/example-react-ts-webpack4", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "scripts": { "build-storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true build-storybook -c ./", @@ -8,10 +8,10 @@ "storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true start-storybook -p 9011 -c ./ --no-manager-cache" }, "dependencies": { - "@storybook/addon-controls": "6.4.0-beta.26", - "@storybook/addon-essentials": "6.4.0-beta.26", - "@storybook/builder-webpack4": "6.4.0-beta.26", - "@storybook/react": "6.4.0-beta.26", + "@storybook/addon-controls": "6.4.0-beta.31", + "@storybook/addon-essentials": "6.4.0-beta.31", + "@storybook/builder-webpack4": "6.4.0-beta.31", + "@storybook/react": "6.4.0-beta.31", "@types/react": "^16.14.2", "@types/react-dom": "^16.9.10", "prop-types": "15.7.2", diff --git a/examples/react-ts/package.json b/examples/react-ts/package.json index eccdc7535bc..1bd3d5a3f62 100644 --- a/examples/react-ts/package.json +++ b/examples/react-ts/package.json @@ -1,11 +1,12 @@ { "name": "@storybook/example-react-ts", - "version": "6.4.0-beta.26", + "version": "6.4.0-beta.31", "private": true, "scripts": { "build-storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true build-storybook", "debug": "cross-env NODE_OPTIONS=--inspect-brk STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true start-storybook -p 9011", - "storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true start-storybook -p 9011 --no-manager-cache" + "storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true start-storybook -p 9011 --no-manager-cache", + "sb": "node ../../lib/cli/bin/index.js" }, "dependencies": { "formik": "^2.2.9", @@ -17,12 +18,13 @@ "@babel/preset-env": "^7.12.11", "@babel/preset-react": "^7.12.10", "@babel/preset-typescript": "^7.12.7", - "@storybook/addon-essentials": "6.4.0-beta.26", - "@storybook/addon-storyshots": "6.4.0-beta.26", - "@storybook/addon-storysource": "6.4.0-beta.26", - "@storybook/components": "6.4.0-beta.26", - "@storybook/react": "6.4.0-beta.26", - "@storybook/theming": "6.4.0-beta.26", + "@storybook/addon-essentials": "6.4.0-beta.31", + "@storybook/addon-storyshots": "6.4.0-beta.31", + "@storybook/addon-storysource": "6.4.0-beta.31", + "@storybook/cli": "6.4.0-beta.31", + "@storybook/components": "6.4.0-beta.31", + "@storybook/react": "6.4.0-beta.31", + "@storybook/theming": "6.4.0-beta.31", "@testing-library/dom": "^7.31.2", "@testing-library/user-event": "^13.1.9", "@types/babel__preset-env": "^7", diff --git a/examples/react-ts/src/button.stories.tsx b/examples/react-ts/src/button.stories.tsx index 2c278463d02..4f2400bb745 100644 --- a/examples/react-ts/src/button.stories.tsx +++ b/examples/react-ts/src/button.stories.tsx @@ -13,6 +13,7 @@ export default { export const WithArgs: ComponentStory = (args) =>