@storybook/addon-docs 6.4.0-rc.9 → 6.4.3

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.
@@ -6,16 +6,8 @@ require("core-js/modules/es.symbol.js");
6
6
 
7
7
  require("core-js/modules/es.symbol.description.js");
8
8
 
9
- require("core-js/modules/es.object.to-string.js");
10
-
11
9
  require("core-js/modules/es.symbol.iterator.js");
12
10
 
13
- require("core-js/modules/es.string.iterator.js");
14
-
15
- require("core-js/modules/es.array.iterator.js");
16
-
17
- require("core-js/modules/web.dom-collections.iterator.js");
18
-
19
11
  require("core-js/modules/es.array.slice.js");
20
12
 
21
13
  require("core-js/modules/es.array.from.js");
@@ -33,6 +25,16 @@ require("core-js/modules/es.function.name.js");
33
25
 
34
26
  require("core-js/modules/es.object.assign.js");
35
27
 
28
+ require("core-js/modules/es.promise.js");
29
+
30
+ require("core-js/modules/es.object.to-string.js");
31
+
32
+ require("core-js/modules/es.string.iterator.js");
33
+
34
+ require("core-js/modules/es.array.iterator.js");
35
+
36
+ require("core-js/modules/web.dom-collections.iterator.js");
37
+
36
38
  require("core-js/modules/es.array.concat.js");
37
39
 
38
40
  var _react = _interopRequireWildcard(require("react"));
@@ -151,9 +153,15 @@ var getStoryProps = function getStoryProps(_ref4, story, context, onStoryFnCalle
151
153
 
152
154
  exports.getStoryProps = getStoryProps;
153
155
 
154
- var Story = function Story(props) {
155
- var _global$FEATURES;
156
+ function makeGate() {
157
+ var open;
158
+ var gate = new Promise(function (r) {
159
+ open = r;
160
+ });
161
+ return [gate, open];
162
+ }
156
163
 
164
+ var Story = function Story(props) {
157
165
  var context = (0, _react.useContext)(_DocsContext.DocsContext);
158
166
 
159
167
  var channel = _addons.addons.getChannel();
@@ -200,37 +208,62 @@ var Story = function Story(props) {
200
208
  };
201
209
  }, [story]);
202
210
 
211
+ var _makeGate = makeGate(),
212
+ _makeGate2 = _slicedToArray(_makeGate, 2),
213
+ storyFnRan = _makeGate2[0],
214
+ onStoryFnRan = _makeGate2[1];
215
+
216
+ var _makeGate3 = makeGate(),
217
+ _makeGate4 = _slicedToArray(_makeGate3, 2),
218
+ rendered = _makeGate4[0],
219
+ onRendered = _makeGate4[1];
220
+
221
+ (0, _react.useEffect)(onRendered);
222
+
203
223
  if (!story) {
204
224
  return /*#__PURE__*/_react.default.createElement(_components.StorySkeleton, null);
205
- } // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
206
- // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
207
- // `Preview.renderStoryToDom()` which itself emits the event.
225
+ }
208
226
 
209
-
210
- var storyProps = getStoryProps(props, story, context, function () {
211
- return channel.emit(_coreEvents.default.STORY_RENDERED, storyId);
212
- });
227
+ var storyProps = getStoryProps(props, story, context, onStoryFnRan);
213
228
 
214
229
  if (!storyProps) {
215
230
  return null;
216
231
  }
217
232
 
