@storybook/html 7.0.0-alpha.6 → 7.0.0-alpha.60

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.
Files changed (65) hide show
  1. package/dist/chunk-ZJLPYI6H.mjs +7 -0
  2. package/dist/config.d.ts +4 -0
  3. package/dist/config.js +7 -0
  4. package/dist/config.mjs +1 -0
  5. package/dist/index.d.ts +50 -0
  6. package/dist/index.js +7 -0
  7. package/dist/index.mjs +1 -0
  8. package/dist/types-fb08647b.d.ts +36 -0
  9. package/jest.config.js +7 -0
  10. package/package.json +39 -15
  11. package/preview.js +1 -1
  12. package/template/cli/.eslintrc.json +6 -0
  13. package/template/cli/js/Button.js +21 -0
  14. package/template/cli/js/Button.stories.js +50 -0
  15. package/template/cli/js/Header.js +47 -0
  16. package/template/cli/js/Header.stories.js +28 -0
  17. package/template/cli/js/Page.js +94 -0
  18. package/template/cli/js/Page.stories.js +24 -0
  19. package/template/cli/ts/Button.stories.ts +55 -0
  20. package/template/cli/ts/Button.ts +51 -0
  21. package/template/cli/ts/Header.stories.ts +33 -0
  22. package/template/cli/ts/Header.ts +54 -0
  23. package/template/cli/ts/Page.stories.ts +27 -0
  24. package/template/cli/ts/Page.ts +98 -0
  25. package/template/components/Button.js +9 -0
  26. package/template/components/Form.js +32 -0
  27. package/template/components/Html.js +1 -0
  28. package/template/components/Pre.js +15 -0
  29. package/template/components/index.js +9 -0
  30. package/template/stories/README.md +1 -0
  31. package/template/stories/html-mdx.stories.mdx +21 -0
  32. package/LICENSE +0 -21
  33. package/dist/cjs/config.js +0 -36
  34. package/dist/cjs/docs/config.js +0 -23
  35. package/dist/cjs/docs/sourceDecorator.js +0 -68
  36. package/dist/cjs/index.js +0 -84
  37. package/dist/cjs/preview/config.js +0 -13
  38. package/dist/cjs/preview/globals.js +0 -10
  39. package/dist/cjs/preview/index.js +0 -42
  40. package/dist/cjs/preview/render.js +0 -52
  41. package/dist/cjs/preview/types-6-0.js +0 -5
  42. package/dist/cjs/preview/types-7-0.js +0 -5
  43. package/dist/cjs/preview/types.js +0 -1
  44. package/dist/esm/config.js +0 -6
  45. package/dist/esm/docs/config.js +0 -12
  46. package/dist/esm/docs/sourceDecorator.js +0 -53
  47. package/dist/esm/index.js +0 -4
  48. package/dist/esm/preview/config.js +0 -1
  49. package/dist/esm/preview/globals.js +0 -5
  50. package/dist/esm/preview/index.js +0 -19
  51. package/dist/esm/preview/render.js +0 -39
  52. package/dist/esm/preview/types-6-0.js +0 -1
  53. package/dist/esm/preview/types-7-0.js +0 -1
  54. package/dist/esm/preview/types.js +0 -0
  55. package/dist/types/config.d.ts +0 -12
  56. package/dist/types/docs/config.d.ts +0 -12
  57. package/dist/types/docs/sourceDecorator.d.ts +0 -3
  58. package/dist/types/index.d.ts +0 -2
  59. package/dist/types/preview/config.d.ts +0 -1
  60. package/dist/types/preview/globals.d.ts +0 -1
  61. package/dist/types/preview/index.d.ts +0 -24
  62. package/dist/types/preview/render.d.ts +0 -3
  63. package/dist/types/preview/types-6-0.d.ts +0 -34
  64. package/dist/types/preview/types-7-0.d.ts +0 -9
  65. package/dist/types/preview/types.d.ts +0 -14
