@storybook/react 7.0.0-alpha.45 → 7.0.0-alpha.47
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-UWO3SUKR.mjs → chunk-Y6TTZ4RO.mjs} +1 -1
- package/dist/config.js +3 -3
- package/dist/config.mjs +3 -3
- package/dist/index.mjs +1 -1
- package/package.json +9 -8
- package/template/cli/.eslintrc.json +5 -0
- package/template/cli/js/Button.jsx +50 -0
- package/template/cli/js/Button.stories.js +39 -0
- package/template/cli/js/Header.jsx +59 -0
- package/template/cli/js/Header.stories.js +20 -0
- package/template/cli/js/Page.jsx +69 -0
- package/template/cli/js/Page.stories.js +25 -0
- package/template/cli/ts/Button.stories.ts +45 -0
- package/template/cli/ts/Button.tsx +48 -0
- package/template/cli/ts/Header.stories.ts +24 -0
- package/template/cli/ts/Header.tsx +56 -0
- package/template/cli/ts/Page.stories.ts +29 -0
- package/template/cli/ts/Page.tsx +73 -0
- package/template/components/Button.jsx +13 -0
- package/template/components/Form.jsx +36 -0
- package/template/components/Html.jsx +9 -0
- package/template/components/Pre.jsx +20 -0
- package/template/components/index.js +9 -0
- package/template/stories/decorators.stories.tsx +28 -0
- package/template/stories/docgen-components/10017-ts-union/argTypes.snapshot +36 -0
- package/template/stories/docgen-components/10017-ts-union/docgen.snapshot +34 -0
- package/template/stories/docgen-components/10017-ts-union/input.tsx +12 -0
- package/template/stories/docgen-components/10017-ts-union/properties.snapshot +32 -0
- package/template/stories/docgen-components/10278-ts-multiple-components/argTypes.snapshot +26 -0
- package/template/stories/docgen-components/10278-ts-multiple-components/docgen.snapshot +49 -0
- package/template/stories/docgen-components/10278-ts-multiple-components/input.tsx +27 -0
- package/template/stories/docgen-components/10278-ts-multiple-components/properties.snapshot +22 -0
- package/template/stories/docgen-components/8140-js-prop-types-oneof/argTypes.snapshot +127 -0
- package/template/stories/docgen-components/8140-js-prop-types-oneof/docgen.snapshot +97 -0
- package/template/stories/docgen-components/8140-js-prop-types-oneof/input.jsx +27 -0
- package/template/stories/docgen-components/8140-js-prop-types-oneof/properties.snapshot +89 -0
- package/template/stories/docgen-components/8143-ts-imported-types/argTypes.snapshot +27 -0
- package/template/stories/docgen-components/8143-ts-imported-types/docgen.snapshot +22 -0
- package/template/stories/docgen-components/8143-ts-imported-types/input.tsx +10 -0
- package/template/stories/docgen-components/8143-ts-imported-types/properties.snapshot +23 -0
- package/template/stories/docgen-components/8143-ts-imported-types/types.ts +3 -0
- package/template/stories/docgen-components/8143-ts-react-fc-generics/argTypes.snapshot +27 -0
- package/template/stories/docgen-components/8143-ts-react-fc-generics/docgen.snapshot +24 -0
- package/template/stories/docgen-components/8143-ts-react-fc-generics/input.tsx +10 -0
- package/template/stories/docgen-components/8143-ts-react-fc-generics/properties.snapshot +21 -0
- package/template/stories/docgen-components/8428-js-static-prop-types/argTypes.snapshot +25 -0
- package/template/stories/docgen-components/8428-js-static-prop-types/docgen.snapshot +37 -0
- package/template/stories/docgen-components/8428-js-static-prop-types/input.jsx +20 -0
- package/template/stories/docgen-components/8428-js-static-prop-types/properties.snapshot +21 -0
- package/template/stories/docgen-components/8740-ts-multi-props/argTypes.snapshot +27 -0
- package/template/stories/docgen-components/8740-ts-multi-props/docgen.snapshot +49 -0
- package/template/stories/docgen-components/8740-ts-multi-props/input.tsx +23 -0
- package/template/stories/docgen-components/8740-ts-multi-props/properties.snapshot +21 -0
- package/template/stories/docgen-components/8894-9511-ts-forward-ref/argTypes.snapshot +48 -0
- package/template/stories/docgen-components/8894-9511-ts-forward-ref/docgen.snapshot +39 -0
- package/template/stories/docgen-components/8894-9511-ts-forward-ref/input.tsx +31 -0
- package/template/stories/docgen-components/8894-9511-ts-forward-ref/properties.snapshot +34 -0
- package/template/stories/docgen-components/9023-js-hoc/argTypes.snapshot +89 -0
- package/template/stories/docgen-components/9023-js-hoc/docgen.snapshot +84 -0
- package/template/stories/docgen-components/9023-js-hoc/input.jsx +40 -0
- package/template/stories/docgen-components/9023-js-hoc/properties.snapshot +67 -0
- package/template/stories/docgen-components/9399-js-proptypes-shape/argTypes.snapshot +39 -0
- package/template/stories/docgen-components/9399-js-proptypes-shape/docgen.snapshot +48 -0
- package/template/stories/docgen-components/9399-js-proptypes-shape/input.jsx +16 -0
- package/template/stories/docgen-components/9399-js-proptypes-shape/properties.snapshot +35 -0
- package/template/stories/docgen-components/9465-ts-type-props/argTypes.snapshot +28 -0
- package/template/stories/docgen-components/9465-ts-type-props/docgen.snapshot +33 -0
- package/template/stories/docgen-components/9465-ts-type-props/input.tsx +12 -0
- package/template/stories/docgen-components/9465-ts-type-props/properties.snapshot +24 -0
- package/template/stories/docgen-components/9493-ts-display-name/argTypes.snapshot +62 -0
- package/template/stories/docgen-components/9493-ts-display-name/docgen.snapshot +50 -0
- package/template/stories/docgen-components/9493-ts-display-name/input.tsx +30 -0
- package/template/stories/docgen-components/9493-ts-display-name/properties.snapshot +52 -0
- package/template/stories/docgen-components/9556-ts-react-default-exports/argTypes.snapshot +28 -0
- package/template/stories/docgen-components/9556-ts-react-default-exports/docgen.snapshot +32 -0
- package/template/stories/docgen-components/9556-ts-react-default-exports/input.tsx +12 -0
- package/template/stories/docgen-components/9556-ts-react-default-exports/properties.snapshot +24 -0
- package/template/stories/docgen-components/9575-ts-camel-case/argTypes.snapshot +28 -0
- package/template/stories/docgen-components/9575-ts-camel-case/docgen.snapshot +38 -0
- package/template/stories/docgen-components/9575-ts-camel-case/input.tsx +26 -0
- package/template/stories/docgen-components/9575-ts-camel-case/properties.snapshot +24 -0
- package/template/stories/docgen-components/9586-js-react-memo/argTypes.snapshot +41 -0
- package/template/stories/docgen-components/9586-js-react-memo/docgen.snapshot +42 -0
- package/template/stories/docgen-components/9586-js-react-memo/input.jsx +15 -0
- package/template/stories/docgen-components/9586-js-react-memo/properties.snapshot +34 -0
- package/template/stories/docgen-components/9591-ts-import-types/Bar.tsx +3 -0
- package/template/stories/docgen-components/9591-ts-import-types/argTypes.snapshot +25 -0
- package/template/stories/docgen-components/9591-ts-import-types/docgen.snapshot +21 -0
- package/template/stories/docgen-components/9591-ts-import-types/input.tsx +10 -0
- package/template/stories/docgen-components/9591-ts-import-types/properties.snapshot +21 -0
- package/template/stories/docgen-components/9626-js-default-values/argTypes.snapshot +27 -0
- package/template/stories/docgen-components/9626-js-default-values/docgen.snapshot +25 -0
- package/template/stories/docgen-components/9626-js-default-values/input.jsx +5 -0
- package/template/stories/docgen-components/9626-js-default-values/properties.snapshot +21 -0
- package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/argTypes.snapshot +42 -0
- package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/docgen.snapshot +36 -0
- package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/input.jsx +13 -0
- package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/properties.snapshot +35 -0
- package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/argTypes.snapshot +53 -0
- package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/docgen.snapshot +45 -0
- package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/input.tsx +18 -0
- package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/properties.snapshot +43 -0
- package/template/stories/docgen-components/9764-ts-extend-props/argTypes.snapshot +72 -0
- package/template/stories/docgen-components/9764-ts-extend-props/docgen.snapshot +41 -0
- package/template/stories/docgen-components/9764-ts-extend-props/input.tsx +17 -0
- package/template/stories/docgen-components/9764-ts-extend-props/properties.snapshot +56 -0
- package/template/stories/docgen-components/9827-ts-default-values/argTypes.snapshot +72 -0
- package/template/stories/docgen-components/9827-ts-default-values/docgen.snapshot +52 -0
- package/template/stories/docgen-components/9827-ts-default-values/input.tsx +17 -0
- package/template/stories/docgen-components/9827-ts-default-values/properties.snapshot +56 -0
- package/template/stories/docgen-components/9832-ts-enum-export/argTypes.snapshot +3 -0
- package/template/stories/docgen-components/9832-ts-enum-export/docgen.snapshot +16 -0
- package/template/stories/docgen-components/9832-ts-enum-export/input.tsx +8 -0
- package/template/stories/docgen-components/9832-ts-enum-export/properties.snapshot +7 -0
- package/template/stories/docgen-components/9922-ts-component-props/argTypes.snapshot +25 -0
- package/template/stories/docgen-components/9922-ts-component-props/docgen.snapshot +35 -0
- package/template/stories/docgen-components/9922-ts-component-props/input.tsx +24 -0
- package/template/stories/docgen-components/9922-ts-component-props/properties.snapshot +21 -0
- package/template/stories/docgen-components/imported.js +1 -0
- package/template/stories/docgen-components/js-class-component/argTypes.snapshot +386 -0
- package/template/stories/docgen-components/js-class-component/docgen.snapshot +252 -0
- package/template/stories/docgen-components/js-class-component/input.jsx +57 -0
- package/template/stories/docgen-components/js-class-component/properties.snapshot +286 -0
- package/template/stories/docgen-components/js-function-component/argTypes.snapshot +386 -0
- package/template/stories/docgen-components/js-function-component/docgen.snapshot +236 -0
- package/template/stories/docgen-components/js-function-component/input.jsx +50 -0
- package/template/stories/docgen-components/js-function-component/properties.snapshot +286 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults/argTypes.snapshot +386 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults/docgen.snapshot +247 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults/input.jsx +65 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults/properties.snapshot +286 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/argTypes.snapshot +237 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/docgen.snapshot +124 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/input.jsx +41 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/properties.snapshot +151 -0
- package/template/stories/docgen-components/js-proptypes/docgen.snapshot +1770 -0
- package/template/stories/docgen-components/js-proptypes/ext.js +13 -0
- package/template/stories/docgen-components/js-proptypes/input.jsx +497 -0
- package/template/stories/docgen-components/jsdoc/argTypes.snapshot +969 -0
- package/template/stories/docgen-components/jsdoc/docgen.snapshot +548 -0
- package/template/stories/docgen-components/jsdoc/input.jsx +231 -0
- package/template/stories/docgen-components/jsdoc/properties.snapshot +857 -0
- package/template/stories/docgen-components/ts-function-component/argTypes.snapshot +396 -0
- package/template/stories/docgen-components/ts-function-component/docgen.snapshot +241 -0
- package/template/stories/docgen-components/ts-function-component/input.tsx +52 -0
- package/template/stories/docgen-components/ts-function-component/properties.snapshot +296 -0
- package/template/stories/docgen-components/ts-function-component-inline-defaults/argTypes.snapshot +279 -0
- package/template/stories/docgen-components/ts-function-component-inline-defaults/docgen.snapshot +151 -0
- package/template/stories/docgen-components/ts-function-component-inline-defaults/input.tsx +80 -0
- package/template/stories/docgen-components/ts-function-component-inline-defaults/properties.snapshot +177 -0
- package/template/stories/docgen-components/ts-html/argTypes.snapshot +3 -0
- package/template/stories/docgen-components/ts-html/docgen.snapshot +12 -0
- package/template/stories/docgen-components/ts-html/input.tsx +12 -0
- package/template/stories/docgen-components/ts-html/properties.snapshot +7 -0
- package/template/stories/docgen-components/ts-jsdoc/argTypes.snapshot +3 -0
- package/template/stories/docgen-components/ts-jsdoc/docgen.snapshot +21 -0
- package/template/stories/docgen-components/ts-jsdoc/input.tsx +27 -0
- package/template/stories/docgen-components/ts-jsdoc/properties.snapshot +7 -0
- package/template/stories/docgen-components/ts-types/argTypes.snapshot +656 -0
- package/template/stories/docgen-components/ts-types/docgen.snapshot +317 -0
- package/template/stories/docgen-components/ts-types/input.tsx +130 -0
- package/template/stories/docgen-components/ts-types/properties.snapshot +410 -0
- package/template/stories/errors.stories.tsx +37 -0
- package/template/stories/hooks.stories.tsx +17 -0
- package/template/stories/js-argtypes.stories.jsx +91 -0
- package/template/stories/react-mdx.stories.mdx +26 -0
- package/template/stories/ts-argtypes.stories.tsx +81 -0
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
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="wrapper">
|
|
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
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { within, userEvent } from '@storybook/testing-library';
|
|
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/react/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 interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing
|
|
21
|
+
export const LoggedIn: Story = {
|
|
22
|
+
play: async ({ canvasElement }) => {
|
|
23
|
+
const canvas = within(canvasElement);
|
|
24
|
+
const loginButton = await canvas.getByRole('button', {
|
|
25
|
+
name: /Log in/i,
|
|
26
|
+
});
|
|
27
|
+
await userEvent.click(loginButton);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
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.VFC = () => {
|
|
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>
|
|
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="https://storybook.js.org/tutorials/" 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
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
export const Button = ({ onClick, label }) => (
|
|
5
|
+
<button type="button" onClick={onClick}>
|
|
6
|
+
{label}
|
|
7
|
+
</button>
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
Button.propTypes = {
|
|
11
|
+
onClick: PropTypes.func.isRequired,
|
|
12
|
+
label: PropTypes.string.isRequired,
|
|
13
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
export const Form = ({ onSuccess }) => {
|
|
5
|
+
const [value, setValue] = useState('');
|
|
6
|
+
const [complete, setComplete] = useState(false);
|
|
7
|
+
|
|
8
|
+
function onSubmit(event) {
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
onSuccess(value);
|
|
11
|
+
|
|
12
|
+
setTimeout(() => setComplete(true), 500);
|
|
13
|
+
setTimeout(() => setComplete(false), 1500);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<form id="interaction-test-form" onSubmit={onSubmit}>
|
|
18
|
+
<label>
|
|
19
|
+
Enter Value
|
|
20
|
+
<input
|
|
21
|
+
type="text"
|
|
22
|
+
data-testid="value"
|
|
23
|
+
value={value}
|
|
24
|
+
required
|
|
25
|
+
onChange={(event) => setValue(event.target.value)}
|
|
26
|
+
/>
|
|
27
|
+
</label>
|
|
28
|
+
<button type="submit">Submit</button>
|
|
29
|
+
{complete && <p>Completed!!</p>}
|
|
30
|
+
</form>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
Form.propTypes = {
|
|
35
|
+
onSuccess: PropTypes.func.isRequired,
|
|
36
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line react/no-danger
|
|
5
|
+
export const Html = ({ content }) => <div dangerouslySetInnerHTML={{ __html: content }} />;
|
|
6
|
+
|
|
7
|
+
Html.propTypes = {
|
|
8
|
+
content: PropTypes.string.isRequired,
|
|
9
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
export const Pre = ({ style, object, text }) => (
|
|
5
|
+
<pre style={style} data-testid="pre">
|
|
6
|
+
{object ? JSON.stringify(object, null, 2) : text}
|
|
7
|
+
</pre>
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
Pre.propTypes = {
|
|
11
|
+
style: PropTypes.shape({}),
|
|
12
|
+
object: PropTypes.shape({}),
|
|
13
|
+
text: PropTypes.string,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
Pre.defaultProps = {
|
|
17
|
+
style: {},
|
|
18
|
+
object: null,
|
|
19
|
+
text: '',
|
|
20
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import globalThis from 'global';
|
|
2
|
+
|
|
3
|
+
import { Button } from './Button.jsx';
|
|
4
|
+
import { Pre } from './Pre.jsx';
|
|
5
|
+
import { Form } from './Form.jsx';
|
|
6
|
+
import { Html } from './Html.jsx';
|
|
7
|
+
|
|
8
|
+
globalThis.Components = { Button, Pre, Form, Html };
|
|
9
|
+
globalThis.storybookRenderer = 'react';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
4
|
+
|
|
5
|
+
const Component: FC = () => <p>Story</p>;
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
component: Component,
|
|
9
|
+
decorators: [
|
|
10
|
+
(Story) => (
|
|
11
|
+
<>
|
|
12
|
+
<p>Component Decorator</p>
|
|
13
|
+
<Story />
|
|
14
|
+
</>
|
|
15
|
+
),
|
|
16
|
+
],
|
|
17
|
+
} as Meta<typeof Component>;
|
|
18
|
+
|
|
19
|
+
export const All: StoryObj<typeof Component> = {
|
|
20
|
+
decorators: [
|
|
21
|
+
(Story) => (
|
|
22
|
+
<>
|
|
23
|
+
<p>Local Decorator</p>
|
|
24
|
+
<Story />
|
|
25
|
+
</>
|
|
26
|
+
),
|
|
27
|
+
],
|
|
28
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`react component properties 10017-ts-union 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"icon": Object {
|
|
6
|
+
"control": Object {
|
|
7
|
+
"type": "object",
|
|
8
|
+
},
|
|
9
|
+
"description": "specify icon=\\"search\\" or icon={IconComponent}",
|
|
10
|
+
"name": "icon",
|
|
11
|
+
"table": Object {
|
|
12
|
+
"defaultValue": null,
|
|
13
|
+
"jsDocTags": undefined,
|
|
14
|
+
"type": Object {
|
|
15
|
+
"detail": undefined,
|
|
16
|
+
"summary": "union",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
"type": Object {
|
|
20
|
+
"name": "union",
|
|
21
|
+
"raw": "React.ReactNode | string",
|
|
22
|
+
"required": true,
|
|
23
|
+
"value": Array [
|
|
24
|
+
Object {
|
|
25
|
+
"name": "other",
|
|
26
|
+
"raw": "React.ReactNode",
|
|
27
|
+
"value": "ReactReactNode",
|
|
28
|
+
},
|
|
29
|
+
Object {
|
|
30
|
+
"name": "string",
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`react component properties 10017-ts-union 1`] = `
|
|
4
|
+
"import React from 'react';
|
|
5
|
+
const Avatar = ({
|
|
6
|
+
icon
|
|
7
|
+
}) => {
|
|
8
|
+
return /*#__PURE__*/React.createElement(\\"div\\", {
|
|
9
|
+
className: \\"hello\\"
|
|
10
|
+
}, \\"Hello Component \\", icon);
|
|
11
|
+
};
|
|
12
|
+
export const component = Avatar;
|
|
13
|
+
Avatar.__docgenInfo = {
|
|
14
|
+
\\"description\\": \\"\\",
|
|
15
|
+
\\"methods\\": [],
|
|
16
|
+
\\"displayName\\": \\"Avatar\\",
|
|
17
|
+
\\"props\\": {
|
|
18
|
+
\\"icon\\": {
|
|
19
|
+
\\"required\\": true,
|
|
20
|
+
\\"tsType\\": {
|
|
21
|
+
\\"name\\": \\"union\\",
|
|
22
|
+
\\"raw\\": \\"React.ReactNode | string\\",
|
|
23
|
+
\\"elements\\": [{
|
|
24
|
+
\\"name\\": \\"ReactReactNode\\",
|
|
25
|
+
\\"raw\\": \\"React.ReactNode\\"
|
|
26
|
+
}, {
|
|
27
|
+
\\"name\\": \\"string\\"
|
|
28
|
+
}]
|
|
29
|
+
},
|
|
30
|
+
\\"description\\": \\"specify icon=\\\\\\"search\\\\\\" or icon={IconComponent}\\"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};"
|
|
34
|
+
`;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface AvatarProps {
|
|
4
|
+
/** specify icon="search" or icon={IconComponent} */
|
|
5
|
+
icon: React.ReactNode | string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Avatar = ({ icon }: AvatarProps) => {
|
|
9
|
+
return <div className="hello">Hello Component {icon}</div>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const component = Avatar;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`react component properties 10017-ts-union 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"rows": Array [
|
|
6
|
+
Object {
|
|
7
|
+
"defaultValue": null,
|
|
8
|
+
"description": "specify icon=\\"search\\" or icon={IconComponent}",
|
|
9
|
+
"name": "icon",
|
|
10
|
+
"required": true,
|
|
11
|
+
"sbType": Object {
|
|
12
|
+
"name": "union",
|
|
13
|
+
"raw": "React.ReactNode | string",
|
|
14
|
+
"value": Array [
|
|
15
|
+
Object {
|
|
16
|
+
"name": "other",
|
|
17
|
+
"raw": "React.ReactNode",
|
|
18
|
+
"value": "ReactReactNode",
|
|
19
|
+
},
|
|
20
|
+
Object {
|
|
21
|
+
"name": "string",
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
"type": Object {
|
|
26
|
+
"detail": undefined,
|
|
27
|
+
"summary": "union",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`react component properties 10278-ts-multiple-components 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"aProperty": Object {
|
|
6
|
+
"control": Object {
|
|
7
|
+
"type": "object",
|
|
8
|
+
},
|
|
9
|
+
"description": "",
|
|
10
|
+
"name": "aProperty",
|
|
11
|
+
"table": Object {
|
|
12
|
+
"defaultValue": null,
|
|
13
|
+
"jsDocTags": undefined,
|
|
14
|
+
"type": Object {
|
|
15
|
+
"detail": undefined,
|
|
16
|
+
"summary": "any",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
"type": Object {
|
|
20
|
+
"name": "other",
|
|
21
|
+
"required": true,
|
|
22
|
+
"value": "any",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`react component properties 10278-ts-multiple-components 1`] = `
|
|
4
|
+
"/* eslint-disable react/destructuring-assignment */
|
|
5
|
+
import React from 'react';
|
|
6
|
+
/**
|
|
7
|
+
* A component
|
|
8
|
+
*/
|
|
9
|
+
const A = props => {
|
|
10
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, \\"Hi \\", props.aProperty);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* B component
|
|
15
|
+
*/
|
|
16
|
+
const B = props => {
|
|
17
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, \\"Hi \\", props.bProperty);
|
|
18
|
+
};
|
|
19
|
+
A.__docgenInfo = {
|
|
20
|
+
\\"description\\": \\"A component\\",
|
|
21
|
+
\\"methods\\": [],
|
|
22
|
+
\\"displayName\\": \\"A\\",
|
|
23
|
+
\\"props\\": {
|
|
24
|
+
\\"aProperty\\": {
|
|
25
|
+
\\"required\\": true,
|
|
26
|
+
\\"tsType\\": {
|
|
27
|
+
\\"name\\": \\"any\\"
|
|
28
|
+
},
|
|
29
|
+
\\"description\\": \\"\\"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
B.__docgenInfo = {
|
|
34
|
+
\\"description\\": \\"B component\\",
|
|
35
|
+
\\"methods\\": [],
|
|
36
|
+
\\"displayName\\": \\"B\\",
|
|
37
|
+
\\"props\\": {
|
|
38
|
+
\\"bProperty\\": {
|
|
39
|
+
\\"required\\": true,
|
|
40
|
+
\\"tsType\\": {
|
|
41
|
+
\\"name\\": \\"any\\"
|
|
42
|
+
},
|
|
43
|
+
\\"description\\": \\"\\"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export { A, B };
|
|
48
|
+
export const component = A;"
|
|
49
|
+
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-disable react/destructuring-assignment */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
interface IAProps {
|
|
5
|
+
aProperty: any;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface IBProps {
|
|
9
|
+
bProperty: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A component
|
|
14
|
+
*/
|
|
15
|
+
const A = (props: IAProps): JSX.Element => {
|
|
16
|
+
return <>Hi {props.aProperty}</>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* B component
|
|
21
|
+
*/
|
|
22
|
+
const B = (props: IBProps): JSX.Element => {
|
|
23
|
+
return <>Hi {props.bProperty}</>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { A, B };
|
|
27
|
+
export const component = A;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`react component properties 10278-ts-multiple-components 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"rows": Array [
|
|
6
|
+
Object {
|
|
7
|
+
"defaultValue": null,
|
|
8
|
+
"description": "",
|
|
9
|
+
"name": "aProperty",
|
|
10
|
+
"required": true,
|
|
11
|
+
"sbType": Object {
|
|
12
|
+
"name": "other",
|
|
13
|
+
"value": "any",
|
|
14
|
+
},
|
|
15
|
+
"type": Object {
|
|
16
|
+
"detail": undefined,
|
|
17
|
+
"summary": "any",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`react component properties 8140-js-prop-types-oneof 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"blank": Object {
|
|
6
|
+
"control": Object {
|
|
7
|
+
"type": "boolean",
|
|
8
|
+
},
|
|
9
|
+
"description": "No background or border if static alert",
|
|
10
|
+
"name": "blank",
|
|
11
|
+
"table": Object {
|
|
12
|
+
"defaultValue": null,
|
|
13
|
+
"jsDocTags": undefined,
|
|
14
|
+
"type": Object {
|
|
15
|
+
"detail": undefined,
|
|
16
|
+
"summary": "bool",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
"type": Object {
|
|
20
|
+
"name": "boolean",
|
|
21
|
+
"required": false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
"icon": Object {
|
|
25
|
+
"control": Object {
|
|
26
|
+
"type": "text",
|
|
27
|
+
},
|
|
28
|
+
"description": "Allows icon override, accepts material icon name",
|
|
29
|
+
"name": "icon",
|
|
30
|
+
"table": Object {
|
|
31
|
+
"defaultValue": null,
|
|
32
|
+
"jsDocTags": undefined,
|
|
33
|
+
"type": Object {
|
|
34
|
+
"detail": undefined,
|
|
35
|
+
"summary": "string",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
"type": Object {
|
|
39
|
+
"name": "string",
|
|
40
|
+
"required": false,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
"message": Object {
|
|
44
|
+
"control": Object {
|
|
45
|
+
"type": "text",
|
|
46
|
+
},
|
|
47
|
+
"description": "",
|
|
48
|
+
"name": "message",
|
|
49
|
+
"table": Object {
|
|
50
|
+
"defaultValue": null,
|
|
51
|
+
"jsDocTags": undefined,
|
|
52
|
+
"type": Object {
|
|
53
|
+
"detail": undefined,
|
|
54
|
+
"summary": "string",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
"type": Object {
|
|
58
|
+
"name": "string",
|
|
59
|
+
"required": true,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
"mode": Object {
|
|
63
|
+
"control": Object {
|
|
64
|
+
"type": "radio",
|
|
65
|
+
},
|
|
66
|
+
"description": "",
|
|
67
|
+
"name": "mode",
|
|
68
|
+
"options": Array [
|
|
69
|
+
"static",
|
|
70
|
+
"timed",
|
|
71
|
+
],
|
|
72
|
+
"table": Object {
|
|
73
|
+
"defaultValue": Object {
|
|
74
|
+
"detail": undefined,
|
|
75
|
+
"summary": "'static'",
|
|
76
|
+
},
|
|
77
|
+
"jsDocTags": undefined,
|
|
78
|
+
"type": Object {
|
|
79
|
+
"detail": undefined,
|
|
80
|
+
"summary": "'static' | 'timed'",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
"type": Object {
|
|
84
|
+
"name": "enum",
|
|
85
|
+
"required": false,
|
|
86
|
+
"value": Array [
|
|
87
|
+
"static",
|
|
88
|
+
"timed",
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
"type": Object {
|
|
93
|
+
"control": Object {
|
|
94
|
+
"type": "radio",
|
|
95
|
+
},
|
|
96
|
+
"description": "",
|
|
97
|
+
"name": "type",
|
|
98
|
+
"options": Array [
|
|
99
|
+
"success",
|
|
100
|
+
"warning",
|
|
101
|
+
"error",
|
|
102
|
+
"primary",
|
|
103
|
+
],
|
|
104
|
+
"table": Object {
|
|
105
|
+
"defaultValue": Object {
|
|
106
|
+
"detail": undefined,
|
|
107
|
+
"summary": "'warning'",
|
|
108
|
+
},
|
|
109
|
+
"jsDocTags": undefined,
|
|
110
|
+
"type": Object {
|
|
111
|
+
"detail": undefined,
|
|
112
|
+
"summary": "'success' | 'warning' | 'error' | 'primary'",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
"type": Object {
|
|
116
|
+
"name": "enum",
|
|
117
|
+
"required": false,
|
|
118
|
+
"value": Array [
|
|
119
|
+
"success",
|
|
120
|
+
"warning",
|
|
121
|
+
"error",
|
|
122
|
+
"primary",
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
}
|
|
127
|
+
`;
|