218
- if (_global.default !== null && _global.default !== void 0 && (_global$FEATURES = _global.default.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender) {
219
- // We do this so React doesn't complain when we replace the span in a secondary render
220
- var htmlContents = "<span></span>"; // FIXME: height/style/etc. lifted from PureStory
221
-
222
- var height = storyProps.height;
223
- return /*#__PURE__*/_react.default.createElement("div", {
224
- id: storyBlockIdFromId(story.id)
225
- }, /*#__PURE__*/_react.default.createElement(_react2.MDXProvider, {
226
- components: _components.resetComponents
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,
229
- "data-name": story.name,
230
- dangerouslySetInnerHTML: {
231
- __html: htmlContents
232
- }
233
- })));
233
+ if (storyProps.inline) {
234
+ var _global$FEATURES;
235
+
236
+ // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
237
+ // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
238
+ // `Preview.renderStoryToDom()` which itself emits the event.
239
+ if (!(_global.default !== null && _global.default !== void 0 && (_global$FEATURES = _global.default.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender)) {
240
+ // We need to wait for two things before we can consider the story rendered:
241
+ // (a) React's `useEffect` hook needs to fire. This is needed for React stories, as
242
+ // decorators of the form `<A><B/></A>` will not actually execute `B` in the first
243
+ // call to the story function.
244
+ // (b) The story function needs to actually have been called.
245
+ // Certain frameworks (i.e.angular) don't actually render the component in the very first
246
+ // React render cycle, so we need to wait for the framework to actually do that
247
+ Promise.all([storyFnRan, rendered]).then(function () {
248
+ channel.emit(_coreEvents.default.STORY_RENDERED, storyId);
249
+ });
250
+ } else {
251
+ // We do this so React doesn't complain when we replace the span in a secondary render
252
+ var htmlContents = "<span></span>"; // FIXME: height/style/etc. lifted from PureStory
253
+
254
+ var height = storyProps.height;
255
+ return /*#__PURE__*/_react.default.createElement("div", {
256
+ id: storyBlockIdFromId(story.id)
257
+ }, /*#__PURE__*/_react.default.createElement(_react2.MDXProvider, {
258
+ components: _components.resetComponents
259
+ }, 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", {
260
+ ref: storyRef,
261
+ "data-name": story.name,
262
+ dangerouslySetInnerHTML: {
263
+ __html: htmlContents
264
+ }
265
+ })));
266
+ }
234
267
  }
235
268
 
236
269
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -12,14 +12,15 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
13
  import "core-js/modules/es.function.name.js";
14
14
  import "core-js/modules/es.object.assign.js";
15
- import "core-js/modules/es.array.concat.js";
16
- import "core-js/modules/es.symbol.js";
17
- import "core-js/modules/es.symbol.description.js";
15
+ import "core-js/modules/es.promise.js";
18
16
  import "core-js/modules/es.object.to-string.js";
19
- import "core-js/modules/es.symbol.iterator.js";
20
17
  import "core-js/modules/es.string.iterator.js";
21
18
  import "core-js/modules/es.array.iterator.js";
22
19
  import "core-js/modules/web.dom-collections.iterator.js";
20
+ import "core-js/modules/es.array.concat.js";
21
+ import "core-js/modules/es.symbol.js";
22
+ import "core-js/modules/es.symbol.description.js";
23
+ import "core-js/modules/es.symbol.iterator.js";
23
24
  import "core-js/modules/es.array.slice.js";
24
25
  import "core-js/modules/es.array.from.js";
25
26
  import React, { useContext, useRef, useEffect, useState } from 'react';
@@ -99,9 +100,15 @@ export var getStoryProps = function getStoryProps(_ref4, story, context, onStory
99
100
  });
100
101
  };
101
102
 
102
- var Story = function Story(props) {
103
- var _global$FEATURES;
103
+ function makeGate() {
104
+ var open;
105
+ var gate = new Promise(function (r) {
106
+ open = r;
107
+ });
108
+ return [gate, open];
109
+ }
104
110
 
111
+ var Story = function Story(props) {
105
112
  var context = useContext(DocsContext);
106
113
  var channel = addons.getChannel();
107
114
  var storyRef = useRef();
@@ -146,37 +153,62 @@ var Story = function Story(props) {
146
153
  };
147
154
  }, [story]);
148
155
 
156
+ var _makeGate = makeGate(),
157
+ _makeGate2 = _slicedToArray(_makeGate, 2),
158
+ storyFnRan = _makeGate2[0],
159
+ onStoryFnRan = _makeGate2[1];
160
+
161
+ var _makeGate3 = makeGate(),
162
+ _makeGate4 = _slicedToArray(_makeGate3, 2),
163
+ rendered = _makeGate4[0],
164
+ onRendered = _makeGate4[1];
165
+
166
+ useEffect(onRendered);
167
+
149
168
  if (!story) {
150
169
  return /*#__PURE__*/React.createElement(StorySkeleton, null);
151
- } // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
152
- // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
153
- // `Preview.renderStoryToDom()` which itself emits the event.
154
-
170
+ }
155
171
 
156
- var storyProps = getStoryProps(props, story, context, function () {
157
- return channel.emit(Events.STORY_RENDERED, storyId);
158
- });
172
+ var storyProps = getStoryProps(props, story, context, onStoryFnRan);
159
173
 
160
174
  if (!storyProps) {
161
175
  return null;
162
176
  }
163
177
 
