@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.
Files changed (160) hide show
  1. package/blocks.d.ts +1 -1
  2. package/dist/cjs/blocks/Anchor.js +7 -10
  3. package/dist/cjs/blocks/ArgsTable.js +135 -206
  4. package/dist/cjs/blocks/Canvas.js +38 -73
  5. package/dist/cjs/blocks/Description.js +41 -68
  6. package/dist/cjs/blocks/DocsContainer.js +40 -68
  7. package/dist/cjs/blocks/DocsContext.js +1 -1
  8. package/dist/cjs/blocks/DocsPage.js +3 -5
  9. package/dist/cjs/blocks/DocsStory.js +18 -28
  10. package/dist/cjs/blocks/Heading.js +5 -9
  11. package/dist/cjs/blocks/Meta.js +11 -33
  12. package/dist/cjs/blocks/Preview.js +4 -10
  13. package/dist/cjs/blocks/Primary.js +12 -40
  14. package/dist/cjs/blocks/Props.js +4 -10
  15. package/dist/cjs/blocks/Source.js +62 -80
  16. package/dist/cjs/blocks/SourceContainer.js +19 -68
  17. package/dist/cjs/blocks/Stories.js +17 -48
  18. package/dist/cjs/blocks/Story.js +60 -180
  19. package/dist/cjs/blocks/Subheading.js +5 -9
  20. package/dist/cjs/blocks/Subtitle.js +15 -35
  21. package/dist/cjs/blocks/Title.js +12 -36
  22. package/dist/cjs/blocks/Wrapper.js +7 -8
  23. package/dist/cjs/blocks/enhanceSource.js +30 -67
  24. package/dist/cjs/blocks/index.js +28 -34
  25. package/dist/cjs/blocks/mdx.js +86 -97
  26. package/dist/cjs/blocks/types.js +2 -2
  27. package/dist/cjs/blocks/useStory.js +16 -87
  28. package/dist/cjs/blocks/utils.js +4 -25
  29. package/dist/cjs/index.js +1 -7
  30. package/dist/cjs/manager.js +9 -15
  31. package/dist/cjs/preset.js +129 -193
  32. package/dist/cjs/preview.js +5 -87
  33. package/dist/cjs/shared.js +5 -5
  34. package/dist/esm/blocks/Anchor.js +7 -10
  35. package/dist/esm/blocks/ArgsTable.js +133 -182
  36. package/dist/esm/blocks/Canvas.js +34 -46
  37. package/dist/esm/blocks/Description.js +39 -45
  38. package/dist/esm/blocks/DocsContainer.js +36 -44
  39. package/dist/esm/blocks/DocsContext.js +1 -1
  40. package/dist/esm/blocks/DocsPage.js +3 -5
  41. package/dist/esm/blocks/DocsStory.js +18 -27
  42. package/dist/esm/blocks/Heading.js +5 -7
  43. package/dist/esm/blocks/Meta.js +9 -13
  44. package/dist/esm/blocks/Preview.js +5 -10
  45. package/dist/esm/blocks/Primary.js +10 -16
  46. package/dist/esm/blocks/Props.js +5 -10
  47. package/dist/esm/blocks/Source.js +64 -70
  48. package/dist/esm/blocks/SourceContainer.js +17 -50
  49. package/dist/esm/blocks/Stories.js +15 -27
  50. package/dist/esm/blocks/Story.js +58 -151
  51. package/dist/esm/blocks/Subheading.js +5 -7
  52. package/dist/esm/blocks/Subtitle.js +12 -12
  53. package/dist/esm/blocks/Title.js +10 -11
  54. package/dist/esm/blocks/Wrapper.js +7 -8
  55. package/dist/esm/blocks/enhanceSource.js +32 -56
  56. package/dist/esm/blocks/mdx.js +85 -89
  57. package/dist/esm/blocks/types.js +2 -2
  58. package/dist/esm/blocks/useStory.js +16 -73
  59. package/dist/esm/blocks/utils.js +4 -18
  60. package/dist/esm/manager.js +9 -14
  61. package/dist/esm/preset.js +114 -179
  62. package/dist/esm/preview.js +3 -61
  63. package/dist/esm/shared.js +5 -5
  64. package/dist/{ts3.9 → types}/blocks/Anchor.d.ts +0 -0
  65. package/dist/{ts3.9 → types}/blocks/ArgsTable.d.ts +0 -0
  66. package/dist/{ts3.9 → types}/blocks/Canvas.d.ts +0 -0
  67. package/dist/{ts3.9 → types}/blocks/Description.d.ts +0 -0
  68. package/dist/{ts3.9 → types}/blocks/DocsContainer.d.ts +0 -0
  69. package/dist/{ts3.9 → types}/blocks/DocsContext.d.ts +0 -0
  70. package/dist/{ts3.9 → types}/blocks/DocsPage.d.ts +0 -0
  71. package/dist/{ts3.9 → types}/blocks/DocsStory.d.ts +0 -0
  72. package/dist/{ts3.9 → types}/blocks/Heading.d.ts +0 -0
  73. package/dist/{ts3.9 → types}/blocks/Meta.d.ts +0 -0
  74. package/dist/{ts3.9 → types}/blocks/Preview.d.ts +0 -0
  75. package/dist/{ts3.9 → types}/blocks/Primary.d.ts +0 -0
  76. package/dist/{ts3.9 → types}/blocks/Props.d.ts +0 -0
  77. package/dist/{ts3.9 → types}/blocks/Source.d.ts +0 -0
  78. package/dist/{ts3.9 → types}/blocks/SourceContainer.d.ts +0 -0
  79. package/dist/{ts3.9 → types}/blocks/Stories.d.ts +0 -0
  80. package/dist/{ts3.9 → types}/blocks/Story.d.ts +2 -2
  81. package/dist/{ts3.9 → types}/blocks/Subheading.d.ts +0 -0
  82. package/dist/{ts3.9 → types}/blocks/Subtitle.d.ts +0 -0
  83. package/dist/{ts3.9 → types}/blocks/Title.d.ts +0 -0
  84. package/dist/{ts3.9 → types}/blocks/Wrapper.d.ts +0 -0
  85. package/dist/{ts3.9 → types}/blocks/enhanceSource.d.ts +0 -0
  86. package/dist/{ts3.9 → types}/blocks/index.d.ts +0 -0
  87. package/dist/{ts3.9 → types}/blocks/mdx.d.ts +0 -0
  88. package/dist/{ts3.9 → types}/blocks/types.d.ts +0 -0
  89. package/dist/{ts3.9 → types}/blocks/useStory.d.ts +0 -0
  90. package/dist/{ts3.9 → types}/blocks/utils.d.ts +0 -0
  91. package/dist/{ts3.9 → types}/index.d.ts +0 -0
  92. package/dist/{ts3.9 → types}/manager.d.ts +0 -0
  93. package/dist/{ts3.9 → types}/preset.d.ts +2 -1
  94. package/dist/{ts3.9 → types}/preview.d.ts +0 -0
  95. package/dist/{ts3.9 → types}/shared.d.ts +0 -0
  96. package/package.json +17 -24
  97. package/dist/modern/blocks/Anchor.js +0 -8
  98. package/dist/modern/blocks/ArgsTable.js +0 -292
  99. package/dist/modern/blocks/Canvas.js +0 -83
  100. package/dist/modern/blocks/Description.js +0 -107
  101. package/dist/modern/blocks/DocsContainer.js +0 -98
  102. package/dist/modern/blocks/DocsContext.js +0 -16
  103. package/dist/modern/blocks/DocsPage.js +0 -11
  104. package/dist/modern/blocks/DocsStory.js +0 -48
  105. package/dist/modern/blocks/Heading.js +0 -17
  106. package/dist/modern/blocks/Meta.js +0 -31
  107. package/dist/modern/blocks/Preview.js +0 -9
  108. package/dist/modern/blocks/Primary.js +0 -23
  109. package/dist/modern/blocks/Props.js +0 -14
  110. package/dist/modern/blocks/Source.js +0 -154
  111. package/dist/modern/blocks/SourceContainer.js +0 -44
  112. package/dist/modern/blocks/Stories.js +0 -34
  113. package/dist/modern/blocks/Story.js +0 -168
  114. package/dist/modern/blocks/Subheading.js +0 -17
  115. package/dist/modern/blocks/Subtitle.js +0 -23
  116. package/dist/modern/blocks/Title.js +0 -24
  117. package/dist/modern/blocks/Wrapper.js +0 -8
  118. package/dist/modern/blocks/enhanceSource.js +0 -89
  119. package/dist/modern/blocks/index.js +0 -24
  120. package/dist/modern/blocks/mdx.js +0 -204
  121. package/dist/modern/blocks/types.js +0 -2
  122. package/dist/modern/blocks/useStory.js +0 -28
  123. package/dist/modern/blocks/utils.js +0 -29
  124. package/dist/modern/index.js +0 -1
  125. package/dist/modern/manager.js +0 -16
  126. package/dist/modern/preset.js +0 -130
  127. package/dist/modern/preview.js +0 -6
  128. package/dist/modern/shared.js +0 -11
  129. package/dist/ts3.4/blocks/Anchor.d.ts +0 -6
  130. package/dist/ts3.4/blocks/ArgsTable.d.ts +0 -33
  131. package/dist/ts3.4/blocks/Canvas.d.ts +0 -9
  132. package/dist/ts3.4/blocks/Description.d.ts +0 -20
  133. package/dist/ts3.4/blocks/DocsContainer.d.ts +0 -7
  134. package/dist/ts3.4/blocks/DocsContext.d.ts +0 -5
  135. package/dist/ts3.4/blocks/DocsPage.d.ts +0 -2
  136. package/dist/ts3.4/blocks/DocsStory.d.ts +0 -3
  137. package/dist/ts3.4/blocks/Heading.d.ts +0 -6
  138. package/dist/ts3.4/blocks/Meta.d.ts +0 -9
  139. package/dist/ts3.4/blocks/Preview.d.ts +0 -3
  140. package/dist/ts3.4/blocks/Primary.d.ts +0 -6
  141. package/dist/ts3.4/blocks/Props.d.ts +0 -3
  142. package/dist/ts3.4/blocks/Source.d.ts +0 -38
  143. package/dist/ts3.4/blocks/SourceContainer.d.ts +0 -14
  144. package/dist/ts3.4/blocks/Stories.d.ts +0 -7
  145. package/dist/ts3.4/blocks/Story.d.ts +0 -28
  146. package/dist/ts3.4/blocks/Subheading.d.ts +0 -3
  147. package/dist/ts3.4/blocks/Subtitle.d.ts +0 -6
  148. package/dist/ts3.4/blocks/Title.d.ts +0 -8
  149. package/dist/ts3.4/blocks/Wrapper.d.ts +0 -2
  150. package/dist/ts3.4/blocks/enhanceSource.d.ts +0 -3
  151. package/dist/ts3.4/blocks/index.d.ts +0 -24
  152. package/dist/ts3.4/blocks/mdx.d.ts +0 -20
  153. package/dist/ts3.4/blocks/types.d.ts +0 -13
  154. package/dist/ts3.4/blocks/useStory.d.ts +0 -5
  155. package/dist/ts3.4/blocks/utils.d.ts +0 -3
  156. package/dist/ts3.4/index.d.ts +0 -1
  157. package/dist/ts3.4/manager.d.ts +0 -1
  158. package/dist/ts3.4/preset.d.ts +0 -11
  159. package/dist/ts3.4/preview.d.ts +0 -6
  160. package/dist/ts3.4/shared.d.ts +0 -24
