@storybook/html 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 -25
- package/dist/cjs/config.js +36 -0
- package/dist/cjs/{client/docs → docs}/config.js +2 -5
- package/dist/cjs/{client/docs → docs}/sourceDecorator.js +11 -12
- package/dist/cjs/{client/index.js → index.js} +13 -18
- package/dist/cjs/{client/preview → preview}/config.js +2 -8
- package/dist/cjs/{client/preview → preview}/globals.js +3 -1
- package/dist/cjs/preview/index.js +42 -0
- package/dist/cjs/preview/render.js +52 -0
- package/dist/cjs/{client/preview → preview}/types-6-0.js +0 -0
- package/dist/cjs/{client/preview → preview}/types-7-0.js +0 -0
- 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/sourceDecorator.js +51 -0
- package/dist/{modern/client → esm}/index.js +2 -4
- package/dist/esm/preview/config.js +1 -0
- 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-6-0.js +0 -0
- package/dist/esm/{client/preview → preview}/types-7-0.js +0 -0
- package/dist/esm/{client/preview → preview}/types.js +0 -0
- package/dist/types/config.d.ts +12 -0
- package/dist/{ts3.9/client → types}/docs/config.d.ts +0 -2
- package/dist/{ts3.9/client → types}/docs/sourceDecorator.d.ts +1 -1
- package/dist/{ts3.9/client → types}/index.d.ts +0 -0
- package/dist/types/preview/config.d.ts +1 -0
- package/dist/{ts3.9/client → types}/preview/globals.d.ts +0 -0
- package/dist/{ts3.9/client → types}/preview/index.d.ts +0 -0
- package/dist/{ts3.9/client → types}/preview/render.d.ts +0 -0
- package/dist/{ts3.9/client → types}/preview/types-6-0.d.ts +0 -0
- package/dist/{ts3.9/client → types}/preview/types-7-0.d.ts +0 -0
- package/dist/{ts3.9/client → types}/preview/types.d.ts +1 -1
- package/package.json +14 -37
- package/preview.js +1 -0
- package/bin/build.js +0 -4
- package/bin/index.js +0 -3
- package/dist/cjs/client/docs/prepareForInline.js +0 -29
- package/dist/cjs/client/preview/index.js +0 -50
- package/dist/cjs/client/preview/render.js +0 -57
- package/dist/cjs/server/build.js +0 -9
- package/dist/cjs/server/framework-preset-html-docs.js +0 -17
- package/dist/cjs/server/framework-preset-html.js +0 -23
- 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/esm/client/docs/config.js +0 -14
- package/dist/esm/client/docs/prepareForInline.js +0 -19
- package/dist/esm/client/docs/sourceDecorator.js +0 -56
- package/dist/esm/client/index.js +0 -6
- package/dist/esm/client/preview/config.js +0 -4
- package/dist/esm/client/preview/globals.js +0 -3
- package/dist/esm/client/preview/index.js +0 -27
- package/dist/esm/client/preview/render.js +0 -42
- package/dist/esm/server/build.js +0 -3
- package/dist/esm/server/framework-preset-html-docs.js +0 -6
- package/dist/esm/server/framework-preset-html.js +0 -11
- 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/modern/client/docs/prepareForInline.js +0 -17
- package/dist/modern/client/docs/sourceDecorator.js +0 -56
- package/dist/modern/client/preview/config.js +0 -4
- package/dist/modern/client/preview/types-6-0.js +0 -1
- package/dist/modern/client/preview/types-7-0.js +0 -1
- package/dist/modern/client/preview/types.js +0 -0
- package/dist/modern/server/build.js +0 -3
- package/dist/modern/server/framework-preset-html-docs.js +0 -6
- package/dist/modern/server/framework-preset-html.js +0 -11
- 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/ts3.4/client/docs/config.d.ts +0 -14
- package/dist/ts3.4/client/docs/prepareForInline.d.ts +0 -2
- package/dist/ts3.4/client/docs/sourceDecorator.d.ts +0 -3
- package/dist/ts3.4/client/index.d.ts +0 -2
- package/dist/ts3.4/client/preview/config.d.ts +0 -4
- package/dist/ts3.4/client/preview/globals.d.ts +0 -1
- package/dist/ts3.4/client/preview/index.d.ts +0 -24
- package/dist/ts3.4/client/preview/render.d.ts +0 -3
- package/dist/ts3.4/client/preview/types-6-0.d.ts +0 -34
- package/dist/ts3.4/client/preview/types-7-0.d.ts +0 -9
- package/dist/ts3.4/client/preview/types.d.ts +0 -14
- package/dist/ts3.4/server/build.d.ts +0 -1
- package/dist/ts3.4/server/framework-preset-html-docs.d.ts +0 -2
- package/dist/ts3.4/server/framework-preset-html.d.ts +0 -4
- 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.9/client/docs/prepareForInline.d.ts +0 -2
- package/dist/ts3.9/client/preview/config.d.ts +0 -4
- package/dist/ts3.9/server/build.d.ts +0 -1
- package/dist/ts3.9/server/framework-preset-html-docs.d.ts +0 -2
- package/dist/ts3.9/server/framework-preset-html.d.ts +0 -4
- 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/preset.js +0 -1
- package/standalone.js +0 -8
- package/types-7-0.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,25 +1 @@
|
|
|
1
|
-
# Storybook
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Storybook for HTML is a UI development environment for your plain HTML snippets.
|
|
6
|
-
With it, you can visualize different states of your UI components and develop them interactively.
|
|
7
|
-
|
|
8
|
-

