@storybook/svelte-vite 9.0.0-alpha.13 → 9.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/template/stories_svelte-vite-default-js/docgen/jsdoc.stories.js +17 -0
- package/template/stories_svelte-vite-default-js/docgen/jsdoc.svelte +92 -0
- package/template/stories_svelte-vite-default-ts/docgen/jsdoc.stories.js +17 -0
- package/template/stories_svelte-vite-default-ts/docgen/jsdoc.svelte +91 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-inline-prop-types.stories.ts +16 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-inline-prop-types.svelte +103 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-legacy.stories.ts +16 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-legacy.svelte +98 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-referenced-prop-types.stories.ts +16 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-referenced-prop-types.svelte +107 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts.stories.ts +16 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts.svelte +125 -0
- package/template/cli/js/Button.stories.js +0 -43
- package/template/cli/js/Button.svelte +0 -36
- package/template/cli/js/Header.stories.js +0 -22
- package/template/cli/js/Header.svelte +0 -52
- package/template/cli/js/Page.stories.js +0 -28
- package/template/cli/js/Page.svelte +0 -70
- package/template/cli/svelte-5-js/Button.stories.svelte +0 -31
- package/template/cli/svelte-5-js/Button.svelte +0 -26
- package/template/cli/svelte-5-js/Header.stories.svelte +0 -26
- package/template/cli/svelte-5-js/Header.svelte +0 -47
- package/template/cli/svelte-5-js/Page.stories.svelte +0 -30
- package/template/cli/svelte-5-js/Page.svelte +0 -70
- package/template/cli/svelte-5-ts-3-8/Button.stories.svelte +0 -31
- package/template/cli/svelte-5-ts-3-8/Button.svelte +0 -29
- package/template/cli/svelte-5-ts-3-8/Header.stories.svelte +0 -26
- package/template/cli/svelte-5-ts-3-8/Header.svelte +0 -45
- package/template/cli/svelte-5-ts-3-8/Page.stories.svelte +0 -30
- package/template/cli/svelte-5-ts-3-8/Page.svelte +0 -70
- package/template/cli/svelte-5-ts-4-9/Button.stories.svelte +0 -31
- package/template/cli/svelte-5-ts-4-9/Button.svelte +0 -29
- package/template/cli/svelte-5-ts-4-9/Header.stories.svelte +0 -26
- package/template/cli/svelte-5-ts-4-9/Header.svelte +0 -45
- package/template/cli/svelte-5-ts-4-9/Page.stories.svelte +0 -30
- package/template/cli/svelte-5-ts-4-9/Page.svelte +0 -70
- package/template/cli/ts-4-9/Button.stories.ts +0 -48
- package/template/cli/ts-4-9/Button.svelte +0 -34
- package/template/cli/ts-4-9/Header.stories.ts +0 -27
- package/template/cli/ts-4-9/Header.svelte +0 -52
- package/template/cli/ts-4-9/Page.stories.ts +0 -33
- package/template/cli/ts-4-9/Page.svelte +0 -70
- package/template/stories_svelte-vite-default-ts/DocsTS.svelte +0 -97
- package/template/stories_svelte-vite-default-ts/docs-ts.stories.js +0 -10
- /package/template/stories_svelte-vite-default-ts/{types.ts → docgen/types.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/svelte-vite",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.14",
|
|
4
4
|
"description": "Storybook for Svelte and Vite: Develop Svelte components in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"prep": "jiti ../../../scripts/prepare/bundle.ts"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@storybook/builder-vite": "9.0.0-alpha.
|
|
58
|
-
"@storybook/svelte": "9.0.0-alpha.
|
|
57
|
+
"@storybook/builder-vite": "9.0.0-alpha.14",
|
|
58
|
+
"@storybook/svelte": "9.0.0-alpha.14",
|
|
59
59
|
"magic-string": "^0.30.0",
|
|
60
60
|
"svelte-preprocess": "^5.1.1",
|
|
61
61
|
"svelte2tsx": "^0.7.35",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@sveltejs/vite-plugin-svelte": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0",
|
|
75
|
-
"storybook": "^9.0.0-alpha.
|
|
76
|
-
"svelte": "^
|
|
75
|
+
"storybook": "^9.0.0-alpha.14",
|
|
76
|
+
"svelte": "^5.0.0",
|
|
77
77
|
"vite": "^5.0.0 || ^6.0.0"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
@@ -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 = {};
|
|
@@ -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>
|
|
@@ -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 = {};
|
|
@@ -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>
|
|
@@ -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 = {};
|
|
@@ -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>
|
|
@@ -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 = {};
|
|
@@ -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>
|
|
@@ -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 = {};
|
|
@@ -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>
|
|
@@ -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 = {};
|