@storybook/addon-docs 6.4.0-beta.32 → 6.4.0-beta.33
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/ArgsTable.js +3 -4
- package/dist/cjs/blocks/Canvas.js +2 -1
- package/dist/cjs/blocks/Story.js +35 -12
- package/dist/cjs/blocks/useStory.js +6 -1
- package/dist/esm/blocks/ArgsTable.js +3 -4
- package/dist/esm/blocks/Canvas.js +3 -2
- package/dist/esm/blocks/Story.js +37 -9
- package/dist/esm/blocks/useStory.js +6 -1
- package/dist/modern/blocks/ArgsTable.js +3 -5
- package/dist/modern/blocks/Canvas.js +3 -2
- package/dist/modern/blocks/Story.js +11 -9
- package/dist/modern/blocks/useStory.js +6 -1
- package/package.json +27 -27
|
@@ -233,10 +233,9 @@ var StoryTable = function StoryTable(props) {
|
|
|
233
233
|
updateArgs = _useArgs2[1],
|
|
234
234
|
resetArgs = _useArgs2[2];
|
|
235
235
|
|
|
236
|
-
if (!story) {
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
236
|
+
if (!story) return /*#__PURE__*/_react.default.createElement(_components.ArgsTable, {
|
|
237
|
+
isLoading: true
|
|
238
|
+
});
|
|
240
239
|
var argTypes = (0, _store.filterArgTypes)(story.argTypes, include, exclude);
|
|
241
240
|
var mainLabel = (0, _utils.getComponentName)(component) || 'Story';
|
|
242
241
|
|
|
@@ -128,7 +128,8 @@ var Canvas = function Canvas(props) {
|
|
|
128
128
|
previewProps = _getPreviewProps.previewProps;
|
|
129
129
|
|
|
130
130
|
var children = props.children;
|
|
131
|
-
|
|
131
|
+
if (isLoading) return /*#__PURE__*/_react.default.createElement(_components.PreviewSkeleton, null);
|
|
132
|
+
return /*#__PURE__*/_react.default.createElement(_react2.MDXProvider, {
|
|
132
133
|
components: _components.resetComponents
|
|
133
134
|
}, /*#__PURE__*/_react.default.createElement(_components.Preview, previewProps, children));
|
|
134
135
|
};
|
package/dist/cjs/blocks/Story.js
CHANGED
|
@@ -2,23 +2,27 @@
|
|
|
2
2
|
|
|
3
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
4
|
|
|
5
|
-
require("core-js/modules/es.
|
|
5
|
+
require("core-js/modules/es.symbol.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.symbol.description.js");
|
|
6
8
|
|
|
7
9
|
require("core-js/modules/es.object.to-string.js");
|
|
8
10
|
|
|
11
|
+
require("core-js/modules/es.symbol.iterator.js");
|
|
12
|
+
|
|
9
13
|
require("core-js/modules/es.string.iterator.js");
|
|
10
14
|
|
|
11
15
|
require("core-js/modules/es.array.iterator.js");
|
|
12
16
|
|
|
13
17
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
14
18
|
|
|
15
|
-
require("core-js/modules/es.
|
|
19
|
+
require("core-js/modules/es.array.slice.js");
|
|
16
20
|
|
|
17
|
-
require("core-js/modules/es.
|
|
21
|
+
require("core-js/modules/es.array.from.js");
|
|
18
22
|
|
|
19
|
-
require("core-js/modules/es.
|
|
23
|
+
require("core-js/modules/es.weak-map.js");
|
|
20
24
|
|
|
21
|
-
require("core-js/modules/es.
|
|
25
|
+
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
22
26
|
|
|
23
27
|
Object.defineProperty(exports, "__esModule", {
|
|
24
28
|
value: true
|
|
@@ -57,6 +61,18 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
57
61
|
|
|
58
62
|
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; }
|
|
59
63
|
|
|
64
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
65
|
+
|
|
66
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
67
|
+
|
|
68
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
69
|
+
|
|
70
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
71
|
+
|
|
72
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
73
|
+
|
|
74
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
75
|
+
|
|
60
76
|
var storyBlockIdFromId = function storyBlockIdFromId(storyId) {
|
|
61
77
|
return "story--".concat(storyId);
|
|
62
78
|
};
|
|
@@ -142,13 +158,19 @@ var Story = function Story(props) {
|
|
|
142
158
|
|
|
143
159
|
var channel = _addons.addons.getChannel();
|
|
144
160
|
|
|
145
|
-
var
|
|
161
|
+
var storyRef = (0, _react.useRef)();
|
|
146
162
|
var storyId = getStoryId(props, context);
|
|
147
163
|
var story = (0, _useStory.useStory)(storyId, context);
|
|
164
|
+
|
|
165
|
+
var _useState = (0, _react.useState)(true),
|
|
166
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
167
|
+
showLoader = _useState2[0],
|
|
168
|
+
setShowLoader = _useState2[1];
|
|
169
|
+
|
|
148
170
|
(0, _react.useEffect)(function () {
|
|
149
171
|
var cleanup;
|
|
150
172
|
|
|
151
|
-
if (story &&
|
|
173
|
+
if (story && storyRef.current) {
|
|
152
174
|
var componentId = story.componentId,
|
|
153
175
|
id = story.id,
|
|
154
176
|
title = story.title,
|
|
@@ -168,8 +190,9 @@ var Story = function Story(props) {
|
|
|
168
190
|
cleanup = context.renderStoryToElement({
|
|
169
191
|
story: story,
|
|
170
192
|
renderContext: renderContext,
|
|
171
|
-
element:
|
|
193
|
+
element: storyRef.current
|
|
172
194
|
});
|
|
195
|
+
setShowLoader(false);
|
|
173
196
|
}
|
|
174
197
|
|
|
175
198
|
return function () {
|
|
@@ -178,7 +201,7 @@ var Story = function Story(props) {
|
|
|
178
201
|
}, [story]);
|
|
179
202
|
|
|
180
203
|
if (!story) {
|
|
181
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
204
|
+
return /*#__PURE__*/_react.default.createElement(_components.StorySkeleton, null);
|
|
182
205
|
} // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
|
|
183
206
|
// the `STORY_RENDERED` event when it renders. The modern mode below calls out to
|
|
184
207
|
// `Preview.renderStoryToDom()` which itself emits the event.
|
|
@@ -194,15 +217,15 @@ var Story = function Story(props) {
|
|
|
194
217
|
|
|
195
218
|
if (_global.default !== null && _global.default !== void 0 && (_global$FEATURES = _global.default.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender) {
|
|
196
219
|
// We do this so React doesn't complain when we replace the span in a secondary render
|
|
197
|
-
var htmlContents = "<span
|
|
220
|
+
var htmlContents = "<span></span>"; // FIXME: height/style/etc. lifted from PureStory
|
|
198
221
|
|
|
199
222
|
var height = storyProps.height;
|
|
200
223
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
201
224
|
id: storyBlockIdFromId(story.id)
|
|
202
225
|
}, /*#__PURE__*/_react.default.createElement(_react2.MDXProvider, {
|
|
203
226
|
components: _components.resetComponents
|
|
204
|
-
}, height ? /*#__PURE__*/_react.default.createElement("style", null, "#story--".concat(story.id, " { min-height: ").concat(height, "; transform: translateZ(0); overflow: auto }")) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
205
|
-
ref:
|
|
227
|
+
}, height ? /*#__PURE__*/_react.default.createElement("style", null, "#story--".concat(story.id, " { min-height: ").concat(height, "; transform: translateZ(0); overflow: auto }")) : null, showLoader && /*#__PURE__*/_react.default.createElement(_components.StorySkeleton, null), /*#__PURE__*/_react.default.createElement("div", {
|
|
228
|
+
ref: storyRef,
|
|
206
229
|
"data-name": story.name,
|
|
207
230
|
dangerouslySetInnerHTML: {
|
|
208
231
|
__html: htmlContents
|
|
@@ -60,7 +60,12 @@ function useStory(storyId, context) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function useStories(storyIds, context) {
|
|
63
|
-
var
|
|
63
|
+
var initialStoriesById = context.componentStories().reduce(function (acc, story) {
|
|
64
|
+
acc[story.id] = story;
|
|
65
|
+
return acc;
|
|
66
|
+
}, {});
|
|
67
|
+
|
|
68
|
+
var _useState = (0, _react.useState)(initialStoriesById),
|
|
64
69
|
_useState2 = _slicedToArray(_useState, 2),
|
|
65
70
|
storiesById = _useState2[0],
|
|
66
71
|
setStories = _useState2[1];
|
|
@@ -185,10 +185,9 @@ export var StoryTable = function StoryTable(props) {
|
|
|
185
185
|
updateArgs = _useArgs2[1],
|
|
186
186
|
resetArgs = _useArgs2[2];
|
|
187
187
|
|
|
188
|
-
if (!story) {
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
188
|
+
if (!story) return /*#__PURE__*/React.createElement(PureArgsTable, {
|
|
189
|
+
isLoading: true
|
|
190
|
+
});
|
|
192
191
|
var argTypes = filterArgTypes(story.argTypes, include, exclude);
|
|
193
192
|
var mainLabel = getComponentName(component) || 'Story';
|
|
194
193
|
|
|
@@ -12,7 +12,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
12
12
|
import React, { useContext } from 'react';
|
|
13
13
|
import { MDXProvider } from '@mdx-js/react';
|
|
14
14
|
import { toId, storyNameFromExport } from '@storybook/csf';
|
|
15
|
-
import { resetComponents, Preview as PurePreview } from '@storybook/components';
|
|
15
|
+
import { resetComponents, Preview as PurePreview, PreviewSkeleton } from '@storybook/components';
|
|
16
16
|
import { DocsContext } from './DocsContext';
|
|
17
17
|
import { SourceContext } from './SourceContainer';
|
|
18
18
|
import { getSourceProps, SourceState } from './Source';
|
|
@@ -82,7 +82,8 @@ export var Canvas = function Canvas(props) {
|
|
|
82
82
|
previewProps = _getPreviewProps.previewProps;
|
|
83
83
|
|
|
84
84
|
var children = props.children;
|
|
85
|
-
|
|
85
|
+
if (isLoading) return /*#__PURE__*/React.createElement(PreviewSkeleton, null);
|
|
86
|
+
return /*#__PURE__*/React.createElement(MDXProvider, {
|
|
86
87
|
components: resetComponents
|
|
87
88
|
}, /*#__PURE__*/React.createElement(PurePreview, previewProps, children));
|
|
88
89
|
};
|
package/dist/esm/blocks/Story.js
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
+
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
1
13
|
import "core-js/modules/es.function.name.js";
|
|
2
14
|
import "core-js/modules/es.object.assign.js";
|
|
3
15
|
import "core-js/modules/es.array.concat.js";
|
|
4
|
-
import
|
|
16
|
+
import "core-js/modules/es.symbol.js";
|
|
17
|
+
import "core-js/modules/es.symbol.description.js";
|
|
18
|
+
import "core-js/modules/es.object.to-string.js";
|
|
19
|
+
import "core-js/modules/es.symbol.iterator.js";
|
|
20
|
+
import "core-js/modules/es.string.iterator.js";
|
|
21
|
+
import "core-js/modules/es.array.iterator.js";
|
|
22
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
23
|
+
import "core-js/modules/es.array.slice.js";
|
|
24
|
+
import "core-js/modules/es.array.from.js";
|
|
25
|
+
import React, { useContext, useRef, useEffect, useState } from 'react';
|
|
5
26
|
import { MDXProvider } from '@mdx-js/react';
|
|
6
27
|
import global from 'global';
|
|
7
|
-
import { resetComponents, Story as PureStory } from '@storybook/components';
|
|
28
|
+
import { resetComponents, Story as PureStory, StorySkeleton } from '@storybook/components';
|
|
8
29
|
import { toId, storyNameFromExport } from '@storybook/csf';
|
|
9
30
|
import { addons } from '@storybook/addons';
|
|
10
31
|
import Events from '@storybook/core-events';
|
|
@@ -83,13 +104,19 @@ var Story = function Story(props) {
|
|
|
83
104
|
|
|
84
105
|
var context = useContext(DocsContext);
|
|
85
106
|
var channel = addons.getChannel();
|
|
86
|
-
var
|
|
107
|
+
var storyRef = useRef();
|
|
87
108
|
var storyId = getStoryId(props, context);
|
|
88
109
|
var story = useStory(storyId, context);
|
|
110
|
+
|
|
111
|
+
var _useState = useState(true),
|
|
112
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
113
|
+
showLoader = _useState2[0],
|
|
114
|
+
setShowLoader = _useState2[1];
|
|
115
|
+
|
|
89
116
|
useEffect(function () {
|
|
90
117
|
var cleanup;
|
|
91
118
|
|
|
92
|
-
if (story &&
|
|
119
|
+
if (story && storyRef.current) {
|
|
93
120
|
var componentId = story.componentId,
|
|
94
121
|
id = story.id,
|
|
95
122
|
title = story.title,
|
|
@@ -109,8 +136,9 @@ var Story = function Story(props) {
|
|
|
109
136
|
cleanup = context.renderStoryToElement({
|
|
110
137
|
story: story,
|
|
111
138
|
renderContext: renderContext,
|
|
112
|
-
element:
|
|
139
|
+
element: storyRef.current
|
|
113
140
|
});
|
|
141
|
+
setShowLoader(false);
|
|
114
142
|
}
|
|
115
143
|
|
|
116
144
|
return function () {
|
|
@@ -119,7 +147,7 @@ var Story = function Story(props) {
|
|
|
119
147
|
}, [story]);
|
|
120
148
|
|
|
121
149
|
if (!story) {
|
|
122
|
-
return /*#__PURE__*/React.createElement(
|
|
150
|
+
return /*#__PURE__*/React.createElement(StorySkeleton, null);
|
|
123
151
|
} // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
|
|
124
152
|
// the `STORY_RENDERED` event when it renders. The modern mode below calls out to
|
|
125
153
|
// `Preview.renderStoryToDom()` which itself emits the event.
|
|
@@ -135,15 +163,15 @@ var Story = function Story(props) {
|
|
|
135
163
|
|
|
136
164
|
if (global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender) {
|
|
137
165
|
// We do this so React doesn't complain when we replace the span in a secondary render
|
|
138
|
-
var htmlContents = "<span
|
|
166
|
+
var htmlContents = "<span></span>"; // FIXME: height/style/etc. lifted from PureStory
|
|
139
167
|
|
|
140
168
|
var height = storyProps.height;
|
|
141
169
|
return /*#__PURE__*/React.createElement("div", {
|
|
142
170
|
id: storyBlockIdFromId(story.id)
|
|
143
171
|
}, /*#__PURE__*/React.createElement(MDXProvider, {
|
|
144
172
|
components: resetComponents
|
|
145
|
-
}, height ? /*#__PURE__*/React.createElement("style", null, "#story--".concat(story.id, " { min-height: ").concat(height, "; transform: translateZ(0); overflow: auto }")) : null, /*#__PURE__*/React.createElement("div", {
|
|
146
|
-
ref:
|
|
173
|
+
}, height ? /*#__PURE__*/React.createElement("style", null, "#story--".concat(story.id, " { min-height: ").concat(height, "; transform: translateZ(0); overflow: auto }")) : null, showLoader && /*#__PURE__*/React.createElement(StorySkeleton, null), /*#__PURE__*/React.createElement("div", {
|
|
174
|
+
ref: storyRef,
|
|
147
175
|
"data-name": story.name,
|
|
148
176
|
dangerouslySetInnerHTML: {
|
|
149
177
|
__html: htmlContents
|
|
@@ -38,7 +38,12 @@ export function useStory(storyId, context) {
|
|
|
38
38
|
return stories && stories[0];
|
|
39
39
|
}
|
|
40
40
|
export function useStories(storyIds, context) {
|
|
41
|
-
var
|
|
41
|
+
var initialStoriesById = context.componentStories().reduce(function (acc, story) {
|
|
42
|
+
acc[story.id] = story;
|
|
43
|
+
return acc;
|
|
44
|
+
}, {});
|
|
45
|
+
|
|
46
|
+
var _useState = useState(initialStoriesById),
|
|
42
47
|
_useState2 = _slicedToArray(_useState, 2),
|
|
43
48
|
storiesById = _useState2[0],
|
|
44
49
|
setStories = _useState2[1];
|
|
@@ -139,11 +139,9 @@ export const StoryTable = props => {
|
|
|
139
139
|
const story = useStory(storyId, context); // eslint-disable-next-line prefer-const
|
|
140
140
|
|
|
141
141
|
let [args, updateArgs, resetArgs] = useArgs(storyId, context);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
142
|
+
if (!story) return /*#__PURE__*/React.createElement(PureArgsTable, {
|
|
143
|
+
isLoading: true
|
|
144
|
+
});
|
|
147
145
|
const argTypes = filterArgTypes(story.argTypes, include, exclude);
|
|
148
146
|
const mainLabel = getComponentName(component) || 'Story';
|
|
149
147
|
let tabs = {
|
|
@@ -3,7 +3,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
3
3
|
import React, { useContext } from 'react';
|
|
4
4
|
import { MDXProvider } from '@mdx-js/react';
|
|
5
5
|
import { toId, storyNameFromExport } from '@storybook/csf';
|
|
6
|
-
import { resetComponents, Preview as PurePreview } from '@storybook/components';
|
|
6
|
+
import { resetComponents, Preview as PurePreview, PreviewSkeleton } from '@storybook/components';
|
|
7
7
|
import { DocsContext } from './DocsContext';
|
|
8
8
|
import { SourceContext } from './SourceContainer';
|
|
9
9
|
import { getSourceProps, SourceState } from './Source';
|
|
@@ -72,7 +72,8 @@ export const Canvas = props => {
|
|
|
72
72
|
const {
|
|
73
73
|
children
|
|
74
74
|
} = props;
|
|
75
|
-
|
|
75
|
+
if (isLoading) return /*#__PURE__*/React.createElement(PreviewSkeleton, null);
|
|
76
|
+
return /*#__PURE__*/React.createElement(MDXProvider, {
|
|
76
77
|
components: resetComponents
|
|
77
78
|
}, /*#__PURE__*/React.createElement(PurePreview, previewProps, children));
|
|
78
79
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useContext, useRef, useEffect } from 'react';
|
|
1
|
+
import React, { useContext, useRef, useEffect, useState } from 'react';
|
|
2
2
|
import { MDXProvider } from '@mdx-js/react';
|
|
3
3
|
import global from 'global';
|
|
4
|
-
import { resetComponents, Story as PureStory } from '@storybook/components';
|
|
4
|
+
import { resetComponents, Story as PureStory, StorySkeleton } from '@storybook/components';
|
|
5
5
|
import { toId, storyNameFromExport } from '@storybook/csf';
|
|
6
6
|
import { addons } from '@storybook/addons';
|
|
7
7
|
import Events from '@storybook/core-events';
|
|
@@ -81,13 +81,14 @@ const Story = props => {
|
|
|
81
81
|
|
|
82
82
|
const context = useContext(DocsContext);
|
|
83
83
|
const channel = addons.getChannel();
|
|
84
|
-
const
|
|
84
|
+
const storyRef = useRef();
|
|
85
85
|
const storyId = getStoryId(props, context);
|
|
86
86
|
const story = useStory(storyId, context);
|
|
87
|
+
const [showLoader, setShowLoader] = useState(true);
|
|
87
88
|
useEffect(() => {
|
|
88
89
|
let cleanup;
|
|
89
90
|
|
|
90
|
-
if (story &&
|
|
91
|
+
if (story && storyRef.current) {
|
|
91
92
|
const {
|
|
92
93
|
componentId,
|
|
93
94
|
id,
|
|
@@ -109,15 +110,16 @@ const Story = props => {
|
|
|
109
110
|
cleanup = context.renderStoryToElement({
|
|
110
111
|
story,
|
|
111
112
|
renderContext,
|
|
112
|
-
element:
|
|
113
|
+
element: storyRef.current
|
|
113
114
|
});
|
|
115
|
+
setShowLoader(false);
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
return () => cleanup && cleanup();
|
|
117
119
|
}, [story]);
|
|
118
120
|
|
|
119
121
|
if (!story) {
|
|
120
|
-
return /*#__PURE__*/React.createElement(
|
|
122
|
+
return /*#__PURE__*/React.createElement(StorySkeleton, null);
|
|
121
123
|
} // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
|
|
122
124
|
// the `STORY_RENDERED` event when it renders. The modern mode below calls out to
|
|
123
125
|
// `Preview.renderStoryToDom()` which itself emits the event.
|
|
@@ -131,7 +133,7 @@ const Story = props => {
|
|
|
131
133
|
|
|
132
134
|
if (global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender) {
|
|
133
135
|
// We do this so React doesn't complain when we replace the span in a secondary render
|
|
134
|
-
const htmlContents = `<span
|
|
136
|
+
const htmlContents = `<span></span>`; // FIXME: height/style/etc. lifted from PureStory
|
|
135
137
|
|
|
136
138
|
const {
|
|
137
139
|
height
|
|
@@ -140,8 +142,8 @@ const Story = props => {
|
|
|
140
142
|
id: storyBlockIdFromId(story.id)
|
|
141
143
|
}, /*#__PURE__*/React.createElement(MDXProvider, {
|
|
142
144
|
components: resetComponents
|
|
143
|
-
}, height ? /*#__PURE__*/React.createElement("style", null, `#story--${story.id} { min-height: ${height}; transform: translateZ(0); overflow: auto }`) : null, /*#__PURE__*/React.createElement("div", {
|
|
144
|
-
ref:
|
|
145
|
+
}, height ? /*#__PURE__*/React.createElement("style", null, `#story--${story.id} { min-height: ${height}; transform: translateZ(0); overflow: auto }`) : null, showLoader && /*#__PURE__*/React.createElement(StorySkeleton, null), /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
ref: storyRef,
|
|
145
147
|
"data-name": story.name,
|
|
146
148
|
dangerouslySetInnerHTML: {
|
|
147
149
|
__html: htmlContents
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import "core-js/modules/es.array.reduce.js";
|
|
1
2
|
import { useState, useEffect } from 'react';
|
|
2
3
|
export function useStory(storyId, context) {
|
|
3
4
|
const stories = useStories([storyId], context);
|
|
4
5
|
return stories && stories[0];
|
|
5
6
|
}
|
|
6
7
|
export function useStories(storyIds, context) {
|
|
7
|
-
const
|
|
8
|
+
const initialStoriesById = context.componentStories().reduce((acc, story) => {
|
|
9
|
+
acc[story.id] = story;
|
|
10
|
+
return acc;
|
|
11
|
+
}, {});
|
|
12
|
+
const [storiesById, setStories] = useState(initialStoriesById);
|
|
8
13
|
useEffect(() => {
|
|
9
14
|
Promise.all(storyIds.map(async storyId => {
|
|
10
15
|
// loadStory will be called every single time useStory is called
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-docs",
|
|
3
|
-
"version": "6.4.0-beta.
|
|
3
|
+
"version": "6.4.0-beta.33",
|
|
4
4
|
"description": "Document component usage and properties in Markdown",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -63,21 +63,21 @@
|
|
|
63
63
|
"@mdx-js/loader": "^1.6.22",
|
|
64
64
|
"@mdx-js/mdx": "^1.6.22",
|
|
65
65
|
"@mdx-js/react": "^1.6.22",
|
|
66
|
-
"@storybook/addons": "6.4.0-beta.
|
|
67
|
-
"@storybook/api": "6.4.0-beta.
|
|
68
|
-
"@storybook/builder-webpack4": "6.4.0-beta.
|
|
69
|
-
"@storybook/client-logger": "6.4.0-beta.
|
|
70
|
-
"@storybook/components": "6.4.0-beta.
|
|
71
|
-
"@storybook/core": "6.4.0-beta.
|
|
72
|
-
"@storybook/core-events": "6.4.0-beta.
|
|
66
|
+
"@storybook/addons": "6.4.0-beta.33",
|
|
67
|
+
"@storybook/api": "6.4.0-beta.33",
|
|
68
|
+
"@storybook/builder-webpack4": "6.4.0-beta.33",
|
|
69
|
+
"@storybook/client-logger": "6.4.0-beta.33",
|
|
70
|
+
"@storybook/components": "6.4.0-beta.33",
|
|
71
|
+
"@storybook/core": "6.4.0-beta.33",
|
|
72
|
+
"@storybook/core-events": "6.4.0-beta.33",
|
|
73
73
|
"@storybook/csf": "0.0.2--canary.87bc651.0",
|
|
74
|
-
"@storybook/csf-tools": "6.4.0-beta.
|
|
75
|
-
"@storybook/node-logger": "6.4.0-beta.
|
|
76
|
-
"@storybook/postinstall": "6.4.0-beta.
|
|
77
|
-
"@storybook/preview-web": "6.4.0-beta.
|
|
78
|
-
"@storybook/source-loader": "6.4.0-beta.
|
|
79
|
-
"@storybook/store": "6.4.0-beta.
|
|
80
|
-
"@storybook/theming": "6.4.0-beta.
|
|
74
|
+
"@storybook/csf-tools": "6.4.0-beta.33",
|
|
75
|
+
"@storybook/node-logger": "6.4.0-beta.33",
|
|
76
|
+
"@storybook/postinstall": "6.4.0-beta.33",
|
|
77
|
+
"@storybook/preview-web": "6.4.0-beta.33",
|
|
78
|
+
"@storybook/source-loader": "6.4.0-beta.33",
|
|
79
|
+
"@storybook/store": "6.4.0-beta.33",
|
|
80
|
+
"@storybook/theming": "6.4.0-beta.33",
|
|
81
81
|
"acorn": "^7.4.1",
|
|
82
82
|
"acorn-jsx": "^5.3.1",
|
|
83
83
|
"acorn-walk": "^7.2.0",
|
|
@@ -106,11 +106,11 @@
|
|
|
106
106
|
"@babel/core": "^7.12.10",
|
|
107
107
|
"@emotion/core": "^10.1.1",
|
|
108
108
|
"@emotion/styled": "^10.0.27",
|
|
109
|
-
"@storybook/angular": "6.4.0-beta.
|
|
110
|
-
"@storybook/html": "6.4.0-beta.
|
|
111
|
-
"@storybook/react": "6.4.0-beta.
|
|
112
|
-
"@storybook/vue": "6.4.0-beta.
|
|
113
|
-
"@storybook/web-components": "6.4.0-beta.
|
|
109
|
+
"@storybook/angular": "6.4.0-beta.33",
|
|
110
|
+
"@storybook/html": "6.4.0-beta.33",
|
|
111
|
+
"@storybook/react": "6.4.0-beta.33",
|
|
112
|
+
"@storybook/vue": "6.4.0-beta.33",
|
|
113
|
+
"@storybook/web-components": "6.4.0-beta.33",
|
|
114
114
|
"@types/cross-spawn": "^6.0.2",
|
|
115
115
|
"@types/doctrine": "^0.0.3",
|
|
116
116
|
"@types/enzyme": "^3.10.8",
|
|
@@ -140,12 +140,12 @@
|
|
|
140
140
|
"zone.js": "^0.11.3"
|
|
141
141
|
},
|
|
142
142
|
"peerDependencies": {
|
|
143
|
-
"@storybook/angular": "6.4.0-beta.
|
|
144
|
-
"@storybook/html": "6.4.0-beta.
|
|
145
|
-
"@storybook/react": "6.4.0-beta.
|
|
146
|
-
"@storybook/vue": "6.4.0-beta.
|
|
147
|
-
"@storybook/vue3": "6.4.0-beta.
|
|
148
|
-
"@storybook/web-components": "6.4.0-beta.
|
|
143
|
+
"@storybook/angular": "6.4.0-beta.33",
|
|
144
|
+
"@storybook/html": "6.4.0-beta.33",
|
|
145
|
+
"@storybook/react": "6.4.0-beta.33",
|
|
146
|
+
"@storybook/vue": "6.4.0-beta.33",
|
|
147
|
+
"@storybook/vue3": "6.4.0-beta.33",
|
|
148
|
+
"@storybook/web-components": "6.4.0-beta.33",
|
|
149
149
|
"lit": "^2.0.0-rc.1",
|
|
150
150
|
"lit-html": "^1.4.1 || ^2.0.0-rc.3",
|
|
151
151
|
"react": "^16.8.0 || ^17.0.0",
|
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
"publishConfig": {
|
|
203
203
|
"access": "public"
|
|
204
204
|
},
|
|
205
|
-
"gitHead": "
|
|
205
|
+
"gitHead": "c85171dc319d1d3a31eee1b762f01ba84ae45194",
|
|
206
206
|
"sbmodern": "dist/modern/index.js",
|
|
207
207
|
"storybook": {
|
|
208
208
|
"displayName": "Docs",
|