164
- if (global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender) {
165
- // We do this so React doesn't complain when we replace the span in a secondary render
166
- var htmlContents = "<span></span>"; // FIXME: height/style/etc. lifted from PureStory
167
-
168
- var height = storyProps.height;
169
- return /*#__PURE__*/React.createElement("div", {
170
- id: storyBlockIdFromId(story.id)
171
- }, /*#__PURE__*/React.createElement(MDXProvider, {
172
- components: resetComponents
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,
175
- "data-name": story.name,
176
- dangerouslySetInnerHTML: {
177
- __html: htmlContents
178
- }
179
- })));
178
+ if (storyProps.inline) {
179
+ var _global$FEATURES;
180
+
181
+ // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
182
+ // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
183
+ // `Preview.renderStoryToDom()` which itself emits the event.
184
+ if (!(global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender)) {
185
+ // We need to wait for two things before we can consider the story rendered:
186
+ // (a) React's `useEffect` hook needs to fire. This is needed for React stories, as
187
+ // decorators of the form `<A><B/></A>` will not actually execute `B` in the first
188
+ // call to the story function.
189
+ // (b) The story function needs to actually have been called.
190
+ // Certain frameworks (i.e.angular) don't actually render the component in the very first
191
+ // React render cycle, so we need to wait for the framework to actually do that
192
+ Promise.all([storyFnRan, rendered]).then(function () {
193
+ channel.emit(Events.STORY_RENDERED, storyId);
194
+ });
195
+ } else {
196
+ // We do this so React doesn't complain when we replace the span in a secondary render
197
+ var htmlContents = "<span></span>"; // FIXME: height/style/etc. lifted from PureStory
198
+
199
+ var height = storyProps.height;
200
+ return /*#__PURE__*/React.createElement("div", {
201
+ id: storyBlockIdFromId(story.id)
202
+ }, /*#__PURE__*/React.createElement(MDXProvider, {
203
+ components: resetComponents
204
+ }, 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", {
205
+ ref: storyRef,
206
+ "data-name": story.name,
207
+ dangerouslySetInnerHTML: {
208
+ __html: htmlContents
209
+ }
210
+ })));
211
+ }
180
212
  }
181
213
 
182
214
  return /*#__PURE__*/React.createElement("div", {
@@ -76,9 +76,15 @@ export const getStoryProps = ({
76
76
  });
77
77
  };
78
78
 
79
- const Story = props => {
80
- var _global$FEATURES;
79
+ function makeGate() {
80
+ let open;
81
+ const gate = new Promise(r => {
82
+ open = r;
83
+ });
84
+ return [gate, open];
85
+ }
81
86
 
87
+ const Story = props => {
82
88
  const context = useContext(DocsContext);
83
89
  const channel = addons.getChannel();
84
90
  const storyRef = useRef();
@@ -117,38 +123,56 @@ const Story = props => {
117
123
 
118
124
  return () => cleanup && cleanup();
119
125
  }, [story]);
126
+ const [storyFnRan, onStoryFnRan] = makeGate();
127
+ const [rendered, onRendered] = makeGate();
128
+ useEffect(onRendered);
120
129
 
121
130
  if (!story) {
122
131
  return /*#__PURE__*/React.createElement(StorySkeleton, null);
123
- } // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
124
- // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
125
- // `Preview.renderStoryToDom()` which itself emits the event.
126
-
132
+ }
127
133
 
128
- const storyProps = getStoryProps(props, story, context, () => channel.emit(Events.STORY_RENDERED, storyId));
134
+ const storyProps = getStoryProps(props, story, context, onStoryFnRan);
129
135
 
130
136
  if (!storyProps) {
131
137
  return null;
132
138
  }
133
139
 
134
- if (global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender) {
135
- // We do this so React doesn't complain when we replace the span in a secondary render
136
- const htmlContents = `<span></span>`; // FIXME: height/style/etc. lifted from PureStory
137
-
138
- const {
139
- height
140
- } = storyProps;
141
- return /*#__PURE__*/React.createElement("div", {
142
- id: storyBlockIdFromId(story.id)
143
- }, /*#__PURE__*/React.createElement(MDXProvider, {
144
- components: resetComponents
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,
147
- "data-name": story.name,
148
- dangerouslySetInnerHTML: {
149
- __html: htmlContents
150
- }
151
- })));
140
+ if (storyProps.inline) {
141
+ var _global$FEATURES;
142
+
143
+ // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
144
+ // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
145
+ // `Preview.renderStoryToDom()` which itself emits the event.
146
+ if (!(global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender)) {
147
+ // We need to wait for two things before we can consider the story rendered:
148
+ // (a) React's `useEffect` hook needs to fire. This is needed for React stories, as
149
+ // decorators of the form `<A><B/></A>` will not actually execute `B` in the first
150
+ // call to the story function.
151
+ // (b) The story function needs to actually have been called.
152
+ // Certain frameworks (i.e.angular) don't actually render the component in the very first
153
+ // React render cycle, so we need to wait for the framework to actually do that
154
+ Promise.all([storyFnRan, rendered]).then(() => {
155
+ channel.emit(Events.STORY_RENDERED, storyId);
156
+ });
157
+ } else {
158
+ // We do this so React doesn't complain when we replace the span in a secondary render
159
+ const htmlContents = `<span></span>`; // FIXME: height/style/etc. lifted from PureStory
160
+
161
+ const {
162
+ height
163
+ } = storyProps;
164
+ return /*#__PURE__*/React.createElement("div", {
165
+ id: storyBlockIdFromId(story.id)
166
+ }, /*#__PURE__*/React.createElement(MDXProvider, {
167
+ components: resetComponents
168
+ }, 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", {
169
+ ref: storyRef,
170
+ "data-name": story.name,
171
+ dangerouslySetInnerHTML: {
172
+ __html: htmlContents
173
+ }
174
+ })));
175
+ }
152
176
  }
