@storybook/addon-docs 6.5.9 → 7.0.0-alpha.10
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/blocks.d.ts +1 -1
- package/dist/cjs/blocks/index.js +5 -359
- package/dist/cjs/index.js +1 -7
- package/dist/cjs/manager.js +9 -15
- package/dist/cjs/preset.js +121 -193
- package/dist/cjs/preview.js +9 -87
- package/dist/cjs/shared.js +5 -5
- package/dist/esm/blocks/index.js +1 -24
- package/dist/esm/manager.js +9 -14
- package/dist/esm/preset.js +114 -179
- package/dist/esm/preview.js +7 -61
- package/dist/esm/shared.js +5 -5
- package/dist/types/blocks/index.d.ts +1 -0
- package/dist/{ts3.9 → types}/index.d.ts +0 -0
- package/dist/{ts3.9 → types}/manager.d.ts +0 -0
- package/dist/{ts3.9 → types}/preset.d.ts +2 -1
- package/dist/types/preview.d.ts +1 -0
- package/dist/{ts3.9 → types}/shared.d.ts +0 -0
- package/package.json +18 -25
- package/dist/cjs/blocks/Anchor.js +0 -26
- package/dist/cjs/blocks/ArgsTable.js +0 -400
- package/dist/cjs/blocks/Canvas.js +0 -144
- package/dist/cjs/blocks/Description.js +0 -153
- package/dist/cjs/blocks/DocsContainer.js +0 -155
- package/dist/cjs/blocks/DocsContext.js +0 -25
- package/dist/cjs/blocks/DocsPage.js +0 -32
- package/dist/cjs/blocks/DocsStory.js +0 -78
- package/dist/cjs/blocks/Heading.js +0 -35
- package/dist/cjs/blocks/Meta.js +0 -72
- package/dist/cjs/blocks/Preview.js +0 -29
- package/dist/cjs/blocks/Primary.js +0 -67
- package/dist/cjs/blocks/Props.js +0 -35
- package/dist/cjs/blocks/Source.js +0 -197
- package/dist/cjs/blocks/SourceContainer.js +0 -116
- package/dist/cjs/blocks/Stories.js +0 -82
- package/dist/cjs/blocks/Story.js +0 -263
- package/dist/cjs/blocks/Subheading.js +0 -35
- package/dist/cjs/blocks/Subtitle.js +0 -59
- package/dist/cjs/blocks/Title.js +0 -68
- package/dist/cjs/blocks/Wrapper.js +0 -21
- package/dist/cjs/blocks/enhanceSource.js +0 -129
- package/dist/cjs/blocks/mdx.js +0 -245
- package/dist/cjs/blocks/types.js +0 -10
- package/dist/cjs/blocks/useStory.js +0 -108
- package/dist/cjs/blocks/utils.js +0 -61
- package/dist/esm/blocks/Anchor.js +0 -11
- package/dist/esm/blocks/ArgsTable.js +0 -341
- package/dist/esm/blocks/Canvas.js +0 -95
- package/dist/esm/blocks/Description.js +0 -113
- package/dist/esm/blocks/DocsContainer.js +0 -106
- package/dist/esm/blocks/DocsContext.js +0 -16
- package/dist/esm/blocks/DocsPage.js +0 -13
- package/dist/esm/blocks/DocsStory.js +0 -55
- package/dist/esm/blocks/Heading.js +0 -19
- package/dist/esm/blocks/Meta.js +0 -35
- package/dist/esm/blocks/Preview.js +0 -14
- package/dist/esm/blocks/Primary.js +0 -29
- package/dist/esm/blocks/Props.js +0 -19
- package/dist/esm/blocks/Source.js +0 -150
- package/dist/esm/blocks/SourceContainer.js +0 -77
- package/dist/esm/blocks/Stories.js +0 -42
- package/dist/esm/blocks/Story.js +0 -207
- package/dist/esm/blocks/Subheading.js +0 -19
- package/dist/esm/blocks/Subtitle.js +0 -23
- package/dist/esm/blocks/Title.js +0 -25
- package/dist/esm/blocks/Wrapper.js +0 -9
- package/dist/esm/blocks/enhanceSource.js +0 -111
- package/dist/esm/blocks/mdx.js +0 -207
- package/dist/esm/blocks/types.js +0 -2
- package/dist/esm/blocks/useStory.js +0 -84
- package/dist/esm/blocks/utils.js +0 -43
- package/dist/modern/blocks/Anchor.js +0 -8
- package/dist/modern/blocks/ArgsTable.js +0 -292
- package/dist/modern/blocks/Canvas.js +0 -83
- package/dist/modern/blocks/Description.js +0 -107
- package/dist/modern/blocks/DocsContainer.js +0 -98
- package/dist/modern/blocks/DocsContext.js +0 -16
- package/dist/modern/blocks/DocsPage.js +0 -11
- package/dist/modern/blocks/DocsStory.js +0 -48
- package/dist/modern/blocks/Heading.js +0 -17
- package/dist/modern/blocks/Meta.js +0 -31
- package/dist/modern/blocks/Preview.js +0 -9
- package/dist/modern/blocks/Primary.js +0 -23
- package/dist/modern/blocks/Props.js +0 -14
- package/dist/modern/blocks/Source.js +0 -154
- package/dist/modern/blocks/SourceContainer.js +0 -44
- package/dist/modern/blocks/Stories.js +0 -34
- package/dist/modern/blocks/Story.js +0 -168
- package/dist/modern/blocks/Subheading.js +0 -17
- package/dist/modern/blocks/Subtitle.js +0 -23
- package/dist/modern/blocks/Title.js +0 -24
- package/dist/modern/blocks/Wrapper.js +0 -8
- package/dist/modern/blocks/enhanceSource.js +0 -89
- package/dist/modern/blocks/index.js +0 -24
- package/dist/modern/blocks/mdx.js +0 -204
- package/dist/modern/blocks/types.js +0 -2
- package/dist/modern/blocks/useStory.js +0 -28
- package/dist/modern/blocks/utils.js +0 -29
- package/dist/modern/index.js +0 -1
- package/dist/modern/manager.js +0 -16
- package/dist/modern/preset.js +0 -130
- package/dist/modern/preview.js +0 -6
- package/dist/modern/shared.js +0 -11
- package/dist/ts3.4/blocks/Anchor.d.ts +0 -6
- package/dist/ts3.4/blocks/ArgsTable.d.ts +0 -33
- package/dist/ts3.4/blocks/Canvas.d.ts +0 -9
- package/dist/ts3.4/blocks/Description.d.ts +0 -20
- package/dist/ts3.4/blocks/DocsContainer.d.ts +0 -7
- package/dist/ts3.4/blocks/DocsContext.d.ts +0 -5
- package/dist/ts3.4/blocks/DocsPage.d.ts +0 -2
- package/dist/ts3.4/blocks/DocsStory.d.ts +0 -3
- package/dist/ts3.4/blocks/Heading.d.ts +0 -6
- package/dist/ts3.4/blocks/Meta.d.ts +0 -9
- package/dist/ts3.4/blocks/Preview.d.ts +0 -3
- package/dist/ts3.4/blocks/Primary.d.ts +0 -6
- package/dist/ts3.4/blocks/Props.d.ts +0 -3
- package/dist/ts3.4/blocks/Source.d.ts +0 -38
- package/dist/ts3.4/blocks/SourceContainer.d.ts +0 -14
- package/dist/ts3.4/blocks/Stories.d.ts +0 -7
- package/dist/ts3.4/blocks/Story.d.ts +0 -28
- package/dist/ts3.4/blocks/Subheading.d.ts +0 -3
- package/dist/ts3.4/blocks/Subtitle.d.ts +0 -6
- package/dist/ts3.4/blocks/Title.d.ts +0 -8
- package/dist/ts3.4/blocks/Wrapper.d.ts +0 -2
- package/dist/ts3.4/blocks/enhanceSource.d.ts +0 -3
- package/dist/ts3.4/blocks/index.d.ts +0 -24
- package/dist/ts3.4/blocks/mdx.d.ts +0 -20
- package/dist/ts3.4/blocks/types.d.ts +0 -13
- package/dist/ts3.4/blocks/useStory.d.ts +0 -5
- package/dist/ts3.4/blocks/utils.d.ts +0 -3
- package/dist/ts3.4/index.d.ts +0 -1
- package/dist/ts3.4/manager.d.ts +0 -1
- package/dist/ts3.4/preset.d.ts +0 -11
- package/dist/ts3.4/preview.d.ts +0 -6
- package/dist/ts3.4/shared.d.ts +0 -24
- package/dist/ts3.9/blocks/Anchor.d.ts +0 -6
- package/dist/ts3.9/blocks/ArgsTable.d.ts +0 -33
- package/dist/ts3.9/blocks/Canvas.d.ts +0 -9
- package/dist/ts3.9/blocks/Description.d.ts +0 -20
- package/dist/ts3.9/blocks/DocsContainer.d.ts +0 -7
- package/dist/ts3.9/blocks/DocsContext.d.ts +0 -5
- package/dist/ts3.9/blocks/DocsPage.d.ts +0 -2
- package/dist/ts3.9/blocks/DocsStory.d.ts +0 -3
- package/dist/ts3.9/blocks/Heading.d.ts +0 -6
- package/dist/ts3.9/blocks/Meta.d.ts +0 -9
- package/dist/ts3.9/blocks/Preview.d.ts +0 -3
- package/dist/ts3.9/blocks/Primary.d.ts +0 -6
- package/dist/ts3.9/blocks/Props.d.ts +0 -3
- package/dist/ts3.9/blocks/Source.d.ts +0 -38
- package/dist/ts3.9/blocks/SourceContainer.d.ts +0 -14
- package/dist/ts3.9/blocks/Stories.d.ts +0 -7
- package/dist/ts3.9/blocks/Story.d.ts +0 -28
- package/dist/ts3.9/blocks/Subheading.d.ts +0 -3
- package/dist/ts3.9/blocks/Subtitle.d.ts +0 -6
- package/dist/ts3.9/blocks/Title.d.ts +0 -8
- package/dist/ts3.9/blocks/Wrapper.d.ts +0 -2
- package/dist/ts3.9/blocks/enhanceSource.d.ts +0 -3
- package/dist/ts3.9/blocks/index.d.ts +0 -24
- package/dist/ts3.9/blocks/mdx.d.ts +0 -20
- package/dist/ts3.9/blocks/types.d.ts +0 -13
- package/dist/ts3.9/blocks/useStory.d.ts +0 -5
- package/dist/ts3.9/blocks/utils.d.ts +0 -3
- package/dist/ts3.9/preview.d.ts +0 -6
package/dist/esm/blocks/Story.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
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) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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
|
-
|
|
13
|
-
import "core-js/modules/es.function.name.js";
|
|
14
|
-
import "core-js/modules/es.object.assign.js";
|
|
15
|
-
import "core-js/modules/es.object.to-string.js";
|
|
16
|
-
import "core-js/modules/es.promise.js";
|
|
17
|
-
import "core-js/modules/es.array.iterator.js";
|
|
18
|
-
import "core-js/modules/es.string.iterator.js";
|
|
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";
|
|
24
|
-
import "core-js/modules/es.array.slice.js";
|
|
25
|
-
import "core-js/modules/es.array.from.js";
|
|
26
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
27
|
-
import React, { useContext, useRef, useEffect, useState } from 'react';
|
|
28
|
-
import { MDXProvider } from '@mdx-js/react';
|
|
29
|
-
import global from 'global';
|
|
30
|
-
import { resetComponents, Story as PureStory, StorySkeleton } from '@storybook/components';
|
|
31
|
-
import { toId, storyNameFromExport } from '@storybook/csf';
|
|
32
|
-
import { addons } from '@storybook/addons';
|
|
33
|
-
import Events from '@storybook/core-events';
|
|
34
|
-
import { CURRENT_SELECTION } from './types';
|
|
35
|
-
import { DocsContext } from './DocsContext';
|
|
36
|
-
import { useStory } from './useStory';
|
|
37
|
-
export var storyBlockIdFromId = function storyBlockIdFromId(storyId) {
|
|
38
|
-
return "story--".concat(storyId);
|
|
39
|
-
};
|
|
40
|
-
export var lookupStoryId = function lookupStoryId(storyName, _ref) {
|
|
41
|
-
var mdxStoryNameToKey = _ref.mdxStoryNameToKey,
|
|
42
|
-
mdxComponentAnnotations = _ref.mdxComponentAnnotations;
|
|
43
|
-
return toId(mdxComponentAnnotations.id || mdxComponentAnnotations.title, storyNameFromExport(mdxStoryNameToKey[storyName]));
|
|
44
|
-
};
|
|
45
|
-
export var getStoryId = function getStoryId(props, context) {
|
|
46
|
-
var _ref2 = props,
|
|
47
|
-
id = _ref2.id;
|
|
48
|
-
var _ref3 = props,
|
|
49
|
-
name = _ref3.name;
|
|
50
|
-
var inputId = id === CURRENT_SELECTION ? context.id : id;
|
|
51
|
-
return inputId || lookupStoryId(name, context);
|
|
52
|
-
};
|
|
53
|
-
export var getStoryProps = function getStoryProps(_ref4, story, context, onStoryFnCalled) {
|
|
54
|
-
var height = _ref4.height,
|
|
55
|
-
inline = _ref4.inline;
|
|
56
|
-
var storyName = story.name,
|
|
57
|
-
parameters = story.parameters;
|
|
58
|
-
var _parameters$docs = parameters.docs,
|
|
59
|
-
docs = _parameters$docs === void 0 ? {} : _parameters$docs;
|
|
60
|
-
|
|
61
|
-
if (docs.disable) {
|
|
62
|
-
return null;
|
|
63
|
-
} // prefer block props, then story parameters defined by the framework-specific settings and optionally overridden by users
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var _docs$inlineStories = docs.inlineStories,
|
|
67
|
-
inlineStories = _docs$inlineStories === void 0 ? false : _docs$inlineStories,
|
|
68
|
-
_docs$iframeHeight = docs.iframeHeight,
|
|
69
|
-
iframeHeight = _docs$iframeHeight === void 0 ? 100 : _docs$iframeHeight,
|
|
70
|
-
prepareForInline = docs.prepareForInline;
|
|
71
|
-
var storyIsInline = typeof inline === 'boolean' ? inline : inlineStories;
|
|
72
|
-
|
|
73
|
-
if (storyIsInline && !prepareForInline) {
|
|
74
|
-
throw new Error("Story '".concat(storyName, "' is set to render inline, but no 'prepareForInline' function is implemented in your docs configuration!"));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
var boundStoryFn = function boundStoryFn() {
|
|
78
|
-
var storyResult = story.unboundStoryFn(Object.assign({}, context.getStoryContext(story), {
|
|
79
|
-
loaded: {},
|
|
80
|
-
abortSignal: undefined,
|
|
81
|
-
canvasElement: undefined
|
|
82
|
-
})); // We need to wait until the bound story function has actually been called before we
|
|
83
|
-
// consider the story rendered. Certain frameworks (i.e. angular) don't actually render
|
|
84
|
-
// the component in the very first react render cycle, and so we can't just wait until the
|
|
85
|
-
// `PureStory` component has been rendered to consider the underlying story "rendered".
|
|
86
|
-
|
|
87
|
-
onStoryFnCalled();
|
|
88
|
-
return storyResult;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
return Object.assign({
|
|
92
|
-
inline: storyIsInline,
|
|
93
|
-
id: story.id,
|
|
94
|
-
height: height || (storyIsInline ? undefined : iframeHeight),
|
|
95
|
-
title: storyName
|
|
96
|
-
}, storyIsInline && {
|
|
97
|
-
parameters: parameters,
|
|
98
|
-
storyFn: function storyFn() {
|
|
99
|
-
return prepareForInline(boundStoryFn, context.getStoryContext(story));
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
function makeGate() {
|
|
105
|
-
var open;
|
|
106
|
-
var gate = new Promise(function (r) {
|
|
107
|
-
open = r;
|
|
108
|
-
});
|
|
109
|
-
return [gate, open];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
var Story = function Story(props) {
|
|
113
|
-
var context = useContext(DocsContext);
|
|
114
|
-
var channel = addons.getChannel();
|
|
115
|
-
var storyRef = useRef();
|
|
116
|
-
var storyId = getStoryId(props, context);
|
|
117
|
-
var story = useStory(storyId, context);
|
|
118
|
-
|
|
119
|
-
var _useState = useState(true),
|
|
120
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
121
|
-
showLoader = _useState2[0],
|
|
122
|
-
setShowLoader = _useState2[1];
|
|
123
|
-
|
|
124
|
-
useEffect(function () {
|
|
125
|
-
var cleanup;
|
|
126
|
-
|
|
127
|
-
if (story && storyRef.current) {
|
|
128
|
-
var element = storyRef.current;
|
|
129
|
-
cleanup = context.renderStoryToElement(story, element);
|
|
130
|
-
setShowLoader(false);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return function () {
|
|
134
|
-
return cleanup && cleanup();
|
|
135
|
-
};
|
|
136
|
-
}, [story]);
|
|
137
|
-
|
|
138
|
-
var _makeGate = makeGate(),
|
|
139
|
-
_makeGate2 = _slicedToArray(_makeGate, 2),
|
|
140
|
-
storyFnRan = _makeGate2[0],
|
|
141
|
-
onStoryFnRan = _makeGate2[1];
|
|
142
|
-
|
|
143
|
-
var _makeGate3 = makeGate(),
|
|
144
|
-
_makeGate4 = _slicedToArray(_makeGate3, 2),
|
|
145
|
-
rendered = _makeGate4[0],
|
|
146
|
-
onRendered = _makeGate4[1];
|
|
147
|
-
|
|
148
|
-
useEffect(onRendered);
|
|
149
|
-
|
|
150
|
-
if (!story) {
|
|
151
|
-
return /*#__PURE__*/React.createElement(StorySkeleton, null);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
var storyProps = getStoryProps(props, story, context, onStoryFnRan);
|
|
155
|
-
|
|
156
|
-
if (!storyProps) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (storyProps.inline) {
|
|
161
|
-
var _global$FEATURES;
|
|
162
|
-
|
|
163
|
-
// If we are rendering a old-style inline Story via `PureStory` below, we want to emit
|
|
164
|
-
// the `STORY_RENDERED` event when it renders. The modern mode below calls out to
|
|
165
|
-
// `Preview.renderStoryToDom()` which itself emits the event.
|
|
166
|
-
if (!(global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender)) {
|
|
167
|
-
// We need to wait for two things before we can consider the story rendered:
|
|
168
|
-
// (a) React's `useEffect` hook needs to fire. This is needed for React stories, as
|
|
169
|
-
// decorators of the form `<A><B/></A>` will not actually execute `B` in the first
|
|
170
|
-
// call to the story function.
|
|
171
|
-
// (b) The story function needs to actually have been called.
|
|
172
|
-
// Certain frameworks (i.e.angular) don't actually render the component in the very first
|
|
173
|
-
// React render cycle, so we need to wait for the framework to actually do that
|
|
174
|
-
Promise.all([storyFnRan, rendered]).then(function () {
|
|
175
|
-
channel.emit(Events.STORY_RENDERED, storyId);
|
|
176
|
-
});
|
|
177
|
-
} else {
|
|
178
|
-
// We do this so React doesn't complain when we replace the span in a secondary render
|
|
179
|
-
var htmlContents = "<span></span>"; // FIXME: height/style/etc. lifted from PureStory
|
|
180
|
-
|
|
181
|
-
var height = storyProps.height;
|
|
182
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
183
|
-
id: storyBlockIdFromId(story.id)
|
|
184
|
-
}, /*#__PURE__*/React.createElement(MDXProvider, {
|
|
185
|
-
components: resetComponents
|
|
186
|
-
}, 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", {
|
|
187
|
-
ref: storyRef,
|
|
188
|
-
"data-name": story.name,
|
|
189
|
-
dangerouslySetInnerHTML: {
|
|
190
|
-
__html: htmlContents
|
|
191
|
-
}
|
|
192
|
-
})));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
197
|
-
id: storyBlockIdFromId(story.id)
|
|
198
|
-
}, /*#__PURE__*/React.createElement(MDXProvider, {
|
|
199
|
-
components: resetComponents
|
|
200
|
-
}, /*#__PURE__*/React.createElement(PureStory, storyProps)));
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
Story.defaultProps = {
|
|
204
|
-
children: null,
|
|
205
|
-
name: null
|
|
206
|
-
};
|
|
207
|
-
export { Story };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
2
|
-
import "core-js/modules/es.string.replace.js";
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { H3 } from '@storybook/components';
|
|
5
|
-
import { HeaderMdx } from './mdx';
|
|
6
|
-
export var Subheading = function Subheading(_ref) {
|
|
7
|
-
var children = _ref.children,
|
|
8
|
-
disableAnchor = _ref.disableAnchor;
|
|
9
|
-
|
|
10
|
-
if (disableAnchor || typeof children !== 'string') {
|
|
11
|
-
return /*#__PURE__*/React.createElement(H3, null, children);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
var tagID = children.toLowerCase().replace(/[^a-z0-9]/gi, '-');
|
|
15
|
-
return /*#__PURE__*/React.createElement(HeaderMdx, {
|
|
16
|
-
as: "h3",
|
|
17
|
-
id: tagID
|
|
18
|
-
}, children);
|
|
19
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import { Subtitle as PureSubtitle } from '@storybook/components';
|
|
3
|
-
import { DocsContext } from './DocsContext';
|
|
4
|
-
export var Subtitle = function Subtitle(_ref) {
|
|
5
|
-
var children = _ref.children;
|
|
6
|
-
|
|
7
|
-
var _useContext = useContext(DocsContext),
|
|
8
|
-
id = _useContext.id,
|
|
9
|
-
storyById = _useContext.storyById;
|
|
10
|
-
|
|
11
|
-
var _storyById = storyById(id),
|
|
12
|
-
parameters = _storyById.parameters;
|
|
13
|
-
|
|
14
|
-
var text = children;
|
|
15
|
-
|
|
16
|
-
if (!text) {
|
|
17
|
-
text = parameters === null || parameters === void 0 ? void 0 : parameters.componentSubtitle;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return text ? /*#__PURE__*/React.createElement(PureSubtitle, {
|
|
21
|
-
className: "sbdocs-subtitle"
|
|
22
|
-
}, text) : null;
|
|
23
|
-
};
|
package/dist/esm/blocks/Title.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
2
|
-
import "core-js/modules/es.string.split.js";
|
|
3
|
-
import "core-js/modules/es.string.trim.js";
|
|
4
|
-
import React, { useContext } from 'react';
|
|
5
|
-
import { Title as PureTitle } from '@storybook/components';
|
|
6
|
-
import { DocsContext } from './DocsContext';
|
|
7
|
-
var STORY_KIND_PATH_SEPARATOR = /\s*\/\s*/;
|
|
8
|
-
export var extractTitle = function extractTitle(_ref) {
|
|
9
|
-
var title = _ref.title;
|
|
10
|
-
var groups = title.trim().split(STORY_KIND_PATH_SEPARATOR);
|
|
11
|
-
return groups && groups[groups.length - 1] || title;
|
|
12
|
-
};
|
|
13
|
-
export var Title = function Title(_ref2) {
|
|
14
|
-
var children = _ref2.children;
|
|
15
|
-
var context = useContext(DocsContext);
|
|
16
|
-
var text = children;
|
|
17
|
-
|
|
18
|
-
if (!text) {
|
|
19
|
-
text = extractTitle(context);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return text ? /*#__PURE__*/React.createElement(PureTitle, {
|
|
23
|
-
className: "sbdocs-title"
|
|
24
|
-
}, text) : null;
|
|
25
|
-
};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
-
|
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
|
|
13
|
-
import "core-js/modules/es.array.join.js";
|
|
14
|
-
import "core-js/modules/es.array.concat.js";
|
|
15
|
-
import "core-js/modules/es.array.slice.js";
|
|
16
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
17
|
-
import "core-js/modules/es.string.replace.js";
|
|
18
|
-
import "core-js/modules/es.string.split.js";
|
|
19
|
-
import "core-js/modules/es.symbol.js";
|
|
20
|
-
import "core-js/modules/es.symbol.description.js";
|
|
21
|
-
import "core-js/modules/es.object.to-string.js";
|
|
22
|
-
import "core-js/modules/es.symbol.iterator.js";
|
|
23
|
-
import "core-js/modules/es.array.iterator.js";
|
|
24
|
-
import "core-js/modules/es.string.iterator.js";
|
|
25
|
-
import "core-js/modules/web.dom-collections.iterator.js";
|
|
26
|
-
import "core-js/modules/es.array.from.js";
|
|
27
|
-
import "core-js/modules/es.function.name.js";
|
|
28
|
-
import { combineParameters } from '@storybook/store'; // ============================================================
|
|
29
|
-
// START @storybook/source-loader/extract-source
|
|
30
|
-
//
|
|
31
|
-
// This code duplicated because tree-shaking isn't working.
|
|
32
|
-
// It's not DRY, but source-loader is on the chopping block for
|
|
33
|
-
// the next version of addon-docs, so it's not the worst sin.
|
|
34
|
-
// ============================================================
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* given a location, extract the text from the full source
|
|
38
|
-
*/
|
|
39
|
-
function extractSource(location, lines) {
|
|
40
|
-
var start = location.startBody,
|
|
41
|
-
end = location.endBody;
|
|
42
|
-
|
|
43
|
-
if (start.line === end.line && lines[start.line - 1] !== undefined) {
|
|
44
|
-
return lines[start.line - 1].substring(start.col, end.col);
|
|
45
|
-
} // NOTE: storysource locations are 1-based not 0-based!
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var startLine = lines[start.line - 1];
|
|
49
|
-
var endLine = lines[end.line - 1];
|
|
50
|
-
|
|
51
|
-
if (startLine === undefined || endLine === undefined) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return [startLine.substring(start.col)].concat(_toConsumableArray(lines.slice(start.line, end.line - 1)), [endLine.substring(0, end.col)]).join('\n');
|
|
56
|
-
} // ============================================================
|
|
57
|
-
// END @storybook/source-loader/extract-source
|
|
58
|
-
// ============================================================
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Replaces full story id name like: story-kind--story-name -> story-name
|
|
63
|
-
* @param id
|
|
64
|
-
*/
|
|
65
|
-
var storyIdToSanitizedStoryName = function storyIdToSanitizedStoryName(id) {
|
|
66
|
-
return id.replace(/^.*?--/, '');
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
var extract = function extract(targetId, _ref) {
|
|
70
|
-
var source = _ref.source,
|
|
71
|
-
locationsMap = _ref.locationsMap;
|
|
72
|
-
|
|
73
|
-
if (!locationsMap) {
|
|
74
|
-
return source;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
var sanitizedStoryName = storyIdToSanitizedStoryName(targetId);
|
|
78
|
-
var location = locationsMap[sanitizedStoryName];
|
|
79
|
-
|
|
80
|
-
if (!location) {
|
|
81
|
-
return source;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
var lines = source.split('\n');
|
|
85
|
-
return extractSource(location, lines);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export var enhanceSource = function enhanceSource(story) {
|
|
89
|
-
var _docs$source;
|
|
90
|
-
|
|
91
|
-
var id = story.id,
|
|
92
|
-
parameters = story.parameters;
|
|
93
|
-
var storySource = parameters.storySource,
|
|
94
|
-
_parameters$docs = parameters.docs,
|
|
95
|
-
docs = _parameters$docs === void 0 ? {} : _parameters$docs;
|
|
96
|
-
var transformSource = docs.transformSource; // no input or user has manually overridden the output
|
|
97
|
-
|
|
98
|
-
if (!(storySource !== null && storySource !== void 0 && storySource.source) || (_docs$source = docs.source) !== null && _docs$source !== void 0 && _docs$source.code) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
var input = extract(id, storySource);
|
|
103
|
-
var code = transformSource ? transformSource(input, story) : input;
|
|
104
|
-
return {
|
|
105
|
-
docs: combineParameters(docs, {
|
|
106
|
-
source: {
|
|
107
|
-
code: code
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
};
|
|
111
|
-
};
|
package/dist/esm/blocks/mdx.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import "core-js/modules/es.object.keys.js";
|
|
2
|
-
import "core-js/modules/es.symbol.js";
|
|
3
|
-
var _excluded = ["children"],
|
|
4
|
-
_excluded2 = ["className", "children"],
|
|
5
|
-
_excluded3 = ["href", "target", "children"],
|
|
6
|
-
_excluded4 = ["as", "id", "children"],
|
|
7
|
-
_excluded5 = ["as", "id", "children"];
|
|
8
|
-
|
|
9
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
-
|
|
11
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
-
|
|
13
|
-
import "core-js/modules/es.object.assign.js";
|
|
14
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
15
|
-
import "core-js/modules/es.string.match.js";
|
|
16
|
-
import "core-js/modules/es.string.split.js";
|
|
17
|
-
import "core-js/modules/es.string.starts-with.js";
|
|
18
|
-
import "core-js/modules/es.object.to-string.js";
|
|
19
|
-
|
|
20
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
|
-
|
|
22
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
23
|
-
|
|
24
|
-
import React from 'react';
|
|
25
|
-
import { addons } from '@storybook/addons';
|
|
26
|
-
import { NAVIGATE_URL } from '@storybook/core-events';
|
|
27
|
-
import { Source, Code, components } from '@storybook/components';
|
|
28
|
-
import global from 'global';
|
|
29
|
-
import { styled } from '@storybook/theming';
|
|
30
|
-
import { DocsContext } from './DocsContext';
|
|
31
|
-
var document = global.document; // Hacky utility for asserting identifiers in MDX Story elements
|
|
32
|
-
|
|
33
|
-
export var assertIsFn = function assertIsFn(val) {
|
|
34
|
-
if (typeof val !== 'function') {
|
|
35
|
-
throw new Error("Expected story function, got: ".concat(val));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return val;
|
|
39
|
-
}; // Hacky utility for adding mdxStoryToId to the default context
|
|
40
|
-
|
|
41
|
-
export var AddContext = function AddContext(props) {
|
|
42
|
-
var children = props.children,
|
|
43
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
44
|
-
|
|
45
|
-
var parentContext = React.useContext(DocsContext);
|
|
46
|
-
return /*#__PURE__*/React.createElement(DocsContext.Provider, {
|
|
47
|
-
value: Object.assign({}, parentContext, rest)
|
|
48
|
-
}, children);
|
|
49
|
-
};
|
|
50
|
-
export var CodeOrSourceMdx = function CodeOrSourceMdx(_ref) {
|
|
51
|
-
var className = _ref.className,
|
|
52
|
-
children = _ref.children,
|
|
53
|
-
rest = _objectWithoutProperties(_ref, _excluded2);
|
|
54
|
-
|
|
55
|
-
// markdown-to-jsx does not add className to inline code
|
|
56
|
-
if (typeof className !== 'string' && (typeof children !== 'string' || !children.match(/[\n\r]/g))) {
|
|
57
|
-
return /*#__PURE__*/React.createElement(Code, null, children);
|
|
58
|
-
} // className: "lang-jsx"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var language = className && className.split('-');
|
|
62
|
-
return /*#__PURE__*/React.createElement(Source, _extends({
|
|
63
|
-
language: language && language[1] || 'plaintext',
|
|
64
|
-
format: false,
|
|
65
|
-
code: children
|
|
66
|
-
}, rest));
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
function navigate(url) {
|
|
70
|
-
addons.getChannel().emit(NAVIGATE_URL, url);
|
|
71
|
-
} // @ts-ignore
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
var A = components.a;
|
|
75
|
-
|
|
76
|
-
var AnchorInPage = function AnchorInPage(_ref2) {
|
|
77
|
-
var hash = _ref2.hash,
|
|
78
|
-
children = _ref2.children;
|
|
79
|
-
return /*#__PURE__*/React.createElement(A, {
|
|
80
|
-
href: hash,
|
|
81
|
-
target: "_self",
|
|
82
|
-
onClick: function onClick(event) {
|
|
83
|
-
var id = hash.substring(1);
|
|
84
|
-
var element = document.getElementById(id);
|
|
85
|
-
|
|
86
|
-
if (element) {
|
|
87
|
-
navigate(hash);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}, children);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export var AnchorMdx = function AnchorMdx(props) {
|
|
94
|
-
var href = props.href,
|
|
95
|
-
target = props.target,
|
|
96
|
-
children = props.children,
|
|
97
|
-
rest = _objectWithoutProperties(props, _excluded3);
|
|
98
|
-
|
|
99
|
-
if (href) {
|
|
100
|
-
// Enable scrolling for in-page anchors.
|
|
101
|
-
if (href.startsWith('#')) {
|
|
102
|
-
return /*#__PURE__*/React.createElement(AnchorInPage, {
|
|
103
|
-
hash: href
|
|
104
|
-
}, children);
|
|
105
|
-
} // Links to other pages of SB should use the base URL of the top level iframe instead of the base URL of the preview iframe.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (target !== '_blank' && !href.startsWith('https://')) {
|
|
109
|
-
return /*#__PURE__*/React.createElement(A, _extends({
|
|
110
|
-
href: href,
|
|
111
|
-
onClick: function onClick(event) {
|
|
112
|
-
event.preventDefault(); // use the A element's href, which has been modified for
|
|
113
|
-
// local paths without a `?path=` query param prefix
|
|
114
|
-
|
|
115
|
-
navigate(event.currentTarget.getAttribute('href'));
|
|
116
|
-
},
|
|
117
|
-
target: target
|
|
118
|
-
}, rest), children);
|
|
119
|
-
}
|
|
120
|
-
} // External URL dont need any modification.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return /*#__PURE__*/React.createElement(A, props);
|
|
124
|
-
};
|
|
125
|
-
var SUPPORTED_MDX_HEADERS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
126
|
-
var OcticonHeaders = SUPPORTED_MDX_HEADERS.reduce(function (acc, headerType) {
|
|
127
|
-
return Object.assign({}, acc, _defineProperty({}, headerType, styled(components[headerType])({
|
|
128
|
-
'& svg': {
|
|
129
|
-
visibility: 'hidden'
|
|
130
|
-
},
|
|
131
|
-
'&:hover svg': {
|
|
132
|
-
visibility: 'visible'
|
|
133
|
-
}
|
|
134
|
-
})));
|
|
135
|
-
}, {});
|
|
136
|
-
var OcticonAnchor = styled.a(function () {
|
|
137
|
-
return {
|
|
138
|
-
float: 'left',
|
|
139
|
-
paddingRight: '4px',
|
|
140
|
-
marginLeft: '-20px',
|
|
141
|
-
// Allow the theme's text color to override the default link color.
|
|
142
|
-
color: 'inherit'
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
var HeaderWithOcticonAnchor = function HeaderWithOcticonAnchor(_ref3) {
|
|
147
|
-
var as = _ref3.as,
|
|
148
|
-
id = _ref3.id,
|
|
149
|
-
children = _ref3.children,
|
|
150
|
-
rest = _objectWithoutProperties(_ref3, _excluded4);
|
|
151
|
-
|
|
152
|
-
// @ts-ignore
|
|
153
|
-
var OcticonHeader = OcticonHeaders[as];
|
|
154
|
-
var hash = "#".concat(id);
|
|
155
|
-
return /*#__PURE__*/React.createElement(OcticonHeader, _extends({
|
|
156
|
-
id: id
|
|
157
|
-
}, rest), /*#__PURE__*/React.createElement(OcticonAnchor, {
|
|
158
|
-
"aria-hidden": "true",
|
|
159
|
-
href: hash,
|
|
160
|
-
tabIndex: -1,
|
|
161
|
-
target: "_self",
|
|
162
|
-
onClick: function onClick(event) {
|
|
163
|
-
var element = document.getElementById(id);
|
|
164
|
-
|
|
165
|
-
if (element) {
|
|
166
|
-
navigate(hash);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}, /*#__PURE__*/React.createElement("svg", {
|
|
170
|
-
viewBox: "0 0 16 16",
|
|
171
|
-
version: "1.1",
|
|
172
|
-
width: "16",
|
|
173
|
-
height: "16",
|
|
174
|
-
"aria-hidden": "true",
|
|
175
|
-
fill: "currentColor"
|
|
176
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
177
|
-
fillRule: "evenodd",
|
|
178
|
-
d: "M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
|
|
179
|
-
}))), children);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
export var HeaderMdx = function HeaderMdx(props) {
|
|
183
|
-
var as = props.as,
|
|
184
|
-
id = props.id,
|
|
185
|
-
children = props.children,
|
|
186
|
-
rest = _objectWithoutProperties(props, _excluded5); // An id should have been added on every header by the "remark-slug" plugin.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (id) {
|
|
190
|
-
return /*#__PURE__*/React.createElement(HeaderWithOcticonAnchor, _extends({
|
|
191
|
-
as: as,
|
|
192
|
-
id: id
|
|
193
|
-
}, rest), children);
|
|
194
|
-
} // @ts-ignore
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
var Header = components[as]; // Make sure it still work if "remark-slug" plugin is not present.
|
|
198
|
-
|
|
199
|
-
return /*#__PURE__*/React.createElement(Header, props);
|
|
200
|
-
};
|
|
201
|
-
export var HeadersMdx = SUPPORTED_MDX_HEADERS.reduce(function (acc, headerType) {
|
|
202
|
-
return Object.assign({}, acc, _defineProperty({}, headerType, function (props) {
|
|
203
|
-
return /*#__PURE__*/React.createElement(HeaderMdx, _extends({
|
|
204
|
-
as: headerType
|
|
205
|
-
}, props));
|
|
206
|
-
}));
|
|
207
|
-
}, {});
|
package/dist/esm/blocks/types.js
DELETED