@storybook/react 6.5.0-alpha.52 → 6.5.0-alpha.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,6 +70,20 @@ Object.defineProperty(exports, "storiesOf", {
70
70
 
71
71
  var _preview = require("./preview");
72
72
 
73
+ var _testing = require("./testing");
74
+
75
+ Object.keys(_testing).forEach(function (key) {
76
+ if (key === "default" || key === "__esModule") return;
77
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
78
+ if (key in exports && exports[key] === _testing[key]) return;
79
+ Object.defineProperty(exports, key, {
80
+ enumerable: true,
81
+ get: function get() {
82
+ return _testing[key];
83
+ }
84
+ });
85
+ });
86
+
73
87
  var _types = require("./preview/types-6-3");
74
88
 
75
89
  Object.keys(_types).forEach(function (key) {
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.composeStories = composeStories;
7
+ exports.composeStory = composeStory;
8
+ exports.setGlobalConfig = setGlobalConfig;
9
+ exports.setProjectAnnotations = setProjectAnnotations;
10
+
11
+ var _store = require("@storybook/store");
12
+
13
+ var _clientLogger = require("@storybook/client-logger");
14
+
15
+ var _render = require("../preview/render");
16
+
17
+ /** Function that sets the globalConfig of your storybook. The global config is the preview module of your .storybook folder.
18
+ *
19
+ * It should be run a single time, so that your global config (e.g. decorators) is applied to your stories when using `composeStories` or `composeStory`.
20
+ *
21
+ * Example:
22
+ *```jsx
23
+ * // setup.js (for jest)
24
+ * import { setProjectAnnotations } from '@storybook/react';
25
+ * import * as projectAnnotations from './.storybook/preview';
26
+ *
27
+ * setProjectAnnotations(projectAnnotations);
28
+ *```
29
+ *
30
+ * @param projectAnnotations - e.g. (import * as projectAnnotations from '../.storybook/preview')
31
+ */
32
+ function setProjectAnnotations(projectAnnotations) {
33
+ (0, _store.setProjectAnnotations)(projectAnnotations);
34
+ }
35
+ /** Preserved for users migrating from `@storybook/testing-react`.
36
+ *
37
+ * @deprecated Use setProjectAnnotations instead
38
+ */
39
+
40
+
41
+ function setGlobalConfig(projectAnnotations) {
42
+ _clientLogger.once.warn("setGlobalConfig is deprecated. Use setProjectAnnotations instead.");
43
+
44
+ setProjectAnnotations(projectAnnotations);
45
+ } // This will not be necessary once we have auto preset loading
46
+
47
+
48
+ var defaultProjectAnnotations = {
49
+ render: _render.render
50
+ };
51
+ /**
52
+ * Function that will receive a story along with meta (e.g. a default export from a .stories file)
53
+ * and optionally projectAnnotations e.g. (import * from '../.storybook/preview)
54
+ * and will return a composed component that has all args/parameters/decorators/etc combined and applied to it.
55
+ *
56
+ *
57
+ * It's very useful for reusing a story in scenarios outside of Storybook like unit testing.
58
+ *
59
+ * Example:
60
+ *```jsx
61
+ * import { render } from '@testing-library/react';
62
+ * import { composeStory } from '@storybook/react';
63
+ * import Meta, { Primary as PrimaryStory } from './Button.stories';
64
+ *
65
+ * const Primary = composeStory(PrimaryStory, Meta);
66
+ *
67
+ * test('renders primary button with Hello World', () => {
68
+ * const { getByText } = render(<Primary>Hello world</Primary>);
69
+ * expect(getByText(/Hello world/i)).not.toBeNull();
70
+ * });
71
+ *```
72
+ *
73
+ * @param story
74
+ * @param componentAnnotations - e.g. (import Meta from './Button.stories')
75
+ * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
76
+ * @param [exportsName] - in case your story does not contain a name and you want it to have a name.
77
+ */
78
+
79
+ function composeStory(story, componentAnnotations, projectAnnotations, exportsName) {
80
+ return (0, _store.composeStory)(story, componentAnnotations, projectAnnotations, defaultProjectAnnotations, exportsName);
81
+ }
82
+ /**
83
+ * Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`)
84
+ * and optionally projectAnnotations (e.g. `import * from '../.storybook/preview`)
85
+ * and will return an object containing all the stories passed, but now as a composed component that has all args/parameters/decorators/etc combined and applied to it.
86
+ *
87
+ *
88
+ * It's very useful for reusing stories in scenarios outside of Storybook like unit testing.
89
+ *
90
+ * Example:
91
+ *```jsx
92
+ * import { render } from '@testing-library/react';
93
+ * import { composeStories } from '@storybook/react';
94
+ * import * as stories from './Button.stories';
95
+ *
96
+ * const { Primary, Secondary } = composeStories(stories);
97
+ *
98
+ * test('renders primary button with Hello World', () => {
99
+ * const { getByText } = render(<Primary>Hello world</Primary>);
100
+ * expect(getByText(/Hello world/i)).not.toBeNull();
101
+ * });
102
+ *```
103
+ *
104
+ * @param csfExports - e.g. (import * as stories from './Button.stories')
105
+ * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
106
+ */
107
+
108
+
109
+ function composeStories(csfExports, projectAnnotations) {
110
+ var composedStories = (0, _store.composeStories)(csfExports, projectAnnotations, composeStory);
111
+ return composedStories;
112
+ }
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.babel = babel;
7
- exports.config = void 0;
7
+ exports.previewAnnotations = void 0;
8
8
  exports.webpackFinal = webpackFinal;
9
9
 
10
10
  require("core-js/modules/es.promise.js");
@@ -60,9 +60,9 @@ async function webpackFinal(config, options) {
60
60
  });
61
61
  }
62
62
 
63
- var config = function (entry = [], options) {
63
+ var previewAnnotations = function (entry = [], options) {
64
64
  if (!(0, _docsTools.hasDocsOrControls)(options)) return entry;
65
65
  return [...entry, (0, _coreCommon.findDistEsm)(__dirname, 'client/docs/config')];
66
66
  };
67
67
 
68
- exports.config = config;
68
+ exports.previewAnnotations = previewAnnotations;
@@ -3,14 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.config = exports.addons = void 0;
6
+ exports.previewAnnotations = exports.addons = void 0;
7
7
 
8
8
  var _coreCommon = require("@storybook/core-common");
9
9
 
10
- var config = function (entries = []) {
10
+ var previewAnnotations = function (entries = []) {
11
11
  return [...entries, (0, _coreCommon.findDistEsm)(__dirname, 'client/preview/config')];
12
12
  };
13
13
 
14
- exports.config = config;
14
+ exports.previewAnnotations = previewAnnotations;
15
15
  var addons = [require.resolve('./framework-preset-react'), require.resolve('./framework-preset-cra'), require.resolve('./framework-preset-react-docs')];
16
16
  exports.addons = addons;
@@ -1,4 +1,5 @@
1
1
  export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, raw, forceReRender } from './preview';
2
+ export * from './testing';
2
3
  export * from './preview/types-6-3';
3
4
 
4
5
  if (module && module.hot && module.hot.decline) {
@@ -0,0 +1,96 @@
1
+ import { composeStory as originalComposeStory, composeStories as originalComposeStories, setProjectAnnotations as originalSetProjectAnnotations } from '@storybook/store';
2
+ import { once } from '@storybook/client-logger';
3
+ import { render } from '../preview/render';
4
+
5
+ /** Function that sets the globalConfig of your storybook. The global config is the preview module of your .storybook folder.
6
+ *
7
+ * It should be run a single time, so that your global config (e.g. decorators) is applied to your stories when using `composeStories` or `composeStory`.
8
+ *
9
+ * Example:
10
+ *```jsx
11
+ * // setup.js (for jest)
12
+ * import { setProjectAnnotations } from '@storybook/react';
13
+ * import * as projectAnnotations from './.storybook/preview';
14
+ *
15
+ * setProjectAnnotations(projectAnnotations);
16
+ *```
17
+ *
18
+ * @param projectAnnotations - e.g. (import * as projectAnnotations from '../.storybook/preview')
19
+ */
20
+ export function setProjectAnnotations(projectAnnotations) {
21
+ originalSetProjectAnnotations(projectAnnotations);
22
+ }
23
+ /** Preserved for users migrating from `@storybook/testing-react`.
24
+ *
25
+ * @deprecated Use setProjectAnnotations instead
26
+ */
27
+
28
+ export function setGlobalConfig(projectAnnotations) {
29
+ once.warn("setGlobalConfig is deprecated. Use setProjectAnnotations instead.");
30
+ setProjectAnnotations(projectAnnotations);
31
+ } // This will not be necessary once we have auto preset loading
32
+
33
+ var defaultProjectAnnotations = {
34
+ render: render
35
+ };
36
+ /**
37
+ * Function that will receive a story along with meta (e.g. a default export from a .stories file)
38
+ * and optionally projectAnnotations e.g. (import * from '../.storybook/preview)
39
+ * and will return a composed component that has all args/parameters/decorators/etc combined and applied to it.
40
+ *
41
+ *
42
+ * It's very useful for reusing a story in scenarios outside of Storybook like unit testing.
43
+ *
44
+ * Example:
45
+ *```jsx
46
+ * import { render } from '@testing-library/react';
47
+ * import { composeStory } from '@storybook/react';
48
+ * import Meta, { Primary as PrimaryStory } from './Button.stories';
49
+ *
50
+ * const Primary = composeStory(PrimaryStory, Meta);
51
+ *
52
+ * test('renders primary button with Hello World', () => {
53
+ * const { getByText } = render(<Primary>Hello world</Primary>);
54
+ * expect(getByText(/Hello world/i)).not.toBeNull();
55
+ * });
56
+ *```
57
+ *
58
+ * @param story
59
+ * @param componentAnnotations - e.g. (import Meta from './Button.stories')
60
+ * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
61
+ * @param [exportsName] - in case your story does not contain a name and you want it to have a name.
62
+ */
63
+
64
+ export function composeStory(story, componentAnnotations, projectAnnotations, exportsName) {
65
+ return originalComposeStory(story, componentAnnotations, projectAnnotations, defaultProjectAnnotations, exportsName);
66
+ }
67
+ /**
68
+ * Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`)
69
+ * and optionally projectAnnotations (e.g. `import * from '../.storybook/preview`)
70
+ * and will return an object containing all the stories passed, but now as a composed component that has all args/parameters/decorators/etc combined and applied to it.
71
+ *
72
+ *
73
+ * It's very useful for reusing stories in scenarios outside of Storybook like unit testing.
74
+ *
75
+ * Example:
76
+ *```jsx
77
+ * import { render } from '@testing-library/react';
78
+ * import { composeStories } from '@storybook/react';
79
+ * import * as stories from './Button.stories';
80
+ *
81
+ * const { Primary, Secondary } = composeStories(stories);
82
+ *
83
+ * test('renders primary button with Hello World', () => {
84
+ * const { getByText } = render(<Primary>Hello world</Primary>);
85
+ * expect(getByText(/Hello world/i)).not.toBeNull();
86
+ * });
87
+ *```
88
+ *
89
+ * @param csfExports - e.g. (import * as stories from './Button.stories')
90
+ * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
91
+ */
92
+
93
+ export function composeStories(csfExports, projectAnnotations) {
94
+ var composedStories = originalComposeStories(csfExports, projectAnnotations, composeStory);
95
+ return composedStories;
96
+ }
@@ -43,7 +43,7 @@ export async function webpackFinal(config, options) {
43
43
  }))]
44
44
  });