@@ -0,0 +1,54 @@
1
+ import './header.css';
2
+ import { createButton } from './Button';
3
+
4
+ export interface HeaderProps {
5
+ user?: { name: string };
6
+ onLogin: () => void;
7
+ onLogout: () => void;
8
+ onCreateAccount: () => void;
9
+ }
10
+
11
+ export const createHeader = ({ user, onLogout, onLogin, onCreateAccount }: HeaderProps) => {
12
+ const header = document.createElement('header');
13
+
14
+ const wrapper = document.createElement('div');
15
+ wrapper.className = 'wrapper';
16
+
17
+ const logo = `<div>
18
+ <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
19
+ <g fill="none" fillRule="evenodd">
20
+ <path
21
+ d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
22
+ fill="#FFF" />
23
+ <path
24
+ d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
25
+ fill="#555AB9" />
26
+ <path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
27
+ </g>
28
+ </svg>
29
+ <h1>Acme</h1>
30
+ </div>`;
31
+
32
+ wrapper.insertAdjacentHTML('afterbegin', logo);
33
+
34
+ const account = document.createElement('div');
35
+ if (user) {
36
+ const welcomeMessage = `<span class="welcome">Welcome, <b>${user.name}</b>!</span>`;
37
+ account.innerHTML = welcomeMessage;
38
+ account.appendChild(createButton({ size: 'small', label: 'Log out', onClick: onLogout }));
39
+ } else {
40
+ account.appendChild(createButton({ size: 'small', label: 'Log in', onClick: onLogin }));
41
+ account.appendChild(
42
+ createButton({
43
+ size: 'small',
44
+ label: 'Sign up',
45
+ onClick: onCreateAccount,
46
+ primary: true,
47
+ })
48
+ );
49
+ }
50
+ wrapper.appendChild(account);
51
+ header.appendChild(wrapper);
52
+
53
+ return header;
54
+ };
@@ -0,0 +1,27 @@
1
+ import type { Meta, StoryObj } from '@storybook/html';
2
+ import { within, userEvent } from '@storybook/testing-library';
3
+ import { createPage } from './Page';
4
+
5
+ const meta: Meta = {
6
+ title: 'Example/Page',
7
+ render: () => createPage(),
8
+ parameters: {
9
+ // More on how to position stories at: https://storybook.js.org/docs/7.0/html/configure/story-layout
10
+ layout: 'fullscreen',
11
+ },
12
+ };
13
+
14
+ export default meta;
15
+
16
+ export const LoggedOut: StoryObj = {};
17
+
18
+ // More on interaction testing: https://storybook.js.org/docs/7.0/html/writing-tests/interaction-testing
19
+ export const LoggedIn: StoryObj = {
20
+ play: async ({ canvasElement }) => {
21
+ const canvas = within(canvasElement);
22
+ const loginButton = await canvas.getByRole('button', {
23
+ name: /Log in/i,
24
+ });
25
+ await userEvent.click(loginButton);
26
+ },
27
+ };
@@ -0,0 +1,98 @@
1
+ import './page.css';
2
+ import { createHeader } from './Header';
3
+
4
+ type User = {
5
+ name: string;
6
+ };
7
+
8
+ export const createPage = () => {
9
+ const article = document.createElement('article');
10
+ let user: User | undefined;
11
+ let header: HTMLElement | null = null;
12
+
13
+ const rerenderHeader = () => {
14
+ const wrapper = document.getElementsByTagName('article')[0];
15
+ wrapper.replaceChild(createHeaderElement(), wrapper.firstChild as HTMLElement);
16
+ };
17
+
18
+ const onLogin = () => {
19
+ user = { name: 'Jane Doe' };
20
+ rerenderHeader();
21
+ };
22
+
23
+ const onLogout = () => {
24
+ user = undefined;
25
+ rerenderHeader();
26
+ };
27
+
28
+ const onCreateAccount = () => {
29
+ user = { name: 'Jane Doe' };
30
+ rerenderHeader();
31
+ };
32
+
33
+ const createHeaderElement = () => {
34
+ return createHeader({ onLogin, onLogout, onCreateAccount, user });
35
+ };
36
+
37
+ header = createHeaderElement();
38
+ article.appendChild(header);
39
+
40
+ const section = `
41
+ <section>
42
+ <h2>Pages in Storybook</h2>
43
+ <p>
44
+ We recommend building UIs with a
45
+ <a
46
+ href="https://blog.hichroma.com/component-driven-development-ce1109d56c8e"
47
+ target="_blank"
48
+ rel="noopener noreferrer">
49
+ <strong>component-driven</strong>
50
+ </a>
51
+ process starting with atomic components and ending with pages.
52
+ </p>
53
+ <p>
54
+ Render pages with mock data. This makes it easy to build and review page states without
55
+ needing to navigate to them in your app. Here are some handy patterns for managing page data
56
+ in Storybook:
57
+ </p>
58
+ <ul>
59
+ <li>
60
+ Use a higher-level connected component. Storybook helps you compose such data from the
61
+ "args" of child component stories
62
+ </li>
63
+ <li>
64
+ Assemble data in the page component from your services. You can mock these services out
65
+ using Storybook.
66
+ </li>
67
+ </ul>
68
+ <p>
69
+ Get a guided tutorial on component-driven development at
70
+ <a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
71
+ Storybook tutorials
72
+ </a>
73
+ . Read more in the
74
+ <a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">docs</a>
75
+ .
76
+ </p>
77
+ <div class="tip-wrapper">
78
+ <span class="tip">Tip</span>
79
+ Adjust the width of the canvas with the
80
+ <svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
81
+ <g fill="none" fillRule="evenodd">
82
+ <path
83
+ d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0
84
+ 01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0
85
+ 010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z"
86
+ id="a"
87
+ fill="#999" />
88
+ </g>
89
+ </svg>
90
+ Viewports addon in the toolbar
91
+ </div>
92
+ </section>
93
+ `;
94
+
95
+ article.insertAdjacentHTML('beforeend', section);
96
+
97
+ return article;
98
+ };
@@ -0,0 +1,9 @@
1
+ /* eslint-disable no-undef */
2
+ export const Button = (args) => {
3
+ const button = document.createElement('button');
4
+
5
+ button.innerHTML = args.label;
6
+ button.addEventListener('click', args.onClick);
7
+
8
+ return button;
9
+ };
@@ -0,0 +1,32 @@
1
+ /* eslint-disable no-undef */
2
+ export const Form = ({ onSuccess }) => {
3
+ const container = document.createElement('div');
4
+
5
+ const getInnerHTML = ({ complete }) => `
6
+ <form id="interaction-test-form">
7
+ <label>
8
+ Enter Value
9
+ <input type="text" data-testid="value" required />
10
+ </label>
11
+ <button type="submit">Submit</button>
12
+ ${complete ? '<p>Completed!!</p>' : ''}
13
+ </form>
14
+ `;
15
+
16
+ container.innerHTML = getInnerHTML({ complete: false });
17
+
18
+ const form = container.querySelector('form');
19
+ form.addEventListener('submit', (e) => {
20
+ e.preventDefault();
21
+
22
+ setTimeout(() => {
23
+ container.innerHTML = getInnerHTML({ complete: true });
24
+ }, 500);
25
+ setTimeout(() => {
26
+ container.innerHTML = getInnerHTML({ complete: false });
27
+ }, 1500);
28
+ onSuccess(e);
29
+ });
30
+
31
+ return container;
32
+ };
@@ -0,0 +1 @@
1
+ export const Html = `<div>{{content}}</div>`;
@@ -0,0 +1,15 @@
1
+ /* eslint-disable no-undef */
2
+ export const Pre = (args) => {
3
+ const pre = document.createElement('pre');
4
+
5
+ pre.setAttribute('data-testid', 'pre');
6
+ pre.style = args.style;
7
+
8
+ if (args.object) {
9
+ pre.textContent = JSON.stringify(args.object, null, 2);
10
+ } else {
11
+ pre.textContent = args.text;
12
+ }
13
+
14
+ return pre;
15
+ };
@@ -0,0 +1,9 @@
1
+ import globalThis from 'global';
2
+
3
+ import { Button } from './Button';
4
+ import { Pre } from './Pre';
5
+ import { Form } from './Form';
6
+ import { Html } from './Html';
7
+
8
+ globalThis.Components = { Button, Pre, Form, Html };
9
+ globalThis.storybookRenderer = 'html';
@@ -0,0 +1 @@
1
+ Placeholder until we write some render-specific stories
@@ -0,0 +1,21 @@
1
+ import { Meta, Story, Canvas } from '@storybook/addon-docs';
2
+
3
+ <Meta title="html/html-mdx" />
4
+
5
+ ## HTML-specific MDX Stories
6
+
7
+ <Canvas>
8
+ <Story name="Basic" height="100px">
9
+ {'<h1>Hello World</h1>'}
10
+ </Story>
11
+ </Canvas>
12
+
13
+ <Canvas>
14
+ <Story name="Function" height="100px">
15
+ {() => {
16
+ const btn = document.createElement('button');
17
+ btn.innerHTML = 'Hello Button';
18
+ return btn;
19
+ }}
20
+ </Story>
21
+ </Canvas>
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 Kadira Inc. <hello@kadira.io>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,36 +0,0 @@
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;
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.parameters = exports.decorators = void 0;
7
-
8
- var _docsTools = require("@storybook/docs-tools");
9
-
10
- var _sourceDecorator = require("./sourceDecorator");
11
-
12
- const decorators = [_sourceDecorator.sourceDecorator];
13
- exports.decorators = decorators;
14
- const parameters = {
15
- docs: {
16
- inlineStories: true,
17
- source: {
18
- type: _docsTools.SourceType.DYNAMIC,
19
- language: 'html'
20
- }
21
- }
22
- };
23
- exports.parameters = parameters;
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.sourceDecorator = sourceDecorator;
7
-
8
- var _docsTools = require("@storybook/docs-tools");
9
-
10
- var _addons = require("@storybook/addons");
11
-
12
- var _tsDedent = _interopRequireDefault(require("ts-dedent"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- /* eslint-disable no-underscore-dangle */
17
-
18
- /* global window */
19
- function skipSourceRender(context) {
20
- var _context$parameters$d;
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
24
-
25
- if ((sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.DYNAMIC) {
26
- return false;
27
- } // never render if the user is forcing the block to render code, or
28
- // if the user provides code, or if it's not an args story.
29
-
30
-
31
- return !isArgsStory || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.code) || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.CODE;
32
- } // By default, just remove indentation
33
-
34
-
35
- function defaultTransformSource(source) {
36
- // Have to wrap dedent so it doesn't serialize the context
37
- return (0, _tsDedent.default)(source);
38
- }
39
-
40
- function applyTransformSource(source, context) {
41
- const docs = context.parameters.docs ?? {};
42
- const transformSource = docs.transformSource ?? defaultTransformSource;
43
- return transformSource(source, context);
44
- }
45
-
46
- function sourceDecorator(storyFn, context) {
47
- var _context$parameters$d2, _context$parameters$d3;
48
-
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
-
52
- if (!skipSourceRender(context)) {
53
- if (typeof story === 'string') {
54
- source = story;
55
- } else if (story instanceof Element) {
56
- source = story.outerHTML;
57
- }
58
-
59
- if (source) {
60
- source = applyTransformSource(source, context);
61
- }
62
- }
63
-
64
- (0, _addons.useEffect)(() => {
65
- if (source) _addons.addons.getChannel().emit(_docsTools.SNIPPET_RENDERED, context.id, source);
66
- });
67
- return story;
68
- }
package/dist/cjs/index.js DELETED
@@ -1,84 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- storiesOf: true,
8
- setAddon: true,
9
- addDecorator: true,
10
- addParameters: true,
11
- configure: true,
12
- getStorybook: true,
13
- forceReRender: true,
14
- raw: true
15
- };
16
- Object.defineProperty(exports, "addDecorator", {
17
- enumerable: true,
18
- get: function () {
19
- return _preview.addDecorator;
20
- }
21
- });
22
- Object.defineProperty(exports, "addParameters", {
23
- enumerable: true,
24
- get: function () {
25
- return _preview.addParameters;
26
- }
27
- });
28
- Object.defineProperty(exports, "configure", {
29
- enumerable: true,
30
- get: function () {
31
- return _preview.configure;
32
- }
33
- });
34
- Object.defineProperty(exports, "forceReRender", {
35
- enumerable: true,
36
- get: function () {
37
- return _preview.forceReRender;
38
- }
39
- });
40
- Object.defineProperty(exports, "getStorybook", {
41
- enumerable: true,
42
- get: function () {
43
- return _preview.getStorybook;
44
- }
45
- });
46
- Object.defineProperty(exports, "raw", {
47
- enumerable: true,
48
- get: function () {
49
- return _preview.raw;
50
- }
51
- });
52
- Object.defineProperty(exports, "setAddon", {
53
- enumerable: true,
54
- get: function () {
55
- return _preview.setAddon;
56
- }
57
- });
58
- Object.defineProperty(exports, "storiesOf", {
59
- enumerable: true,
60
- get: function () {
61
- return _preview.storiesOf;
62
- }
63
- });
64
-
65
- var _preview = require("./preview");
66
-
67
- var _types = require("./preview/types-6-0");
68
-
69
- Object.keys(_types).forEach(function (key) {
70
- if (key === "default" || key === "__esModule") return;
71
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
72
- if (key in exports && exports[key] === _types[key]) return;
73
- Object.defineProperty(exports, key, {
74
- enumerable: true,
75
- get: function () {
76
- return _types[key];
77
- }
78
- });
79
- });
80
-
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();
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "renderToDOM", {
7
- enumerable: true,
8
- get: function () {
9
- return _render.renderToDOM;
10
- }
11
- });
12
-
13
- var _render = require("./render");
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- var _global = _interopRequireDefault(require("global"));
4
-
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
-
7
- const {
8
- window: globalWindow
9
- } = _global.default;
10
- globalWindow.STORYBOOK_ENV = 'HTML';
@@ -1,42 +0,0 @@
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;
@@ -1,52 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,6 +0,0 @@
1
- import { parameters as docsParams } from './docs/config';
2
- export const parameters = Object.assign({
3
- framework: 'html'
4
- }, docsParams);
5
- export { decorators } from './docs/config';
6
- export * from './preview/config';
@@ -1,12 +0,0 @@
1
- import { SourceType } from '@storybook/docs-tools';
2
- import { sourceDecorator } from './sourceDecorator';
3
- export const decorators = [sourceDecorator];
4
- export const parameters = {
5
- docs: {
6
- inlineStories: true,
7
- source: {
8
- type: SourceType.DYNAMIC,
9
- language: 'html'
10
- }
11
- }
12
- };