|
|
9
|
-
|
|
10
|
-
Storybook runs outside of your app.
|
|
11
|
-
So you can develop UI components in isolation without worrying about app specific dependencies and requirements.
|
|
12
|
-
|
|
13
|
-
## Getting Started
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
cd my-app
|
|
17
|
-
npx sb init -t html
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
For more information visit: [storybook.js.org](https://storybook.js.org)
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
Storybook also comes with a lot of [addons](https://storybook.js.org/addons) and a great API to customize as you wish.
|
|
25
|
-
You can also build a [static version](https://storybook.js.org/docs/html/sharing/publish-storybook) of your Storybook and deploy it anywhere you want.
|
|
1
|
+
# Storybook HTML Renderer
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
parameters: true,
|
|
8
|
+
decorators: true
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "decorators", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _config.decorators;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
exports.parameters = void 0;
|
|
17
|
+
|
|
18
|
+
var _config = require("./docs/config");
|
|
19
|
+
|
|
20
|
+
var _config2 = require("./preview/config");
|
|
21
|
+
|
|
22
|
+
Object.keys(_config2).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
25
|
+
if (key in exports && exports[key] === _config2[key]) return;
|
|
26
|
+
Object.defineProperty(exports, key, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _config2[key];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
const parameters = Object.assign({
|
|
34
|
+
framework: 'html'
|
|
35
|
+
}, _config.parameters);
|
|
36
|
+
exports.parameters = parameters;
|
|
@@ -9,14 +9,11 @@ var _docsTools = require("@storybook/docs-tools");
|
|
|
9
9
|
|
|
10
10
|
var _sourceDecorator = require("./sourceDecorator");
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var decorators = [_sourceDecorator.sourceDecorator];
|
|
12
|
+
const decorators = [_sourceDecorator.sourceDecorator];
|
|
15
13
|
exports.decorators = decorators;
|
|
16
|
-
|
|
14
|
+
const parameters = {
|
|
17
15
|
docs: {
|
|
18
16
|
inlineStories: true,
|
|
19
|
-
prepareForInline: _prepareForInline.prepareForInline,
|
|
20
17
|
source: {
|
|
21
18
|
type: _docsTools.SourceType.DYNAMIC,
|
|
22
19
|
language: 'html'
|
|
@@ -13,12 +13,14 @@ var _tsDedent = _interopRequireDefault(require("ts-dedent"));
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
+
/* eslint-disable no-underscore-dangle */
|
|
17
|
+
|
|
16
18
|
/* global window */
|
|
17
19
|
function skipSourceRender(context) {
|
|
18
20
|
var _context$parameters$d;
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
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;
|
|
23
|
+
const isArgsStory = context === null || context === void 0 ? void 0 : context.parameters.__isArgsStory; // always render if the user forces it
|
|
22
24
|
|
|
23
25
|
if ((sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.DYNAMIC) {
|
|
24
26
|
return false;
|
|
@@ -36,31 +38,28 @@ function defaultTransformSource(source) {
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
function applyTransformSource(source, context) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var docs = (_context$parameters$d2 = context.parameters.docs) !== null && _context$parameters$d2 !== void 0 ? _context$parameters$d2 : {};
|
|
42
|
-
var transformSource = (_docs$transformSource = docs.transformSource) !== null && _docs$transformSource !== void 0 ? _docs$transformSource : defaultTransformSource;
|
|
41
|
+
const docs = context.parameters.docs ?? {};
|
|
42
|
+
const transformSource = docs.transformSource ?? defaultTransformSource;
|
|
43
43
|
return transformSource(source, context);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function sourceDecorator(storyFn, context) {
|
|
47
|
-
var _context$parameters$
|
|
47
|
+
var _context$parameters$d2, _context$parameters$d3;
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
const story = context !== null && context !== void 0 && (_context$parameters$d2 = context.parameters.docs) !== null && _context$parameters$d2 !== void 0 && (_context$parameters$d3 = _context$parameters$d2.source) !== null && _context$parameters$d3 !== void 0 && _context$parameters$d3.excludeDecorators ? context.originalStoryFn(context.args, context) : storyFn();
|
|
50
|
+
let source;
|
|
51
51
|
|
|
52
52
|
if (!skipSourceRender(context)) {
|
|
53
53
|
if (typeof story === 'string') {
|
|
54
54
|
source = story;
|
|
55
|
-
}
|
|
56
|
-
else if (story instanceof Element) {
|
|
55
|
+
} else if (story instanceof Element) {
|
|
57
56
|
source = story.outerHTML;
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
if (source) source = applyTransformSource(source, context);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
(0, _addons.useEffect)(
|
|
62
|
+
(0, _addons.useEffect)(() => {
|
|
64
63
|
if (source) _addons.addons.getChannel().emit(_docsTools.SNIPPET_RENDERED, context.id, source);
|
|
65
64
|
});
|
|
66
65
|
return story;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.object.to-string.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.object.keys.js");
|
|
8
|
-
|
|
9
3
|
Object.defineProperty(exports, "__esModule", {
|
|
10
4
|
value: true
|
|
11
5
|
});
|
|
@@ -21,49 +15,49 @@ var _exportNames = {
|
|
|
21
15
|
};
|
|
22
16
|
Object.defineProperty(exports, "addDecorator", {
|
|
23
17
|
enumerable: true,
|
|
24
|
-
get: function
|
|
18
|
+
get: function () {
|
|
25
19
|
return _preview.addDecorator;
|
|
26
20
|
}
|
|
27
21
|
});
|
|
28
22
|
Object.defineProperty(exports, "addParameters", {
|
|
29
23
|
enumerable: true,
|
|
30
|
-
get: function
|
|
24
|
+
get: function () {
|
|
31
25
|
return _preview.addParameters;
|
|
32
26
|
}
|
|
33
27
|
});
|
|
34
28
|
Object.defineProperty(exports, "configure", {
|
|
35
29
|
enumerable: true,
|
|
36
|
-
get: function
|
|
30
|
+
get: function () {
|
|
37
31
|
return _preview.configure;
|
|
38
32
|
}
|
|
39
33
|
});
|
|
40
34
|
Object.defineProperty(exports, "forceReRender", {
|
|
41
35
|
enumerable: true,
|
|
42
|
-
get: function
|
|
36
|
+
get: function () {
|
|
43
37
|
return _preview.forceReRender;
|
|
44
38
|
}
|
|
45
39
|
});
|
|
46
40
|
Object.defineProperty(exports, "getStorybook", {
|
|
47
41
|
enumerable: true,
|
|
48
|
-
get: function
|
|
42
|
+
get: function () {
|
|
49
43
|
return _preview.getStorybook;
|
|
50
44
|
}
|
|
51
45
|
});
|
|
52
46
|
Object.defineProperty(exports, "raw", {
|
|
53
47
|
enumerable: true,
|
|
54
|
-
get: function
|
|
48
|
+
get: function () {
|
|
55
49
|
return _preview.raw;
|
|
56
50
|
}
|
|
57
51
|
});
|
|
58
52
|
Object.defineProperty(exports, "setAddon", {
|
|
59
53
|
enumerable: true,
|
|
60
|
-
get: function
|
|
54
|
+
get: function () {
|
|
61
55
|
return _preview.setAddon;
|
|
62
56
|
}
|
|
63
57
|
});
|
|
64
58
|
Object.defineProperty(exports, "storiesOf", {
|
|
65
59
|
enumerable: true,
|
|
66
|
-
get: function
|
|
60
|
+
get: function () {
|
|
67
61
|
return _preview.storiesOf;
|
|
68
62
|
}
|
|
69
63
|
});
|
|
@@ -78,12 +72,13 @@ Object.keys(_types).forEach(function (key) {
|
|
|
78
72
|
if (key in exports && exports[key] === _types[key]) return;
|
|
79
73
|
Object.defineProperty(exports, key, {
|
|
80
74
|
enumerable: true,
|
|
81
|
-
get: function
|
|
75
|
+
get: function () {
|
|
82
76
|
return _types[key];
|
|
83
77
|
}
|
|
84
78
|
});
|
|
85
79
|
});
|
|
86
80
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
var _module, _module$hot;
|
|
82
|
+
|
|
83
|
+
// optimization: stop HMR propagation in webpack
|
|
84
|
+
(_module = module) === null || _module === void 0 ? void 0 : (_module$hot = _module.hot) === null || _module$hot === void 0 ? void 0 : _module$hot.decline();
|
|
@@ -3,17 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.parameters = void 0;
|
|
7
6
|
Object.defineProperty(exports, "renderToDOM", {
|
|
8
7
|
enumerable: true,
|
|
9
|
-
get: function
|
|
8
|
+
get: function () {
|
|
10
9
|
return _render.renderToDOM;
|
|
11
10
|
}
|
|
12
11
|
});
|
|
13
12
|
|
|
14
|
-
var _render = require("./render");
|
|
15
|
-
|
|
16
|
-
var parameters = {
|
|
17
|
-
framework: 'html'
|
|
18
|
-
};
|
|
19
|
-
exports.parameters = parameters;
|
|
13
|
+
var _render = require("./render");
|
|
@@ -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 = 'HTML';
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
require("./globals");
|
|
11
|
+
|
|
12
|
+
var _render = require("./render");
|
|
13
|
+
|
|
14
|
+
/* eslint-disable prefer-destructuring */
|
|
15
|
+
const framework = 'html';
|
|
16
|
+
const api = (0, _coreClient.start)(_render.renderToDOM);
|
|
17
|
+
|
|
18
|
+
const storiesOf = (kind, m) => {
|
|
19
|
+
return api.clientApi.storiesOf(kind, m).addParameters({
|
|
20
|
+
framework
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.storiesOf = storiesOf;
|
|
25
|
+
|
|
26
|
+
const configure = (...args) => api.configure(framework, ...args);
|
|
27
|
+
|
|
28
|
+
exports.configure = configure;
|
|
29
|
+
const addDecorator = api.clientApi.addDecorator;
|
|
30
|
+
exports.addDecorator = addDecorator;
|
|
31
|
+
const addParameters = api.clientApi.addParameters;
|
|
32
|
+
exports.addParameters = addParameters;
|
|
33
|
+
const clearDecorators = api.clientApi.clearDecorators;
|
|
34
|
+
exports.clearDecorators = clearDecorators;
|
|
35
|
+
const setAddon = api.clientApi.setAddon;
|
|
36
|
+
exports.setAddon = setAddon;
|
|
37
|
+
const forceReRender = api.forceReRender;
|
|
38
|
+
exports.forceReRender = forceReRender;
|
|
39
|
+
const getStorybook = api.clientApi.getStorybook;
|
|
40
|
+
exports.getStorybook = getStorybook;
|
|
41
|
+
const raw = api.clientApi.raw;
|
|
42
|
+
exports.raw = raw;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderToDOM = renderToDOM;
|
|
7
|
+
|
|
8
|
+
var _global = _interopRequireDefault(require("global"));
|
|
9
|
+
|
|
10
|
+
var _tsDedent = _interopRequireDefault(require("ts-dedent"));
|
|
11
|
+
|
|
12
|
+
var _previewWeb = require("@storybook/preview-web");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
/* eslint-disable no-param-reassign */
|
|
17
|
+
const {
|
|
18
|
+
Node
|
|
19
|
+
} = _global.default;
|
|
20
|
+
|
|
21
|
+
function renderToDOM({
|
|
22
|
+
storyFn,
|
|
23
|
+
kind,
|
|
24
|
+
name,
|
|
25
|
+
showMain,
|
|
26
|
+
showError,
|
|
27
|
+
forceRemount
|
|
28
|
+
}, domElement) {
|
|
29
|
+
const element = storyFn();
|
|
30
|
+
showMain();
|
|
31
|
+
|
|
32
|
+
if (typeof element === 'string') {
|
|
33
|
+
domElement.innerHTML = element;
|
|
34
|
+
(0, _previewWeb.simulatePageLoad)(domElement);
|
|
35
|
+
} else if (element instanceof Node) {
|
|
36
|
+
if (domElement.firstChild === element && forceRemount === false) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
domElement.innerHTML = '';
|
|
41
|
+
domElement.appendChild(element);
|
|
42
|
+
(0, _previewWeb.simulateDOMContentLoaded)();
|
|
43
|
+
} else {
|
|
44
|
+
showError({
|
|
45
|
+
title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${kind}".`,
|
|
46
|
+
description: (0, _tsDedent.default)`
|
|
47
|
+
Did you forget to return the HTML snippet from the story?
|
|
48
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
49
|
+
`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { SourceType } from '@storybook/docs-tools';
|
|
2
2
|
import { sourceDecorator } from './sourceDecorator';
|
|
3
|
-
import { prepareForInline } from './prepareForInline';
|
|
4
3
|
export const decorators = [sourceDecorator];
|
|
5
4
|
export const parameters = {
|
|
6
5
|
docs: {
|
|
7
6
|
inlineStories: true,
|
|
8
|
-
prepareForInline,
|
|
9
7
|
source: {
|
|
10
8
|
type: SourceType.DYNAMIC,
|
|
11
9
|
language: 'html'
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
|
|
3
|
+
/* global window */
|
|
4
|
+
import { SNIPPET_RENDERED, SourceType } from '@storybook/docs-tools';
|
|
5
|
+
import { addons, useEffect } from '@storybook/addons';
|
|
6
|
+
import dedent from 'ts-dedent';
|
|
7
|
+
|
|
8
|
+
function skipSourceRender(context) {
|
|
9
|
+
const sourceParams = context?.parameters.docs?.source;
|
|
10
|
+
const isArgsStory = context?.parameters.__isArgsStory; // always render if the user forces it
|
|
11
|
+
|
|
12
|
+
if (sourceParams?.type === SourceType.DYNAMIC) {
|
|
13
|
+
return false;
|
|
14
|
+
} // never render if the user is forcing the block to render code, or
|
|
15
|
+
// if the user provides code, or if it's not an args story.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
return !isArgsStory || sourceParams?.code || sourceParams?.type === SourceType.CODE;
|
|
19
|
+
} // By default, just remove indentation
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function defaultTransformSource(source) {
|
|
23
|
+
// Have to wrap dedent so it doesn't serialize the context
|
|
24
|
+
return dedent(source);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function applyTransformSource(source, context) {
|
|
28
|
+
const docs = context.parameters.docs ?? {};
|
|
29
|
+
const transformSource = docs.transformSource ?? defaultTransformSource;
|
|
30
|
+
return transformSource(source, context);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function sourceDecorator(storyFn, context) {
|
|
34
|
+
const story = context?.parameters.docs?.source?.excludeDecorators ? context.originalStoryFn(context.args, context) : storyFn();
|
|
35
|
+
let source;
|
|
36
|
+
|
|
37
|
+
if (!skipSourceRender(context)) {
|
|
38
|
+
if (typeof story === 'string') {
|
|
39
|
+
source = story;
|
|
40
|
+
} else if (story instanceof Element) {
|
|
41
|
+
source = story.outerHTML;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (source) source = applyTransformSource(source, context);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (source) addons.getChannel().emit(SNIPPET_RENDERED, context.id, source);
|
|
49
|
+
});
|
|
50
|
+
return story;
|
|
51
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw } from './preview';
|
|
2
|
-
export * from './preview/types-6-0';
|
|
2
|
+
export * from './preview/types-6-0'; // optimization: stop HMR propagation in webpack
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
module.hot.decline();
|
|
6
|
-
}
|
|
4
|
+
module?.hot?.decline();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { renderToDOM } from './render';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const parameters: {
|
|
2
|
+
docs: {
|
|
3
|
+
inlineStories: boolean;
|
|
4
|
+
source: {
|
|
5
|
+
type: import("lib/docs-tools/dist/types").SourceType;
|
|
6
|
+
language: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
framework: string;
|
|
10
|
+
};
|
|
11
|
+
export { decorators } from './docs/config';
|
|
12
|
+
export * from './preview/config';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { SourceType } from '@storybook/docs-tools';
|
|
2
2
|
import { sourceDecorator } from './sourceDecorator';
|
|
3
|
-
import { prepareForInline } from './prepareForInline';
|
|
4
3
|
export declare const decorators: (typeof sourceDecorator)[];
|
|
5
4
|
export declare const parameters: {
|
|
6
5
|
docs: {
|
|
7
6
|
inlineStories: boolean;
|
|
8
|
-
prepareForInline: typeof prepareForInline;
|
|
9
7
|
source: {
|
|
10
8
|
type: SourceType;
|
|
11
9
|
language: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PartialStoryFn, StoryContext } from '@storybook/csf';
|
|
2
2
|
import type { HtmlFramework } from '..';
|
|
3
|
-
export declare function sourceDecorator(storyFn: PartialStoryFn<HtmlFramework>, context: StoryContext<HtmlFramework>):
|
|
3
|
+
export declare function sourceDecorator(storyFn: PartialStoryFn<HtmlFramework>, context: StoryContext<HtmlFramework>): import("../preview/types").StoryFnHtmlReturnType;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { renderToDOM } from './render';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,41 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/html",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Storybook
|
|
3
|
+
"version": "7.0.0-alpha.2",
|
|
4
|
+
"description": "Storybook HTML renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
7
7
|
],
|
|
8
|
-
"homepage": "https://github.com/storybookjs/storybook/tree/main/
|
|
8
|
+
"homepage": "https://github.com/storybookjs/storybook/tree/main/renderers/html",
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/storybookjs/storybook/issues"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "https://github.com/storybookjs/storybook.git",
|
|
15
|
-
"directory": "
|
|
15
|
+
"directory": "renderers/html"
|
|
16
16
|
},
|
|
17
17
|
"funding": {
|
|
18
18
|
"type": "opencollective",
|
|
19
19
|
"url": "https://opencollective.com/storybook"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"main": "dist/cjs/
|
|
23
|
-
"module": "dist/esm/
|
|
24
|
-
"types": "dist/
|
|
25
|
-
"typesVersions": {
|
|
26
|
-
"<3.8": {
|
|
27
|
-
"dist/ts3.9/*": [
|
|
28
|
-
"dist/ts3.4/*"
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"bin": {
|
|
33
|
-
"build-storybook": "./bin/build.js",
|
|
34
|
-
"start-storybook": "./bin/index.js",
|
|
35
|
-
"storybook-server": "./bin/index.js"
|
|
36
|
-
},
|
|
22
|
+
"main": "dist/cjs/index.js",
|
|
23
|
+
"module": "dist/esm/index.js",
|
|
24
|
+
"types": "dist/types/index.d.ts",
|
|
37
25
|
"files": [
|
|
38
|
-
"bin/**/*",
|
|
39
26
|
"dist/**/*",
|
|
40
27
|
"README.md",
|
|
41
28
|
"*.js",
|
|
@@ -45,27 +32,18 @@
|
|
|
45
32
|
"prepare": "node ../../scripts/prepare.js"
|
|
46
33
|
},
|
|
47
34
|
"dependencies": {
|
|
48
|
-
"@storybook/addons": "
|
|
49
|
-
"@storybook/core": "
|
|
50
|
-
"@storybook/core-common": "6.5.9",
|
|
35
|
+
"@storybook/addons": "7.0.0-alpha.2",
|
|
36
|
+
"@storybook/core-client": "7.0.0-alpha.2",
|
|
51
37
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
52
|
-
"@storybook/docs-tools": "
|
|
53
|
-
"@storybook/preview-web": "
|
|
54
|
-
"@storybook/store": "
|
|
55
|
-
"@types/node": "^14.14.20 || ^16.0.0",
|
|
56
|
-
"@types/webpack-env": "^1.16.0",
|
|
38
|
+
"@storybook/docs-tools": "7.0.0-alpha.2",
|
|
39
|
+
"@storybook/preview-web": "7.0.0-alpha.2",
|
|
40
|
+
"@storybook/store": "7.0.0-alpha.2",
|
|
57
41
|
"core-js": "^3.8.2",
|
|
58
42
|
"global": "^4.4.0",
|
|
59
|
-
"html-loader": "^1.3.2",
|
|
60
43
|
"react": "16.14.0",
|
|
61
44
|
"react-dom": "16.14.0",
|
|
62
|
-
"read-pkg-up": "^7.0.1",
|
|
63
45
|
"regenerator-runtime": "^0.13.7",
|
|
64
|
-
"ts-dedent": "^2.0.0"
|
|
65
|
-
"webpack": ">=4.0.0 <6.0.0"
|
|
66
|
-
},
|
|
67
|
-
"devDependencies": {
|
|
68
|
-
"webpack": "4"
|
|
46
|
+
"ts-dedent": "^2.0.0"
|
|
69
47
|
},
|
|
70
48
|
"peerDependencies": {
|
|
71
49
|
"@babel/core": "*"
|
|
@@ -76,6 +54,5 @@
|
|
|
76
54
|
"publishConfig": {
|
|
77
55
|
"access": "public"
|
|
78
56
|
},
|
|
79
|
-
"gitHead": "
|
|
80
|
-
"sbmodern": "dist/modern/client/index.js"
|
|
57
|
+
"gitHead": "44920e2b6bd51981bac5124743c29fb9f5517e44"
|
|
81
58
|
}
|
package/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/esm/config';
|
package/bin/build.js
DELETED
package/bin/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.prepareForInline = prepareForInline;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
function prepareForInline(storyFn) {
|
|
13
|
-
var html = storyFn();
|
|
14
|
-
|
|
15
|
-
if (typeof html === 'string') {
|
|
16
|
-
// eslint-disable-next-line react/no-danger
|
|
17
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
18
|
-
dangerouslySetInnerHTML: {
|
|
19
|
-
__html: html
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
25
|
-
ref: function ref(node) {
|
|
26
|
-
return node ? node.appendChild(html) : null;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|