@storybook/sveltekit 9.0.0-alpha.2 → 9.0.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/{chunk-REI2Y3HY.mjs → chunk-UUT6FZ4K.mjs} +1 -1
  2. package/dist/index.d.ts +2 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.mjs +3 -2
  5. package/dist/preview.js +1 -1
  6. package/dist/preview.mjs +1 -1
  7. package/package.json +10 -10
  8. package/template/cli/js/Button.stories.svelte +31 -0
  9. package/template/cli/js/Button.svelte +27 -0
  10. package/template/cli/js/Header.stories.svelte +26 -0
  11. package/template/cli/js/Header.svelte +47 -0
  12. package/template/cli/js/Page.stories.svelte +30 -0
  13. package/template/cli/js/Page.svelte +70 -0
  14. package/template/cli/ts/Button.stories.svelte +31 -0
  15. package/template/cli/ts/Button.svelte +30 -0
  16. package/template/cli/ts/Header.stories.svelte +26 -0
  17. package/template/cli/ts/Header.svelte +45 -0
  18. package/template/cli/ts/Page.stories.svelte +30 -0
  19. package/template/cli/ts/Page.svelte +70 -0
  20. package/template/stories_svelte-kit-skeleton-ts/modules/Environment.svelte +8 -0
  21. package/template/stories_svelte-kit-skeleton-ts/modules/Forms.svelte +7 -0
  22. package/template/stories_svelte-kit-skeleton-ts/modules/Hrefs.svelte +8 -0
  23. package/template/stories_svelte-kit-skeleton-ts/modules/Navigation.svelte +37 -0
  24. package/template/stories_svelte-kit-skeleton-ts/modules/Paths.svelte +6 -0
  25. package/template/stories_svelte-kit-skeleton-ts/modules/Stores.svelte +17 -0
  26. package/template/stories_svelte-kit-skeleton-ts/modules/environment.stories.js +8 -0
  27. package/template/{stories_svelte-kit-prerelease-ts → stories_svelte-kit-skeleton-ts/modules}/forms.stories.js +2 -3
  28. package/template/{stories_svelte-kit-prerelease-ts → stories_svelte-kit-skeleton-ts/modules}/hrefs.stories.js +2 -3
  29. package/template/{stories_svelte-kit-skeleton-js → stories_svelte-kit-skeleton-ts/modules}/navigation.stories.js +2 -3
  30. package/template/stories_svelte-kit-skeleton-ts/modules/paths.stories.js +8 -0
  31. package/template/stories_svelte-kit-skeleton-ts/{stores.stories.js → modules/stores.stories.js} +1 -2
  32. package/template/stories_svelte-kit-prerelease-ts/docs-jsdoc-runes.stories.js +0 -10
  33. package/template/stories_svelte-kit-prerelease-ts/docs-ts-inline-prop-types.stories.js +0 -10
  34. package/template/stories_svelte-kit-prerelease-ts/docs-ts-referenced-prop-types.stories.js +0 -10
  35. package/template/stories_svelte-kit-prerelease-ts/docs-ts.stories.js +0 -10
  36. package/template/stories_svelte-kit-prerelease-ts/navigation.stories.js +0 -121
  37. package/template/stories_svelte-kit-prerelease-ts/stores.stories.js +0 -116
  38. package/template/stories_svelte-kit-skeleton-js/environment.stories.js +0 -11
  39. package/template/stories_svelte-kit-skeleton-js/forms.stories.js +0 -27
  40. package/template/stories_svelte-kit-skeleton-js/hrefs.stories.js +0 -53
  41. package/template/stories_svelte-kit-skeleton-js/paths.stories.js +0 -11
  42. package/template/stories_svelte-kit-skeleton-js/stores.stories.js +0 -116
  43. package/template/stories_svelte-kit-skeleton-ts/docs-ts.stories.js +0 -10
  44. package/template/stories_svelte-kit-skeleton-ts/environment.stories.js +0 -11
  45. package/template/stories_svelte-kit-skeleton-ts/forms.stories.js +0 -27
  46. package/template/stories_svelte-kit-skeleton-ts/hrefs.stories.js +0 -53
  47. package/template/stories_svelte-kit-skeleton-ts/navigation.stories.js +0 -121
  48. package/template/stories_svelte-kit-skeleton-ts/paths.stories.js +0 -11
