@storybook/addon-docs 7.0.0-alpha.8 → 7.0.0-beta.0
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/README.md +14 -77
- package/angular/index.js +1 -1
- package/dist/DocsRenderer-FLOC7YSC.mjs +1 -0
- package/dist/chunk-HXSBEJGO.mjs +1 -0
- package/dist/chunk-MA2MUXQN.mjs +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/preset.d.ts +5 -0
- package/dist/preset.js +7 -0
- package/dist/preset.mjs +7 -0
- package/dist/preview.d.ts +3 -0
- package/dist/preview.js +1 -0
- package/dist/preview.mjs +1 -0
- package/dist/shims/mdx-react-shim.d.ts +1 -0
- package/dist/shims/mdx-react-shim.js +1 -0
- package/dist/shims/mdx-react-shim.mjs +1 -0
- package/jest-transform-mdx.js +4 -3
- package/jest.config.js +7 -0
- package/package.json +80 -47
- package/preset.js +1 -1
- package/preview.js +2 -1
- package/web-components/README.md +1 -0
- package/LICENSE +0 -21
- package/blocks.d.ts +0 -2
- package/blocks.js +0 -14
- package/dist/cjs/blocks/index.js +0 -18
- package/dist/cjs/index.js +0 -18
- package/dist/cjs/manager.js +0 -20
- package/dist/cjs/preset.js +0 -154
- package/dist/cjs/preview.js +0 -22
- package/dist/cjs/shared.js +0 -22
- package/dist/esm/blocks/index.js +0 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/manager.js +0 -16
- package/dist/esm/preset.js +0 -132
- package/dist/esm/preview.js +0 -10
- package/dist/esm/shared.js +0 -11
- package/dist/types/blocks/index.d.ts +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/manager.d.ts +0 -1
- package/dist/types/preset.d.ts +0 -12
- package/dist/types/preview.d.ts +0 -1
- package/dist/types/shared.d.ts +0 -24
- package/manager.js +0 -1
- package/mdx-compiler-plugin.js +0 -1
- package/register.js +0 -6
package/README.md
CHANGED
|
@@ -23,7 +23,6 @@ Read on to learn more:
|
|
|
23
23
|
- [Installation](#installation)
|
|
24
24
|
- [Be sure to check framework specific installation needs](#be-sure-to-check-framework-specific-installation-needs)
|
|
25
25
|
- [Preset options](#preset-options)
|
|
26
|
-
- [Manual configuration](#manual-configuration)
|
|
27
26
|
- [TypeScript configuration](#typescript-configuration)
|
|
28
27
|
- [More resources](#more-resources)
|
|
29
28
|
|
|
@@ -37,7 +36,7 @@ Click on the `Docs` tab to see it:
|
|
|
37
36
|
<img src="https://raw.githubusercontent.com/storybookjs/storybook/main/addons/docs/docs/media/docs-tab.png" width="100%" />
|
|
38
37
|
</center>
|
|
39
38
|
|
|
40
|
-
For more information on how it works, see the [`DocsPage` reference](https://github.com/storybookjs/storybook/
|
|
39
|
+
For more information on how it works, see the [`DocsPage` reference](https://github.com/storybookjs/storybook/blob/next/code/addons/docs/docs/docspage.md).
|
|
41
40
|
|
|
42
41
|
## MDX
|
|
43
42
|
|
|
@@ -73,7 +72,7 @@ And here's how that's rendered in Storybook:
|
|
|
73
72
|
<img src="https://raw.githubusercontent.com/storybookjs/storybook/main/addons/docs/docs/media/mdx-simple.png" width="100%" />
|
|
74
73
|
</center>
|
|
75
74
|
|
|
76
|
-
For more information on `MDX`, see the [`MDX` reference](https://github.com/storybookjs/storybook/
|
|
75
|
+
For more information on `MDX`, see the [`MDX` reference](https://github.com/storybookjs/storybook/blob/next/code/addons/docs/docs/mdx.md).
|
|
77
76
|
|
|
78
77
|
## Framework support
|
|
79
78
|
|
|
@@ -81,10 +80,9 @@ Storybook Docs supports all view layers that Storybook supports except for React
|
|
|
81
80
|
|
|
82
81
|
[Framework Support](https://storybook.js.org/docs/react/api/frameworks-feature-support)
|
|
83
82
|
|
|
84
|
-
|
|
85
83
|
**Note:** `#` = WIP support
|
|
86
84
|
|
|
87
|
-
Want to add enhanced features to your favorite framework? Check out this [dev guide](https://github.com/storybookjs/storybook/tree/next/addons/docs/docs/multiframework.md)
|
|
85
|
+
Want to add enhanced features to your favorite framework? Check out this [dev guide](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/docs/multiframework.md)
|
|
88
86
|
|
|
89
87
|
## Installation
|
|
90
88
|
|
|
@@ -109,7 +107,7 @@ module.exports = {
|
|
|
109
107
|
};
|
|
110
108
|
```
|
|
111
109
|
|
|
112
|
-
If using in conjunction with the [storyshots add-on](https://github.com/storybookjs/storybook/blob/next/addons/storyshots/storyshots-core/README.md), you will need to
|
|
110
|
+
If using in conjunction with the [storyshots add-on](https://github.com/storybookjs/storybook/blob/next/code/addons/storyshots/storyshots-core/README.md), you will need to
|
|
113
111
|
configure Jest to transform MDX stories into something Storyshots can understand:
|
|
114
112
|
|
|
115
113
|
Add the following to your Jest configuration:
|
|
@@ -125,12 +123,12 @@ Add the following to your Jest configuration:
|
|
|
125
123
|
|
|
126
124
|
### Be sure to check framework specific installation needs
|
|
127
125
|
|
|
128
|
-
- [React](https://github.com/storybookjs/storybook/tree/next/addons/docs/react) (covered here)
|
|
129
|
-
- [Vue](https://github.com/storybookjs/storybook/tree/next/addons/docs/vue)
|
|
130
|
-
- [Angular](https://github.com/storybookjs/storybook/tree/next/addons/docs/angular)
|
|
131
|
-
- [Ember](https://github.com/storybookjs/storybook/tree/next/addons/docs/ember)
|
|
132
|
-
- [Web Components](https://github.com/storybookjs/storybook/tree/next/addons/docs/web-components)
|
|
133
|
-
- [Common setup (all other frameworks)](https://github.com/storybookjs/storybook/tree/next/addons/docs/common)
|
|
126
|
+
- [React](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/react) (covered here)
|
|
127
|
+
- [Vue](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/vue)
|
|
128
|
+
- [Angular](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/angular)
|
|
129
|
+
- [Ember](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/ember)
|
|
130
|
+
- [Web Components](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/web-components)
|
|
131
|
+
- [Common setup (all other frameworks)](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/common)
|
|
134
132
|
|
|
135
133
|
## Preset options
|
|
136
134
|
|
|
@@ -144,7 +142,7 @@ module.exports = {
|
|
|
144
142
|
options: {
|
|
145
143
|
configureJSX: true,
|
|
146
144
|
babelOptions: {},
|
|
147
|
-
|
|
145
|
+
csfPluginOptions: null,
|
|
148
146
|
transcludeMarkdown: true,
|
|
149
147
|
},
|
|
150
148
|
},
|
|
@@ -154,7 +152,7 @@ module.exports = {
|
|
|
154
152
|
|
|
155
153
|
The `configureJSX` option is useful when you're writing your docs in MDX and your project's babel config isn't already set up to handle JSX files. `babelOptions` is a way to further configure the babel processor when you're using `configureJSX`.
|
|
156
154
|
|
|
157
|
-
`
|
|
155
|
+
`csfPluginOptions` is an object for configuring `@storybook/csf-plugin`. When set to `null` it tells docs not to run the `csf-plugin` at all, which can be used as an optimization, or if you're already using `csf-plugin` in your `main.js`.
|
|
158
156
|
|
|
159
157
|
The `transcludeMarkdown` option enables mdx files to import `.md` files and render them as a component.
|
|
160
158
|
|
|
@@ -167,75 +165,14 @@ import Changelog from '../CHANGELOG.md';
|
|
|
167
165
|
<Changelog />
|
|
168
166
|
```
|
|
169
167
|
|
|
170
|
-
## Manual configuration
|
|
171
|
-
|
|
172
|
-
We recommend using the preset, which should work out of the box. If you don't want to use the preset, and prefer to configure "the long way" add the following configuration to `.storybook/main.js` (see comments inline for explanation):
|
|
173
|
-
|
|
174
|
-
```js
|
|
175
|
-
const createCompiler = require('@storybook/addon-docs/mdx-compiler-plugin');
|
|
176
|
-
|
|
177
|
-
module.exports = {
|
|
178
|
-
// 1. register the docs panel (as opposed to '@storybook/addon-docs' which
|
|
179
|
-
// will configure everything with a preset)
|
|
180
|
-
addons: ['@storybook/addon-docs/register'],
|
|
181
|
-
// 2. manually configure webpack, since you're not using the preset
|
|
182
|
-
webpackFinal: async (config) => {
|
|
183
|
-
config.module.rules.push({
|
|
184
|
-
// 2a. Load `.stories.mdx` / `.story.mdx` files as CSF and generate
|
|
185
|
-
// the docs page from the markdown
|
|
186
|
-
test: /\.(stories|story)\.mdx$/,
|
|
187
|
-
use: [
|
|
188
|
-
{
|
|
189
|
-
// Need to add babel-loader as dependency: `yarn add -D babel-loader`
|
|
190
|
-
loader: require.resolve('babel-loader'),
|
|
191
|
-
// may or may not need this line depending on your app's setup
|
|
192
|
-
options: {
|
|
193
|
-
plugins: ['@babel/plugin-transform-react-jsx'],
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
loader: '@mdx-js/loader',
|
|
198
|
-
options: {
|
|
199
|
-
compilers: [createCompiler({})],
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
});
|
|
204
|
-
// 2b. Run `source-loader` on story files to show their source code
|
|
205
|
-
// automatically in `DocsPage` or the `Source` doc block.
|
|
206
|
-
config.module.rules.push({
|
|
207
|
-
test: /\.(stories|story)\.[tj]sx?$/,
|
|
208
|
-
loader: require.resolve('@storybook/source-loader'),
|
|
209
|
-
exclude: [/node_modules/],
|
|
210
|
-
enforce: 'pre',
|
|
211
|
-
});
|
|
212
|
-
return config;
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
You'll also need to set up the docs parameter in `.storybook/preview.js`. This includes the `DocsPage` for rendering the page, a container, and various configuration options, such as `extractComponentDescription` for manually extracting a component description:
|
|
218
|
-
|
|
219
|
-
```js
|
|
220
|
-
import { addParameters } from '@storybook/react';
|
|
221
|
-
import { DocsPage, DocsContainer } from '@storybook/addon-docs';
|
|
222
|
-
|
|
223
|
-
addParameters({
|
|
224
|
-
docs: {
|
|
225
|
-
container: DocsContainer,
|
|
226
|
-
page: DocsPage,
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
```
|
|
230
|
-
|
|
231
168
|
## TypeScript configuration
|
|
232
169
|
|
|
233
|
-
As of SB6 [TypeScript is zero-config](https://storybook.js.org/docs/react/configure/typescript) and should work with SB Docs out of the box. For advanced configuration options, refer to the [Props documentation](https://github.com/storybookjs/storybook/tree/next/addons/docs/docs/props-tables.md).
|
|
170
|
+
As of SB6 [TypeScript is zero-config](https://storybook.js.org/docs/react/configure/typescript) and should work with SB Docs out of the box. For advanced configuration options, refer to the [Props documentation](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/docs/props-tables.md).
|
|
234
171
|
|
|
235
172
|
## More resources
|
|
236
173
|
|
|
237
174
|
Want to learn more? Here are some more articles on Storybook Docs:
|
|
238
175
|
|
|
239
|
-
- References: [DocsPage](https://github.com/storybookjs/storybook/tree/next/addons/docs/docs/docspage.md) / [MDX](https://github.com/storybookjs/storybook/tree/next/addons/docs/docs/mdx.md) / [FAQ](https://github.com/storybookjs/storybook/tree/next/addons/docs/docs/faq.md) / [Recipes](https://github.com/storybookjs/storybook/tree/next/addons/docs/docs/recipes.md) / [Theming](https://github.com/storybookjs/storybook/tree/next/addons/docs/docs/theming.md) / [Props](https://github.com/storybookjs/storybook/tree/next/addons/docs/docs/props-tables.md)
|
|
176
|
+
- References: [DocsPage](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/docs/docspage.md) / [MDX](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/docs/mdx.md) / [FAQ](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/docs/faq.md) / [Recipes](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/docs/recipes.md) / [Theming](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/docs/theming.md) / [Props](https://github.com/storybookjs/storybook/tree/next/code/addons/docs/docs/props-tables.md)
|
|
240
177
|
- Announcements: [Vision](https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a) / [DocsPage](https://medium.com/storybookjs/storybook-docspage-e185bc3622bf) / [MDX](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) / [Framework support](https://medium.com/storybookjs/storybook-docs-for-new-frameworks-b1f6090ee0ea)
|
|
241
178
|
- Example: [Storybook Design System](https://github.com/storybookjs/design-system)
|
package/angular/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DocsRenderer,defaultComponents}from"./chunk-MA2MUXQN.mjs";import"./chunk-HXSBEJGO.mjs";export{DocsRenderer,defaultComponents};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __require=(x=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(x,{get:(a,b)=>(typeof require!="undefined"?require:a)[b]}):x)(function(x){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+x+'" is not supported')});export{__require};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from"react";import ReactDOM from"react-dom";import{Docs,CodeOrSourceMdx,AnchorMdx,HeadersMdx}from"@storybook/blocks";var defaultComponents={code:CodeOrSourceMdx,a:AnchorMdx,...HeadersMdx},DocsRenderer=class{constructor(){this.render=(context,docsParameter,element,callback)=>{let components={...defaultComponents,...docsParameter?.components};import("@mdx-js/react").then(({MDXProvider})=>{ReactDOM.render(React.createElement(MDXProvider,{components},React.createElement(Docs,{key:Math.random(),context,docsParameter})),element,callback)})},this.unmount=element=>{ReactDOM.unmountComponentAtNode(element)}}};export{defaultComponents,DocsRenderer};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from '@storybook/blocks';
|
|
2
|
+
import { Renderer, DocsRenderFunction } from '@storybook/types';
|
|
3
|
+
|
|
4
|
+
declare class DocsRenderer<TRenderer extends Renderer> {
|
|
5
|
+
render: DocsRenderFunction<TRenderer>;
|
|
6
|
+
unmount: (element: HTMLElement) => void;
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { DocsRenderer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.create;var p=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var n in e)p(o,n,{get:e[n],enumerable:!0})},s=(o,e,n,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of T(e))!y.call(o,t)&&t!==n&&p(o,t,{get:()=>e[t],enumerable:!(d=D(e,t))||d.enumerable});return o},c=(o,e,n)=>(s(o,e,"default"),n&&s(n,e,"default")),u=(o,e,n)=>(n=o!=null?f(h(o)):{},s(e||!o||!o.__esModule?p(n,"default",{value:o,enumerable:!0}):n,o)),v=o=>s(p({},"__esModule",{value:!0}),o);var m={};C(m,{DocsRenderer:()=>i});module.exports=v(m);c(m,require("@storybook/blocks"),module.exports);var x=u(require("react")),M=u(require("react-dom")),r=require("@storybook/blocks"),H={code:r.CodeOrSourceMdx,a:r.AnchorMdx,...r.HeadersMdx},i=class{constructor(){this.render=(e,n,d,t)=>{let l={...H,...n==null?void 0:n.components};import("@mdx-js/react").then(({MDXProvider:R})=>{M.default.render(x.default.createElement(R,{components:l},x.default.createElement(r.Docs,{key:Math.random(),context:e,docsParameter:n})),d,t)})},this.unmount=e=>{M.default.unmountComponentAtNode(e)}}};0&&(module.exports={DocsRenderer});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DocsRenderer}from"./chunk-MA2MUXQN.mjs";import"./chunk-HXSBEJGO.mjs";export*from"@storybook/blocks";export{DocsRenderer};
|
package/dist/preset.d.ts
ADDED
package/dist/preset.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var w=Object.create;var d=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var X=(e,r)=>{for(var o in r)d(e,o,{get:r[o],enumerable:!0})},y=(e,r,o,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of S(r))!h.call(e,s)&&s!==o&&d(e,s,{get:()=>r[s],enumerable:!(t=L(r,s))||t.enumerable});return e};var i=(e,r,o)=>(o=e!=null?w($(e)):{},y(r||!e||!e.__esModule?d(o,"default",{value:e,enumerable:!0}):o,e)),v=e=>y(d({},"__esModule",{value:!0}),e);var B={};X(B,{docs:()=>q,storyIndexers:()=>j,webpack:()=>R});module.exports=v(B);var g=i(require("fs-extra")),x=i(require("remark-slug")),b=i(require("remark-external-links")),k=require("ts-dedent"),O=require("@storybook/csf-tools");function m({mdxBabelOptions:e,configureJSX:r}){let o=(e==null?void 0:e.plugins)||[],t=o.filter(a=>{let l=Array.isArray(a)?a[0]:a;return typeof l=="string"?!l.includes("plugin-transform-react-jsx"):!0}),s=[require.resolve("@babel/plugin-transform-react-jsx"),{pragma:"React.createElement",pragmaFrag:"React.Fragment"}],n=r?[...t,s]:o;return{babelrc:!1,configFile:!1,...e,plugins:n}}async function A(e={},r){let o=await r.presets.apply("babelLoaderRef"),{module:t={}}=e,{mdxBabelOptions:s,configureJSX:n=!0,csfPluginOptions:a={},sourceLoaderOptions:l=null,transcludeMarkdown:I=!1}=r,u=await r.presets.apply("mdxLoaderOptions",{skipCsf:!0,mdxCompileOptions:{providerImportSource:"@storybook/addon-docs/mdx-react-shim",remarkPlugins:[x.default,b.default]}});if(l)throw new Error(k.dedent`
|
|
2
|
+
Addon-docs no longer uses source-loader in 7.0.
|
|
3
|
+
|
|
4
|
+
To update your configuration, please see migration instructions here:
|
|
5
|
+
|
|
6
|
+
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#dropped-source-loader--storiesof-static-snippets
|
|
7
|
+
`);let c=require.resolve("@storybook/mdx2-csf/loader"),p=t.rules||[];return I&&(p=[...p.filter(P=>{var f;return((f=P.test)==null?void 0:f.toString())!=="/\\.md$/"}),{test:/\.md$/,use:[{loader:o,options:m({mdxBabelOptions:s,configureJSX:n})},{loader:c,options:u}]}]),{...e,plugins:[...e.plugins||[],...a?[require("@storybook/csf-plugin").webpack(a)]:[]],module:{...t,rules:[...p,{test:/(stories|story)\.mdx$/,use:[{loader:o,options:m({mdxBabelOptions:s,configureJSX:n})},{loader:c,options:{...u,skipCsf:!1}}]},{test:/\.mdx$/,exclude:/(stories|story)\.mdx$/,use:[{loader:o,options:m({mdxBabelOptions:s,configureJSX:n})},{loader:c,options:u}]}]}}}var C=e=>[{test:/(stories|story)\.mdx$/,indexer:async(o,t)=>{let s=(await g.default.readFile(o,"utf-8")).toString(),{compile:n}=await import("@storybook/mdx2-csf");return s=await n(s,{}),(0,O.loadCsf)(s,{...t,fileName:o}).parse()}},...e||[]],F=e=>({...e,enabled:!0,defaultName:"Docs",docsPage:!0}),R=A,j=C,q=F;0&&(module.exports={docs,storyIndexers,webpack});
|
package/dist/preset.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{__require}from"./chunk-HXSBEJGO.mjs";import fs from"fs-extra";import remarkSlug from"remark-slug";import remarkExternalLinks from"remark-external-links";import{dedent}from"ts-dedent";import{loadCsf}from"@storybook/csf-tools";function createBabelOptions({mdxBabelOptions,configureJSX}){let babelPlugins=mdxBabelOptions?.plugins||[],filteredBabelPlugins=babelPlugins.filter(p=>{let name=Array.isArray(p)?p[0]:p;return typeof name=="string"?!name.includes("plugin-transform-react-jsx"):!0}),jsxPlugin=[__require.resolve("@babel/plugin-transform-react-jsx"),{pragma:"React.createElement",pragmaFrag:"React.Fragment"}],plugins=configureJSX?[...filteredBabelPlugins,jsxPlugin]:babelPlugins;return{babelrc:!1,configFile:!1,...mdxBabelOptions,plugins}}async function webpack(webpackConfig={},options){let resolvedBabelLoader=await options.presets.apply("babelLoaderRef"),{module={}}=webpackConfig,{mdxBabelOptions,configureJSX=!0,csfPluginOptions={},sourceLoaderOptions=null,transcludeMarkdown=!1}=options,mdxLoaderOptions=await options.presets.apply("mdxLoaderOptions",{skipCsf:!0,mdxCompileOptions:{providerImportSource:"@storybook/addon-docs/mdx-react-shim",remarkPlugins:[remarkSlug,remarkExternalLinks]}});if(sourceLoaderOptions)throw new Error(dedent`
|
|
2
|
+
Addon-docs no longer uses source-loader in 7.0.
|
|
3
|
+
|
|
4
|
+
To update your configuration, please see migration instructions here:
|
|
5
|
+
|
|
6
|
+
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#dropped-source-loader--storiesof-static-snippets
|
|
7
|
+
`);let mdxLoader=__require.resolve("@storybook/mdx2-csf/loader"),rules=module.rules||[];return transcludeMarkdown&&(rules=[...rules.filter(rule=>rule.test?.toString()!=="/\\.md$/"),{test:/\.md$/,use:[{loader:resolvedBabelLoader,options:createBabelOptions({mdxBabelOptions,configureJSX})},{loader:mdxLoader,options:mdxLoaderOptions}]}]),{...webpackConfig,plugins:[...webpackConfig.plugins||[],...csfPluginOptions?[__require("@storybook/csf-plugin").webpack(csfPluginOptions)]:[]],module:{...module,rules:[...rules,{test:/(stories|story)\.mdx$/,use:[{loader:resolvedBabelLoader,options:createBabelOptions({mdxBabelOptions,configureJSX})},{loader:mdxLoader,options:{...mdxLoaderOptions,skipCsf:!1}}]},{test:/\.mdx$/,exclude:/(stories|story)\.mdx$/,use:[{loader:resolvedBabelLoader,options:createBabelOptions({mdxBabelOptions,configureJSX})},{loader:mdxLoader,options:mdxLoaderOptions}]}]}}}var storyIndexers=indexers=>[{test:/(stories|story)\.mdx$/,indexer:async(fileName,opts)=>{let code=(await fs.readFile(fileName,"utf-8")).toString(),{compile}=await import("@storybook/mdx2-csf");return code=await compile(code,{}),loadCsf(code,{...opts,fileName}).parse()}},...indexers||[]],docs=docsOptions=>({...docsOptions,enabled:!0,defaultName:"Docs",docsPage:!0}),webpackX=webpack,storyIndexersX=storyIndexers,docsX=docs;export{docsX as docs,storyIndexersX as storyIndexers,webpackX as webpack};
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var D=Object.create;var d=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var v=(e,o)=>()=>(e&&(o=e(e=0)),o);var u=(e,o)=>{for(var n in o)d(e,n,{get:o[n],enumerable:!0})},a=(e,o,n,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of f(o))!C.call(e,t)&&t!==n&&d(e,t,{get:()=>o[t],enumerable:!(s=T(o,t))||s.enumerable});return e};var c=(e,o,n)=>(n=e!=null?D(h(e)):{},a(o||!e||!e.__esModule?d(n,"default",{value:e,enumerable:!0}):n,e)),H=e=>a(d({},"__esModule",{value:!0}),e);var M={};u(M,{DocsRenderer:()=>i,defaultComponents:()=>x});var m,p,r,x,i,l=v(()=>{m=c(require("react")),p=c(require("react-dom")),r=require("@storybook/blocks"),x={code:r.CodeOrSourceMdx,a:r.AnchorMdx,...r.HeadersMdx},i=class{constructor(){this.render=(o,n,s,t)=>{let y={...x,...n==null?void 0:n.components};import("@mdx-js/react").then(({MDXProvider:R})=>{p.default.render(m.default.createElement(R,{components:y},m.default.createElement(r.Docs,{key:Math.random(),context:o,docsParameter:n})),s,t)})},this.unmount=o=>{p.default.unmountComponentAtNode(o)}}}});var E={};u(E,{parameters:()=>b});module.exports=H(E);var b={docs:{renderer:async()=>{let{DocsRenderer:e}=await Promise.resolve().then(()=>(l(),M));return new e}}};0&&(module.exports={parameters});
|
package/dist/preview.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-HXSBEJGO.mjs";var parameters={docs:{renderer:async()=>{let{DocsRenderer}=await import("./DocsRenderer-FLOC7YSC.mjs");return new DocsRenderer}}};export{parameters};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mdx-js/react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("@mdx-js/react"),module.exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@mdx-js/react";
|
package/jest-transform-mdx.js
CHANGED
|
@@ -2,15 +2,16 @@ const path = require('path');
|
|
|
2
2
|
const { ScriptTransformer } = require('@jest/transform');
|
|
3
3
|
const { dedent } = require('ts-dedent');
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const { compile } = require('@storybook/mdx2-csf');
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
|
-
|
|
8
|
+
async processAsync(src, filename, config, { instrument }) {
|
|
9
|
+
const code = await compile(src, { skipCsf: false });
|
|
9
10
|
const result = dedent`
|
|
10
11
|
/* @jsx mdx */
|
|
11
12
|
import React from 'react'
|
|
12
13
|
import { mdx } from '@mdx-js/react'
|
|
13
|
-
${
|
|
14
|
+
${code}
|
|
14
15
|
`;
|
|
15
16
|
|
|
16
17
|
const extension = path.extname(filename);
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-docs",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-beta.0",
|
|
4
4
|
"description": "Document component usage and properties in Markdown",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -24,9 +24,55 @@
|
|
|
24
24
|
"url": "https://opencollective.com/storybook"
|
|
25
25
|
},
|
|
26
26
|
"license": "MIT",
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"node": "./dist/index.js",
|
|
30
|
+
"require": "./dist/index.js",
|
|
31
|
+
"import": "./dist/index.mjs",
|
|
32
|
+
"types": "./dist/index.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./preview": {
|
|
35
|
+
"require": "./dist/preview.js",
|
|
36
|
+
"import": "./dist/preview.mjs",
|
|
37
|
+
"types": "./dist/preview.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./preset": {
|
|
40
|
+
"require": "./dist/preset.js",
|
|
41
|
+
"import": "./dist/preset.mjs",
|
|
42
|
+
"types": "./dist/preset.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./dist/preview": {
|
|
45
|
+
"require": "./dist/preview.js",
|
|
46
|
+
"import": "./dist/preview.mjs",
|
|
47
|
+
"types": "./dist/preview.d.ts"
|
|
48
|
+
},
|
|
49
|
+
"./dist/preset": {
|
|
50
|
+
"require": "./dist/preset.js",
|
|
51
|
+
"import": "./dist/preset.mjs",
|
|
52
|
+
"types": "./dist/preset.d.ts"
|
|
53
|
+
},
|
|
54
|
+
"./dist/shims/mdx-react-shim": {
|
|
55
|
+
"require": "./dist/shims/mdx-react-shim.js",
|
|
56
|
+
"import": "./dist/shims/mdx-react-shim.mjs",
|
|
57
|
+
"types": "./dist/shims/mdx-react-shim.d.ts"
|
|
58
|
+
},
|
|
59
|
+
"./mdx-react-shim": {
|
|
60
|
+
"require": "./dist/shims/mdx-react-shim.js",
|
|
61
|
+
"import": "./dist/shims/mdx-react-shim.mjs",
|
|
62
|
+
"types": "./dist/shims/mdx-react-shim.d.ts"
|
|
63
|
+
},
|
|
64
|
+
"./svelte/HOC.svelte": "./svelte/HOC.svelte",
|
|
65
|
+
"./ember": "./ember/index.js",
|
|
66
|
+
"./ember/index.js": "./ember/index.js",
|
|
67
|
+
"./angular": "./angular/index.js",
|
|
68
|
+
"./angular/index.js": "./angular/index.js",
|
|
69
|
+
"./web-components/index.js": "./web-components/index.js",
|
|
70
|
+
"./jest-transform-mdx": "./jest-transform-mdx.js",
|
|
71
|
+
"./package.json": "./package.json"
|
|
72
|
+
},
|
|
73
|
+
"main": "dist/index.js",
|
|
74
|
+
"module": "dist/index.mjs",
|
|
75
|
+
"types": "dist/index.d.ts",
|
|
30
76
|
"files": [
|
|
31
77
|
"dist/**/*",
|
|
32
78
|
"angular/**/*",
|
|
@@ -45,64 +91,51 @@
|
|
|
45
91
|
"!__testfixtures__"
|
|
46
92
|
],
|
|
47
93
|
"scripts": {
|
|
48
|
-
"
|
|
94
|
+
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
|
95
|
+
"prep": "../../../scripts/prepare/bundle.ts"
|
|
49
96
|
},
|
|
50
97
|
"dependencies": {
|
|
51
|
-
"@babel/
|
|
52
|
-
"@babel/
|
|
53
|
-
"@jest/transform": "^
|
|
54
|
-
"@mdx-js/react": "^1.
|
|
55
|
-
"@storybook/
|
|
56
|
-
"@storybook/
|
|
57
|
-
"@storybook/
|
|
58
|
-
"@storybook/
|
|
59
|
-
"@storybook/
|
|
60
|
-
"@storybook/
|
|
61
|
-
"@storybook/
|
|
62
|
-
"@storybook/
|
|
63
|
-
"@storybook/
|
|
64
|
-
"@storybook/
|
|
65
|
-
"
|
|
66
|
-
"@storybook/postinstall": "7.0.0-alpha.8",
|
|
67
|
-
"@storybook/preview-web": "7.0.0-alpha.8",
|
|
68
|
-
"@storybook/source-loader": "7.0.0-alpha.8",
|
|
69
|
-
"@storybook/store": "7.0.0-alpha.8",
|
|
70
|
-
"@storybook/theming": "7.0.0-alpha.8",
|
|
71
|
-
"babel-loader": "^8.2.5",
|
|
72
|
-
"core-js": "^3.8.2",
|
|
73
|
-
"fast-deep-equal": "^3.1.3",
|
|
98
|
+
"@babel/core": "^7.20.2",
|
|
99
|
+
"@babel/plugin-transform-react-jsx": "^7.19.0",
|
|
100
|
+
"@jest/transform": "^29.3.1",
|
|
101
|
+
"@mdx-js/react": "^2.1.5",
|
|
102
|
+
"@storybook/blocks": "7.0.0-beta.0",
|
|
103
|
+
"@storybook/components": "7.0.0-beta.0",
|
|
104
|
+
"@storybook/csf-plugin": "7.0.0-beta.0",
|
|
105
|
+
"@storybook/csf-tools": "7.0.0-beta.0",
|
|
106
|
+
"@storybook/mdx2-csf": "next",
|
|
107
|
+
"@storybook/node-logger": "7.0.0-beta.0",
|
|
108
|
+
"@storybook/postinstall": "7.0.0-beta.0",
|
|
109
|
+
"@storybook/preview-api": "7.0.0-beta.0",
|
|
110
|
+
"@storybook/theming": "7.0.0-beta.0",
|
|
111
|
+
"@storybook/types": "7.0.0-beta.0",
|
|
112
|
+
"fs-extra": "^9.0.1",
|
|
74
113
|
"global": "^4.4.0",
|
|
75
|
-
"lodash": "^4.17.21",
|
|
76
114
|
"remark-external-links": "^8.0.0",
|
|
77
115
|
"remark-slug": "^6.0.0",
|
|
78
|
-
"ts-dedent": "^2.0.0"
|
|
79
|
-
"util-deprecate": "^1.0.2"
|
|
116
|
+
"ts-dedent": "^2.0.0"
|
|
80
117
|
},
|
|
81
118
|
"devDependencies": {
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
119
|
+
"react": "^16.14.0",
|
|
120
|
+
"react-dom": "^16.8.0",
|
|
121
|
+
"typescript": "~4.9.3"
|
|
85
122
|
},
|
|
86
123
|
"peerDependencies": {
|
|
87
|
-
"@storybook/mdx2-csf": "^0.0.3",
|
|
88
124
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
89
125
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
90
126
|
},
|
|
91
|
-
"peerDependenciesMeta": {
|
|
92
|
-
"@storybook/mdx2-csf": {
|
|
93
|
-
"optional": true
|
|
94
|
-
},
|
|
95
|
-
"react": {
|
|
96
|
-
"optional": true
|
|
97
|
-
},
|
|
98
|
-
"react-dom": {
|
|
99
|
-
"optional": true
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
127
|
"publishConfig": {
|
|
103
128
|
"access": "public"
|
|
104
129
|
},
|
|
105
|
-
"
|
|
130
|
+
"bundler": {
|
|
131
|
+
"entries": [
|
|
132
|
+
"./src/index.ts",
|
|
133
|
+
"./src/preset.ts",
|
|
134
|
+
"./src/preview.ts",
|
|
135
|
+
"./src/shims/mdx-react-shim.ts"
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
"gitHead": "2e4ddde6a0a291266d91fe6a5ecda767bf119e70",
|
|
106
139
|
"storybook": {
|
|
107
140
|
"displayName": "Docs",
|
|
108
141
|
"icon": "https://user-images.githubusercontent.com/263385/101991672-48355c80-3c7c-11eb-82d9-95fa12438f64.png",
|
package/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./dist/
|
|
1
|
+
module.exports = require('./dist/preset');
|
package/preview.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
// eslint-disable-next-line import/export
|
|
2
|
+
export * from './dist/preview';
|
package/web-components/README.md
CHANGED
|
@@ -39,6 +39,7 @@ Known analyzers that output `custom-elements.json` v1.0.0:
|
|
|
39
39
|
- Supports Vanilla, LitElement, FASTElement, Stencil, Catalyst, Atomico
|
|
40
40
|
|
|
41
41
|
Known analyzers that output older versions of `custom-elements.json`:
|
|
42
|
+
|
|
42
43
|
- [web-component-analyzer](https://github.com/runem/web-component-analyzer)
|
|
43
44
|
- Supports LitElement, Polymer, Vanilla, (Stencil)
|
|
44
45
|
- [stenciljs](https://stenciljs.com/)
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2017 Kadira Inc. <hello@kadira.io>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
package/blocks.d.ts
DELETED
package/blocks.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import deprecate from 'util-deprecate';
|
|
2
|
-
import dedent from 'ts-dedent';
|
|
3
|
-
|
|
4
|
-
const warnBlocksImport = deprecate(
|
|
5
|
-
() => {},
|
|
6
|
-
dedent`
|
|
7
|
-
Importing from '@storybook/addon-docs/blocks' is deprecated, import directly from '@storybook/addon-docs' instead:
|
|
8
|
-
|
|
9
|
-
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-scoped-blocks-imports
|
|
10
|
-
`
|
|
11
|
-
);
|
|
12
|
-
warnBlocksImport();
|
|
13
|
-
|
|
14
|
-
export * from './dist/esm/blocks';
|
package/dist/cjs/blocks/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _blocks = require("@storybook/blocks");
|
|
8
|
-
|
|
9
|
-
Object.keys(_blocks).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _blocks[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _blocks[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
package/dist/cjs/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _blocks = require("./blocks");
|
|
8
|
-
|
|
9
|
-
Object.keys(_blocks).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _blocks[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _blocks[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
package/dist/cjs/manager.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _addons = require("@storybook/addons");
|
|
4
|
-
|
|
5
|
-
var _shared = require("./shared");
|
|
6
|
-
|
|
7
|
-
_addons.addons.register(_shared.ADDON_ID, () => {
|
|
8
|
-
_addons.addons.add(_shared.PANEL_ID, {
|
|
9
|
-
type: _addons.types.TAB,
|
|
10
|
-
title: 'Docs',
|
|
11
|
-
route: ({
|
|
12
|
-
storyId,
|
|
13
|
-
refId
|
|
14
|
-
}) => refId ? `/docs/${refId}_${storyId}` : `/docs/${storyId}`,
|
|
15
|
-
match: ({
|
|
16
|
-
viewMode
|
|
17
|
-
}) => viewMode === 'docs',
|
|
18
|
-
render: () => null
|
|
19
|
-
});
|
|
20
|
-
});
|
package/dist/cjs/preset.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.storyIndexers = void 0;
|
|
7
|
-
exports.webpack = webpack;
|
|
8
|
-
|
|
9
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
10
|
-
|
|
11
|
-
var _remarkSlug = _interopRequireDefault(require("remark-slug"));
|
|
12
|
-
|
|
13
|
-
var _remarkExternalLinks = _interopRequireDefault(require("remark-external-links"));
|
|
14
|
-
|
|
15
|
-
var _global = _interopRequireDefault(require("global"));
|
|
16
|
-
|
|
17
|
-
var _nodeLogger = require("@storybook/node-logger");
|
|
18
|
-
|
|
19
|
-
var _csfTools = require("@storybook/csf-tools");
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
|
-
|
|
25
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
26
|
-
|
|
27
|
-
function createBabelOptions({
|
|
28
|
-
babelOptions,
|
|
29
|
-
mdxBabelOptions,
|
|
30
|
-
configureJSX
|
|
31
|
-
}) {
|
|
32
|
-
const babelPlugins = mdxBabelOptions?.plugins || babelOptions?.plugins || [];
|
|
33
|
-
const jsxPlugin = [require.resolve('@babel/plugin-transform-react-jsx'), {
|
|
34
|
-
pragma: 'React.createElement',
|
|
35
|
-
pragmaFrag: 'React.Fragment'
|
|
36
|
-
}];
|
|
37
|
-
const plugins = configureJSX ? [...babelPlugins, jsxPlugin] : babelPlugins;
|
|
38
|
-
return Object.assign({
|
|
39
|
-
// don't use the root babelrc by default (users can override this in mdxBabelOptions)
|
|
40
|
-
babelrc: false,
|
|
41
|
-
configFile: false
|
|
42
|
-
}, babelOptions, mdxBabelOptions, {
|
|
43
|
-
plugins
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function webpack(webpackConfig = {}, options) {
|
|
48
|
-
const resolvedBabelLoader = require.resolve('babel-loader');
|
|
49
|
-
|
|
50
|
-
const {
|
|
51
|
-
module = {}
|
|
52
|
-
} = webpackConfig; // it will reuse babel options that are already in use in storybook
|
|
53
|
-
// also, these babel options are chained with other presets.
|
|
54
|
-
|
|
55
|
-
const {
|
|
56
|
-
babelOptions,
|
|
57
|
-
mdxBabelOptions,
|
|
58
|
-
configureJSX = true,
|
|
59
|
-
sourceLoaderOptions = {
|
|
60
|
-
injectStoryParameters: true
|
|
61
|
-
},
|
|
62
|
-
transcludeMarkdown = false
|
|
63
|
-
} = options;
|
|
64
|
-
const mdxLoaderOptions = {
|
|
65
|
-
skipCsf: true,
|
|
66
|
-
remarkPlugins: [_remarkSlug.default, _remarkExternalLinks.default]
|
|
67
|
-
};
|
|
68
|
-
const mdxVersion = _global.default.FEATURES?.previewMdx2 ? 'MDX2' : 'MDX1';
|
|
69
|
-
|
|
70
|
-
_nodeLogger.logger.info(`Addon-docs: using ${mdxVersion}`);
|
|
71
|
-
|
|
72
|
-
const mdxLoader = _global.default.FEATURES?.previewMdx2 ? require.resolve('@storybook/mdx2-csf/loader') : require.resolve('@storybook/mdx1-csf/loader'); // set `sourceLoaderOptions` to `null` to disable for manual configuration
|
|
73
|
-
|
|
74
|
-
const sourceLoader = sourceLoaderOptions ? [{
|
|
75
|
-
test: /\.(stories|story)\.[tj]sx?$/,
|
|
76
|
-
loader: require.resolve('@storybook/source-loader'),
|
|
77
|
-
options: Object.assign({}, sourceLoaderOptions, {
|
|
78
|
-
inspectLocalDependencies: true
|
|
79
|
-
}),
|
|
80
|
-
enforce: 'pre'
|
|
81
|
-
}] : [];
|
|
82
|
-
let rules = module.rules || [];
|
|
83
|
-
|
|
84
|
-
if (transcludeMarkdown) {
|
|
85
|
-
rules = [...rules.filter(rule => rule.test?.toString() !== '/\\.md$/'), {
|
|
86
|
-
test: /\.md$/,
|
|
87
|
-
use: [{
|
|
88
|
-
loader: resolvedBabelLoader,
|
|
89
|
-
options: createBabelOptions({
|
|
90
|
-
babelOptions,
|
|
91
|
-
mdxBabelOptions,
|
|
92
|
-
configureJSX
|
|
93
|
-
})
|
|
94
|
-
}, {
|
|
95
|
-
loader: mdxLoader,
|
|
96
|
-
options: mdxLoaderOptions
|
|
97
|
-
}]
|
|
98
|
-
}];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const result = Object.assign({}, webpackConfig, {
|
|
102
|
-
module: Object.assign({}, module, {
|
|
103
|
-
rules: [...rules, {
|
|
104
|
-
test: /(stories|story)\.mdx$/,
|
|
105
|
-
use: [{
|
|
106
|
-
loader: resolvedBabelLoader,
|
|
107
|
-
options: createBabelOptions({
|
|
108
|
-
babelOptions,
|
|
109
|
-
mdxBabelOptions,
|
|
110
|
-
configureJSX
|
|
111
|
-
})
|
|
112
|
-
}, {
|
|
113
|
-
loader: mdxLoader
|
|
114
|
-
}]
|
|
115
|
-
}, {
|
|
116
|
-
test: /\.mdx$/,
|
|
117
|
-
exclude: /(stories|story)\.mdx$/,
|
|
118
|
-
use: [{
|
|
119
|
-
loader: resolvedBabelLoader,
|
|
120
|
-
options: createBabelOptions({
|
|
121
|
-
babelOptions,
|
|
122
|
-
mdxBabelOptions,
|
|
123
|
-
configureJSX
|
|
124
|
-
})
|
|
125
|
-
}, {
|
|
126
|
-
loader: mdxLoader,
|
|
127
|
-
options: mdxLoaderOptions
|
|
128
|
-
}]
|
|
129
|
-
}, ...sourceLoader]
|
|
130
|
-
})
|
|
131
|
-
});
|
|
132
|
-
return result;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const storyIndexers = async indexers => {
|
|
136
|
-
const mdxIndexer = async (fileName, opts) => {
|
|
137
|
-
let code = (await _fsExtra.default.readFile(fileName, 'utf-8')).toString(); // @ts-ignore
|
|
138
|
-
|
|
139
|
-
const {
|
|
140
|
-
compile
|
|
141
|
-
} = _global.default.FEATURES?.previewMdx2 ? await Promise.resolve().then(() => _interopRequireWildcard(require('@storybook/mdx2-csf'))) : await Promise.resolve().then(() => _interopRequireWildcard(require('@storybook/mdx1-csf')));
|
|
142
|
-
code = await compile(code, {});
|
|
143
|
-
return (0, _csfTools.loadCsf)(code, Object.assign({}, opts, {
|
|
144
|
-
fileName
|
|
145
|
-
})).parse();
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
return [{
|
|
149
|
-
test: /(stories|story)\.mdx$/,
|
|
150
|
-
indexer: mdxIndexer
|
|
151
|
-
}, ...(indexers || [])];
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
exports.storyIndexers = storyIndexers;
|
package/dist/cjs/preview.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parameters = void 0;
|
|
7
|
-
|
|
8
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
|
|
10
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
-
|
|
12
|
-
const parameters = {
|
|
13
|
-
docs: {
|
|
14
|
-
renderer: async () => {
|
|
15
|
-
const {
|
|
16
|
-
DocsRenderer
|
|
17
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./blocks')));
|
|
18
|
-
return new DocsRenderer();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
exports.parameters = parameters;
|
package/dist/cjs/shared.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SourceType = exports.SNIPPET_RENDERED = exports.PARAM_KEY = exports.PANEL_ID = exports.ADDON_ID = void 0;
|
|
7
|
-
const ADDON_ID = 'storybook/docs';
|
|
8
|
-
exports.ADDON_ID = ADDON_ID;
|
|
9
|
-
const PANEL_ID = `${ADDON_ID}/panel`;
|
|
10
|
-
exports.PANEL_ID = PANEL_ID;
|
|
11
|
-
const PARAM_KEY = `docs`;
|
|
12
|
-
exports.PARAM_KEY = PARAM_KEY;
|
|
13
|
-
const SNIPPET_RENDERED = `${ADDON_ID}/snippet-rendered`;
|
|
14
|
-
exports.SNIPPET_RENDERED = SNIPPET_RENDERED;
|
|
15
|
-
let SourceType;
|
|
16
|
-
exports.SourceType = SourceType;
|
|
17
|
-
|
|
18
|
-
(function (SourceType) {
|
|
19
|
-
SourceType["AUTO"] = "auto";
|
|
20
|
-
SourceType["CODE"] = "code";
|
|
21
|
-
SourceType["DYNAMIC"] = "dynamic";
|
|
22
|
-
})(SourceType || (exports.SourceType = SourceType = {}));
|
package/dist/esm/blocks/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@storybook/blocks';
|
package/dist/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './blocks';
|
package/dist/esm/manager.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { addons, types } from '@storybook/addons';
|
|
2
|
-
import { ADDON_ID, PANEL_ID } from './shared';
|
|
3
|
-
addons.register(ADDON_ID, () => {
|
|
4
|
-
addons.add(PANEL_ID, {
|
|
5
|
-
type: types.TAB,
|
|
6
|
-
title: 'Docs',
|
|
7
|
-
route: ({
|
|
8
|
-
storyId,
|
|
9
|
-
refId
|
|
10
|
-
}) => refId ? `/docs/${refId}_${storyId}` : `/docs/${storyId}`,
|
|
11
|
-
match: ({
|
|
12
|
-
viewMode
|
|
13
|
-
}) => viewMode === 'docs',
|
|
14
|
-
render: () => null
|
|
15
|
-
});
|
|
16
|
-
});
|
package/dist/esm/preset.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import remarkSlug from 'remark-slug';
|
|
3
|
-
import remarkExternalLinks from 'remark-external-links';
|
|
4
|
-
import global from 'global';
|
|
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
|
|
7
|
-
// the jsx to transpile mdx, for now there will be a flag for that
|
|
8
|
-
// for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
|
|
9
|
-
|
|
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'), {
|
|
17
|
-
pragma: 'React.createElement',
|
|
18
|
-
pragmaFrag: 'React.Fragment'
|
|
19
|
-
}];
|
|
20
|
-
const plugins = configureJSX ? [...babelPlugins, jsxPlugin] : babelPlugins;
|
|
21
|
-
return Object.assign({
|
|
22
|
-
// don't use the root babelrc by default (users can override this in mdxBabelOptions)
|
|
23
|
-
babelrc: false,
|
|
24
|
-
configFile: false
|
|
25
|
-
}, babelOptions, mdxBabelOptions, {
|
|
26
|
-
plugins
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
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;
|
|
114
|
-
}
|
|
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
|
-
};
|
package/dist/esm/preview.js
DELETED
package/dist/esm/shared.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
|
|
7
|
-
(function (SourceType) {
|
|
8
|
-
SourceType["AUTO"] = "auto";
|
|
9
|
-
SourceType["CODE"] = "code";
|
|
10
|
-
SourceType["DYNAMIC"] = "dynamic";
|
|
11
|
-
})(SourceType || (SourceType = {}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@storybook/blocks';
|
package/dist/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './blocks';
|
package/dist/types/manager.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/preset.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Options, StoryIndexer } from '@storybook/core-common';
|
|
2
|
-
declare type BabelParams = {
|
|
3
|
-
babelOptions?: any;
|
|
4
|
-
mdxBabelOptions?: any;
|
|
5
|
-
configureJSX?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare function webpack(webpackConfig: any, options: Options & BabelParams & {
|
|
8
|
-
sourceLoaderOptions: any;
|
|
9
|
-
transcludeMarkdown: boolean;
|
|
10
|
-
}): Promise<any>;
|
|
11
|
-
export declare const storyIndexers: (indexers?: StoryIndexer[]) => Promise<StoryIndexer[]>;
|
|
12
|
-
export {};
|
package/dist/types/preview.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const parameters: any;
|
package/dist/types/shared.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare const ADDON_ID = "storybook/docs";
|
|
2
|
-
export declare const PANEL_ID: string;
|
|
3
|
-
export declare const PARAM_KEY = "docs";
|
|
4
|
-
export declare const SNIPPET_RENDERED: string;
|
|
5
|
-
export declare enum SourceType {
|
|
6
|
-
/**
|
|
7
|
-
* AUTO is the default
|
|
8
|
-
*
|
|
9
|
-
* Use the CODE logic if:
|
|
10
|
-
* - the user has set a custom source snippet in `docs.source.code` story parameter
|
|
11
|
-
* - the story is not an args-based story
|
|
12
|
-
*
|
|
13
|
-
* Use the DYNAMIC rendered snippet if the story is an args story
|
|
14
|
-
*/
|
|
15
|
-
AUTO = "auto",
|
|
16
|
-
/**
|
|
17
|
-
* Render the code extracted by source-loader
|
|
18
|
-
*/
|
|
19
|
-
CODE = "code",
|
|
20
|
-
/**
|
|
21
|
-
* Render dynamically-rendered source snippet from the story's virtual DOM (currently React only)
|
|
22
|
-
*/
|
|
23
|
-
DYNAMIC = "dynamic"
|
|
24
|
-
}
|
package/manager.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './dist/esm/manager';
|
package/mdx-compiler-plugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('@storybook/mdx1-csf').createCompiler;
|