@storybook/web-components 6.5.9 → 7.0.0-alpha.10
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 +1 -71
- package/dist/chunk-LW7MJT4D.mjs +5 -0
- package/dist/config.d.ts +32 -0
- package/dist/config.js +5 -0
- package/dist/config.mjs +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +5 -0
- package/dist/index.mjs +1 -0
- package/dist/types-7ab3c005.d.ts +17 -0
- package/package.json +36 -37
- package/preview.js +1 -0
- package/bin/build.js +0 -4
- package/bin/index.js +0 -3
- package/dist/cjs/client/customElements.js +0 -56
- package/dist/cjs/client/docs/config.js +0 -32
- package/dist/cjs/client/docs/custom-elements.js +0 -165
- package/dist/cjs/client/docs/prepareForInline.js +0 -96
- package/dist/cjs/client/docs/sourceDecorator.js +0 -63
- package/dist/cjs/client/index.js +0 -148
- package/dist/cjs/client/preview/config.js +0 -19
- package/dist/cjs/client/preview/globals.js +0 -8
- package/dist/cjs/client/preview/index.js +0 -50
- package/dist/cjs/client/preview/render.js +0 -73
- package/dist/cjs/client/preview/types-6-0.js +0 -5
- package/dist/cjs/client/preview/types-7-0.js +0 -5
- package/dist/cjs/client/preview/types.js +0 -5
- package/dist/cjs/server/build.js +0 -9
- package/dist/cjs/server/framework-preset-web-components-docs.js +0 -17
- package/dist/cjs/server/framework-preset-web-components.js +0 -46
- package/dist/cjs/server/index.js +0 -9
- package/dist/cjs/server/options.js +0 -17
- package/dist/cjs/server/preset.js +0 -8
- package/dist/esm/client/customElements.js +0 -41
- package/dist/esm/client/docs/config.js +0 -18
- package/dist/esm/client/docs/custom-elements.js +0 -140
- package/dist/esm/client/docs/prepareForInline.js +0 -74
- package/dist/esm/client/docs/sourceDecorator.js +0 -52
- package/dist/esm/client/index.js +0 -24
- package/dist/esm/client/preview/config.js +0 -4
- package/dist/esm/client/preview/globals.js +0 -3
- package/dist/esm/client/preview/index.js +0 -27
- package/dist/esm/client/preview/render.js +0 -58
- package/dist/esm/client/preview/types-6-0.js +0 -1
- package/dist/esm/client/preview/types-7-0.js +0 -1
- package/dist/esm/client/preview/types.js +0 -1
- package/dist/esm/server/build.js +0 -3
- package/dist/esm/server/framework-preset-web-components-docs.js +0 -6
- package/dist/esm/server/framework-preset-web-components.js +0 -34
- package/dist/esm/server/index.js +0 -3
- package/dist/esm/server/options.js +0 -8
- package/dist/esm/server/preset.js +0 -1
- package/dist/modern/client/customElements.js +0 -42
- package/dist/modern/client/docs/config.js +0 -18
- package/dist/modern/client/docs/custom-elements.js +0 -125
- package/dist/modern/client/docs/prepareForInline.js +0 -23
- package/dist/modern/client/docs/sourceDecorator.js +0 -49
- package/dist/modern/client/index.js +0 -27
- package/dist/modern/client/preview/config.js +0 -4
- package/dist/modern/client/preview/globals.js +0 -5
- package/dist/modern/client/preview/index.js +0 -19
- package/dist/modern/client/preview/render.js +0 -55
- package/dist/modern/client/preview/types-6-0.js +0 -1
- package/dist/modern/client/preview/types-7-0.js +0 -1
- package/dist/modern/client/preview/types.js +0 -1
- package/dist/modern/server/build.js +0 -3
- package/dist/modern/server/framework-preset-web-components-docs.js +0 -6
- package/dist/modern/server/framework-preset-web-components.js +0 -34
- package/dist/modern/server/index.js +0 -3
- package/dist/modern/server/options.js +0 -8
- package/dist/modern/server/preset.js +0 -1
- package/dist/ts3.4/client/customElements.d.ts +0 -8
- package/dist/ts3.4/client/docs/config.d.ts +0 -18
- package/dist/ts3.4/client/docs/custom-elements.d.ts +0 -36
- package/dist/ts3.4/client/docs/prepareForInline.d.ts +0 -4
- package/dist/ts3.4/client/docs/sourceDecorator.d.ts +0 -3
- package/dist/ts3.4/client/index.d.ts +0 -3
- package/dist/ts3.4/client/preview/config.d.ts +0 -4
- package/dist/ts3.4/client/preview/globals.d.ts +0 -1
- package/dist/ts3.4/client/preview/index.d.ts +0 -24
- package/dist/ts3.4/client/preview/render.d.ts +0 -3
- package/dist/ts3.4/client/preview/types-6-0.d.ts +0 -34
- package/dist/ts3.4/client/preview/types-7-0.d.ts +0 -9
- package/dist/ts3.4/client/preview/types.d.ts +0 -16
- package/dist/ts3.4/server/build.d.ts +0 -1
- package/dist/ts3.4/server/framework-preset-web-components-docs.d.ts +0 -2
- package/dist/ts3.4/server/framework-preset-web-components.d.ts +0 -4
- package/dist/ts3.4/server/index.d.ts +0 -1
- package/dist/ts3.4/server/options.d.ts +0 -3
- package/dist/ts3.4/server/preset.d.ts +0 -2
- package/dist/ts3.9/client/customElements.d.ts +0 -8
- package/dist/ts3.9/client/docs/config.d.ts +0 -18
- package/dist/ts3.9/client/docs/custom-elements.d.ts +0 -35
- package/dist/ts3.9/client/docs/prepareForInline.d.ts +0 -4
- package/dist/ts3.9/client/docs/sourceDecorator.d.ts +0 -3
- package/dist/ts3.9/client/index.d.ts +0 -3
- package/dist/ts3.9/client/preview/config.d.ts +0 -4
- package/dist/ts3.9/client/preview/globals.d.ts +0 -1
- package/dist/ts3.9/client/preview/index.d.ts +0 -24
- package/dist/ts3.9/client/preview/render.d.ts +0 -3
- package/dist/ts3.9/client/preview/types-6-0.d.ts +0 -34
- package/dist/ts3.9/client/preview/types-7-0.d.ts +0 -9
- package/dist/ts3.9/client/preview/types.d.ts +0 -16
- package/dist/ts3.9/server/build.d.ts +0 -1
- package/dist/ts3.9/server/framework-preset-web-components-docs.d.ts +0 -2
- package/dist/ts3.9/server/framework-preset-web-components.d.ts +0 -4
- package/dist/ts3.9/server/index.d.ts +0 -1
- package/dist/ts3.9/server/options.d.ts +0 -3
- package/dist/ts3.9/server/preset.d.ts +0 -2
- package/preset.js +0 -1
- package/standalone.js +0 -8
- package/types-6-0.d.ts +0 -1
- package/types-7-0.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,71 +1 @@
|
|
|
1
|
-
# Storybook
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Storybook for web-components is a UI development environment for your plain web-component snippets.
|
|
6
|
-
With it, you can visualize different states of your UI components and develop them interactively.
|
|
7
|
-
|
|
8
|
-