@@ -0,0 +1,37 @@
1
+ <script>
2
+ import { goto, invalidate, invalidateAll, afterNavigate, replaceState, pushState } from '$app/navigation';
3
+
4
+ export let afterNavigateFn;
5
+
6
+ afterNavigate(afterNavigateFn);
7
+ </script>
8
+
9
+ <button
10
+ on:click={() => {
11
+ goto('/storybook-goto');
12
+ }}>goto</button
13
+ >
14
+
15
+ <button
16
+ on:click={() => {
17
+ invalidate('/storybook-invalidate');
18
+ }}>invalidate</button
19
+ >
20
+
21
+ <button
22
+ on:click={() => {
23
+ invalidateAll();
24
+ }}>invalidateAll</button
25
+ >
26
+
27
+ <button
28
+ on:click={() => {
29
+ pushState('/storybook-push-state', {});
30
+ }}>pushState</button
31
+ >
32
+
33
+ <button
34
+ on:click={() => {
35
+ replaceState('/storybook-replace-state', {});
36
+ }}>replaceState</button
37
+ >
@@ -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>
@@ -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>
@@ -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 = {};
@@ -1,11 +1,10 @@
1
- import { expect, fn, within } from '@storybook/test';
1
+ import { expect, fn, within } from 'storybook/test';
2
2
 
3
3
  import Forms from './Forms.svelte';
4
4
 
5
5
  export default {
6
- title: 'stories/sveltekit/modules/forms',
6
+ title: 'stories/frameworks/sveltekit/modules/forms',
7
7
  component: Forms,
8
- tags: ['autodocs'],
9
8
  };
10
9
 
11
10
  const enhance = fn();
@@ -1,11 +1,10 @@
1
- import { expect, fn, within } from '@storybook/test';
1
+ import { expect, fn, within } from 'storybook/test';
2
2
 
3
3
  import Hrefs from './Hrefs.svelte';
4
4
 
5
5
  export default {
6
- title: 'stories/sveltekit/modules/hrefs',
6
+ title: 'stories/frameworks/sveltekit/modules/hrefs',
7
7
  component: Hrefs,
8
- tags: ['autodocs'],
9
8
  };
10
9
 
