@storybook/web-components 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 -71
- package/dist/cjs/config.js +43 -0
- package/dist/cjs/{client/customElements.js → customElements.js} +2 -1
- package/dist/cjs/{client/docs → docs}/config.js +3 -6
- package/dist/cjs/{client/docs → docs}/custom-elements.js +47 -73
- package/dist/{modern/client → cjs}/docs/sourceDecorator.js +24 -14
- package/dist/cjs/{client/index.js → index.js} +22 -25
- 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/{client/preview → preview}/render.js +22 -25
- 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}/customElements.js +0 -0
- package/dist/{modern/client → esm}/docs/config.js +0 -2
- package/dist/{modern/client → esm}/docs/custom-elements.js +29 -37
- package/dist/esm/docs/sourceDecorator.js +45 -0
- package/dist/{modern/client → esm}/index.js +0 -0
- 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 +16 -0
- package/dist/{ts3.9/client → types}/customElements.d.ts +0 -0
- package/dist/{ts3.9/client → types}/docs/config.d.ts +2 -3
- package/dist/{ts3.9/client → types}/docs/custom-elements.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/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 +15 -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 -96
- package/dist/cjs/client/docs/sourceDecorator.js +0 -63
- package/dist/cjs/client/preview/index.js +0 -50
- package/dist/cjs/server/build.js +0 -9
- package/dist/cjs/server/framework-preset-web-components-docs.js +0 -17
- package/dist/cjs/server/framework-preset-web-components.js +0 -46
- 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/customElements.js +0 -41
- package/dist/esm/client/docs/config.js +0 -18
- package/dist/esm/client/docs/custom-elements.js +0 -140
- package/dist/esm/client/docs/prepareForInline.js +0 -74
- package/dist/esm/client/docs/sourceDecorator.js +0 -52
- package/dist/esm/client/index.js +0 -24
- 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 -58
- package/dist/esm/server/build.js +0 -3
- package/dist/esm/server/framework-preset-web-components-docs.js +0 -6
- package/dist/esm/server/framework-preset-web-components.js +0 -34
- 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 -23
- 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 -1
- package/dist/modern/server/build.js +0 -3
- package/dist/modern/server/framework-preset-web-components-docs.js +0 -6
- package/dist/modern/server/framework-preset-web-components.js +0 -34
- 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/customElements.d.ts +0 -8
- package/dist/ts3.4/client/docs/config.d.ts +0 -18
- package/dist/ts3.4/client/docs/custom-elements.d.ts +0 -36
- package/dist/ts3.4/client/docs/prepareForInline.d.ts +0 -4
- package/dist/ts3.4/client/docs/sourceDecorator.d.ts +0 -3
- package/dist/ts3.4/client/index.d.ts +0 -3
- 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 -16
- package/dist/ts3.4/server/build.d.ts +0 -1
- package/dist/ts3.4/server/framework-preset-web-components-docs.d.ts +0 -2
- package/dist/ts3.4/server/framework-preset-web-components.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 -4
- 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-web-components-docs.d.ts +0 -2
- package/dist/ts3.9/server/framework-preset-web-components.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-6-0.d.ts +0 -1
- package/types-7-0.d.ts +0 -1
|
@@ -1,18 +1,10 @@
|
|
|
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"));
|
|
@@ -23,22 +15,24 @@ var _directiveHelpers = require("lit-html/directive-helpers.js");
|
|
|
23
15
|
|
|
24
16
|
var _previewWeb = require("@storybook/preview-web");
|
|
25
17
|
|
|
26
|
-
var _templateObject;
|
|
27
|
-
|
|
28
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
19
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
20
|
+
/* eslint-disable no-param-reassign */
|
|
21
|
+
// Keep `.js` extension to avoid issue with Webpack (related to export map?)
|
|
22
|
+
// eslint-disable-next-line import/extensions
|
|
23
|
+
const {
|
|
24
|
+
Node
|
|
25
|
+
} = _global.default;
|
|
26
|
+
|
|
27
|
+
function renderToDOM({
|
|
28
|
+
storyFn,
|
|
29
|
+
kind,
|
|
30
|
+
name,
|
|
31
|
+
showMain,
|
|
32
|
+
showError,
|
|
33
|
+
forceRemount
|
|
34
|
+
}, domElement) {
|
|
35
|
+
const element = storyFn();
|
|
42
36
|
showMain();
|
|
43
37
|
|
|
44
38
|
if ((0, _directiveHelpers.isTemplateResult)(element)) {
|
|
@@ -49,7 +43,7 @@ function renderToDOM(_ref, domElement) {
|
|
|
49
43
|
domElement.innerHTML = '<div id="root-inner"></div>';
|
|
50
44
|
}
|
|
51
45
|
|
|
52
|
-
|
|
46
|
+
const renderTo = domElement.querySelector('[id="root-inner"]');
|
|
53
47
|
(0, _litHtml.render)(element, renderTo);
|
|
54
48
|
(0, _previewWeb.simulatePageLoad)(domElement);
|
|
55
49
|
} else if (typeof element === 'string') {
|
|
@@ -66,8 +60,11 @@ function renderToDOM(_ref, domElement) {
|
|
|
66
60
|
(0, _previewWeb.simulateDOMContentLoaded)();
|
|
67
61
|
} else {
|
|
68
62
|
showError({
|
|
69
|
-
title:
|
|
70
|
-
description: (0, _tsDedent.default)
|
|
63
|
+
title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${kind}".`,
|
|
64
|
+
description: (0, _tsDedent.default)`
|
|
65
|
+
Did you forget to return the HTML snippet from the story?
|
|
66
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
67
|
+
`
|
|
71
68
|
});
|
|
72
69
|
}
|
|
73
70
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { SourceType, enhanceArgTypes } from '@storybook/docs-tools';
|
|
2
2
|
import { extractArgTypes, extractComponentDescription } from './custom-elements';
|
|
3
3
|
import { sourceDecorator } from './sourceDecorator';
|
|
4
|
-
import { prepareForInline } from './prepareForInline';
|
|
5
4
|
export const decorators = [sourceDecorator];
|
|
6
5
|
export const parameters = {
|
|
7
6
|
docs: {
|
|
8
7
|
extractArgTypes,
|
|
9
8
|
extractComponentDescription,
|
|
10
9
|
inlineStories: true,
|
|
11
|
-
prepareForInline,
|
|
12
10
|
source: {
|
|
13
11
|
type: SourceType.DYNAMIC,
|
|
14
12
|
language: 'html'
|
|
@@ -1,32 +1,9 @@
|
|
|
1
|
-
import "core-js/modules/es.array.reduce.js";
|
|
2
1
|
import { logger } from '@storybook/client-logger';
|
|
3
2
|
import { getCustomElements, isValidComponent, isValidMetaData } from '..';
|
|
4
3
|
|
|
5
|
-
function mapData(data, category) {
|
|
6
|
-
return data && data.filter(item => item && item.name).reduce((acc, item) => {
|
|
7
|
-
if (item.kind === 'method') return acc;
|
|
8
|
-
|
|
9
|
-
switch (category) {
|
|
10
|
-
case 'events':
|
|
11
|
-
mapEvent(item).forEach(argType => {
|
|
12
|
-
acc[argType.name] = argType;
|
|
13
|
-
});
|
|
14
|
-
break;
|
|
15
|
-
|
|
16
|
-
default:
|
|
17
|
-
acc[item.name] = mapItem(item, category);
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return acc;
|
|
22
|
-
}, {});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
4
|
function mapItem(item, category) {
|
|
26
|
-
var _item$type, _item$type2;
|
|
27
|
-
|
|
28
5
|
const type = category === 'properties' ? {
|
|
29
|
-
name:
|
|
6
|
+
name: item.type?.text || item.type
|
|
30
7
|
} : {
|
|
31
8
|
name: 'void'
|
|
32
9
|
};
|
|
@@ -38,7 +15,7 @@ function mapItem(item, category) {
|
|
|
38
15
|
table: {
|
|
39
16
|
category,
|
|
40
17
|
type: {
|
|
41
|
-
summary:
|
|
18
|
+
summary: item.type?.text || item.type
|
|
42
19
|
},
|
|
43
20
|
defaultValue: {
|
|
44
21
|
summary: item.default !== undefined ? item.default : item.defaultValue
|
|
@@ -63,6 +40,26 @@ function mapEvent(item) {
|
|
|
63
40
|
}, mapItem(item, 'events')];
|
|
64
41
|
}
|
|
65
42
|
|
|
43
|
+
function mapData(data, category) {
|
|
44
|
+
return data && data.filter(item => item && item.name).reduce((acc, item) => {
|
|
45
|
+
if (item.kind === 'method') return acc;
|
|
46
|
+
|
|
47
|
+
switch (category) {
|
|
48
|
+
case 'events':
|
|
49
|
+
mapEvent(item).forEach(argType => {
|
|
50
|
+
acc[argType.name] = argType;
|
|
51
|
+
});
|
|
52
|
+
break;
|
|
53
|
+
|
|
54
|
+
default:
|
|
55
|
+
acc[item.name] = mapItem(item, category);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return acc;
|
|
60
|
+
}, {});
|
|
61
|
+
}
|
|
62
|
+
|
|
66
63
|
const getMetaDataExperimental = (tagName, customElements) => {
|
|
67
64
|
if (!isValidComponent(tagName) || !isValidMetaData(customElements)) {
|
|
68
65
|
return null;
|
|
@@ -78,17 +75,13 @@ const getMetaDataExperimental = (tagName, customElements) => {
|
|
|
78
75
|
};
|
|
79
76
|
|
|
80
77
|
const getMetaDataV1 = (tagName, customElements) => {
|
|
81
|
-
var _customElements$modul;
|
|
82
|
-
|
|
83
78
|
if (!isValidComponent(tagName) || !isValidMetaData(customElements)) {
|
|
84
79
|
return null;
|
|
85
80
|
}
|
|
86
81
|
|
|
87
82
|
let metadata;
|
|
88
|
-
customElements
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
_module === null || _module === void 0 ? void 0 : (_module$declarations = _module.declarations) === null || _module$declarations === void 0 ? void 0 : _module$declarations.forEach(declaration => {
|
|
83
|
+
customElements?.modules?.forEach(_module => {
|
|
84
|
+
_module?.declarations?.forEach(declaration => {
|
|
92
85
|
if (declaration.tagName === tagName) {
|
|
93
86
|
metadata = declaration;
|
|
94
87
|
}
|
|
@@ -102,19 +95,18 @@ const getMetaDataV1 = (tagName, customElements) => {
|
|
|
102
95
|
return metadata;
|
|
103
96
|
};
|
|
104
97
|
|
|
105
|
-
export const extractArgTypesFromElements = (tagName, customElements) => {
|
|
106
|
-
const metaData = getMetaData(tagName, customElements);
|
|
107
|
-
return metaData && Object.assign({}, mapData(metaData.attributes, 'attributes'), mapData(metaData.members, 'properties'), mapData(metaData.properties, 'properties'), mapData(metaData.events, 'events'), mapData(metaData.slots, 'slots'), mapData(metaData.cssProperties, 'css custom properties'), mapData(metaData.cssParts, 'css shadow parts'));
|
|
108
|
-
};
|
|
109
|
-
|
|
110
98
|
const getMetaData = (tagName, manifest) => {
|
|
111
|
-
if (
|
|
99
|
+
if (manifest?.version === 'experimental') {
|
|
112
100
|
return getMetaDataExperimental(tagName, manifest);
|
|
113
101
|
}
|
|
114
102
|
|
|
115
103
|
return getMetaDataV1(tagName, manifest);
|
|
116
104
|
};
|
|
117
105
|
|
|
106
|
+
export const extractArgTypesFromElements = (tagName, customElements) => {
|
|
107
|
+
const metaData = getMetaData(tagName, customElements);
|
|
108
|
+
return metaData && Object.assign({}, mapData(metaData.attributes, 'attributes'), mapData(metaData.members, 'properties'), mapData(metaData.properties, 'properties'), mapData(metaData.events, 'events'), mapData(metaData.slots, 'slots'), mapData(metaData.cssProperties, 'css custom properties'), mapData(metaData.cssParts, 'css shadow parts'));
|
|
109
|
+
};
|
|
118
110
|
export const extractArgTypes = tagName => {
|
|
119
111
|
const cem = getCustomElements();
|
|
120
112
|
return extractArgTypesFromElements(tagName, cem);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
|
|
3
|
+
/* global window */
|
|
4
|
+
import { render } from 'lit-html';
|
|
5
|
+
import { addons, useEffect } from '@storybook/addons';
|
|
6
|
+
import { SNIPPET_RENDERED, SourceType } from '@storybook/docs-tools';
|
|
7
|
+
// Taken from https://github.com/lit/lit/blob/main/packages/lit-html/src/test/test-utils/strip-markers.ts
|
|
8
|
+
const LIT_EXPRESSION_COMMENTS = /<!--\?lit\$[0-9]+\$-->|<!--\??-->/g;
|
|
9
|
+
|
|
10
|
+
function skipSourceRender(context) {
|
|
11
|
+
const sourceParams = context?.parameters.docs?.source;
|
|
12
|
+
const isArgsStory = context?.parameters.__isArgsStory; // always render if the user forces it
|
|
13
|
+
|
|
14
|
+
if (sourceParams?.type === SourceType.DYNAMIC) {
|
|
15
|
+
return false;
|
|
16
|
+
} // never render if the user is forcing the block to render code, or
|
|
17
|
+
// if the user provides code, or if it's not an args story.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
return !isArgsStory || sourceParams?.code || sourceParams?.type === SourceType.CODE;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function applyTransformSource(source, context) {
|
|
24
|
+
const {
|
|
25
|
+
transformSource
|
|
26
|
+
} = context.parameters.docs ?? {};
|
|
27
|
+
if (typeof transformSource !== 'function') return source;
|
|
28
|
+
return transformSource(source, context);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function sourceDecorator(storyFn, context) {
|
|
32
|
+
const story = context?.parameters.docs?.source?.excludeDecorators ? context.originalStoryFn(context.args, context) : storyFn();
|
|
33
|
+
let source;
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (source) addons.getChannel().emit(SNIPPET_RENDERED, context.id, source);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (!skipSourceRender(context)) {
|
|
39
|
+
const container = window.document.createElement('div');
|
|
40
|
+
render(story, container);
|
|
41
|
+
source = applyTransformSource(container.innerHTML.replace(LIT_EXPRESSION_COMMENTS, ''), context);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return story;
|
|
45
|
+
}
|
|
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
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const parameters: {
|
|
2
|
+
docs: {
|
|
3
|
+
extractArgTypes: (tagName: string) => {
|
|
4
|
+
[x: string]: import("lib/api/dist/types").ArgType;
|
|
5
|
+
};
|
|
6
|
+
extractComponentDescription: (tagName: string) => string;
|
|
7
|
+
inlineStories: boolean;
|
|
8
|
+
source: {
|
|
9
|
+
type: import("lib/docs-tools/dist/types").SourceType;
|
|
10
|
+
language: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
framework: string;
|
|
14
|
+
};
|
|
15
|
+
export { decorators, argTypesEnhancers } from './docs/config';
|
|
16
|
+
export * from './preview/config';
|
|
File without changes
|
|
@@ -4,15 +4,14 @@ export declare const decorators: (typeof sourceDecorator)[];
|
|
|
4
4
|
export declare const parameters: {
|
|
5
5
|
docs: {
|
|
6
6
|
extractArgTypes: (tagName: string) => {
|
|
7
|
-
[x: string]: import("
|
|
7
|
+
[x: string]: import("lib/api/dist/types").ArgType;
|
|
8
8
|
};
|
|
9
9
|
extractComponentDescription: (tagName: string) => string;
|
|
10
10
|
inlineStories: boolean;
|
|
11
|
-
prepareForInline: (storyFn: import("@storybook/csf").PartialStoryFn<import("..").WebComponentsFramework, import("@storybook/csf").Args>) => import("react").CElement<{}, import("react").Component<{}, {}, any>>;
|
|
12
11
|
source: {
|
|
13
12
|
type: SourceType;
|
|
14
13
|
language: string;
|
|
15
14
|
};
|
|
16
15
|
};
|
|
17
16
|
};
|
|
18
|
-
export declare const argTypesEnhancers: (<TFramework extends import("@storybook/csf").AnyFramework>(context: import("@storybook/csf").StoryContextForEnhancers<TFramework, import("@storybook/csf").Args>) => import("@storybook/
|
|
17
|
+
export declare const argTypesEnhancers: (<TFramework extends import("@storybook/csf").AnyFramework>(context: import("@storybook/csf").StoryContextForEnhancers<TFramework, import("@storybook/csf").Args>) => import("@storybook/csf").StrictArgTypes<import("@storybook/csf").Args> | import("lib/addons/dist/types").Parameters)[];
|
|
File without changes
|
|
File without changes
|
|
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
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TemplateResult, SVGTemplateResult } from 'lit-html';
|
|
2
|
-
export type { RenderContext } from '@storybook/core';
|
|
2
|
+
export type { RenderContext } from '@storybook/core-client';
|
|
3
3
|
export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/addons';
|
|
4
4
|
export declare type StoryFnHtmlReturnType = string | Node | TemplateResult | SVGTemplateResult;
|
|
5
5
|
export interface IStorybookStory {
|
package/package.json
CHANGED
|
@@ -1,43 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/web-components",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Storybook
|
|
3
|
+
"version": "7.0.0-alpha.2",
|
|
4
|
+
"description": "Storybook web-components renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lit-html",
|
|
7
7
|
"storybook",
|
|
8
8
|
"web-components"
|
|
9
9
|
],
|
|
10
|
-
"homepage": "https://github.com/storybookjs/storybook/tree/main/
|
|
10
|
+
"homepage": "https://github.com/storybookjs/storybook/tree/main/renderers/web-components",
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/storybookjs/storybook/issues"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/storybookjs/storybook.git",
|
|
17
|
-
"directory": "
|
|
17
|
+
"directory": "renderers/web-components"
|
|
18
18
|
},
|
|
19
19
|
"funding": {
|
|
20
20
|
"type": "opencollective",
|
|
21
21
|
"url": "https://opencollective.com/storybook"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
|
-
"main": "dist/cjs/
|
|
25
|
-
"module": "dist/esm/
|
|
26
|
-
"types": "dist/
|
|
27
|
-
"typesVersions": {
|
|
28
|
-
"<3.8": {
|
|
29
|
-
"dist/ts3.9/*": [
|
|
30
|
-
"dist/ts3.4/*"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"bin": {
|
|
35
|
-
"build-storybook": "./bin/build.js",
|
|
36
|
-
"start-storybook": "./bin/index.js",
|
|
37
|
-
"storybook-server": "./bin/index.js"
|
|
38
|
-
},
|
|
24
|
+
"main": "dist/cjs/index.js",
|
|
25
|
+
"module": "dist/esm/index.js",
|
|
26
|
+
"types": "dist/types/index.d.ts",
|
|
39
27
|
"files": [
|
|
40
|
-
"bin/**/*",
|
|
41
28
|
"dist/**/*",
|
|
42
29
|
"README.md",
|
|
43
30
|
"*.js",
|
|
@@ -47,26 +34,18 @@
|
|
|
47
34
|
"prepare": "node ../../scripts/prepare.js"
|
|
48
35
|
},
|
|
49
36
|
"dependencies": {
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@storybook/
|
|
54
|
-
"@storybook/client-api": "6.5.9",
|
|
55
|
-
"@storybook/client-logger": "6.5.9",
|
|
56
|
-
"@storybook/core": "6.5.9",
|
|
57
|
-
"@storybook/core-common": "6.5.9",
|
|
37
|
+
"@storybook/addons": "7.0.0-alpha.2",
|
|
38
|
+
"@storybook/api": "7.0.0-alpha.2",
|
|
39
|
+
"@storybook/client-logger": "7.0.0-alpha.2",
|
|
40
|
+
"@storybook/core-client": "7.0.0-alpha.2",
|
|
58
41
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
59
|
-
"@storybook/docs-tools": "
|
|
60
|
-
"@storybook/preview-web": "
|
|
61
|
-
"@storybook/store": "
|
|
62
|
-
"@types/node": "^14.14.20 || ^16.0.0",
|
|
63
|
-
"@types/webpack-env": "^1.16.0",
|
|
64
|
-
"babel-plugin-bundled-import-meta": "^0.3.1",
|
|
42
|
+
"@storybook/docs-tools": "7.0.0-alpha.2",
|
|
43
|
+
"@storybook/preview-web": "7.0.0-alpha.2",
|
|
44
|
+
"@storybook/store": "7.0.0-alpha.2",
|
|
65
45
|
"core-js": "^3.8.2",
|
|
66
46
|
"global": "^4.4.0",
|
|
67
47
|
"react": "16.14.0",
|
|
68
48
|
"react-dom": "16.14.0",
|
|
69
|
-
"read-pkg-up": "^7.0.1",
|
|
70
49
|
"regenerator-runtime": "^0.13.7",
|
|
71
50
|
"ts-dedent": "^2.0.0"
|
|
72
51
|
},
|
|
@@ -82,6 +61,5 @@
|
|
|
82
61
|
"publishConfig": {
|
|
83
62
|
"access": "public"
|
|
84
63
|
},
|
|
85
|
-
"gitHead": "
|
|
86
|
-
"sbmodern": "dist/modern/client/index.js"
|
|
64
|
+
"gitHead": "44920e2b6bd51981bac5124743c29fb9f5517e44"
|
|
87
65
|
}
|
package/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/esm/config';
|
package/bin/build.js
DELETED
package/bin/index.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.object.to-string.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.reflect.construct.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.symbol.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.symbol.description.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.array.iterator.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.string.iterator.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, "__esModule", {
|
|
22
|
-
value: true
|
|
23
|
-
});
|
|
24
|
-
exports.prepareForInline = void 0;
|
|
25
|
-
|
|
26
|
-
require("core-js/modules/es.array.concat.js");
|
|
27
|
-
|
|
28
|
-
require("core-js/modules/es.object.get-prototype-of.js");
|
|
29
|
-
|
|
30
|
-
var _react = _interopRequireDefault(require("react"));
|
|
31
|
-
|
|
32
|
-
var _litHtml = require("lit-html");
|
|
33
|
-
|
|
34
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
-
|
|
36
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37
|
-
|
|
38
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
39
|
-
|
|
40
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
41
|
-
|
|
42
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
43
|
-
|
|
44
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
45
|
-
|
|
46
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
47
|
-
|
|
48
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
49
|
-
|
|
50
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
51
|
-
|
|
52
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
53
|
-
|
|
54
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
|
-
|
|
56
|
-
var prepareForInline = function prepareForInline(storyFn) {
|
|
57
|
-
var Story = /*#__PURE__*/function (_React$Component) {
|
|
58
|
-
_inherits(Story, _React$Component);
|
|
59
|
-
|
|
60
|
-
var _super = _createSuper(Story);
|
|
61
|
-
|
|
62
|
-
function Story() {
|
|
63
|
-
var _this;
|
|
64
|
-
|
|
65
|
-
_classCallCheck(this, Story);
|
|
66
|
-
|
|
67
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
68
|
-
args[_key] = arguments[_key];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
72
|
-
_this.wrapperRef = /*#__PURE__*/_react.default.createRef();
|
|
73
|
-
return _this;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
_createClass(Story, [{
|
|
77
|
-
key: "componentDidMount",
|
|
78
|
-
value: function componentDidMount() {
|
|
79
|
-
(0, _litHtml.render)(storyFn(), this.wrapperRef.current);
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "render",
|
|
83
|
-
value: function render() {
|
|
84
|
-
return /*#__PURE__*/_react.default.createElement('div', {
|
|
85
|
-
ref: this.wrapperRef
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}]);
|
|
89
|
-
|
|
90
|
-
return Story;
|
|
91
|
-
}(_react.default.Component);
|
|
92
|
-
|
|
93
|
-
return /*#__PURE__*/_react.default.createElement(Story);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
exports.prepareForInline = prepareForInline;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.sourceDecorator = sourceDecorator;
|
|
7
|
-
|
|
8
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.string.replace.js");
|
|
11
|
-
|
|
12
|
-
var _litHtml = require("lit-html");
|
|
13
|
-
|
|
14
|
-
var _addons = require("@storybook/addons");
|
|
15
|
-
|
|
16
|
-
var _docsTools = require("@storybook/docs-tools");
|
|
17
|
-
|
|
18
|
-
/* global window */
|
|
19
|
-
// Taken from https://github.com/lit/lit/blob/main/packages/lit-html/src/test/test-utils/strip-markers.ts
|
|
20
|
-
var LIT_EXPRESSION_COMMENTS = /<!--\?lit\$[0-9]+\$-->|<!--\??-->/g;
|
|
21
|
-
|
|
22
|
-
function skipSourceRender(context) {
|
|
23
|
-
var _context$parameters$d;
|
|
24
|
-
|
|
25
|
-
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;
|
|
26
|
-
var isArgsStory = context === null || context === void 0 ? void 0 : context.parameters.__isArgsStory; // always render if the user forces it
|
|
27
|
-
|
|
28
|
-
if ((sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.DYNAMIC) {
|
|
29
|
-
return false;
|
|
30
|
-
} // never render if the user is forcing the block to render code, or
|
|
31
|
-
// if the user provides code, or if it's not an args story.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return !isArgsStory || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.code) || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.CODE;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function applyTransformSource(source, context) {
|
|
38
|
-
var _context$parameters$d2;
|
|
39
|
-
|
|
40
|
-
var _ref = (_context$parameters$d2 = context.parameters.docs) !== null && _context$parameters$d2 !== void 0 ? _context$parameters$d2 : {},
|
|
41
|
-
transformSource = _ref.transformSource;
|
|
42
|
-
|
|
43
|
-
if (typeof transformSource !== 'function') return source;
|
|
44
|
-
return transformSource(source, context);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function sourceDecorator(storyFn, context) {
|
|
48
|
-
var _context$parameters$d3, _context$parameters$d4;
|
|
49
|
-
|
|
50
|
-
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();
|
|
51
|
-
var source;
|
|
52
|
-
(0, _addons.useEffect)(function () {
|
|
53
|
-
if (source) _addons.addons.getChannel().emit(_docsTools.SNIPPET_RENDERED, context.id, source);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (!skipSourceRender(context)) {
|
|
57
|
-
var container = window.document.createElement('div');
|
|
58
|
-
(0, _litHtml.render)(story, container);
|
|
59
|
-
source = applyTransformSource(container.innerHTML.replace(LIT_EXPRESSION_COMMENTS, ''), context);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return story;
|
|
63
|
-
}
|