@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.
@@ -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 get() {
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 get() {
28
+ get: function () {
37
29
  return _config2[key];
38
30
  }
39
31
  });
40
32
  });
41
- var parameters = Object.assign({
33
+ const parameters = Object.assign({
42
34
  framework: 'html'
43
35
  }, _config.parameters);
44
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
- var _prepareForInline = require("./prepareForInline");
13
-
14
- var decorators = [_sourceDecorator.sourceDecorator];
12
+ const decorators = [_sourceDecorator.sourceDecorator];
15
13
  exports.decorators = decorators;
16
- var parameters = {
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
- var 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
- var isArgsStory = context === null || context === void 0 ? void 0 : context.parameters.__isArgsStory; // always render if the user forces it
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
- var _context$parameters$d2, _docs$transformSource;
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$d3, _context$parameters$d4;
47
+ var _context$parameters$d2, _context$parameters$d3;
50
48
 
51
- var story = context !== null && context !== void 0 && (_context$parameters$d3 = context.parameters.docs) !== null && _context$parameters$d3 !== void 0 && (_context$parameters$d4 = _context$parameters$d3.source) !== null && _context$parameters$d4 !== void 0 && _context$parameters$d4.excludeDecorators ? context.originalStoryFn(context.args, context) : storyFn();
52
- var source;
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) source = applyTransformSource(source, context);
59
+ if (source) {
60
+ source = applyTransformSource(source, context);
61
+ }
62
62
  }
63
63
 
64
- (0, _addons.useEffect)(function () {
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 get() {
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 get() {
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 get() {
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 get() {
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 get() {
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 get() {
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 get() {
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 get() {
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 get() {
75
+ get: function () {
82
76
  return _types[key];
83
77
  }
84
78
  });
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "renderToDOM", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _render.renderToDOM;
10
10
  }
11
11
  });
@@ -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
- var globalWindow = _global.default.window;
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
- var framework = 'html';
18
- var api = (0, _coreClient.start)(_render.renderToDOM);
15
+ const framework = 'html';
16
+ const api = (0, _coreClient.start)(_render.renderToDOM);
19
17
 
20
- var storiesOf = function storiesOf(kind, m) {
18
+ const storiesOf = (kind, m) => {
21
19
  return api.clientApi.storiesOf(kind, m).addParameters({
22
- framework: framework
20
+ framework
23
21
  });
24
22
  };
25
23
 
26
24
  exports.storiesOf = storiesOf;
27
25
 
28
- var configure = function configure() {
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
- var addDecorator = api.clientApi.addDecorator;
29
+ const addDecorator = api.clientApi.addDecorator;
38
30
  exports.addDecorator = addDecorator;
39
- var addParameters = api.clientApi.addParameters;
31
+ const addParameters = api.clientApi.addParameters;
40
32
  exports.addParameters = addParameters;
41
- var clearDecorators = api.clientApi.clearDecorators;
33
+ const clearDecorators = api.clientApi.clearDecorators;
42
34
  exports.clearDecorators = clearDecorators;
43
- var setAddon = api.clientApi.setAddon;
35
+ const setAddon = api.clientApi.setAddon;
44
36
  exports.setAddon = setAddon;
45
- var forceReRender = api.forceReRender;
37
+ const forceReRender = api.forceReRender;
46
38
  exports.forceReRender = forceReRender;
47
- var getStorybook = api.clientApi.getStorybook;
39
+ const getStorybook = api.clientApi.getStorybook;
48
40
  exports.getStorybook = getStorybook;
49
- var raw = api.clientApi.raw;
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
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
27
-
28
- var Node = _global.default.Node;
29
-
30
- function renderToDOM(_ref, domElement) {
31
- var storyFn = _ref.storyFn,
32
- kind = _ref.kind,
33
- name = _ref.name,
34
- showMain = _ref.showMain,
35
- showError = _ref.showError,
36
- forceRemount = _ref.forceRemount;
37
- var element = storyFn();
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: "Expecting an HTML snippet or DOM node from the story: \"".concat(name, "\" of \"").concat(kind, "\"."),
54
- description: (0, _tsDedent.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n Did you forget to return the HTML snippet from the story?\n Use \"() => <your snippet or node>\" or when defining the story.\n "])))
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
  }
@@ -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'
@@ -41,7 +41,9 @@ export function sourceDecorator(storyFn, context) {
41
41
  source = story.outerHTML;
42
42
  }
43
43
 
44
- if (source) source = applyTransformSource(source, context);
44
+ if (source) {
45
+ source = applyTransformSource(source, context);
46
+ }
45
47
  }
46
48
 
47
49
  useEffect(() => {
@@ -1,7 +1,6 @@
1
1
  export declare const parameters: {
2
2
  docs: {
3
3
  inlineStories: boolean;
4
- prepareForInline: typeof import("./docs/prepareForInline").prepareForInline;
5
4
  source: {
6
5
  type: import("lib/docs-tools/dist/types").SourceType;
7
6
  language: string;
@@ -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: HTMLElement): void;
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.1",
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.1",
36
- "@storybook/core-client": "7.0.0-alpha.1",
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.1",
39
- "@storybook/preview-web": "7.0.0-alpha.1",
40
- "@storybook/store": "7.0.0-alpha.1",
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": "b90b85210f66da59656c2ef58b0910b156256bea"
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
- }
@@ -1,2 +0,0 @@
1
- import { PartialStoryFn } from '@storybook/csf';
2
- export declare function prepareForInline(storyFn: PartialStoryFn<any>): JSX.Element;