@storybook/addon-svelte-csf 1.1.1 → 1.1.2
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/CHANGELOG.md +12 -0
- package/dist/cjs/components/Story.svelte +2 -1
- package/dist/cjs/components/Template.svelte +1 -1
- package/dist/cjs/parser/collect-stories.js +2 -1
- package/dist/esm/components/Story.svelte +2 -1
- package/dist/esm/components/Template.svelte +1 -1
- package/dist/esm/parser/collect-stories.js +2 -1
- package/index.d.ts +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v1.1.2 (Fri Apr 08 2022)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Allow a Story to access its context [#47](https://github.com/storybookjs/addon-svelte-csf/pull/47) ([@j3rem1e](https://github.com/j3rem1e))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Jérémie ([@j3rem1e](https://github.com/j3rem1e))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v1.1.1 (Fri Apr 08 2022)
|
|
2
14
|
|
|
3
15
|
#### 🐛 Bug Fix
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
$: render = context.render && !context.templateName && context.storyName == name;
|
|
20
|
+
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
23
|
{#if render}
|
|
23
|
-
<slot args={context.
|
|
24
|
+
<slot {...context.args} context={context.storyContext} args={context.args}/>
|
|
24
25
|
{/if}
|
|
@@ -116,7 +116,7 @@ var _default = function _default(StoriesComponent, _ref) {
|
|
|
116
116
|
|
|
117
117
|
var unknownTemplate = template != null && templatesId.indexOf(template) < 0;
|
|
118
118
|
|
|
119
|
-
var storyFn = function storyFn(args) {
|
|
119
|
+
var storyFn = function storyFn(args, storyContext) {
|
|
120
120
|
if (unknownTemplate) {
|
|
121
121
|
throw new Error("Story ".concat(name, " is referencing an unknown template ").concat(template));
|
|
122
122
|
}
|
|
@@ -128,6 +128,7 @@ var _default = function _default(StoriesComponent, _ref) {
|
|
|
128
128
|
storyName: name,
|
|
129
129
|
templateId: template,
|
|
130
130
|
args: args,
|
|
131
|
+
storyContext: storyContext,
|
|
131
132
|
sourceComponent: component || globalComponent
|
|
132
133
|
}
|
|
133
134
|
};
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
$: render = context.render && !context.templateName && context.storyName == name;
|
|
20
|
+
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
23
|
{#if render}
|
|
23
|
-
<slot args={context.
|
|
24
|
+
<slot {...context.args} context={context.storyContext} args={context.args}/>
|
|
24
25
|
{/if}
|
|
@@ -102,7 +102,7 @@ export default (function (StoriesComponent, _ref) {
|
|
|
102
102
|
|
|
103
103
|
var unknownTemplate = template != null && templatesId.indexOf(template) < 0;
|
|
104
104
|
|
|
105
|
-
var storyFn = function storyFn(args) {
|
|
105
|
+
var storyFn = function storyFn(args, storyContext) {
|
|
106
106
|
if (unknownTemplate) {
|
|
107
107
|
throw new Error("Story ".concat(name, " is referencing an unknown template ").concat(template));
|
|
108
108
|
}
|
|
@@ -114,6 +114,7 @@ export default (function (StoriesComponent, _ref) {
|
|
|
114
114
|
storyName: name,
|
|
115
115
|
templateId: template,
|
|
116
116
|
args: args,
|
|
117
|
+
storyContext: storyContext,
|
|
117
118
|
sourceComponent: component || globalComponent
|
|
118
119
|
}
|
|
119
120
|
};
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SvelteComponentTyped, SvelteComponent } from 'svelte';
|
|
2
|
-
import type { BaseMeta, BaseAnnotations } from '@storybook/addons';
|
|
2
|
+
import type { BaseMeta, BaseAnnotations, StoryContext } from '@storybook/addons';
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
type DecoratorReturnType = void|SvelteComponent|{
|
|
@@ -47,6 +47,7 @@ interface TemplateProps extends BaseAnnotations<any, DecoratorReturnType> {
|
|
|
47
47
|
interface Slots {
|
|
48
48
|
default: {
|
|
49
49
|
args: any;
|
|
50
|
+
context: StoryContext;
|
|
50
51
|
[key: string]: any;
|
|
51
52
|
}
|
|
52
53
|
}
|