@storybook/addon-docs 6.5.0-alpha.40 → 6.5.0-alpha.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/blocks/DocsContext.js +2 -2
- package/dist/cjs/frameworks/common/preset.js +20 -10
- package/dist/cjs/lib/convert/proptypes/convert.js +6 -1
- package/dist/cjs/lib/convert/utils.js +8 -2
- package/dist/esm/blocks/DocsContext.js +2 -2
- package/dist/esm/frameworks/common/preset.js +20 -12
- package/dist/esm/lib/convert/proptypes/convert.js +5 -2
- package/dist/esm/lib/convert/utils.js +3 -0
- package/dist/modern/blocks/DocsContext.js +2 -2
- package/dist/modern/frameworks/common/preset.js +18 -11
- package/dist/modern/lib/convert/proptypes/convert.js +5 -2
- package/dist/modern/lib/convert/utils.js +2 -1
- package/dist/ts3.4/frameworks/common/preset.d.ts +1 -2
- package/dist/ts3.4/lib/convert/utils.d.ts +1 -0
- package/dist/ts3.9/frameworks/common/preset.d.ts +1 -2
- package/dist/ts3.9/lib/convert/utils.d.ts +1 -0
- package/jest-transform-mdx.js +2 -5
- package/mdx-compiler-plugin.js +1 -1
- package/package.json +43 -29
|
@@ -16,10 +16,10 @@ var _global = require("global");
|
|
|
16
16
|
// This was specifically a problem with the Vite builder.
|
|
17
17
|
|
|
18
18
|
/* eslint-disable no-underscore-dangle */
|
|
19
|
-
if (_global.window.__DOCS_CONTEXT__ === undefined) {
|
|
19
|
+
if (_global.window && _global.window.__DOCS_CONTEXT__ === undefined) {
|
|
20
20
|
_global.window.__DOCS_CONTEXT__ = /*#__PURE__*/(0, _react.createContext)({});
|
|
21
21
|
_global.window.__DOCS_CONTEXT__.displayName = 'DocsContext';
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
var DocsContext = _global.window.__DOCS_CONTEXT__;
|
|
24
|
+
var DocsContext = _global.window ? _global.window.__DOCS_CONTEXT__ : /*#__PURE__*/(0, _react.createContext)({});
|
|
25
25
|
exports.DocsContext = DocsContext;
|
|
@@ -49,7 +49,7 @@ var _remarkSlug = _interopRequireDefault(require("remark-slug"));
|
|
|
49
49
|
|
|
50
50
|
var _remarkExternalLinks = _interopRequireDefault(require("remark-external-links"));
|
|
51
51
|
|
|
52
|
-
var
|
|
52
|
+
var _global = _interopRequireDefault(require("global"));
|
|
53
53
|
|
|
54
54
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
55
55
|
|
|
@@ -69,6 +69,11 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
69
69
|
|
|
70
70
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
71
71
|
|
|
72
|
+
var _console = console,
|
|
73
|
+
log = _console.log; // for frameworks that are not working with react, we need to configure
|
|
74
|
+
// the jsx to transpile mdx, for now there will be a flag for that
|
|
75
|
+
// for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
|
|
76
|
+
|
|
72
77
|
function createBabelOptions(_ref) {
|
|
73
78
|
var babelOptions = _ref.babelOptions,
|
|
74
79
|
mdxBabelOptions = _ref.mdxBabelOptions,
|
|
@@ -94,6 +99,8 @@ function webpack() {
|
|
|
94
99
|
|
|
95
100
|
function _webpack() {
|
|
96
101
|
_webpack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
102
|
+
var _global$FEATURES, _global$FEATURES2;
|
|
103
|
+
|
|
97
104
|
var webpackConfig,
|
|
98
105
|
options,
|
|
99
106
|
_yield$options$preset,
|
|
@@ -112,6 +119,8 @@ function _webpack() {
|
|
|
112
119
|
_options$transcludeMa,
|
|
113
120
|
transcludeMarkdown,
|
|
114
121
|
mdxLoaderOptions,
|
|
122
|
+
mdxVersion,
|
|
123
|
+
mdxLoader,
|
|
115
124
|
sourceLoader,
|
|
116
125
|
rules,
|
|
117
126
|
result,
|
|
@@ -132,7 +141,7 @@ function _webpack() {
|
|
|
132
141
|
builder = _yield$options$preset2 === void 0 ? 'webpack4' : _yield$options$preset2;
|
|
133
142
|
builderName = typeof builder === 'string' ? builder : builder.name;
|
|
134
143
|
resolvedBabelLoader = require.resolve('babel-loader', {
|
|
135
|
-
paths: builderName.match(
|
|
144
|
+
paths: builderName.match(/^webpack(4|5)$/) ? [require.resolve("@storybook/builder-".concat(builderName))] : [builderName]
|
|
136
145
|
});
|
|
137
146
|
_webpackConfig$module = webpackConfig.module, module = _webpackConfig$module === void 0 ? {} : _webpackConfig$module; // it will reuse babel options that are already in use in storybook
|
|
138
147
|
// also, these babel options are chained with other presets.
|
|
@@ -141,8 +150,12 @@ function _webpack() {
|
|
|
141
150
|
injectStoryParameters: true
|
|
142
151
|
} : _options$sourceLoader, _options$transcludeMa = options.transcludeMarkdown, transcludeMarkdown = _options$transcludeMa === void 0 ? false : _options$transcludeMa;
|
|
143
152
|
mdxLoaderOptions = {
|
|
153
|
+
skipCsf: true,
|
|
144
154
|
remarkPlugins: [_remarkSlug.default, _remarkExternalLinks.default]
|
|
145
|
-
};
|
|
155
|
+
};
|
|
156
|
+
mdxVersion = (_global$FEATURES = _global.default.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.previewMdx2 ? 'MDX2' : 'MDX1';
|
|
157
|
+
log("Addon-docs: using ".concat(mdxVersion));
|
|
158
|
+
mdxLoader = (_global$FEATURES2 = _global.default.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.previewMdx2 ? require.resolve('@storybook/mdx2-csf/loader') : require.resolve('@storybook/mdx1-csf/loader'); // set `sourceLoaderOptions` to `null` to disable for manual configuration
|
|
146
159
|
|
|
147
160
|
sourceLoader = sourceLoaderOptions ? [{
|
|
148
161
|
test: /\.(stories|story)\.[tj]sx?$/,
|
|
@@ -169,7 +182,7 @@ function _webpack() {
|
|
|
169
182
|
configureJSX: configureJSX
|
|
170
183
|
})
|
|
171
184
|
}, {
|
|
172
|
-
loader:
|
|
185
|
+
loader: mdxLoader,
|
|
173
186
|
options: mdxLoaderOptions
|
|
174
187
|
}]
|
|
175
188
|
}]);
|
|
@@ -198,10 +211,7 @@ function _webpack() {
|
|
|
198
211
|
configureJSX: configureJSX
|
|
199
212
|
})
|
|
200
213
|
}, {
|
|
201
|
-
loader:
|
|
202
|
-
options: Object.assign({
|
|
203
|
-
compilers: [(0, _mdx.createCompiler)(options)]
|
|
204
|
-
}, mdxLoaderOptions)
|
|
214
|
+
loader: mdxLoader
|
|
205
215
|
}]
|
|
206
216
|
}, {
|
|
207
217
|
test: /\.mdx$/,
|
|
@@ -214,7 +224,7 @@ function _webpack() {
|
|
|
214
224
|
configureJSX: configureJSX
|
|
215
225
|
})
|
|
216
226
|
}, {
|
|
217
|
-
loader:
|
|
227
|
+
loader: mdxLoader,
|
|
218
228
|
options: mdxLoaderOptions
|
|
219
229
|
}]
|
|
220
230
|
}], sourceLoader)
|
|
@@ -222,7 +232,7 @@ function _webpack() {
|
|
|
222
232
|
});
|
|
223
233
|
return _context.abrupt("return", result);
|
|
224
234
|
|
|
225
|
-
case
|
|
235
|
+
case 20:
|
|
226
236
|
case "end":
|
|
227
237
|
return _context.stop();
|
|
228
238
|
}
|
|
@@ -9,6 +9,10 @@ require("core-js/modules/es.function.name.js");
|
|
|
9
9
|
|
|
10
10
|
require("core-js/modules/es.array.map.js");
|
|
11
11
|
|
|
12
|
+
require("core-js/modules/es.number.is-nan.js");
|
|
13
|
+
|
|
14
|
+
require("core-js/modules/es.number.constructor.js");
|
|
15
|
+
|
|
12
16
|
require("core-js/modules/es.object.assign.js");
|
|
13
17
|
|
|
14
18
|
require("core-js/modules/es.regexp.exec.js");
|
|
@@ -38,7 +42,8 @@ var convert = function convert(type) {
|
|
|
38
42
|
case 'enum':
|
|
39
43
|
{
|
|
40
44
|
var _values = computed ? value : value.map(function (v) {
|
|
41
|
-
|
|
45
|
+
var trimmedValue = (0, _utils.trimQuotes)(v.value);
|
|
46
|
+
return (0, _utils.includesQuotes)(v.value) || Number.isNaN(Number(trimmedValue)) ? trimmedValue : Number(trimmedValue);
|
|
42
47
|
});
|
|
43
48
|
|
|
44
49
|
return Object.assign({}, base, {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.trimQuotes = void 0;
|
|
6
|
+
exports.trimQuotes = exports.includesQuotes = void 0;
|
|
7
7
|
|
|
8
8
|
require("core-js/modules/es.regexp.exec.js");
|
|
9
9
|
|
|
@@ -15,4 +15,10 @@ var trimQuotes = function trimQuotes(str) {
|
|
|
15
15
|
return str.replace(QUOTE_REGEX, '');
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
exports.trimQuotes = trimQuotes;
|
|
18
|
+
exports.trimQuotes = trimQuotes;
|
|
19
|
+
|
|
20
|
+
var includesQuotes = function includesQuotes(str) {
|
|
21
|
+
return QUOTE_REGEX.test(str);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.includesQuotes = includesQuotes;
|
|
@@ -8,9 +8,9 @@ import { window as globalWindow } from 'global';
|
|
|
8
8
|
// This was specifically a problem with the Vite builder.
|
|
9
9
|
|
|
10
10
|
/* eslint-disable no-underscore-dangle */
|
|
11
|
-
if (globalWindow.__DOCS_CONTEXT__ === undefined) {
|
|
11
|
+
if (globalWindow && globalWindow.__DOCS_CONTEXT__ === undefined) {
|
|
12
12
|
globalWindow.__DOCS_CONTEXT__ = /*#__PURE__*/createContext({});
|
|
13
13
|
globalWindow.__DOCS_CONTEXT__.displayName = 'DocsContext';
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export var DocsContext = globalWindow.__DOCS_CONTEXT__;
|
|
16
|
+
export var DocsContext = globalWindow ? globalWindow.__DOCS_CONTEXT__ : /*#__PURE__*/createContext({});
|
|
@@ -37,9 +37,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
37
37
|
|
|
38
38
|
import path from 'path';
|
|
39
39
|
import remarkSlug from 'remark-slug';
|
|
40
|
-
import remarkExternalLinks from 'remark-external-links';
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
import remarkExternalLinks from 'remark-external-links';
|
|
41
|
+
import global from 'global';
|
|
42
|
+
var _console = console,
|
|
43
|
+
log = _console.log; // for frameworks that are not working with react, we need to configure
|
|
44
|
+
// the jsx to transpile mdx, for now there will be a flag for that
|
|
45
|
+
// for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
|
|
43
46
|
|
|
44
47
|
function createBabelOptions(_ref) {
|
|
45
48
|
var babelOptions = _ref.babelOptions,
|
|
@@ -66,6 +69,8 @@ export function webpack() {
|
|
|
66
69
|
|
|
67
70
|
function _webpack() {
|
|
68
71
|
_webpack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
72
|
+
var _global$FEATURES, _global$FEATURES2;
|
|
73
|
+
|
|
69
74
|
var webpackConfig,
|
|
70
75
|
options,
|
|
71
76
|
_yield$options$preset,
|
|
@@ -84,6 +89,8 @@ function _webpack() {
|
|
|
84
89
|
_options$transcludeMa,
|
|
85
90
|
transcludeMarkdown,
|
|
86
91
|
mdxLoaderOptions,
|
|
92
|
+
mdxVersion,
|
|
93
|
+
mdxLoader,
|
|
87
94
|
sourceLoader,
|
|
88
95
|
rules,
|
|
89
96
|
result,
|
|
@@ -104,7 +111,7 @@ function _webpack() {
|
|
|
104
111
|
builder = _yield$options$preset2 === void 0 ? 'webpack4' : _yield$options$preset2;
|
|
105
112
|
builderName = typeof builder === 'string' ? builder : builder.name;
|
|
106
113
|
resolvedBabelLoader = require.resolve('babel-loader', {
|
|
107
|
-
paths: builderName.match(
|
|
114
|
+
paths: builderName.match(/^webpack(4|5)$/) ? [require.resolve("@storybook/builder-".concat(builderName))] : [builderName]
|
|
108
115
|
});
|
|
109
116
|
_webpackConfig$module = webpackConfig.module, module = _webpackConfig$module === void 0 ? {} : _webpackConfig$module; // it will reuse babel options that are already in use in storybook
|
|
110
117
|
// also, these babel options are chained with other presets.
|
|
@@ -113,8 +120,12 @@ function _webpack() {
|
|
|
113
120
|
injectStoryParameters: true
|
|
114
121
|
} : _options$sourceLoader, _options$transcludeMa = options.transcludeMarkdown, transcludeMarkdown = _options$transcludeMa === void 0 ? false : _options$transcludeMa;
|
|
115
122
|
mdxLoaderOptions = {
|
|
123
|
+
skipCsf: true,
|
|
116
124
|
remarkPlugins: [remarkSlug, remarkExternalLinks]
|
|
117
|
-
};
|
|
125
|
+
};
|
|
126
|
+
mdxVersion = (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.previewMdx2 ? 'MDX2' : 'MDX1';
|
|
127
|
+
log("Addon-docs: using ".concat(mdxVersion));
|
|
128
|
+
mdxLoader = (_global$FEATURES2 = global.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.previewMdx2 ? require.resolve('@storybook/mdx2-csf/loader') : require.resolve('@storybook/mdx1-csf/loader'); // set `sourceLoaderOptions` to `null` to disable for manual configuration
|
|
118
129
|
|
|
119
130
|
sourceLoader = sourceLoaderOptions ? [{
|
|
120
131
|
test: /\.(stories|story)\.[tj]sx?$/,
|
|
@@ -141,7 +152,7 @@ function _webpack() {
|
|
|
141
152
|
configureJSX: configureJSX
|
|
142
153
|
})
|
|
143
154
|
}, {
|
|
144
|
-
loader:
|
|
155
|
+
loader: mdxLoader,
|
|
145
156
|
options: mdxLoaderOptions
|
|
146
157
|
}]
|
|
147
158
|
}]);
|
|
@@ -170,10 +181,7 @@ function _webpack() {
|
|
|
170
181
|
configureJSX: configureJSX
|
|
171
182
|
})
|
|
172
183
|
}, {
|
|
173
|
-
loader:
|
|
174
|
-
options: Object.assign({
|
|
175
|
-
compilers: [createCompiler(options)]
|
|
176
|
-
}, mdxLoaderOptions)
|
|
184
|
+
loader: mdxLoader
|
|
177
185
|
}]
|
|
178
186
|
}, {
|
|
179
187
|
test: /\.mdx$/,
|
|
@@ -186,7 +194,7 @@ function _webpack() {
|
|
|
186
194
|
configureJSX: configureJSX
|
|
187
195
|
})
|
|
188
196
|
}, {
|
|
189
|
-
loader:
|
|
197
|
+
loader: mdxLoader,
|
|
190
198
|
options: mdxLoaderOptions
|
|
191
199
|
}]
|
|
192
200
|
}], sourceLoader)
|
|
@@ -194,7 +202,7 @@ function _webpack() {
|
|
|
194
202
|
});
|
|
195
203
|
return _context.abrupt("return", result);
|
|
196
204
|
|
|
197
|
-
case
|
|
205
|
+
case 20:
|
|
198
206
|
case "end":
|
|
199
207
|
return _context.stop();
|
|
200
208
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "core-js/modules/es.function.name.js";
|
|
2
2
|
import "core-js/modules/es.array.map.js";
|
|
3
|
+
import "core-js/modules/es.number.is-nan.js";
|
|
4
|
+
import "core-js/modules/es.number.constructor.js";
|
|
3
5
|
import "core-js/modules/es.object.assign.js";
|
|
4
6
|
import "core-js/modules/es.regexp.exec.js";
|
|
5
7
|
import "core-js/modules/es.string.split.js";
|
|
@@ -7,7 +9,7 @@ import "core-js/modules/es.array.concat.js";
|
|
|
7
9
|
|
|
8
10
|
/* eslint-disable no-case-declarations */
|
|
9
11
|
import mapValues from 'lodash/mapValues';
|
|
10
|
-
import { trimQuotes } from '../utils';
|
|
12
|
+
import { includesQuotes, trimQuotes } from '../utils';
|
|
11
13
|
var SIGNATURE_REGEXP = /^\(.*\) => /;
|
|
12
14
|
export var convert = function convert(type) {
|
|
13
15
|
var name = type.name,
|
|
@@ -21,7 +23,8 @@ export var convert = function convert(type) {
|
|
|
21
23
|
case 'enum':
|
|
22
24
|
{
|
|
23
25
|
var _values = computed ? value : value.map(function (v) {
|
|
24
|
-
|
|
26
|
+
var trimmedValue = trimQuotes(v.value);
|
|
27
|
+
return includesQuotes(v.value) || Number.isNaN(Number(trimmedValue)) ? trimmedValue : Number(trimmedValue);
|
|
25
28
|
});
|
|
26
29
|
|
|
27
30
|
return Object.assign({}, base, {
|
|
@@ -3,4 +3,7 @@ import "core-js/modules/es.string.replace.js";
|
|
|
3
3
|
var QUOTE_REGEX = /^['"]|['"]$/g;
|
|
4
4
|
export var trimQuotes = function trimQuotes(str) {
|
|
5
5
|
return str.replace(QUOTE_REGEX, '');
|
|
6
|
+
};
|
|
7
|
+
export var includesQuotes = function includesQuotes(str) {
|
|
8
|
+
return QUOTE_REGEX.test(str);
|
|
6
9
|
};
|
|
@@ -8,9 +8,9 @@ import { window as globalWindow } from 'global';
|
|
|
8
8
|
// This was specifically a problem with the Vite builder.
|
|
9
9
|
|
|
10
10
|
/* eslint-disable no-underscore-dangle */
|
|
11
|
-
if (globalWindow.__DOCS_CONTEXT__ === undefined) {
|
|
11
|
+
if (globalWindow && globalWindow.__DOCS_CONTEXT__ === undefined) {
|
|
12
12
|
globalWindow.__DOCS_CONTEXT__ = /*#__PURE__*/createContext({});
|
|
13
13
|
globalWindow.__DOCS_CONTEXT__.displayName = 'DocsContext';
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const DocsContext = globalWindow.__DOCS_CONTEXT__;
|
|
16
|
+
export const DocsContext = globalWindow ? globalWindow.__DOCS_CONTEXT__ : /*#__PURE__*/createContext({});
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import remarkSlug from 'remark-slug';
|
|
3
|
-
import remarkExternalLinks from 'remark-external-links';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import remarkExternalLinks from 'remark-external-links';
|
|
4
|
+
import global from 'global';
|
|
5
|
+
const {
|
|
6
|
+
log
|
|
7
|
+
} = console; // for frameworks that are not working with react, we need to configure
|
|
8
|
+
// the jsx to transpile mdx, for now there will be a flag for that
|
|
9
|
+
// for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
|
|
6
10
|
|
|
7
11
|
function createBabelOptions({
|
|
8
12
|
babelOptions,
|
|
@@ -25,13 +29,15 @@ function createBabelOptions({
|
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
export async function webpack(webpackConfig = {}, options) {
|
|
32
|
+
var _global$FEATURES, _global$FEATURES2;
|
|
33
|
+
|
|
28
34
|
const {
|
|
29
35
|
builder = 'webpack4'
|
|
30
36
|
} = await options.presets.apply('core', {});
|
|
31
37
|
const builderName = typeof builder === 'string' ? builder : builder.name;
|
|
32
38
|
|
|
33
39
|
const resolvedBabelLoader = require.resolve('babel-loader', {
|
|
34
|
-
paths: builderName.match(
|
|
40
|
+
paths: builderName.match(/^webpack(4|5)$/) ? [require.resolve(`@storybook/builder-${builderName}`)] : [builderName]
|
|
35
41
|
});
|
|
36
42
|
|
|
37
43
|
const {
|
|
@@ -49,8 +55,12 @@ export async function webpack(webpackConfig = {}, options) {
|
|
|
49
55
|
transcludeMarkdown = false
|
|
50
56
|
} = options;
|
|
51
57
|
const mdxLoaderOptions = {
|
|
58
|
+
skipCsf: true,
|
|
52
59
|
remarkPlugins: [remarkSlug, remarkExternalLinks]
|
|
53
|
-
};
|
|
60
|
+
};
|
|
61
|
+
const mdxVersion = (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.previewMdx2 ? 'MDX2' : 'MDX1';
|
|
62
|
+
log(`Addon-docs: using ${mdxVersion}`);
|
|
63
|
+
const mdxLoader = (_global$FEATURES2 = global.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.previewMdx2 ? require.resolve('@storybook/mdx2-csf/loader') : require.resolve('@storybook/mdx1-csf/loader'); // set `sourceLoaderOptions` to `null` to disable for manual configuration
|
|
54
64
|
|
|
55
65
|
const sourceLoader = sourceLoaderOptions ? [{
|
|
56
66
|
test: /\.(stories|story)\.[tj]sx?$/,
|
|
@@ -77,7 +87,7 @@ export async function webpack(webpackConfig = {}, options) {
|
|
|
77
87
|
configureJSX
|
|
78
88
|
})
|
|
79
89
|
}, {
|
|
80
|
-
loader:
|
|
90
|
+
loader: mdxLoader,
|
|
81
91
|
options: mdxLoaderOptions
|
|
82
92
|
}]
|
|
83
93
|
}];
|
|
@@ -106,10 +116,7 @@ export async function webpack(webpackConfig = {}, options) {
|
|
|
106
116
|
configureJSX
|
|
107
117
|
})
|
|
108
118
|
}, {
|
|
109
|
-
loader:
|
|
110
|
-
options: Object.assign({
|
|
111
|
-
compilers: [createCompiler(options)]
|
|
112
|
-
}, mdxLoaderOptions)
|
|
119
|
+
loader: mdxLoader
|
|
113
120
|
}]
|
|
114
121
|
}, {
|
|
115
122
|
test: /\.mdx$/,
|
|
@@ -122,7 +129,7 @@ export async function webpack(webpackConfig = {}, options) {
|
|
|
122
129
|
configureJSX
|
|
123
130
|
})
|
|
124
131
|
}, {
|
|
125
|
-
loader:
|
|
132
|
+
loader: mdxLoader,
|
|
126
133
|
options: mdxLoaderOptions
|
|
127
134
|
}]
|
|
128
135
|
}, ...sourceLoader]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-case-declarations */
|
|
2
2
|
import mapValues from 'lodash/mapValues';
|
|
3
|
-
import { trimQuotes } from '../utils';
|
|
3
|
+
import { includesQuotes, trimQuotes } from '../utils';
|
|
4
4
|
const SIGNATURE_REGEXP = /^\(.*\) => /;
|
|
5
5
|
export const convert = type => {
|
|
6
6
|
const {
|
|
@@ -15,7 +15,10 @@ export const convert = type => {
|
|
|
15
15
|
switch (name) {
|
|
16
16
|
case 'enum':
|
|
17
17
|
{
|
|
18
|
-
const values = computed ? value : value.map(v =>
|
|
18
|
+
const values = computed ? value : value.map(v => {
|
|
19
|
+
const trimmedValue = trimQuotes(v.value);
|
|
20
|
+
return includesQuotes(v.value) || Number.isNaN(Number(trimmedValue)) ? trimmedValue : Number(trimmedValue);
|
|
21
|
+
});
|
|
19
22
|
return Object.assign({}, base, {
|
|
20
23
|
name,
|
|
21
24
|
value: values
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createCompiler } from '@storybook/csf-tools/mdx';
|
|
2
1
|
import { Options } from '@storybook/core-common';
|
|
3
2
|
declare type BabelParams = {
|
|
4
3
|
babelOptions?: any;
|
|
@@ -8,5 +7,5 @@ declare type BabelParams = {
|
|
|
8
7
|
export declare function webpack(webpackConfig: any, options: Options & BabelParams & {
|
|
9
8
|
sourceLoaderOptions: any;
|
|
10
9
|
transcludeMarkdown: boolean;
|
|
11
|
-
}
|
|
10
|
+
}): Promise<any>;
|
|
12
11
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createCompiler } from '@storybook/csf-tools/mdx';
|
|
2
1
|
import type { Options } from '@storybook/core-common';
|
|
3
2
|
declare type BabelParams = {
|
|
4
3
|
babelOptions?: any;
|
|
@@ -8,5 +7,5 @@ declare type BabelParams = {
|
|
|
8
7
|
export declare function webpack(webpackConfig: any, options: Options & BabelParams & {
|
|
9
8
|
sourceLoaderOptions: any;
|
|
10
9
|
transcludeMarkdown: boolean;
|
|
11
|
-
}
|
|
10
|
+
}): Promise<any>;
|
|
12
11
|
export {};
|
package/jest-transform-mdx.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const mdx = require('@mdx-js/mdx');
|
|
3
2
|
const { ScriptTransformer } = require('@jest/transform');
|
|
4
3
|
const { dedent } = require('ts-dedent');
|
|
5
4
|
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
const compilers = [createCompiler({})];
|
|
5
|
+
const { compileSync } = require('@storybook/mdx1-csf');
|
|
9
6
|
|
|
10
7
|
module.exports = {
|
|
11
8
|
process(src, filename, config, { instrument }) {
|
|
@@ -13,7 +10,7 @@ module.exports = {
|
|
|
13
10
|
/* @jsx mdx */
|
|
14
11
|
import React from 'react'
|
|
15
12
|
import { mdx } from '@mdx-js/react'
|
|
16
|
-
${
|
|
13
|
+
${compileSync(src, { filepath: filename })}
|
|
17
14
|
`;
|
|
18
15
|
|
|
19
16
|
const extension = path.extname(filename);
|
package/mdx-compiler-plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('@storybook/csf
|
|
1
|
+
module.exports = require('@storybook/mdx1-csf').createCompiler;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-docs",
|
|
3
|
-
"version": "6.5.0-alpha.
|
|
3
|
+
"version": "6.5.0-alpha.43",
|
|
4
4
|
"description": "Document component usage and properties in Markdown",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -61,24 +61,23 @@
|
|
|
61
61
|
"@babel/plugin-transform-react-jsx": "^7.12.12",
|
|
62
62
|
"@babel/preset-env": "^7.12.11",
|
|
63
63
|
"@jest/transform": "^26.6.2",
|
|
64
|
-
"@mdx-js/loader": "^1.6.22",
|
|
65
|
-
"@mdx-js/mdx": "^1.6.22",
|
|
66
64
|
"@mdx-js/react": "^1.6.22",
|
|
67
|
-
"@storybook/addons": "6.5.0-alpha.
|
|
68
|
-
"@storybook/api": "6.5.0-alpha.
|
|
69
|
-
"@storybook/builder-webpack4": "6.5.0-alpha.
|
|
70
|
-
"@storybook/client-logger": "6.5.0-alpha.
|
|
71
|
-
"@storybook/components": "6.5.0-alpha.
|
|
72
|
-
"@storybook/core": "6.5.0-alpha.
|
|
73
|
-
"@storybook/core-events": "6.5.0-alpha.
|
|
65
|
+
"@storybook/addons": "6.5.0-alpha.43",
|
|
66
|
+
"@storybook/api": "6.5.0-alpha.43",
|
|
67
|
+
"@storybook/builder-webpack4": "6.5.0-alpha.43",
|
|
68
|
+
"@storybook/client-logger": "6.5.0-alpha.43",
|
|
69
|
+
"@storybook/components": "6.5.0-alpha.43",
|
|
70
|
+
"@storybook/core": "6.5.0-alpha.43",
|
|
71
|
+
"@storybook/core-events": "6.5.0-alpha.43",
|
|
74
72
|
"@storybook/csf": "0.0.2--canary.87bc651.0",
|
|
75
|
-
"@storybook/csf-tools": "6.5.0-alpha.
|
|
76
|
-
"@storybook/
|
|
77
|
-
"@storybook/
|
|
78
|
-
"@storybook/
|
|
79
|
-
"@storybook/
|
|
80
|
-
"@storybook/
|
|
81
|
-
"@storybook/
|
|
73
|
+
"@storybook/csf-tools": "6.5.0-alpha.43",
|
|
74
|
+
"@storybook/mdx1-csf": "0.0.1-canary.1.0025c94.0",
|
|
75
|
+
"@storybook/node-logger": "6.5.0-alpha.43",
|
|
76
|
+
"@storybook/postinstall": "6.5.0-alpha.43",
|
|
77
|
+
"@storybook/preview-web": "6.5.0-alpha.43",
|
|
78
|
+
"@storybook/source-loader": "6.5.0-alpha.43",
|
|
79
|
+
"@storybook/store": "6.5.0-alpha.43",
|
|
80
|
+
"@storybook/theming": "6.5.0-alpha.43",
|
|
82
81
|
"acorn": "^7.4.1",
|
|
83
82
|
"acorn-jsx": "^5.3.1",
|
|
84
83
|
"acorn-walk": "^7.2.0",
|
|
@@ -88,7 +87,6 @@
|
|
|
88
87
|
"fast-deep-equal": "^3.1.3",
|
|
89
88
|
"global": "^4.4.0",
|
|
90
89
|
"html-tags": "^3.1.0",
|
|
91
|
-
"js-string-escape": "^1.0.1",
|
|
92
90
|
"loader-utils": "^2.0.0",
|
|
93
91
|
"lodash": "^4.17.21",
|
|
94
92
|
"nanoid": "^3.1.23",
|
|
@@ -107,16 +105,15 @@
|
|
|
107
105
|
"@babel/core": "^7.12.10",
|
|
108
106
|
"@emotion/core": "^10.3.1",
|
|
109
107
|
"@emotion/styled": "^10.0.27",
|
|
110
|
-
"@storybook/angular": "6.5.0-alpha.
|
|
111
|
-
"@storybook/html": "6.5.0-alpha.
|
|
112
|
-
"@storybook/
|
|
113
|
-
"@storybook/
|
|
114
|
-
"@storybook/
|
|
108
|
+
"@storybook/angular": "6.5.0-alpha.43",
|
|
109
|
+
"@storybook/html": "6.5.0-alpha.43",
|
|
110
|
+
"@storybook/mdx2-csf": "0.0.1-canary.1.357011b.0",
|
|
111
|
+
"@storybook/react": "6.5.0-alpha.43",
|
|
112
|
+
"@storybook/vue": "6.5.0-alpha.43",
|
|
113
|
+
"@storybook/web-components": "6.5.0-alpha.43",
|
|
115
114
|
"@types/cross-spawn": "^6.0.2",
|
|
116
115
|
"@types/doctrine": "^0.0.3",
|
|
117
|
-
"@types/enzyme": "^3.10.8",
|
|
118
116
|
"@types/estree": "^0.0.44",
|
|
119
|
-
"@types/jest": "^26.0.16",
|
|
120
117
|
"@types/loader-utils": "^2.0.0",
|
|
121
118
|
"@types/prop-types": "^15.7.3",
|
|
122
119
|
"@types/tmp": "^0.2.0",
|
|
@@ -124,7 +121,6 @@
|
|
|
124
121
|
"babel-loader": "^8.0.0",
|
|
125
122
|
"babel-plugin-react-docgen": "^4.2.1",
|
|
126
123
|
"cross-spawn": "^7.0.3",
|
|
127
|
-
"fs-extra": "^9.0.1",
|
|
128
124
|
"jest": "^26.6.3",
|
|
129
125
|
"jest-specific-snapshot": "^4.0.0",
|
|
130
126
|
"lit-element": "^3.0.2",
|
|
@@ -134,12 +130,27 @@
|
|
|
134
130
|
"styled-components": "^5.2.1",
|
|
135
131
|
"sveltedoc-parser": "4.1.0",
|
|
136
132
|
"tmp": "^0.2.1",
|
|
137
|
-
"tslib": "^2.1.0",
|
|
138
133
|
"vue": "^2.6.10",
|
|
139
|
-
"web-component-analyzer": "^1.1.6",
|
|
140
134
|
"webpack": "4",
|
|
141
135
|
"zone.js": "^0.11.3"
|
|
142
136
|
},
|
|
137
|
+
"peerDependencies": {
|
|
138
|
+
"@storybook/angular": "6.5.0-alpha.43",
|
|
139
|
+
"@storybook/html": "6.5.0-alpha.43",
|
|
140
|
+
"@storybook/mdx2-csf": "0.0.1-canary.1.357011b.0",
|
|
141
|
+
"@storybook/react": "6.5.0-alpha.43",
|
|
142
|
+
"@storybook/vue": "6.5.0-alpha.43",
|
|
143
|
+
"@storybook/vue3": "6.5.0-alpha.43",
|
|
144
|
+
"@storybook/web-components": "6.5.0-alpha.43",
|
|
145
|
+
"lit": "^2.0.0",
|
|
146
|
+
"lit-html": "^1.4.1 || ^2.0.0",
|
|
147
|
+
"react": "^16.8.0 || ^17.0.0",
|
|
148
|
+
"react-dom": "^16.8.0 || ^17.0.0",
|
|
149
|
+
"svelte": "^3.31.2",
|
|
150
|
+
"sveltedoc-parser": "^4.1.0",
|
|
151
|
+
"vue": "^2.6.10 || ^3.0.0",
|
|
152
|
+
"webpack": "*"
|
|
153
|
+
},
|
|
143
154
|
"peerDependenciesMeta": {
|
|
144
155
|
"@storybook/angular": {
|
|
145
156
|
"optional": true
|
|
@@ -159,6 +170,9 @@
|
|
|
159
170
|
"@storybook/manager-webpack5": {
|
|
160
171
|
"optional": true
|
|
161
172
|
},
|
|
173
|
+
"@storybook/mdx2-csf": {
|
|
174
|
+
"optional": true
|
|
175
|
+
},
|
|
162
176
|
"@storybook/react": {
|
|
163
177
|
"optional": true
|
|
164
178
|
},
|
|
@@ -199,7 +213,7 @@
|
|
|
199
213
|
"publishConfig": {
|
|
200
214
|
"access": "public"
|
|
201
215
|
},
|
|
202
|
-
"gitHead": "
|
|
216
|
+
"gitHead": "62e538940658869e62dc852f5754d55a5e0fb52b",
|
|
203
217
|
"sbmodern": "dist/modern/index.js",
|
|
204
218
|
"storybook": {
|
|
205
219
|
"displayName": "Docs",
|