@storybook/react 8.3.0-alpha.6 → 8.3.0-alpha.8
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.
- package/dist/index.d.ts +29 -21
- package/dist/preset.d.ts +5 -4
- package/package.json +8 -8
- package/template/cli/js/Button.jsx +6 -18
- package/template/cli/ts-3-8/Button.tsx +6 -18
- package/template/cli/ts-4-9/Button.tsx +6 -18
package/dist/index.d.ts
CHANGED
|
@@ -6,33 +6,38 @@ import { R as ReactRenderer } from './types-a5624094.js';
|
|
|
6
6
|
import 'react';
|
|
7
7
|
import 'type-fest';
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Function that sets the globalConfig of your storybook. The global config is the preview module of
|
|
11
|
+
* your .storybook folder.
|
|
10
12
|
*
|
|
11
|
-
* It should be run a single time, so that your global config (e.g. decorators) is applied to your
|
|
13
|
+
* It should be run a single time, so that your global config (e.g. decorators) is applied to your
|
|
14
|
+
* stories when using `composeStories` or `composeStory`.
|
|
12
15
|
*
|
|
13
16
|
* Example:
|
|
14
|
-
|
|
15
|
-
*
|
|
17
|
+
*
|
|
18
|
+
* ```jsx
|
|
19
|
+
* // setup-file.js
|
|
16
20
|
* import { setProjectAnnotations } from '@storybook/react';
|
|
17
21
|
* import projectAnnotations from './.storybook/preview';
|
|
18
22
|
*
|
|
19
23
|
* setProjectAnnotations(projectAnnotations);
|
|
20
|
-
|
|
24
|
+
* ```
|
|
21
25
|
*
|
|
22
|
-
* @param projectAnnotations -
|
|
26
|
+
* @param projectAnnotations - E.g. (import * as projectAnnotations from '../.storybook/preview')
|
|
23
27
|
*/
|
|
24
28
|
declare function setProjectAnnotations(projectAnnotations: NamedOrDefaultProjectAnnotations<any> | NamedOrDefaultProjectAnnotations<any>[]): NormalizedProjectAnnotations<ReactRenderer>;
|
|
25
29
|
declare const INTERNAL_DEFAULT_PROJECT_ANNOTATIONS: ProjectAnnotations<ReactRenderer>;
|
|
26
30
|
/**
|
|
27
31
|
* Function that will receive a story along with meta (e.g. a default export from a .stories file)
|
|
28
|
-
* and optionally projectAnnotations e.g. (import * as projectAnnotations from
|
|
29
|
-
* and will return a composed component that has all
|
|
30
|
-
*
|
|
32
|
+
* and optionally projectAnnotations e.g. (import * as projectAnnotations from
|
|
33
|
+
* '../.storybook/preview) and will return a composed component that has all
|
|
34
|
+
* args/parameters/decorators/etc combined and applied to it.
|
|
31
35
|
*
|
|
32
36
|
* It's very useful for reusing a story in scenarios outside of Storybook like unit testing.
|
|
33
37
|
*
|
|
34
38
|
* Example:
|
|
35
|
-
|
|
39
|
+
*
|
|
40
|
+
* ```jsx
|
|
36
41
|
* import { render } from '@testing-library/react';
|
|
37
42
|
* import { composeStory } from '@storybook/react';
|
|
38
43
|
* import Meta, { Primary as PrimaryStory } from './Button.stories';
|
|
@@ -43,24 +48,26 @@ declare const INTERNAL_DEFAULT_PROJECT_ANNOTATIONS: ProjectAnnotations<ReactRend
|
|
|
43
48
|
* const { getByText } = render(<Primary>Hello world</Primary>);
|
|
44
49
|
* expect(getByText(/Hello world/i)).not.toBeNull();
|
|
45
50
|
* });
|
|
46
|
-
|
|
51
|
+
* ```
|
|
47
52
|
*
|
|
48
53
|
* @param story
|
|
49
|
-
* @param componentAnnotations -
|
|
50
|
-
* @param [projectAnnotations] -
|
|
51
|
-
*
|
|
54
|
+
* @param componentAnnotations - E.g. (import Meta from './Button.stories')
|
|
55
|
+
* @param [projectAnnotations] - E.g. (import * as projectAnnotations from '../.storybook/preview')
|
|
56
|
+
* this can be applied automatically if you use `setProjectAnnotations` in your setup files.
|
|
57
|
+
* @param [exportsName] - In case your story does not contain a name and you want it to have a name.
|
|
52
58
|
*/
|
|
53
59
|
declare function composeStory<TArgs extends Args = Args>(story: StoryAnnotationsOrFn<ReactRenderer, TArgs>, componentAnnotations: Meta<TArgs | any>, projectAnnotations?: ProjectAnnotations<ReactRenderer>, exportsName?: string): ComposedStoryFn<ReactRenderer, Partial<TArgs>>;
|
|
54
60
|
/**
|
|
55
61
|
* Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`)
|
|
56
|
-
* and optionally projectAnnotations (e.g. `import * as projectAnnotations from
|
|
57
|
-
* and will return an object containing all the stories passed, but now as
|
|
58
|
-
*
|
|
62
|
+
* and optionally projectAnnotations (e.g. `import * as projectAnnotations from
|
|
63
|
+
* '../.storybook/preview`) and will return an object containing all the stories passed, but now as
|
|
64
|
+
* a composed component that has all args/parameters/decorators/etc combined and applied to it.
|
|
59
65
|
*
|
|
60
66
|
* It's very useful for reusing stories in scenarios outside of Storybook like unit testing.
|
|
61
67
|
*
|
|
62
68
|
* Example:
|
|
63
|
-
|
|
69
|
+
*
|
|
70
|
+
* ```jsx
|
|
64
71
|
* import { render } from '@testing-library/react';
|
|
65
72
|
* import { composeStories } from '@storybook/react';
|
|
66
73
|
* import * as stories from './Button.stories';
|
|
@@ -71,10 +78,11 @@ declare function composeStory<TArgs extends Args = Args>(story: StoryAnnotations
|
|
|
71
78
|
* const { getByText } = render(<Primary>Hello world</Primary>);
|
|
72
79
|
* expect(getByText(/Hello world/i)).not.toBeNull();
|
|
73
80
|
* });
|
|
74
|
-
|
|
81
|
+
* ```
|
|
75
82
|
*
|
|
76
|
-
* @param csfExports -
|
|
77
|
-
* @param [projectAnnotations] -
|
|
83
|
+
* @param csfExports - E.g. (import * as stories from './Button.stories')
|
|
84
|
+
* @param [projectAnnotations] - E.g. (import * as projectAnnotations from '../.storybook/preview')
|
|
85
|
+
* this can be applied automatically if you use `setProjectAnnotations` in your setup files.
|
|
78
86
|
*/
|
|
79
87
|
declare function composeStories<TModule extends Store_CSFExports<ReactRenderer, any>>(csfExports: TModule, projectAnnotations?: ProjectAnnotations<ReactRenderer>): Omit<StoriesWithPartialProps<ReactRenderer, TModule>, keyof Store_CSFExports>;
|
|
80
88
|
|
package/dist/preset.d.ts
CHANGED
|
@@ -3,12 +3,13 @@ import { PresetProperty } from 'storybook/internal/types';
|
|
|
3
3
|
declare const addons: PresetProperty<'addons'>;
|
|
4
4
|
declare const previewAnnotations: PresetProperty<'previewAnnotations'>;
|
|
5
5
|
/**
|
|
6
|
-
* Try to resolve react and react-dom from the root node_modules of the project
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Try to resolve react and react-dom from the root node_modules of the project addon-docs uses this
|
|
7
|
+
* to alias react and react-dom to the project's version when possible If the user doesn't have an
|
|
8
|
+
* explicit dependency on react this will return the existing values Which will be the versions
|
|
9
|
+
* shipped with addon-docs
|
|
10
10
|
*
|
|
11
11
|
* We do the exact same thing in the common preset, but that will fail in Yarn PnP because
|
|
12
|
+
*
|
|
12
13
|
* @storybook/core-server doesn't have a peer dependency on react
|
|
13
14
|
* This will make @storybook/react projects work in Yarn PnP
|
|
14
15
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react",
|
|
3
|
-
"version": "8.3.0-alpha.
|
|
3
|
+
"version": "8.3.0-alpha.8",
|
|
4
4
|
"description": "Storybook React renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"prep": "jiti ../../../scripts/prepare/bundle.ts"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@storybook/components": "^8.3.0-alpha.
|
|
67
|
+
"@storybook/components": "^8.3.0-alpha.8",
|
|
68
68
|
"@storybook/global": "^5.0.0",
|
|
69
|
-
"@storybook/manager-api": "^8.3.0-alpha.
|
|
70
|
-
"@storybook/preview-api": "^8.3.0-alpha.
|
|
71
|
-
"@storybook/react-dom-shim": "8.3.0-alpha.
|
|
72
|
-
"@storybook/theming": "^8.3.0-alpha.
|
|
69
|
+
"@storybook/manager-api": "^8.3.0-alpha.8",
|
|
70
|
+
"@storybook/preview-api": "^8.3.0-alpha.8",
|
|
71
|
+
"@storybook/react-dom-shim": "8.3.0-alpha.8",
|
|
72
|
+
"@storybook/theming": "^8.3.0-alpha.8",
|
|
73
73
|
"@types/escodegen": "^0.0.6",
|
|
74
74
|
"@types/estree": "^0.0.51",
|
|
75
75
|
"@types/node": "^22.0.0",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"util-deprecate": "^1.0.2"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@storybook/test": "8.3.0-alpha.
|
|
89
|
+
"@storybook/test": "8.3.0-alpha.8",
|
|
90
90
|
"@types/babel-plugin-react-docgen": "^4",
|
|
91
91
|
"@types/semver": "^7.3.4",
|
|
92
92
|
"@types/util-deprecate": "^1.0.0",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
|
|
100
100
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
|
|
101
|
-
"storybook": "^8.3.0-alpha.
|
|
101
|
+
"storybook": "^8.3.0-alpha.8",
|
|
102
102
|
"typescript": ">= 4.2.x"
|
|
103
103
|
},
|
|
104
104
|
"peerDependenciesMeta": {
|
|
@@ -4,9 +4,7 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
|
|
5
5
|
import './button.css';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Primary UI component for user interaction
|
|
9
|
-
*/
|
|
7
|
+
/** Primary UI component for user interaction */
|
|
10
8
|
export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
|
|
11
9
|
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
12
10
|
return (
|
|
@@ -22,25 +20,15 @@ export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
|
|
|
22
20
|
};
|
|
23
21
|
|
|
24
22
|
Button.propTypes = {
|
|
25
|
-
/**
|
|
26
|
-
* Is this the principal call to action on the page?
|
|
27
|
-
*/
|
|
23
|
+
/** Is this the principal call to action on the page? */
|
|
28
24
|
primary: PropTypes.bool,
|
|
29
|
-
/**
|
|
30
|
-
* What background color to use
|
|
31
|
-
*/
|
|
25
|
+
/** What background color to use */
|
|
32
26
|
backgroundColor: PropTypes.string,
|
|
33
|
-
/**
|
|
34
|
-
* How large should the button be?
|
|
35
|
-
*/
|
|
27
|
+
/** How large should the button be? */
|
|
36
28
|
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
37
|
-
/**
|
|
38
|
-
* Button contents
|
|
39
|
-
*/
|
|
29
|
+
/** Button contents */
|
|
40
30
|
label: PropTypes.string.isRequired,
|
|
41
|
-
/**
|
|
42
|
-
* Optional click handler
|
|
43
|
-
*/
|
|
31
|
+
/** Optional click handler */
|
|
44
32
|
onClick: PropTypes.func,
|
|
45
33
|
};
|
|
46
34
|
|
|
@@ -3,31 +3,19 @@ import React from 'react';
|
|
|
3
3
|
import './button.css';
|
|
4
4
|
|
|
5
5
|
export interface ButtonProps {
|
|
6
|
-
/**
|
|
7
|
-
* Is this the principal call to action on the page?
|
|
8
|
-
*/
|
|
6
|
+
/** Is this the principal call to action on the page? */
|
|
9
7
|
primary?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* What background color to use
|
|
12
|
-
*/
|
|
8
|
+
/** What background color to use */
|
|
13
9
|
backgroundColor?: string;
|
|
14
|
-
/**
|
|
15
|
-
* How large should the button be?
|
|
16
|
-
*/
|
|
10
|
+
/** How large should the button be? */
|
|
17
11
|
size?: 'small' | 'medium' | 'large';
|
|
18
|
-
/**
|
|
19
|
-
* Button contents
|
|
20
|
-
*/
|
|
12
|
+
/** Button contents */
|
|
21
13
|
label: string;
|
|
22
|
-
/**
|
|
23
|
-
* Optional click handler
|
|
24
|
-
*/
|
|
14
|
+
/** Optional click handler */
|
|
25
15
|
onClick?: () => void;
|
|
26
16
|
}
|
|
27
17
|
|
|
28
|
-
/**
|
|
29
|
-
* Primary UI component for user interaction
|
|
30
|
-
*/
|
|
18
|
+
/** Primary UI component for user interaction */
|
|
31
19
|
export const Button = ({
|
|
32
20
|
primary = false,
|
|
33
21
|
size = 'medium',
|
|
@@ -3,31 +3,19 @@ import React from 'react';
|
|
|
3
3
|
import './button.css';
|
|
4
4
|
|
|
5
5
|
export interface ButtonProps {
|
|
6
|
-
/**
|
|
7
|
-
* Is this the principal call to action on the page?
|
|
8
|
-
*/
|
|
6
|
+
/** Is this the principal call to action on the page? */
|
|
9
7
|
primary?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* What background color to use
|
|
12
|
-
*/
|
|
8
|
+
/** What background color to use */
|
|
13
9
|
backgroundColor?: string;
|
|
14
|
-
/**
|
|
15
|
-
* How large should the button be?
|
|
16
|
-
*/
|
|
10
|
+
/** How large should the button be? */
|
|
17
11
|
size?: 'small' | 'medium' | 'large';
|
|
18
|
-
/**
|
|
19
|
-
* Button contents
|
|
20
|
-
*/
|
|
12
|
+
/** Button contents */
|
|
21
13
|
label: string;
|
|
22
|
-
/**
|
|
23
|
-
* Optional click handler
|
|
24
|
-
*/
|
|
14
|
+
/** Optional click handler */
|
|
25
15
|
onClick?: () => void;
|
|
26
16
|
}
|
|
27
17
|
|
|
28
|
-
/**
|
|
29
|
-
* Primary UI component for user interaction
|
|
30
|
-
*/
|
|
18
|
+
/** Primary UI component for user interaction */
|
|
31
19
|
export const Button = ({
|
|
32
20
|
primary = false,
|
|
33
21
|
size = 'medium',
|