45
45
  }
46
- export var config = function (entry = [], options) {
46
+ export var previewAnnotations = function (entry = [], options) {
47
47
  if (!hasDocsOrControls(options)) return entry;
48
48
  return [...entry, findDistEsm(__dirname, 'client/docs/config')];
49
49
  };
@@ -1,5 +1,5 @@
1
1
  import { findDistEsm } from '@storybook/core-common';
2
- export var config = function (entries = []) {
2
+ export var previewAnnotations = function (entries = []) {
3
3
  return [...entries, findDistEsm(__dirname, 'client/preview/config')];
4
4
  };
5
5
  export var addons = [require.resolve('./framework-preset-react'), require.resolve('./framework-preset-cra'), require.resolve('./framework-preset-react-docs')];
@@ -1,4 +1,5 @@
1
1
  export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, raw, forceReRender } from './preview';
2
+ export * from './testing';
2
3
  export * from './preview/types-6-3';
3
4
 
4
5
  if (module && module.hot && module.hot.decline) {
@@ -0,0 +1,96 @@
1
+ import { composeStory as originalComposeStory, composeStories as originalComposeStories, setProjectAnnotations as originalSetProjectAnnotations } from '@storybook/store';
2
+ import { once } from '@storybook/client-logger';
3
+ import { render } from '../preview/render';
4
+
5
+ /** Function that sets the globalConfig of your storybook. The global config is the preview module of your .storybook folder.
6
+ *
7
+ * It should be run a single time, so that your global config (e.g. decorators) is applied to your stories when using `composeStories` or `composeStory`.
8
+ *
9
+ * Example:
10
+ *```jsx
11
+ * // setup.js (for jest)
12
+ * import { setProjectAnnotations } from '@storybook/react';
13
+ * import * as projectAnnotations from './.storybook/preview';
14
+ *
15
+ * setProjectAnnotations(projectAnnotations);
16
+ *```
17
+ *
18
+ * @param projectAnnotations - e.g. (import * as projectAnnotations from '../.storybook/preview')
19
+ */
20
+ export function setProjectAnnotations(projectAnnotations) {
21
+ originalSetProjectAnnotations(projectAnnotations);
22
+ }
23
+ /** Preserved for users migrating from `@storybook/testing-react`.
24
+ *
25
+ * @deprecated Use setProjectAnnotations instead
26
+ */
27
+
28
+ export function setGlobalConfig(projectAnnotations) {
29
+ once.warn(`setGlobalConfig is deprecated. Use setProjectAnnotations instead.`);
30
+ setProjectAnnotations(projectAnnotations);
31
+ } // This will not be necessary once we have auto preset loading
32
+
33
+ const defaultProjectAnnotations = {
34
+ render
35
+ };
36
+ /**
37
+ * Function that will receive a story along with meta (e.g. a default export from a .stories file)
38
+ * and optionally projectAnnotations e.g. (import * from '../.storybook/preview)
39
+ * and will return a composed component that has all args/parameters/decorators/etc combined and applied to it.
40
+ *
41
+ *
42
+ * It's very useful for reusing a story in scenarios outside of Storybook like unit testing.
43
+ *
44
+ * Example:
45
+ *```jsx
46
+ * import { render } from '@testing-library/react';
47
+ * import { composeStory } from '@storybook/react';
48
+ * import Meta, { Primary as PrimaryStory } from './Button.stories';
49
+ *
50
+ * const Primary = composeStory(PrimaryStory, Meta);
51
+ *
52
+ * test('renders primary button with Hello World', () => {
53
+ * const { getByText } = render(<Primary>Hello world</Primary>);
54
+ * expect(getByText(/Hello world/i)).not.toBeNull();
55
+ * });
56
+ *```
57
+ *
58
+ * @param story
59
+ * @param componentAnnotations - e.g. (import Meta from './Button.stories')
60
+ * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
61
+ * @param [exportsName] - in case your story does not contain a name and you want it to have a name.
62
+ */
63
+
64
+ export function composeStory(story, componentAnnotations, projectAnnotations, exportsName) {
65
+ return originalComposeStory(story, componentAnnotations, projectAnnotations, defaultProjectAnnotations, exportsName);
66
+ }
67
+ /**
68
+ * Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`)
69
+ * and optionally projectAnnotations (e.g. `import * from '../.storybook/preview`)
70
+ * and will return an object containing all the stories passed, but now as a composed component that has all args/parameters/decorators/etc combined and applied to it.
71
+ *
72
+ *
73
+ * It's very useful for reusing stories in scenarios outside of Storybook like unit testing.
74
+ *
75
+ * Example:
76
+ *```jsx
77
+ * import { render } from '@testing-library/react';
78
+ * import { composeStories } from '@storybook/react';
79
+ * import * as stories from './Button.stories';
80
+ *
81
+ * const { Primary, Secondary } = composeStories(stories);
82
+ *
83
+ * test('renders primary button with Hello World', () => {
84
+ * const { getByText } = render(<Primary>Hello world</Primary>);
85
+ * expect(getByText(/Hello world/i)).not.toBeNull();
86
+ * });
87
+ *```
88
+ *
89
+ * @param csfExports - e.g. (import * as stories from './Button.stories')
90
+ * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
91
+ */
92
+
93
+ export function composeStories(csfExports, projectAnnotations) {
94
+ const composedStories = originalComposeStories(csfExports, projectAnnotations, composeStory);
95
+ return composedStories;
96
+ }
@@ -43,7 +43,7 @@ export async function webpackFinal(config, options) {
43
43
  }))]