@@ -1,197 +1,132 @@
1
- import "regenerator-runtime/runtime.js";
2
-
3
- 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); } }
4
-
5
- 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); }); }; }
6
-
7
- import "core-js/modules/es.array.concat.js";
8
- import "core-js/modules/es.object.assign.js";
9
- import "core-js/modules/es.array.filter.js";
10
- import "core-js/modules/es.object.to-string.js";
11
- import "core-js/modules/es.regexp.exec.js";
12
- import "core-js/modules/es.regexp.to-string.js";
13
- import "core-js/modules/es.regexp.constructor.js";
14
- import "core-js/modules/es.symbol.js";
15
- import "core-js/modules/es.symbol.description.js";
16
- import "core-js/modules/es.symbol.iterator.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.from.js";
21
- import "core-js/modules/es.array.slice.js";
22
- import "core-js/modules/es.function.name.js";
23
- import "core-js/modules/es.promise.js";
24
-
25
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
26
-
27
- 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."); }
28
-
29
- 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); }
30
-
31
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
32
-
33
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
34
-
35
- 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; }
36
-
37
- import path from 'path';
1
+ import fs from 'fs-extra';
38
2
  import remarkSlug from 'remark-slug';
39
3
  import remarkExternalLinks from 'remark-external-links';
40
4
  import global from 'global';
