@storybook/html 7.0.0-alpha.1 → 7.0.0-alpha.4
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/dist/cjs/config.js +3 -11
- package/dist/cjs/docs/config.js +2 -5
- package/dist/cjs/docs/sourceDecorator.js +11 -11
- package/dist/cjs/index.js +9 -15
- package/dist/cjs/preview/config.js +1 -1
- package/dist/cjs/preview/globals.js +3 -1
- package/dist/cjs/preview/index.js +12 -20
- package/dist/cjs/preview/render.js +19 -24
- package/dist/esm/docs/config.js +0 -2
- package/dist/esm/docs/sourceDecorator.js +3 -1
- package/dist/types/config.d.ts +0 -1
- package/dist/types/docs/config.d.ts +0 -2
- package/dist/types/preview/render.d.ts +2 -2
- package/package.json +7 -8
- package/dist/cjs/docs/prepareForInline.js +0 -29
- package/dist/esm/docs/prepareForInline.js +0 -17
- package/dist/types/docs/prepareForInline.d.ts +0 -2
package/dist/cjs/config.js
CHANGED
|
@@ -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
|
});
|
|
@@ -15,14 +9,12 @@ var _exportNames = {
|
|
|
15
9
|
};
|
|
16
10
|
Object.defineProperty(exports, "decorators", {
|
|
17
11
|
enumerable: true,
|
|
18
|
-
get: function
|
|
12
|
+
get: function () {
|
|
19
13
|
return _config.decorators;
|
|
20
14
|
}
|
|
21
15
|
});
|
|
22
16
|
exports.parameters = void 0;
|
|
23
17
|
|
|
24
|
-
require("core-js/modules/es.object.assign.js");
|
|
25
|
-
|
|
26
18
|
var _config = require("./docs/config");
|
|
27
19
|
|
|
28
20
|
var _config2 = require("./preview/config");
|
|
@@ -33,12 +25,12 @@ Object.keys(_config2).forEach(function (key) {
|
|
|
33
25
|
if (key in exports && exports[key] === _config2[key]) return;
|
|
34
26
|
Object.defineProperty(exports, key, {
|
|
35
27
|
enumerable: true,
|
|
36
|
-
get: function
|
|
28
|
+
get: function () {
|
|
37
29
|
return _config2[key];
|
|
38
30
|
}
|
|
39
31
|
});
|
|
40
32
|
});
|
|
41
|
-
|
|
33
|
+
const parameters = Object.assign({
|
|
42
34
|
framework: 'html'
|
|
43
35
|
}, _config.parameters);
|
|
44
36
|
exports.parameters = parameters;
|
package/dist/cjs/docs/config.js
CHANGED
|
@@ -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'
|
|
@@ -19,8 +19,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
19
|
function skipSourceRender(context) {
|
|
20
20
|
var _context$parameters$d;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
24
24
|
|
|
25
25
|
if ((sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.DYNAMIC) {
|
|
26
26
|
return false;
|
|
@@ -38,18 +38,16 @@ function defaultTransformSource(source) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function applyTransformSource(source, context) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var docs = (_context$parameters$d2 = context.parameters.docs) !== null && _context$parameters$d2 !== void 0 ? _context$parameters$d2 : {};
|
|
44
|
-
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;
|
|
45
43
|
return transformSource(source, context);
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
function sourceDecorator(storyFn, context) {
|
|
49
|
-
var _context$parameters$
|
|
47
|
+
var _context$parameters$d2, _context$parameters$d3;
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
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;
|
|
53
51
|
|
|
54
52
|
if (!skipSourceRender(context)) {
|
|
55
53
|
if (typeof story === 'string') {
|
|
@@ -58,10 +56,12 @@ function sourceDecorator(storyFn, context) {
|
|
|
58
56
|
source = story.outerHTML;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
if (source)
|
|
59
|
+
if (source) {
|
|
60
|
+
source = applyTransformSource(source, context);
|
|
61
|
+
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
(0, _addons.useEffect)(
|
|
64
|
+
(0, _addons.useEffect)(() => {
|
|
65
65
|
if (source) _addons.addons.getChannel().emit(_docsTools.SNIPPET_RENDERED, context.id, source);
|
|
66
66
|
});
|
|
67
67
|
return story;
|
package/dist/cjs/index.js
CHANGED
|
@@ -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,7 +72,7 @@ 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
|
});
|
|
@@ -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';
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.storiesOf = exports.setAddon = exports.raw = exports.getStorybook = exports.forceReRender = exports.configure = exports.clearDecorators = exports.addParameters = exports.addDecorator = void 0;
|
|
7
7
|
|
|
8
|
-
require("core-js/modules/es.array.concat.js");
|
|
9
|
-
|
|
10
8
|
var _coreClient = require("@storybook/core-client");
|
|
11
9
|
|
|
12
10
|
require("./globals");
|
|
@@ -14,37 +12,31 @@ require("./globals");
|
|
|
14
12
|
var _render = require("./render");
|
|
15
13
|
|
|
16
14
|
/* eslint-disable prefer-destructuring */
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const framework = 'html';
|
|
16
|
+
const api = (0, _coreClient.start)(_render.renderToDOM);
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
const storiesOf = (kind, m) => {
|
|
21
19
|
return api.clientApi.storiesOf(kind, m).addParameters({
|
|
22
|
-
framework
|
|
20
|
+
framework
|
|
23
21
|
});
|
|
24
22
|
};
|
|
25
23
|
|
|
26
24
|
exports.storiesOf = storiesOf;
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
|
-
args[_key] = arguments[_key];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return api.configure.apply(api, [framework].concat(args));
|
|
34
|
-
};
|
|
26
|
+
const configure = (...args) => api.configure(framework, ...args);
|
|
35
27
|
|
|
36
28
|
exports.configure = configure;
|
|
37
|
-
|
|
29
|
+
const addDecorator = api.clientApi.addDecorator;
|
|
38
30
|
exports.addDecorator = addDecorator;
|
|
39
|
-
|
|
31
|
+
const addParameters = api.clientApi.addParameters;
|
|
40
32
|
exports.addParameters = addParameters;
|
|
41
|
-
|
|
33
|
+
const clearDecorators = api.clientApi.clearDecorators;
|
|
42
34
|
exports.clearDecorators = clearDecorators;
|
|
43
|
-
|
|
35
|
+
const setAddon = api.clientApi.setAddon;
|
|
44
36
|
exports.setAddon = setAddon;
|
|
45
|
-
|
|
37
|
+
const forceReRender = api.forceReRender;
|
|
46
38
|
exports.forceReRender = forceReRender;
|
|
47
|
-
|
|
39
|
+
const getStorybook = api.clientApi.getStorybook;
|
|
48
40
|
exports.getStorybook = getStorybook;
|
|
49
|
-
|
|
41
|
+
const raw = api.clientApi.raw;
|
|
50
42
|
exports.raw = raw;
|
|
@@ -1,40 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.array.slice.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.object.freeze.js");
|
|
6
|
-
|
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
6
|
exports.renderToDOM = renderToDOM;
|
|
11
7
|
|
|
12
|
-
require("core-js/modules/es.function.name.js");
|
|
13
|
-
|
|
14
|
-
require("core-js/modules/es.array.concat.js");
|
|
15
|
-
|
|
16
8
|
var _global = _interopRequireDefault(require("global"));
|
|
17
9
|
|
|
18
10
|
var _tsDedent = _interopRequireDefault(require("ts-dedent"));
|
|
19
11
|
|
|
20
12
|
var _previewWeb = require("@storybook/preview-web");
|
|
21
13
|
|
|
22
|
-
var _templateObject;
|
|
23
|
-
|
|
24
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
15
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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();
|
|
38
30
|
showMain();
|
|
39
31
|
|
|
40
32
|
if (typeof element === 'string') {
|
|
@@ -50,8 +42,11 @@ function renderToDOM(_ref, domElement) {
|
|
|
50
42
|
(0, _previewWeb.simulateDOMContentLoaded)();
|
|
51
43
|
} else {
|
|
52
44
|
showError({
|
|
53
|
-
title:
|
|
54
|
-
description: (0, _tsDedent.default)
|
|
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
|
+
`
|
|
55
50
|
});
|
|
56
51
|
}
|
|
57
52
|
}
|
package/dist/esm/docs/config.js
CHANGED
|
@@ -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'
|
package/dist/types/config.d.ts
CHANGED
|
@@ -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
|
-
import { RenderContext } from '@storybook/store';
|
|
1
|
+
import type { RenderContext } from '@storybook/store';
|
|
2
2
|
import { HtmlFramework } from './types-6-0';
|
|
3
|
-
export declare function renderToDOM({ storyFn, kind, name, showMain, showError, forceRemount }: RenderContext<HtmlFramework>, domElement:
|
|
3
|
+
export declare function renderToDOM({ storyFn, kind, name, showMain, showError, forceRemount }: RenderContext<HtmlFramework>, domElement: Element): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/html",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.4",
|
|
4
4
|
"description": "Storybook HTML renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -32,17 +32,16 @@
|
|
|
32
32
|
"prepare": "node ../../scripts/prepare.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
36
|
-
"@storybook/core-client": "7.0.0-alpha.
|
|
35
|
+
"@storybook/addons": "7.0.0-alpha.4",
|
|
36
|
+
"@storybook/core-client": "7.0.0-alpha.4",
|
|
37
37
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
38
|
-
"@storybook/docs-tools": "7.0.0-alpha.
|
|
39
|
-
"@storybook/preview-web": "7.0.0-alpha.
|
|
40
|
-
"@storybook/store": "7.0.0-alpha.
|
|
38
|
+
"@storybook/docs-tools": "7.0.0-alpha.4",
|
|
39
|
+
"@storybook/preview-web": "7.0.0-alpha.4",
|
|
40
|
+
"@storybook/store": "7.0.0-alpha.4",
|
|
41
41
|
"core-js": "^3.8.2",
|
|
42
42
|
"global": "^4.4.0",
|
|
43
43
|
"react": "16.14.0",
|
|
44
44
|
"react-dom": "16.14.0",
|
|
45
|
-
"regenerator-runtime": "^0.13.7",
|
|
46
45
|
"ts-dedent": "^2.0.0"
|
|
47
46
|
},
|
|
48
47
|
"peerDependencies": {
|
|
@@ -54,5 +53,5 @@
|
|
|
54
53
|
"publishConfig": {
|
|
55
54
|
"access": "public"
|
|
56
55
|
},
|
|
57
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "006ed54452dd7c37a8cbe91a84f5312182f7ca00"
|
|
58
57
|
}
|
|
@@ -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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export function prepareForInline(storyFn) {
|
|
3
|
-
const html = storyFn();
|
|
4
|
-
|
|
5
|
-
if (typeof html === 'string') {
|
|
6
|
-
// eslint-disable-next-line react/no-danger
|
|
7
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
8
|
-
dangerouslySetInnerHTML: {
|
|
9
|
-
__html: html
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
-
ref: node => node ? node.appendChild(html) : null
|
|
16
|
-
});
|
|
17
|
-
}
|