44
44
  });
45
45
  }
46
- export var config = function (entry = [], options) {
46
+ export var previewAnnotations = function (entry = [], options) {
47
47
  if (!hasDocsOrControls(options)) return entry;
48
48
  return [...entry, findDistEsm(__dirname, 'client/docs/config')];
49
49
  };
@@ -1,5 +1,5 @@
1
1
  import { findDistEsm } from '@storybook/core-common';
2
- export var config = function (entries = []) {
2
+ export var previewAnnotations = function (entries = []) {
3
3
  return [...entries, findDistEsm(__dirname, 'client/preview/config')];
4
4
  };
5
5
  export var addons = [require.resolve('./framework-preset-react'), require.resolve('./framework-preset-cra'), require.resolve('./framework-preset-react-docs')];
@@ -1,3 +1,4 @@
1
1
  export { DecoratorFn } from './preview';
2
2
  export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, raw, forceReRender, } from './preview';
3
+ export * from './testing';
3
4
  export * from './preview/types-6-3';
@@ -0,0 +1,84 @@
1
+ import { CSFExports, ComposedStory, StoriesWithPartialProps } from '@storybook/store';
2
+ import { ProjectAnnotations, Args } from '@storybook/csf';
3
+ import { Meta, ReactFramework } from '../preview/types-6-0';
4
+ /** Function that sets the globalConfig of your storybook. The global config is the preview module of your .storybook folder.
5
+ *
6
+ * It should be run a single time, so that your global config (e.g. decorators) is applied to your stories when using `composeStories` or `composeStory`.
7
+ *
8
+ * Example:
9
+ *```jsx
10
+ * // setup.js (for jest)
11
+ * import { setProjectAnnotations } from '@storybook/react';
12
+ * import * as projectAnnotations from './.storybook/preview';
13
+ *
14
+ * setProjectAnnotations(projectAnnotations);
15
+ *```
16
+ *
17
+ * @param projectAnnotations - e.g. (import * as projectAnnotations from '../.storybook/preview')
18
+ */
19
+ export declare function setProjectAnnotations(projectAnnotations: ProjectAnnotations<ReactFramework> | ProjectAnnotations<ReactFramework>[]): void;
20
+ /** Preserved for users migrating from `@storybook/testing-react`.
21
+ *
22
+ * @deprecated Use setProjectAnnotations instead
23
+ */
24
+ export declare function setGlobalConfig(projectAnnotations: ProjectAnnotations<ReactFramework> | ProjectAnnotations<ReactFramework>[]): void;
25
+ /**
26
+ * Function that will receive a story along with meta (e.g. a default export from a .stories file)
27
+ * and optionally projectAnnotations e.g. (import * from '../.storybook/preview)
28
+ * and will return a composed component that has all args/parameters/decorators/etc combined and applied to it.
29
+ *
30
+ *
31
+ * It's very useful for reusing a story in scenarios outside of Storybook like unit testing.
32
+ *
33
+ * Example:
34
+ *```jsx
35
+ * import { render } from '@testing-library/react';
36
+ * import { composeStory } from '@storybook/react';
37
+ * import Meta, { Primary as PrimaryStory } from './Button.stories';
38
+ *
39
+ * const Primary = composeStory(PrimaryStory, Meta);
40
+ *
41
+ * test('renders primary button with Hello World', () => {
42
+ * const { getByText } = render(<Primary>Hello world</Primary>);
43
+ * expect(getByText(/Hello world/i)).not.toBeNull();
44
+ * });
45
+ *```
46
+ *
47
+ * @param story
48
+ * @param componentAnnotations - e.g. (import Meta from './Button.stories')
49
+ * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
50
+ * @param [exportsName] - in case your story does not contain a name and you want it to have a name.
51
+ */
52
+ export declare function composeStory<TArgs = Args>(story: ComposedStory<ReactFramework, TArgs>, componentAnnotations: Meta<TArgs | any>, projectAnnotations?: ProjectAnnotations<ReactFramework>, exportsName?: string): {
53
+ (extraArgs: Partial<TArgs>): import("../preview/types").StoryFnReactReturnType;
54
+ storyName: string;
55
+ args: Args;
56
+ play: import("@storybook/store").ComposedStoryPlayFn;
57
+ parameters: import("@storybook/store").Parameters;
58
+ };
59
+ /**
60
+ * Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`)
61
+ * and optionally projectAnnotations (e.g. `import * from '../.storybook/preview`)
62
+ * and will return an object containing all the stories passed, but now as a composed component that has all args/parameters/decorators/etc combined and applied to it.
63
+ *
64
+ *
65
+ * It's very useful for reusing stories in scenarios outside of Storybook like unit testing.
66
+ *
67
+ * Example:
68
+ *```jsx
69
+ * import { render } from '@testing-library/react';
70
+ * import { composeStories } from '@storybook/react';
71
+ * import * as stories from './Button.stories';
72
+ *
73
+ * const { Primary, Secondary } = composeStories(stories);
74
+ *
75
+ * test('renders primary button with Hello World', () => {
76
+ * const { getByText } = render(<Primary>Hello world</Primary>);
77
+ * expect(getByText(/Hello world/i)).not.toBeNull();
78
+ * });
79
+ *```
80
+ *
81
+ * @param csfExports - e.g. (import * as stories from './Button.stories')
82
+ * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
83
+ */
84
+ export declare function composeStories<TModule extends CSFExports<ReactFramework>>(csfExports: TModule, projectAnnotations?: ProjectAnnotations<ReactFramework>): Pick<StoriesWithPartialProps<ReactFramework, TModule>, Exclude<keyof TModule, "default" | "__esModule" | "__namedExportsOrder">>;
@@ -3,4 +3,4 @@ import { TransformOptions } from '@babel/core';
3
3
  import { Configuration } from 'webpack';
4
4
  export declare function babel(config: TransformOptions, options: Options): Promise<TransformOptions>;
5
5
  export declare function webpackFinal(config: Configuration, options: Options): Promise<Configuration>;
6
- export declare const config: StorybookConfig['config'];
6
+ export declare const previewAnnotations: StorybookConfig['previewAnnotations'];
@@ -1,3 +1,3 @@
1
1
  import { StorybookConfig } from '@storybook/core-common';
2
- export declare const config: StorybookConfig['config'];
2
+ export declare const previewAnnotations: StorybookConfig['previewAnnotations'];
3
3
  export declare const addons: StorybookConfig['addons'];
@@ -1,3 +1,4 @@
1
1
  export type { DecoratorFn } from './preview';
2
2
  export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, raw, forceReRender, } from './preview';
