@storybook/addon-docs 6.4.0-beta.2 → 6.4.0-beta.23
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/blocks/DocsStory.js +2 -1
- package/dist/cjs/blocks/Story.js +30 -18
- package/dist/cjs/blocks/enhanceSource.js +2 -2
- package/dist/cjs/blocks/useStory.js +2 -2
- package/dist/cjs/frameworks/angular/compodoc.js +3 -1
- package/dist/cjs/frameworks/angular/prepareForInline.js +52 -53
- package/dist/cjs/frameworks/angular/sourceDecorator.js +99 -23
- package/dist/cjs/frameworks/common/config.js +87 -3
- package/dist/cjs/frameworks/react/react-argtypes.stories.js +2 -2
- package/dist/cjs/frameworks/vue/extractArgTypes.js +106 -15
- package/dist/cjs/frameworks/vue/sourceDecorator.js +80 -33
- package/dist/cjs/frameworks/web-components/custom-elements.js +63 -25
- package/dist/esm/blocks/DocsStory.js +2 -1
- package/dist/esm/blocks/Story.js +27 -19
- package/dist/esm/blocks/enhanceSource.js +7 -1
- package/dist/esm/blocks/useStory.js +2 -2
- package/dist/esm/frameworks/angular/compodoc.js +3 -1
- package/dist/esm/frameworks/angular/prepareForInline.js +46 -50
- package/dist/esm/frameworks/angular/sourceDecorator.js +72 -20
- package/dist/esm/frameworks/common/config.js +60 -3
- package/dist/esm/frameworks/react/react-argtypes.stories.js +1 -1
- package/dist/esm/frameworks/vue/extractArgTypes.js +97 -14
- package/dist/esm/frameworks/vue/sourceDecorator.js +60 -23
- package/dist/esm/frameworks/web-components/custom-elements.js +60 -24
- package/dist/modern/blocks/DocsStory.js +2 -1
- package/dist/modern/blocks/Story.js +27 -21
- package/dist/modern/blocks/enhanceSource.js +7 -1
- package/dist/modern/blocks/useStory.js +8 -2
- package/dist/modern/frameworks/angular/compodoc.js +3 -1
- package/dist/modern/frameworks/angular/prepareForInline.js +20 -15
- package/dist/modern/frameworks/angular/sourceDecorator.js +33 -20
- package/dist/modern/frameworks/common/config.js +2 -3
- package/dist/modern/frameworks/react/react-argtypes.stories.js +1 -1
- package/dist/modern/frameworks/vue/extractArgTypes.js +64 -4
- package/dist/modern/frameworks/vue/sourceDecorator.js +14 -9
- package/dist/modern/frameworks/web-components/custom-elements.js +55 -23
- package/dist/ts3.4/blocks/Story.d.ts +1 -1
- package/dist/ts3.4/frameworks/angular/config.d.ts +1 -1
- package/dist/ts3.4/frameworks/angular/prepareForInline.d.ts +1 -1
- package/dist/ts3.4/frameworks/angular/sourceDecorator.d.ts +1 -1
- package/dist/ts3.4/frameworks/common/config.d.ts +2 -2
- package/dist/ts3.4/frameworks/web-components/custom-elements.d.ts +4 -3
- package/dist/ts3.9/blocks/Story.d.ts +1 -1
- package/dist/ts3.9/frameworks/angular/config.d.ts +1 -1
- package/dist/ts3.9/frameworks/angular/prepareForInline.d.ts +1 -1
- package/dist/ts3.9/frameworks/angular/sourceDecorator.d.ts +1 -1
- package/dist/ts3.9/frameworks/common/config.d.ts +2 -2
- package/dist/ts3.9/frameworks/web-components/custom-elements.d.ts +4 -3
- package/package.json +29 -30
|
@@ -70,7 +70,8 @@ var DocsStory = function DocsStory(_ref) {
|
|
|
70
70
|
}), /*#__PURE__*/_react.default.createElement(_Canvas.Canvas, {
|
|
71
71
|
withToolbar: withToolbar
|
|
72
72
|
}, /*#__PURE__*/_react.default.createElement(_Story.Story, {
|
|
73
|
-
id: id
|
|
73
|
+
id: id,
|
|
74
|
+
parameters: parameters
|
|
74
75
|
})));
|
|
75
76
|
};
|
|
76
77
|
|
package/dist/cjs/blocks/Story.js
CHANGED
|
@@ -35,11 +35,15 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
35
35
|
|
|
36
36
|
var _react2 = require("@mdx-js/react");
|
|
37
37
|
|
|
38
|
+
var _global = _interopRequireDefault(require("global"));
|
|
39
|
+
|
|
38
40
|
var _components = require("@storybook/components");
|
|
39
41
|
|
|
40
42
|
var _csf = require("@storybook/csf");
|
|
41
43
|
|
|
42
|
-
var
|
|
44
|
+
var _addons = require("@storybook/addons");
|
|
45
|
+
|
|
46
|
+
var _coreEvents = _interopRequireDefault(require("@storybook/core-events"));
|
|
43
47
|
|
|
44
48
|
var _types = require("./types");
|
|
45
49
|
|
|
@@ -78,7 +82,7 @@ var getStoryId = function getStoryId(props, context) {
|
|
|
78
82
|
|
|
79
83
|
exports.getStoryId = getStoryId;
|
|
80
84
|
|
|
81
|
-
var getStoryProps = function getStoryProps(_ref4, story, context) {
|
|
85
|
+
var getStoryProps = function getStoryProps(_ref4, story, context, onStoryFnCalled) {
|
|
82
86
|
var height = _ref4.height,
|
|
83
87
|
inline = _ref4.inline;
|
|
84
88
|
var storyName = story.name,
|
|
@@ -103,9 +107,17 @@ var getStoryProps = function getStoryProps(_ref4, story, context) {
|
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
var boundStoryFn = function boundStoryFn() {
|
|
106
|
-
|
|
107
|
-
loaded: {}
|
|
108
|
-
|
|
110
|
+
var storyResult = story.unboundStoryFn(Object.assign({}, context.getStoryContext(story), {
|
|
111
|
+
loaded: {},
|
|
112
|
+
abortSignal: undefined,
|
|
113
|
+
canvasElement: undefined
|
|
114
|
+
})); // We need to wait until the bound story function has actually been called before we
|
|
115
|
+
// consider the story rendered. Certain frameworks (i.e. angular) don't actually render
|
|
116
|
+
// the component in the very first react render cycle, and so we can't just wait until the
|
|
117
|
+
// `PureStory` component has been rendered to consider the underlying story "rendered".
|
|
118
|
+
|
|
119
|
+
onStoryFnCalled();
|
|
120
|
+
return storyResult;
|
|
109
121
|
};
|
|
110
122
|
|
|
111
123
|
return Object.assign({
|
|
@@ -116,7 +128,7 @@ var getStoryProps = function getStoryProps(_ref4, story, context) {
|
|
|
116
128
|
}, storyIsInline && {
|
|
117
129
|
parameters: parameters,
|
|
118
130
|
storyFn: function storyFn() {
|
|
119
|
-
return prepareForInline(boundStoryFn, story);
|
|
131
|
+
return prepareForInline(boundStoryFn, context.getStoryContext(story));
|
|
120
132
|
}
|
|
121
133
|
});
|
|
122
134
|
};
|
|
@@ -127,17 +139,12 @@ var Story = function Story(props) {
|
|
|
127
139
|
var _global$FEATURES;
|
|
128
140
|
|
|
129
141
|
var context = (0, _react.useContext)(_DocsContext.DocsContext);
|
|
130
|
-
var ref = (0, _react.useRef)();
|
|
131
|
-
var story = (0, _useStory.useStory)(getStoryId(props, context), context); // Ensure we wait until this story is properly rendered in the docs context.
|
|
132
|
-
// The purpose of this is to ensure that that the `DOCS_RENDERED` event isn't emitted
|
|
133
|
-
// until all stories on the page have rendered.
|
|
134
142
|
|
|
135
|
-
var
|
|
136
|
-
|
|
137
|
-
var
|
|
138
|
-
(
|
|
139
|
-
|
|
140
|
-
}, [story]);
|
|
143
|
+
var channel = _addons.addons.getChannel();
|
|
144
|
+
|
|
145
|
+
var ref = (0, _react.useRef)();
|
|
146
|
+
var storyId = getStoryId(props, context);
|
|
147
|
+
var story = (0, _useStory.useStory)(storyId, context);
|
|
141
148
|
(0, _react.useEffect)(function () {
|
|
142
149
|
var cleanup;
|
|
143
150
|
|
|
@@ -172,9 +179,14 @@ var Story = function Story(props) {
|
|
|
172
179
|
|
|
173
180
|
if (!story) {
|
|
174
181
|
return /*#__PURE__*/_react.default.createElement("div", null, "Loading...");
|
|
175
|
-
}
|
|
182
|
+
} // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
|
|
183
|
+
// the `STORY_RENDERED` event when it renders. The modern mode below calls out to
|
|
184
|
+
// `Preview.renderStoryToDom()` which itself emits the event.
|
|
185
|
+
|
|
176
186
|
|
|
177
|
-
var storyProps = getStoryProps(props, story, context)
|
|
187
|
+
var storyProps = getStoryProps(props, story, context, function () {
|
|
188
|
+
return channel.emit(_coreEvents.default.STORY_RENDERED, storyId);
|
|
189
|
+
});
|
|
178
190
|
|
|
179
191
|
if (!storyProps) {
|
|
180
192
|
return null;
|
|
@@ -35,7 +35,7 @@ require("core-js/modules/es.regexp.exec.js");
|
|
|
35
35
|
|
|
36
36
|
require("core-js/modules/es.string.split.js");
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _store = require("@storybook/store");
|
|
39
39
|
|
|
40
40
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
41
41
|
|
|
@@ -118,7 +118,7 @@ var enhanceSource = function enhanceSource(story) {
|
|
|
118
118
|
var input = extract(id, storySource);
|
|
119
119
|
var code = transformSource ? transformSource(input, story) : input;
|
|
120
120
|
return {
|
|
121
|
-
docs: (0,
|
|
121
|
+
docs: (0, _store.combineParameters)(docs, {
|
|
122
122
|
source: {
|
|
123
123
|
code: code
|
|
124
124
|
}
|
|
@@ -79,7 +79,7 @@ function useStories(storyIds, context) {
|
|
|
79
79
|
case 2:
|
|
80
80
|
story = _context.sent;
|
|
81
81
|
setStories(function (current) {
|
|
82
|
-
return Object.assign({}, current, _defineProperty({}, storyId, story));
|
|
82
|
+
return current[storyId] === story ? current : Object.assign({}, current, _defineProperty({}, storyId, story));
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
case 4:
|
|
@@ -94,7 +94,7 @@ function useStories(storyIds, context) {
|
|
|
94
94
|
return _ref.apply(this, arguments);
|
|
95
95
|
};
|
|
96
96
|
}()));
|
|
97
|
-
}
|
|
97
|
+
});
|
|
98
98
|
return storyIds.map(function (storyId) {
|
|
99
99
|
return storiesById[storyId];
|
|
100
100
|
});
|
|
@@ -316,8 +316,10 @@ var extractDefaultValue = function extractDefaultValue(property) {
|
|
|
316
316
|
};
|
|
317
317
|
|
|
318
318
|
var resolveTypealias = function resolveTypealias(compodocType) {
|
|
319
|
+
var _compodocJson$miscell, _compodocJson$miscell2;
|
|
320
|
+
|
|
319
321
|
var compodocJson = getCompodocJson();
|
|
320
|
-
var typeAlias = compodocJson === null || compodocJson === void 0 ? void 0 : compodocJson.miscellaneous.typealiases.find(function (x) {
|
|
322
|
+
var typeAlias = compodocJson === null || compodocJson === void 0 ? void 0 : (_compodocJson$miscell = compodocJson.miscellaneous) === null || _compodocJson$miscell === void 0 ? void 0 : (_compodocJson$miscell2 = _compodocJson$miscell.typealiases) === null || _compodocJson$miscell2 === void 0 ? void 0 : _compodocJson$miscell2.find(function (x) {
|
|
321
323
|
return x.name === compodocType;
|
|
322
324
|
});
|
|
323
325
|
return typeAlias ? resolveTypealias(typeAlias.rawtype) : compodocType;
|
|
@@ -34,63 +34,62 @@ var limit = (0, _pLimit.default)(1);
|
|
|
34
34
|
|
|
35
35
|
var prepareForInline = function prepareForInline(storyFn, _ref) {
|
|
36
36
|
var id = _ref.id,
|
|
37
|
-
parameters = _ref.parameters
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
37
|
+
parameters = _ref.parameters,
|
|
38
|
+
component = _ref.component;
|
|
39
|
+
|
|
40
|
+
var el = _react.default.useRef();
|
|
41
|
+
|
|
42
|
+
_react.default.useEffect(function () {
|
|
43
|
+
_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
44
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
45
|
+
while (1) {
|
|
46
|
+
switch (_context2.prev = _context2.next) {
|
|
47
|
+
case 0:
|
|
48
|
+
limit( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
49
|
+
var renderer;
|
|
50
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
51
|
+
while (1) {
|
|
52
|
+
switch (_context.prev = _context.next) {
|
|
53
|
+
case 0:
|
|
54
|
+
_context.next = 2;
|
|
55
|
+
return _renderer.rendererFactory.getRendererInstance("".concat(id, "-").concat((0, _nanoid.nanoid)(10)).toLowerCase(), el.current);
|
|
56
|
+
|
|
57
|
+
case 2:
|
|
58
|
+
renderer = _context.sent;
|
|
59
|
+
|
|
60
|
+
if (!renderer) {
|
|
61
|
+
_context.next = 6;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
_context.next = 6;
|
|
66
|
+
return renderer.render({
|
|
67
|
+
forced: false,
|
|
68
|
+
component: component,
|
|
69
|
+
parameters: parameters,
|
|
70
|
+
storyFnAngular: storyFn(),
|
|
71
|
+
targetDOMNode: el.current
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
case 6:
|
|
75
|
+
case "end":
|
|
76
|
+
return _context.stop();
|
|
76
77
|
}
|
|
77
|
-
}
|
|
78
|
-
})
|
|
78
|
+
}
|
|
79
|
+
}, _callee);
|
|
80
|
+
})));
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
82
|
+
case 1:
|
|
83
|
+
case "end":
|
|
84
|
+
return _context2.stop();
|
|
84
85
|
}
|
|
85
|
-
}
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return _ref2.apply(this, arguments);
|
|
90
|
-
}
|
|
86
|
+
}
|
|
87
|
+
}, _callee2);
|
|
88
|
+
}))();
|
|
89
|
+
});
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
return /*#__PURE__*/_react.default.createElement('div', {
|
|
92
|
+
ref: el
|
|
94
93
|
});
|
|
95
94
|
};
|
|
96
95
|
|
|
@@ -1,21 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.weak-map.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.string.iterator.js");
|
|
8
|
+
|
|
9
|
+
require("core-js/modules/es.array.iterator.js");
|
|
10
|
+
|
|
11
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
14
|
+
|
|
15
|
+
require("core-js/modules/es.symbol.js");
|
|
16
|
+
|
|
17
|
+
require("core-js/modules/es.symbol.description.js");
|
|
18
|
+
|
|
19
|
+
require("core-js/modules/es.symbol.iterator.js");
|
|
20
|
+
|
|
3
21
|
Object.defineProperty(exports, "__esModule", {
|
|
4
22
|
value: true
|
|
5
23
|
});
|
|
6
24
|
exports.sourceDecorator = exports.skipSourceRender = void 0;
|
|
7
25
|
|
|
26
|
+
require("regenerator-runtime/runtime.js");
|
|
27
|
+
|
|
28
|
+
require("core-js/modules/es.promise.js");
|
|
29
|
+
|
|
30
|
+
require("core-js/modules/es.object.to-string.js");
|
|
31
|
+
|
|
8
32
|
var _addons = require("@storybook/addons");
|
|
9
33
|
|
|
10
34
|
var _renderer = require("@storybook/angular/renderer");
|
|
11
35
|
|
|
12
|
-
var
|
|
36
|
+
var _shared = require("../../shared");
|
|
13
37
|
|
|
14
|
-
|
|
38
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
15
39
|
|
|
16
|
-
|
|
40
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
41
|
|
|
18
|
-
function
|
|
42
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
43
|
+
|
|
44
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
19
45
|
|
|
20
46
|
var skipSourceRender = function skipSourceRender(context) {
|
|
21
47
|
var _context$parameters$d;
|
|
@@ -32,16 +58,62 @@ var skipSourceRender = function skipSourceRender(context) {
|
|
|
32
58
|
};
|
|
33
59
|
|
|
34
60
|
exports.skipSourceRender = skipSourceRender;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
61
|
+
var prettyUpInternal;
|
|
62
|
+
|
|
63
|
+
var makePrettyUp = /*#__PURE__*/function () {
|
|
64
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
65
|
+
var prettierHtml, prettier;
|
|
66
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
67
|
+
while (1) {
|
|
68
|
+
switch (_context.prev = _context.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
if (!prettyUpInternal) {
|
|
71
|
+
_context.next = 2;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return _context.abrupt("return", prettyUpInternal);
|
|
76
|
+
|
|
77
|
+
case 2:
|
|
78
|
+
_context.next = 4;
|
|
79
|
+
return Promise.resolve().then(function () {
|
|
80
|
+
return _interopRequireWildcard(require('prettier/parser-html'));
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
case 4:
|
|
84
|
+
prettierHtml = _context.sent;
|
|
85
|
+
_context.next = 7;
|
|
86
|
+
return Promise.resolve().then(function () {
|
|
87
|
+
return _interopRequireWildcard(require('prettier/standalone'));
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
case 7:
|
|
91
|
+
prettier = _context.sent;
|
|
92
|
+
|
|
93
|
+
prettyUpInternal = function prettyUpInternal(source) {
|
|
94
|
+
return prettier.format(source, {
|
|
95
|
+
parser: 'angular',
|
|
96
|
+
plugins: [prettierHtml],
|
|
97
|
+
htmlWhitespaceSensitivity: 'ignore'
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return _context.abrupt("return", prettyUpInternal);
|
|
102
|
+
|
|
103
|
+
case 10:
|
|
104
|
+
case "end":
|
|
105
|
+
return _context.stop();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}, _callee);
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
return function makePrettyUp() {
|
|
112
|
+
return _ref.apply(this, arguments);
|
|
113
|
+
};
|
|
114
|
+
}();
|
|
43
115
|
/**
|
|
44
|
-
*
|
|
116
|
+
* Angular source decorator.
|
|
45
117
|
* @param storyFn Fn
|
|
46
118
|
* @param context StoryContext
|
|
47
119
|
*/
|
|
@@ -62,21 +134,25 @@ var sourceDecorator = function sourceDecorator(storyFn, context) {
|
|
|
62
134
|
var component = context.component,
|
|
63
135
|
argTypes = context.argTypes;
|
|
64
136
|
var toEmit;
|
|
137
|
+
var prettyUpPromise = makePrettyUp();
|
|
65
138
|
(0, _addons.useEffect)(function () {
|
|
66
|
-
|
|
139
|
+
prettyUpPromise.then(function (prettyUp) {
|
|
140
|
+
if (toEmit) channel.emit(_shared.SNIPPET_RENDERED, context.id, prettyUp(toEmit));
|
|
141
|
+
});
|
|
67
142
|
});
|
|
143
|
+
prettyUpPromise.then(function (prettyUp) {
|
|
144
|
+
if (component && !userDefinedTemplate) {
|
|
145
|
+
var _source = (0, _renderer.computesTemplateSourceFromComponent)(component, props, argTypes); // We might have a story with a Directive or Service defined as the component
|
|
146
|
+
// In these cases there might exist a template, even if we aren't able to create source from component
|
|
68
147
|
|
|
69
|
-
if (component && !userDefinedTemplate) {
|
|
70
|
-
var source = (0, _renderer.computesTemplateSourceFromComponent)(component, props, argTypes); // We might have a story with a Directive or Service defined as the component
|
|
71
|
-
// In these cases there might exist a template, even if we aren't able to create source from component
|
|
72
148
|
|
|
73
|
-
|
|
74
|
-
|
|
149
|
+
if (_source || template) {
|
|
150
|
+
toEmit = prettyUp(_source || template);
|
|
151
|
+
}
|
|
152
|
+
} else if (template) {
|
|
153
|
+
toEmit = prettyUp(template);
|
|
75
154
|
}
|
|
76
|
-
}
|
|
77
|
-
toEmit = prettyUp(template);
|
|
78
|
-
}
|
|
79
|
-
|
|
155
|
+
});
|
|
80
156
|
return story;
|
|
81
157
|
};
|
|
82
158
|
|
|
@@ -1,19 +1,103 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.weak-map.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.string.iterator.js");
|
|
8
|
+
|
|
9
|
+
require("core-js/modules/es.array.iterator.js");
|
|
10
|
+
|
|
11
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
14
|
+
|
|
15
|
+
require("core-js/modules/es.symbol.js");
|
|
16
|
+
|
|
17
|
+
require("core-js/modules/es.symbol.description.js");
|
|
18
|
+
|
|
19
|
+
require("core-js/modules/es.symbol.iterator.js");
|
|
20
|
+
|
|
3
21
|
Object.defineProperty(exports, "__esModule", {
|
|
4
22
|
value: true
|
|
5
23
|
});
|
|
6
24
|
exports.argTypesEnhancers = exports.parameters = void 0;
|
|
7
25
|
|
|
8
|
-
|
|
26
|
+
require("regenerator-runtime/runtime.js");
|
|
27
|
+
|
|
28
|
+
require("core-js/modules/es.promise.js");
|
|
29
|
+
|
|
30
|
+
require("core-js/modules/es.object.to-string.js");
|
|
9
31
|
|
|
10
32
|
var _enhanceArgTypes = require("./enhanceArgTypes");
|
|
11
33
|
|
|
34
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
35
|
+
|
|
36
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
+
|
|
38
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
39
|
+
|
|
40
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
41
|
+
|
|
12
42
|
var parameters = {
|
|
13
43
|
docs: {
|
|
14
44
|
inlineStories: false,
|
|
15
|
-
|
|
16
|
-
|
|
45
|
+
getContainer: function () {
|
|
46
|
+
var _getContainer = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
47
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
48
|
+
while (1) {
|
|
49
|
+
switch (_context.prev = _context.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
_context.next = 2;
|
|
52
|
+
return Promise.resolve().then(function () {
|
|
53
|
+
return _interopRequireWildcard(require('../../blocks'));
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
case 2:
|
|
57
|
+
return _context.abrupt("return", _context.sent.DocsContainer);
|
|
58
|
+
|
|
59
|
+
case 3:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, _callee);
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
function getContainer() {
|
|
68
|
+
return _getContainer.apply(this, arguments);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return getContainer;
|
|
72
|
+
}(),
|
|
73
|
+
getPage: function () {
|
|
74
|
+
var _getPage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
75
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
76
|
+
while (1) {
|
|
77
|
+
switch (_context2.prev = _context2.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
_context2.next = 2;
|
|
80
|
+
return Promise.resolve().then(function () {
|
|
81
|
+
return _interopRequireWildcard(require('../../blocks'));
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
case 2:
|
|
85
|
+
return _context2.abrupt("return", _context2.sent.DocsPage);
|
|
86
|
+
|
|
87
|
+
case 3:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context2.stop();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, _callee2);
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
function getPage() {
|
|
96
|
+
return _getPage.apply(this, arguments);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return getPage;
|
|
100
|
+
}(),
|
|
17
101
|
iframeHeight: 100
|
|
18
102
|
}
|
|
19
103
|
};
|
|
@@ -40,7 +40,7 @@ var _react2 = require("@storybook/react");
|
|
|
40
40
|
|
|
41
41
|
var _components = require("@storybook/components");
|
|
42
42
|
|
|
43
|
-
var
|
|
43
|
+
var _store = require("@storybook/store");
|
|
44
44
|
|
|
45
45
|
var _extractArgTypes = require("./extractArgTypes");
|
|
46
46
|
|
|
@@ -67,7 +67,7 @@ var argsTableProps = function argsTableProps(component) {
|
|
|
67
67
|
var parameters = {
|
|
68
68
|
__isArgsStory: true
|
|
69
69
|
};
|
|
70
|
-
var rows = (0,
|
|
70
|
+
var rows = (0, _store.inferControls)({
|
|
71
71
|
argTypes: argTypes,
|
|
72
72
|
parameters: parameters
|
|
73
73
|
});
|