|
|
9
|
-
|
|
10
|
-
Storybook runs outside of your app.
|
|
11
|
-
So you can develop UI components in isolation without worrying about app specific dependencies and requirements.
|
|
12
|
-
|
|
13
|
-
## Getting Started
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
cd my-app
|
|
17
|
-
npx sb init -t web_components
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
For more information visit: [storybook.js.org](https://storybook.js.org)
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
Storybook also comes with a lot of [addons](https://storybook.js.org/addons) and a great API to customize as you wish.
|
|
25
|
-
You can also build a [static version](https://storybook.js.org/docs/web-components/sharing/publish-storybook) of your storybook and deploy it anywhere you want.
|
|
26
|
-
|
|
27
|
-
# Hot Module Reloading (HMR)
|
|
28
|
-
|
|
29
|
-
As web components register on a global registry which only accepts a certain name/class once it can lead to errors when using classical HMR. There are ideas on how to archive HMR with a static registry but there is no proven solution yet. Therefore the best approach for now is to do full page reloads. If you keep your stories to specific states of components (which we would recommend anyways) this usually means it is fast.
|
|
30
|
-
|
|
31
|
-
# Setup es6/7 dependencies
|
|
32
|
-
|
|
33
|
-
By default storybook only works with precompiled ES5 code but as most web components themselves and their libs are distributed as ES2017 you will need to manually mark those packages as "needs transpilation".
|
|
34
|
-
|
|
35
|
-
For example if you have a library called `my-library` which is in ES2017 then you can add it like so
|
|
36
|
-
|
|
37
|
-
```js
|
|
38
|
-
// .storybook/main.js
|
|
39
|
-
|
|
40
|
-
module.exports = {
|
|
41
|
-
webpackFinal: async (config) => {
|
|
42
|
-
// find web-components rule for extra transpilation
|
|
43
|
-
const webComponentsRule = config.module.rules.find(
|
|
44
|
-
(rule) => rule.use && rule.use.options && rule.use.options.babelrc === false
|
|
45
|
-
);
|
|
46
|
-
// add your own `my-library`
|
|
47
|
-
webComponentsRule.test.push(new RegExp(`node_modules(\\/|\\\\)my-library(.*)\\.js$`));
|
|
48
|
-
|
|
49
|
-
return config;
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
By default the following folders are included
|
|
55
|
-
|
|
56
|
-
- `src/*.js`
|
|
57
|
-
- `packages/*/src/*.js`
|
|
58
|
-
- `node_modules/lit-html/*.js`
|
|
59
|
-
- `node_modules/lit-element/*.js`
|
|
60
|
-
- `node_modules/@open-wc/*.js`
|
|
61
|
-
- `node_modules/@polymer/*.js`
|
|
62
|
-
- `node_modules/@vaadin/*.js`
|
|
63
|
-
|
|
64
|
-
As you can see the `src` folder is also included.
|
|
65
|
-
The reason for that is as it has some extra configuration to allow for example `import.meta`.
|
|
66
|
-
If you use a different folder you will need to make sure webpack/babel can handle it.
|
|
67
|
-
|
|
68
|
-
# FAQ
|
|
69
|
-
|
|
70
|
-
- While working on my component I get the error `Failed to execute 'define' on 'CustomElementRegistry': the name "..." has already been used with this registry`
|
|
71
|
-
=> please see <a href="#user-content-setup-page-reload-via-hmr">Setup page reload via HMR</a>
|
|
1
|
+
# Storybook web-components renderer
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var u=Object.defineProperty;var f=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var l=(e,o,r)=>o in e?u(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,v=(e,o)=>{for(var r in o||(o={}))M.call(o,r)&&l(e,r,o[r]);if(f)for(var r of f(o))S.call(o,r)&&l(e,r,o[r]);return e};var t=(e,o)=>u(e,"name",{value:o,configurable:!0});import R from"global";import g from"global";var{window:x}=g;x.STORYBOOK_ENV="web-components";import{start as L}from"@storybook/core-client";import y from"global";import h from"ts-dedent";import{render as A}from"lit-html";import{isTemplateResult as E}from"lit-html/directive-helpers.js";import{simulatePageLoad as m,simulateDOMContentLoaded as b}from"@storybook/preview-web";var{Node:C}=y;function _({storyFn:e,kind:o,name:r,showMain:p,showError:w,forceRemount:c},n){let s=e();if(p(),E(s)){(c||!n.querySelector('[id="root-inner"]'))&&(n.innerHTML='<div id="root-inner"></div>');let T=n.querySelector('[id="root-inner"]');A(s,T),m(n)}else if(typeof s=="string")n.innerHTML=s,m(n);else if(s instanceof C){if(n.firstChild===s&&!c)return;n.innerHTML="",n.appendChild(s),b()}else w({title:`Expecting an HTML snippet or DOM node from the story: "${r}" of "${o}".`,description:h`
|
|
2
|
+
Did you forget to return the HTML snippet from the story?
|
|
3
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
4
|
+
`})}t(_,"renderToDOM");var O="web-components",i=L(_),I=t((e,o)=>i.clientApi.storiesOf(e,o).addParameters({framework:O}),"storiesOf"),W=t((...e)=>i.configure(O,...e),"configure"),$=i.clientApi.addDecorator,j=i.clientApi.addParameters,J=i.clientApi.clearDecorators,z=i.clientApi.setAddon,G=i.forceReRender,Q=i.clientApi.getStorybook,X=i.clientApi.raw;function ee(e){if(!e)return!1;if(typeof e=="string")return!0;throw new Error('Provided component needs to be a string. e.g. component: "my-element"')}t(ee,"isValidComponent");function oe(e){if(!e)return!1;if(e.tags&&Array.isArray(e.tags)||e.modules&&Array.isArray(e.modules))return!0;throw new Error(`You need to setup valid meta data in your config.js via setCustomElements().
|
|
5
|
+
See the readme of addon-docs for web components for more details.`)}t(oe,"isValidMetaData");function re(e){window.__STORYBOOK_CUSTOM_ELEMENTS__=e}t(re,"setCustomElements");function te(e){window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__=e}t(te,"setCustomElementsManifest");function ne(){return window.__STORYBOOK_CUSTOM_ELEMENTS__||window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__}t(ne,"getCustomElements");var{window:D,EventSource:N}=R;module&&module.hot&&module.hot.decline&&(module.hot.decline(),new N("__webpack_hmr").addEventListener("message",t(function(r){try{let{action:p}=JSON.parse(r.data);p==="built"&&D.location.reload()}catch{}},"fullPageReload")));export{v as a,t as b,_ as c,I as d,W as e,$ as f,j as g,J as h,z as i,G as j,Q as k,X as l,ee as m,oe as n,re as o,te as p,ne as q};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as lib_docs_tools_dist_types from 'lib/docs-tools/dist/types';
|
|
2
|
+
import * as lib_api_dist_types from 'lib/api/dist/types';
|
|
3
|
+
import * as lib_addons_dist_types from 'lib/addons/dist/types';
|
|
4
|
+
import * as _storybook_csf from '@storybook/csf';
|
|
5
|
+
import { PartialStoryFn, StoryContext } from '@storybook/csf';
|
|
6
|
+
import { W as WebComponentsFramework } from './types-7ab3c005.js';
|
|
7
|
+
import { RenderContext } from '@storybook/store';
|
|
8
|
+
import 'lit-html';
|
|
9
|
+
|
|
10
|
+
declare function sourceDecorator(storyFn: PartialStoryFn<WebComponentsFramework>, context: StoryContext<WebComponentsFramework>): WebComponentsFramework['storyResult'];
|
|
11
|
+
|
|
12
|
+
declare const decorators: (typeof sourceDecorator)[];
|
|
13
|
+
declare const argTypesEnhancers: (<TFramework extends _storybook_csf.AnyFramework>(context: _storybook_csf.StoryContextForEnhancers<TFramework, _storybook_csf.Args>) => _storybook_csf.StrictArgTypes<_storybook_csf.Args> | lib_addons_dist_types.Parameters)[];
|
|
14
|
+
|
|
15
|
+
declare function renderToDOM({ storyFn, kind, name, showMain, showError, forceRemount }: RenderContext<WebComponentsFramework>, domElement: Element): void;
|
|
16
|
+
|
|
17
|
+
declare const parameters: {
|
|
18
|
+
docs: {
|
|
19
|
+
extractArgTypes: (tagName: string) => {
|
|
20
|
+
[x: string]: lib_api_dist_types.ArgType;
|
|
21
|
+
};
|
|
22
|
+
extractComponentDescription: (tagName: string) => string;
|
|
23
|
+
inlineStories: boolean;
|
|
24
|
+
source: {
|
|
25
|
+
type: lib_docs_tools_dist_types.SourceType;
|
|
26
|
+
language: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
framework: "web-components";
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { argTypesEnhancers, decorators, parameters, renderToDOM };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var j=Object.create;var l=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames,D=Object.getOwnPropertySymbols,J=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var C=(e,r,o)=>r in e?l(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,i=(e,r)=>{for(var o in r||(r={}))A.call(r,o)&&C(e,o,r[o]);if(D)for(var o of D(r))X.call(r,o)&&C(e,o,r[o]);return e};var s=(e,r)=>l(e,"name",{value:r,configurable:!0});var Z=(e,r)=>{for(var o in r)l(e,o,{get:r[o],enumerable:!0})},E=(e,r,o,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of W(r))!A.call(e,n)&&n!==o&&l(e,n,{get:()=>r[n],enumerable:!(t=q(r,n))||t.enumerable});return e};var T=(e,r,o)=>(o=e!=null?j(J(e)):{},E(r||!e||!e.__esModule?l(o,"default",{value:e,enumerable:!0}):o,e)),z=e=>E(l({},"__esModule",{value:!0}),e);var de={};Z(de,{argTypesEnhancers:()=>B,decorators:()=>H,parameters:()=>ce,renderToDOM:()=>g});module.exports=z(de);var S=require("@storybook/docs-tools");var h=require("@storybook/client-logger");var k=T(require("global"));var b=T(require("global")),{window:G}=b.default;G.STORYBOOK_ENV="web-components";var N=require("@storybook/core-client");var x=T(require("global")),R=T(require("ts-dedent")),v=require("lit-html"),L=require("lit-html/directive-helpers.js"),m=require("@storybook/preview-web"),{Node:Q}=x.default;function g({storyFn:e,kind:r,name:o,showMain:t,showError:n,forceRemount:c},a){let d=e();if(t(),(0,L.isTemplateResult)(d)){(c||!a.querySelector('[id="root-inner"]'))&&(a.innerHTML='<div id="root-inner"></div>');let F=a.querySelector('[id="root-inner"]');(0,v.render)(d,F),(0,m.simulatePageLoad)(a)}else if(typeof d=="string")a.innerHTML=d,(0,m.simulatePageLoad)(a);else if(d instanceof Q){if(a.firstChild===d&&!c)return;a.innerHTML="",a.appendChild(d),(0,m.simulateDOMContentLoaded)()}else n({title:`Expecting an HTML snippet or DOM node from the story: "${o}" of "${r}".`,description:R.default`
|
|
2
|
+
Did you forget to return the HTML snippet from the story?
|
|
3
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
4
|
+
`})}s(g,"renderToDOM");var f=(0,N.start)(g);var me=f.clientApi.addDecorator,ye=f.clientApi.addParameters,Te=f.clientApi.clearDecorators,ge=f.clientApi.setAddon,we=f.forceReRender,Se=f.clientApi.getStorybook,_e=f.clientApi.raw;function _(e){if(!e)return!1;if(typeof e=="string")return!0;throw new Error('Provided component needs to be a string. e.g. component: "my-element"')}s(_,"isValidComponent");function M(e){if(!e)return!1;if(e.tags&&Array.isArray(e.tags)||e.modules&&Array.isArray(e.modules))return!0;throw new Error(`You need to setup valid meta data in your config.js via setCustomElements().
|
|
5
|
+
See the readme of addon-docs for web components for more details.`)}s(M,"isValidMetaData");function O(){return window.__STORYBOOK_CUSTOM_ELEMENTS__||window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__}s(O,"getCustomElements");var{window:ee,EventSource:re}=k.default;module&&module.hot&&module.hot.decline&&(module.hot.decline(),new re("__webpack_hmr").addEventListener("message",s(function(o){try{let{action:t}=JSON.parse(o.data);t==="built"&&ee.location.reload()}catch{}},"fullPageReload")));function U(e,r){var t,n;let o=r==="properties"?{name:((t=e.type)==null?void 0:t.text)||e.type}:{name:"void"};return{name:e.name,required:!1,description:e.description,type:o,table:{category:r,type:{summary:((n=e.type)==null?void 0:n.text)||e.type},defaultValue:{summary:e.default!==void 0?e.default:e.defaultValue}}}}s(U,"mapItem");function oe(e){let r=e.name.replace(/(-|_|:|\.|\s)+(.)?/g,(o,t,n)=>n?n.toUpperCase():"").replace(/^([A-Z])/,o=>o.toLowerCase());return r=`on${r.charAt(0).toUpperCase()+r.substr(1)}`,[{name:r,action:{name:e.name},table:{disable:!0}},U(e,"events")]}s(oe,"mapEvent");function u(e,r){return e&&e.filter(o=>o&&o.name).reduce((o,t)=>{if(t.kind==="method")return o;switch(r){case"events":oe(t).forEach(n=>{o[n.name]=n});break;default:o[t.name]=U(t,r);break}return o},{})}s(u,"mapData");var te=s((e,r)=>{if(!_(e)||!M(r))return null;let o=r.tags.find(t=>t.name.toUpperCase()===e.toUpperCase());return o||h.logger.warn(`Component not found in custom-elements.json: ${e}`),o},"getMetaDataExperimental"),ne=s((e,r)=>{var t;if(!_(e)||!M(r))return null;let o;return(t=r==null?void 0:r.modules)==null||t.forEach(n=>{var c;(c=n==null?void 0:n.declarations)==null||c.forEach(a=>{a.tagName===e&&(o=a)})}),o||h.logger.warn(`Component not found in custom-elements.json: ${e}`),o},"getMetaDataV1"),I=s((e,r)=>(r==null?void 0:r.version)==="experimental"?te(e,r):ne(e,r),"getMetaData"),se=s((e,r)=>{let o=I(e,r);return o&&i(i(i(i(i(i(i({},u(o.attributes,"attributes")),u(o.members,"properties")),u(o.properties,"properties")),u(o.events,"events")),u(o.slots,"slots")),u(o.cssProperties,"css custom properties")),u(o.cssParts,"css shadow parts"))},"extractArgTypesFromElements"),V=s(e=>{let r=O();return se(e,r)},"extractArgTypes"),Y=s(e=>{let r=I(e,O());return r&&r.description},"extractComponentDescription");var P=require("lit-html"),w=require("@storybook/addons"),y=require("@storybook/docs-tools"),ae=/<!--\?lit\$[0-9]+\$-->|<!--\??-->/g;function ie(e){var t;let r=(t=e==null?void 0:e.parameters.docs)==null?void 0:t.source,o=e==null?void 0:e.parameters.__isArgsStory;return(r==null?void 0:r.type)===y.SourceType.DYNAMIC?!1:!o||(r==null?void 0:r.code)||(r==null?void 0:r.type)===y.SourceType.CODE}s(ie,"skipSourceRender");function pe(e,r){let{transformSource:o}=r.parameters.docs??{};return typeof o!="function"?e:o(e,r)}s(pe,"applyTransformSource");function $(e,r){var n,c;let o=(c=(n=r==null?void 0:r.parameters.docs)==null?void 0:n.source)!=null&&c.excludeDecorators?r.originalStoryFn(r.args,r):e(),t;if((0,w.useEffect)(()=>{t&&w.addons.getChannel().emit(y.SNIPPET_RENDERED,r.id,t)}),!ie(r)){let a=window.document.createElement("div");(0,P.render)(o,a),t=pe(a.innerHTML.replace(ae,""),r)}return o}s($,"sourceDecorator");var H=[$],K={docs:{extractArgTypes:V,extractComponentDescription:Y,inlineStories:!0,source:{type:S.SourceType.DYNAMIC,language:"html"}}},B=[S.enhanceArgTypes];var ce=i({framework:"web-components"},K);0&&(module.exports={argTypesEnhancers,decorators,parameters,renderToDOM});
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b as s,c as b,m as c,n as f,q as d}from"./chunk-LW7MJT4D.mjs";import{SourceType as _,enhanceArgTypes as L}from"@storybook/docs-tools";import{logger as y}from"@storybook/client-logger";function D(e,r){var o,n;let t=r==="properties"?{name:((o=e.type)==null?void 0:o.text)||e.type}:{name:"void"};return{name:e.name,required:!1,description:e.description,type:t,table:{category:r,type:{summary:((n=e.type)==null?void 0:n.text)||e.type},defaultValue:{summary:e.default!==void 0?e.default:e.defaultValue}}}}s(D,"mapItem");function A(e){let r=e.name.replace(/(-|_|:|\.|\s)+(.)?/g,(t,o,n)=>n?n.toUpperCase():"").replace(/^([A-Z])/,t=>t.toLowerCase());return r=`on${r.charAt(0).toUpperCase()+r.substr(1)}`,[{name:r,action:{name:e.name},table:{disable:!0}},D(e,"events")]}s(A,"mapEvent");function p(e,r){return e&&e.filter(t=>t&&t.name).reduce((t,o)=>{if(o.kind==="method")return t;switch(r){case"events":A(o).forEach(n=>{t[n.name]=n});break;default:t[o.name]=D(o,r);break}return t},{})}s(p,"mapData");var M=s((e,r)=>{if(!c(e)||!f(r))return null;let t=r.tags.find(o=>o.name.toUpperCase()===e.toUpperCase());return t||y.warn(`Component not found in custom-elements.json: ${e}`),t},"getMetaDataExperimental"),w=s((e,r)=>{var o;if(!c(e)||!f(r))return null;let t;return(o=r==null?void 0:r.modules)==null||o.forEach(n=>{var i;(i=n==null?void 0:n.declarations)==null||i.forEach(u=>{u.tagName===e&&(t=u)})}),t||y.warn(`Component not found in custom-elements.json: ${e}`),t},"getMetaDataV1"),C=s((e,r)=>(r==null?void 0:r.version)==="experimental"?M(e,r):w(e,r),"getMetaData"),v=s((e,r)=>{let t=C(e,r);return t&&a(a(a(a(a(a(a({},p(t.attributes,"attributes")),p(t.members,"properties")),p(t.properties,"properties")),p(t.events,"events")),p(t.slots,"slots")),p(t.cssProperties,"css custom properties")),p(t.cssParts,"css shadow parts"))},"extractArgTypesFromElements"),g=s(e=>{let r=d();return v(e,r)},"extractArgTypes"),E=s(e=>{let r=C(e,d());return r&&r.description},"extractComponentDescription");import{render as I}from"lit-html";import{addons as k,useEffect as V}from"@storybook/addons";import{SNIPPET_RENDERED as $,SourceType as S}from"@storybook/docs-tools";var O=/<!--\?lit\$[0-9]+\$-->|<!--\??-->/g;function R(e){var o;let r=(o=e==null?void 0:e.parameters.docs)==null?void 0:o.source,t=e==null?void 0:e.parameters.__isArgsStory;return(r==null?void 0:r.type)===S.DYNAMIC?!1:!t||(r==null?void 0:r.code)||(r==null?void 0:r.type)===S.CODE}s(R,"skipSourceRender");function U(e,r){let{transformSource:t}=r.parameters.docs??{};return typeof t!="function"?e:t(e,r)}s(U,"applyTransformSource");function T(e,r){var n,i;let t=(i=(n=r==null?void 0:r.parameters.docs)==null?void 0:n.source)!=null&&i.excludeDecorators?r.originalStoryFn(r.args,r):e(),o;if(V(()=>{o&&k.getChannel().emit($,r.id,o)}),!R(r)){let u=window.document.createElement("div");I(t,u),o=U(u.innerHTML.replace(O,""),r)}return t}s(T,"sourceDecorator");var j=[T],h={docs:{extractArgTypes:g,extractComponentDescription:E,inlineStories:!0,source:{type:_.DYNAMIC,language:"html"}}},F=[L];var K=a({framework:"web-components"},h);export{F as argTypesEnhancers,j as decorators,K as parameters,b as renderToDOM};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations } from '@storybook/csf';
|
|
2
|
+
import { W as WebComponentsFramework, I as IStorybookSection } from './types-7ab3c005.js';
|
|
3
|
+
import { ClientStoryApi, Loadable } from '@storybook/addons';
|
|
4
|
+
import 'lit-html';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Metadata to configure the stories for a component.
|
|
8
|
+
*
|
|
9
|
+
* @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
|
|
10
|
+
*/
|
|
11
|
+
declare type Meta<TArgs = Args> = ComponentAnnotations<WebComponentsFramework, TArgs>;
|
|
12
|
+
/**
|
|
13
|
+
* Story function that represents a CSFv2 component example.
|
|
14
|
+
*
|
|
15
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
16
|
+
*/
|
|
17
|
+
declare type StoryFn<TArgs = Args> = AnnotatedStoryFn<WebComponentsFramework, TArgs>;
|
|
18
|
+
/**
|
|
19
|
+
* Story function that represents a CSFv3 component example.
|
|
20
|
+
*
|
|
21
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
22
|
+
*/
|
|
23
|
+
declare type StoryObj<TArgs = Args> = StoryAnnotations<WebComponentsFramework, TArgs>;
|
|
24
|
+
/**
|
|
25
|
+
* Story function that represents a CSFv3 component example.
|
|
26
|
+
*
|
|
27
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
28
|
+
*/
|
|
29
|
+
declare type Story<TArgs = Args> = StoryObj<TArgs>;
|
|
30
|
+
|
|
31
|
+
interface ClientApi extends ClientStoryApi<WebComponentsFramework['storyResult']> {
|
|
32
|
+
setAddon(addon: any): void;
|
|
33
|
+
configure(loader: Loadable, module: NodeModule): void;
|
|
34
|
+
getStorybook(): IStorybookSection[];
|
|
35
|
+
clearDecorators(): void;
|
|
36
|
+
forceReRender(): void;
|
|
37
|
+
raw: () => any;
|
|
38
|
+
}
|
|
39
|
+
declare const storiesOf: ClientApi['storiesOf'];
|
|
40
|
+
declare const configure: ClientApi['configure'];
|
|
41
|
+
declare const addDecorator: ClientApi['addDecorator'];
|
|
42
|
+
declare const addParameters: ClientApi['addParameters'];
|
|
43
|
+
declare const clearDecorators: ClientApi['clearDecorators'];
|
|
44
|
+
declare const setAddon: ClientApi['setAddon'];
|
|
45
|
+
declare const forceReRender: ClientApi['forceReRender'];
|
|
46
|
+
declare const getStorybook: ClientApi['getStorybook'];
|
|
47
|
+
declare const raw: ClientApi['raw'];
|
|
48
|
+
|
|
49
|
+
declare function isValidComponent(tagName: string): boolean;
|
|
50
|
+
declare function isValidMetaData(customElements: any): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* @param customElements any for now as spec is not super stable yet
|
|
53
|
+
*/
|
|
54
|
+
declare function setCustomElements(customElements: any): void;
|
|
55
|
+
declare function setCustomElementsManifest(customElements: any): void;
|
|
56
|
+
declare function getCustomElements(): any;
|
|
57
|
+
|
|
58
|
+
export { Meta, Story, StoryFn, StoryObj, addDecorator, addParameters, clearDecorators, configure, forceReRender, getCustomElements, getStorybook, isValidComponent, isValidMetaData, raw, setAddon, setCustomElements, setCustomElementsManifest, storiesOf };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var A=Object.create;var p=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var r=(e,o)=>p(e,"name",{value:o,configurable:!0});var R=(e,o)=>{for(var t in o)p(e,t,{get:o[t],enumerable:!0})},m=(e,o,t,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of b(o))!L.call(e,a)&&a!==t&&p(e,a,{get:()=>o[a],enumerable:!(s=E(o,a))||s.enumerable});return e};var l=(e,o,t)=>(t=e!=null?A(C(e)):{},m(o||!e||!e.__esModule?p(t,"default",{value:e,enumerable:!0}):t,e)),D=e=>m(p({},"__esModule",{value:!0}),e);var G={};R(G,{addDecorator:()=>Y,addParameters:()=>B,clearDecorators:()=>H,configure:()=>P,forceReRender:()=>k,getCustomElements:()=>j,getStorybook:()=>F,isValidComponent:()=>q,isValidMetaData:()=>I,raw:()=>V,setAddon:()=>U,setCustomElements:()=>W,setCustomElementsManifest:()=>$,storiesOf:()=>K});module.exports=D(G);var y=l(require("global"));var _=l(require("global")),{window:N}=_.default;N.STORYBOOK_ENV="web-components";var g=require("@storybook/core-client");var O=l(require("global")),w=l(require("ts-dedent")),T=require("lit-html"),M=require("lit-html/directive-helpers.js"),f=require("@storybook/preview-web"),{Node:v}=O.default;function S({storyFn:e,kind:o,name:t,showMain:s,showError:a,forceRemount:u},n){let d=e();if(s(),(0,M.isTemplateResult)(d)){(u||!n.querySelector('[id="root-inner"]'))&&(n.innerHTML='<div id="root-inner"></div>');let h=n.querySelector('[id="root-inner"]');(0,T.render)(d,h),(0,f.simulatePageLoad)(n)}else if(typeof d=="string")n.innerHTML=d,(0,f.simulatePageLoad)(n);else if(d instanceof v){if(n.firstChild===d&&!u)return;n.innerHTML="",n.appendChild(d),(0,f.simulateDOMContentLoaded)()}else a({title:`Expecting an HTML snippet or DOM node from the story: "${t}" of "${o}".`,description:w.default`
|
|
2
|
+
Did you forget to return the HTML snippet from the story?
|
|
3
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
4
|
+
`})}r(S,"renderToDOM");var x="web-components",i=(0,g.start)(S),K=r((e,o)=>i.clientApi.storiesOf(e,o).addParameters({framework:x}),"storiesOf"),P=r((...e)=>i.configure(x,...e),"configure"),Y=i.clientApi.addDecorator,B=i.clientApi.addParameters,H=i.clientApi.clearDecorators,U=i.clientApi.setAddon,k=i.forceReRender,F=i.clientApi.getStorybook,V=i.clientApi.raw;function q(e){if(!e)return!1;if(typeof e=="string")return!0;throw new Error('Provided component needs to be a string. e.g. component: "my-element"')}r(q,"isValidComponent");function I(e){if(!e)return!1;if(e.tags&&Array.isArray(e.tags)||e.modules&&Array.isArray(e.modules))return!0;throw new Error(`You need to setup valid meta data in your config.js via setCustomElements().
|
|
5
|
+
See the readme of addon-docs for web components for more details.`)}r(I,"isValidMetaData");function W(e){window.__STORYBOOK_CUSTOM_ELEMENTS__=e}r(W,"setCustomElements");function $(e){window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__=e}r($,"setCustomElementsManifest");function j(){return window.__STORYBOOK_CUSTOM_ELEMENTS__||window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__}r(j,"getCustomElements");var{window:J,EventSource:z}=y.default;module&&module.hot&&module.hot.decline&&(module.hot.decline(),new z("__webpack_hmr").addEventListener("message",r(function(t){try{let{action:s}=JSON.parse(t.data);s==="built"&&J.location.reload()}catch{}},"fullPageReload")));0&&(module.exports={addDecorator,addParameters,clearDecorators,configure,forceReRender,getCustomElements,getStorybook,isValidComponent,isValidMetaData,raw,setAddon,setCustomElements,setCustomElementsManifest,storiesOf});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i,m as j,n as k,o as l,p as m,q as n}from"./chunk-LW7MJT4D.mjs";export{c as addDecorator,d as addParameters,e as clearDecorators,b as configure,g as forceReRender,n as getCustomElements,h as getStorybook,j as isValidComponent,k as isValidMetaData,i as raw,f as setAddon,l as setCustomElements,m as setCustomElementsManifest,a as storiesOf};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TemplateResult, SVGTemplateResult } from 'lit-html';
|
|
2
|
+
|
|
3
|
+
declare type StoryFnHtmlReturnType = string | Node | TemplateResult | SVGTemplateResult;
|
|
4
|
+
declare type WebComponentsFramework = {
|
|
5
|
+
component: string;
|
|
6
|
+
storyResult: StoryFnHtmlReturnType;
|
|
7
|
+
};
|
|
8
|
+
interface IStorybookStory {
|
|
9
|
+
name: string;
|
|
10
|
+
render: (context: any) => any;
|
|
11
|
+
}
|
|
12
|
+
interface IStorybookSection {
|
|
13
|
+
kind: string;
|
|
14
|
+
stories: IStorybookStory[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { IStorybookSection as I, WebComponentsFramework as W };
|
package/package.json
CHANGED
|
@@ -1,76 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/web-components",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Storybook
|
|
3
|
+
"version": "7.0.0-alpha.10",
|
|
4
|
+
"description": "Storybook web-components renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lit-html",
|
|
7
7
|
"storybook",
|
|
8
8
|
"web-components"
|
|
9
9
|
],
|
|
10
|
-
"homepage": "https://github.com/storybookjs/storybook/tree/main/
|
|
10
|
+
"homepage": "https://github.com/storybookjs/storybook/tree/main/renderers/web-components",
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/storybookjs/storybook/issues"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/storybookjs/storybook.git",
|
|
17
|
-
"directory": "
|
|
17
|
+
"directory": "renderers/web-components"
|
|
18
18
|
},
|
|
19
19
|
"funding": {
|
|
20
20
|
"type": "opencollective",
|
|
21
21
|
"url": "https://opencollective.com/storybook"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"require": "./dist/index.js",
|
|
27
|
+
"import": "./dist/index.mjs",
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./preview": {
|
|
31
|
+
"require": "./dist/config.js",
|
|
32
|
+
"import": "./dist/config.mjs",
|
|
33
|
+
"types": "./dist/config.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": {
|
|
36
|
+
"require": "./package.json",
|
|
37
|
+
"import": "./package.json",
|
|
38
|
+
"types": "./package.json"
|
|
32
39
|
}
|
|
33
40
|
},
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"storybook-server": "./bin/index.js"
|
|
38
|
-
},
|
|
41
|
+
"main": "dist/index.js",
|
|
42
|
+
"module": "dist/index.mjs",
|
|
43
|
+
"types": "dist/index.d.ts",
|
|
39
44
|
"files": [
|
|
40
|
-
"bin/**/*",
|
|
41
45
|
"dist/**/*",
|
|
42
46
|
"README.md",
|
|
43
47
|
"*.js",
|
|
44
48
|
"*.d.ts"
|
|
45
49
|
],
|
|
46
50
|
"scripts": {
|
|
47
|
-
"prepare": "
|
|
51
|
+
"prepare": "esrun ../../scripts/prepare/bundle.ts"
|
|
48
52
|
},
|
|
49
53
|
"dependencies": {
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@storybook/
|
|
54
|
-
"@storybook/client-api": "6.5.9",
|
|
55
|
-
"@storybook/client-logger": "6.5.9",
|
|
56
|
-
"@storybook/core": "6.5.9",
|
|
57
|
-
"@storybook/core-common": "6.5.9",
|
|
54
|
+
"@storybook/addons": "7.0.0-alpha.10",
|
|
55
|
+
"@storybook/api": "7.0.0-alpha.10",
|
|
56
|
+
"@storybook/client-logger": "7.0.0-alpha.10",
|
|
57
|
+
"@storybook/core-client": "7.0.0-alpha.10",
|
|
58
58
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
59
|
-
"@storybook/docs-tools": "
|
|
60
|
-
"@storybook/preview-web": "
|
|
61
|
-
"@storybook/store": "
|
|
62
|
-
"@types/node": "^14.14.20 || ^16.0.0",
|
|
63
|
-
"@types/webpack-env": "^1.16.0",
|
|
64
|
-
"babel-plugin-bundled-import-meta": "^0.3.1",
|
|
59
|
+
"@storybook/docs-tools": "7.0.0-alpha.10",
|
|
60
|
+
"@storybook/preview-web": "7.0.0-alpha.10",
|
|
61
|
+
"@storybook/store": "7.0.0-alpha.10",
|
|
65
62
|
"core-js": "^3.8.2",
|
|
66
63
|
"global": "^4.4.0",
|
|
67
64
|
"react": "16.14.0",
|
|
68
65
|
"react-dom": "16.14.0",
|
|
69
|
-
"read-pkg-up": "^7.0.1",
|
|
70
|
-
"regenerator-runtime": "^0.13.7",
|
|
71
66
|
"ts-dedent": "^2.0.0"
|
|
72
67
|
},
|
|
73
68
|
"devDependencies": {
|
|
69
|
+
"@digitak/esrun": "^3.2.2",
|
|
74
70
|
"lit-html": "2.0.2"
|
|
75
71
|
},
|
|
76
72
|
"peerDependencies": {
|
|
@@ -82,6 +78,9 @@
|
|
|
82
78
|
"publishConfig": {
|
|
83
79
|
"access": "public"
|
|
84
80
|
},
|
|
85
|
-
"
|
|
86
|
-
|
|
81
|
+
"bundlerEntrypoint": [
|
|
82
|
+
"./src/index.ts",
|
|
83
|
+
"./src/config.ts"
|
|
84
|
+
],
|
|
85
|
+
"gitHead": "b13dd8fb52819d73d4983148af8ffc5d683e8b75"
|
|
87
86
|
}
|
package/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/config';
|
package/bin/build.js
DELETED
package/bin/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCustomElements = getCustomElements;
|
|
7
|
-
exports.isValidComponent = isValidComponent;
|
|
8
|
-
exports.isValidMetaData = isValidMetaData;
|
|
9
|
-
exports.setCustomElements = setCustomElements;
|
|
10
|
-
exports.setCustomElementsManifest = setCustomElementsManifest;
|
|
11
|
-
|
|
12
|
-
/* eslint-disable no-underscore-dangle */
|
|
13
|
-
|
|
14
|
-
/* global window */
|
|
15
|
-
function isValidComponent(tagName) {
|
|
16
|
-
if (!tagName) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (typeof tagName === 'string') {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
throw new Error('Provided component needs to be a string. e.g. component: "my-element"');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function isValidMetaData(customElements) {
|
|
28
|
-
if (!customElements) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (customElements.tags && Array.isArray(customElements.tags) || customElements.modules && Array.isArray(customElements.modules)) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
throw new Error("You need to setup valid meta data in your config.js via setCustomElements().\n See the readme of addon-docs for web components for more details.");
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* @param customElements any for now as spec is not super stable yet
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
function setCustomElements(customElements) {
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
window.__STORYBOOK_CUSTOM_ELEMENTS__ = customElements;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function setCustomElementsManifest(customElements) {
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ = customElements;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function getCustomElements() {
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
return window.__STORYBOOK_CUSTOM_ELEMENTS__ || window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__;
|
|
56
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parameters = exports.decorators = exports.argTypesEnhancers = void 0;
|
|
7
|
-
|
|
8
|
-
var _docsTools = require("@storybook/docs-tools");
|
|
9
|
-
|
|
10
|
-
var _customElements = require("./custom-elements");
|
|
11
|
-
|
|
12
|
-
var _sourceDecorator = require("./sourceDecorator");
|
|
13
|
-
|
|
14
|
-
var _prepareForInline = require("./prepareForInline");
|
|
15
|
-
|
|
16
|
-
var decorators = [_sourceDecorator.sourceDecorator];
|
|
17
|
-
exports.decorators = decorators;
|
|
18
|
-
var parameters = {
|
|
19
|
-
docs: {
|
|
20
|
-
extractArgTypes: _customElements.extractArgTypes,
|
|
21
|
-
extractComponentDescription: _customElements.extractComponentDescription,
|
|
22
|
-
inlineStories: true,
|
|
23
|
-
prepareForInline: _prepareForInline.prepareForInline,
|
|
24
|
-
source: {
|
|
25
|
-
type: _docsTools.SourceType.DYNAMIC,
|
|
26
|
-
language: 'html'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
exports.parameters = parameters;
|
|
31
|
-
var argTypesEnhancers = [_docsTools.enhanceArgTypes];
|
|
32
|
-
exports.argTypesEnhancers = argTypesEnhancers;
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.extractComponentDescription = exports.extractArgTypesFromElements = exports.extractArgTypes = void 0;
|
|
7
|
-
|
|
8
|
-
require("core-js/modules/es.object.to-string.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.array.filter.js");
|
|
11
|
-
|
|
12
|
-
require("core-js/modules/es.function.name.js");
|
|
13
|
-
|
|
14
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
15
|
-
|
|
16
|
-
require("core-js/modules/es.symbol.js");
|
|
17
|
-
|
|
18
|
-
require("core-js/modules/es.symbol.description.js");
|
|
19
|
-
|
|
20
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
21
|
-
|
|
22
|
-
require("core-js/modules/es.string.replace.js");
|
|
23
|
-
|
|
24
|
-
require("core-js/modules/es.array.find.js");
|
|
25
|
-
|
|
26
|
-
require("core-js/modules/es.object.assign.js");
|
|
27
|
-
|
|
28
|
-
var _clientLogger = require("@storybook/client-logger");
|
|
29
|
-
|
|
30
|
-
var _ = require("..");
|
|
31
|
-
|
|
32
|
-
function mapData(data, category) {
|
|
33
|
-
return data && data.filter(function (item) {
|
|
34
|
-
return item && item.name;
|
|
35
|
-
}).reduce(function (acc, item) {
|
|
36
|
-
if (item.kind === 'method') return acc;
|
|
37
|
-
|
|
38
|
-
switch (category) {
|
|
39
|
-
case 'events':
|
|
40
|
-
mapEvent(item).forEach(function (argType) {
|
|
41
|
-
acc[argType.name] = argType;
|
|
42
|
-
});
|
|
43
|
-
break;
|
|
44
|
-
|
|
45
|
-
default:
|
|
46
|
-
acc[item.name] = mapItem(item, category);
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return acc;
|
|
51
|
-
}, {});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function mapItem(item, category) {
|
|
55
|
-
var _item$type, _item$type2;
|
|
56
|
-
|
|
57
|
-
var type = category === 'properties' ? {
|
|
58
|
-
name: ((_item$type = item.type) === null || _item$type === void 0 ? void 0 : _item$type.text) || item.type
|
|
59
|
-
} : {
|
|
60
|
-
name: 'void'
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
name: item.name,
|
|
64
|
-
required: false,
|
|
65
|
-
description: item.description,
|
|
66
|
-
type: type,
|
|
67
|
-
table: {
|
|
68
|
-
category: category,
|
|
69
|
-
type: {
|
|
70
|
-
summary: ((_item$type2 = item.type) === null || _item$type2 === void 0 ? void 0 : _item$type2.text) || item.type
|
|
71
|
-
},
|
|
72
|
-
defaultValue: {
|
|
73
|
-
summary: item.default !== undefined ? item.default : item.defaultValue
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function mapEvent(item) {
|
|
80
|
-
var name = item.name.replace(/(-|_|:|\.|\s)+(.)?/g, function (_match, _separator, chr) {
|
|
81
|
-
return chr ? chr.toUpperCase() : '';
|
|
82
|
-
}).replace(/^([A-Z])/, function (match) {
|
|
83
|
-
return match.toLowerCase();
|
|
84
|
-
});
|
|
85
|
-
name = "on".concat(name.charAt(0).toUpperCase() + name.substr(1));
|
|
86
|
-
return [{
|
|
87
|
-
name: name,
|
|
88
|
-
action: {
|
|
89
|
-
name: item.name
|
|
90
|
-
},
|
|
91
|
-
table: {
|
|
92
|
-
disable: true
|
|
93
|
-
}
|
|
94
|
-
}, mapItem(item, 'events')];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
var getMetaDataExperimental = function getMetaDataExperimental(tagName, customElements) {
|
|
98
|
-
if (!(0, _.isValidComponent)(tagName) || !(0, _.isValidMetaData)(customElements)) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
var metaData = customElements.tags.find(function (tag) {
|
|
103
|
-
return tag.name.toUpperCase() === tagName.toUpperCase();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
if (!metaData) {
|
|
107
|
-
_clientLogger.logger.warn("Component not found in custom-elements.json: ".concat(tagName));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return metaData;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
var getMetaDataV1 = function getMetaDataV1(tagName, customElements) {
|
|
114
|
-
var _customElements$modul;
|
|
115
|
-
|
|
116
|
-
if (!(0, _.isValidComponent)(tagName) || !(0, _.isValidMetaData)(customElements)) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
var metadata;
|
|
121
|
-
customElements === null || customElements === void 0 ? void 0 : (_customElements$modul = customElements.modules) === null || _customElements$modul === void 0 ? void 0 : _customElements$modul.forEach(function (_module) {
|
|
122
|
-
var _module$declarations;
|
|
123
|
-
|
|
124
|
-
_module === null || _module === void 0 ? void 0 : (_module$declarations = _module.declarations) === null || _module$declarations === void 0 ? void 0 : _module$declarations.forEach(function (declaration) {
|
|
125
|
-
if (declaration.tagName === tagName) {
|
|
126
|
-
metadata = declaration;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
if (!metadata) {
|
|
132
|
-
_clientLogger.logger.warn("Component not found in custom-elements.json: ".concat(tagName));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return metadata;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
var extractArgTypesFromElements = function extractArgTypesFromElements(tagName, customElements) {
|
|
139
|
-
var metaData = getMetaData(tagName, customElements);
|
|
140
|
-
return metaData && Object.assign({}, mapData(metaData.attributes, 'attributes'), mapData(metaData.members, 'properties'), mapData(metaData.properties, 'properties'), mapData(metaData.events, 'events'), mapData(metaData.slots, 'slots'), mapData(metaData.cssProperties, 'css custom properties'), mapData(metaData.cssParts, 'css shadow parts'));
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
exports.extractArgTypesFromElements = extractArgTypesFromElements;
|
|
144
|
-
|
|
145
|
-
var getMetaData = function getMetaData(tagName, manifest) {
|
|
146
|
-
if ((manifest === null || manifest === void 0 ? void 0 : manifest.version) === 'experimental') {
|
|
147
|
-
return getMetaDataExperimental(tagName, manifest);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return getMetaDataV1(tagName, manifest);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
var extractArgTypes = function extractArgTypes(tagName) {
|
|
154
|
-
var cem = (0, _.getCustomElements)();
|
|
155
|
-
return extractArgTypesFromElements(tagName, cem);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
exports.extractArgTypes = extractArgTypes;
|
|
159
|
-
|
|
160
|
-
var extractComponentDescription = function extractComponentDescription(tagName) {
|
|
161
|
-
var metaData = getMetaData(tagName, (0, _.getCustomElements)());
|
|
162
|
-
return metaData && metaData.description;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
exports.extractComponentDescription = extractComponentDescription;
|