@storybook/addon-docs 6.4.1 → 6.5.0-alpha.1

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.
@@ -162,8 +162,6 @@ function makeGate() {
162
162
  }
163
163
 
164
164
  var Story = function Story(props) {
165
- var _global$FEATURES, _global$FEATURES2;
166
-
167
165
  var context = (0, _react.useContext)(_DocsContext.DocsContext);
168
166
 
169
167
  var channel = _addons.addons.getChannel();
@@ -220,22 +218,7 @@ var Story = function Story(props) {
220
218
  rendered = _makeGate4[0],
221
219
  onRendered = _makeGate4[1];
222
220
 
223
- (0, _react.useEffect)(onRendered); // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
224
- // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
225
- // `Preview.renderStoryToDom()` which itself emits the event.
226
-
227
- if (story && !(_global.default !== null && _global.default !== void 0 && (_global$FEATURES = _global.default.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender)) {
228
- // We need to wait for two things before we can consider the story rendered:
229
- // (a) React's `useEffect` hook needs to fire. This is needed for React stories, as
230
- // decorators of the form `<A><B/></A>` will not actually execute `B` in the first
231
- // call to the story function.
232
- // (b) The story function needs to actually have been called.
233
- // Certain frameworks (i.e.angular) don't actually render the component in the very first
234
- // React render cycle, so we need to wait for the framework to actually do that
235
- Promise.all([storyFnRan, rendered]).then(function () {
236
- channel.emit(_coreEvents.default.STORY_RENDERED, storyId);
237
- });
238
- }
221
+ (0, _react.useEffect)(onRendered);
239
222
 
240
223
  if (!story) {
241
224
  return /*#__PURE__*/_react.default.createElement(_components.StorySkeleton, null);
@@ -247,22 +230,40 @@ var Story = function Story(props) {
247
230
  return null;
248
231
  }
249
232
 
250
- if (_global.default !== null && _global.default !== void 0 && (_global$FEATURES2 = _global.default.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.modernInlineRender) {
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
- })));
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
+ }
266
267
  }
267
268
 