11
10
  export const DefaultActions = {
@@ -1,11 +1,10 @@
1
- import { expect, fn, within } from '@storybook/test';
1
+ import { expect, fn, within } from 'storybook/test';
2
2
 
3
3
  import Navigation from './Navigation.svelte';
4
4
 
5
5
  export default {
6
- title: 'stories/sveltekit/modules/navigation',
6
+ title: 'stories/frameworks/sveltekit/modules/navigation',
7
7
  component: Navigation,
8
- tags: ['autodocs'],
9
8
  };
10
9
 
11
10
  const goto = fn();
@@ -0,0 +1,8 @@
1
+ import Paths from './Paths.svelte';
2
+
3
+ export default {
4
+ title: 'stories/frameworks/sveltekit/modules/paths',
5
+ component: Paths,
6
+ };
7
+
8
+ export const Default = {};
@@ -1,9 +1,8 @@
1
1
  import Stores from './Stores.svelte';
2
2
 
3
3
  export default {
4
- title: 'stories/sveltekit/modules/stores',
4
+ title: 'stories/frameworks/sveltekit/modules/stores',
5
5
  component: Stores,
6
- tags: ['autodocs'],
7
6
  };
8
7
 
9
8
  export const AllUndefined = {};
@@ -1,10 +0,0 @@
1
- import DocsJSDocRunes from './DocsJSDocRunes.svelte';
2
-
3
- export default {
4
- title: 'stories/renderers/svelte/docs-jsdoc-runes',
5
- component: DocsJSDocRunes,
6
- args: {},
7
- tags: ['autodocs'],
8
- };
9
-
10
- export const Primary = {};
@@ -1,10 +0,0 @@
1
- import DocsTSInlinePropTypes from './DocsTSInlinePropTypes.svelte';
2
-
3
- export default {
4
- title: 'stories/renderers/svelte/docs-ts-inline-prop-types',
5
- component: DocsTSInlinePropTypes,
6
- args: {},
7
- tags: ['autodocs'],
8
- };
9
-
10
- export const Primary = {};
@@ -1,10 +0,0 @@
1
- import DocsTSReferencedPropTypes from './DocsTSReferencedPropTypes.svelte';
2
-
3
- export default {
4
- title: 'stories/renderers/svelte/docs-ts-referenced-prop-types',
5
- component: DocsTSReferencedPropTypes,
6
- args: {},
7
- tags: ['autodocs'],
8
- };
9
-
10
- export const Primary = {};
@@ -1,10 +0,0 @@
1
- import DocsTSLegacy from './DocsTSLegacy.svelte';
2
-
3
- export default {
4
- title: 'stories/renderers/svelte/docs-ts',
5
- component: DocsTSLegacy,
6
- args: {},
7
- tags: ['autodocs'],
8
- };
9
-
10
- export const Primary = {};
@@ -1,121 +0,0 @@
1
- import { expect, fn, within } from '@storybook/test';
2
-
3
- import Navigation from './Navigation.svelte';
4
-
5
- export default {
6
- title: 'stories/sveltekit/modules/navigation',
7
- component: Navigation,
8
- tags: ['autodocs'],
9
- };
10
-
11
- const goto = fn();
12
-
13
- export const Goto = {
14
- async play({ canvasElement }) {
15
- const canvas = within(canvasElement);
16
- const button = canvas.getByText('goto');
17
- button.click();
18
- expect(goto).toHaveBeenCalledWith('/storybook-goto');
19
- },
20
- parameters: {
21
- sveltekit_experimental: {
22
- navigation: {
23
- goto,
24
- },
25
- },
26
- },
27
- };
28
-
29
- const replaceState = fn();
30
-
31
- export const ReplaceState = {
32
- async play({ canvasElement }) {
33
- const canvas = within(canvasElement);
34
- const button = canvas.getByText('replaceState');
35
- button.click();
36
- expect(replaceState).toHaveBeenCalledWith('/storybook-replace-state', {});
37
- },
38
- parameters: {
39
- sveltekit_experimental: {
40
- navigation: {
41
- replaceState,
42
- },
43
- },
44
- },
45
- };
46
-
47
- const pushState = fn();
48
-
49
- export const PushState = {
50
- async play({ canvasElement }) {
51
- const canvas = within(canvasElement);
52
- const button = canvas.getByText('pushState');
53
- button.click();
54
- expect(pushState).toHaveBeenCalledWith('/storybook-push-state', {});
55
- },
56
- parameters: {
57
- sveltekit_experimental: {
58
- navigation: {
59
- pushState,
60
- },
61
- },
62
- },
63
- };
64
-
65
- export const DefaultActions = {};
66
-
67
- const invalidate = fn();
68
-
69
- export const Invalidate = {
70
- async play({ canvasElement }) {
71
- const canvas = within(canvasElement);
72
- const button = canvas.getByText('invalidate', { exact: true });
73
- button.click();
74
- expect(invalidate).toHaveBeenCalledWith('/storybook-invalidate');
75
- },
76
- parameters: {
77
- sveltekit_experimental: {
78
- navigation: {
79
- invalidate,
80
- },
81
- },
82
- },
83
- };
84
-
85
- const invalidateAll = fn();
86
-
87
- export const InvalidateAll = {
88
- async play({ canvasElement }) {
89
- const canvas = within(canvasElement);
90
- const button = canvas.getByText('invalidateAll');
91
- button.click();
92
- expect(invalidateAll).toHaveBeenCalledWith();
93
- },
94
- parameters: {
95
- sveltekit_experimental: {
96
- navigation: {
97
- invalidateAll,
98
- },
99
- },
100
- },
101
- };
102
-
103
- const afterNavigateFn = fn();
104
-
105
- export const AfterNavigate = {
106
- async play() {
107
- expect(afterNavigateFn).toHaveBeenCalledWith({ test: 'passed' });
108
- },
109
- args: {
110
- afterNavigateFn,
111
- },
112
- parameters: {
113
- sveltekit_experimental: {
114
- navigation: {
115
- afterNavigate: {
116
- test: 'passed',
117
- },
118
- },
119
- },
120
- },
121
- };
@@ -1,116 +0,0 @@
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
- };
@@ -1,11 +0,0 @@
1
- import { expect, fn, within } from '@storybook/test';
2
-
3
- import Environment from './Environment.svelte';
4
-
5
- export default {
6
- title: 'stories/sveltekit/modules/environment',
7
- component: Environment,
8
- tags: ['autodocs'],
9
- };
10
-
11
- export const Default = {};
@@ -1,27 +0,0 @@
1
- import { expect, fn, userEvent, within } from '@storybook/test';
2
-
3
- import Forms from './Forms.svelte';
4
-
5
- export default {
6
- title: 'stories/sveltekit/modules/forms',
7
- component: Forms,
8
- tags: ['autodocs'],
9
- };
10
-
11
- const enhance = fn();
12
-
13
- export const Enhance = {
14
- async play({ canvasElement }) {
15
- const canvas = within(canvasElement);
16
- const button = canvas.getByRole('button');
17
- await userEvent.click(button);
18
- expect(enhance).toHaveBeenCalled();
19
- },
20
- parameters: {
21
- sveltekit_experimental: {
22
- forms: {
23
- enhance,
24
- },
25
- },
26
- },
27
- };
@@ -1,53 +0,0 @@
1
- import { expect, fn, within } from '@storybook/test';
2
-
3
- import Hrefs from './Hrefs.svelte';
4
-
5
- export default {
6
- title: 'stories/sveltekit/modules/hrefs',
7
- component: Hrefs,
8
- tags: ['autodocs'],
9
- };
10
-
11
- export const DefaultActions = {
12
- async play({ canvasElement }) {
13
- const canvas = within(canvasElement);
14
-
15
- const initialUrl = window.location.toString();
16
-
17
- const basicHref = canvas.getByText('/basic-href');
18
- basicHref.click();
19
-
20
- const complexHref = canvas.getByText(
21
- '/deep/nested/link?with=true&multiple-params=200#and-an-id'
22
- );
23
- complexHref.click();
24
-
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
- };
@@ -1,11 +0,0 @@
1
- import { expect, fn, within } from '@storybook/test';
2
-
3
- import Paths from './Paths.svelte';
4
-
5
- export default {
6
- title: 'stories/sveltekit/modules/paths',
7
- component: Paths,
8
- tags: ['autodocs'],
9
- };
10
-
11
- export const Default = {};
@@ -1,116 +0,0 @@
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
- };
@@ -1,10 +0,0 @@
1
- import DocsTS from './DocsTS.svelte';
2
-
3
- export default {
4
- title: 'stories/renderers/svelte/docs-ts',
5
- component: DocsTS,
6
- args: {},
7
- tags: ['autodocs'],
8
- };
9
-
10
- export const Primary = {};
@@ -1,11 +0,0 @@
1
- import { expect, fn, within } from '@storybook/test';
2
-
3
- import Environment from './Environment.svelte';
4
-
5
- export default {
6
- title: 'stories/sveltekit/modules/environment',
7
- component: Environment,
8
- tags: ['autodocs'],
9
- };
10
-
11
- export const Default = {};
@@ -1,27 +0,0 @@
1
- import { expect, fn, within } from '@storybook/test';
2
-
3
- import Forms from './Forms.svelte';
4
-
5
- export default {
6
- title: 'stories/sveltekit/modules/forms',
7
- component: Forms,
8
- tags: ['autodocs'],
9
- };
10
-
11
- const enhance = fn();
12
-
13
- export const Enhance = {
14
- async play({ canvasElement }) {
15
- const canvas = within(canvasElement);
16
- const button = canvas.getByText('enhance');
17
- button.click();
18
- expect(enhance).toHaveBeenCalled();
19
- },
20
- parameters: {
21
- sveltekit_experimental: {
22
- forms: {
23
- enhance,
24
- },
25
- },
26
- },
27
- };