@storybook/react 9.0.0-alpha.1 → 9.0.0-alpha.2
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/{chunk-W32SJPZN.mjs → chunk-GRKIXS2O.mjs} +1 -1
- package/dist/entry-preview-docs.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/preset.d.ts +3 -2
- package/dist/preview.d.ts +2 -2
- package/dist/preview.mjs +2 -2
- package/package.json +6 -10
- package/template/cli/ts-3-8/Button.stories.ts +0 -53
- package/template/cli/ts-3-8/Button.tsx +0 -37
- package/template/cli/ts-3-8/Header.stories.ts +0 -33
- package/template/cli/ts-3-8/Header.tsx +0 -56
- package/template/cli/ts-3-8/Page.stories.ts +0 -32
- package/template/cli/ts-3-8/Page.tsx +0 -73
- /package/dist/{chunk-EZTXUNTE.mjs → chunk-EWIU6LHT.mjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { entry_preview_exports } from './chunk-6IITSBZU.mjs';
|
|
2
|
-
import { entry_preview_docs_exports } from './chunk-
|
|
2
|
+
import { entry_preview_docs_exports } from './chunk-EWIU6LHT.mjs';
|
|
3
3
|
import { __definePreview as __definePreview$1 } from 'storybook/internal/csf';
|
|
4
4
|
|
|
5
5
|
function __definePreview(preview){return __definePreview$1({...preview,addons:[entry_preview_exports,entry_preview_docs_exports,...preview.addons??[]]})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { applyDecorators, argTypesEnhancers, decorators, parameters } from './chunk-
|
|
1
|
+
export { applyDecorators, argTypesEnhancers, decorators, parameters } from './chunk-EWIU6LHT.mjs';
|
|
2
2
|
import './chunk-XP5HYGXS.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, Project
|
|
|
4
4
|
export { ArgTypes, Args, Parameters, StrictArgs } from 'storybook/internal/types';
|
|
5
5
|
import { R as ReactRenderer } from './types-5617c98e.js';
|
|
6
6
|
export { a as ReactParameters } from './types-5617c98e.js';
|
|
7
|
-
export { ReactPreview, __definePreview } from './preview.js';
|
|
7
|
+
export { ReactPreview, ReactStory, __definePreview } from './preview.js';
|
|
8
8
|
import 'react';
|
|
9
9
|
import 'storybook/internal/csf';
|
|
10
10
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { __definePreview } from './chunk-
|
|
1
|
+
export { __definePreview } from './chunk-GRKIXS2O.mjs';
|
|
2
2
|
import { entry_preview_exports, renderToCanvas } from './chunk-6IITSBZU.mjs';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-EWIU6LHT.mjs';
|
|
4
4
|
import './chunk-XP5HYGXS.mjs';
|
|
5
5
|
import { global } from '@storybook/global';
|
|
6
6
|
import * as React from 'react';
|
package/dist/preset.d.ts
CHANGED
|
@@ -10,8 +10,9 @@ declare const previewAnnotations: PresetProperty<'previewAnnotations'>;
|
|
|
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
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* Storybook/internal/core-server doesn't have a peer dependency on react This will make
|
|
14
|
+
*
|
|
15
|
+
* @storybook/react projects work in Yarn PnP
|
|
15
16
|
*/
|
|
16
17
|
declare const resolvedReact: (existing: any) => Promise<any>;
|
|
17
18
|
|
package/dist/preview.d.ts
CHANGED
|
@@ -191,9 +191,9 @@ interface ReactMeta<Context extends {
|
|
|
191
191
|
story<TInput extends StoryAnnotations<ReactRenderer, Context['args']> & {
|
|
192
192
|
render: () => ReactRenderer['storyResult'];
|
|
193
193
|
}>(story: TInput): ReactStory;
|
|
194
|
-
story<
|
|
194
|
+
story<TInput extends Simplify<StoryAnnotations<ReactRenderer, AddMocks<Context['args'], MetaInput['args']>, SetOptional<Context['args'], keyof Context['args'] & keyof MetaInput['args']>>>>(story: TInput): ReactStory;
|
|
195
195
|
}
|
|
196
196
|
interface ReactStory extends Story<ReactRenderer> {
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
export { ReactPreview, __definePreview };
|
|
199
|
+
export { ReactPreview, ReactStory, __definePreview };
|
package/dist/preview.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.2",
|
|
4
4
|
"description": "Storybook React renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -70,15 +70,11 @@
|
|
|
70
70
|
"prep": "jiti ../../../scripts/prepare/bundle.ts"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@storybook/components": "9.0.0-alpha.1",
|
|
74
73
|
"@storybook/global": "^5.0.0",
|
|
75
|
-
"@storybook/
|
|
76
|
-
"@storybook/preview-api": "9.0.0-alpha.1",
|
|
77
|
-
"@storybook/react-dom-shim": "9.0.0-alpha.1",
|
|
78
|
-
"@storybook/theming": "9.0.0-alpha.1"
|
|
74
|
+
"@storybook/react-dom-shim": "9.0.0-alpha.2"
|
|
79
75
|
},
|
|
80
76
|
"devDependencies": {
|
|
81
|
-
"@storybook/test": "9.0.0-alpha.
|
|
77
|
+
"@storybook/test": "9.0.0-alpha.2",
|
|
82
78
|
"@types/babel-plugin-react-docgen": "^4.2.3",
|
|
83
79
|
"@types/escodegen": "^0.0.6",
|
|
84
80
|
"@types/estree": "^0.0.51",
|
|
@@ -100,11 +96,11 @@
|
|
|
100
96
|
"type-fest": "~2.19"
|
|
101
97
|
},
|
|
102
98
|
"peerDependencies": {
|
|
103
|
-
"@storybook/test": "9.0.0-alpha.
|
|
99
|
+
"@storybook/test": "9.0.0-alpha.2",
|
|
104
100
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
|
|
105
101
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
|
|
106
|
-
"storybook": "^9.0.0-alpha.
|
|
107
|
-
"typescript": ">= 4.
|
|
102
|
+
"storybook": "^9.0.0-alpha.2",
|
|
103
|
+
"typescript": ">= 4.9.x"
|
|
108
104
|
},
|
|
109
105
|
"peerDependenciesMeta": {
|
|
110
106
|
"@storybook/test": {
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { fn } from '@storybook/test';
|
|
3
|
-
|
|
4
|
-
import { Button } from './Button';
|
|
5
|
-
|
|
6
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
7
|
-
const meta: Meta<typeof Button> = {
|
|
8
|
-
title: 'Example/Button',
|
|
9
|
-
component: Button,
|
|
10
|
-
parameters: {
|
|
11
|
-
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
12
|
-
layout: 'centered',
|
|
13
|
-
},
|
|
14
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
15
|
-
tags: ['autodocs'],
|
|
16
|
-
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
17
|
-
argTypes: {
|
|
18
|
-
backgroundColor: { control: 'color' },
|
|
19
|
-
},
|
|
20
|
-
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
|
21
|
-
args: { onClick: fn() },
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default meta;
|
|
25
|
-
type Story = StoryObj<typeof Button>;
|
|
26
|
-
|
|
27
|
-
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
28
|
-
export const Primary: Story = {
|
|
29
|
-
args: {
|
|
30
|
-
primary: true,
|
|
31
|
-
label: 'Button',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const Secondary: Story = {
|
|
36
|
-
args: {
|
|
37
|
-
label: 'Button',
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const Large: Story = {
|
|
42
|
-
args: {
|
|
43
|
-
size: 'large',
|
|
44
|
-
label: 'Button',
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const Small: Story = {
|
|
49
|
-
args: {
|
|
50
|
-
size: 'small',
|
|
51
|
-
label: 'Button',
|
|
52
|
-
},
|
|
53
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import './button.css';
|
|
4
|
-
|
|
5
|
-
export interface ButtonProps {
|
|
6
|
-
/** Is this the principal call to action on the page? */
|
|
7
|
-
primary?: boolean;
|
|
8
|
-
/** What background color to use */
|
|
9
|
-
backgroundColor?: string;
|
|
10
|
-
/** How large should the button be? */
|
|
11
|
-
size?: 'small' | 'medium' | 'large';
|
|
12
|
-
/** Button contents */
|
|
13
|
-
label: string;
|
|
14
|
-
/** Optional click handler */
|
|
15
|
-
onClick?: () => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Primary UI component for user interaction */
|
|
19
|
-
export const Button = ({
|
|
20
|
-
primary = false,
|
|
21
|
-
size = 'medium',
|
|
22
|
-
backgroundColor,
|
|
23
|
-
label,
|
|
24
|
-
...props
|
|
25
|
-
}: ButtonProps) => {
|
|
26
|
-
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
27
|
-
return (
|
|
28
|
-
<button
|
|
29
|
-
type="button"
|
|
30
|
-
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
31
|
-
style={{ backgroundColor }}
|
|
32
|
-
{...props}
|
|
33
|
-
>
|
|
34
|
-
{label}
|
|
35
|
-
</button>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { fn } from '@storybook/test';
|
|
3
|
-
|
|
4
|
-
import { Header } from './Header';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Header> = {
|
|
7
|
-
title: 'Example/Header',
|
|
8
|
-
component: Header,
|
|
9
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
10
|
-
tags: ['autodocs'],
|
|
11
|
-
parameters: {
|
|
12
|
-
// More on Story layout: https://storybook.js.org/docs/configure/story-layout
|
|
13
|
-
layout: 'fullscreen',
|
|
14
|
-
},
|
|
15
|
-
args: {
|
|
16
|
-
onLogin: fn(),
|
|
17
|
-
onLogout: fn(),
|
|
18
|
-
onCreateAccount: fn(),
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default meta;
|
|
23
|
-
type Story = StoryObj<typeof Header>;
|
|
24
|
-
|
|
25
|
-
export const LoggedIn: Story = {
|
|
26
|
-
args: {
|
|
27
|
-
user: {
|
|
28
|
-
name: 'Jane Doe',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const LoggedOut: Story = {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Button } from './Button';
|
|
4
|
-
import './header.css';
|
|
5
|
-
|
|
6
|
-
type User = {
|
|
7
|
-
name: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export interface HeaderProps {
|
|
11
|
-
user?: User;
|
|
12
|
-
onLogin?: () => void;
|
|
13
|
-
onLogout?: () => void;
|
|
14
|
-
onCreateAccount?: () => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => (
|
|
18
|
-
<header>
|
|
19
|
-
<div className="storybook-header">
|
|
20
|
-
<div>
|
|
21
|
-
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
|
22
|
-
<g fill="none" fillRule="evenodd">
|
|
23
|
-
<path
|
|
24
|
-
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
|
25
|
-
fill="#FFF"
|
|
26
|
-
/>
|
|
27
|
-
<path
|
|
28
|
-
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
|
29
|
-
fill="#555AB9"
|
|
30
|
-
/>
|
|
31
|
-
<path
|
|
32
|
-
d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
|
|
33
|
-
fill="#91BAF8"
|
|
34
|
-
/>
|
|
35
|
-
</g>
|
|
36
|
-
</svg>
|
|
37
|
-
<h1>Acme</h1>
|
|
38
|
-
</div>
|
|
39
|
-
<div>
|
|
40
|
-
{user ? (
|
|
41
|
-
<>
|
|
42
|
-
<span className="welcome">
|
|
43
|
-
Welcome, <b>{user.name}</b>!
|
|
44
|
-
</span>
|
|
45
|
-
<Button size="small" onClick={onLogout} label="Log out" />
|
|
46
|
-
</>
|
|
47
|
-
) : (
|
|
48
|
-
<>
|
|
49
|
-
<Button size="small" onClick={onLogin} label="Log in" />
|
|
50
|
-
<Button primary size="small" onClick={onCreateAccount} label="Sign up" />
|
|
51
|
-
</>
|
|
52
|
-
)}
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
</header>
|
|
56
|
-
);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { expect, userEvent, within } from '@storybook/test';
|
|
3
|
-
|
|
4
|
-
import { Page } from './Page';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Page> = {
|
|
7
|
-
title: 'Example/Page',
|
|
8
|
-
component: Page,
|
|
9
|
-
parameters: {
|
|
10
|
-
// More on Story layout: https://storybook.js.org/docs/configure/story-layout
|
|
11
|
-
layout: 'fullscreen',
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default meta;
|
|
16
|
-
type Story = StoryObj<typeof Page>;
|
|
17
|
-
|
|
18
|
-
export const LoggedOut: Story = {};
|
|
19
|
-
|
|
20
|
-
// More on component testing: https://storybook.js.org/docs/writing-tests/component-testing
|
|
21
|
-
export const LoggedIn: Story = {
|
|
22
|
-
play: async ({ canvasElement }) => {
|
|
23
|
-
const canvas = within(canvasElement);
|
|
24
|
-
const loginButton = canvas.getByRole('button', { name: /Log in/i });
|
|
25
|
-
await expect(loginButton).toBeInTheDocument();
|
|
26
|
-
await userEvent.click(loginButton);
|
|
27
|
-
await expect(loginButton).not.toBeInTheDocument();
|
|
28
|
-
|
|
29
|
-
const logoutButton = canvas.getByRole('button', { name: /Log out/i });
|
|
30
|
-
await expect(logoutButton).toBeInTheDocument();
|
|
31
|
-
},
|
|
32
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Header } from './Header';
|
|
4
|
-
import './page.css';
|
|
5
|
-
|
|
6
|
-
type User = {
|
|
7
|
-
name: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const Page: React.FC = () => {
|
|
11
|
-
const [user, setUser] = React.useState<User>();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<article>
|
|
15
|
-
<Header
|
|
16
|
-
user={user}
|
|
17
|
-
onLogin={() => setUser({ name: 'Jane Doe' })}
|
|
18
|
-
onLogout={() => setUser(undefined)}
|
|
19
|
-
onCreateAccount={() => setUser({ name: 'Jane Doe' })}
|
|
20
|
-
/>
|
|
21
|
-
|
|
22
|
-
<section className="storybook-page">
|
|
23
|
-
<h2>Pages in Storybook</h2>
|
|
24
|
-
<p>
|
|
25
|
-
We recommend building UIs with a{' '}
|
|
26
|
-
<a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
|
|
27
|
-
<strong>component-driven</strong>
|
|
28
|
-
</a>{' '}
|
|
29
|
-
process starting with atomic components and ending with pages.
|
|
30
|
-
</p>
|
|
31
|
-
<p>
|
|
32
|
-
Render pages with mock data. This makes it easy to build and review page states without
|
|
33
|
-
needing to navigate to them in your app. Here are some handy patterns for managing page
|
|
34
|
-
data in Storybook:
|
|
35
|
-
</p>
|
|
36
|
-
<ul>
|
|
37
|
-
<li>
|
|
38
|
-
Use a higher-level connected component. Storybook helps you compose such data from the
|
|
39
|
-
"args" of child component stories
|
|
40
|
-
</li>
|
|
41
|
-
<li>
|
|
42
|
-
Assemble data in the page component from your services. You can mock these services out
|
|
43
|
-
using Storybook.
|
|
44
|
-
</li>
|
|
45
|
-
</ul>
|
|
46
|
-
<p>
|
|
47
|
-
Get a guided tutorial on component-driven development at{' '}
|
|
48
|
-
<a href="renderers/react/template/cli/ts/Page" target="_blank" rel="noopener noreferrer">
|
|
49
|
-
Storybook tutorials
|
|
50
|
-
</a>
|
|
51
|
-
. Read more in the{' '}
|
|
52
|
-
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">
|
|
53
|
-
docs
|
|
54
|
-
</a>
|
|
55
|
-
.
|
|
56
|
-
</p>
|
|
57
|
-
<div className="tip-wrapper">
|
|
58
|
-
<span className="tip">Tip</span> Adjust the width of the canvas with the{' '}
|
|
59
|
-
<svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
|
60
|
-
<g fill="none" fillRule="evenodd">
|
|
61
|
-
<path
|
|
62
|
-
d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0 010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z"
|
|
63
|
-
id="a"
|
|
64
|
-
fill="#999"
|
|
65
|
-
/>
|
|
66
|
-
</g>
|
|
67
|
-
</svg>
|
|
68
|
-
Viewports addon in the toolbar
|
|
69
|
-
</div>
|
|
70
|
-
</section>
|
|
71
|
-
</article>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
File without changes
|