268
269
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -119,7 +119,9 @@ function webpack() {
119
119
 
120
120
  if (transcludeMarkdown) {
121
121
  rules = [].concat(_toConsumableArray(rules.filter(function (rule) {
122
- return rule.test.toString() !== '/\\.md$/';
122
+ var _rule$test;
123
+
124
+ return ((_rule$test = rule.test) === null || _rule$test === void 0 ? void 0 : _rule$test.toString()) !== '/\\.md$/';
123
125
  })), [{
124
126
  test: /\.md$/,
125
127
  use: [{
@@ -109,8 +109,6 @@ function makeGate() {
109
109
  }
110
110
 
111
111
  var Story = function Story(props) {
112
- var _global$FEATURES, _global$FEATURES2;
113
-
114
112
  var context = useContext(DocsContext);
115
113
  var channel = addons.getChannel();
116
114
  var storyRef = useRef();
@@ -165,22 +163,7 @@ var Story = function Story(props) {
165
163
  rendered = _makeGate4[0],
166
164
  onRendered = _makeGate4[1];
167
165
 
168
- useEffect(onRendered); // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
169
- // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
170
- // `Preview.renderStoryToDom()` which itself emits the event.
171
-
172
- if (story && !(global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender)) {
173
- // We need to wait for two things before we can consider the story rendered:
174
- // (a) React's `useEffect` hook needs to fire. This is needed for React stories, as
175
- // decorators of the form `<A><B/></A>` will not actually execute `B` in the first
176
- // call to the story function.
177
- // (b) The story function needs to actually have been called.
178
- // Certain frameworks (i.e.angular) don't actually render the component in the very first
179
- // React render cycle, so we need to wait for the framework to actually do that
180
- Promise.all([storyFnRan, rendered]).then(function () {
181
- channel.emit(Events.STORY_RENDERED, storyId);
182
- });
183
- }
166
+ useEffect(onRendered);
184
167
 
185
168
  if (!story) {
186
169
  return /*#__PURE__*/React.createElement(StorySkeleton, null);
@@ -192,22 +175,40 @@ var Story = function Story(props) {
192
175
  return null;
193
176
  }
194
177
 
195
- if (global !== null && global !== void 0 && (_global$FEATURES2 = global.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.modernInlineRender) {
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
- })));
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
+ }
211
212
  }
212
213
 
213
214
  return /*#__PURE__*/React.createElement("div", {
@@ -93,7 +93,9 @@ export function webpack() {
93
93
 
94
94
  if (transcludeMarkdown) {
95
95
  rules = [].concat(_toConsumableArray(rules.filter(function (rule) {
96
- return rule.test.toString() !== '/\\.md$/';
96
+ var _rule$test;
97
+
98
+ return ((_rule$test = rule.test) === null || _rule$test === void 0 ? void 0 : _rule$test.toString()) !== '/\\.md$/';
97
99
  })), [{
98
100
  test: /\.md$/,
99
101
  use: [{
@@ -85,8 +85,6 @@ function makeGate() {
85
85
  }
86
86
 
87
87
  const Story = props => {
88
- var _global$FEATURES, _global$FEATURES2;
89
-
90
88
  const context = useContext(DocsContext);
91
89
  const channel = addons.getChannel();
92
90
  const storyRef = useRef();
@@ -127,22 +125,7 @@ const Story = props => {
127
125
  }, [story]);
128
126
  const [storyFnRan, onStoryFnRan] = makeGate();
129
127
  const [rendered, onRendered] = makeGate();
130
- useEffect(onRendered); // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
131
- // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
132
- // `Preview.renderStoryToDom()` which itself emits the event.
133
-
134
- if (story && !(global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender)) {
135
- // We need to wait for two things before we can consider the story rendered:
136
- // (a) React's `useEffect` hook needs to fire. This is needed for React stories, as
137
- // decorators of the form `<A><B/></A>` will not actually execute `B` in the first
138
- // call to the story function.
139
- // (b) The story function needs to actually have been called.
140
- // Certain frameworks (i.e.angular) don't actually render the component in the very first
141
- // React render cycle, so we need to wait for the framework to actually do that
142
- Promise.all([storyFnRan, rendered]).then(() => {
143
- channel.emit(Events.STORY_RENDERED, storyId);
144
- });
145
- }
128
+ useEffect(onRendered);
146
129
 
147
130
  if (!story) {
148
131
  return /*#__PURE__*/React.createElement(StorySkeleton, null);
@@ -154,24 +137,42 @@ const Story = props => {
154
137
  return null;
155
138
  }
156
139
 
157
- if (global !== null && global !== void 0 && (_global$FEATURES2 = global.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.modernInlineRender) {
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
- })));
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
+ }
175
176
  }
176
177
 
177
178
  return /*#__PURE__*/React.createElement("div", {
@@ -62,7 +62,11 @@ export function webpack(webpackConfig = {}, options = {}) {
62
62
  let rules = module.rules || [];
63
63
 
64
64
  if (transcludeMarkdown) {
65
- rules = [...rules.filter(rule => rule.test.toString() !== '/\\.md$/'), {
65
+ rules = [...rules.filter(rule => {
66
+ var _rule$test;
67
+
68
+ return ((_rule$test = rule.test) === null || _rule$test === void 0 ? void 0 : _rule$test.toString()) !== '/\\.md$/';
69
+ }), {
66
70
  test: /\.md$/,
67
71
  use: [{
68
72
  loader: resolvedBabelLoader,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-docs",
3
- "version": "6.4.1",
3
+ "version": "6.5.0-alpha.1",
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.1",
67
- "@storybook/api": "6.4.1",
68
- "@storybook/builder-webpack4": "6.4.1",
69
- "@storybook/client-logger": "6.4.1",
70
- "@storybook/components": "6.4.1",
71
- "@storybook/core": "6.4.1",
72
- "@storybook/core-events": "6.4.1",
66
+ "@storybook/addons": "6.5.0-alpha.1",
67
+ "@storybook/api": "6.5.0-alpha.1",
68
+ "@storybook/builder-webpack4": "6.5.0-alpha.1",
69
+ "@storybook/client-logger": "6.5.0-alpha.1",
70
+ "@storybook/components": "6.5.0-alpha.1",
71
+ "@storybook/core": "6.5.0-alpha.1",
72
+ "@storybook/core-events": "6.5.0-alpha.1",
73
73
  "@storybook/csf": "0.0.2--canary.87bc651.0",
74
- "@storybook/csf-tools": "6.4.1",
75
- "@storybook/node-logger": "6.4.1",
76
- "@storybook/postinstall": "6.4.1",
77
- "@storybook/preview-web": "6.4.1",
78
- "@storybook/source-loader": "6.4.1",
79
- "@storybook/store": "6.4.1",
80
- "@storybook/theming": "6.4.1",
74
+ "@storybook/csf-tools": "6.5.0-alpha.1",
75
+ "@storybook/node-logger": "6.5.0-alpha.1",
76
+ "@storybook/postinstall": "6.5.0-alpha.1",
77
+ "@storybook/preview-web": "6.5.0-alpha.1",
78
+ "@storybook/source-loader": "6.5.0-alpha.1",
79
+ "@storybook/store": "6.5.0-alpha.1",
80
+ "@storybook/theming": "6.5.0-alpha.1",
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.1",
110
- "@storybook/html": "6.4.1",
111
- "@storybook/react": "6.4.1",
112
- "@storybook/vue": "6.4.1",
113
- "@storybook/web-components": "6.4.1",
109
+ "@storybook/angular": "6.5.0-alpha.1",
110
+ "@storybook/html": "6.5.0-alpha.1",
111
+ "@storybook/react": "6.5.0-alpha.1",
112
+ "@storybook/vue": "6.5.0-alpha.1",
113
+ "@storybook/web-components": "6.5.0-alpha.1",
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.1",
144
- "@storybook/html": "6.4.1",
145
- "@storybook/react": "6.4.1",
146
- "@storybook/vue": "6.4.1",
147
- "@storybook/vue3": "6.4.1",
148
- "@storybook/web-components": "6.4.1",
143
+ "@storybook/angular": "6.5.0-alpha.1",
144
+ "@storybook/html": "6.5.0-alpha.1",
145
+ "@storybook/react": "6.5.0-alpha.1",
146
+ "@storybook/vue": "6.5.0-alpha.1",
147
+ "@storybook/vue3": "6.5.0-alpha.1",
148
+ "@storybook/web-components": "6.5.0-alpha.1",
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": "bb20e8fef506e05fb9c67dd55b0405b4b1043698",
205
+ "gitHead": "fbf6e247a099ec45c30f8594f255a088847b7957",
206
206
  "sbmodern": "dist/modern/index.js",
207
207
  "storybook": {
208
208
  "displayName": "Docs",