@storybook/svelte 6.5.9 → 7.0.0-alpha.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/README.md +1 -32
- package/dist/cjs/config.js +43 -0
- package/dist/cjs/{client/docs → docs}/config.js +3 -6
- package/dist/{modern/client → cjs}/docs/extractArgTypes.js +17 -4
- package/dist/cjs/{client/docs → docs}/extractComponentDescription.js +3 -7
- package/dist/{modern/client → cjs}/docs/sourceDecorator.js +29 -13
- package/dist/cjs/{client/index.js → index.js} +12 -11
- package/dist/cjs/{client/preview → preview}/config.js +5 -5
- package/dist/cjs/{client/preview → preview}/decorators.js +17 -25
- package/dist/cjs/{client/preview → preview}/globals.js +3 -1
- package/dist/cjs/preview/index.js +49 -0
- package/dist/cjs/{client/preview → preview}/render.js +24 -21
- package/dist/cjs/{client/preview → preview}/types.js +0 -0
- package/dist/esm/config.js +6 -0
- package/dist/{modern/client → esm}/docs/config.js +0 -2
- package/dist/esm/docs/extractArgTypes.js +115 -0
- package/dist/{modern/client → esm}/docs/extractComponentDescription.js +0 -0
- package/dist/esm/docs/sourceDecorator.js +192 -0
- package/dist/esm/index.js +3 -0
- package/dist/{modern/client → esm}/preview/config.js +1 -1
- package/dist/{modern/client → esm}/preview/decorators.js +0 -1
- package/dist/{modern/client → esm}/preview/globals.js +0 -0
- package/dist/{modern/client → esm}/preview/index.js +1 -1
- package/dist/{modern/client → esm}/preview/render.js +0 -0
- package/dist/esm/{client/preview → preview}/types.js +0 -0
- package/dist/types/config.d.ts +10 -0
- package/dist/{ts3.9/client → types}/docs/config.d.ts +1 -2
- package/dist/{ts3.9/client → types}/docs/extractArgTypes.d.ts +0 -0
- package/dist/{ts3.9/client → types}/docs/extractComponentDescription.d.ts +0 -0
- package/dist/{ts3.9/client → types}/docs/sourceDecorator.d.ts +0 -0
- package/dist/{ts3.9/client → types}/index.d.ts +0 -0
- package/dist/{ts3.4/client → types}/preview/config.d.ts +5 -5
- package/dist/{ts3.9/client → types}/preview/decorators.d.ts +0 -0
- package/dist/{ts3.9/client → types}/preview/globals.d.ts +0 -0
- package/dist/{ts3.9/client → types}/preview/index.d.ts +2 -2
- package/dist/{ts3.9/client → types}/preview/render.d.ts +0 -0
- package/dist/{ts3.9/client → types}/preview/types.d.ts +1 -1
- package/package.json +16 -41
- package/preview.js +1 -0
- package/bin/build.js +0 -5
- package/bin/index.js +0 -3
- package/dist/cjs/client/docs/extractArgTypes.js +0 -162
- package/dist/cjs/client/docs/prepareForInline.js +0 -35
- package/dist/cjs/client/docs/sourceDecorator.js +0 -271
- package/dist/cjs/client/preview/index.js +0 -51
- package/dist/cjs/server/build.js +0 -9
- package/dist/cjs/server/framework-preset-svelte-docs.js +0 -32
- package/dist/cjs/server/framework-preset-svelte.js +0 -57
- package/dist/cjs/server/index.js +0 -9
- package/dist/cjs/server/options.js +0 -17
- package/dist/cjs/server/preset.js +0 -8
- package/dist/cjs/server/svelte-docgen-loader.js +0 -120
- package/dist/esm/client/docs/config.js +0 -15
- package/dist/esm/client/docs/extractArgTypes.js +0 -140
- package/dist/esm/client/docs/extractComponentDescription.js +0 -12
- package/dist/esm/client/docs/prepareForInline.js +0 -20
- package/dist/esm/client/docs/sourceDecorator.js +0 -239
- package/dist/esm/client/index.js +0 -5
- package/dist/esm/client/preview/config.js +0 -5
- package/dist/esm/client/preview/decorators.js +0 -95
- package/dist/esm/client/preview/globals.js +0 -3
- package/dist/esm/client/preview/index.js +0 -30
- package/dist/esm/client/preview/render.js +0 -49
- package/dist/esm/server/build.js +0 -3
- package/dist/esm/server/framework-preset-svelte-docs.js +0 -16
- package/dist/esm/server/framework-preset-svelte.js +0 -42
- package/dist/esm/server/index.js +0 -3
- package/dist/esm/server/options.js +0 -8
- package/dist/esm/server/preset.js +0 -1
- package/dist/esm/server/svelte-docgen-loader.js +0 -99
- package/dist/modern/client/docs/prepareForInline.js +0 -18
- package/dist/modern/client/index.js +0 -5
- package/dist/modern/client/preview/types.js +0 -0
- package/dist/modern/server/build.js +0 -3
- package/dist/modern/server/framework-preset-svelte-docs.js +0 -16
- package/dist/modern/server/framework-preset-svelte.js +0 -42
- package/dist/modern/server/index.js +0 -3
- package/dist/modern/server/options.js +0 -8
- package/dist/modern/server/preset.js +0 -1
- package/dist/modern/server/svelte-docgen-loader.js +0 -99
- package/dist/ts3.4/client/docs/config.d.ts +0 -11
- package/dist/ts3.4/client/docs/extractArgTypes.d.ts +0 -5
- package/dist/ts3.4/client/docs/extractComponentDescription.d.ts +0 -3
- package/dist/ts3.4/client/docs/prepareForInline.d.ts +0 -3
- package/dist/ts3.4/client/docs/sourceDecorator.d.ts +0 -16
- package/dist/ts3.4/client/index.d.ts +0 -1
- package/dist/ts3.4/client/preview/decorators.d.ts +0 -1
- package/dist/ts3.4/client/preview/globals.d.ts +0 -1
- package/dist/ts3.4/client/preview/index.d.ts +0 -9
- package/dist/ts3.4/client/preview/render.d.ts +0 -5
- package/dist/ts3.4/client/preview/types.d.ts +0 -21
- package/dist/ts3.4/server/build.d.ts +0 -1
- package/dist/ts3.4/server/framework-preset-svelte-docs.d.ts +0 -5
- package/dist/ts3.4/server/framework-preset-svelte.d.ts +0 -6
- package/dist/ts3.4/server/index.d.ts +0 -1
- package/dist/ts3.4/server/options.d.ts +0 -3
- package/dist/ts3.4/server/preset.d.ts +0 -2
- package/dist/ts3.4/server/svelte-docgen-loader.d.ts +0 -5
- package/dist/ts3.9/client/docs/prepareForInline.d.ts +0 -3
- package/dist/ts3.9/client/preview/config.d.ts +0 -5
- package/dist/ts3.9/server/build.d.ts +0 -1
- package/dist/ts3.9/server/framework-preset-svelte-docs.d.ts +0 -5
- package/dist/ts3.9/server/framework-preset-svelte.d.ts +0 -6
- package/dist/ts3.9/server/index.d.ts +0 -1
- package/dist/ts3.9/server/options.d.ts +0 -3
- package/dist/ts3.9/server/preset.d.ts +0 -2
- package/dist/ts3.9/server/svelte-docgen-loader.d.ts +0 -5
- package/preset.js +0 -1
- package/standalone.js +0 -8
package/README.md
CHANGED
|
@@ -1,32 +1 @@
|
|
|
1
|
-
# Storybook
|
|
2
|
-
|
|
3
|
-
Storybook for Svelte is a UI development environment for your Svelte components.
|
|
4
|
-
With it, you can visualize different states of your UI components and develop them interactively.
|
|
5
|
-
|
|
6
|
-

