@storybook/svelte-vite 9.0.0-alpha.9 → 9.0.0-beta.0

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.
Files changed (47) hide show
  1. package/dist/preset.js +2 -10
  2. package/package.json +8 -8
  3. package/template/cli/{svelte-5-ts-3-8 → js}/Button.stories.svelte +1 -1
  4. package/template/cli/js/Button.svelte +11 -20
  5. package/template/cli/js/Header.svelte +12 -17
  6. package/template/cli/{svelte-5-js → js}/Page.stories.svelte +1 -1
  7. package/template/cli/js/Page.svelte +4 -4
  8. package/template/cli/{svelte-5-ts-4-9 → ts}/Button.stories.svelte +1 -1
  9. package/template/cli/{svelte-5-ts-3-8 → ts}/Button.svelte +8 -7
  10. package/template/cli/{svelte-5-ts-4-9 → ts}/Header.svelte +3 -3
  11. package/template/cli/{svelte-5-ts-4-9 → ts}/Page.stories.svelte +1 -1
  12. package/template/stories_svelte-vite-default-js/docgen/jsdoc.stories.js +17 -0
  13. package/template/stories_svelte-vite-default-js/docgen/jsdoc.svelte +92 -0
  14. package/template/stories_svelte-vite-default-ts/docgen/jsdoc.stories.js +17 -0
  15. package/template/stories_svelte-vite-default-ts/docgen/jsdoc.svelte +91 -0
  16. package/template/stories_svelte-vite-default-ts/docgen/ts-inline-prop-types.stories.ts +16 -0
  17. package/template/stories_svelte-vite-default-ts/docgen/ts-inline-prop-types.svelte +103 -0
  18. package/template/stories_svelte-vite-default-ts/docgen/ts-legacy.stories.ts +16 -0
  19. package/template/stories_svelte-vite-default-ts/docgen/ts-legacy.svelte +98 -0
  20. package/template/stories_svelte-vite-default-ts/docgen/ts-referenced-prop-types.stories.ts +16 -0
  21. package/template/stories_svelte-vite-default-ts/docgen/ts-referenced-prop-types.svelte +107 -0
  22. package/template/stories_svelte-vite-default-ts/docgen/ts.stories.ts +16 -0
  23. package/template/stories_svelte-vite-default-ts/docgen/ts.svelte +125 -0
  24. package/template/cli/js/Button.stories.js +0 -43
  25. package/template/cli/js/Header.stories.js +0 -22
  26. package/template/cli/js/Page.stories.js +0 -28
  27. package/template/cli/svelte-5-js/Button.stories.svelte +0 -31
  28. package/template/cli/svelte-5-js/Button.svelte +0 -26
  29. package/template/cli/svelte-5-js/Header.svelte +0 -47
  30. package/template/cli/svelte-5-js/Page.svelte +0 -70
  31. package/template/cli/svelte-5-ts-3-8/Header.svelte +0 -45
  32. package/template/cli/svelte-5-ts-3-8/Page.stories.svelte +0 -30
  33. package/template/cli/svelte-5-ts-4-9/Button.svelte +0 -29
  34. package/template/cli/svelte-5-ts-4-9/Header.stories.svelte +0 -26
  35. package/template/cli/svelte-5-ts-4-9/Page.svelte +0 -70
  36. package/template/cli/ts-4-9/Button.stories.ts +0 -48
  37. package/template/cli/ts-4-9/Button.svelte +0 -34
  38. package/template/cli/ts-4-9/Header.stories.ts +0 -27
  39. package/template/cli/ts-4-9/Header.svelte +0 -52
  40. package/template/cli/ts-4-9/Page.stories.ts +0 -33
  41. package/template/cli/ts-4-9/Page.svelte +0 -70
  42. package/template/stories_svelte-vite-default-ts/DocsTS.svelte +0 -97
  43. package/template/stories_svelte-vite-default-ts/docs-ts.stories.js +0 -10
  44. /package/template/cli/{svelte-5-js → js}/Header.stories.svelte +0 -0
  45. /package/template/cli/{svelte-5-ts-3-8 → ts}/Header.stories.svelte +0 -0
  46. /package/template/cli/{svelte-5-ts-3-8 → ts}/Page.svelte +0 -0
  47. /package/template/stories_svelte-vite-default-ts/{types.ts → docgen/types.ts} +0 -0
