@storybook/addon-docs 6.5.9 → 7.0.0-alpha.2
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/Anchor.js +7 -10
- package/dist/cjs/blocks/ArgsTable.js +135 -206
- package/dist/cjs/blocks/Canvas.js +38 -73
- package/dist/cjs/blocks/Description.js +41 -68
- package/dist/cjs/blocks/DocsContainer.js +40 -68
- package/dist/cjs/blocks/DocsContext.js +1 -1
- package/dist/cjs/blocks/DocsPage.js +3 -5
- package/dist/cjs/blocks/DocsStory.js +18 -28
- package/dist/cjs/blocks/Heading.js +5 -9
- package/dist/cjs/blocks/Meta.js +11 -33
- package/dist/cjs/blocks/Preview.js +4 -10
- package/dist/cjs/blocks/Primary.js +12 -40
- package/dist/cjs/blocks/Props.js +4 -10
- package/dist/cjs/blocks/Source.js +62 -80
- package/dist/cjs/blocks/SourceContainer.js +19 -68
- package/dist/cjs/blocks/Stories.js +17 -48
- package/dist/cjs/blocks/Story.js +60 -180
- package/dist/cjs/blocks/Subheading.js +5 -9
- package/dist/cjs/blocks/Subtitle.js +15 -35
- package/dist/cjs/blocks/Title.js +12 -36
- package/dist/cjs/blocks/Wrapper.js +7 -8
- package/dist/cjs/blocks/enhanceSource.js +30 -67
- package/dist/cjs/blocks/index.js +28 -34
- package/dist/cjs/blocks/mdx.js +86 -97
- package/dist/cjs/blocks/types.js +2 -2
- package/dist/cjs/blocks/useStory.js +16 -87
- package/dist/cjs/blocks/utils.js +4 -25
- package/dist/cjs/index.js +1 -7
- package/dist/cjs/manager.js +9 -15
- package/dist/cjs/preset.js +129 -193
- package/dist/cjs/preview.js +5 -87
- package/dist/cjs/shared.js +5 -5
- package/dist/esm/blocks/Anchor.js +7 -10
- package/dist/esm/blocks/ArgsTable.js +133 -182
- package/dist/esm/blocks/Canvas.js +34 -46
- package/dist/esm/blocks/Description.js +39 -45
- package/dist/esm/blocks/DocsContainer.js +36 -44
- package/dist/esm/blocks/DocsContext.js +1 -1
- package/dist/esm/blocks/DocsPage.js +3 -5
- package/dist/esm/blocks/DocsStory.js +18 -27
- package/dist/esm/blocks/Heading.js +5 -7
- package/dist/esm/blocks/Meta.js +9 -13
- package/dist/esm/blocks/Preview.js +5 -10
- package/dist/esm/blocks/Primary.js +10 -16
- package/dist/esm/blocks/Props.js +5 -10
- package/dist/esm/blocks/Source.js +64 -70
- package/dist/esm/blocks/SourceContainer.js +17 -50
- package/dist/esm/blocks/Stories.js +15 -27
- package/dist/esm/blocks/Story.js +58 -151
- package/dist/esm/blocks/Subheading.js +5 -7
- package/dist/esm/blocks/Subtitle.js +12 -12
- package/dist/esm/blocks/Title.js +10 -11
- package/dist/esm/blocks/Wrapper.js +7 -8
- package/dist/esm/blocks/enhanceSource.js +32 -56
- package/dist/esm/blocks/mdx.js +85 -89
- package/dist/esm/blocks/types.js +2 -2
- package/dist/esm/blocks/useStory.js +16 -73
- package/dist/esm/blocks/utils.js +4 -18
- package/dist/esm/manager.js +9 -14
- package/dist/esm/preset.js +114 -179
- package/dist/esm/preview.js +3 -61
- package/dist/esm/shared.js +5 -5
- package/dist/{ts3.9 → types}/blocks/Anchor.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/ArgsTable.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Canvas.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Description.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/DocsContainer.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/DocsContext.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/DocsPage.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/DocsStory.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Heading.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Meta.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Preview.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Primary.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Props.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Source.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/SourceContainer.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Stories.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Story.d.ts +2 -2
- package/dist/{ts3.9 → types}/blocks/Subheading.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Subtitle.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Title.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Wrapper.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/enhanceSource.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/index.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/mdx.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/types.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/useStory.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/utils.d.ts +0 -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/{ts3.9 → types}/preview.d.ts +0 -0
- package/dist/{ts3.9 → types}/shared.d.ts +0 -0
- package/package.json +17 -24
- 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/cjs/blocks/mdx.js
CHANGED
|
@@ -1,26 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.object.keys.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol.js");
|
|
6
|
-
|
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
6
|
exports.assertIsFn = exports.HeadersMdx = exports.HeaderMdx = exports.CodeOrSourceMdx = exports.AnchorMdx = exports.AddContext = void 0;
|
|
11
7
|
|
|
12
|
-
require("core-js/modules/es.object.assign.js");
|
|
13
|
-
|
|
14
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
15
|
-
|
|
16
|
-
require("core-js/modules/es.string.match.js");
|
|
17
|
-
|
|
18
|
-
require("core-js/modules/es.string.split.js");
|
|
19
|
-
|
|
20
|
-
require("core-js/modules/es.string.starts-with.js");
|
|
21
|
-
|
|
22
|
-
require("core-js/modules/es.object.to-string.js");
|
|
23
|
-
|
|
24
8
|
var _react = _interopRequireDefault(require("react"));
|
|
25
9
|
|
|
26
10
|
var _addons = require("@storybook/addons");
|
|
@@ -35,27 +19,25 @@ var _theming = require("@storybook/theming");
|
|
|
35
19
|
|
|
36
20
|
var _DocsContext = require("./DocsContext");
|
|
37
21
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
const _excluded = ["children"],
|
|
23
|
+
_excluded2 = ["className", "children"],
|
|
24
|
+
_excluded3 = ["href", "target", "children"],
|
|
25
|
+
_excluded4 = ["as", "id", "children"],
|
|
26
|
+
_excluded5 = ["as", "id", "children"];
|
|
43
27
|
|
|
44
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
45
29
|
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
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); }
|
|
49
|
-
|
|
50
|
-
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; }
|
|
30
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
51
31
|
|
|
52
32
|
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; }
|
|
53
33
|
|
|
54
|
-
|
|
34
|
+
const {
|
|
35
|
+
document
|
|
36
|
+
} = _global.default; // Hacky utility for asserting identifiers in MDX Story elements
|
|
55
37
|
|
|
56
|
-
|
|
38
|
+
const assertIsFn = val => {
|
|
57
39
|
if (typeof val !== 'function') {
|
|
58
|
-
throw new Error(
|
|
40
|
+
throw new Error(`Expected story function, got: ${val}`);
|
|
59
41
|
}
|
|
60
42
|
|
|
61
43
|
return val;
|
|
@@ -64,11 +46,13 @@ var assertIsFn = function assertIsFn(val) {
|
|
|
64
46
|
|
|
65
47
|
exports.assertIsFn = assertIsFn;
|
|
66
48
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
const AddContext = props => {
|
|
50
|
+
const {
|
|
51
|
+
children
|
|
52
|
+
} = props,
|
|
53
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
70
54
|
|
|
71
|
-
|
|
55
|
+
const parentContext = _react.default.useContext(_DocsContext.DocsContext);
|
|
72
56
|
|
|
73
57
|
return /*#__PURE__*/_react.default.createElement(_DocsContext.DocsContext.Provider, {
|
|
74
58
|
value: Object.assign({}, parentContext, rest)
|
|
@@ -77,10 +61,12 @@ var AddContext = function AddContext(props) {
|
|
|
77
61
|
|
|
78
62
|
exports.AddContext = AddContext;
|
|
79
63
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
const CodeOrSourceMdx = _ref => {
|
|
65
|
+
let {
|
|
66
|
+
className,
|
|
67
|
+
children
|
|
68
|
+
} = _ref,
|
|
69
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
84
70
|
|
|
85
71
|
// markdown-to-jsx does not add className to inline code
|
|
86
72
|
if (typeof className !== 'string' && (typeof children !== 'string' || !children.match(/[\n\r]/g))) {
|
|
@@ -88,7 +74,7 @@ var CodeOrSourceMdx = function CodeOrSourceMdx(_ref) {
|
|
|
88
74
|
} // className: "lang-jsx"
|
|
89
75
|
|
|
90
76
|
|
|
91
|
-
|
|
77
|
+
const language = className && className.split('-');
|
|
92
78
|
return /*#__PURE__*/_react.default.createElement(_components.Source, _extends({
|
|
93
79
|
language: language && language[1] || 'plaintext',
|
|
94
80
|
format: false,
|
|
@@ -103,30 +89,31 @@ function navigate(url) {
|
|
|
103
89
|
} // @ts-ignore
|
|
104
90
|
|
|
105
91
|
|
|
106
|
-
|
|
92
|
+
const A = _components.components.a;
|
|
107
93
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
94
|
+
const AnchorInPage = ({
|
|
95
|
+
hash,
|
|
96
|
+
children
|
|
97
|
+
}) => /*#__PURE__*/_react.default.createElement(A, {
|
|
98
|
+
href: hash,
|
|
99
|
+
target: "_self",
|
|
100
|
+
onClick: event => {
|
|
101
|
+
const id = hash.substring(1);
|
|
102
|
+
const element = document.getElementById(id);
|
|
117
103
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
104
|
+
if (element) {
|
|
105
|
+
navigate(hash);
|
|
121
106
|
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
107
|
+
}
|
|
108
|
+
}, children);
|
|
124
109
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
110
|
+
const AnchorMdx = props => {
|
|
111
|
+
const {
|
|
112
|
+
href,
|
|
113
|
+
target,
|
|
114
|
+
children
|
|
115
|
+
} = props,
|
|
116
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded3);
|
|
130
117
|
|
|
131
118
|
if (href) {
|
|
132
119
|
// Enable scrolling for in-page anchors.
|
|
@@ -140,7 +127,7 @@ var AnchorMdx = function AnchorMdx(props) {
|
|
|
140
127
|
if (target !== '_blank' && !href.startsWith('https://')) {
|
|
141
128
|
return /*#__PURE__*/_react.default.createElement(A, _extends({
|
|
142
129
|
href: href,
|
|
143
|
-
onClick:
|
|
130
|
+
onClick: event => {
|
|
144
131
|
event.preventDefault(); // use the A element's href, which has been modified for
|
|
145
132
|
// local paths without a `?path=` query param prefix
|
|
146
133
|
|
|
@@ -156,37 +143,38 @@ var AnchorMdx = function AnchorMdx(props) {
|
|
|
156
143
|
};
|
|
157
144
|
|
|
158
145
|
exports.AnchorMdx = AnchorMdx;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
146
|
+
const SUPPORTED_MDX_HEADERS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
147
|
+
const OcticonHeaders = SUPPORTED_MDX_HEADERS.reduce((acc, headerType) => Object.assign({}, acc, {
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
[headerType]: (0, _theming.styled)(_components.components[headerType])({
|
|
162
150
|
'& svg': {
|
|
163
151
|
visibility: 'hidden'
|
|
164
152
|
},
|
|
165
153
|
'&:hover svg': {
|
|
166
154
|
visibility: 'visible'
|
|
167
155
|
}
|
|
168
|
-
})
|
|
169
|
-
}, {});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
rest =
|
|
156
|
+
})
|
|
157
|
+
}), {});
|
|
158
|
+
|
|
159
|
+
const OcticonAnchor = _theming.styled.a(() => ({
|
|
160
|
+
float: 'left',
|
|
161
|
+
paddingRight: '4px',
|
|
162
|
+
marginLeft: '-20px',
|
|
163
|
+
// Allow the theme's text color to override the default link color.
|
|
164
|
+
color: 'inherit'
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
const HeaderWithOcticonAnchor = _ref2 => {
|
|
168
|
+
let {
|
|
169
|
+
as,
|
|
170
|
+
id,
|
|
171
|
+
children
|
|
172
|
+
} = _ref2,
|
|
173
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded4);
|
|
186
174
|
|
|
187
175
|
// @ts-ignore
|
|
188
|
-
|
|
189
|
-
|
|
176
|
+
const OcticonHeader = OcticonHeaders[as];
|
|
177
|
+
const hash = `#${id}`;
|
|
190
178
|
return /*#__PURE__*/_react.default.createElement(OcticonHeader, _extends({
|
|
191
179
|
id: id
|
|
192
180
|
}, rest), /*#__PURE__*/_react.default.createElement(OcticonAnchor, {
|
|
@@ -194,8 +182,8 @@ var HeaderWithOcticonAnchor = function HeaderWithOcticonAnchor(_ref3) {
|
|
|
194
182
|
href: hash,
|
|
195
183
|
tabIndex: -1,
|
|
196
184
|
target: "_self",
|
|
197
|
-
onClick:
|
|
198
|
-
|
|
185
|
+
onClick: event => {
|
|
186
|
+
const element = document.getElementById(id);
|
|
199
187
|
|
|
200
188
|
if (element) {
|
|
201
189
|
navigate(hash);
|
|
@@ -214,11 +202,13 @@ var HeaderWithOcticonAnchor = function HeaderWithOcticonAnchor(_ref3) {
|
|
|
214
202
|
}))), children);
|
|
215
203
|
};
|
|
216
204
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
205
|
+
const HeaderMdx = props => {
|
|
206
|
+
const {
|
|
207
|
+
as,
|
|
208
|
+
id,
|
|
209
|
+
children
|
|
210
|
+
} = props,
|
|
211
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded5); // An id should have been added on every header by the "remark-slug" plugin.
|
|
222
212
|
|
|
223
213
|
|
|
224
214
|
if (id) {
|
|
@@ -229,17 +219,16 @@ var HeaderMdx = function HeaderMdx(props) {
|
|
|
229
219
|
} // @ts-ignore
|
|
230
220
|
|
|
231
221
|
|
|
232
|
-
|
|
222
|
+
const Header = _components.components[as]; // Make sure it still work if "remark-slug" plugin is not present.
|
|
233
223
|
|
|
234
224
|
return /*#__PURE__*/_react.default.createElement(Header, props);
|
|
235
225
|
};
|
|
236
226
|
|
|
237
227
|
exports.HeaderMdx = HeaderMdx;
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}, {});
|
|
228
|
+
const HeadersMdx = SUPPORTED_MDX_HEADERS.reduce((acc, headerType) => Object.assign({}, acc, {
|
|
229
|
+
// @ts-ignore
|
|
230
|
+
[headerType]: props => /*#__PURE__*/_react.default.createElement(HeaderMdx, _extends({
|
|
231
|
+
as: headerType
|
|
232
|
+
}, props))
|
|
233
|
+
}), {});
|
|
245
234
|
exports.HeadersMdx = HeadersMdx;
|
package/dist/cjs/blocks/types.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PRIMARY_STORY = exports.CURRENT_SELECTION = void 0;
|
|
7
|
-
|
|
7
|
+
const CURRENT_SELECTION = '.';
|
|
8
8
|
exports.CURRENT_SELECTION = CURRENT_SELECTION;
|
|
9
|
-
|
|
9
|
+
const PRIMARY_STORY = '^';
|
|
10
10
|
exports.PRIMARY_STORY = PRIMARY_STORY;
|
|
@@ -1,108 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol.description.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.array.slice.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.function.name.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.array.from.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
16
|
-
|
|
17
3
|
Object.defineProperty(exports, "__esModule", {
|
|
18
4
|
value: true
|
|
19
5
|
});
|
|
20
6
|
exports.useStories = useStories;
|
|
21
7
|
exports.useStory = useStory;
|
|
22
8
|
|
|
23
|
-
require("regenerator-runtime/runtime.js");
|
|
24
|
-
|
|
25
|
-
require("core-js/modules/es.object.to-string.js");
|
|
26
|
-
|
|
27
|
-
require("core-js/modules/es.array.iterator.js");
|
|
28
|
-
|
|
29
|
-
require("core-js/modules/es.promise.js");
|
|
30
|
-
|
|
31
|
-
require("core-js/modules/es.string.iterator.js");
|
|
32
|
-
|
|
33
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
34
|
-
|
|
35
|
-
require("core-js/modules/es.array.map.js");
|
|
36
|
-
|
|
37
|
-
require("core-js/modules/es.object.assign.js");
|
|
38
|
-
|
|
39
9
|
var _react = require("react");
|
|
40
10
|
|
|
41
|
-
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; }
|
|
42
|
-
|
|
43
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
44
|
-
|
|
45
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
46
|
-
|
|
47
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
48
|
-
|
|
49
|
-
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."); }
|
|
50
|
-
|
|
51
|
-
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); }
|
|
52
|
-
|
|
53
|
-
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; }
|
|
54
|
-
|
|
55
|
-
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; }
|
|
56
|
-
|
|
57
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
58
|
-
|
|
59
11
|
function useStory(storyId, context) {
|
|
60
|
-
|
|
12
|
+
const stories = useStories([storyId], context);
|
|
61
13
|
return stories && stories[0];
|
|
62
14
|
}
|
|
63
15
|
|
|
64
16
|
function useStories(storyIds, context) {
|
|
65
|
-
|
|
17
|
+
const initialStoriesById = context.componentStories().reduce((acc, story) => {
|
|
66
18
|
acc[story.id] = story;
|
|
67
19
|
return acc;
|
|
68
20
|
}, {});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
switch (_context.prev = _context.next) {
|
|
82
|
-
case 0:
|
|
83
|
-
_context.next = 2;
|
|
84
|
-
return context.loadStory(storyId);
|
|
85
|
-
|
|
86
|
-
case 2:
|
|
87
|
-
story = _context.sent;
|
|
88
|
-
setStories(function (current) {
|
|
89
|
-
return current[storyId] === story ? current : Object.assign({}, current, _defineProperty({}, storyId, story));
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
case 4:
|
|
93
|
-
case "end":
|
|
94
|
-
return _context.stop();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}, _callee);
|
|
21
|
+
const [storiesById, setStories] = (0, _react.useState)(initialStoriesById);
|
|
22
|
+
(0, _react.useEffect)(() => {
|
|
23
|
+
Promise.all(storyIds.map(async storyId => {
|
|
24
|
+
// loadStory will be called every single time useStory is called
|
|
25
|
+
// because useEffect does not use storyIds as an input. This is because
|
|
26
|
+
// HMR can change the story even when the storyId hasn't changed. However, it
|
|
27
|
+
// will be a no-op once the story has loaded. Furthermore, the `story` will
|
|
28
|
+
// have an exact equality when the story hasn't changed, so it won't trigger
|
|
29
|
+
// any unnecessary re-renders
|
|
30
|
+
const story = await context.loadStory(storyId);
|
|
31
|
+
setStories(current => current[storyId] === story ? current : Object.assign({}, current, {
|
|
32
|
+
[storyId]: story
|
|
98
33
|
}));
|
|
99
|
-
|
|
100
|
-
return function (_x) {
|
|
101
|
-
return _ref.apply(this, arguments);
|
|
102
|
-
};
|
|
103
|
-
}()));
|
|
104
|
-
});
|
|
105
|
-
return storyIds.map(function (storyId) {
|
|
106
|
-
return storiesById[storyId];
|
|
34
|
+
}));
|
|
107
35
|
});
|
|
36
|
+
return storyIds.map(storyId => storiesById[storyId]);
|
|
108
37
|
}
|
package/dist/cjs/blocks/utils.js
CHANGED
|
@@ -6,30 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getComponentName = void 0;
|
|
7
7
|
exports.scrollToElement = scrollToElement;
|
|
8
8
|
|
|
9
|
-
require("core-js/modules/es.array.join.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.array.map.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.string.split.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.array.slice.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.array.includes.js");
|
|
20
|
-
|
|
21
|
-
require("core-js/modules/es.string.includes.js");
|
|
22
|
-
|
|
23
|
-
require("core-js/modules/es.function.name.js");
|
|
24
|
-
|
|
25
9
|
/* eslint-disable no-underscore-dangle */
|
|
26
|
-
|
|
27
|
-
return str.split('-').map(function (part) {
|
|
28
|
-
return part.charAt(0).toUpperCase() + part.slice(1);
|
|
29
|
-
}).join('');
|
|
30
|
-
};
|
|
10
|
+
const titleCase = str => str.split('-').map(part => part.charAt(0).toUpperCase() + part.slice(1)).join('');
|
|
31
11
|
|
|
32
|
-
|
|
12
|
+
const getComponentName = component => {
|
|
33
13
|
if (!component) {
|
|
34
14
|
return undefined;
|
|
35
15
|
}
|
|
@@ -51,11 +31,10 @@ var getComponentName = function getComponentName(component) {
|
|
|
51
31
|
|
|
52
32
|
exports.getComponentName = getComponentName;
|
|
53
33
|
|
|
54
|
-
function scrollToElement(element) {
|
|
55
|
-
var block = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'start';
|
|
34
|
+
function scrollToElement(element, block = 'start') {
|
|
56
35
|
element.scrollIntoView({
|
|
57
36
|
behavior: 'smooth',
|
|
58
|
-
block
|
|
37
|
+
block,
|
|
59
38
|
inline: 'nearest'
|
|
60
39
|
});
|
|
61
40
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.object.to-string.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.object.keys.js");
|
|
8
|
-
|
|
9
3
|
Object.defineProperty(exports, "__esModule", {
|
|
10
4
|
value: true
|
|
11
5
|
});
|
|
@@ -17,7 +11,7 @@ Object.keys(_blocks).forEach(function (key) {
|
|
|
17
11
|
if (key in exports && exports[key] === _blocks[key]) return;
|
|
18
12
|
Object.defineProperty(exports, key, {
|
|
19
13
|
enumerable: true,
|
|
20
|
-
get: function
|
|
14
|
+
get: function () {
|
|
21
15
|
return _blocks[key];
|
|
22
16
|
}
|
|
23
17
|
});
|
package/dist/cjs/manager.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.array.concat.js");
|
|
4
|
-
|
|
5
3
|
var _addons = require("@storybook/addons");
|
|
6
4
|
|
|
7
5
|
var _shared = require("./shared");
|
|
8
6
|
|
|
9
|
-
_addons.addons.register(_shared.ADDON_ID,
|
|
7
|
+
_addons.addons.register(_shared.ADDON_ID, () => {
|
|
10
8
|
_addons.addons.add(_shared.PANEL_ID, {
|
|
11
9
|
type: _addons.types.TAB,
|
|
12
10
|
title: 'Docs',
|
|
13
|
-
route:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
render: function render() {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
11
|
+
route: ({
|
|
12
|
+
storyId,
|
|
13
|
+
refId
|
|
14
|
+
}) => refId ? `/docs/${refId}_${storyId}` : `/docs/${storyId}`,
|
|
15
|
+
match: ({
|
|
16
|
+
viewMode
|
|
17
|
+
}) => viewMode === 'docs',
|
|
18
|
+
render: () => null
|
|
25
19
|
});
|
|
26
20
|
});
|