|
|
7
|
-
|
|
8
|
-
Storybook runs outside of your app.
|
|
9
|
-
So you can develop UI components in isolation without worrying about app specific dependencies and requirements.
|
|
10
|
-
|
|
11
|
-
## Getting Started
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
cd my-svelte-app
|
|
15
|
-
npx sb init
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
For more information visit: [storybook.js.org](https://storybook.js.org)
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
Storybook also comes with a lot of [addons](https://storybook.js.org/addons) and a great API to customize as you wish.
|
|
23
|
-
You can also build a [static version](https://storybook.js.org/docs/svelte/sharing/publish-storybook) of your Storybook and deploy it anywhere you want.
|
|
24
|
-
|
|
25
|
-
## TODOs
|
|
26
|
-
|
|
27
|
-
- [ ] Support `addon-info`
|
|
28
|
-
- [ ] Support Svelte markup directly in stories
|
|
29
|
-
- [ ] Add Svelte storybook generator
|
|
30
|
-
- [ ] Provide stories that show advanced Svelte use cases
|
|
31
|
-
- [ ] Hydratable
|
|
32
|
-
- [ ] Advanced mount options
|
|
1
|
+
# Storybook Svelte renderer
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
parameters: true,
|
|
8
|
+
decorators: true,
|
|
9
|
+
argTypesEnhancers: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "argTypesEnhancers", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _config.argTypesEnhancers;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "decorators", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _config.decorators;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
exports.parameters = void 0;
|
|
24
|
+
|
|
25
|
+
var _config = require("./docs/config");
|
|
26
|
+
|
|
27
|
+
var _config2 = require("./preview/config");
|
|
28
|
+
|
|
29
|
+
Object.keys(_config2).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
32
|
+
if (key in exports && exports[key] === _config2[key]) return;
|
|
33
|
+
Object.defineProperty(exports, key, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return _config2[key];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
const parameters = Object.assign({
|
|
41
|
+
framework: 'svelte'
|
|
42
|
+
}, _config.parameters);
|
|
43
|
+
exports.parameters = parameters;
|
|
@@ -11,20 +11,17 @@ var _extractArgTypes = require("./extractArgTypes");
|
|
|
11
11
|
|
|
12
12
|
var _extractComponentDescription = require("./extractComponentDescription");
|
|
13
13
|
|
|
14
|
-
var _prepareForInline = require("./prepareForInline");
|
|
15
|
-
|
|
16
14
|
var _sourceDecorator = require("./sourceDecorator");
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
const parameters = {
|
|
19
17
|
docs: {
|
|
20
18
|
inlineStories: true,
|
|
21
|
-
prepareForInline: _prepareForInline.prepareForInline,
|
|
22
19
|
extractArgTypes: _extractArgTypes.extractArgTypes,
|
|
23
20
|
extractComponentDescription: _extractComponentDescription.extractComponentDescription
|
|
24
21
|
}
|
|
25
22
|
};
|
|
26
23
|
exports.parameters = parameters;
|
|
27
|
-
|
|
24
|
+
const decorators = [_sourceDecorator.sourceDecorator];
|
|
28
25
|
exports.decorators = decorators;
|
|
29
|
-
|
|
26
|
+
const argTypesEnhancers = [_docsTools.enhanceArgTypes];
|
|
30
27
|
exports.argTypesEnhancers = argTypesEnhancers;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extractArgTypes = exports.createArgTypes = void 0;
|
|
7
|
+
|
|
8
|
+
var _clientLogger = require("@storybook/client-logger");
|
|
2
9
|
|
|
3
10
|
function hasKeyword(keyword, keywords) {
|
|
4
11
|
return keywords ? keywords.find(k => k.name === keyword) != null : false;
|
|
5
12
|
}
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
const extractArgTypes = component => {
|
|
8
15
|
try {
|
|
9
16
|
// eslint-disable-next-line no-underscore-dangle
|
|
10
17
|
const docgen = component.__docgen;
|
|
@@ -13,12 +20,15 @@ export const extractArgTypes = component => {
|
|
|
13
20
|
return createArgTypes(docgen);
|
|
14
21
|
}
|
|
15
22
|
} catch (err) {
|
|
16
|
-
logger.log(`Error extracting argTypes: ${err}`);
|
|
23
|
+
_clientLogger.logger.log(`Error extracting argTypes: ${err}`);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
return {};
|
|
20
27
|
};
|
|
21
|
-
|
|
28
|
+
|
|
29
|
+
exports.extractArgTypes = extractArgTypes;
|
|
30
|
+
|
|
31
|
+
const createArgTypes = docgen => {
|
|
22
32
|
const results = {};
|
|
23
33
|
docgen.data.forEach(item => {
|
|
24
34
|
var _item$type, _item$type2;
|
|
@@ -78,6 +88,9 @@ export const createArgTypes = docgen => {
|
|
|
78
88
|
* @returns string
|
|
79
89
|
*/
|
|
80
90
|
|
|
91
|
+
|
|
92
|
+
exports.createArgTypes = createArgTypes;
|
|
93
|
+
|
|
81
94
|
const parseTypeToControl = type => {
|
|
82
95
|
if (!type) {
|
|
83
96
|
return null;
|
|
@@ -5,17 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.extractComponentDescription = extractComponentDescription;
|
|
7
7
|
|
|
8
|
-
require("core-js/modules/es.symbol.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.symbol.description.js");
|
|
11
|
-
|
|
12
8
|
function extractComponentDescription(component) {
|
|
13
9
|
if (!component) {
|
|
14
10
|
return null;
|
|
15
11
|
}
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const {
|
|
14
|
+
__docgen = {}
|
|
15
|
+
} = component;
|
|
20
16
|
return __docgen.description;
|
|
21
17
|
}
|
|
@@ -1,25 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.generateSvelteSource = generateSvelteSource;
|
|
7
|
+
exports.sourceDecorator = void 0;
|
|
8
|
+
|
|
9
|
+
var _addons = require("@storybook/addons");
|
|
10
|
+
|
|
11
|
+
var _clientLogger = require("@storybook/client-logger");
|
|
12
|
+
|
|
13
|
+
var _docsTools = require("@storybook/docs-tools");
|
|
14
|
+
|
|
15
|
+
/* eslint-disable no-underscore-dangle */
|
|
16
|
+
|
|
4
17
|
/**
|
|
5
18
|
* Check if the sourcecode should be generated.
|
|
6
19
|
*
|
|
7
20
|
* @param context StoryContext
|
|
8
21
|
*/
|
|
9
|
-
|
|
10
22
|
const skipSourceRender = context => {
|
|
11
23
|
var _context$parameters$d;
|
|
12
24
|
|
|
13
25
|
const sourceParams = context === null || context === void 0 ? void 0 : (_context$parameters$d = context.parameters.docs) === null || _context$parameters$d === void 0 ? void 0 : _context$parameters$d.source;
|
|
14
26
|
const isArgsStory = context === null || context === void 0 ? void 0 : context.parameters.__isArgsStory; // always render if the user forces it
|
|
15
27
|
|
|
16
|
-
if ((sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === SourceType.DYNAMIC) {
|
|
28
|
+
if ((sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.DYNAMIC) {
|
|
17
29
|
return false;
|
|
18
30
|
} // never render if the user is forcing the block to render code, or
|
|
19
31
|
// if the user provides code, or if it's not an args story.
|
|
20
32
|
|
|
21
33
|
|
|
22
|
-
return !isArgsStory || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.code) || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === SourceType.CODE;
|
|
34
|
+
return !isArgsStory || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.code) || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.CODE;
|
|
23
35
|
};
|
|
24
36
|
/**
|
|
25
37
|
* Transform a key/value to a svelte declaration as string.
|
|
@@ -91,7 +103,7 @@ function getComponentName(component) {
|
|
|
91
103
|
*/
|
|
92
104
|
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
function generateSvelteSource(component, args, argTypes, slotProperty) {
|
|
95
107
|
const name = getComponentName(component);
|
|
96
108
|
|
|
97
109
|
if (!name) {
|
|
@@ -120,6 +132,7 @@ export function generateSvelteSource(component, args, argTypes, slotProperty) {
|
|
|
120
132
|
* @param component Component
|
|
121
133
|
*/
|
|
122
134
|
|
|
135
|
+
|
|
123
136
|
function getWrapperProperties(component) {
|
|
124
137
|
const {
|
|
125
138
|
__docgen
|
|
@@ -152,14 +165,15 @@ function getWrapperProperties(component) {
|
|
|
152
165
|
*/
|
|
153
166
|
|
|
154
167
|
|
|
155
|
-
|
|
156
|
-
const channel = addons.getChannel();
|
|
168
|
+
const sourceDecorator = (storyFn, context) => {
|
|
169
|
+
const channel = _addons.addons.getChannel();
|
|
170
|
+
|
|
157
171
|
const skip = skipSourceRender(context);
|
|
158
172
|
const story = storyFn();
|
|
159
173
|
let source;
|
|
160
|
-
useEffect(() => {
|
|
174
|
+
(0, _addons.useEffect)(() => {
|
|
161
175
|
if (!skip && source) {
|
|
162
|
-
channel.emit(SNIPPET_RENDERED, (context || {}).id, source);
|
|
176
|
+
channel.emit(_docsTools.SNIPPET_RENDERED, (context || {}).id, source);
|
|
163
177
|
}
|
|
164
178
|
});
|
|
165
179
|
|
|
@@ -182,7 +196,7 @@ export const sourceDecorator = (storyFn, context) => {
|
|
|
182
196
|
|
|
183
197
|
if (wrapper) {
|
|
184
198
|
if (parameters.component) {
|
|
185
|
-
once.warn('parameters.component is deprecated. Using context.component instead.');
|
|
199
|
+
_clientLogger.once.warn('parameters.component is deprecated. Using context.component instead.');
|
|
186
200
|
}
|
|
187
201
|
|
|
188
202
|
component = ctxtComponent;
|
|
@@ -190,4 +204,6 @@ export const sourceDecorator = (storyFn, context) => {
|
|
|
190
204
|
|
|
191
205
|
source = generateSvelteSource(component, args, context === null || context === void 0 ? void 0 : context.argTypes, slotProperty);
|
|
192
206
|
return story;
|
|
193
|
-
};
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
exports.sourceDecorator = sourceDecorator;
|
|
@@ -5,55 +5,56 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "addDecorator", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _preview.addDecorator;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "addParameters", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _preview.addParameters;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "configure", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _preview.configure;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "forceReRender", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function
|
|
26
|
+
get: function () {
|
|
27
27
|
return _preview.forceReRender;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "getStorybook", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function
|
|
32
|
+
get: function () {
|
|
33
33
|
return _preview.getStorybook;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "raw", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function
|
|
38
|
+
get: function () {
|
|
39
39
|
return _preview.raw;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "setAddon", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function
|
|
44
|
+
get: function () {
|
|
45
45
|
return _preview.setAddon;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "storiesOf", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function
|
|
50
|
+
get: function () {
|
|
51
51
|
return _preview.storiesOf;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
var _preview = require("./preview");
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
var _module, _module$hot;
|
|
58
|
+
|
|
59
|
+
// optimization: stop HMR propagation in webpack
|
|
60
|
+
(_module = module) === null || _module === void 0 ? void 0 : (_module$hot = _module.hot) === null || _module$hot === void 0 ? void 0 : _module$hot.decline();
|
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "applyDecorators", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _decorators.decorateStory;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
exports.parameters = void 0;
|
|
13
13
|
Object.defineProperty(exports, "render", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function
|
|
15
|
+
get: function () {
|
|
16
16
|
return _render.render;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "renderToDOM", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function
|
|
21
|
+
get: function () {
|
|
22
22
|
return _render.renderToDOM;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
@@ -27,7 +27,7 @@ var _render = require("./render");
|
|
|
27
27
|
|
|
28
28
|
var _decorators = require("./decorators");
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const parameters = {
|
|
31
31
|
framework: 'svelte'
|
|
32
32
|
};
|
|
33
33
|
exports.parameters = parameters;
|
|
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.decorateStory = decorateStory;
|
|
7
7
|
|
|
8
|
-
require("core-js/modules/es.object.to-string.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.object.assign.js");
|
|
11
|
-
|
|
12
8
|
var _store = require("@storybook/store");
|
|
13
9
|
|
|
14
10
|
var _SlotDecorator = _interopRequireDefault(require("@storybook/svelte/templates/SlotDecorator.svelte"));
|
|
@@ -48,7 +44,7 @@ function unWrap(obj) {
|
|
|
48
44
|
|
|
49
45
|
|
|
50
46
|
function prepareStory(context, story, originalStory) {
|
|
51
|
-
|
|
47
|
+
let result = unWrap(story);
|
|
52
48
|
|
|
53
49
|
if (isSvelteComponent(result)) {
|
|
54
50
|
// wrap the component
|
|
@@ -70,7 +66,7 @@ function prepareStory(context, story, originalStory) {
|
|
|
70
66
|
}
|
|
71
67
|
};
|
|
72
68
|
} else {
|
|
73
|
-
|
|
69
|
+
let cpn = result.Component;
|
|
74
70
|
|
|
75
71
|
if (!cpn) {
|
|
76
72
|
// if the component is not defined, get it the context
|
|
@@ -84,25 +80,21 @@ function prepareStory(context, story, originalStory) {
|
|
|
84
80
|
}
|
|
85
81
|
|
|
86
82
|
function decorateStory(storyFn, decorators) {
|
|
87
|
-
return decorators.reduce(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
83
|
+
return decorators.reduce((previousStoryFn, decorator) => context => {
|
|
84
|
+
let story;
|
|
85
|
+
const decoratedStory = decorator(update => {
|
|
86
|
+
story = previousStoryFn(Object.assign({}, context, (0, _store.sanitizeStoryContextUpdate)(update)));
|
|
87
|
+
return story;
|
|
88
|
+
}, context);
|
|
89
|
+
|
|
90
|
+
if (!story) {
|
|
91
|
+
story = previousStoryFn(context);
|
|
92
|
+
}
|
|
98
93
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
if (!decoratedStory || decoratedStory === story) {
|
|
95
|
+
return story;
|
|
96
|
+
}
|
|
102
97
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}, function (context) {
|
|
106
|
-
return prepareStory(context, storyFn(context));
|
|
107
|
-
});
|
|
98
|
+
return prepareStory(context, decoratedStory, story);
|
|
99
|
+
}, context => prepareStory(context, storyFn(context)));
|
|
108
100
|
}
|
|
@@ -4,5 +4,7 @@ var _global = _interopRequireDefault(require("global"));
|
|
|
4
4
|
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const {
|
|
8
|
+
window: globalWindow
|
|
9
|
+
} = _global.default;
|
|
8
10
|
globalWindow.STORYBOOK_ENV = 'svelte';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.storiesOf = exports.setAddon = exports.raw = exports.getStorybook = exports.forceReRender = exports.configure = exports.clearDecorators = exports.addParameters = exports.addDecorator = void 0;
|
|
7
|
+
|
|
8
|
+
var _coreClient = require("@storybook/core-client");
|
|
9
|
+
|
|
10
|
+
var _decorators = require("./decorators");
|
|
11
|
+
|
|
12
|
+
require("./globals");
|
|
13
|
+
|
|
14
|
+
var _render = require("./render");
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
configure: coreConfigure,
|
|
18
|
+
clientApi,
|
|
19
|
+
forceReRender
|
|
20
|
+
} = (0, _coreClient.start)(_render.renderToDOM, {
|
|
21
|
+
decorateStory: _decorators.decorateStory,
|
|
22
|
+
render: _render.render
|
|
23
|
+
});
|
|
24
|
+
exports.forceReRender = forceReRender;
|
|
25
|
+
const {
|
|
26
|
+
setAddon,
|
|
27
|
+
addDecorator,
|
|
28
|
+
addParameters,
|
|
29
|
+
clearDecorators,
|
|
30
|
+
getStorybook,
|
|
31
|
+
raw
|
|
32
|
+
} = clientApi;
|
|
33
|
+
exports.raw = raw;
|
|
34
|
+
exports.getStorybook = getStorybook;
|
|
35
|
+
exports.clearDecorators = clearDecorators;
|
|
36
|
+
exports.addParameters = addParameters;
|
|
37
|
+
exports.addDecorator = addDecorator;
|
|
38
|
+
exports.setAddon = setAddon;
|
|
39
|
+
const framework = 'svelte';
|
|
40
|
+
|
|
41
|
+
const storiesOf = (kind, m) => clientApi.storiesOf(kind, m).addParameters({
|
|
42
|
+
framework
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
exports.storiesOf = storiesOf;
|
|
46
|
+
|
|
47
|
+
const configure = (loadable, m) => coreConfigure(framework, loadable, m);
|
|
48
|
+
|
|
49
|
+
exports.configure = configure;
|
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.render = void 0;
|
|
7
7
|
exports.renderToDOM = renderToDOM;
|
|
8
8
|
|
|
9
|
-
require("core-js/modules/es.function.name.js");
|
|
10
|
-
|
|
11
9
|
var _global = _interopRequireDefault(require("global"));
|
|
12
10
|
|
|
13
11
|
var _PreviewRender = _interopRequireDefault(require("@storybook/svelte/templates/PreviewRender.svelte"));
|
|
@@ -15,8 +13,10 @@ var _PreviewRender = _interopRequireDefault(require("@storybook/svelte/templates
|
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
14
|
|
|
17
15
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const {
|
|
17
|
+
document
|
|
18
|
+
} = _global.default;
|
|
19
|
+
let previousComponent = null;
|
|
20
20
|
|
|
21
21
|
function cleanUpPreviousStory() {
|
|
22
22
|
if (!previousComponent) {
|
|
@@ -27,37 +27,40 @@ function cleanUpPreviousStory() {
|
|
|
27
27
|
previousComponent = null;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function renderToDOM(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
function renderToDOM({
|
|
31
|
+
storyFn,
|
|
32
|
+
kind,
|
|
33
|
+
name,
|
|
34
|
+
showMain,
|
|
35
|
+
showError
|
|
36
|
+
}, domElement) {
|
|
36
37
|
cleanUpPreviousStory();
|
|
37
|
-
|
|
38
|
+
const target = document.getElementById('root');
|
|
38
39
|
target.innerHTML = '';
|
|
39
40
|
previousComponent = new _PreviewRender.default({
|
|
40
|
-
target
|
|
41
|
+
target,
|
|
41
42
|
props: {
|
|
42
|
-
storyFn
|
|
43
|
-
name
|
|
44
|
-
kind
|
|
45
|
-
showError
|
|
43
|
+
storyFn,
|
|
44
|
+
name,
|
|
45
|
+
kind,
|
|
46
|
+
showError
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
showMain();
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const render = (args, context) => {
|
|
53
|
+
const {
|
|
54
|
+
id,
|
|
55
|
+
component: Component
|
|
56
|
+
} = context;
|
|
54
57
|
|
|
55
58
|
if (!Component) {
|
|
56
|
-
throw new Error(
|
|
59
|
+
throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
return {
|
|
60
|
-
Component
|
|
63
|
+
Component,
|
|
61
64
|
props: args
|
|
62
65
|
};
|
|
63
66
|
};
|
|
File without changes
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { enhanceArgTypes } from '@storybook/docs-tools';
|
|
2
2
|
import { extractArgTypes } from './extractArgTypes';
|
|
3
3
|
import { extractComponentDescription } from './extractComponentDescription';
|
|
4
|
-
import { prepareForInline } from './prepareForInline';
|
|
5
4
|
import { sourceDecorator } from './sourceDecorator';
|
|
6
5
|
export const parameters = {
|
|
7
6
|
docs: {
|
|
8
7
|
inlineStories: true,
|
|
9
|
-
prepareForInline,
|
|
10
8
|
extractArgTypes,
|
|
11
9
|
extractComponentDescription
|
|
12
10
|
}
|