3
+ export * from './testing';
3
4
  export * from './preview/types-6-3';
@@ -0,0 +1,84 @@
1
+ import { CSFExports, ComposedStory, StoriesWithPartialProps } from '@storybook/store';
2
+ import { ProjectAnnotations, Args } from '@storybook/csf';
3
+ import type { Meta, ReactFramework } from '../preview/types-6-0';
4
+ /** Function that sets the globalConfig of your storybook. The global config is the preview module of your .storybook folder.
5
+ *
6
+ * It should be run a single time, so that your global config (e.g. decorators) is applied to your stories when using `composeStories` or `composeStory`.
7
+ *
8
+ * Example:
9
+ *```jsx
10
+ * // setup.js (for jest)
11
+ * import { setProjectAnnotations } from '@storybook/react';
12
+ * import * as projectAnnotations from './.storybook/preview';
13
+ *
14
+ * setProjectAnnotations(projectAnnotations);
15
+ *```
16
+ *
17
+ * @param projectAnnotations - e.g. (import * as projectAnnotations from '../.storybook/preview')
18
+ */
19
+ export declare function setProjectAnnotations(projectAnnotations: ProjectAnnotations<ReactFramework> | ProjectAnnotations<ReactFramework>[]): void;
20
+ /** Preserved for users migrating from `@storybook/testing-react`.
21
+ *
22
+ * @deprecated Use setProjectAnnotations instead
23
+ */
24
+ export declare function setGlobalConfig(projectAnnotations: ProjectAnnotations<ReactFramework> | ProjectAnnotations<ReactFramework>[]): void;
25
+ /**
26
+ * Function that will receive a story along with meta (e.g. a default export from a .stories file)
27
+ * and optionally projectAnnotations e.g. (import * from '../.storybook/preview)
28
+ * and will return a composed component that has all args/parameters/decorators/etc combined and applied to it.
29
+ *
30
+ *
31
+ * It's very useful for reusing a story in scenarios outside of Storybook like unit testing.
32
+ *
33
+ * Example:
34
+ *```jsx
35
+ * import { render } from '@testing-library/react';
36
+ * import { composeStory } from '@storybook/react';
37
+ * import Meta, { Primary as PrimaryStory } from './Button.stories';
38
+ *
39
+ * const Primary = composeStory(PrimaryStory, Meta);
40
+ *
41
+ * test('renders primary button with Hello World', () => {
42
+ * const { getByText } = render(<Primary>Hello world</Primary>);
43
+ * expect(getByText(/Hello world/i)).not.toBeNull();
44
+ * });
45
+ *```
46
+ *
47
+ * @param story
48
+ * @param componentAnnotations - e.g. (import Meta from './Button.stories')
49
+ * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
50
+ * @param [exportsName] - in case your story does not contain a name and you want it to have a name.
51
+ */
52
+ export declare function composeStory<TArgs = Args>(story: ComposedStory<ReactFramework, TArgs>, componentAnnotations: Meta<TArgs | any>, projectAnnotations?: ProjectAnnotations<ReactFramework>, exportsName?: string): {
53
+ (extraArgs: Partial<TArgs>): import("../preview/types").StoryFnReactReturnType;
54
+ storyName: string;
55
+ args: Args;
56
+ play: import("@storybook/store").ComposedStoryPlayFn;
57
+ parameters: import("@storybook/store").Parameters;
58
+ };
59
+ /**
60
+ * Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`)
61
+ * and optionally projectAnnotations (e.g. `import * from '../.storybook/preview`)
62
+ * and will return an object containing all the stories passed, but now as a composed component that has all args/parameters/decorators/etc combined and applied to it.
63
+ *
64
+ *
65
+ * It's very useful for reusing stories in scenarios outside of Storybook like unit testing.
66
+ *
67
+ * Example:
68
+ *```jsx
69
+ * import { render } from '@testing-library/react';
70
+ * import { composeStories } from '@storybook/react';
71
+ * import * as stories from './Button.stories';
72
+ *
73
+ * const { Primary, Secondary } = composeStories(stories);
74
+ *
75
+ * test('renders primary button with Hello World', () => {
76
+ * const { getByText } = render(<Primary>Hello world</Primary>);
77
+ * expect(getByText(/Hello world/i)).not.toBeNull();
78
+ * });
79
+ *```
80
+ *
81
+ * @param csfExports - e.g. (import * as stories from './Button.stories')
82
+ * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
83
+ */
84
+ export declare function composeStories<TModule extends CSFExports<ReactFramework>>(csfExports: TModule, projectAnnotations?: ProjectAnnotations<ReactFramework>): Pick<StoriesWithPartialProps<ReactFramework, TModule>, Exclude<keyof TModule, "default" | "__esModule" | "__namedExportsOrder">>;
@@ -3,4 +3,4 @@ import type { TransformOptions } from '@babel/core';
3
3
  import type { Configuration } from 'webpack';
