Upload folder using huggingface_hub (part 21)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/js/Page.stories.svelte +30 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/js/Page.svelte +70 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Button.stories.svelte +31 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Button.svelte +30 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Header.stories.svelte +26 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Header.svelte +45 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Page.stories.svelte +30 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Page.svelte +70 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-js/docgen/jsdoc.stories.js +17 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-js/docgen/jsdoc.svelte +92 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/jsdoc.stories.js +17 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/jsdoc.svelte +91 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-inline-prop-types.stories.ts +16 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-inline-prop-types.svelte +103 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-legacy.stories.ts +16 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-legacy.svelte +98 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-referenced-prop-types.stories.ts +16 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-referenced-prop-types.svelte +107 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts.stories.ts +16 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts.svelte +125 -0
- tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/types.ts +7 -0
- tools/ui/node_modules/@storybook/sveltekit/package.json +78 -0
- tools/ui/node_modules/@storybook/sveltekit/preset.js +1 -0
- tools/ui/node_modules/@storybook/sveltekit/preview.js +1 -0
- tools/ui/node_modules/@storybook/sveltekit/static/MockProvider.svelte +127 -0
- tools/ui/node_modules/@storybook/sveltekit/static/app-state-mock.svelte.js +234 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Button.stories.svelte +31 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Button.svelte +27 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Header.stories.svelte +26 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Header.svelte +47 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Page.stories.svelte +30 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Page.svelte +70 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Button.stories.svelte +31 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Button.svelte +30 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Header.stories.svelte +26 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Header.svelte +45 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Page.stories.svelte +30 -0
- tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Page.svelte +70 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Environment.svelte +8 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Forms.svelte +7 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Hrefs.svelte +8 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Navigation.svelte +44 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Paths.svelte +6 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/State.svelte +16 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Stores.svelte +17 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/environment.stories.js +8 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/forms.stories.js +26 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/hrefs.stories.js +52 -0
- tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/navigation.stories.js +120 -0
.gitattributes
CHANGED
|
@@ -101,3 +101,5 @@ tools/ui/node_modules/@parcel/watcher-linux-x64-glibc/watcher.node filter=lfs di
|
|
| 101 |
tools/ui/node_modules/@parcel/watcher-linux-x64-musl/watcher.node filter=lfs diff=lfs merge=lfs -text
|
| 102 |
tools/ui/node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 103 |
tools/ui/node_modules/@rollup/rollup-linux-x64-musl/rollup.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 101 |
tools/ui/node_modules/@parcel/watcher-linux-x64-musl/watcher.node filter=lfs diff=lfs merge=lfs -text
|
| 102 |
tools/ui/node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 103 |
tools/ui/node_modules/@rollup/rollup-linux-x64-musl/rollup.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
| 104 |
+
tools/ui/node_modules/@tailwindcss/oxide-linux-x64-gnu/tailwindcss-oxide.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 105 |
+
tools/ui/node_modules/@tailwindcss/oxide-linux-x64-musl/tailwindcss-oxide.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/js/Page.stories.svelte
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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" />
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/js/Page.svelte
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import './page.css';
|
| 3 |
+
import Header from './Header.svelte';
|
| 4 |
+
|
| 5 |
+
let user = $state(null);
|
| 6 |
+
</script>
|
| 7 |
+
|
| 8 |
+
<article>
|
| 9 |
+
<Header
|
| 10 |
+
{user}
|
| 11 |
+
onLogin={() => (user = { name: 'Jane Doe' })}
|
| 12 |
+
onLogout={() => (user = null)}
|
| 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>
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Button.stories.svelte
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script module>
|
| 2 |
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
| 3 |
+
import Button from './Button.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/Button',
|
| 9 |
+
component: Button,
|
| 10 |
+
tags: ['autodocs'],
|
| 11 |
+
argTypes: {
|
| 12 |
+
backgroundColor: { control: 'color' },
|
| 13 |
+
size: {
|
| 14 |
+
control: { type: 'select' },
|
| 15 |
+
options: ['small', 'medium', 'large'],
|
| 16 |
+
},
|
| 17 |
+
},
|
| 18 |
+
args: {
|
| 19 |
+
onclick: fn(),
|
| 20 |
+
}
|
| 21 |
+
});
|
| 22 |
+
</script>
|
| 23 |
+
|
| 24 |
+
<!-- More on writing stories with args: https://storybook.js.org/docs/writing-stories/args -->
|
| 25 |
+
<Story name="Primary" args={{ primary: true, label: 'Button' }} />
|
| 26 |
+
|
| 27 |
+
<Story name="Secondary" args={{ label: 'Button' }} />
|
| 28 |
+
|
| 29 |
+
<Story name="Large" args={{ size: 'large', label: 'Button' }} />
|
| 30 |
+
|
| 31 |
+
<Story name="Small" args={{ size: 'small', label: 'Button' }} />
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Button.svelte
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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, ...props }: Props = $props();
|
| 18 |
+
|
| 19 |
+
let mode = $derived(primary ? 'storybook-button--primary' : 'storybook-button--secondary');
|
| 20 |
+
let style = $derived(backgroundColor ? `background-color: ${backgroundColor}` : '');
|
| 21 |
+
</script>
|
| 22 |
+
|
| 23 |
+
<button
|
| 24 |
+
type="button"
|
| 25 |
+
class={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
| 26 |
+
{style}
|
| 27 |
+
{...props}
|
| 28 |
+
>
|
| 29 |
+
{label}
|
| 30 |
+
</button>
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Header.stories.svelte
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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" />
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Header.svelte
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import './header.css';
|
| 3 |
+
import Button from './Button.svelte';
|
| 4 |
+
|
| 5 |
+
interface Props {
|
| 6 |
+
user?: { name: string };
|
| 7 |
+
onLogin?: () => void;
|
| 8 |
+
onLogout?: () => void;
|
| 9 |
+
onCreateAccount?: () => void;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
const { user, onLogin, onLogout, onCreateAccount }: Props = $props();
|
| 13 |
+
</script>
|
| 14 |
+
|
| 15 |
+
<header>
|
| 16 |
+
<div class="storybook-header">
|
| 17 |
+
<div>
|
| 18 |
+
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
| 19 |
+
<g fill="none" fill-rule="evenodd">
|
| 20 |
+
<path
|
| 21 |
+
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
| 22 |
+
fill="#FFF"
|
| 23 |
+
/>
|
| 24 |
+
<path
|
| 25 |
+
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
| 26 |
+
fill="#555AB9"
|
| 27 |
+
/>
|
| 28 |
+
<path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
|
| 29 |
+
</g>
|
| 30 |
+
</svg>
|
| 31 |
+
<h1>Acme</h1>
|
| 32 |
+
</div>
|
| 33 |
+
<div>
|
| 34 |
+
{#if user}
|
| 35 |
+
<span class="welcome">
|
| 36 |
+
Welcome, <b>{user.name}</b>!
|
| 37 |
+
</span>
|
| 38 |
+
<Button size="small" onclick={onLogout} label="Log out" />
|
| 39 |
+
{:else}
|
| 40 |
+
<Button size="small" onclick={onLogin} label="Log in" />
|
| 41 |
+
<Button primary size="small" onclick={onCreateAccount} label="Sign up" />
|
| 42 |
+
{/if}
|
| 43 |
+
</div>
|
| 44 |
+
</div>
|
| 45 |
+
</header>
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Page.stories.svelte
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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" />
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/cli/ts/Page.svelte
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-js/docgen/jsdoc.stories.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import JSDoc from './jsdoc.svelte';
|
| 2 |
+
|
| 3 |
+
/** @typedef {import('@storybook/svelte-vite').StoryObj} StoryObj */
|
| 4 |
+
|
| 5 |
+
/** @type {Meta<typeof JSDoc>} */
|
| 6 |
+
const meta = {
|
| 7 |
+
component: JSDoc,
|
| 8 |
+
tags: ['autodocs'],
|
| 9 |
+
render: (args, { argTypes }) => ({
|
| 10 |
+
Component: JSDoc,
|
| 11 |
+
props: { ...args, argTypes },
|
| 12 |
+
}),
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
export default meta;
|
| 16 |
+
|
| 17 |
+
export const Default = {};
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-js/docgen/jsdoc.svelte
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
/**
|
| 3 |
+
* @typedef {Object} MyObject
|
| 4 |
+
* @property {string} foo
|
| 5 |
+
* @property {number} bar
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* @typedef {Object} MyProps
|
| 10 |
+
* @property {boolean} [boolean] Boolean
|
| 11 |
+
* @property {string} [string] String
|
| 12 |
+
* @property {string} stringRequired String (required)
|
| 13 |
+
* @property {number} [number] Number
|
| 14 |
+
* @property {true} [trueLiteral] True literal
|
| 15 |
+
* @property {symbol} [symbol] Symbol
|
| 16 |
+
* @property {null} [nullValue] Null
|
| 17 |
+
* @property {undefined} [undefinedValue] Undefined
|
| 18 |
+
* @property {any} [any] Any
|
| 19 |
+
* @property {Date} [date] Date
|
| 20 |
+
* @property {import('./types').LiteralStrings} [unionLiteralStrings] Union of literal strings
|
| 21 |
+
* @property {import('./types').LiteralNumbers} [unionLiteralNumbers] Union of literal numbers
|
| 22 |
+
* @property {MyObject} [object] Object
|
| 23 |
+
* @property {{ foo: string; bar: number }} [inlineObject] Inline object
|
| 24 |
+
* @property {Record<string, number>} [record] Record
|
| 25 |
+
* @property {number | string} [unionTypes] Union of types
|
| 26 |
+
* @property {{ a: number } & { b: string }} [intersection] Intersection of types
|
| 27 |
+
* @property {(event: MouseEvent) => number} [func] Event callback function
|
| 28 |
+
* @property {import('svelte').Snippet} children Snippet contents
|
| 29 |
+
* @property {Record<string, any>} [argTypes] Actual arg types inferred from the component
|
| 30 |
+
*/
|
| 31 |
+
|
| 32 |
+
/** @type {MyProps} */
|
| 33 |
+
let {
|
| 34 |
+
boolean = true,
|
| 35 |
+
string = 'default',
|
| 36 |
+
stringRequired,
|
| 37 |
+
number = 123,
|
| 38 |
+
trueLiteral = undefined,
|
| 39 |
+
symbol = undefined,
|
| 40 |
+
nullValue = null,
|
| 41 |
+
undefinedValue = undefined,
|
| 42 |
+
any = undefined,
|
| 43 |
+
date = new Date('20 Jan 1983'),
|
| 44 |
+
unionLiteralStrings = 'apple',
|
| 45 |
+
unionLiteralNumbers = 1000,
|
| 46 |
+
object = undefined,
|
| 47 |
+
inlineObject = undefined,
|
| 48 |
+
record = { a: 1, b: 2 },
|
| 49 |
+
unionTypes = 123,
|
| 50 |
+
intersection = undefined,
|
| 51 |
+
func = () => 10,
|
| 52 |
+
children,
|
| 53 |
+
argTypes,
|
| 54 |
+
} = $props();
|
| 55 |
+
</script>
|
| 56 |
+
|
| 57 |
+
<h1>Docgen: JS - JSDoc</h1>
|
| 58 |
+
|
| 59 |
+
<h2>Args</h2>
|
| 60 |
+
<pre>{JSON.stringify(
|
| 61 |
+
{
|
| 62 |
+
boolean,
|
| 63 |
+
string,
|
| 64 |
+
stringRequired,
|
| 65 |
+
number,
|
| 66 |
+
trueLiteral,
|
| 67 |
+
symbol,
|
| 68 |
+
nullValue,
|
| 69 |
+
undefinedValue,
|
| 70 |
+
any,
|
| 71 |
+
date,
|
| 72 |
+
unionLiteralStrings,
|
| 73 |
+
unionLiteralNumbers,
|
| 74 |
+
object,
|
| 75 |
+
inlineObject,
|
| 76 |
+
record,
|
| 77 |
+
unionTypes,
|
| 78 |
+
intersection,
|
| 79 |
+
func,
|
| 80 |
+
argTypes,
|
| 81 |
+
},
|
| 82 |
+
null,
|
| 83 |
+
2
|
| 84 |
+
)}</pre>
|
| 85 |
+
|
| 86 |
+
<h2>Children</h2>
|
| 87 |
+
{#if children}
|
| 88 |
+
{@render children()}
|
| 89 |
+
{/if}
|
| 90 |
+
|
| 91 |
+
<h2>Arg Types</h2>
|
| 92 |
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/jsdoc.stories.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import JSDoc from './jsdoc.svelte';
|
| 2 |
+
|
| 3 |
+
/** @typedef {import('@storybook/svelte-vite').StoryObj} StoryObj */
|
| 4 |
+
|
| 5 |
+
/** @type {Meta<typeof JSDoc>} */
|
| 6 |
+
const meta = {
|
| 7 |
+
component: JSDoc,
|
| 8 |
+
tags: ['autodocs'],
|
| 9 |
+
render: (args, { argTypes }) => ({
|
| 10 |
+
Component: JSDoc,
|
| 11 |
+
props: { ...args, argTypes },
|
| 12 |
+
}),
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
export default meta;
|
| 16 |
+
|
| 17 |
+
export const Default = {};
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/jsdoc.svelte
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
/**
|
| 3 |
+
* @typedef {Object} MyObject
|
| 4 |
+
* @property {string} foo
|
| 5 |
+
* @property {number} bar
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* @typedef {Object} MyProps
|
| 10 |
+
* @property {boolean} [boolean] Boolean
|
| 11 |
+
* @property {string} [string] String
|
| 12 |
+
* @property {string} stringRequired String (required)
|
| 13 |
+
* @property {number} [number] Number
|
| 14 |
+
* @property {true} [trueLiteral] True literal
|
| 15 |
+
* @property {symbol} [symbol] Symbol
|
| 16 |
+
* @property {null} [nullValue] Null
|
| 17 |
+
* @property {undefined} [undefinedValue] Undefined
|
| 18 |
+
* @property {any} [any] Any
|
| 19 |
+
* @property {import('./types').LiteralStrings} [unionLiteralStrings] Union of literal strings
|
| 20 |
+
* @property {import('./types').LiteralNumbers} [unionLiteralNumbers] Union of literal numbers
|
| 21 |
+
* @property {MyObject} [object] Object
|
| 22 |
+
* @property {{ foo: string; bar: number }} [inlineObject] Inline object
|
| 23 |
+
* @property {Record<string, number>} [record] Record
|
| 24 |
+
* @property {Date} [date] Date
|
| 25 |
+
* @property {number | string} [unionTypes] Union of types
|
| 26 |
+
* @property {{ a: number } & { b: string }} [intersection] Intersection of types
|
| 27 |
+
* @property {import('svelte').Snippet} children Snippet contents
|
| 28 |
+
* @property {(event: MouseEvent) => number} [func] Event callback function
|
| 29 |
+
* @property {Record<string, any>} [argTypes] Actual arg types inferred from the component
|
| 30 |
+
*/
|
| 31 |
+
|
| 32 |
+
/** @type {MyProps} */
|
| 33 |
+
let {
|
| 34 |
+
boolean = true,
|
| 35 |
+
string = 'default',
|
| 36 |
+
stringRequired,
|
| 37 |
+
number = 123,
|
| 38 |
+
trueLiteral = undefined,
|
| 39 |
+
symbol = undefined,
|
| 40 |
+
nullValue = null,
|
| 41 |
+
undefinedValue = undefined,
|
| 42 |
+
any = undefined,
|
| 43 |
+
unionLiteralStrings = 'apple',
|
| 44 |
+
unionLiteralNumbers = 1000,
|
| 45 |
+
object = undefined,
|
| 46 |
+
inlineObject = undefined,
|
| 47 |
+
record = { a: 1, b: 2 },
|
| 48 |
+
date = new Date('20 Jan 1983'),
|
| 49 |
+
unionTypes = 123,
|
| 50 |
+
intersection = undefined,
|
| 51 |
+
children,
|
| 52 |
+
func = () => 10,
|
| 53 |
+
argTypes,
|
| 54 |
+
} = $props();
|
| 55 |
+
</script>
|
| 56 |
+
|
| 57 |
+
<h1>Docgen: JS - JSDoc</h1>
|
| 58 |
+
|
| 59 |
+
<h2>Args</h2>
|
| 60 |
+
<pre>{JSON.stringify(
|
| 61 |
+
{
|
| 62 |
+
boolean,
|
| 63 |
+
string,
|
| 64 |
+
stringRequired,
|
| 65 |
+
number,
|
| 66 |
+
trueLiteral,
|
| 67 |
+
symbol,
|
| 68 |
+
nullValue,
|
| 69 |
+
undefinedValue,
|
| 70 |
+
any,
|
| 71 |
+
date,
|
| 72 |
+
unionLiteralStrings,
|
| 73 |
+
unionLiteralNumbers,
|
| 74 |
+
object,
|
| 75 |
+
inlineObject,
|
| 76 |
+
record,
|
| 77 |
+
unionTypes,
|
| 78 |
+
intersection,
|
| 79 |
+
func,
|
| 80 |
+
},
|
| 81 |
+
null,
|
| 82 |
+
2
|
| 83 |
+
)}</pre>
|
| 84 |
+
|
| 85 |
+
<h2>Children</h2>
|
| 86 |
+
{#if children}
|
| 87 |
+
{@render children()}
|
| 88 |
+
{/if}
|
| 89 |
+
|
| 90 |
+
<h2>Arg Types</h2>
|
| 91 |
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-inline-prop-types.stories.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Meta } from '@storybook/svelte-vite';
|
| 2 |
+
|
| 3 |
+
import TSInlinePropTypes from './ts-inline-prop-types.svelte';
|
| 4 |
+
|
| 5 |
+
const meta = {
|
| 6 |
+
component: TSInlinePropTypes,
|
| 7 |
+
tags: ['autodocs'],
|
| 8 |
+
render: (args, { argTypes }) => ({
|
| 9 |
+
Component: TSInlinePropTypes,
|
| 10 |
+
props: { ...args, argTypes },
|
| 11 |
+
}),
|
| 12 |
+
} satisfies Meta<typeof TSInlinePropTypes>;
|
| 13 |
+
|
| 14 |
+
export default meta;
|
| 15 |
+
|
| 16 |
+
export const Default = {};
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-inline-prop-types.svelte
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import type { Snippet } from 'svelte';
|
| 3 |
+
import type { LiteralNumbers, LiteralStrings } from './types';
|
| 4 |
+
import { MyEnum } from './types';
|
| 5 |
+
|
| 6 |
+
type MyObject = {
|
| 7 |
+
foo: string;
|
| 8 |
+
bar: number;
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
let {
|
| 12 |
+
boolean = true,
|
| 13 |
+
string = 'default',
|
| 14 |
+
stringRequired,
|
| 15 |
+
number = 123,
|
| 16 |
+
nullValue = null,
|
| 17 |
+
arrayOfNumbers = [1, 20, 300],
|
| 18 |
+
enumValue = MyEnum.FOO,
|
| 19 |
+
record = { a: 1, b: 2 },
|
| 20 |
+
date = new Date('20 Jan 1983'),
|
| 21 |
+
unionTypes = 123,
|
| 22 |
+
func = () => 10,
|
| 23 |
+
children,
|
| 24 |
+
argTypes,
|
| 25 |
+
}: {
|
| 26 |
+
/** Boolean */
|
| 27 |
+
boolean?: boolean;
|
| 28 |
+
/** String */
|
| 29 |
+
string?: string;
|
| 30 |
+
/** String (required) */
|
| 31 |
+
stringRequired: string;
|
| 32 |
+
/** Number */
|
| 33 |
+
number?: number;
|
| 34 |
+
/** True literal */
|
| 35 |
+
trueLiteral?: true;
|
| 36 |
+
/** Symbol */
|
| 37 |
+
symbol?: symbol;
|
| 38 |
+
/** Null */
|
| 39 |
+
nullValue?: null;
|
| 40 |
+
/** Undefined */
|
| 41 |
+
undefinedValue?: undefined;
|
| 42 |
+
/** Any */
|
| 43 |
+
any?: any;
|
| 44 |
+
/** Date */
|
| 45 |
+
date?: Date;
|
| 46 |
+
/** Array of numbers */
|
| 47 |
+
arrayOfNumbers?: number[];
|
| 48 |
+
/** Enum */
|
| 49 |
+
enumValue?: MyEnum;
|
| 50 |
+
/** Union of literal strings */
|
| 51 |
+
unionLiteralStrings?: LiteralStrings;
|
| 52 |
+
/** Union of literal numbers */
|
| 53 |
+
unionLiteralNumbers?: LiteralNumbers;
|
| 54 |
+
/** Object */
|
| 55 |
+
object?: MyObject;
|
| 56 |
+
/** Inline object */
|
| 57 |
+
inlineObject?: {
|
| 58 |
+
foo: string;
|
| 59 |
+
bar: number;
|
| 60 |
+
};
|
| 61 |
+
/** Record */
|
| 62 |
+
record?: Record<string, number>;
|
| 63 |
+
/** Union of types */
|
| 64 |
+
unionTypes?: number | string;
|
| 65 |
+
/** Intersection of types */
|
| 66 |
+
intersection?: { a: number } & { b: string };
|
| 67 |
+
/** Event callback function */
|
| 68 |
+
func?: (event: MouseEvent) => number;
|
| 69 |
+
/** Snippet contents */
|
| 70 |
+
children: Snippet;
|
| 71 |
+
/** Actual arg types inferred from the component */
|
| 72 |
+
argTypes: Record<string, any>;
|
| 73 |
+
} = $props();
|
| 74 |
+
</script>
|
| 75 |
+
|
| 76 |
+
<h1>Docgen: TS - inline prop types</h1>
|
| 77 |
+
|
| 78 |
+
<h2>Args</h2>
|
| 79 |
+
<pre>{JSON.stringify(
|
| 80 |
+
{
|
| 81 |
+
boolean,
|
| 82 |
+
string,
|
| 83 |
+
stringRequired,
|
| 84 |
+
number,
|
| 85 |
+
nullValue,
|
| 86 |
+
date,
|
| 87 |
+
arrayOfNumbers,
|
| 88 |
+
enumValue,
|
| 89 |
+
record,
|
| 90 |
+
unionTypes,
|
| 91 |
+
func,
|
| 92 |
+
},
|
| 93 |
+
null,
|
| 94 |
+
2
|
| 95 |
+
)}</pre>
|
| 96 |
+
|
| 97 |
+
<h2>Children</h2>
|
| 98 |
+
{#if children}
|
| 99 |
+
{@render children()}
|
| 100 |
+
{/if}
|
| 101 |
+
|
| 102 |
+
<h2>Arg Types</h2>
|
| 103 |
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-legacy.stories.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Meta } from '@storybook/svelte-vite';
|
| 2 |
+
|
| 3 |
+
import TSLegacy from './ts-legacy.svelte';
|
| 4 |
+
|
| 5 |
+
const meta = {
|
| 6 |
+
component: TSLegacy,
|
| 7 |
+
tags: ['autodocs'],
|
| 8 |
+
render: (args, { argTypes }) => ({
|
| 9 |
+
Component: TSLegacy,
|
| 10 |
+
props: { ...args, argTypes } as any,
|
| 11 |
+
}),
|
| 12 |
+
} satisfies Meta<typeof TSLegacy>;
|
| 13 |
+
|
| 14 |
+
export default meta;
|
| 15 |
+
|
| 16 |
+
export const Default = {};
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-legacy.svelte
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import type { Snippet } from 'svelte';
|
| 3 |
+
import type { LiteralNumbers, LiteralStrings } from './types';
|
| 4 |
+
import { MyEnum } from './types';
|
| 5 |
+
|
| 6 |
+
type MyObject = {
|
| 7 |
+
foo: string;
|
| 8 |
+
bar: number;
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
/** Boolean */
|
| 12 |
+
export let boolean: boolean = true;
|
| 13 |
+
/** String */
|
| 14 |
+
export let string: string = 'default';
|
| 15 |
+
/** String (required) */
|
| 16 |
+
export let stringRequired: string;
|
| 17 |
+
/** Number */
|
| 18 |
+
export let number: number = 123;
|
| 19 |
+
/** True literal */
|
| 20 |
+
export let trueLiteral: true | undefined = undefined;
|
| 21 |
+
/** Symbol */
|
| 22 |
+
export let symbol: symbol | undefined = undefined;
|
| 23 |
+
/** Null */
|
| 24 |
+
export let nullValue: null = null;
|
| 25 |
+
/** Undefined */
|
| 26 |
+
export let undefinedValue: undefined = undefined;
|
| 27 |
+
/** Any */
|
| 28 |
+
export let any: any = null;
|
| 29 |
+
/** Date */
|
| 30 |
+
export let date: Date = new Date('20 Jan 1983');
|
| 31 |
+
/** Array of numbers */
|
| 32 |
+
export let arrayOfNumbers: number[] = [1, 20, 300];
|
| 33 |
+
/** Enum */
|
| 34 |
+
export let enumValue: MyEnum = MyEnum.FOO;
|
| 35 |
+
/** Union of literal strings */
|
| 36 |
+
export let unionLiteralStrings: LiteralStrings = 'apple';
|
| 37 |
+
/** Union of literal numbers */
|
| 38 |
+
export let unionLiteralNumbers: LiteralNumbers = 1000;
|
| 39 |
+
/** Object */
|
| 40 |
+
export let object: MyObject | undefined = undefined;
|
| 41 |
+
/** Inline object */
|
| 42 |
+
export let inlineObject:
|
| 43 |
+
| {
|
| 44 |
+
foo: string;
|
| 45 |
+
bar: number;
|
| 46 |
+
}
|
| 47 |
+
| undefined = undefined;
|
| 48 |
+
/** Record */
|
| 49 |
+
export let record: Record<string, number> = { a: 1, b: 2 };
|
| 50 |
+
/** Union of types */
|
| 51 |
+
export let unionTypes: number | string = 123;
|
| 52 |
+
/** Intersection of types */
|
| 53 |
+
export let intersection: ({ a: number } & { b: string }) | undefined = undefined;
|
| 54 |
+
/** Event callback function */
|
| 55 |
+
export let func: (event: MouseEvent) => number = () => 10;
|
| 56 |
+
/** Snippet contents */
|
| 57 |
+
export let children: Snippet;
|
| 58 |
+
/** Actual arg types inferred from the component */
|
| 59 |
+
export let argTypes: Record<string, any> = {};
|
| 60 |
+
</script>
|
| 61 |
+
|
| 62 |
+
<h1>Docgen: TS - legacy</h1>
|
| 63 |
+
|
| 64 |
+
<h2>Args</h2>
|
| 65 |
+
<pre>{JSON.stringify(
|
| 66 |
+
{
|
| 67 |
+
boolean,
|
| 68 |
+
string,
|
| 69 |
+
stringRequired,
|
| 70 |
+
number,
|
| 71 |
+
trueLiteral,
|
| 72 |
+
symbol,
|
| 73 |
+
nullValue,
|
| 74 |
+
undefinedValue,
|
| 75 |
+
any,
|
| 76 |
+
date,
|
| 77 |
+
arrayOfNumbers,
|
| 78 |
+
enumValue,
|
| 79 |
+
unionLiteralStrings,
|
| 80 |
+
unionLiteralNumbers,
|
| 81 |
+
object,
|
| 82 |
+
inlineObject,
|
| 83 |
+
record,
|
| 84 |
+
unionTypes,
|
| 85 |
+
intersection,
|
| 86 |
+
func,
|
| 87 |
+
},
|
| 88 |
+
null,
|
| 89 |
+
2
|
| 90 |
+
)}</pre>
|
| 91 |
+
|
| 92 |
+
<h2>Children</h2>
|
| 93 |
+
{#if children}
|
| 94 |
+
{@render children()}
|
| 95 |
+
{/if}
|
| 96 |
+
|
| 97 |
+
<h2>Arg Types</h2>
|
| 98 |
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-referenced-prop-types.stories.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Meta } from '@storybook/svelte-vite';
|
| 2 |
+
|
| 3 |
+
import TSReferencedPropTypes from './ts-referenced-prop-types.svelte';
|
| 4 |
+
|
| 5 |
+
const meta = {
|
| 6 |
+
component: TSReferencedPropTypes,
|
| 7 |
+
tags: ['autodocs'],
|
| 8 |
+
render: (args, { argTypes }) => ({
|
| 9 |
+
Component: TSReferencedPropTypes,
|
| 10 |
+
props: { ...args, argTypes },
|
| 11 |
+
}),
|
| 12 |
+
} satisfies Meta<typeof TSReferencedPropTypes>;
|
| 13 |
+
|
| 14 |
+
export default meta;
|
| 15 |
+
|
| 16 |
+
export const Default = {};
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts-referenced-prop-types.svelte
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import type { Snippet } from 'svelte';
|
| 3 |
+
import type { LiteralNumbers, LiteralStrings } from './types';
|
| 4 |
+
import { MyEnum } from './types';
|
| 5 |
+
|
| 6 |
+
type MyObject = {
|
| 7 |
+
foo: string;
|
| 8 |
+
bar: number;
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
type PropsA = {
|
| 12 |
+
/** Boolean */
|
| 13 |
+
boolean?: boolean;
|
| 14 |
+
/** String */
|
| 15 |
+
string?: string;
|
| 16 |
+
/** String (required) */
|
| 17 |
+
stringRequired: string;
|
| 18 |
+
/** Number */
|
| 19 |
+
number?: number;
|
| 20 |
+
};
|
| 21 |
+
type PropsB = {
|
| 22 |
+
/** True literal */
|
| 23 |
+
trueLiteral?: true;
|
| 24 |
+
/** Symbol */
|
| 25 |
+
symbol?: symbol;
|
| 26 |
+
/** Null */
|
| 27 |
+
nullValue?: null;
|
| 28 |
+
/** Undefined */
|
| 29 |
+
undefinedValue?: undefined;
|
| 30 |
+
/** Any */
|
| 31 |
+
any?: any;
|
| 32 |
+
/** Date */
|
| 33 |
+
date?: Date;
|
| 34 |
+
/** Array of numbers */
|
| 35 |
+
arrayOfNumbers?: number[];
|
| 36 |
+
/** Enum */
|
| 37 |
+
enumValue?: MyEnum;
|
| 38 |
+
/** Union of literal strings */
|
| 39 |
+
unionLiteralStrings?: LiteralStrings;
|
| 40 |
+
/** Union of literal numbers */
|
| 41 |
+
unionLiteralNumbers?: LiteralNumbers;
|
| 42 |
+
/** Object */
|
| 43 |
+
object?: MyObject;
|
| 44 |
+
/** Inline object */
|
| 45 |
+
inlineObject?: {
|
| 46 |
+
foo: string;
|
| 47 |
+
bar: number;
|
| 48 |
+
};
|
| 49 |
+
/** Record */
|
| 50 |
+
record?: Record<string, number>;
|
| 51 |
+
/** Union of types */
|
| 52 |
+
unionTypes?: number | string;
|
| 53 |
+
/** Intersection of types */
|
| 54 |
+
intersection?: { a: number } & { b: string };
|
| 55 |
+
/** Event callback function */
|
| 56 |
+
func?: (event: MouseEvent) => number;
|
| 57 |
+
/** Snippet contents */
|
| 58 |
+
children: Snippet;
|
| 59 |
+
/** Actual arg types inferred from the component */
|
| 60 |
+
argTypes: Record<string, any>;
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
let {
|
| 64 |
+
boolean = true,
|
| 65 |
+
string = 'default',
|
| 66 |
+
stringRequired,
|
| 67 |
+
number = 123,
|
| 68 |
+
nullValue = null,
|
| 69 |
+
arrayOfNumbers = [1, 20, 300],
|
| 70 |
+
enumValue = MyEnum.FOO,
|
| 71 |
+
record = { a: 1, b: 2 },
|
| 72 |
+
date = new Date('20 Jan 1983'),
|
| 73 |
+
unionTypes = 123,
|
| 74 |
+
children,
|
| 75 |
+
func = () => 10,
|
| 76 |
+
argTypes,
|
| 77 |
+
}: PropsA & PropsB = $props();
|
| 78 |
+
</script>
|
| 79 |
+
|
| 80 |
+
<h1>Docgen: TS - referenced prop types</h1>
|
| 81 |
+
|
| 82 |
+
<h2>Args</h2>
|
| 83 |
+
<pre>{JSON.stringify(
|
| 84 |
+
{
|
| 85 |
+
boolean,
|
| 86 |
+
string,
|
| 87 |
+
stringRequired,
|
| 88 |
+
number,
|
| 89 |
+
nullValue,
|
| 90 |
+
arrayOfNumbers,
|
| 91 |
+
enumValue,
|
| 92 |
+
record,
|
| 93 |
+
date,
|
| 94 |
+
unionTypes,
|
| 95 |
+
func,
|
| 96 |
+
},
|
| 97 |
+
null,
|
| 98 |
+
2
|
| 99 |
+
)}</pre>
|
| 100 |
+
|
| 101 |
+
<h2>Children</h2>
|
| 102 |
+
{#if children}
|
| 103 |
+
{@render children()}
|
| 104 |
+
{/if}
|
| 105 |
+
|
| 106 |
+
<h2>Arg Types</h2>
|
| 107 |
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts.stories.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Meta } from '@storybook/svelte-vite';
|
| 2 |
+
|
| 3 |
+
import TS from './ts.svelte';
|
| 4 |
+
|
| 5 |
+
const meta = {
|
| 6 |
+
component: TS,
|
| 7 |
+
tags: ['autodocs'],
|
| 8 |
+
render: (args, { argTypes }) => ({
|
| 9 |
+
Component: TS,
|
| 10 |
+
props: { ...args, argTypes },
|
| 11 |
+
}),
|
| 12 |
+
} satisfies Meta<typeof TS>;
|
| 13 |
+
|
| 14 |
+
export default meta;
|
| 15 |
+
|
| 16 |
+
export const Default = {};
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/ts.svelte
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import type { Snippet } from 'svelte';
|
| 3 |
+
import type { LiteralNumbers, LiteralStrings } from './types';
|
| 4 |
+
import { MyEnum } from './types';
|
| 5 |
+
|
| 6 |
+
type MyObject = {
|
| 7 |
+
foo: string;
|
| 8 |
+
bar: number;
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
type Props = {
|
| 12 |
+
/** Boolean */
|
| 13 |
+
boolean?: boolean;
|
| 14 |
+
/** String */
|
| 15 |
+
string?: string;
|
| 16 |
+
/** String (required) */
|
| 17 |
+
stringRequired: string;
|
| 18 |
+
/** Number */
|
| 19 |
+
number?: number;
|
| 20 |
+
/** True literal */
|
| 21 |
+
trueLiteral?: true | undefined;
|
| 22 |
+
/** Symbol */
|
| 23 |
+
symbol?: symbol | undefined;
|
| 24 |
+
/** Null */
|
| 25 |
+
nullValue?: null;
|
| 26 |
+
/** Undefined */
|
| 27 |
+
undefinedValue?: undefined;
|
| 28 |
+
/** Any */
|
| 29 |
+
any?: any;
|
| 30 |
+
/** Date */
|
| 31 |
+
date?: Date;
|
| 32 |
+
/** Array of numbers */
|
| 33 |
+
arrayOfNumbers?: number[];
|
| 34 |
+
/** Enum */
|
| 35 |
+
enumValue?: MyEnum;
|
| 36 |
+
/** Union of literal strings */
|
| 37 |
+
unionLiteralStrings?: LiteralStrings;
|
| 38 |
+
/** Union of literal numbers */
|
| 39 |
+
unionLiteralNumbers?: LiteralNumbers;
|
| 40 |
+
/** Object */
|
| 41 |
+
object?: MyObject | undefined;
|
| 42 |
+
/** Inline object */
|
| 43 |
+
inlineObject?:
|
| 44 |
+
| {
|
| 45 |
+
foo: string;
|
| 46 |
+
bar: number;
|
| 47 |
+
}
|
| 48 |
+
| undefined;
|
| 49 |
+
/** Record */
|
| 50 |
+
record?: Record<string, number>;
|
| 51 |
+
/** Union of types */
|
| 52 |
+
unionTypes?: number | string;
|
| 53 |
+
/** Intersection of types */
|
| 54 |
+
intersection?: ({ a: number } & { b: string }) | undefined;
|
| 55 |
+
/** Event callback function */
|
| 56 |
+
func?: (event: MouseEvent) => number;
|
| 57 |
+
/** Children */
|
| 58 |
+
children: Snippet;
|
| 59 |
+
/** Actual arg types inferred from the component */
|
| 60 |
+
argTypes: Record<string, any>;
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
const {
|
| 64 |
+
boolean = true,
|
| 65 |
+
string = 'default',
|
| 66 |
+
stringRequired,
|
| 67 |
+
number = 123,
|
| 68 |
+
trueLiteral = undefined,
|
| 69 |
+
symbol = undefined,
|
| 70 |
+
nullValue = null,
|
| 71 |
+
undefinedValue = undefined,
|
| 72 |
+
any = null,
|
| 73 |
+
date = new Date('20 Jan 1983'),
|
| 74 |
+
arrayOfNumbers = [1, 20, 300],
|
| 75 |
+
enumValue = MyEnum.FOO,
|
| 76 |
+
unionLiteralStrings = 'apple',
|
| 77 |
+
unionLiteralNumbers = 100,
|
| 78 |
+
object = undefined,
|
| 79 |
+
inlineObject = undefined,
|
| 80 |
+
record = { a: 1, b: 2 },
|
| 81 |
+
unionTypes = 123,
|
| 82 |
+
intersection = undefined,
|
| 83 |
+
func = () => 10,
|
| 84 |
+
children,
|
| 85 |
+
argTypes,
|
| 86 |
+
}: Props = $props();
|
| 87 |
+
</script>
|
| 88 |
+
|
| 89 |
+
<h1>Docgen: TS</h1>
|
| 90 |
+
|
| 91 |
+
<h2>Args</h2>
|
| 92 |
+
<pre>{JSON.stringify(
|
| 93 |
+
{
|
| 94 |
+
boolean,
|
| 95 |
+
string,
|
| 96 |
+
stringRequired,
|
| 97 |
+
number,
|
| 98 |
+
trueLiteral,
|
| 99 |
+
symbol,
|
| 100 |
+
nullValue,
|
| 101 |
+
undefinedValue,
|
| 102 |
+
any,
|
| 103 |
+
date,
|
| 104 |
+
arrayOfNumbers,
|
| 105 |
+
enumValue,
|
| 106 |
+
unionLiteralStrings,
|
| 107 |
+
unionLiteralNumbers,
|
| 108 |
+
object,
|
| 109 |
+
inlineObject,
|
| 110 |
+
record,
|
| 111 |
+
unionTypes,
|
| 112 |
+
intersection,
|
| 113 |
+
func,
|
| 114 |
+
},
|
| 115 |
+
null,
|
| 116 |
+
2
|
| 117 |
+
)}</pre>
|
| 118 |
+
|
| 119 |
+
<h2>Children</h2>
|
| 120 |
+
{#if children}
|
| 121 |
+
{@render children()}
|
| 122 |
+
{/if}
|
| 123 |
+
|
| 124 |
+
<h2>Arg Types</h2>
|
| 125 |
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
tools/ui/node_modules/@storybook/sveltekit/node_modules/@storybook/svelte-vite/template/stories_svelte-vite-default-ts/docgen/types.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type LiteralNumbers = 100 | 1000 | 10000;
|
| 2 |
+
export type LiteralStrings = 'apple' | 'grape' | 'orange';
|
| 3 |
+
|
| 4 |
+
export enum MyEnum {
|
| 5 |
+
FOO = 'foo',
|
| 6 |
+
BAR = 'bar',
|
| 7 |
+
}
|
tools/ui/node_modules/@storybook/sveltekit/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@storybook/sveltekit",
|
| 3 |
+
"version": "10.5.6",
|
| 4 |
+
"description": "Storybook for SvelteKit: Develop, document, and test UI components in isolation",
|
| 5 |
+
"keywords": [
|
| 6 |
+
"storybook",
|
| 7 |
+
"storybook-framework",
|
| 8 |
+
"svelte",
|
| 9 |
+
"sveltekit",
|
| 10 |
+
"svelte-kit",
|
| 11 |
+
"vite",
|
| 12 |
+
"component",
|
| 13 |
+
"components"
|
| 14 |
+
],
|
| 15 |
+
"homepage": "https://github.com/storybookjs/storybook/tree/next/code/frameworks/sveltekit",
|
| 16 |
+
"bugs": {
|
| 17 |
+
"url": "https://github.com/storybookjs/storybook/issues"
|
| 18 |
+
},
|
| 19 |
+
"repository": {
|
| 20 |
+
"type": "git",
|
| 21 |
+
"url": "https://github.com/storybookjs/storybook.git",
|
| 22 |
+
"directory": "code/frameworks/sveltekit"
|
| 23 |
+
},
|
| 24 |
+
"funding": {
|
| 25 |
+
"type": "opencollective",
|
| 26 |
+
"url": "https://opencollective.com/storybook"
|
| 27 |
+
},
|
| 28 |
+
"license": "MIT",
|
| 29 |
+
"type": "module",
|
| 30 |
+
"exports": {
|
| 31 |
+
".": {
|
| 32 |
+
"types": "./dist/index.d.ts",
|
| 33 |
+
"code": "./src/index.ts",
|
| 34 |
+
"default": "./dist/index.js"
|
| 35 |
+
},
|
| 36 |
+
"./internal/MockProvider.svelte": "./static/MockProvider.svelte",
|
| 37 |
+
"./internal/mocks/app/forms": "./dist/mocks/app/forms.js",
|
| 38 |
+
"./internal/mocks/app/navigation": "./dist/mocks/app/navigation.js",
|
| 39 |
+
"./internal/mocks/app/state.svelte.js": "./static/app-state-mock.svelte.js",
|
| 40 |
+
"./internal/mocks/app/stores": "./dist/mocks/app/stores.js",
|
| 41 |
+
"./node": {
|
| 42 |
+
"types": "./dist/node/index.d.ts",
|
| 43 |
+
"code": "./src/node/index.ts",
|
| 44 |
+
"default": "./dist/node/index.js"
|
| 45 |
+
},
|
| 46 |
+
"./package.json": "./package.json",
|
| 47 |
+
"./preset": "./dist/preset.js",
|
| 48 |
+
"./preview": "./dist/preview.js",
|
| 49 |
+
"./vite-plugin": "./dist/vite-plugin.js"
|
| 50 |
+
},
|
| 51 |
+
"files": [
|
| 52 |
+
"dist/**/*",
|
| 53 |
+
"static/**/*",
|
| 54 |
+
"template/**/*",
|
| 55 |
+
"README.md",
|
| 56 |
+
"*.js",
|
| 57 |
+
"*.d.ts"
|
| 58 |
+
],
|
| 59 |
+
"dependencies": {
|
| 60 |
+
"@storybook/builder-vite": "10.5.6",
|
| 61 |
+
"@storybook/svelte": "10.5.6",
|
| 62 |
+
"@storybook/svelte-vite": "10.5.6"
|
| 63 |
+
},
|
| 64 |
+
"devDependencies": {
|
| 65 |
+
"@types/node": "^22.19.1",
|
| 66 |
+
"typescript": "^6.0.3",
|
| 67 |
+
"vite": "^7.0.4"
|
| 68 |
+
},
|
| 69 |
+
"peerDependencies": {
|
| 70 |
+
"storybook": "^10.5.6",
|
| 71 |
+
"svelte": "^5.0.0",
|
| 72 |
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
| 73 |
+
},
|
| 74 |
+
"publishConfig": {
|
| 75 |
+
"access": "public"
|
| 76 |
+
},
|
| 77 |
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae1l"
|
| 78 |
+
}
|
tools/ui/node_modules/@storybook/sveltekit/preset.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export * from './dist/preset.js';
|
tools/ui/node_modules/@storybook/sveltekit/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export * from './dist/preview.js';
|
tools/ui/node_modules/@storybook/sveltekit/static/MockProvider.svelte
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import { onMount } from 'svelte';
|
| 3 |
+
import { action } from 'storybook/actions';
|
| 4 |
+
|
| 5 |
+
import { setAfterNavigateArgument } from '@storybook/sveltekit/internal/mocks/app/navigation';
|
| 6 |
+
import { setAppStoresNavigating, setAppStoresPage, setAppStoresUpdated } from '@storybook/sveltekit/internal/mocks/app/stores';
|
| 7 |
+
|
| 8 |
+
const { svelteKitParameters = {}, children } = $props();
|
| 9 |
+
|
| 10 |
+
// Set context during component initialization - this happens before any child components
|
| 11 |
+
setAppStoresPage(svelteKitParameters?.stores?.page);
|
| 12 |
+
setAppStoresNavigating(svelteKitParameters?.stores?.navigating);
|
| 13 |
+
setAppStoresUpdated(svelteKitParameters?.stores?.updated);
|
| 14 |
+
setAfterNavigateArgument(svelteKitParameters?.navigation?.afterNavigate);
|
| 15 |
+
|
| 16 |
+
const normalizeHrefConfig = (hrefConfig) => {
|
| 17 |
+
if (typeof hrefConfig === 'function') {
|
| 18 |
+
return { callback: hrefConfig, asRegex: false };
|
| 19 |
+
}
|
| 20 |
+
return hrefConfig;
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
onMount(() => {
|
| 24 |
+
const globalClickListener = (e) => {
|
| 25 |
+
// we add a global click event listener and we check if there's a link in the composedPath
|
| 26 |
+
const path = e.composedPath();
|
| 27 |
+
const element = path.findLast((el) => el instanceof HTMLElement && el.tagName === 'A');
|
| 28 |
+
if (element && element instanceof HTMLAnchorElement) {
|
| 29 |
+
// if the element is an a-tag we get the href of the element
|
| 30 |
+
// and compare it to the hrefs-parameter set by the user
|
| 31 |
+
const to = element.getAttribute('href');
|
| 32 |
+
if (!to) {
|
| 33 |
+
return;
|
| 34 |
+
}
|
| 35 |
+
e.preventDefault();
|
| 36 |
+
const defaultActionCallback = () => action('navigate')(to, e);
|
| 37 |
+
if (!svelteKitParameters.hrefs) {
|
| 38 |
+
defaultActionCallback();
|
| 39 |
+
return;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
let callDefaultCallback = true;
|
| 43 |
+
// we loop over every href set by the user and check if the href matches
|
| 44 |
+
// if it does we call the callback provided by the user and disable the default callback
|
| 45 |
+
Object.entries(svelteKitParameters.hrefs).forEach(([href, hrefConfig]) => {
|
| 46 |
+
const { callback, asRegex } = normalizeHrefConfig(hrefConfig);
|
| 47 |
+
const isMatch = asRegex ? new RegExp(href).test(to) : to === href;
|
| 48 |
+
if (isMatch) {
|
| 49 |
+
callDefaultCallback = false;
|
| 50 |
+
callback?.(to, e);
|
| 51 |
+
}
|
| 52 |
+
});
|
| 53 |
+
if (callDefaultCallback) {
|
| 54 |
+
defaultActionCallback();
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Function that create and add listeners for the event that are emitted by the mocked
|
| 61 |
+
* functions. The event name is based on the function name
|
| 62 |
+
*
|
| 63 |
+
* Eg. storybook:goto, storybook:invalidateAll
|
| 64 |
+
*
|
| 65 |
+
* @param baseModule The base module where the function lives (navigation|forms)
|
| 66 |
+
* @param functions The list of functions in that module that emit events
|
| 67 |
+
* @param {boolean} [defaultToAction] The list of functions in that module that emit events
|
| 68 |
+
* @returns A function to remove all the listener added
|
| 69 |
+
*/
|
| 70 |
+
function createListeners(baseModule, functions, defaultToAction) {
|
| 71 |
+
// the array of every added listener, we can use this in the return function
|
| 72 |
+
// to clean them
|
| 73 |
+
const toRemove = [];
|
| 74 |
+
functions.forEach((func) => {
|
| 75 |
+
// we loop over every function and check if the user actually passed
|
| 76 |
+
// a function in sveltekit_experimental[baseModule][func] eg. sveltekit_experimental.navigation.goto
|
| 77 |
+
const hasFunction =
|
| 78 |
+
svelteKitParameters[baseModule]?.[func] &&
|
| 79 |
+
svelteKitParameters[baseModule][func] instanceof Function;
|
| 80 |
+
// if we default to an action we still add the listener (this will be the case for goto, invalidate, invalidateAll)
|
| 81 |
+
if (hasFunction || defaultToAction) {
|
| 82 |
+
// we create the listener that will just get the detail array from the custom element
|
| 83 |
+
// and call the user provided function spreading this args in...this will basically call
|
| 84 |
+
// the function that the user provide with the same arguments the function is invoked to
|
| 85 |
+
|
| 86 |
+
// eg. if it calls goto("/my-route") inside the component the function sveltekit_experimental.navigation.goto
|
| 87 |
+
// it provided to storybook will be called with "/my-route"
|
| 88 |
+
const listener = ({ detail = [] }) => {
|
| 89 |
+
const args = Array.isArray(detail) ? detail : [];
|
| 90 |
+
// if it has a function in the parameters we call that function
|
| 91 |
+
// otherwise we invoke the action
|
| 92 |
+
const fnToCall = hasFunction
|
| 93 |
+
? svelteKitParameters[baseModule][func]
|
| 94 |
+
: action(func);
|
| 95 |
+
fnToCall(...args);
|
| 96 |
+
};
|
| 97 |
+
const eventType = `storybook:${func}`;
|
| 98 |
+
toRemove.push({ eventType, listener });
|
| 99 |
+
// add the listener to window
|
| 100 |
+
window.addEventListener(eventType, listener);
|
| 101 |
+
}
|
| 102 |
+
});
|
| 103 |
+
return () => {
|
| 104 |
+
// loop over every listener added and remove them
|
| 105 |
+
toRemove.forEach(({ eventType, listener }) => {
|
| 106 |
+
window.removeEventListener(eventType, listener);
|
| 107 |
+
});
|
| 108 |
+
};
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
const removeNavigationListeners = createListeners(
|
| 112 |
+
'navigation',
|
| 113 |
+
['goto', 'invalidate', 'invalidateAll', 'pushState', 'replaceState'],
|
| 114 |
+
true
|
| 115 |
+
);
|
| 116 |
+
const removeFormsListeners = createListeners('forms', ['enhance']);
|
| 117 |
+
window.addEventListener('click', globalClickListener);
|
| 118 |
+
|
| 119 |
+
return () => {
|
| 120 |
+
window.removeEventListener('click', globalClickListener);
|
| 121 |
+
removeNavigationListeners();
|
| 122 |
+
removeFormsListeners();
|
| 123 |
+
};
|
| 124 |
+
});
|
| 125 |
+
</script>
|
| 126 |
+
|
| 127 |
+
{@render children()}
|
tools/ui/node_modules/@storybook/sveltekit/static/app-state-mock.svelte.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Inspired by the the code:
|
| 3 |
+
* {@link https://github.com/sveltejs/kit/blob/main/packages/kit/src/runtime/client/state.svelte.js}
|
| 4 |
+
*
|
| 5 |
+
* The differences:
|
| 6 |
+
*
|
| 7 |
+
* - Legacy Svelte support is not included
|
| 8 |
+
* - Not using classes (internal coding style preference)
|
| 9 |
+
*
|
| 10 |
+
* @module
|
| 11 |
+
*/
|
| 12 |
+
import { fn } from 'storybook/test';
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* @typedef {Object} App
|
| 16 |
+
* @property {Object} Error
|
| 17 |
+
* @property {string} Error.message
|
| 18 |
+
* @property {Object} Locals
|
| 19 |
+
* @property {Object} PageData
|
| 20 |
+
* @property {Object} PageState
|
| 21 |
+
* @property {Object} Platform
|
| 22 |
+
*/
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @typedef {Object} Page
|
| 26 |
+
* @property {URL} url
|
| 27 |
+
* @property {Record<string, string>} params
|
| 28 |
+
* @property {Object} route
|
| 29 |
+
* @property {string | null} route.id
|
| 30 |
+
* @property {number} status
|
| 31 |
+
* @property {App.Error | null} error
|
| 32 |
+
* @property {App.PageData & Record<string, any>} data
|
| 33 |
+
* @property {App.PageState} state
|
| 34 |
+
* @property {any} form
|
| 35 |
+
*/
|
| 36 |
+
|
| 37 |
+
const defaultStatePageValues = {
|
| 38 |
+
data: {},
|
| 39 |
+
form: null,
|
| 40 |
+
error: null,
|
| 41 |
+
params: {},
|
| 42 |
+
route: { id: null },
|
| 43 |
+
state: {},
|
| 44 |
+
status: -1,
|
| 45 |
+
url: new URL(location.origin),
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
/** @type {Page['data']} */
|
| 49 |
+
let pageData = $state.raw(defaultStatePageValues.data);
|
| 50 |
+
/** @type {Page['form']} */
|
| 51 |
+
let pageForm = $state.raw(defaultStatePageValues.form);
|
| 52 |
+
/** @type {Page['error']} */
|
| 53 |
+
let pageError = $state.raw(defaultStatePageValues.error);
|
| 54 |
+
/** @type {Page['params']} */
|
| 55 |
+
let pageParams = $state.raw(defaultStatePageValues.params);
|
| 56 |
+
/** @type {Page['route']} */
|
| 57 |
+
let pageRoute = $state.raw(defaultStatePageValues.route);
|
| 58 |
+
/** @type {Page['state']} */
|
| 59 |
+
let pageState = $state.raw(defaultStatePageValues.state);
|
| 60 |
+
/** @type {Page['status']} */
|
| 61 |
+
let pageStatus = $state.raw(defaultStatePageValues.status);
|
| 62 |
+
/** @type {Page['url']} */
|
| 63 |
+
let pageUrl = $state.raw(defaultStatePageValues.url);
|
| 64 |
+
|
| 65 |
+
/** @type {Page} */
|
| 66 |
+
export let page = {
|
| 67 |
+
get data() {
|
| 68 |
+
return pageData;
|
| 69 |
+
},
|
| 70 |
+
set data(newPageData) {
|
| 71 |
+
pageData = newPageData;
|
| 72 |
+
},
|
| 73 |
+
get form() {
|
| 74 |
+
return pageForm;
|
| 75 |
+
},
|
| 76 |
+
set form(newPageForm) {
|
| 77 |
+
pageForm = newPageForm;
|
| 78 |
+
},
|
| 79 |
+
get error() {
|
| 80 |
+
return pageError;
|
| 81 |
+
},
|
| 82 |
+
set error(newPageError) {
|
| 83 |
+
pageError = newPageError;
|
| 84 |
+
},
|
| 85 |
+
get params() {
|
| 86 |
+
return pageParams;
|
| 87 |
+
},
|
| 88 |
+
set params(newPageParams) {
|
| 89 |
+
pageParams = newPageParams;
|
| 90 |
+
},
|
| 91 |
+
get route() {
|
| 92 |
+
return pageRoute;
|
| 93 |
+
},
|
| 94 |
+
set route(newPageRoute) {
|
| 95 |
+
pageRoute = newPageRoute;
|
| 96 |
+
},
|
| 97 |
+
get state() {
|
| 98 |
+
return pageState;
|
| 99 |
+
},
|
| 100 |
+
set state(newPageState) {
|
| 101 |
+
pageState = newPageState;
|
| 102 |
+
},
|
| 103 |
+
get status() {
|
| 104 |
+
return pageStatus;
|
| 105 |
+
},
|
| 106 |
+
set status(newPageStatus) {
|
| 107 |
+
pageStatus = newPageStatus;
|
| 108 |
+
},
|
| 109 |
+
get url() {
|
| 110 |
+
return pageUrl;
|
| 111 |
+
},
|
| 112 |
+
set url(newPageUrl) {
|
| 113 |
+
pageUrl = newPageUrl;
|
| 114 |
+
},
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
export function setAppStatePage(params = {}) {
|
| 118 |
+
page.data = params.data ?? defaultStatePageValues.data;
|
| 119 |
+
page.form = params.form ?? defaultStatePageValues.form;
|
| 120 |
+
page.error = params.error ?? defaultStatePageValues.error;
|
| 121 |
+
page.params = params.params ?? defaultStatePageValues.params;
|
| 122 |
+
page.route = params.route ?? defaultStatePageValues.route;
|
| 123 |
+
page.state = params.state ?? defaultStatePageValues.state;
|
| 124 |
+
page.status = params.status ?? defaultStatePageValues.status;
|
| 125 |
+
page.url = params.url ?? defaultStatePageValues.url;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* @typedef {Object} NavigationTarget
|
| 130 |
+
* @property {Record<string, string> | null} params
|
| 131 |
+
* @property {Object} route
|
| 132 |
+
* @property {string | null} route.id
|
| 133 |
+
* @property {URL} url
|
| 134 |
+
*/
|
| 135 |
+
|
| 136 |
+
/** @typedef {'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate'} NavigationType */
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* @typedef {Object} Navigation
|
| 140 |
+
* @property {NavigationTarget | null} from
|
| 141 |
+
* @property {NavigationTarget | null} to
|
| 142 |
+
* @property {Exclude<NavigationType, 'enter'>} type
|
| 143 |
+
* @property {boolean} willUnload
|
| 144 |
+
* @property {number} [delta]
|
| 145 |
+
* @property {Promise<void>} complete
|
| 146 |
+
*/
|
| 147 |
+
|
| 148 |
+
const defaultStateNavigatingValues = {
|
| 149 |
+
from: null,
|
| 150 |
+
to: null,
|
| 151 |
+
type: null,
|
| 152 |
+
willUnload: null,
|
| 153 |
+
delta: null,
|
| 154 |
+
complete: null,
|
| 155 |
+
};
|
| 156 |
+
|
| 157 |
+
/** @type {Navigation['from'] | null} */
|
| 158 |
+
let navigatingFrom = $state.raw(defaultStateNavigatingValues.from);
|
| 159 |
+
/** @type {Navigation['to'] | null} */
|
| 160 |
+
let navigatingTo = $state.raw(defaultStateNavigatingValues.to);
|
| 161 |
+
/** @type {Navigation['type'] | null} */
|
| 162 |
+
let navigatingType = $state.raw(defaultStateNavigatingValues.type);
|
| 163 |
+
/** @type {Navigation['willUnload'] | null} */
|
| 164 |
+
let navigatingWillUnload = $state.raw(defaultStateNavigatingValues.willUnload);
|
| 165 |
+
/** @type {Navigation['delta'] | null} */
|
| 166 |
+
let navigatingDelta = $state.raw(defaultStateNavigatingValues.delta);
|
| 167 |
+
/** @type {Navigation['complete'] | null} */
|
| 168 |
+
let navigatingComplete = $state.raw(defaultStateNavigatingValues.complete);
|
| 169 |
+
|
| 170 |
+
/** @type {Navigation} */
|
| 171 |
+
export let navigating = {
|
| 172 |
+
get from() {
|
| 173 |
+
return navigatingFrom;
|
| 174 |
+
},
|
| 175 |
+
set from(newNavigatingFrom) {
|
| 176 |
+
navigatingFrom = newNavigatingFrom;
|
| 177 |
+
},
|
| 178 |
+
get to() {
|
| 179 |
+
return navigatingTo;
|
| 180 |
+
},
|
| 181 |
+
set to(newNavigatingTo) {
|
| 182 |
+
navigatingTo = newNavigatingTo;
|
| 183 |
+
},
|
| 184 |
+
get type() {
|
| 185 |
+
return navigatingType;
|
| 186 |
+
},
|
| 187 |
+
set type(newNavigatingType) {
|
| 188 |
+
navigatingType = newNavigatingType;
|
| 189 |
+
},
|
| 190 |
+
get willUnload() {
|
| 191 |
+
return navigatingWillUnload;
|
| 192 |
+
},
|
| 193 |
+
set willUnload(newNavigatingWillUnload) {
|
| 194 |
+
navigatingWillUnload = newNavigatingWillUnload;
|
| 195 |
+
},
|
| 196 |
+
get delta() {
|
| 197 |
+
return navigatingDelta;
|
| 198 |
+
},
|
| 199 |
+
set delta(newNavigatingDelta) {
|
| 200 |
+
navigatingDelta = newNavigatingDelta;
|
| 201 |
+
},
|
| 202 |
+
get complete() {
|
| 203 |
+
return navigatingComplete;
|
| 204 |
+
},
|
| 205 |
+
set complete(newNavigatingComplete) {
|
| 206 |
+
navigatingComplete = newNavigatingComplete;
|
| 207 |
+
},
|
| 208 |
+
};
|
| 209 |
+
|
| 210 |
+
export function setAppStateNavigating(params = {}) {
|
| 211 |
+
navigating.from = params.from ?? defaultStateNavigatingValues.from;
|
| 212 |
+
navigating.to = params.to ?? defaultStateNavigatingValues.to;
|
| 213 |
+
navigating.type = params.type ?? defaultStateNavigatingValues.type;
|
| 214 |
+
navigating.willUnload = params.willUnload ?? defaultStateNavigatingValues.willUnload;
|
| 215 |
+
navigating.delta = params.delta ?? defaultStateNavigatingValues.delta;
|
| 216 |
+
navigating.complete = params.complete ?? defaultStateNavigatingValues.complete;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
/** @type {boolean} */
|
| 220 |
+
let updatedCurrent = $state.raw(false);
|
| 221 |
+
|
| 222 |
+
export let updated = {
|
| 223 |
+
get current() {
|
| 224 |
+
return updatedCurrent;
|
| 225 |
+
},
|
| 226 |
+
set current(newCurrent) {
|
| 227 |
+
updatedCurrent = newCurrent;
|
| 228 |
+
},
|
| 229 |
+
check: fn(() => Promise.resolve(updatedCurrent)),
|
| 230 |
+
};
|
| 231 |
+
|
| 232 |
+
export function setAppStateUpdated(params = {}) {
|
| 233 |
+
updated.current = params.current ?? false;
|
| 234 |
+
}
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Button.stories.svelte
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script module>
|
| 2 |
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
| 3 |
+
import Button from './Button.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/Button',
|
| 9 |
+
component: Button,
|
| 10 |
+
tags: ['autodocs'],
|
| 11 |
+
argTypes: {
|
| 12 |
+
backgroundColor: { control: 'color' },
|
| 13 |
+
size: {
|
| 14 |
+
control: { type: 'select' },
|
| 15 |
+
options: ['small', 'medium', 'large'],
|
| 16 |
+
},
|
| 17 |
+
},
|
| 18 |
+
args: {
|
| 19 |
+
onclick: fn(),
|
| 20 |
+
}
|
| 21 |
+
});
|
| 22 |
+
</script>
|
| 23 |
+
|
| 24 |
+
<!-- More on writing stories with args: https://storybook.js.org/docs/writing-stories/args -->
|
| 25 |
+
<Story name="Primary" args={{ primary: true, label: 'Button' }} />
|
| 26 |
+
|
| 27 |
+
<Story name="Secondary" args={{ label: 'Button' }} />
|
| 28 |
+
|
| 29 |
+
<Story name="Large" args={{ size: 'large', label: 'Button' }} />
|
| 30 |
+
|
| 31 |
+
<Story name="Small" args={{ size: 'small', label: 'Button' }} />
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Button.svelte
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import './button.css';
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* @typedef {Object} Props
|
| 6 |
+
* @property {boolean} [primary] Is this the principal call to action on the page?
|
| 7 |
+
* @property {string} [backgroundColor] What background color to use
|
| 8 |
+
* @property {'small' | 'medium' | 'large'} [size] How large should the button be?
|
| 9 |
+
* @property {string} label Button contents
|
| 10 |
+
* @property {() => void} [onclick] The onclick event handler
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
/** @type {Props} */
|
| 14 |
+
const { primary = false, backgroundColor, size = 'medium', label, ...props } = $props();
|
| 15 |
+
|
| 16 |
+
let mode = $derived(primary ? 'storybook-button--primary' : 'storybook-button--secondary');
|
| 17 |
+
let style = $derived(backgroundColor ? `background-color: ${backgroundColor}` : '');
|
| 18 |
+
</script>
|
| 19 |
+
|
| 20 |
+
<button
|
| 21 |
+
type="button"
|
| 22 |
+
class={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
| 23 |
+
{style}
|
| 24 |
+
{...props}
|
| 25 |
+
>
|
| 26 |
+
{label}
|
| 27 |
+
</button>
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Header.stories.svelte
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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" />
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Header.svelte
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import './header.css';
|
| 3 |
+
import Button from './Button.svelte';
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* @typedef {Object} Props
|
| 7 |
+
* @property {{name: string}} [user] The user object
|
| 8 |
+
* @property {() => void} [onLogin] The login event handler
|
| 9 |
+
* @property {() => void} [onLogout] The logout event handler
|
| 10 |
+
* @property {() => void} [onCreateAccount] The account creation event handler
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
/** @type {Props} */
|
| 14 |
+
const { user, onLogin, onLogout, onCreateAccount } = $props();
|
| 15 |
+
</script>
|
| 16 |
+
|
| 17 |
+
<header>
|
| 18 |
+
<div class="storybook-header">
|
| 19 |
+
<div>
|
| 20 |
+
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
| 21 |
+
<g fill="none" fill-rule="evenodd">
|
| 22 |
+
<path
|
| 23 |
+
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
| 24 |
+
fill="#FFF"
|
| 25 |
+
/>
|
| 26 |
+
<path
|
| 27 |
+
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
| 28 |
+
fill="#555AB9"
|
| 29 |
+
/>
|
| 30 |
+
<path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
|
| 31 |
+
</g>
|
| 32 |
+
</svg>
|
| 33 |
+
<h1>Acme</h1>
|
| 34 |
+
</div>
|
| 35 |
+
<div>
|
| 36 |
+
{#if user}
|
| 37 |
+
<span class="welcome">
|
| 38 |
+
Welcome, <b>{user.name}</b>!
|
| 39 |
+
</span>
|
| 40 |
+
<Button size="small" onclick={onLogout} label="Log out" />
|
| 41 |
+
{:else}
|
| 42 |
+
<Button size="small" onclick={onLogin} label="Log in" />
|
| 43 |
+
<Button primary size="small" onclick={onCreateAccount} label="Sign up" />
|
| 44 |
+
{/if}
|
| 45 |
+
</div>
|
| 46 |
+
</div>
|
| 47 |
+
</header>
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Page.stories.svelte
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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" />
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/js/Page.svelte
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import './page.css';
|
| 3 |
+
import Header from './Header.svelte';
|
| 4 |
+
|
| 5 |
+
let user = $state();
|
| 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>
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Button.stories.svelte
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script module>
|
| 2 |
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
| 3 |
+
import Button from './Button.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/Button',
|
| 9 |
+
component: Button,
|
| 10 |
+
tags: ['autodocs'],
|
| 11 |
+
argTypes: {
|
| 12 |
+
backgroundColor: { control: 'color' },
|
| 13 |
+
size: {
|
| 14 |
+
control: { type: 'select' },
|
| 15 |
+
options: ['small', 'medium', 'large'],
|
| 16 |
+
},
|
| 17 |
+
},
|
| 18 |
+
args: {
|
| 19 |
+
onclick: fn(),
|
| 20 |
+
}
|
| 21 |
+
});
|
| 22 |
+
</script>
|
| 23 |
+
|
| 24 |
+
<!-- More on writing stories with args: https://storybook.js.org/docs/writing-stories/args -->
|
| 25 |
+
<Story name="Primary" args={{ primary: true, label: 'Button' }} />
|
| 26 |
+
|
| 27 |
+
<Story name="Secondary" args={{ label: 'Button' }} />
|
| 28 |
+
|
| 29 |
+
<Story name="Large" args={{ size: 'large', label: 'Button' }} />
|
| 30 |
+
|
| 31 |
+
<Story name="Small" args={{ size: 'small', label: 'Button' }} />
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Button.svelte
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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, ...props }: Props = $props();
|
| 18 |
+
|
| 19 |
+
let mode = $derived(primary ? 'storybook-button--primary' : 'storybook-button--secondary');
|
| 20 |
+
let style = $derived(backgroundColor ? `background-color: ${backgroundColor}` : '');
|
| 21 |
+
</script>
|
| 22 |
+
|
| 23 |
+
<button
|
| 24 |
+
type="button"
|
| 25 |
+
class={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
| 26 |
+
{style}
|
| 27 |
+
{...props}
|
| 28 |
+
>
|
| 29 |
+
{label}
|
| 30 |
+
</button>
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Header.stories.svelte
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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" />
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Header.svelte
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import './header.css';
|
| 3 |
+
import Button from './Button.svelte';
|
| 4 |
+
|
| 5 |
+
interface Props {
|
| 6 |
+
user?: { name: string };
|
| 7 |
+
onLogin?: () => void;
|
| 8 |
+
onLogout?: () => void;
|
| 9 |
+
onCreateAccount?: () => void;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
const { user, onLogin, onLogout, onCreateAccount }: Props = $props();
|
| 13 |
+
</script>
|
| 14 |
+
|
| 15 |
+
<header>
|
| 16 |
+
<div class="storybook-header">
|
| 17 |
+
<div>
|
| 18 |
+
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
| 19 |
+
<g fill="none" fill-rule="evenodd">
|
| 20 |
+
<path
|
| 21 |
+
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
| 22 |
+
fill="#FFF"
|
| 23 |
+
/>
|
| 24 |
+
<path
|
| 25 |
+
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
| 26 |
+
fill="#555AB9"
|
| 27 |
+
/>
|
| 28 |
+
<path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
|
| 29 |
+
</g>
|
| 30 |
+
</svg>
|
| 31 |
+
<h1>Acme</h1>
|
| 32 |
+
</div>
|
| 33 |
+
<div>
|
| 34 |
+
{#if user}
|
| 35 |
+
<span class="welcome">
|
| 36 |
+
Welcome, <b>{user.name}</b>!
|
| 37 |
+
</span>
|
| 38 |
+
<Button size="small" onclick={onLogout} label="Log out" />
|
| 39 |
+
{:else}
|
| 40 |
+
<Button size="small" onclick={onLogin} label="Log in" />
|
| 41 |
+
<Button primary size="small" onclick={onCreateAccount} label="Sign up" />
|
| 42 |
+
{/if}
|
| 43 |
+
</div>
|
| 44 |
+
</div>
|
| 45 |
+
</header>
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Page.stories.svelte
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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" />
|
tools/ui/node_modules/@storybook/sveltekit/template/cli/ts/Page.svelte
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Environment.svelte
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import { browser, dev, building, version } from '$app/environment';
|
| 3 |
+
</script>
|
| 4 |
+
|
| 5 |
+
<div data-testid="browser">{browser}</div>
|
| 6 |
+
<div data-testid="dev">{dev}</div>
|
| 7 |
+
<div data-testid="building">{building}</div>
|
| 8 |
+
<div data-testid="version" data-chromatic="ignore">{version}</div>
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Forms.svelte
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import { enhance } from '$app/forms';
|
| 3 |
+
</script>
|
| 4 |
+
|
| 5 |
+
<form use:enhance method="post">
|
| 6 |
+
<button>enhance</button>
|
| 7 |
+
</form>
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Hrefs.svelte
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<ul>
|
| 2 |
+
<li><a href="/basic-href">Link to <code>/basic-href</code></a></li>
|
| 3 |
+
<li>
|
| 4 |
+
<a href="/deep/nested/link?with=true&multiple-params=200#and-an-id"
|
| 5 |
+
>Link to <code>/deep/nested/link?with=true&multiple-params=200#and-an-id</code></a
|
| 6 |
+
>
|
| 7 |
+
</li>
|
| 8 |
+
</ul>
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Navigation.svelte
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import {
|
| 3 |
+
goto,
|
| 4 |
+
invalidate,
|
| 5 |
+
invalidateAll,
|
| 6 |
+
afterNavigate,
|
| 7 |
+
replaceState,
|
| 8 |
+
pushState,
|
| 9 |
+
} from '$app/navigation';
|
| 10 |
+
|
| 11 |
+
const { afterNavigateFn } = $props();
|
| 12 |
+
|
| 13 |
+
afterNavigate(afterNavigateFn);
|
| 14 |
+
</script>
|
| 15 |
+
|
| 16 |
+
<button
|
| 17 |
+
on:click={() => {
|
| 18 |
+
goto('/storybook-goto');
|
| 19 |
+
}}>goto</button
|
| 20 |
+
>
|
| 21 |
+
|
| 22 |
+
<button
|
| 23 |
+
on:click={() => {
|
| 24 |
+
invalidate('/storybook-invalidate');
|
| 25 |
+
}}>invalidate</button
|
| 26 |
+
>
|
| 27 |
+
|
| 28 |
+
<button
|
| 29 |
+
on:click={() => {
|
| 30 |
+
invalidateAll();
|
| 31 |
+
}}>invalidateAll</button
|
| 32 |
+
>
|
| 33 |
+
|
| 34 |
+
<button
|
| 35 |
+
on:click={() => {
|
| 36 |
+
pushState('/storybook-push-state', {});
|
| 37 |
+
}}>pushState</button
|
| 38 |
+
>
|
| 39 |
+
|
| 40 |
+
<button
|
| 41 |
+
on:click={() => {
|
| 42 |
+
replaceState('/storybook-replace-state', {});
|
| 43 |
+
}}>replaceState</button
|
| 44 |
+
>
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Paths.svelte
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import { assets, base } from "$app/paths";
|
| 3 |
+
</script>
|
| 4 |
+
|
| 5 |
+
<div data-testid="assets">{assets}</div>
|
| 6 |
+
<div data-testid="base">{base}</div>
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/State.svelte
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import { page, navigating, updated } from '$app/state';
|
| 3 |
+
|
| 4 |
+
updated.check();
|
| 5 |
+
</script>
|
| 6 |
+
|
| 7 |
+
<h1>$app/state</h1>
|
| 8 |
+
|
| 9 |
+
<h2>page</h2>
|
| 10 |
+
<pre>{JSON.stringify(page, null, 2)}</pre>
|
| 11 |
+
|
| 12 |
+
<h2>navigating</h2>
|
| 13 |
+
<pre>{JSON.stringify(navigating, null, 2)}</pre>
|
| 14 |
+
|
| 15 |
+
<h2>updated</h2>
|
| 16 |
+
<pre>{JSON.stringify(updated, null, 2)}</pre>
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/Stores.svelte
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
import { page, navigating, updated, getStores } from '$app/stores';
|
| 3 |
+
|
| 4 |
+
let { navigating: navigatingStore, page: pageStore, updated: updatedStore } = getStores();
|
| 5 |
+
|
| 6 |
+
updated.check();
|
| 7 |
+
</script>
|
| 8 |
+
|
| 9 |
+
<p>Directly importing</p>
|
| 10 |
+
<pre>{JSON.stringify($page, null, 2)}</pre>
|
| 11 |
+
<pre>{JSON.stringify($navigating, null, 2)}</pre>
|
| 12 |
+
<pre>{JSON.stringify($updated, null, 2)}</pre>
|
| 13 |
+
|
| 14 |
+
<p>With getStores</p>
|
| 15 |
+
<pre>{JSON.stringify($pageStore, null, 2)}</pre>
|
| 16 |
+
<pre>{JSON.stringify($navigatingStore, null, 2)}</pre>
|
| 17 |
+
<pre>{JSON.stringify($updatedStore, null, 2)}</pre>
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/environment.stories.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Environment from './Environment.svelte';
|
| 2 |
+
|
| 3 |
+
export default {
|
| 4 |
+
title: 'stories/frameworks/sveltekit/modules/environment',
|
| 5 |
+
component: Environment,
|
| 6 |
+
};
|
| 7 |
+
|
| 8 |
+
export const Default = {};
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/forms.stories.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { expect, fn, within } from 'storybook/test';
|
| 2 |
+
|
| 3 |
+
import Forms from './Forms.svelte';
|
| 4 |
+
|
| 5 |
+
export default {
|
| 6 |
+
title: 'stories/frameworks/sveltekit/modules/forms',
|
| 7 |
+
component: Forms,
|
| 8 |
+
};
|
| 9 |
+
|
| 10 |
+
const enhance = fn();
|
| 11 |
+
|
| 12 |
+
export const Enhance = {
|
| 13 |
+
async play({ canvasElement }) {
|
| 14 |
+
const canvas = within(canvasElement);
|
| 15 |
+
const button = canvas.getByText('enhance');
|
| 16 |
+
button.click();
|
| 17 |
+
expect(enhance).toHaveBeenCalled();
|
| 18 |
+
},
|
| 19 |
+
parameters: {
|
| 20 |
+
sveltekit_experimental: {
|
| 21 |
+
forms: {
|
| 22 |
+
enhance,
|
| 23 |
+
},
|
| 24 |
+
},
|
| 25 |
+
},
|
| 26 |
+
};
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/hrefs.stories.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { expect, fn, within } from 'storybook/test';
|
| 2 |
+
|
| 3 |
+
import Hrefs from './Hrefs.svelte';
|
| 4 |
+
|
| 5 |
+
export default {
|
| 6 |
+
title: 'stories/frameworks/sveltekit/modules/hrefs',
|
| 7 |
+
component: Hrefs,
|
| 8 |
+
};
|
| 9 |
+
|
| 10 |
+
export const DefaultActions = {
|
| 11 |
+
async play({ canvasElement }) {
|
| 12 |
+
const canvas = within(canvasElement);
|
| 13 |
+
|
| 14 |
+
const initialUrl = window.location.toString();
|
| 15 |
+
|
| 16 |
+
const basicHref = canvas.getByText('/basic-href');
|
| 17 |
+
basicHref.click();
|
| 18 |
+
|
| 19 |
+
const complexHref = canvas.getByText(
|
| 20 |
+
'/deep/nested/link?with=true&multiple-params=200#and-an-id'
|
| 21 |
+
);
|
| 22 |
+
complexHref.click();
|
| 23 |
+
|
| 24 |
+
const finalUrl = window.location.toString();
|
| 25 |
+
expect(finalUrl).toBe(initialUrl);
|
| 26 |
+
},
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
const basicStringMatch = fn();
|
| 30 |
+
const noMatch = fn();
|
| 31 |
+
const exactStringMatch = fn();
|
| 32 |
+
const regexMatch = fn();
|
| 33 |
+
|
| 34 |
+
export const Callbacks = {
|
| 35 |
+
parameters: {
|
| 36 |
+
sveltekit_experimental: {
|
| 37 |
+
hrefs: {
|
| 38 |
+
'/basic-href': basicStringMatch,
|
| 39 |
+
'/basic': noMatch,
|
| 40 |
+
'/deep/nested/link?with=true&multiple-params=200#and-an-id': exactStringMatch,
|
| 41 |
+
'nested/link\\?with': { callback: regexMatch, asRegex: true },
|
| 42 |
+
},
|
| 43 |
+
},
|
| 44 |
+
},
|
| 45 |
+
play: async (ctx) => {
|
| 46 |
+
await DefaultActions.play(ctx);
|
| 47 |
+
expect(basicStringMatch).toHaveBeenCalledTimes(1);
|
| 48 |
+
expect(noMatch).not.toHaveBeenCalled();
|
| 49 |
+
expect(exactStringMatch).toHaveBeenCalledTimes(1);
|
| 50 |
+
expect(regexMatch).toHaveBeenCalledTimes(1);
|
| 51 |
+
},
|
| 52 |
+
};
|
tools/ui/node_modules/@storybook/sveltekit/template/stories_svelte-kit-skeleton-ts/modules/navigation.stories.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { expect, fn, within } from 'storybook/test';
|
| 2 |
+
|
| 3 |
+
import Navigation from './Navigation.svelte';
|
| 4 |
+
|
| 5 |
+
export default {
|
| 6 |
+
title: 'stories/frameworks/sveltekit/modules/navigation',
|
| 7 |
+
component: Navigation,
|
| 8 |
+
};
|
| 9 |
+
|
| 10 |
+
const goto = fn();
|
| 11 |
+
|
| 12 |
+
export const Goto = {
|
| 13 |
+
async play({ canvasElement }) {
|
| 14 |
+
const canvas = within(canvasElement);
|
| 15 |
+
const button = canvas.getByText('goto');
|
| 16 |
+
button.click();
|
| 17 |
+
expect(goto).toHaveBeenCalledWith('/storybook-goto');
|
| 18 |
+
},
|
| 19 |
+
parameters: {
|
| 20 |
+
sveltekit_experimental: {
|
| 21 |
+
navigation: {
|
| 22 |
+
goto,
|
| 23 |
+
},
|
| 24 |
+
},
|
| 25 |
+
},
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
const replaceState = fn();
|
| 29 |
+
|
| 30 |
+
export const ReplaceState = {
|
| 31 |
+
async play({ canvasElement }) {
|
| 32 |
+
const canvas = within(canvasElement);
|
| 33 |
+
const button = canvas.getByText('replaceState');
|
| 34 |
+
button.click();
|
| 35 |
+
expect(replaceState).toHaveBeenCalledWith('/storybook-replace-state', {});
|
| 36 |
+
},
|
| 37 |
+
parameters: {
|
| 38 |
+
sveltekit_experimental: {
|
| 39 |
+
navigation: {
|
| 40 |
+
replaceState,
|
| 41 |
+
},
|
| 42 |
+
},
|
| 43 |
+
},
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
const pushState = fn();
|
| 47 |
+
|
| 48 |
+
export const PushState = {
|
| 49 |
+
async play({ canvasElement }) {
|
| 50 |
+
const canvas = within(canvasElement);
|
| 51 |
+
const button = canvas.getByText('pushState');
|
| 52 |
+
button.click();
|
| 53 |
+
expect(pushState).toHaveBeenCalledWith('/storybook-push-state', {});
|
| 54 |
+
},
|
| 55 |
+
parameters: {
|
| 56 |
+
sveltekit_experimental: {
|
| 57 |
+
navigation: {
|
| 58 |
+
pushState,
|
| 59 |
+
},
|
| 60 |
+
},
|
| 61 |
+
},
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
export const DefaultActions = {};
|
| 65 |
+
|
| 66 |
+
const invalidate = fn();
|
| 67 |
+
|
| 68 |
+
export const Invalidate = {
|
| 69 |
+
async play({ canvasElement }) {
|
| 70 |
+
const canvas = within(canvasElement);
|
| 71 |
+
const button = canvas.getByText('invalidate', { exact: true });
|
| 72 |
+
button.click();
|
| 73 |
+
expect(invalidate).toHaveBeenCalledWith('/storybook-invalidate');
|
| 74 |
+
},
|
| 75 |
+
parameters: {
|
| 76 |
+
sveltekit_experimental: {
|
| 77 |
+
navigation: {
|
| 78 |
+
invalidate,
|
| 79 |
+
},
|
| 80 |
+
},
|
| 81 |
+
},
|
| 82 |
+
};
|
| 83 |
+
|
| 84 |
+
const invalidateAll = fn();
|
| 85 |
+
|
| 86 |
+
export const InvalidateAll = {
|
| 87 |
+
async play({ canvasElement }) {
|
| 88 |
+
const canvas = within(canvasElement);
|
| 89 |
+
const button = canvas.getByText('invalidateAll');
|
| 90 |
+
button.click();
|
| 91 |
+
expect(invalidateAll).toHaveBeenCalledWith();
|
| 92 |
+
},
|
| 93 |
+
parameters: {
|
| 94 |
+
sveltekit_experimental: {
|
| 95 |
+
navigation: {
|
| 96 |
+
invalidateAll,
|
| 97 |
+
},
|
| 98 |
+
},
|
| 99 |
+
},
|
| 100 |
+
};
|
| 101 |
+
|
| 102 |
+
const afterNavigateFn = fn();
|
| 103 |
+
|
| 104 |
+
export const AfterNavigate = {
|
| 105 |
+
async play() {
|
| 106 |
+
expect(afterNavigateFn).toHaveBeenCalledWith({ test: 'passed' });
|
| 107 |
+
},
|
| 108 |
+
args: {
|
| 109 |
+
afterNavigateFn,
|
| 110 |
+
},
|
| 111 |
+
parameters: {
|
| 112 |
+
sveltekit_experimental: {
|
| 113 |
+
navigation: {
|
| 114 |
+
afterNavigate: {
|
| 115 |
+
test: 'passed',
|
| 116 |
+
},
|
| 117 |
+
},
|
| 118 |
+
},
|
| 119 |
+
},
|
| 120 |
+
};
|