41
- import { logger } from '@storybook/node-logger'; // for frameworks that are not working with react, we need to configure
5
+ import { logger } from '@storybook/node-logger';
6
+ import { loadCsf } from '@storybook/csf-tools'; // for frameworks that are not working with react, we need to configure
42
7
  // the jsx to transpile mdx, for now there will be a flag for that
43
8
  // for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
44
9
 
45
- function createBabelOptions(_ref) {
46
- var babelOptions = _ref.babelOptions,
47
- mdxBabelOptions = _ref.mdxBabelOptions,
48
- configureJSX = _ref.configureJSX;
49
- var babelPlugins = (mdxBabelOptions === null || mdxBabelOptions === void 0 ? void 0 : mdxBabelOptions.plugins) || (babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) || [];
50
- var jsxPlugin = [require.resolve('@babel/plugin-transform-react-jsx'), {
10
+ function createBabelOptions({
11
+ babelOptions,
12
+ mdxBabelOptions,
13
+ configureJSX
14
+ }) {
15
+ const babelPlugins = mdxBabelOptions?.plugins || babelOptions?.plugins || [];
16
+ const jsxPlugin = [require.resolve('@babel/plugin-transform-react-jsx'), {
51
17
  pragma: 'React.createElement',
52
18
  pragmaFrag: 'React.Fragment'
53
19
  }];
54
- var plugins = configureJSX ? [].concat(_toConsumableArray(babelPlugins), [jsxPlugin]) : babelPlugins;
20
+ const plugins = configureJSX ? [...babelPlugins, jsxPlugin] : babelPlugins;
55
21
  return Object.assign({
56
22
  // don't use the root babelrc by default (users can override this in mdxBabelOptions)
57
23
  babelrc: false,
58
24
  configFile: false
59
25
  }, babelOptions, mdxBabelOptions, {
60
- plugins: plugins
26
+ plugins
61
27
  });
62
28
  }
63
29
 
64
- export function webpack() {
65
- return _webpack.apply(this, arguments);
30
+ export async function webpack(webpackConfig = {}, options) {
31
+ const resolvedBabelLoader = require.resolve('babel-loader');
32
+
33
+ const {
34
+ module = {}
35
+ } = webpackConfig; // it will reuse babel options that are already in use in storybook
36
+ // also, these babel options are chained with other presets.
37
+
38
+ const {
39
+ babelOptions,
40
+ mdxBabelOptions,
41
+ configureJSX = true,
42
+ sourceLoaderOptions = {
43
+ injectStoryParameters: true
44
+ },
45
+ transcludeMarkdown = false
46
+ } = options;
47
+ const mdxLoaderOptions = {
48
+ skipCsf: true,
49
+ remarkPlugins: [remarkSlug, remarkExternalLinks]
50
+ };
51
+ const mdxVersion = global.FEATURES?.previewMdx2 ? 'MDX2' : 'MDX1';
52
+ logger.info(`Addon-docs: using ${mdxVersion}`);
53
+ const mdxLoader = global.FEATURES?.previewMdx2 ? require.resolve('@storybook/mdx2-csf/loader') : require.resolve('@storybook/mdx1-csf/loader'); // set `sourceLoaderOptions` to `null` to disable for manual configuration
54
+
55
+ const sourceLoader = sourceLoaderOptions ? [{
56
+ test: /\.(stories|story)\.[tj]sx?$/,
57
+ loader: require.resolve('@storybook/source-loader'),
58
+ options: Object.assign({}, sourceLoaderOptions, {
59
+ inspectLocalDependencies: true
60
+ }),
61
+ enforce: 'pre'
62
+ }] : [];
63
+ let rules = module.rules || [];
64
+
65
+ if (transcludeMarkdown) {
66
+ rules = [...rules.filter(rule => rule.test?.toString() !== '/\\.md$/'), {
67
+ test: /\.md$/,
68
+ use: [{
69
+ loader: resolvedBabelLoader,
70
+ options: createBabelOptions({
71
+ babelOptions,
72
+ mdxBabelOptions,
73
+ configureJSX
74
+ })
75
+ }, {
76
+ loader: mdxLoader,
77
+ options: mdxLoaderOptions
78
+ }]
79
+ }];
80
+ }
81
+
82
+ const result = Object.assign({}, webpackConfig, {
83
+ module: Object.assign({}, module, {
84
+ rules: [...rules, {
85
+ test: /(stories|story)\.mdx$/,
86
+ use: [{
87
+ loader: resolvedBabelLoader,
88
+ options: createBabelOptions({
89
+ babelOptions,
90
+ mdxBabelOptions,
91
+ configureJSX
92
+ })
93
+ }, {
94
+ loader: mdxLoader
95
+ }]
96
+ }, {
97
+ test: /\.mdx$/,
98
+ exclude: /(stories|story)\.mdx$/,
99
+ use: [{
100
+ loader: resolvedBabelLoader,
101
+ options: createBabelOptions({
102
+ babelOptions,
103
+ mdxBabelOptions,
104
+ configureJSX
105
+ })
106
+ }, {
107
+ loader: mdxLoader,
108
+ options: mdxLoaderOptions
109
+ }]
110
+ }, ...sourceLoader]
111
+ })
112
+ });
113
+ return result;
66
114
  }
67
-
68
- function _webpack() {
69
- _webpack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
70
- var _global$FEATURES, _global$FEATURES2;
71
-
72
- var webpackConfig,
73
- options,
74
- resolvedBabelLoader,
75
- _webpackConfig$module,
76
- module,
77
- babelOptions,
78
- mdxBabelOptions,
79
- _options$configureJSX,
80
- configureJSX,
81
- _options$sourceLoader,
82
- sourceLoaderOptions,
83
- _options$transcludeMa,
84
- transcludeMarkdown,
85
- mdxLoaderOptions,
86
- mdxVersion,
87
- mdxLoader,
88
- sourceLoader,
89
- rules,
90
- result,
91
- _args = arguments;
92
-
93
- return regeneratorRuntime.wrap(function _callee$(_context) {
94
- while (1) {
95
- switch (_context.prev = _context.next) {
96
- case 0:
97
- webpackConfig = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
98
- options = _args.length > 1 ? _args[1] : undefined;
99
- resolvedBabelLoader = require.resolve('babel-loader');
100
- _webpackConfig$module = webpackConfig.module, module = _webpackConfig$module === void 0 ? {} : _webpackConfig$module; // it will reuse babel options that are already in use in storybook
101
- // also, these babel options are chained with other presets.
102
-
103
- babelOptions = options.babelOptions, mdxBabelOptions = options.mdxBabelOptions, _options$configureJSX = options.configureJSX, configureJSX = _options$configureJSX === void 0 ? true : _options$configureJSX, _options$sourceLoader = options.sourceLoaderOptions, sourceLoaderOptions = _options$sourceLoader === void 0 ? {
104
- injectStoryParameters: true
105
- } : _options$sourceLoader, _options$transcludeMa = options.transcludeMarkdown, transcludeMarkdown = _options$transcludeMa === void 0 ? false : _options$transcludeMa;
106
- mdxLoaderOptions = {
107
- skipCsf: true,
108
- remarkPlugins: [remarkSlug, remarkExternalLinks]
109
- };
110
- mdxVersion = (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.previewMdx2 ? 'MDX2' : 'MDX1';
111
- logger.info("Addon-docs: using ".concat(mdxVersion));
112
- 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
113
-
114
- sourceLoader = sourceLoaderOptions ? [{
115
- test: /\.(stories|story)\.[tj]sx?$/,
116
- loader: require.resolve('@storybook/source-loader'),
117
- options: Object.assign({}, sourceLoaderOptions, {
118
- inspectLocalDependencies: true
119
- }),
120
- enforce: 'pre'
121
- }] : [];
122
- rules = module.rules || [];
123
-
124
- if (transcludeMarkdown) {
125
- rules = [].concat(_toConsumableArray(rules.filter(function (rule) {
126
- var _rule$test;
127
-
128
- return ((_rule$test = rule.test) === null || _rule$test === void 0 ? void 0 : _rule$test.toString()) !== '/\\.md$/';
129
- })), [{
130
- test: /\.md$/,
131
- use: [{
132
- loader: resolvedBabelLoader,
133
- options: createBabelOptions({
134
- babelOptions: babelOptions,
135
- mdxBabelOptions: mdxBabelOptions,
136
- configureJSX: configureJSX
137
- })
138
- }, {
139
- loader: mdxLoader,
140
- options: mdxLoaderOptions
141
- }]
142
- }]);
143
- }
144
-
145
- result = Object.assign({}, webpackConfig, {
146
- module: Object.assign({}, module, {
147
- rules: [].concat(_toConsumableArray(rules), [{
148
- test: /\.js$/,
149
- include: new RegExp("node_modules\\".concat(path.sep, "acorn-jsx")),
150
- use: [{
151
- loader: resolvedBabelLoader,
152
- options: {
153
- presets: [[require.resolve('@babel/preset-env'), {
154
- modules: 'commonjs'
155
- }]]
156
- }
157
- }]
158
- }, {
159
- test: /(stories|story)\.mdx$/,
160
- use: [{
161
- loader: resolvedBabelLoader,
162
- options: createBabelOptions({
163
- babelOptions: babelOptions,
164
- mdxBabelOptions: mdxBabelOptions,
165
- configureJSX: configureJSX
166
- })
167
- }, {
168
- loader: mdxLoader
169
- }]
170
- }, {
171
- test: /\.mdx$/,
172
- exclude: /(stories|story)\.mdx$/,
173
- use: [{
174
- loader: resolvedBabelLoader,
175
- options: createBabelOptions({
176
- babelOptions: babelOptions,
177
- mdxBabelOptions: mdxBabelOptions,
178
- configureJSX: configureJSX
179
- })
180
- }, {
181
- loader: mdxLoader,
182
- options: mdxLoaderOptions
183
- }]
184
- }], sourceLoader)
185
- })
186
- });
187
- return _context.abrupt("return", result);
188
-
189
- case 14:
190
- case "end":
191
- return _context.stop();
192
- }
193
- }
194
- }, _callee);
195
- }));
196
- return _webpack.apply(this, arguments);
197
- }
115
+ export const storyIndexers = async indexers => {
116
+ const mdxIndexer = async (fileName, opts) => {
117
+ let code = (await fs.readFile(fileName, 'utf-8')).toString(); // @ts-ignore
118
+
119
+ const {
120
+ compile
121
+ } = global.FEATURES?.previewMdx2 ? await import('@storybook/mdx2-csf') : await import('@storybook/mdx1-csf');
122
+ code = await compile(code, {});
123
+ return loadCsf(code, Object.assign({}, opts, {
124
+ fileName
125
+ })).parse();
126
+ };
127
+
128
+ return [{
129
+ test: /(stories|story)\.mdx$/,
130
+ indexer: mdxIndexer
131
+ }, ...(indexers || [])];
132
+ };
@@ -1,64 +1,6 @@
1
- import "regenerator-runtime/runtime.js";
2
- import "core-js/modules/es.object.to-string.js";
3
- import "core-js/modules/es.promise.js";
4
-
5
- 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); } }
6
-
7
- 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); }); }; }
8
-
9
- export var parameters = {
1
+ export const parameters = {
10
2
  docs: {
11
- getContainer: function () {
12
- var _getContainer = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
13
- return regeneratorRuntime.wrap(function _callee$(_context) {
14
- while (1) {
15
- switch (_context.prev = _context.next) {
16
- case 0:
17
- _context.next = 2;
18
- return import('./blocks');
19
-
20
- case 2:
21
- return _context.abrupt("return", _context.sent.DocsContainer);
22
-
23
- case 3:
24
- case "end":
25
- return _context.stop();
26
- }
27
- }
28
- }, _callee);
29
- }));
30
-
31
- function getContainer() {
32
- return _getContainer.apply(this, arguments);
33
- }
34
-
35
- return getContainer;
36
- }(),
37
- getPage: function () {
38
- var _getPage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
39
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
40
- while (1) {
41
- switch (_context2.prev = _context2.next) {
42
- case 0:
43
- _context2.next = 2;
44
- return import('./blocks');
45
-
46
- case 2:
47
- return _context2.abrupt("return", _context2.sent.DocsPage);
48
-
49
- case 3:
50
- case "end":
51
- return _context2.stop();
52
- }
53
- }
54
- }, _callee2);
55
- }));
56
-
57
- function getPage() {
58
- return _getPage.apply(this, arguments);
59
- }
60
-
61
- return getPage;
62
- }()
3
+ getContainer: async () => (await import('./blocks')).DocsContainer,
4
+ getPage: async () => (await import('./blocks')).DocsPage
63
5
  }
