@storybook/web-components 7.0.0-alpha.1 → 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/dist/cjs/config.js +4 -12
- package/dist/cjs/customElements.js +2 -1
- package/dist/cjs/docs/config.js +3 -6
- package/dist/cjs/docs/custom-elements.js +24 -50
- package/dist/cjs/docs/sourceDecorator.js +11 -17
- package/dist/cjs/index.js +22 -25
- 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 +22 -25
- package/dist/esm/docs/config.js +0 -2
- package/dist/types/config.d.ts +0 -1
- package/dist/types/docs/config.d.ts +0 -1
- package/package.json +9 -9
- package/dist/cjs/docs/prepareForInline.js +0 -96
- package/dist/esm/docs/prepareForInline.js +0 -24
- package/dist/types/docs/prepareForInline.d.ts +0 -4
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
|
});
|
|
@@ -16,20 +10,18 @@ var _exportNames = {
|
|
|
16
10
|
};
|
|
17
11
|
Object.defineProperty(exports, "argTypesEnhancers", {
|
|
18
12
|
enumerable: true,
|
|
19
|
-
get: function
|
|
13
|
+
get: function () {
|
|
20
14
|
return _config.argTypesEnhancers;
|
|
21
15
|
}
|
|
22
16
|
});
|
|
23
17
|
Object.defineProperty(exports, "decorators", {
|
|
24
18
|
enumerable: true,
|
|
25
|
-
get: function
|
|
19
|
+
get: function () {
|
|
26
20
|
return _config.decorators;
|
|
27
21
|
}
|
|
28
22
|
});
|
|
29
23
|
exports.parameters = void 0;
|
|
30
24
|
|
|
31
|
-
require("core-js/modules/es.object.assign.js");
|
|
32
|
-
|
|
33
25
|
var _config = require("./docs/config");
|
|
34
26
|
|
|
35
27
|
var _config2 = require("./preview/config");
|
|
@@ -40,12 +32,12 @@ Object.keys(_config2).forEach(function (key) {
|
|
|
40
32
|
if (key in exports && exports[key] === _config2[key]) return;
|
|
41
33
|
Object.defineProperty(exports, key, {
|
|
42
34
|
enumerable: true,
|
|
43
|
-
get: function
|
|
35
|
+
get: function () {
|
|
44
36
|
return _config2[key];
|
|
45
37
|
}
|
|
46
38
|
});
|
|
47
39
|
});
|
|
48
|
-
|
|
40
|
+
const parameters = Object.assign({
|
|
49
41
|
framework: 'web-components'
|
|
50
42
|
}, _config.parameters);
|
|
51
43
|
exports.parameters = parameters;
|
|
@@ -33,7 +33,8 @@ function isValidMetaData(customElements) {
|
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
throw new Error(
|
|
36
|
+
throw new Error(`You need to setup valid meta data in your config.js via setCustomElements().
|
|
37
|
+
See the readme of addon-docs for web components for more details.`);
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* @param customElements any for now as spec is not super stable yet
|
package/dist/cjs/docs/config.js
CHANGED
|
@@ -11,16 +11,13 @@ var _customElements = require("./custom-elements");
|
|
|
11
11
|
|
|
12
12
|
var _sourceDecorator = require("./sourceDecorator");
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var decorators = [_sourceDecorator.sourceDecorator];
|
|
14
|
+
const decorators = [_sourceDecorator.sourceDecorator];
|
|
17
15
|
exports.decorators = decorators;
|
|
18
|
-
|
|
16
|
+
const parameters = {
|
|
19
17
|
docs: {
|
|
20
18
|
extractArgTypes: _customElements.extractArgTypes,
|
|
21
19
|
extractComponentDescription: _customElements.extractComponentDescription,
|
|
22
20
|
inlineStories: true,
|
|
23
|
-
prepareForInline: _prepareForInline.prepareForInline,
|
|
24
21
|
source: {
|
|
25
22
|
type: _docsTools.SourceType.DYNAMIC,
|
|
26
23
|
language: 'html'
|
|
@@ -28,5 +25,5 @@ var parameters = {
|
|
|
28
25
|
}
|
|
29
26
|
};
|
|
30
27
|
exports.parameters = parameters;
|
|
31
|
-
|
|
28
|
+
const argTypesEnhancers = [_docsTools.enhanceArgTypes];
|
|
32
29
|
exports.argTypesEnhancers = argTypesEnhancers;
|
|
@@ -5,26 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.extractComponentDescription = exports.extractArgTypesFromElements = exports.extractArgTypes = void 0;
|
|
7
7
|
|
|
8
|
-
require("core-js/modules/es.function.name.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.symbol.js");
|
|
11
|
-
|
|
12
|
-
require("core-js/modules/es.symbol.description.js");
|
|
13
|
-
|
|
14
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
15
|
-
|
|
16
|
-
require("core-js/modules/es.string.replace.js");
|
|
17
|
-
|
|
18
|
-
require("core-js/modules/es.object.to-string.js");
|
|
19
|
-
|
|
20
|
-
require("core-js/modules/es.array.filter.js");
|
|
21
|
-
|
|
22
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
23
|
-
|
|
24
|
-
require("core-js/modules/es.array.find.js");
|
|
25
|
-
|
|
26
|
-
require("core-js/modules/es.object.assign.js");
|
|
27
|
-
|
|
28
8
|
var _clientLogger = require("@storybook/client-logger");
|
|
29
9
|
|
|
30
10
|
var _ = require("..");
|
|
@@ -32,7 +12,7 @@ var _ = require("..");
|
|
|
32
12
|
function mapItem(item, category) {
|
|
33
13
|
var _item$type, _item$type2;
|
|
34
14
|
|
|
35
|
-
|
|
15
|
+
const type = category === 'properties' ? {
|
|
36
16
|
name: ((_item$type = item.type) === null || _item$type === void 0 ? void 0 : _item$type.text) || item.type
|
|
37
17
|
} : {
|
|
38
18
|
name: 'void'
|
|
@@ -41,9 +21,9 @@ function mapItem(item, category) {
|
|
|
41
21
|
name: item.name,
|
|
42
22
|
required: false,
|
|
43
23
|
description: item.description,
|
|
44
|
-
type
|
|
24
|
+
type,
|
|
45
25
|
table: {
|
|
46
|
-
category
|
|
26
|
+
category,
|
|
47
27
|
type: {
|
|
48
28
|
summary: ((_item$type2 = item.type) === null || _item$type2 === void 0 ? void 0 : _item$type2.text) || item.type
|
|
49
29
|
},
|
|
@@ -55,14 +35,12 @@ function mapItem(item, category) {
|
|
|
55
35
|
}
|
|
56
36
|
|
|
57
37
|
function mapEvent(item) {
|
|
58
|
-
|
|
38
|
+
let name = item.name.replace(/(-|_|:|\.|\s)+(.)?/g, (_match, _separator, chr) => {
|
|
59
39
|
return chr ? chr.toUpperCase() : '';
|
|
60
|
-
}).replace(/^([A-Z])/,
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
name = "on".concat(name.charAt(0).toUpperCase() + name.substr(1));
|
|
40
|
+
}).replace(/^([A-Z])/, match => match.toLowerCase());
|
|
41
|
+
name = `on${name.charAt(0).toUpperCase() + name.substr(1)}`;
|
|
64
42
|
return [{
|
|
65
|
-
name
|
|
43
|
+
name,
|
|
66
44
|
action: {
|
|
67
45
|
name: item.name
|
|
68
46
|
},
|
|
@@ -73,14 +51,12 @@ function mapEvent(item) {
|
|
|
73
51
|
}
|
|
74
52
|
|
|
75
53
|
function mapData(data, category) {
|
|
76
|
-
return data && data.filter(
|
|
77
|
-
return item && item.name;
|
|
78
|
-
}).reduce(function (acc, item) {
|
|
54
|
+
return data && data.filter(item => item && item.name).reduce((acc, item) => {
|
|
79
55
|
if (item.kind === 'method') return acc;
|
|
80
56
|
|
|
81
57
|
switch (category) {
|
|
82
58
|
case 'events':
|
|
83
|
-
mapEvent(item).forEach(
|
|
59
|
+
mapEvent(item).forEach(argType => {
|
|
84
60
|
acc[argType.name] = argType;
|
|
85
61
|
});
|
|
86
62
|
break;
|
|
@@ -94,34 +70,32 @@ function mapData(data, category) {
|
|
|
94
70
|
}, {});
|
|
95
71
|
}
|
|
96
72
|
|
|
97
|
-
|
|
73
|
+
const getMetaDataExperimental = (tagName, customElements) => {
|
|
98
74
|
if (!(0, _.isValidComponent)(tagName) || !(0, _.isValidMetaData)(customElements)) {
|
|
99
75
|
return null;
|
|
100
76
|
}
|
|
101
77
|
|
|
102
|
-
|
|
103
|
-
return tag.name.toUpperCase() === tagName.toUpperCase();
|
|
104
|
-
});
|
|
78
|
+
const metaData = customElements.tags.find(tag => tag.name.toUpperCase() === tagName.toUpperCase());
|
|
105
79
|
|
|
106
80
|
if (!metaData) {
|
|
107
|
-
_clientLogger.logger.warn(
|
|
81
|
+
_clientLogger.logger.warn(`Component not found in custom-elements.json: ${tagName}`);
|
|
108
82
|
}
|
|
109
83
|
|
|
110
84
|
return metaData;
|
|
111
85
|
};
|
|
112
86
|
|
|
113
|
-
|
|
87
|
+
const getMetaDataV1 = (tagName, customElements) => {
|
|
114
88
|
var _customElements$modul;
|
|
115
89
|
|
|
116
90
|
if (!(0, _.isValidComponent)(tagName) || !(0, _.isValidMetaData)(customElements)) {
|
|
117
91
|
return null;
|
|
118
92
|
}
|
|
119
93
|
|
|
120
|
-
|
|
121
|
-
customElements === null || customElements === void 0 ? void 0 : (_customElements$modul = customElements.modules) === null || _customElements$modul === void 0 ? void 0 : _customElements$modul.forEach(
|
|
94
|
+
let metadata;
|
|
95
|
+
customElements === null || customElements === void 0 ? void 0 : (_customElements$modul = customElements.modules) === null || _customElements$modul === void 0 ? void 0 : _customElements$modul.forEach(_module => {
|
|
122
96
|
var _module$declarations;
|
|
123
97
|
|
|
124
|
-
_module === null || _module === void 0 ? void 0 : (_module$declarations = _module.declarations) === null || _module$declarations === void 0 ? void 0 : _module$declarations.forEach(
|
|
98
|
+
_module === null || _module === void 0 ? void 0 : (_module$declarations = _module.declarations) === null || _module$declarations === void 0 ? void 0 : _module$declarations.forEach(declaration => {
|
|
125
99
|
if (declaration.tagName === tagName) {
|
|
126
100
|
metadata = declaration;
|
|
127
101
|
}
|
|
@@ -129,13 +103,13 @@ var getMetaDataV1 = function getMetaDataV1(tagName, customElements) {
|
|
|
129
103
|
});
|
|
130
104
|
|
|
131
105
|
if (!metadata) {
|
|
132
|
-
_clientLogger.logger.warn(
|
|
106
|
+
_clientLogger.logger.warn(`Component not found in custom-elements.json: ${tagName}`);
|
|
133
107
|
}
|
|
134
108
|
|
|
135
109
|
return metadata;
|
|
136
110
|
};
|
|
137
111
|
|
|
138
|
-
|
|
112
|
+
const getMetaData = (tagName, manifest) => {
|
|
139
113
|
if ((manifest === null || manifest === void 0 ? void 0 : manifest.version) === 'experimental') {
|
|
140
114
|
return getMetaDataExperimental(tagName, manifest);
|
|
141
115
|
}
|
|
@@ -143,22 +117,22 @@ var getMetaData = function getMetaData(tagName, manifest) {
|
|
|
143
117
|
return getMetaDataV1(tagName, manifest);
|
|
144
118
|
};
|
|
145
119
|
|
|
146
|
-
|
|
147
|
-
|
|
120
|
+
const extractArgTypesFromElements = (tagName, customElements) => {
|
|
121
|
+
const metaData = getMetaData(tagName, customElements);
|
|
148
122
|
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'));
|
|
149
123
|
};
|
|
150
124
|
|
|
151
125
|
exports.extractArgTypesFromElements = extractArgTypesFromElements;
|
|
152
126
|
|
|
153
|
-
|
|
154
|
-
|
|
127
|
+
const extractArgTypes = tagName => {
|
|
128
|
+
const cem = (0, _.getCustomElements)();
|
|
155
129
|
return extractArgTypesFromElements(tagName, cem);
|
|
156
130
|
};
|
|
157
131
|
|
|
158
132
|
exports.extractArgTypes = extractArgTypes;
|
|
159
133
|
|
|
160
|
-
|
|
161
|
-
|
|
134
|
+
const extractComponentDescription = tagName => {
|
|
135
|
+
const metaData = getMetaData(tagName, (0, _.getCustomElements)());
|
|
162
136
|
return metaData && metaData.description;
|
|
163
137
|
};
|
|
164
138
|
|
|
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.sourceDecorator = sourceDecorator;
|
|
7
7
|
|
|
8
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.string.replace.js");
|
|
11
|
-
|
|
12
8
|
var _litHtml = require("lit-html");
|
|
13
9
|
|
|
14
10
|
var _addons = require("@storybook/addons");
|
|
@@ -19,13 +15,13 @@ var _docsTools = require("@storybook/docs-tools");
|
|
|
19
15
|
|
|
20
16
|
/* global window */
|
|
21
17
|
// Taken from https://github.com/lit/lit/blob/main/packages/lit-html/src/test/test-utils/strip-markers.ts
|
|
22
|
-
|
|
18
|
+
const LIT_EXPRESSION_COMMENTS = /<!--\?lit\$[0-9]+\$-->|<!--\??-->/g;
|
|
23
19
|
|
|
24
20
|
function skipSourceRender(context) {
|
|
25
21
|
var _context$parameters$d;
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
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;
|
|
24
|
+
const isArgsStory = context === null || context === void 0 ? void 0 : context.parameters.__isArgsStory; // always render if the user forces it
|
|
29
25
|
|
|
30
26
|
if ((sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.DYNAMIC) {
|
|
31
27
|
return false;
|
|
@@ -37,26 +33,24 @@ function skipSourceRender(context) {
|
|
|
37
33
|
}
|
|
38
34
|
|
|
39
35
|
function applyTransformSource(source, context) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
transformSource = _ref.transformSource;
|
|
44
|
-
|
|
36
|
+
const {
|
|
37
|
+
transformSource
|
|
38
|
+
} = context.parameters.docs ?? {};
|
|
45
39
|
if (typeof transformSource !== 'function') return source;
|
|
46
40
|
return transformSource(source, context);
|
|
47
41
|
}
|
|
48
42
|
|
|
49
43
|
function sourceDecorator(storyFn, context) {
|
|
50
|
-
var _context$parameters$
|
|
44
|
+
var _context$parameters$d2, _context$parameters$d3;
|
|
51
45
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(0, _addons.useEffect)(
|
|
46
|
+
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();
|
|
47
|
+
let source;
|
|
48
|
+
(0, _addons.useEffect)(() => {
|
|
55
49
|
if (source) _addons.addons.getChannel().emit(_docsTools.SNIPPET_RENDERED, context.id, source);
|
|
56
50
|
});
|
|
57
51
|
|
|
58
52
|
if (!skipSourceRender(context)) {
|
|
59
|
-
|
|
53
|
+
const container = window.document.createElement('div');
|
|
60
54
|
(0, _litHtml.render)(story, container);
|
|
61
55
|
source = applyTransformSource(container.innerHTML.replace(LIT_EXPRESSION_COMMENTS, ''), context);
|
|
62
56
|
}
|
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
|
});
|
|
@@ -26,79 +20,79 @@ var _exportNames = {
|
|
|
26
20
|
};
|
|
27
21
|
Object.defineProperty(exports, "addDecorator", {
|
|
28
22
|
enumerable: true,
|
|
29
|
-
get: function
|
|
23
|
+
get: function () {
|
|
30
24
|
return _preview.addDecorator;
|
|
31
25
|
}
|
|
32
26
|
});
|
|
33
27
|
Object.defineProperty(exports, "addParameters", {
|
|
34
28
|
enumerable: true,
|
|
35
|
-
get: function
|
|
29
|
+
get: function () {
|
|
36
30
|
return _preview.addParameters;
|
|
37
31
|
}
|
|
38
32
|
});
|
|
39
33
|
Object.defineProperty(exports, "configure", {
|
|
40
34
|
enumerable: true,
|
|
41
|
-
get: function
|
|
35
|
+
get: function () {
|
|
42
36
|
return _preview.configure;
|
|
43
37
|
}
|
|
44
38
|
});
|
|
45
39
|
Object.defineProperty(exports, "forceReRender", {
|
|
46
40
|
enumerable: true,
|
|
47
|
-
get: function
|
|
41
|
+
get: function () {
|
|
48
42
|
return _preview.forceReRender;
|
|
49
43
|
}
|
|
50
44
|
});
|
|
51
45
|
Object.defineProperty(exports, "getCustomElements", {
|
|
52
46
|
enumerable: true,
|
|
53
|
-
get: function
|
|
47
|
+
get: function () {
|
|
54
48
|
return _customElements.getCustomElements;
|
|
55
49
|
}
|
|
56
50
|
});
|
|
57
51
|
Object.defineProperty(exports, "getStorybook", {
|
|
58
52
|
enumerable: true,
|
|
59
|
-
get: function
|
|
53
|
+
get: function () {
|
|
60
54
|
return _preview.getStorybook;
|
|
61
55
|
}
|
|
62
56
|
});
|
|
63
57
|
Object.defineProperty(exports, "isValidComponent", {
|
|
64
58
|
enumerable: true,
|
|
65
|
-
get: function
|
|
59
|
+
get: function () {
|
|
66
60
|
return _customElements.isValidComponent;
|
|
67
61
|
}
|
|
68
62
|
});
|
|
69
63
|
Object.defineProperty(exports, "isValidMetaData", {
|
|
70
64
|
enumerable: true,
|
|
71
|
-
get: function
|
|
65
|
+
get: function () {
|
|
72
66
|
return _customElements.isValidMetaData;
|
|
73
67
|
}
|
|
74
68
|
});
|
|
75
69
|
Object.defineProperty(exports, "raw", {
|
|
76
70
|
enumerable: true,
|
|
77
|
-
get: function
|
|
71
|
+
get: function () {
|
|
78
72
|
return _preview.raw;
|
|
79
73
|
}
|
|
80
74
|
});
|
|
81
75
|
Object.defineProperty(exports, "setAddon", {
|
|
82
76
|
enumerable: true,
|
|
83
|
-
get: function
|
|
77
|
+
get: function () {
|
|
84
78
|
return _preview.setAddon;
|
|
85
79
|
}
|
|
86
80
|
});
|
|
87
81
|
Object.defineProperty(exports, "setCustomElements", {
|
|
88
82
|
enumerable: true,
|
|
89
|
-
get: function
|
|
83
|
+
get: function () {
|
|
90
84
|
return _customElements.setCustomElements;
|
|
91
85
|
}
|
|
92
86
|
});
|
|
93
87
|
Object.defineProperty(exports, "setCustomElementsManifest", {
|
|
94
88
|
enumerable: true,
|
|
95
|
-
get: function
|
|
89
|
+
get: function () {
|
|
96
90
|
return _customElements.setCustomElementsManifest;
|
|
97
91
|
}
|
|
98
92
|
});
|
|
99
93
|
Object.defineProperty(exports, "storiesOf", {
|
|
100
94
|
enumerable: true,
|
|
101
|
-
get: function
|
|
95
|
+
get: function () {
|
|
102
96
|
return _preview.storiesOf;
|
|
103
97
|
}
|
|
104
98
|
});
|
|
@@ -117,7 +111,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
117
111
|
if (key in exports && exports[key] === _types[key]) return;
|
|
118
112
|
Object.defineProperty(exports, key, {
|
|
119
113
|
enumerable: true,
|
|
120
|
-
get: function
|
|
114
|
+
get: function () {
|
|
121
115
|
return _types[key];
|
|
122
116
|
}
|
|
123
117
|
});
|
|
@@ -125,19 +119,22 @@ Object.keys(_types).forEach(function (key) {
|
|
|
125
119
|
|
|
126
120
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
127
121
|
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
const {
|
|
123
|
+
window,
|
|
124
|
+
EventSource
|
|
125
|
+
} = _global.default;
|
|
130
126
|
|
|
131
127
|
// TODO: disable HMR and do full page loads because of customElements.define
|
|
132
128
|
if (module && module.hot && module.hot.decline) {
|
|
133
129
|
module.hot.decline(); // forcing full reloads for customElements as elements can only be defined once per page
|
|
134
130
|
|
|
135
|
-
|
|
131
|
+
const hmr = new EventSource('__webpack_hmr');
|
|
136
132
|
hmr.addEventListener('message', function fullPageReload(event) {
|
|
137
133
|
try {
|
|
138
134
|
// Only care for built events. Heartbeats are not parsable so we ignore those
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
const {
|
|
136
|
+
action
|
|
137
|
+
} = JSON.parse(event.data);
|
|
141
138
|
|
|
142
139
|
if (action === 'built') {
|
|
143
140
|
window.location.reload();
|
|
@@ -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 = 'web-components';
|
|
@@ -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 = 'web-components';
|
|
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,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
|
}
|
package/dist/esm/docs/config.js
CHANGED
|
@@ -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'
|
package/dist/types/config.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export declare const parameters: {
|
|
|
5
5
|
};
|
|
6
6
|
extractComponentDescription: (tagName: string) => string;
|
|
7
7
|
inlineStories: boolean;
|
|
8
|
-
prepareForInline: (storyFn: import("@storybook/csf").PartialStoryFn<import(".").WebComponentsFramework, import("@storybook/csf").Args>) => import("react").CElement<{}, import("react").Component<{}, {}, any>>;
|
|
9
8
|
source: {
|
|
10
9
|
type: import("lib/docs-tools/dist/types").SourceType;
|
|
11
10
|
language: string;
|
|
@@ -8,7 +8,6 @@ export declare const parameters: {
|
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/web-components",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.2",
|
|
4
4
|
"description": "Storybook web-components renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lit-html",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"prepare": "node ../../scripts/prepare.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
38
|
-
"@storybook/api": "7.0.0-alpha.
|
|
39
|
-
"@storybook/client-logger": "7.0.0-alpha.
|
|
40
|
-
"@storybook/core-client": "7.0.0-alpha.
|
|
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",
|
|
41
41
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
42
|
-
"@storybook/docs-tools": "7.0.0-alpha.
|
|
43
|
-
"@storybook/preview-web": "7.0.0-alpha.
|
|
44
|
-
"@storybook/store": "7.0.0-alpha.
|
|
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",
|
|
45
45
|
"core-js": "^3.8.2",
|
|
46
46
|
"global": "^4.4.0",
|
|
47
47
|
"react": "16.14.0",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "44920e2b6bd51981bac5124743c29fb9f5517e44"
|
|
65
65
|
}
|
|
@@ -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 ? Object.setPrototypeOf.bind() : 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.bind() : 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,24 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { render } from 'lit-html';
|
|
4
|
-
export const prepareForInline = storyFn => {
|
|
5
|
-
class Story extends React.Component {
|
|
6
|
-
constructor(...args) {
|
|
7
|
-
super(...args);
|
|
8
|
-
this.wrapperRef = /*#__PURE__*/React.createRef();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
componentDidMount() {
|
|
12
|
-
render(storyFn(), this.wrapperRef.current);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
render() {
|
|
16
|
-
return /*#__PURE__*/React.createElement('div', {
|
|
17
|
-
ref: this.wrapperRef
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return /*#__PURE__*/React.createElement(Story);
|
|
24
|
-
};
|