4
4
  export declare function babel(config: TransformOptions, options: Options): Promise<TransformOptions>;
5
5
  export declare function webpackFinal(config: Configuration, options: Options): Promise<Configuration>;
6
- export declare const config: StorybookConfig['config'];
6
+ export declare const previewAnnotations: StorybookConfig['previewAnnotations'];
@@ -1,3 +1,3 @@
1
1
  import type { StorybookConfig } from '@storybook/core-common';
2
- export declare const config: StorybookConfig['config'];
2
+ export declare const previewAnnotations: StorybookConfig['previewAnnotations'];
3
3
  export declare const addons: StorybookConfig['addons'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react",
3
- "version": "6.5.0-alpha.52",
3
+ "version": "6.5.0-alpha.55",
4
4
  "description": "Storybook for React: Develop React Component in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook"
@@ -49,16 +49,16 @@
49
49
  "@babel/preset-flow": "^7.12.1",
50
50
  "@babel/preset-react": "^7.12.10",
51
51
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
52
- "@storybook/addons": "6.5.0-alpha.52",
53
- "@storybook/client-logger": "6.5.0-alpha.52",
54
- "@storybook/core": "6.5.0-alpha.52",
55
- "@storybook/core-common": "6.5.0-alpha.52",
52
+ "@storybook/addons": "6.5.0-alpha.55",
53
+ "@storybook/client-logger": "6.5.0-alpha.55",
54
+ "@storybook/core": "6.5.0-alpha.55",
55
+ "@storybook/core-common": "6.5.0-alpha.55",
56
56
  "@storybook/csf": "0.0.2--canary.507502b.0",
57
- "@storybook/docs-tools": "6.5.0-alpha.52",
58
- "@storybook/node-logger": "6.5.0-alpha.52",
57
+ "@storybook/docs-tools": "6.5.0-alpha.55",
58
+ "@storybook/node-logger": "6.5.0-alpha.55",
59
59
  "@storybook/react-docgen-typescript-plugin": "1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0",
60
60
  "@storybook/semver": "^7.3.2",
61
- "@storybook/store": "6.5.0-alpha.52",
61
+ "@storybook/store": "6.5.0-alpha.55",
62
62
  "@types/estree": "^0.0.51",
63
63
  "@types/node": "^14.14.20 || ^16.0.0",
64
64
  "@types/webpack-env": "^1.16.0",
@@ -88,8 +88,8 @@
88
88
  "peerDependencies": {
89
89
  "@babel/core": "^7.11.5",
90
90
  "jest-specific-snapshot": "^4.0.0",
91
- "react": "^16.8.0 || ^17.0.0",
92
- "react-dom": "^16.8.0 || ^17.0.0",
91
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
92
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
93
93
  "require-from-string": "^2.0.2"
94
94
  },
95
95
  "peerDependenciesMeta": {
@@ -118,6 +118,6 @@
118
118
  "publishConfig": {
119
119
  "access": "public"
120
120
  },
121
- "gitHead": "863b3811b24a4703645a09286059bc6d95bd2e65",
121
+ "gitHead": "0d051c3d8efb90e15d8734e6e6914b2439420953",
122
122
  "sbmodern": "dist/modern/client/index.js"
123
123
  }