64
6
  };
@@ -1,8 +1,8 @@
1
- export var ADDON_ID = 'storybook/docs';
2
- export var PANEL_ID = "".concat(ADDON_ID, "/panel");
3
- export var PARAM_KEY = "docs";
4
- export var SNIPPET_RENDERED = "".concat(ADDON_ID, "/snippet-rendered");
5
- export var SourceType;
1
+ export const ADDON_ID = 'storybook/docs';
2
+ export const PANEL_ID = `${ADDON_ID}/panel`;
3
+ export const PARAM_KEY = `docs`;
4
+ export const SNIPPET_RENDERED = `${ADDON_ID}/snippet-rendered`;
5
+ export let SourceType;
6
6
 
7
7
  (function (SourceType) {
8
8
  SourceType["AUTO"] = "auto";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,7 +1,7 @@
1
1
  import { FunctionComponent, ReactNode, ElementType, ComponentProps } from 'react';
2
2
  import { Story as PureStory } from '@storybook/components';
3
3
  import { StoryId, StoryAnnotations, AnyFramework } from '@storybook/csf';
4
- import { Story as StoryType } from '@storybook/store';
4
+ import type { Story as StoryType } from '@storybook/store';
5
5
  import { DocsContextProps } from './DocsContext';
6
6
  export declare const storyBlockIdFromId: (storyId: string) => string;
7
7
  declare type PureStoryProps = ComponentProps<typeof PureStory>;
@@ -23,6 +23,6 @@ declare type StoryImportProps = {
23
23
  export declare type StoryProps = (StoryDefProps | StoryRefProps | StoryImportProps) & CommonProps;
24
24
  export declare const lookupStoryId: (storyName: string, { mdxStoryNameToKey, mdxComponentAnnotations }: DocsContextProps) => string;
25
25
  export declare const getStoryId: (props: StoryProps, context: DocsContextProps) => StoryId;
26
- export declare const getStoryProps: <TFramework extends AnyFramework>({ height, inline }: StoryProps, story: StoryType<TFramework>, context: DocsContextProps<TFramework>, onStoryFnCalled: () => void) => PureStoryProps;
26
+ export declare const getStoryProps: <TFramework extends AnyFramework>({ height, inline }: StoryProps, story: StoryType<TFramework>) => PureStoryProps;
27
27
  declare const Story: FunctionComponent<StoryProps>;
28
28
  export { Story };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- import type { Options } from '@storybook/core-common';
1
+ import type { Options, StoryIndexer } from '@storybook/core-common';
2
2
  declare type BabelParams = {
3
3
  babelOptions?: any;
4
4
  mdxBabelOptions?: any;
@@ -8,4 +8,5 @@ export declare function webpack(webpackConfig: any, options: Options & BabelPara
8
8
  sourceLoaderOptions: any;
9
9
  transcludeMarkdown: boolean;
10
10
  }): Promise<any>;
11
+ export declare const storyIndexers: (indexers?: StoryIndexer[]) => Promise<StoryIndexer[]>;
11
12
  export {};
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-docs",
3
- "version": "6.5.9",
3
+ "version": "7.0.0-alpha.2",
4
4
  "description": "Document component usage and properties in Markdown",
5
5
  "keywords": [
6
6
  "addon",
@@ -26,14 +26,7 @@
26
26
  "license": "MIT",
27
27
  "main": "dist/cjs/index.js",
28
28
  "module": "dist/esm/index.js",
29
- "types": "dist/ts3.9/index.d.ts",
30
- "typesVersions": {
31
- "<3.8": {
32
- "dist/ts3.9/*": [
33
- "dist/ts3.4/*"
34
- ]
35
- }
36
- },
29
+ "types": "dist/types/index.d.ts",
37
30
  "files": [
38
31
  "dist/**/*",
39
32
  "angular/**/*",
@@ -59,21 +52,22 @@
59
52
  "@babel/preset-env": "^7.12.11",
60
53
  "@jest/transform": "^26.6.2",
61
54
  "@mdx-js/react": "^1.6.22",
62
- "@storybook/addons": "6.5.9",
63
- "@storybook/api": "6.5.9",
64
- "@storybook/components": "6.5.9",
65
- "@storybook/core-common": "6.5.9",
66
- "@storybook/core-events": "6.5.9",
55
+ "@storybook/addons": "7.0.0-alpha.2",
56
+ "@storybook/api": "7.0.0-alpha.2",
57
+ "@storybook/components": "7.0.0-alpha.2",
58
+ "@storybook/core-common": "7.0.0-alpha.2",
59
+ "@storybook/core-events": "7.0.0-alpha.2",
67
60
  "@storybook/csf": "0.0.2--canary.4566f4d.1",
68
- "@storybook/docs-tools": "6.5.9",
61
+ "@storybook/csf-tools": "7.0.0-alpha.2",
62
+ "@storybook/docs-tools": "7.0.0-alpha.2",
69
63
  "@storybook/mdx1-csf": "^0.0.1",
70
- "@storybook/node-logger": "6.5.9",
71
- "@storybook/postinstall": "6.5.9",
72
- "@storybook/preview-web": "6.5.9",
73
- "@storybook/source-loader": "6.5.9",
74
- "@storybook/store": "6.5.9",
75
- "@storybook/theming": "6.5.9",
76
- "babel-loader": "^8.0.0",
64
+ "@storybook/node-logger": "7.0.0-alpha.2",
65
+ "@storybook/postinstall": "7.0.0-alpha.2",
66
+ "@storybook/preview-web": "7.0.0-alpha.2",
67
+ "@storybook/source-loader": "7.0.0-alpha.2",
68
+ "@storybook/store": "7.0.0-alpha.2",
69
+ "@storybook/theming": "7.0.0-alpha.2",
70
+ "babel-loader": "^8.2.5",
77
71
  "core-js": "^3.8.2",
78
72
  "fast-deep-equal": "^3.1.3",
79
73
  "global": "^4.4.0",
@@ -108,8 +102,7 @@
108
102
  "publishConfig": {
109
103
  "access": "public"
110
104
  },
111
- "gitHead": "e2673f765722cbb542ef1b5cf8d533c8e746a127",
112
- "sbmodern": "dist/modern/index.js",
105
+ "gitHead": "44920e2b6bd51981bac5124743c29fb9f5517e44",
113
106
  "storybook": {
114
107
  "displayName": "Docs",
115
108
  "icon": "https://user-images.githubusercontent.com/263385/101991672-48355c80-3c7c-11eb-82d9-95fa12438f64.png",
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- export const anchorBlockIdFromId = storyId => `anchor--${storyId}`;
3
- export const Anchor = ({
4
- storyId,
5
- children
6
- }) => /*#__PURE__*/React.createElement("div", {
7
- id: anchorBlockIdFromId(storyId)
8
- }, children);