@@ -1,30 +0,0 @@
1
- <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import { expect, userEvent, waitFor, within } from '@storybook/test';
4
- import Page from './Page.svelte';
5
- import { fn } from 'storybook/test';
6
-
7
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
8
- const { Story } = defineMeta({
9
- title: 'Example/Page',
10
- component: Page,
11
- parameters: {
12
- // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
13
- layout: 'fullscreen',
14
- },
15
- });
16
- </script>
17
-
18
- <Story name="Logged In" play={async ({ canvasElement }) => {
19
- const canvas = within(canvasElement);
20
- const loginButton = canvas.getByRole('button', { name: /Log in/i });
21
- await expect(loginButton).toBeInTheDocument();
22
- await userEvent.click(loginButton);
23
- await waitFor(() => expect(loginButton).not.toBeInTheDocument());
24
-
25
- const logoutButton = canvas.getByRole('button', { name: /Log out/i });
26
- await expect(logoutButton).toBeInTheDocument();
27
- }}
28
- />
29
-
30
- <Story name="Logged Out" />
@@ -1,29 +0,0 @@
1
- <script lang="ts">
2
- import './button.css';
3
-
4
- interface Props {
5
- /** Is this the principal call to action on the page? */
6
- primary?: boolean;
7
- /** What background color to use */
8
- backgroundColor?: string;
9
- /** How large should the button be? */
10
- size?: 'small' | 'medium' | 'large';
11
- /** Button contents */
12
- label: string;
13
- /** The onclick event handler */
14
- onClick?: () => void;
15
- }
16
-
17
- const { primary = false, backgroundColor, size = 'medium', label, onClick }: Props = $props();
18
- </script>
19
-
20
- <button
21
- type="button"
22
- class={['storybook-button', `storybook-button--${size}`].join(' ')}
23
- class:storybook-button--primary={primary}
24
- class:storybook-button--secondary={!primary}
25
- style:background-color={backgroundColor}
26
- onclick={onClick}
27
- >
28
- {label}
29
- </button>
@@ -1,26 +0,0 @@
1
- <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import Header from './Header.svelte';
4
- import { fn } from 'storybook/test';
5
-
6
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
7
- const { Story } = defineMeta({
8
- title: 'Example/Header',
9
- component: Header,
10
- // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
11
- tags: ['autodocs'],
12
- parameters: {
13
- // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
14
- layout: 'fullscreen',
15
- },
16
- args: {
17
- onLogin: fn(),
18
- onLogout: fn(),
19
- onCreateAccount: fn(),
20
- }
21
- });
22
- </script>
23
-
24
- <Story name="Logged In" args={{ user: { name: 'Jane Doe' } }} />
25
-
26
- <Story name="Logged Out" />
@@ -1,70 +0,0 @@
1
- <script lang="ts">
2
- import './page.css';
3
- import Header from './Header.svelte';
4
-
5
- let user = $state<{ name: string }>();
6
- </script>
7
-
8
- <article>
9
- <Header
10
- {user}
11
- onLogin={() => (user = { name: 'Jane Doe' })}
12
- onLogout={() => (user = undefined)}
13
- onCreateAccount={() => (user = { name: 'Jane Doe' })}
14
- />
15
-
16
- <section class="storybook-page">
17
- <h2>Pages in Storybook</h2>
18
- <p>
19
- We recommend building UIs with a
20
- <a
21
- href="https://blog.hichroma.com/component-driven-development-ce1109d56c8e"
22
- target="_blank"
23
- rel="noopener noreferrer"
24
- >
25
- <strong>component-driven</strong>
26
- </a>
27
- process starting with atomic components and ending with pages.
28
- </p>
29
- <p>
30
- Render pages with mock data. This makes it easy to build and review page states without
31
- needing to navigate to them in your app. Here are some handy patterns for managing page data
32
- in Storybook:
33
- </p>
34
- <ul>
35
- <li>
36
- Use a higher-level connected component. Storybook helps you compose such data from the
37
- "args" of child component stories
38
- </li>
39
- <li>
40
- Assemble data in the page component from your services. You can mock these services out
41
- using Storybook.
42
- </li>
43
- </ul>
44
- <p>
45
- Get a guided tutorial on component-driven development at
46
- <a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
47
- Storybook tutorials
48
- </a>
49
- . Read more in the
50
- <a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">docs</a>
51
- .
52
- </p>
53
- <div class="tip-wrapper">
54
- <span class="tip">Tip</span>
55
- Adjust the width of the canvas with the
56
- <svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
57
- <g fill="none" fill-rule="evenodd">
58
- <path
59
- d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0
60
- 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
61
- 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"
62
- id="a"
63
- fill="#999"
64
- />
65
- </g>
66
- </svg>
67
- Viewports addon in the toolbar
68
- </div>
69
- </section>
70
- </article>
@@ -1,48 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/svelte-vite';
2
-
3
- import Button from './Button.svelte';
4
-
5
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
6
- const meta = {
7
- title: 'Example/Button',
8
- component: Button,
9
- tags: ['autodocs'],
10
- argTypes: {
11
- backgroundColor: { control: 'color' },
12
- size: {
13
- control: { type: 'select' },
14
- options: ['small', 'medium', 'large'],
15
- },
16
- },
17
- } satisfies Meta<Button>;
18
-
19
- export default meta;
20
- type Story = StoryObj<typeof meta>;
21
-
22
- // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
23
- export const Primary: Story = {
24
- args: {
25
- primary: true,
26
- label: 'Button',
27
- },
28
- };
29
-
30
- export const Secondary: Story = {
31
- args: {
32
- label: 'Button',
33
- },
34
- };
35
-
36
- export const Large: Story = {
37
- args: {
38
- size: 'large',
39
- label: 'Button',
40
- },
41
- };
42
-
43
- export const Small: Story = {
44
- args: {
45
- size: 'small',
46
- label: 'Button',
47
- },
48
- };
@@ -1,34 +0,0 @@
1
- <script lang="ts">
2
- import './button.css';
3
-
4
- /**
5
- * Is this the principal call to action on the page?
6
- */
7
- export let primary = false;
8
-
9
- /**
10
- * What background color to use
11
- */
12
- export let backgroundColor: string | undefined = undefined;
13
- /**
14
- * How large should the button be?
15
- */
16
- export let size: 'small' | 'medium' | 'large' = 'medium';
17
- /**
18
- * Button contents
19
- */
20
- export let label: string = '';
21
-
22
- $: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
23
-
24
- $: style = backgroundColor ? `background-color: ${backgroundColor}` : '';
25
- </script>
26
-
27
- <button
28
- type="button"
29
- class={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
30
- {style}
31
- on:click
32
- >
33
- {label}
34
- </button>
@@ -1,27 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/svelte-vite';
2
-
3
- import Header from './Header.svelte';
4
-
5
- const meta = {
6
- title: 'Example/Header',
7
- component: Header,
8
- // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
9
- tags: ['autodocs'],
10
- parameters: {
11
- // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
12
- layout: 'fullscreen',
13
- },
14
- } satisfies Meta<Header>;
15
-
16
- export default meta;
17
- type Story = StoryObj<typeof meta>;
18
-
19
- export const LoggedIn: Story = {
20
- args: {
21
- user: {
22
- name: 'Jane Doe',
23
- },
24
- },
25
- };
26
-
27
- export const LoggedOut: Story = {};
@@ -1,52 +0,0 @@
1
- <script lang="ts">
2
- import './header.css';
3
- import Button from './Button.svelte';
4
-
5
- import { createEventDispatcher } from 'svelte';
6
-
7
- export let user: { name: string } | null = null;
8
-
9
- const dispatch = createEventDispatcher();
10
-
11
- function onLogin(event: MouseEvent) {
12
- dispatch('login', event);
13
- }
14
- function onLogout(event: MouseEvent) {
15
- dispatch('logout', event);
16
- }
17
- function onCreateAccount(event: MouseEvent) {
18
- dispatch('createAccount', event);
19
- }
20
- </script>
21
-
22
- <header>
23
- <div class="storybook-header">
24
- <div>
25
- <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
26
- <g fill="none" fill-rule="evenodd">
27
- <path
28
- d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
29
- fill="#FFF"
30
- />
31
- <path
32
- d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
33
- fill="#555AB9"
34
- />
35
- <path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
36
- </g>
37
- </svg>
38
- <h1>Acme</h1>
39
- </div>
40
- <div>
41
- {#if user}
42
- <span class="welcome">
43
- Welcome, <b>{user.name}</b>!
44
- </span>
45
- <Button size="small" on:click={onLogout} label="Log out" />
46
- {:else}
47
- <Button size="small" on:click={onLogin} label="Log in" />
48
- <Button primary size="small" on:click={onCreateAccount} label="Sign up" />
49
- {/if}
50
- </div>
51
- </div>
52
- </header>
@@ -1,33 +0,0 @@
1
- import { expect, userEvent, waitFor, within } from '@storybook/test';
2
-
3
- import type { Meta, StoryObj } from '@storybook/svelte-vite';
4
-
5
- import Page from './Page.svelte';
6
-
7
- const meta = {
8
- title: 'Example/Page',
9
- component: Page,
10
- parameters: {
11
- // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
12
- layout: 'fullscreen',
13
- },
14
- } satisfies Meta<Page>;
15
-
16
- export default meta;
17
- type Story = StoryObj<typeof meta>;
18
-
19
- export const LoggedOut: Story = {};
20
-
21
- // More on component testing: https://storybook.js.org/docs/writing-tests/component-testing
22
- export const LoggedIn: Story = {
23
- play: async ({ canvasElement }) => {
24
- const canvas = within(canvasElement);
25
- const loginButton = canvas.getByRole('button', { name: /Log in/i });
26
- await expect(loginButton).toBeInTheDocument();
27
- await userEvent.click(loginButton);
28
- await waitFor(() => expect(loginButton).not.toBeInTheDocument());
29
-
30
- const logoutButton = canvas.getByRole('button', { name: /Log out/i });
31
- await expect(logoutButton).toBeInTheDocument();
32
- },
33
- };
@@ -1,70 +0,0 @@
1
- <script lang="ts">
2
- import './page.css';
3
- import Header from './Header.svelte';
4
-
5
- let user: { name: string } | null = null;
6
- </script>
7
-
8
- <article>
9
- <Header
10
- {user}
11
- on:login={() => (user = { name: 'Jane Doe' })}
12
- on:logout={() => (user = null)}
13
- on:createAccount={() => (user = { name: 'Jane Doe' })}
14
- />
15
-
16
- <section class="storybook-page">
17
- <h2>Pages in Storybook</h2>
18
- <p>
19
- We recommend building UIs with a
20
- <a
21
- href="https://blog.hichroma.com/component-driven-development-ce1109d56c8e"
22
- target="_blank"
23
- rel="noopener noreferrer"
24
- >
25
- <strong>component-driven</strong>
26
- </a>
27
- process starting with atomic components and ending with pages.
28
- </p>
29
- <p>
30
- Render pages with mock data. This makes it easy to build and review page states without
31
- needing to navigate to them in your app. Here are some handy patterns for managing page data
32
- in Storybook:
33
- </p>
34
- <ul>
35
- <li>
36
- Use a higher-level connected component. Storybook helps you compose such data from the
37
- "args" of child component stories
38
- </li>
39
- <li>
40
- Assemble data in the page component from your services. You can mock these services out
41
- using Storybook.
42
- </li>
43
- </ul>
44
- <p>
45
- Get a guided tutorial on component-driven development at
46
- <a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
47
- Storybook tutorials
48
- </a>
49
- . Read more in the
50
- <a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">docs</a>
51
- .
52
- </p>
53
- <div class="tip-wrapper">
54
- <span class="tip">Tip</span>
55
- Adjust the width of the canvas with the
56
- <svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
57
- <g fill="none" fill-rule="evenodd">
58
- <path
59
- d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0
60
- 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
61
- 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"
62
- id="a"
63
- fill="#999"
64
- />
65
- </g>
66
- </svg>
67
- Viewports addon in the toolbar
68
- </div>
69
- </section>
70
- </article>
@@ -1,97 +0,0 @@
1
- <script lang="ts">
2
- import type { LiteralNumbers, LiteralStrings } from './types';
3
- import { MyEnum } from './types';
4
-
5
- type MyObject = {
6
- foo: string;
7
- bar: number;
8
- };
9
-
10
- /**
11
- * Boolean
12
- */
13
- export let boolean: boolean = true;
14
- /**
15
- * String
16
- */
17
- export let string: string = 'default';
18
- /**
19
- * String (required)
20
- */
21
- export let stringRequired: string;
22
- /**
23
- * Number
24
- */
25
- export let number: number = 123;
26
- /**
27
- * True literal
28
- */
29
- export let trueLiteral: true | undefined = undefined;
30
- /**
31
- * Symbol
32
- */
33
- export let symbol: symbol | undefined = undefined;
34
- /**
35
- * Null
36
- */
37
- export let nullValue: null = null;
38
- /**
39
- * Undefined
40
- */
41
- export let undefinedValue: undefined = undefined;
42
- /**
43
- * Any
44
- */
45
- export let any: any = null;
46
- /**
47
- * Date
48
- */
49
- export let date: Date = new Date('20 Jan 1983');
50
- /**
51
- * Array of numbers
52
- */
53
- export let arrayOfNumbers: number[] = [1, 20, 300];
54
- /**
55
- * Enum
56
- */
57
- export let enumValue: MyEnum = MyEnum.FOO;
58
- /**
59
- * Union of literal strings
60
- */
61
- export let unionLiteralStrings: LiteralStrings = 'apple';
62
- /**
63
- * Union of literal numbers
64
- */
65
- export let unionLiteralNumbers: LiteralNumbers = 100;
66
- /**
67
- * Object
68
- */
69
- export let object: MyObject | undefined = undefined;
70
- /**
71
- * Inline object
72
- */
73
- export let inlineObject:
74
- | {
75
- foo: string;
76
- bar: number;
77
- }
78
- | undefined = undefined;
79
- /**
80
- * Record
81
- */
82
- export let record: Record<string, number> = { a: 1, b: 2 };
83
- /**
84
- * Union of types
85
- */
86
- export let unionTypes: number | string = 123;
87
- /**
88
- * Intersection of types
89
- */
90
- export let intersection: ({ a: number } & { b: string }) | undefined = undefined;
91
- /**
92
- * Event callback function
93
- */
94
- export let func: (event: MouseEvent) => number = () => 10;
95
- </script>
96
-
97
- <div>Docs: TS</div>
@@ -1,10 +0,0 @@
1
- import DocsTS from './DocsTS.svelte';
2
-
3
- export default {
4
- title: 'stories/renderers/svelte/docs-ts',
5
- component: DocsTS,
6
- args: {},
7
- tags: ['autodocs'],
8
- };
9
-
10
- export const Primary = {};