@storybook/addon-docs 7.0.0-alpha.47 → 7.0.0-alpha.49
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/DocsRenderer-AJHLT5UG.mjs +1 -0
- package/dist/chunk-HKSD7XQF.mjs +1 -0
- package/dist/chunk-ORIYCP7O.mjs +1 -0
- package/dist/index.d.ts +11 -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/jest-transform-mdx.js +2 -2
- package/package.json +56 -22
- package/preset.js +1 -1
- package/preview.js +1 -1
- package/dist/cjs/DocsRenderer.js +0 -54
- package/dist/cjs/blocks.js +0 -18
- package/dist/cjs/index.js +0 -30
- package/dist/cjs/preset.js +0 -179
- package/dist/cjs/preview.js +0 -22
- package/dist/cjs/shared.js +0 -22
- package/dist/esm/DocsRenderer.js +0 -35
- package/dist/esm/blocks.js +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/preset.js +0 -153
- package/dist/esm/preview.js +0 -10
- package/dist/esm/shared.js +0 -11
- package/dist/types/DocsRenderer.d.ts +0 -8
- package/dist/types/blocks.d.ts +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/preset.d.ts +0 -21
- package/dist/types/preview.d.ts +0 -1
- package/dist/types/shared.d.ts +0 -24
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-ORIYCP7O.mjs";import"./chunk-HKSD7XQF.mjs";export{b as DocsRenderer,a as defaultComponents};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=(a=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(a,{get:(b,c)=>(typeof require!="undefined"?require:b)[c]}):a)(function(a){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+a+'" is not supported')});export{d as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"react";import t from"react-dom";import{components as c}from"@storybook/components";import{Docs as d,CodeOrSourceMdx as i,AnchorMdx as a,HeadersMdx as u}from"@storybook/blocks";import{MDXProvider as M}from"@mdx-js/react";var l={...c,code:i,a,...u},n=class{constructor(){this.render=(o,e,m,s)=>{let p={...l,...e?.components};t.render(r.createElement(M,{components:p},r.createElement(d,{key:Math.random(),context:o,docsParameter:e})),m,s)},this.unmount=o=>{t.unmountComponentAtNode(o)}}};export{l as a,n as b};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from '@storybook/blocks';
|
|
2
|
+
import { Framework } from '@storybook/types';
|
|
3
|
+
import { DocsRenderFunction } from '@storybook/preview-web';
|
|
4
|
+
|
|
5
|
+
declare class DocsRenderer<TFramework extends Framework> {
|
|
6
|
+
render: DocsRenderFunction<TFramework>;
|
|
7
|
+
unmount: (element: HTMLElement) => void;
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { DocsRenderer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var k=Object.create;var i=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var v=(e,o)=>{for(var r in o)i(e,r,{get:o[r],enumerable:!0})},s=(e,o,r,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of w(o))!F.call(e,n)&&n!==r&&i(e,n,{get:()=>o[n],enumerable:!(p=D(o,n))||p.enumerable});return e},c=(e,o,r)=>(s(e,o,"default"),r&&s(r,o,"default")),f=(e,o,r)=>(r=e!=null?k(y(e)):{},s(o||!e||!e.__esModule?i(r,"default",{value:e,enumerable:!0}):r,e)),C=e=>s(i({},"__esModule",{value:!0}),e);var m={};v(m,{DocsRenderer:()=>d});module.exports=C(m);c(m,require("@storybook/blocks"),module.exports);var u=f(require("react")),x=f(require("react-dom")),M=require("@storybook/components"),t=require("@storybook/blocks"),a=require("@mdx-js/react"),T={...M.components,code:t.CodeOrSourceMdx,a:t.AnchorMdx,...t.HeadersMdx},d=class{constructor(){this.render=(o,r,p,n)=>{let l={...T,...r==null?void 0:r.components};x.default.render(u.default.createElement(a.MDXProvider,{components:l},u.default.createElement(t.Docs,{key:Math.random(),context:o,docsParameter:r})),p,n)},this.unmount=o=>{x.default.unmountComponentAtNode(o)}}};0&&(module.exports={DocsRenderer});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as r}from"./chunk-ORIYCP7O.mjs";import"./chunk-HKSD7XQF.mjs";export*from"@storybook/blocks";export{r as DocsRenderer};
|
package/dist/preset.d.ts
ADDED
package/dist/preset.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var O=Object.create;var d=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var h=(e,o)=>{for(var r in o)d(e,r,{get:o[r],enumerable:!0})},g=(e,o,r,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of S(o))!X.call(e,s)&&s!==r&&d(e,s,{get:()=>o[s],enumerable:!(t=L(o,s))||t.enumerable});return e};var i=(e,o,r)=>(r=e!=null?O($(e)):{},g(o||!e||!e.__esModule?d(r,"default",{value:e,enumerable:!0}):r,e)),A=e=>g(d({},"__esModule",{value:!0}),e);var B={};h(B,{docs:()=>v,storyIndexers:()=>q,webpack:()=>j});module.exports=A(B);var x=i(require("fs-extra")),b=i(require("remark-slug")),k=i(require("remark-external-links")),P=require("ts-dedent"),C=require("@storybook/csf-tools");function f({babelOptions:e,mdxBabelOptions:o,configureJSX:r}){let t=(o==null?void 0:o.plugins)||(e==null?void 0:e.plugins)||[],s=t.filter(a=>{let u=Array.isArray(a)?a[0]:a;return typeof u=="string"?!u.includes("plugin-transform-react-jsx"):!0}),n=[require.resolve("@babel/plugin-transform-react-jsx"),{pragma:"React.createElement",pragmaFrag:"React.Fragment"}],l=r?[...s,n]:t;return{babelrc:!1,configFile:!1,...e,...o,plugins:l}}async function F(e={},o){let r=await o.presets.apply("babelLoaderRef"),{module:t={}}=e,{babelOptions:s,mdxBabelOptions:n,configureJSX:l=!0,csfPluginOptions:a={},sourceLoaderOptions:u=null,transcludeMarkdown:I=!1}=o,c={skipCsf:!0,remarkPlugins:[b.default,k.default]};if(u)throw new Error(P.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 p=require.resolve("@storybook/mdx2-csf/loader"),m=t.rules||[];return I&&(m=[...m.filter(w=>{var y;return((y=w.test)==null?void 0:y.toString())!=="/\\.md$/"}),{test:/\.md$/,use:[{loader:r,options:f({babelOptions:s,mdxBabelOptions:n,configureJSX:l})},{loader:p,options:c}]}]),{...e,plugins:[...e.plugins||[],...a?[require("@storybook/csf-plugin").webpack(a)]:[]],module:{...t,rules:[...m,{test:/(stories|story)\.mdx$/,use:[{loader:r,options:f({babelOptions:s,mdxBabelOptions:n,configureJSX:l})},{loader:p,options:{...c,skipCsf:!1}}]},{test:/\.mdx$/,exclude:/(stories|story)\.mdx$/,use:[{loader:r,options:f({babelOptions:s,mdxBabelOptions:n,configureJSX:l})},{loader:p,options:c}]}]}}}var R=e=>[{test:/(stories|story)\.mdx$/,indexer:async(r,t)=>{let s=(await x.default.readFile(r,"utf-8")).toString(),{compile:n}=await import("@storybook/mdx2-csf");return s=await n(s,{}),(0,C.loadCsf)(s,{...t,fileName:r}).parse()}},...e||[]],_=e=>({...e,enabled:!0,defaultName:"Docs",docsPage:!0}),j=F,q=R,v=_;0&&(module.exports={docs,storyIndexers,webpack});
|
package/dist/preset.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as d}from"./chunk-HKSD7XQF.mjs";import g from"fs-extra";import b from"remark-slug";import x from"remark-external-links";import{dedent as O}from"ts-dedent";import{loadCsf as k}from"@storybook/csf-tools";function m({babelOptions:e,mdxBabelOptions:n,configureJSX:r}){let s=n?.plugins||e?.plugins||[],o=s.filter(a=>{let l=Array.isArray(a)?a[0]:a;return typeof l=="string"?!l.includes("plugin-transform-react-jsx"):!0}),t=[d.resolve("@babel/plugin-transform-react-jsx"),{pragma:"React.createElement",pragmaFrag:"React.Fragment"}],i=r?[...o,t]:s;return{babelrc:!1,configFile:!1,...e,...n,plugins:i}}async function P(e={},n){let r=await n.presets.apply("babelLoaderRef"),{module:s={}}=e,{babelOptions:o,mdxBabelOptions:t,configureJSX:i=!0,csfPluginOptions:a={},sourceLoaderOptions:l=null,transcludeMarkdown:f=!1}=n,u={skipCsf:!0,remarkPlugins:[b,x]};if(l)throw new Error(O`
|
|
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=d.resolve("@storybook/mdx2-csf/loader"),p=s.rules||[];return f&&(p=[...p.filter(y=>y.test?.toString()!=="/\\.md$/"),{test:/\.md$/,use:[{loader:r,options:m({babelOptions:o,mdxBabelOptions:t,configureJSX:i})},{loader:c,options:u}]}]),{...e,plugins:[...e.plugins||[],...a?[d("@storybook/csf-plugin").webpack(a)]:[]],module:{...s,rules:[...p,{test:/(stories|story)\.mdx$/,use:[{loader:r,options:m({babelOptions:o,mdxBabelOptions:t,configureJSX:i})},{loader:c,options:{...u,skipCsf:!1}}]},{test:/\.mdx$/,exclude:/(stories|story)\.mdx$/,use:[{loader:r,options:m({babelOptions:o,mdxBabelOptions:t,configureJSX:i})},{loader:c,options:u}]}]}}}var C=e=>[{test:/(stories|story)\.mdx$/,indexer:async(r,s)=>{let o=(await g.readFile(r,"utf-8")).toString(),{compile:t}=await import("@storybook/mdx2-csf");return o=await t(o,{}),k(o,{...s,fileName:r}).parse()}},...e||[]],I=e=>({...e,enabled:!0,defaultName:"Docs",docsPage:!0}),h=P,j=C,A=I;export{A as docs,j as storyIndexers,h as webpack};
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var k=Object.create;var s=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var T=(o,e)=>()=>(o&&(e=o(o=0)),e);var d=(o,e)=>{for(var r in e)s(o,r,{get:e[r],enumerable:!0})},a=(o,e,r,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of F(e))!C.call(o,n)&&n!==r&&s(o,n,{get:()=>e[n],enumerable:!(m=D(e,n))||m.enumerable});return o};var u=(o,e,r)=>(r=o!=null?k(v(o)):{},a(e||!o||!o.__esModule?s(r,"default",{value:o,enumerable:!0}):r,o)),b=o=>a(s({},"__esModule",{value:!0}),o);var l={};d(l,{DocsRenderer:()=>i,defaultComponents:()=>M});var p,c,x,t,y,M,i,w=T(()=>{p=u(require("react")),c=u(require("react-dom")),x=require("@storybook/components"),t=require("@storybook/blocks"),y=require("@mdx-js/react"),M={...x.components,code:t.CodeOrSourceMdx,a:t.AnchorMdx,...t.HeadersMdx},i=class{constructor(){this.render=(e,r,m,n)=>{let f={...M,...r==null?void 0:r.components};c.default.render(p.default.createElement(y.MDXProvider,{components:f},p.default.createElement(t.Docs,{key:Math.random(),context:e,docsParameter:r})),m,n)},this.unmount=e=>{c.default.unmountComponentAtNode(e)}}}});var H={};d(H,{parameters:()=>h});module.exports=b(H);var h={docs:{renderer:async()=>{let{DocsRenderer:o}=await Promise.resolve().then(()=>(w(),l));return new o}}};0&&(module.exports={parameters});
|
package/dist/preview.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-HKSD7XQF.mjs";var r={docs:{renderer:async()=>{let{DocsRenderer:e}=await import("./DocsRenderer-AJHLT5UG.mjs");return new e}}};export{r as parameters};
|
package/jest-transform-mdx.js
CHANGED
|
@@ -2,11 +2,11 @@ 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
|
|
9
|
+
const code = await compile(src, { skipCsf: false });
|
|
10
10
|
const result = dedent`
|
|
11
11
|
/* @jsx mdx */
|
|
12
12
|
import React from 'react'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-docs",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.49",
|
|
4
4
|
"description": "Document component usage and properties in Markdown",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -24,9 +24,44 @@
|
|
|
24
24
|
"url": "https://opencollective.com/storybook"
|
|
25
25
|
},
|
|
26
26
|
"license": "MIT",
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"require": "./dist/index.js",
|
|
30
|
+
"import": "./dist/index.mjs",
|
|
31
|
+
"types": "./dist/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./preview": {
|
|
34
|
+
"require": "./dist/preview.js",
|
|
35
|
+
"import": "./dist/preview.mjs",
|
|
36
|
+
"types": "./dist/preview.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"./preset": {
|
|
39
|
+
"require": "./dist/preset.js",
|
|
40
|
+
"import": "./dist/preset.mjs",
|
|
41
|
+
"types": "./dist/preset.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./dist/preview": {
|
|
44
|
+
"require": "./dist/preview.js",
|
|
45
|
+
"import": "./dist/preview.mjs",
|
|
46
|
+
"types": "./dist/preview.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./dist/preset": {
|
|
49
|
+
"require": "./dist/preset.js",
|
|
50
|
+
"import": "./dist/preset.mjs",
|
|
51
|
+
"types": "./dist/preset.d.ts"
|
|
52
|
+
},
|
|
53
|
+
"./svelte/HOC.svelte": "./svelte/HOC.svelte",
|
|
54
|
+
"./ember": "./ember/index.js",
|
|
55
|
+
"./ember/index.js": "./ember/index.js",
|
|
56
|
+
"./angular": "./angular/index.js",
|
|
57
|
+
"./angular/index.js": "./angular/index.js",
|
|
58
|
+
"./web-components/index.js": "./web-components/index.js",
|
|
59
|
+
"./jest-transform-mdx.js": "./jest-transform-mdx.js",
|
|
60
|
+
"./package.json": "./package.json"
|
|
61
|
+
},
|
|
62
|
+
"main": "dist/index.js",
|
|
63
|
+
"module": "dist/index.mjs",
|
|
64
|
+
"types": "dist/index.d.ts",
|
|
30
65
|
"files": [
|
|
31
66
|
"dist/**/*",
|
|
32
67
|
"angular/**/*",
|
|
@@ -46,29 +81,21 @@
|
|
|
46
81
|
],
|
|
47
82
|
"scripts": {
|
|
48
83
|
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
|
49
|
-
"prep": "
|
|
84
|
+
"prep": "../../../scripts/prepare/bundle.ts"
|
|
50
85
|
},
|
|
51
86
|
"dependencies": {
|
|
52
87
|
"@babel/plugin-transform-react-jsx": "^7.12.12",
|
|
53
88
|
"@jest/transform": "^26.6.2",
|
|
54
89
|
"@mdx-js/react": "^2.1.5",
|
|
55
|
-
"@storybook/
|
|
56
|
-
"@storybook/
|
|
57
|
-
"@storybook/
|
|
58
|
-
"@storybook/
|
|
59
|
-
"@storybook/core-common": "7.0.0-alpha.47",
|
|
60
|
-
"@storybook/core-events": "7.0.0-alpha.47",
|
|
61
|
-
"@storybook/csf-plugin": "7.0.0-alpha.47",
|
|
62
|
-
"@storybook/csf-tools": "7.0.0-alpha.47",
|
|
63
|
-
"@storybook/docs-tools": "7.0.0-alpha.47",
|
|
90
|
+
"@storybook/blocks": "7.0.0-alpha.49",
|
|
91
|
+
"@storybook/components": "7.0.0-alpha.49",
|
|
92
|
+
"@storybook/csf-plugin": "7.0.0-alpha.49",
|
|
93
|
+
"@storybook/csf-tools": "7.0.0-alpha.49",
|
|
64
94
|
"@storybook/mdx2-csf": "next",
|
|
65
|
-
"@storybook/node-logger": "7.0.0-alpha.
|
|
66
|
-
"@storybook/postinstall": "7.0.0-alpha.
|
|
67
|
-
"@storybook/preview-web": "7.0.0-alpha.
|
|
68
|
-
"@storybook/
|
|
69
|
-
"@storybook/theming": "7.0.0-alpha.47",
|
|
70
|
-
"@storybook/types": "7.0.0-alpha.47",
|
|
71
|
-
"dequal": "^2.0.2",
|
|
95
|
+
"@storybook/node-logger": "7.0.0-alpha.49",
|
|
96
|
+
"@storybook/postinstall": "7.0.0-alpha.49",
|
|
97
|
+
"@storybook/preview-web": "7.0.0-alpha.49",
|
|
98
|
+
"@storybook/types": "7.0.0-alpha.49",
|
|
72
99
|
"fs-extra": "^9.0.1",
|
|
73
100
|
"global": "^4.4.0",
|
|
74
101
|
"remark-external-links": "^8.0.0",
|
|
@@ -94,7 +121,14 @@
|
|
|
94
121
|
"publishConfig": {
|
|
95
122
|
"access": "public"
|
|
96
123
|
},
|
|
97
|
-
"
|
|
124
|
+
"bundler": {
|
|
125
|
+
"entries": [
|
|
126
|
+
"./src/index.ts",
|
|
127
|
+
"./src/preset.ts",
|
|
128
|
+
"./src/preview.ts"
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
"gitHead": "d7eb433300cac55d3c7256c8181eb6fd7a47b4c8",
|
|
98
132
|
"storybook": {
|
|
99
133
|
"displayName": "Docs",
|
|
100
134
|
"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 @@
|
|
|
1
|
-
export * from './dist/
|
|
1
|
+
export * from './dist/preview';
|
package/dist/cjs/DocsRenderer.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.defaultComponents = exports.DocsRenderer = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
11
|
-
|
|
12
|
-
var _components = require("@storybook/components");
|
|
13
|
-
|
|
14
|
-
var _blocks = require("@storybook/blocks");
|
|
15
|
-
|
|
16
|
-
var _react2 = require("@mdx-js/react");
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
// TS doesn't like that we export a component with types that it doesn't know about (TS4203)
|
|
21
|
-
const defaultComponents = Object.assign({}, _components.components, {
|
|
22
|
-
code: _blocks.CodeOrSourceMdx,
|
|
23
|
-
a: _blocks.AnchorMdx
|
|
24
|
-
}, _blocks.HeadersMdx);
|
|
25
|
-
exports.defaultComponents = defaultComponents;
|
|
26
|
-
|
|
27
|
-
class DocsRenderer {
|
|
28
|
-
constructor() {
|
|
29
|
-
this.render = void 0;
|
|
30
|
-
this.unmount = void 0;
|
|
31
|
-
|
|
32
|
-
this.render = (context, docsParameter, element, callback) => {
|
|
33
|
-
// Use a random key to force the container to re-render each time we call `renderDocs`
|
|
34
|
-
// TODO: do we still need this? It was needed for angular (legacy) inline rendering:
|
|
35
|
-
// https://github.com/storybookjs/storybook/pull/16149
|
|
36
|
-
const components = Object.assign({}, defaultComponents, docsParameter === null || docsParameter === void 0 ? void 0 : docsParameter.components);
|
|
37
|
-
|
|
38
|
-
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_react2.MDXProvider, {
|
|
39
|
-
components: components
|
|
40
|
-
}, /*#__PURE__*/_react.default.createElement(_blocks.Docs, {
|
|
41
|
-
key: Math.random(),
|
|
42
|
-
context: context,
|
|
43
|
-
docsParameter: docsParameter
|
|
44
|
-
})), element, callback);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
this.unmount = element => {
|
|
48
|
-
_reactDom.default.unmountComponentAtNode(element);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
exports.DocsRenderer = DocsRenderer;
|
package/dist/cjs/blocks.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,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
DocsRenderer: true
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "DocsRenderer", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () {
|
|
12
|
-
return _DocsRenderer.DocsRenderer;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
var _blocks = require("./blocks");
|
|
17
|
-
|
|
18
|
-
Object.keys(_blocks).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
21
|
-
if (key in exports && exports[key] === _blocks[key]) return;
|
|
22
|
-
Object.defineProperty(exports, key, {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () {
|
|
25
|
-
return _blocks[key];
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
var _DocsRenderer = require("./DocsRenderer");
|
package/dist/cjs/preset.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.storyIndexers = exports.docs = 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 _tsDedent = require("ts-dedent");
|
|
16
|
-
|
|
17
|
-
var _csfTools = require("@storybook/csf-tools");
|
|
18
|
-
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
|
-
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); }
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
|
|
25
|
-
function createBabelOptions({
|
|
26
|
-
babelOptions,
|
|
27
|
-
mdxBabelOptions,
|
|
28
|
-
configureJSX
|
|
29
|
-
}) {
|
|
30
|
-
const babelPlugins = (mdxBabelOptions === null || mdxBabelOptions === void 0 ? void 0 : mdxBabelOptions.plugins) || (babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) || [];
|
|
31
|
-
const filteredBabelPlugins = babelPlugins.filter(p => {
|
|
32
|
-
const name = Array.isArray(p) ? p[0] : p;
|
|
33
|
-
|
|
34
|
-
if (typeof name === 'string') {
|
|
35
|
-
return !name.includes('plugin-transform-react-jsx');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return true;
|
|
39
|
-
});
|
|
40
|
-
const jsxPlugin = [require.resolve('@babel/plugin-transform-react-jsx'), {
|
|
41
|
-
pragma: 'React.createElement',
|
|
42
|
-
pragmaFrag: 'React.Fragment'
|
|
43
|
-
}];
|
|
44
|
-
const plugins = configureJSX ? [...filteredBabelPlugins, jsxPlugin] : babelPlugins;
|
|
45
|
-
return Object.assign({
|
|
46
|
-
// don't use the root babelrc by default (users can override this in mdxBabelOptions)
|
|
47
|
-
babelrc: false,
|
|
48
|
-
configFile: false
|
|
49
|
-
}, babelOptions, mdxBabelOptions, {
|
|
50
|
-
plugins
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async function webpack(webpackConfig = {}, options) {
|
|
55
|
-
const resolvedBabelLoader = await options.presets.apply('babelLoaderRef');
|
|
56
|
-
const {
|
|
57
|
-
module = {}
|
|
58
|
-
} = webpackConfig; // it will reuse babel options that are already in use in storybook
|
|
59
|
-
// also, these babel options are chained with other presets.
|
|
60
|
-
|
|
61
|
-
const {
|
|
62
|
-
babelOptions,
|
|
63
|
-
mdxBabelOptions,
|
|
64
|
-
configureJSX = true,
|
|
65
|
-
csfPluginOptions = {},
|
|
66
|
-
sourceLoaderOptions = null,
|
|
67
|
-
transcludeMarkdown = false
|
|
68
|
-
} = options;
|
|
69
|
-
const mdxLoaderOptions = {
|
|
70
|
-
// whether to skip storybook files, useful for docs only mdx or md files
|
|
71
|
-
skipCsf: true,
|
|
72
|
-
remarkPlugins: [_remarkSlug.default, _remarkExternalLinks.default]
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
if (sourceLoaderOptions) {
|
|
76
|
-
throw new Error((0, _tsDedent.dedent)`
|
|
77
|
-
Addon-docs no longer uses source-loader in 7.0.
|
|
78
|
-
|
|
79
|
-
To update your configuration, please see migration instructions here:
|
|
80
|
-
|
|
81
|
-
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#dropped-source-loader--storiesof-static-snippets
|
|
82
|
-
`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const mdxLoader = require.resolve('@storybook/mdx2-csf/loader');
|
|
86
|
-
|
|
87
|
-
let rules = module.rules || [];
|
|
88
|
-
|
|
89
|
-
if (transcludeMarkdown) {
|
|
90
|
-
rules = [...rules.filter(rule => {
|
|
91
|
-
var _rule$test;
|
|
92
|
-
|
|
93
|
-
return ((_rule$test = rule.test) === null || _rule$test === void 0 ? void 0 : _rule$test.toString()) !== '/\\.md$/';
|
|
94
|
-
}), {
|
|
95
|
-
test: /\.md$/,
|
|
96
|
-
use: [{
|
|
97
|
-
loader: resolvedBabelLoader,
|
|
98
|
-
options: createBabelOptions({
|
|
99
|
-
babelOptions,
|
|
100
|
-
mdxBabelOptions,
|
|
101
|
-
configureJSX
|
|
102
|
-
})
|
|
103
|
-
}, {
|
|
104
|
-
loader: mdxLoader,
|
|
105
|
-
options: mdxLoaderOptions
|
|
106
|
-
}]
|
|
107
|
-
}];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const result = Object.assign({}, webpackConfig, {
|
|
111
|
-
plugins: [...(webpackConfig.plugins || []), // eslint-disable-next-line global-require
|
|
112
|
-
...(csfPluginOptions ? [require('@storybook/csf-plugin').webpack(csfPluginOptions)] : [])],
|
|
113
|
-
module: Object.assign({}, module, {
|
|
114
|
-
rules: [...rules, {
|
|
115
|
-
test: /(stories|story)\.mdx$/,
|
|
116
|
-
use: [{
|
|
117
|
-
loader: resolvedBabelLoader,
|
|
118
|
-
options: createBabelOptions({
|
|
119
|
-
babelOptions,
|
|
120
|
-
mdxBabelOptions,
|
|
121
|
-
configureJSX
|
|
122
|
-
})
|
|
123
|
-
}, {
|
|
124
|
-
loader: mdxLoader,
|
|
125
|
-
options: Object.assign({}, mdxLoaderOptions, {
|
|
126
|
-
skipCsf: false
|
|
127
|
-
})
|
|
128
|
-
}]
|
|
129
|
-
}, {
|
|
130
|
-
test: /\.mdx$/,
|
|
131
|
-
exclude: /(stories|story)\.mdx$/,
|
|
132
|
-
use: [{
|
|
133
|
-
loader: resolvedBabelLoader,
|
|
134
|
-
options: createBabelOptions({
|
|
135
|
-
babelOptions,
|
|
136
|
-
mdxBabelOptions,
|
|
137
|
-
configureJSX
|
|
138
|
-
})
|
|
139
|
-
}, {
|
|
140
|
-
loader: mdxLoader,
|
|
141
|
-
options: mdxLoaderOptions
|
|
142
|
-
}]
|
|
143
|
-
}]
|
|
144
|
-
})
|
|
145
|
-
});
|
|
146
|
-
return result;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const storyIndexers = async indexers => {
|
|
150
|
-
const mdxIndexer = async (fileName, opts) => {
|
|
151
|
-
let code = (await _fsExtra.default.readFile(fileName, 'utf-8')).toString(); // @ts-expect-error (Converted from ts-ignore)
|
|
152
|
-
|
|
153
|
-
const {
|
|
154
|
-
compile
|
|
155
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('@storybook/mdx2-csf')));
|
|
156
|
-
code = await compile(code, {});
|
|
157
|
-
return (0, _csfTools.loadCsf)(code, Object.assign({}, opts, {
|
|
158
|
-
fileName
|
|
159
|
-
})).parse();
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
return [{
|
|
163
|
-
test: /(stories|story)\.mdx$/,
|
|
164
|
-
indexer: mdxIndexer,
|
|
165
|
-
addDocsTemplate: true
|
|
166
|
-
}, ...(indexers || [])];
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
exports.storyIndexers = storyIndexers;
|
|
170
|
-
|
|
171
|
-
const docs = docsOptions => {
|
|
172
|
-
return Object.assign({}, docsOptions, {
|
|
173
|
-
enabled: true,
|
|
174
|
-
defaultName: 'Docs',
|
|
175
|
-
docsPage: true
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
exports.docs = docs;
|
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('./DocsRenderer')));
|
|
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/DocsRenderer.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import { components as htmlComponents } from '@storybook/components';
|
|
4
|
-
import { Docs, CodeOrSourceMdx, AnchorMdx, HeadersMdx } from '@storybook/blocks';
|
|
5
|
-
import { MDXProvider } from '@mdx-js/react'; // TS doesn't like that we export a component with types that it doesn't know about (TS4203)
|
|
6
|
-
|
|
7
|
-
export const defaultComponents = Object.assign({}, htmlComponents, {
|
|
8
|
-
code: CodeOrSourceMdx,
|
|
9
|
-
a: AnchorMdx
|
|
10
|
-
}, HeadersMdx);
|
|
11
|
-
export class DocsRenderer {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.render = void 0;
|
|
14
|
-
this.unmount = void 0;
|
|
15
|
-
|
|
16
|
-
this.render = (context, docsParameter, element, callback) => {
|
|
17
|
-
// Use a random key to force the container to re-render each time we call `renderDocs`
|
|
18
|
-
// TODO: do we still need this? It was needed for angular (legacy) inline rendering:
|
|
19
|
-
// https://github.com/storybookjs/storybook/pull/16149
|
|
20
|
-
const components = Object.assign({}, defaultComponents, docsParameter?.components);
|
|
21
|
-
ReactDOM.render( /*#__PURE__*/React.createElement(MDXProvider, {
|
|
22
|
-
components: components
|
|
23
|
-
}, /*#__PURE__*/React.createElement(Docs, {
|
|
24
|
-
key: Math.random(),
|
|
25
|
-
context: context,
|
|
26
|
-
docsParameter: docsParameter
|
|
27
|
-
})), element, callback);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
this.unmount = element => {
|
|
31
|
-
ReactDOM.unmountComponentAtNode(element);
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
package/dist/esm/blocks.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@storybook/blocks';
|
package/dist/esm/index.js
DELETED
package/dist/esm/preset.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import remarkSlug from 'remark-slug';
|
|
3
|
-
import remarkExternalLinks from 'remark-external-links';
|
|
4
|
-
import { dedent } from 'ts-dedent';
|
|
5
|
-
import { loadCsf } from '@storybook/csf-tools'; // for frameworks that are not working with react, we need to configure
|
|
6
|
-
// the jsx to transpile mdx, for now there will be a flag for that
|
|
7
|
-
// for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
|
|
8
|
-
|
|
9
|
-
function createBabelOptions({
|
|
10
|
-
babelOptions,
|
|
11
|
-
mdxBabelOptions,
|
|
12
|
-
configureJSX
|
|
13
|
-
}) {
|
|
14
|
-
const babelPlugins = mdxBabelOptions?.plugins || babelOptions?.plugins || [];
|
|
15
|
-
const filteredBabelPlugins = babelPlugins.filter(p => {
|
|
16
|
-
const name = Array.isArray(p) ? p[0] : p;
|
|
17
|
-
|
|
18
|
-
if (typeof name === 'string') {
|
|
19
|
-
return !name.includes('plugin-transform-react-jsx');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return true;
|
|
23
|
-
});
|
|
24
|
-
const jsxPlugin = [require.resolve('@babel/plugin-transform-react-jsx'), {
|
|
25
|
-
pragma: 'React.createElement',
|
|
26
|
-
pragmaFrag: 'React.Fragment'
|
|
27
|
-
}];
|
|
28
|
-
const plugins = configureJSX ? [...filteredBabelPlugins, jsxPlugin] : babelPlugins;
|
|
29
|
-
return Object.assign({
|
|
30
|
-
// don't use the root babelrc by default (users can override this in mdxBabelOptions)
|
|
31
|
-
babelrc: false,
|
|
32
|
-
configFile: false
|
|
33
|
-
}, babelOptions, mdxBabelOptions, {
|
|
34
|
-
plugins
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export async function webpack(webpackConfig = {}, options) {
|
|
39
|
-
const resolvedBabelLoader = await options.presets.apply('babelLoaderRef');
|
|
40
|
-
const {
|
|
41
|
-
module = {}
|
|
42
|
-
} = webpackConfig; // it will reuse babel options that are already in use in storybook
|
|
43
|
-
// also, these babel options are chained with other presets.
|
|
44
|
-
|
|
45
|
-
const {
|
|
46
|
-
babelOptions,
|
|
47
|
-
mdxBabelOptions,
|
|
48
|
-
configureJSX = true,
|
|
49
|
-
csfPluginOptions = {},
|
|
50
|
-
sourceLoaderOptions = null,
|
|
51
|
-
transcludeMarkdown = false
|
|
52
|
-
} = options;
|
|
53
|
-
const mdxLoaderOptions = {
|
|
54
|
-
// whether to skip storybook files, useful for docs only mdx or md files
|
|
55
|
-
skipCsf: true,
|
|
56
|
-
remarkPlugins: [remarkSlug, remarkExternalLinks]
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
if (sourceLoaderOptions) {
|
|
60
|
-
throw new Error(dedent`
|
|
61
|
-
Addon-docs no longer uses source-loader in 7.0.
|
|
62
|
-
|
|
63
|
-
To update your configuration, please see migration instructions here:
|
|
64
|
-
|
|
65
|
-
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#dropped-source-loader--storiesof-static-snippets
|
|
66
|
-
`);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const mdxLoader = require.resolve('@storybook/mdx2-csf/loader');
|
|
70
|
-
|
|
71
|
-
let rules = module.rules || [];
|
|
72
|
-
|
|
73
|
-
if (transcludeMarkdown) {
|
|
74
|
-
rules = [...rules.filter(rule => rule.test?.toString() !== '/\\.md$/'), {
|
|
75
|
-
test: /\.md$/,
|
|
76
|
-
use: [{
|
|
77
|
-
loader: resolvedBabelLoader,
|
|
78
|
-
options: createBabelOptions({
|
|
79
|
-
babelOptions,
|
|
80
|
-
mdxBabelOptions,
|
|
81
|
-
configureJSX
|
|
82
|
-
})
|
|
83
|
-
}, {
|
|
84
|
-
loader: mdxLoader,
|
|
85
|
-
options: mdxLoaderOptions
|
|
86
|
-
}]
|
|
87
|
-
}];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const result = Object.assign({}, webpackConfig, {
|
|
91
|
-
plugins: [...(webpackConfig.plugins || []), // eslint-disable-next-line global-require
|
|
92
|
-
...(csfPluginOptions ? [require('@storybook/csf-plugin').webpack(csfPluginOptions)] : [])],
|
|
93
|
-
module: Object.assign({}, module, {
|
|
94
|
-
rules: [...rules, {
|
|
95
|
-
test: /(stories|story)\.mdx$/,
|
|
96
|
-
use: [{
|
|
97
|
-
loader: resolvedBabelLoader,
|
|
98
|
-
options: createBabelOptions({
|
|
99
|
-
babelOptions,
|
|
100
|
-
mdxBabelOptions,
|
|
101
|
-
configureJSX
|
|
102
|
-
})
|
|
103
|
-
}, {
|
|
104
|
-
loader: mdxLoader,
|
|
105
|
-
options: Object.assign({}, mdxLoaderOptions, {
|
|
106
|
-
skipCsf: false
|
|
107
|
-
})
|
|
108
|
-
}]
|
|
109
|
-
}, {
|
|
110
|
-
test: /\.mdx$/,
|
|
111
|
-
exclude: /(stories|story)\.mdx$/,
|
|
112
|
-
use: [{
|
|
113
|
-
loader: resolvedBabelLoader,
|
|
114
|
-
options: createBabelOptions({
|
|
115
|
-
babelOptions,
|
|
116
|
-
mdxBabelOptions,
|
|
117
|
-
configureJSX
|
|
118
|
-
})
|
|
119
|
-
}, {
|
|
120
|
-
loader: mdxLoader,
|
|
121
|
-
options: mdxLoaderOptions
|
|
122
|
-
}]
|
|
123
|
-
}]
|
|
124
|
-
})
|
|
125
|
-
});
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
export const storyIndexers = async indexers => {
|
|
129
|
-
const mdxIndexer = async (fileName, opts) => {
|
|
130
|
-
let code = (await fs.readFile(fileName, 'utf-8')).toString(); // @ts-expect-error (Converted from ts-ignore)
|
|
131
|
-
|
|
132
|
-
const {
|
|
133
|
-
compile
|
|
134
|
-
} = await import('@storybook/mdx2-csf');
|
|
135
|
-
code = await compile(code, {});
|
|
136
|
-
return loadCsf(code, Object.assign({}, opts, {
|
|
137
|
-
fileName
|
|
138
|
-
})).parse();
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
return [{
|
|
142
|
-
test: /(stories|story)\.mdx$/,
|
|
143
|
-
indexer: mdxIndexer,
|
|
144
|
-
addDocsTemplate: true
|
|
145
|
-
}, ...(indexers || [])];
|
|
146
|
-
};
|
|
147
|
-
export const docs = docsOptions => {
|
|
148
|
-
return Object.assign({}, docsOptions, {
|
|
149
|
-
enabled: true,
|
|
150
|
-
defaultName: 'Docs',
|
|
151
|
-
docsPage: true
|
|
152
|
-
});
|
|
153
|
-
};
|
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,8 +0,0 @@
|
|
|
1
|
-
import type { AnyFramework } from '@storybook/types';
|
|
2
|
-
import type { DocsRenderFunction } from '@storybook/preview-web';
|
|
3
|
-
export declare const defaultComponents: Record<string, any>;
|
|
4
|
-
export declare class DocsRenderer<TFramework extends AnyFramework> {
|
|
5
|
-
render: DocsRenderFunction<TFramework>;
|
|
6
|
-
unmount: (element: HTMLElement) => void;
|
|
7
|
-
constructor();
|
|
8
|
-
}
|
package/dist/types/blocks.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@storybook/blocks';
|
package/dist/types/index.d.ts
DELETED
package/dist/types/preset.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { CoreCommon_StoryIndexer, DocsOptions, Options } from '@storybook/types';
|
|
2
|
-
import type { CsfPluginOptions } from '@storybook/csf-plugin';
|
|
3
|
-
declare type BabelParams = {
|
|
4
|
-
babelOptions?: any;
|
|
5
|
-
mdxBabelOptions?: any;
|
|
6
|
-
configureJSX?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function webpack(webpackConfig: any, options: Options & BabelParams & {
|
|
9
|
-
/** @deprecated */
|
|
10
|
-
sourceLoaderOptions: any;
|
|
11
|
-
csfPluginOptions: CsfPluginOptions | null;
|
|
12
|
-
transcludeMarkdown: boolean;
|
|
13
|
-
}): Promise<any>;
|
|
14
|
-
export declare const storyIndexers: (indexers: CoreCommon_StoryIndexer[] | null) => Promise<CoreCommon_StoryIndexer[]>;
|
|
15
|
-
export declare const docs: (docsOptions: DocsOptions) => {
|
|
16
|
-
enabled: boolean;
|
|
17
|
-
defaultName: string;
|
|
18
|
-
docsPage: boolean;
|
|
19
|
-
docsMode?: boolean;
|
|
20
|
-
};
|
|
21
|
-
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
|
-
}
|