@storybook/sveltekit 8.0.0-alpha.1 → 8.0.0-alpha.3
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/README.md +0 -10
- package/dist/{index-76c82265.d.ts → index-82e4147f.d.ts} +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/preset.d.ts +1 -1
- package/package.json +6 -6
- package/template/stories_svelte-kit-prerelease-ts/forms.stories.js +26 -0
- package/template/stories_svelte-kit-prerelease-ts/hrefs.stories.js +53 -0
- package/template/stories_svelte-kit-prerelease-ts/navigation.stories.js +84 -0
- package/template/stories_svelte-kit-prerelease-ts/stores.stories.js +116 -0
- package/template/stories_svelte-kit-prerelease-ts/ts-docs.stories.js +12 -0
package/README.md
CHANGED
|
@@ -185,16 +185,6 @@ export const MyStory = {
|
|
|
185
185
|
|
|
186
186
|
You'll get this error when manually upgrading from 6.5 to 7.0. You need to remove the `svelteOptions` property in `.storybook/main.js`, as that is not supported by Storybook 7.0 + SvelteKit. The property is also not necessary anymore because the Vite and Svelte configurations are loaded automatically in Storybook 7.0.
|
|
187
187
|
|
|
188
|
-
### Error: `Cannot read properties of undefined (reading 'disable_scroll_handling')` in preview
|
|
189
|
-
|
|
190
|
-
> Some stories don't load, instead they show the following error in the preview:
|
|
191
|
-
>
|
|
192
|
-
> ```
|
|
193
|
-
> Cannot read properties of undefined (reading 'disable_scroll_handling')
|
|
194
|
-
> ```
|
|
195
|
-
|
|
196
|
-
You'll experience this if anything in your story is importing from `$app/forms` or `$app/navigation`, which is currently not supported. To get around this, separate your component into a shallow parent component that imports what's needed and passes it to a child component via props. This way you can write stories for your child component and mock any of the necessary modules by passing props in.
|
|
197
|
-
|
|
198
188
|
## Acknowledgements
|
|
199
189
|
|
|
200
190
|
Integrating with SvelteKit would not have been possible if it weren't for the fantastic efforts by the Svelte core team - especially [Ben McCann](https://twitter.com/benjaminmccann) - to make integrations with the wider ecosystem possible.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { F as FrameworkOptions, H as HrefConfig, N as NormalizedHrefConfig, S as StorybookConfig, a as SvelteKitParameters } from './index-
|
|
1
|
+
export { F as FrameworkOptions, H as HrefConfig, N as NormalizedHrefConfig, S as StorybookConfig, a as SvelteKitParameters } from './index-82e4147f.js';
|
|
2
2
|
import '@storybook/builder-vite';
|
|
3
3
|
import 'file-system-cache';
|
|
4
4
|
import '@babel/core';
|
package/dist/preset.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/sveltekit",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.3",
|
|
4
4
|
"description": "Storybook for SvelteKit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@storybook/addon-actions": "8.0.0-alpha.
|
|
57
|
-
"@storybook/builder-vite": "8.0.0-alpha.
|
|
58
|
-
"@storybook/svelte": "8.0.0-alpha.
|
|
59
|
-
"@storybook/svelte-vite": "8.0.0-alpha.
|
|
56
|
+
"@storybook/addon-actions": "8.0.0-alpha.3",
|
|
57
|
+
"@storybook/builder-vite": "8.0.0-alpha.3",
|
|
58
|
+
"@storybook/svelte": "8.0.0-alpha.3",
|
|
59
|
+
"@storybook/svelte-vite": "8.0.0-alpha.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/node": "^18.0.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"vite": "^4.0.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"svelte": "^
|
|
67
|
+
"svelte": "^4.0.0 || ^5.0.0-next.16",
|
|
68
68
|
"vite": "^4.0.0"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { expect, fn, within } from '@storybook/test';
|
|
2
|
+
import Forms from './Forms.svelte';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'stories/sveltekit/modules/forms',
|
|
6
|
+
component: Forms,
|
|
7
|
+
tags: ['autodocs'],
|
|
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
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { expect, fn, within } from '@storybook/test';
|
|
2
|
+
import Hrefs from './Hrefs.svelte';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'stories/sveltekit/modules/hrefs',
|
|
6
|
+
component: Hrefs,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const DefaultActions = {
|
|
11
|
+
async play({ canvasElement }) {
|
|
12
|
+
const canvas = within(canvasElement);
|
|
13
|
+
// eslint-disable-next-line no-undef
|
|
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
|
+
// eslint-disable-next-line no-undef
|
|
25
|
+
const finalUrl = window.location.toString();
|
|
26
|
+
expect(finalUrl).toBe(initialUrl);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const basicStringMatch = fn();
|
|
31
|
+
const noMatch = fn();
|
|
32
|
+
const exactStringMatch = fn();
|
|
33
|
+
const regexMatch = fn();
|
|
34
|
+
|
|
35
|
+
export const Callbacks = {
|
|
36
|
+
parameters: {
|
|
37
|
+
sveltekit_experimental: {
|
|
38
|
+
hrefs: {
|
|
39
|
+
'/basic-href': basicStringMatch,
|
|
40
|
+
'/basic': noMatch,
|
|
41
|
+
'/deep/nested/link?with=true&multiple-params=200#and-an-id': exactStringMatch,
|
|
42
|
+
'nested/link\\?with': { callback: regexMatch, asRegex: true },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
play: async (ctx) => {
|
|
47
|
+
await DefaultActions.play(ctx);
|
|
48
|
+
expect(basicStringMatch).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(noMatch).not.toHaveBeenCalled();
|
|
50
|
+
expect(exactStringMatch).toHaveBeenCalledTimes(1);
|
|
51
|
+
expect(regexMatch).toHaveBeenCalledTimes(1);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { expect, fn, within } from '@storybook/test';
|
|
2
|
+
import Navigation from './Navigation.svelte';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'stories/sveltekit/modules/navigation',
|
|
6
|
+
component: Navigation,
|
|
7
|
+
tags: ['autodocs'],
|
|
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
|
+
export const DefaultActions = {};
|
|
29
|
+
|
|
30
|
+
const invalidate = fn();
|
|
31
|
+
|
|
32
|
+
export const Invalidate = {
|
|
33
|
+
async play({ canvasElement }) {
|
|
34
|
+
const canvas = within(canvasElement);
|
|
35
|
+
const button = canvas.getByText('invalidate', { exact: true });
|
|
36
|
+
button.click();
|
|
37
|
+
expect(invalidate).toHaveBeenCalledWith('/storybook-invalidate');
|
|
38
|
+
},
|
|
39
|
+
parameters: {
|
|
40
|
+
sveltekit_experimental: {
|
|
41
|
+
navigation: {
|
|
42
|
+
invalidate,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const invalidateAll = fn();
|
|
49
|
+
|
|
50
|
+
export const InvalidateAll = {
|
|
51
|
+
async play({ canvasElement }) {
|
|
52
|
+
const canvas = within(canvasElement);
|
|
53
|
+
const button = canvas.getByText('invalidateAll');
|
|
54
|
+
button.click();
|
|
55
|
+
expect(invalidateAll).toHaveBeenCalledWith();
|
|
56
|
+
},
|
|
57
|
+
parameters: {
|
|
58
|
+
sveltekit_experimental: {
|
|
59
|
+
navigation: {
|
|
60
|
+
invalidateAll,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const afterNavigateFn = fn();
|
|
67
|
+
|
|
68
|
+
export const AfterNavigate = {
|
|
69
|
+
async play() {
|
|
70
|
+
expect(afterNavigateFn).toHaveBeenCalledWith({ test: 'passed' });
|
|
71
|
+
},
|
|
72
|
+
args: {
|
|
73
|
+
afterNavigateFn,
|
|
74
|
+
},
|
|
75
|
+
parameters: {
|
|
76
|
+
sveltekit_experimental: {
|
|
77
|
+
navigation: {
|
|
78
|
+
afterNavigate: {
|
|
79
|
+
test: 'passed',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import Stores from './Stores.svelte';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'stories/sveltekit/modules/stores',
|
|
5
|
+
component: Stores,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const AllUndefined = {};
|
|
10
|
+
|
|
11
|
+
export const PageStore = {
|
|
12
|
+
parameters: {
|
|
13
|
+
sveltekit_experimental: {
|
|
14
|
+
stores: {
|
|
15
|
+
page: {
|
|
16
|
+
data: {
|
|
17
|
+
test: 'passed',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const NavigatingStore = {
|
|
26
|
+
parameters: {
|
|
27
|
+
sveltekit_experimental: {
|
|
28
|
+
stores: {
|
|
29
|
+
navigating: {
|
|
30
|
+
route: {
|
|
31
|
+
id: '/storybook',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const UpdatedStore = {
|
|
40
|
+
parameters: {
|
|
41
|
+
sveltekit_experimental: {
|
|
42
|
+
stores: {
|
|
43
|
+
updated: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const PageAndNavigatingStore = {
|
|
50
|
+
parameters: {
|
|
51
|
+
sveltekit_experimental: {
|
|
52
|
+
stores: {
|
|
53
|
+
page: {
|
|
54
|
+
data: {
|
|
55
|
+
test: 'passed',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
navigating: {
|
|
59
|
+
route: {
|
|
60
|
+
id: '/storybook',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const PageAndUpdatedStore = {
|
|
69
|
+
parameters: {
|
|
70
|
+
sveltekit_experimental: {
|
|
71
|
+
stores: {
|
|
72
|
+
page: {
|
|
73
|
+
data: {
|
|
74
|
+
test: 'passed',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
updated: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const NavigatingAndUpdatedStore = {
|
|
84
|
+
parameters: {
|
|
85
|
+
sveltekit_experimental: {
|
|
86
|
+
stores: {
|
|
87
|
+
navigating: {
|
|
88
|
+
route: {
|
|
89
|
+
id: '/storybook',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
updated: true,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const AllThreeStores = {
|
|
99
|
+
parameters: {
|
|
100
|
+
sveltekit_experimental: {
|
|
101
|
+
stores: {
|
|
102
|
+
page: {
|
|
103
|
+
data: {
|
|
104
|
+
test: 'passed',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
navigating: {
|
|
108
|
+
route: {
|
|
109
|
+
id: '/storybook',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
updated: true,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|