153
177
 
154
178
  return /*#__PURE__*/React.createElement("div", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-docs",
3
- "version": "6.4.0-rc.9",
3
+ "version": "6.4.3",
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-rc.9",
67
- "@storybook/api": "6.4.0-rc.9",
68
- "@storybook/builder-webpack4": "6.4.0-rc.9",
69
- "@storybook/client-logger": "6.4.0-rc.9",
70
- "@storybook/components": "6.4.0-rc.9",
71
- "@storybook/core": "6.4.0-rc.9",
72
- "@storybook/core-events": "6.4.0-rc.9",
66
+ "@storybook/addons": "6.4.3",
67
+ "@storybook/api": "6.4.3",
68
+ "@storybook/builder-webpack4": "6.4.3",
69
+ "@storybook/client-logger": "6.4.3",
70
+ "@storybook/components": "6.4.3",
71
+ "@storybook/core": "6.4.3",
72
+ "@storybook/core-events": "6.4.3",
73
73
  "@storybook/csf": "0.0.2--canary.87bc651.0",
74
- "@storybook/csf-tools": "6.4.0-rc.9",
75
- "@storybook/node-logger": "6.4.0-rc.9",
76
- "@storybook/postinstall": "6.4.0-rc.9",
77
- "@storybook/preview-web": "6.4.0-rc.9",
78
- "@storybook/source-loader": "6.4.0-rc.9",
79
- "@storybook/store": "6.4.0-rc.9",
80
- "@storybook/theming": "6.4.0-rc.9",
74
+ "@storybook/csf-tools": "6.4.3",
75
+ "@storybook/node-logger": "6.4.3",
76
+ "@storybook/postinstall": "6.4.3",
77
+ "@storybook/preview-web": "6.4.3",
78
+ "@storybook/source-loader": "6.4.3",
79
+ "@storybook/store": "6.4.3",
80
+ "@storybook/theming": "6.4.3",
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-rc.9",
110
- "@storybook/html": "6.4.0-rc.9",
111
- "@storybook/react": "6.4.0-rc.9",
112
- "@storybook/vue": "6.4.0-rc.9",
113
- "@storybook/web-components": "6.4.0-rc.9",
109
+ "@storybook/angular": "6.4.3",
110
+ "@storybook/html": "6.4.3",
111
+ "@storybook/react": "6.4.3",
112
+ "@storybook/vue": "6.4.3",
113
+ "@storybook/web-components": "6.4.3",
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-rc.9",
144
- "@storybook/html": "6.4.0-rc.9",
145
- "@storybook/react": "6.4.0-rc.9",
146
- "@storybook/vue": "6.4.0-rc.9",
147
- "@storybook/vue3": "6.4.0-rc.9",
148
- "@storybook/web-components": "6.4.0-rc.9",
143
+ "@storybook/angular": "6.4.3",
144
+ "@storybook/html": "6.4.3",
145
+ "@storybook/react": "6.4.3",
146
+ "@storybook/vue": "6.4.3",
147
+ "@storybook/vue3": "6.4.3",
148
+ "@storybook/web-components": "6.4.3",
149
149
  "lit": "^2.0.0",
150
150
  "lit-html": "^1.4.1 || ^2.0.0",
151
151
  "react": "^16.8.0 || ^17.0.0",
@@ -202,7 +202,7 @@
202
202
  "publishConfig": {
203
203
  "access": "public"
204
204
  },
205
- "gitHead": "d5236ddaafc17b739a8b546fd65603dd09142344",
205
+ "gitHead": "3e8133aa834b15a7c7021c6e5e090016491b5218",
206
206
  "sbmodern": "dist/modern/index.js",
207
207
  "storybook": {
208
208
  "displayName": "Docs",