@storybook/web-components 7.0.0-alpha.4 → 7.0.0-alpha.40
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/chunk-DG4WPIKN.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 +50 -0
- package/dist/index.js +5 -0
- package/dist/index.mjs +1 -0
- package/dist/types-ad9cebe0.d.ts +9 -0
- package/package.json +42 -16
- package/preview.js +1 -1
- package/LICENSE +0 -21
- package/dist/cjs/config.js +0 -43
- package/dist/cjs/customElements.js +0 -57
- package/dist/cjs/docs/config.js +0 -29
- package/dist/cjs/docs/custom-elements.js +0 -139
- package/dist/cjs/docs/sourceDecorator.js +0 -59
- package/dist/cjs/index.js +0 -145
- package/dist/cjs/preview/config.js +0 -13
- package/dist/cjs/preview/globals.js +0 -10
- package/dist/cjs/preview/index.js +0 -42
- package/dist/cjs/preview/render.js +0 -70
- package/dist/cjs/preview/types-6-0.js +0 -5
- package/dist/cjs/preview/types-7-0.js +0 -5
- package/dist/cjs/preview/types.js +0 -5
- package/dist/esm/config.js +0 -6
- package/dist/esm/customElements.js +0 -42
- package/dist/esm/docs/config.js +0 -16
- package/dist/esm/docs/custom-elements.js +0 -117
- package/dist/esm/docs/sourceDecorator.js +0 -45
- package/dist/esm/index.js +0 -27
- package/dist/esm/preview/config.js +0 -1
- package/dist/esm/preview/globals.js +0 -5
- package/dist/esm/preview/index.js +0 -19
- package/dist/esm/preview/render.js +0 -55
- package/dist/esm/preview/types-6-0.js +0 -1
- package/dist/esm/preview/types-7-0.js +0 -1
- package/dist/esm/preview/types.js +0 -1
- package/dist/types/config.d.ts +0 -16
- package/dist/types/customElements.d.ts +0 -8
- package/dist/types/docs/config.d.ts +0 -17
- package/dist/types/docs/custom-elements.d.ts +0 -35
- package/dist/types/docs/sourceDecorator.d.ts +0 -3
- package/dist/types/index.d.ts +0 -3
- package/dist/types/preview/config.d.ts +0 -1
- package/dist/types/preview/globals.d.ts +0 -1
- package/dist/types/preview/index.d.ts +0 -24
- package/dist/types/preview/render.d.ts +0 -3
- package/dist/types/preview/types-6-0.d.ts +0 -34
- package/dist/types/preview/types-7-0.d.ts +0 -9
- package/dist/types/preview/types.d.ts +0 -16
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import _ from"global";import y from"global";var{window:u}=y;u.STORYBOOK_ENV="web-components";import{start as S}from"@storybook/core-client";import g from"global";import{dedent as w}from"ts-dedent";import{render as A}from"lit-html";import{isTemplateResult as T}from"lit-html/directive-helpers.js";import{simulatePageLoad as d,simulateDOMContentLoaded as C}from"@storybook/preview-web";var{Node:O}=g,k=(e,n)=>{let{id:i,component:r}=n;if(!r)throw new Error(`Unable to render story ${i} as the component annotation is missing from the default export`);let a=document.createElement(r);return Object.entries(e).forEach(([p,o])=>{a[p]=o}),a};function f({storyFn:e,kind:n,name:i,showMain:r,showError:a,forceRemount:p},o){let t=e();if(r(),T(t)){(p||!o.querySelector('[id="root-inner"]'))&&(o.innerHTML='<div id="root-inner"></div>');let c=o.querySelector('[id="root-inner"]');A(t,c),d(o)}else if(typeof t=="string")o.innerHTML=t,d(o);else if(t instanceof O){if(o.firstChild===t&&!p)return;o.innerHTML="",o.appendChild(t),C()}else a({title:`Expecting an HTML snippet or DOM node from the story: "${i}" of "${n}".`,description:w`
|
|
2
|
+
Did you forget to return the HTML snippet from the story?
|
|
3
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
4
|
+
`})}var l="web-components",m=S(f),D=(e,n)=>m.clientApi.storiesOf(e,n).addParameters({framework:l}),H=(...e)=>m.configure(l,...e),K=m.forceReRender,U=m.clientApi.raw;function B(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"')}function j(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.`)}function P(e){window.__STORYBOOK_CUSTOM_ELEMENTS__=e}function V(e){window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__=e}function $(){return window.__STORYBOOK_CUSTOM_ELEMENTS__||window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__}var{window:b,EventSource:M}=_;module&&module.hot&&module.hot.decline&&(module.hot.decline(),new M("__webpack_hmr").addEventListener("message",function(i){try{let{action:r}=JSON.parse(i.data);r==="built"&&b.location.reload()}catch{}}));export{k as a,f as b,D as c,H as d,K as e,U as f,B as g,j as h,P as i,V as j,$ as k};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as lib_docs_tools_dist from 'lib/docs-tools/dist';
|
|
2
|
+
import * as lib_api_dist from 'lib/api/dist';
|
|
3
|
+
import * as _storybook_csf from '@storybook/csf';
|
|
4
|
+
import { PartialStoryFn, StoryContext, ArgsStoryFn } from '@storybook/csf';
|
|
5
|
+
import { W as WebComponentsFramework } from './types-ad9cebe0.js';
|
|
6
|
+
import { RenderContext } from '@storybook/store';
|
|
7
|
+
import 'lit-html';
|
|
8
|
+
|
|
9
|
+
declare function sourceDecorator(storyFn: PartialStoryFn<WebComponentsFramework>, context: StoryContext<WebComponentsFramework>): WebComponentsFramework['storyResult'];
|
|
10
|
+
|
|
11
|
+
declare const decorators: (typeof sourceDecorator)[];
|
|
12
|
+
declare const argTypesEnhancers: (<TFramework extends _storybook_csf.AnyFramework>(context: _storybook_csf.StoryContextForEnhancers<TFramework, _storybook_csf.Args>) => _storybook_csf.StrictArgTypes<_storybook_csf.Args>)[];
|
|
13
|
+
|
|
14
|
+
declare const render: ArgsStoryFn<WebComponentsFramework>;
|
|
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.ArgType;
|
|
21
|
+
};
|
|
22
|
+
extractComponentDescription: (tagName: string) => string;
|
|
23
|
+
inlineStories: boolean;
|
|
24
|
+
source: {
|
|
25
|
+
type: lib_docs_tools_dist.SourceType;
|
|
26
|
+
language: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
framework: "web-components";
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { argTypesEnhancers, decorators, parameters, render, renderToDOM };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var V=Object.create;var d=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var B=(e,r)=>{for(var t in r)d(e,t,{get:r[t],enumerable:!0})},S=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of $(r))!K.call(e,n)&&n!==t&&d(e,n,{get:()=>r[n],enumerable:!(o=Y(r,n))||o.enumerable});return e};var y=(e,r,t)=>(t=e!=null?V(H(e)):{},S(r||!e||!e.__esModule?d(t,"default",{value:e,enumerable:!0}):t,e)),j=e=>S(d({},"__esModule",{value:!0}),e);var se={};B(se,{argTypesEnhancers:()=>P,decorators:()=>W,parameters:()=>ne,render:()=>O,renderToDOM:()=>c});module.exports=j(se);var l=require("@storybook/docs-tools");var w=require("@storybook/client-logger");var R=y(require("global"));var b=y(require("global")),{window:q}=b.default;q.STORYBOOK_ENV="web-components";var _=require("@storybook/core-client");var A=y(require("global")),M=require("ts-dedent"),h=require("lit-html"),E=require("lit-html/directive-helpers.js"),m=require("@storybook/preview-web"),{Node:J}=A.default,O=(e,r)=>{let{id:t,component:o}=r;if(!o)throw new Error(`Unable to render story ${t} as the component annotation is missing from the default export`);let n=document.createElement(o);return Object.entries(e).forEach(([a,s])=>{n[a]=s}),n};function c({storyFn:e,kind:r,name:t,showMain:o,showError:n,forceRemount:a},s){let i=e();if(o(),(0,E.isTemplateResult)(i)){(a||!s.querySelector('[id="root-inner"]'))&&(s.innerHTML='<div id="root-inner"></div>');let U=s.querySelector('[id="root-inner"]');(0,h.render)(i,U),(0,m.simulatePageLoad)(s)}else if(typeof i=="string")s.innerHTML=i,(0,m.simulatePageLoad)(s);else if(i instanceof J){if(s.firstChild===i&&!a)return;s.innerHTML="",s.appendChild(i),(0,m.simulateDOMContentLoaded)()}else n({title:`Expecting an HTML snippet or DOM node from the story: "${t}" of "${r}".`,description:M.dedent`
|
|
2
|
+
Did you forget to return the HTML snippet from the story?
|
|
3
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
4
|
+
`})}var D=(0,_.start)(c);var me=D.forceReRender,fe=D.clientApi.raw;function g(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"')}function C(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.`)}function T(){return window.__STORYBOOK_CUSTOM_ELEMENTS__||window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__}var{window:X,EventSource:Z}=R.default;module&&module.hot&&module.hot.decline&&(module.hot.decline(),new Z("__webpack_hmr").addEventListener("message",function(t){try{let{action:o}=JSON.parse(t.data);o==="built"&&X.location.reload()}catch{}}));function k(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}}}}function z(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}},k(e,"events")]}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":z(o).forEach(n=>{t[n.name]=n});break;default:t[o.name]=k(o,r);break}return t},{})}var G=(e,r)=>{if(!g(e)||!C(r))return null;let t=r.tags.find(o=>o.name.toUpperCase()===e.toUpperCase());return t||w.logger.warn(`Component not found in custom-elements.json: ${e}`),t},Q=(e,r)=>{var o;if(!g(e)||!C(r))return null;let t;return(o=r==null?void 0:r.modules)==null||o.forEach(n=>{var a;(a=n==null?void 0:n.declarations)==null||a.forEach(s=>{s.tagName===e&&(t=s)})}),t||w.logger.warn(`Component not found in custom-elements.json: ${e}`),t},x=(e,r)=>(r==null?void 0:r.version)==="experimental"?G(e,r):Q(e,r),ee=(e,r)=>{let t=x(e,r);return t&&{...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")}},F=e=>{let r=T();return ee(e,r)},I=e=>{let r=x(e,T());return r&&r.description};var v=require("lit-html"),u=require("@storybook/addons"),f=require("@storybook/docs-tools"),re=/<!--\?lit\$[0-9]+\$-->|<!--\??-->/g;function te(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)===f.SourceType.DYNAMIC?!1:!t||(r==null?void 0:r.code)||(r==null?void 0:r.type)===f.SourceType.CODE}function oe(e,r){let{transformSource:t}=r.parameters.docs??{};return typeof t!="function"?e:t(e,r)}function L(e,r){var n,a;let t=(a=(n=r==null?void 0:r.parameters.docs)==null?void 0:n.source)!=null&&a.excludeDecorators?r.originalStoryFn(r.args,r):e(),o;if((0,u.useEffect)(()=>{o&&u.addons.getChannel().emit(f.SNIPPET_RENDERED,r.id,o)}),!te(r)){let s=window.document.createElement("div");(0,v.render)(t,s),o=oe(s.innerHTML.replace(re,""),r)}return t}var W=[L],N={docs:{extractArgTypes:F,extractComponentDescription:I,inlineStories:!0,source:{type:l.SourceType.DYNAMIC,language:"html"}}},P=[l.enhanceArgTypes];var ne={framework:"web-components",...N};0&&(module.exports={argTypesEnhancers,decorators,parameters,render,renderToDOM});
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as T,b as S,g as a,h as p,k as i}from"./chunk-DG4WPIKN.mjs";import{SourceType as M,enhanceArgTypes as v}from"@storybook/docs-tools";import{logger as c}from"@storybook/client-logger";function u(r,e){let t=e==="properties"?{name:r.type?.text||r.type}:{name:"void"};return{name:r.name,required:!1,description:r.description,type:t,table:{category:e,type:{summary:r.type?.text||r.type},defaultValue:{summary:r.default!==void 0?r.default:r.defaultValue}}}}function b(r){let e=r.name.replace(/(-|_|:|\.|\s)+(.)?/g,(t,o,s)=>s?s.toUpperCase():"").replace(/^([A-Z])/,t=>t.toLowerCase());return e=`on${e.charAt(0).toUpperCase()+e.substr(1)}`,[{name:e,action:{name:r.name},table:{disable:!0}},u(r,"events")]}function n(r,e){return r&&r.filter(t=>t&&t.name).reduce((t,o)=>{if(o.kind==="method")return t;switch(e){case"events":b(o).forEach(s=>{t[s.name]=s});break;default:t[o.name]=u(o,e);break}return t},{})}var D=(r,e)=>{if(!a(r)||!p(e))return null;let t=e.tags.find(o=>o.name.toUpperCase()===r.toUpperCase());return t||c.warn(`Component not found in custom-elements.json: ${r}`),t},E=(r,e)=>{if(!a(r)||!p(e))return null;let t;return e?.modules?.forEach(o=>{o?.declarations?.forEach(s=>{s.tagName===r&&(t=s)})}),t||c.warn(`Component not found in custom-elements.json: ${r}`),t},f=(r,e)=>e?.version==="experimental"?D(r,e):E(r,e),I=(r,e)=>{let t=f(r,e);return t&&{...n(t.attributes,"attributes"),...n(t.members,"properties"),...n(t.properties,"properties"),...n(t.events,"events"),...n(t.slots,"slots"),...n(t.cssProperties,"css custom properties"),...n(t.cssParts,"css shadow parts")}},l=r=>{let e=i();return I(r,e)},g=r=>{let e=f(r,i());return e&&e.description};import{render as w}from"lit-html";import{addons as x,useEffect as A}from"@storybook/addons";import{SNIPPET_RENDERED as k,SourceType as y}from"@storybook/docs-tools";var h=/<!--\?lit\$[0-9]+\$-->|<!--\??-->/g;function F(r){let e=r?.parameters.docs?.source,t=r?.parameters.__isArgsStory;return e?.type===y.DYNAMIC?!1:!t||e?.code||e?.type===y.CODE}function P(r,e){let{transformSource:t}=e.parameters.docs??{};return typeof t!="function"?r:t(r,e)}function d(r,e){let t=e?.parameters.docs?.source?.excludeDecorators?e.originalStoryFn(e.args,e):r(),o;if(A(()=>{o&&x.getChannel().emit(k,e.id,o)}),!F(e)){let s=window.document.createElement("div");w(t,s),o=P(s.innerHTML.replace(h,""),e)}return t}var _=[d],C={docs:{extractArgTypes:l,extractComponentDescription:g,inlineStories:!0,source:{type:M.DYNAMIC,language:"html"}}},W=[v];var Z={framework:"web-components",...C};export{W as argTypesEnhancers,_ as decorators,Z as parameters,T as render,S as renderToDOM};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations } from '@storybook/csf';
|
|
2
|
+
import { W as WebComponentsFramework } from './types-ad9cebe0.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
|
+
configure(loader: Loadable, module: NodeModule): void;
|
|
33
|
+
forceReRender(): void;
|
|
34
|
+
raw: () => any;
|
|
35
|
+
}
|
|
36
|
+
declare const storiesOf: ClientApi['storiesOf'];
|
|
37
|
+
declare const configure: ClientApi['configure'];
|
|
38
|
+
declare const forceReRender: ClientApi['forceReRender'];
|
|
39
|
+
declare const raw: ClientApi['raw'];
|
|
40
|
+
|
|
41
|
+
declare function isValidComponent(tagName: string): boolean;
|
|
42
|
+
declare function isValidMetaData(customElements: any): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* @param customElements any for now as spec is not super stable yet
|
|
45
|
+
*/
|
|
46
|
+
declare function setCustomElements(customElements: any): void;
|
|
47
|
+
declare function setCustomElementsManifest(customElements: any): void;
|
|
48
|
+
declare function getCustomElements(): any;
|
|
49
|
+
|
|
50
|
+
export { Meta, Story, StoryFn, StoryObj, configure, forceReRender, getCustomElements, isValidComponent, isValidMetaData, raw, setCustomElements, setCustomElementsManifest, storiesOf };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var S=Object.create;var p=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var A=(e,o)=>{for(var r in o)p(e,r,{get:o[r],enumerable:!0})},l=(e,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of h(o))!x.call(e,i)&&i!==r&&p(e,i,{get:()=>o[i],enumerable:!(n=b(o,i))||n.enumerable});return e};var f=(e,o,r)=>(r=e!=null?S(R(e)):{},l(o||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e)),E=e=>l(p({},"__esModule",{value:!0}),e);var V={};A(V,{configure:()=>v,forceReRender:()=>N,getCustomElements:()=>Y,isValidComponent:()=>D,isValidMetaData:()=>H,raw:()=>W,setCustomElements:()=>K,setCustomElementsManifest:()=>U,storiesOf:()=>k});module.exports=E(V);var T=f(require("global"));var c=f(require("global")),{window:L}=c.default;L.STORYBOOK_ENV="web-components";var C=require("@storybook/core-client");var u=f(require("global")),w=require("ts-dedent"),y=require("lit-html"),O=require("lit-html/directive-helpers.js"),a=require("@storybook/preview-web"),{Node:F}=u.default;function _({storyFn:e,kind:o,name:r,showMain:n,showError:i,forceRemount:m},t){let s=e();if(n(),(0,O.isTemplateResult)(s)){(m||!t.querySelector('[id="root-inner"]'))&&(t.innerHTML='<div id="root-inner"></div>');let M=t.querySelector('[id="root-inner"]');(0,y.render)(s,M),(0,a.simulatePageLoad)(t)}else if(typeof s=="string")t.innerHTML=s,(0,a.simulatePageLoad)(t);else if(s instanceof F){if(t.firstChild===s&&!m)return;t.innerHTML="",t.appendChild(s),(0,a.simulateDOMContentLoaded)()}else i({title:`Expecting an HTML snippet or DOM node from the story: "${r}" of "${o}".`,description:w.dedent`
|
|
2
|
+
Did you forget to return the HTML snippet from the story?
|
|
3
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
4
|
+
`})}var g="web-components",d=(0,C.start)(_),k=(e,o)=>d.clientApi.storiesOf(e,o).addParameters({framework:g}),v=(...e)=>d.configure(g,...e),N=d.forceReRender,W=d.clientApi.raw;function D(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"')}function H(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.`)}function K(e){window.__STORYBOOK_CUSTOM_ELEMENTS__=e}function U(e){window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__=e}function Y(){return window.__STORYBOOK_CUSTOM_ELEMENTS__||window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__}var{window:B,EventSource:P}=T.default;module&&module.hot&&module.hot.decline&&(module.hot.decline(),new P("__webpack_hmr").addEventListener("message",function(r){try{let{action:n}=JSON.parse(r.data);n==="built"&&B.location.reload()}catch{}}));0&&(module.exports={configure,forceReRender,getCustomElements,isValidComponent,isValidMetaData,raw,setCustomElements,setCustomElementsManifest,storiesOf});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i}from"./chunk-DG4WPIKN.mjs";export{b as configure,c as forceReRender,i as getCustomElements,e as isValidComponent,f as isValidMetaData,d as raw,g as setCustomElements,h as setCustomElementsManifest,a as storiesOf};
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
|
|
9
|
+
export { WebComponentsFramework as W };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/web-components",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.40",
|
|
4
4
|
"description": "Storybook web-components renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lit-html",
|
|
@@ -21,9 +21,26 @@
|
|
|
21
21
|
"url": "https://opencollective.com/storybook"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
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"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"main": "dist/index.js",
|
|
42
|
+
"module": "dist/index.mjs",
|
|
43
|
+
"types": "dist/index.d.ts",
|
|
27
44
|
"files": [
|
|
28
45
|
"dist/**/*",
|
|
29
46
|
"README.md",
|
|
@@ -31,25 +48,27 @@
|
|
|
31
48
|
"*.d.ts"
|
|
32
49
|
],
|
|
33
50
|
"scripts": {
|
|
34
|
-
"
|
|
51
|
+
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
|
52
|
+
"prep": "../../../scripts/prepare/bundle.ts"
|
|
35
53
|
},
|
|
36
54
|
"dependencies": {
|
|
37
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
38
|
-
"@storybook/api": "7.0.0-alpha.
|
|
39
|
-
"@storybook/client-logger": "7.0.0-alpha.
|
|
40
|
-
"@storybook/core-client": "7.0.0-alpha.
|
|
41
|
-
"@storybook/csf": "0.0.2--canary.
|
|
42
|
-
"@storybook/docs-tools": "7.0.0-alpha.
|
|
43
|
-
"@storybook/preview-web": "7.0.0-alpha.
|
|
44
|
-
"@storybook/store": "7.0.0-alpha.
|
|
45
|
-
"core-js": "^3.8.2",
|
|
55
|
+
"@storybook/addons": "7.0.0-alpha.40",
|
|
56
|
+
"@storybook/api": "7.0.0-alpha.40",
|
|
57
|
+
"@storybook/client-logger": "7.0.0-alpha.40",
|
|
58
|
+
"@storybook/core-client": "7.0.0-alpha.40",
|
|
59
|
+
"@storybook/csf": "0.0.2--canary.49.258942b.0",
|
|
60
|
+
"@storybook/docs-tools": "7.0.0-alpha.40",
|
|
61
|
+
"@storybook/preview-web": "7.0.0-alpha.40",
|
|
62
|
+
"@storybook/store": "7.0.0-alpha.40",
|
|
46
63
|
"global": "^4.4.0",
|
|
47
64
|
"react": "16.14.0",
|
|
48
65
|
"react-dom": "16.14.0",
|
|
49
66
|
"ts-dedent": "^2.0.0"
|
|
50
67
|
},
|
|
51
68
|
"devDependencies": {
|
|
52
|
-
"lit
|
|
69
|
+
"lit": "2.3.1",
|
|
70
|
+
"lit-html": "2.0.2",
|
|
71
|
+
"typescript": "~4.6.3"
|
|
53
72
|
},
|
|
54
73
|
"peerDependencies": {
|
|
55
74
|
"lit-html": "^1.4.1 || ^2.0.0"
|
|
@@ -60,5 +79,12 @@
|
|
|
60
79
|
"publishConfig": {
|
|
61
80
|
"access": "public"
|
|
62
81
|
},
|
|
63
|
-
"
|
|
82
|
+
"bundler": {
|
|
83
|
+
"entries": [
|
|
84
|
+
"./src/index.ts",
|
|
85
|
+
"./src/config.ts"
|
|
86
|
+
],
|
|
87
|
+
"platform": "browser"
|
|
88
|
+
},
|
|
89
|
+
"gitHead": "8f6d8629f1ad7e776c39e2c7621f4a0d538aa93c"
|
|
64
90
|
}
|
package/preview.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './dist/
|
|
1
|
+
export * from './dist/config';
|
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/dist/cjs/config.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
parameters: true,
|
|
8
|
-
decorators: true,
|
|
9
|
-
argTypesEnhancers: true
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "argTypesEnhancers", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return _config.argTypesEnhancers;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "decorators", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return _config.decorators;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
exports.parameters = void 0;
|
|
24
|
-
|
|
25
|
-
var _config = require("./docs/config");
|
|
26
|
-
|
|
27
|
-
var _config2 = require("./preview/config");
|
|
28
|
-
|
|
29
|
-
Object.keys(_config2).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
32
|
-
if (key in exports && exports[key] === _config2[key]) return;
|
|
33
|
-
Object.defineProperty(exports, key, {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () {
|
|
36
|
-
return _config2[key];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
const parameters = Object.assign({
|
|
41
|
-
framework: 'web-components'
|
|
42
|
-
}, _config.parameters);
|
|
43
|
-
exports.parameters = parameters;
|
|
@@ -1,57 +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().
|
|
37
|
-
See the readme of addon-docs for web components for more details.`);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @param customElements any for now as spec is not super stable yet
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function setCustomElements(customElements) {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
window.__STORYBOOK_CUSTOM_ELEMENTS__ = customElements;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function setCustomElementsManifest(customElements) {
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ = customElements;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function getCustomElements() {
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
return window.__STORYBOOK_CUSTOM_ELEMENTS__ || window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__;
|
|
57
|
-
}
|
package/dist/cjs/docs/config.js
DELETED
|
@@ -1,29 +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
|
-
const decorators = [_sourceDecorator.sourceDecorator];
|
|
15
|
-
exports.decorators = decorators;
|
|
16
|
-
const parameters = {
|
|
17
|
-
docs: {
|
|
18
|
-
extractArgTypes: _customElements.extractArgTypes,
|
|
19
|
-
extractComponentDescription: _customElements.extractComponentDescription,
|
|
20
|
-
inlineStories: true,
|
|
21
|
-
source: {
|
|
22
|
-
type: _docsTools.SourceType.DYNAMIC,
|
|
23
|
-
language: 'html'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
exports.parameters = parameters;
|
|
28
|
-
const argTypesEnhancers = [_docsTools.enhanceArgTypes];
|
|
29
|
-
exports.argTypesEnhancers = argTypesEnhancers;
|
|
@@ -1,139 +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
|
-
var _clientLogger = require("@storybook/client-logger");
|
|
9
|
-
|
|
10
|
-
var _ = require("..");
|
|
11
|
-
|
|
12
|
-
function mapItem(item, category) {
|
|
13
|
-
var _item$type, _item$type2;
|
|
14
|
-
|
|
15
|
-
const type = category === 'properties' ? {
|
|
16
|
-
name: ((_item$type = item.type) === null || _item$type === void 0 ? void 0 : _item$type.text) || item.type
|
|
17
|
-
} : {
|
|
18
|
-
name: 'void'
|
|
19
|
-
};
|
|
20
|
-
return {
|
|
21
|
-
name: item.name,
|
|
22
|
-
required: false,
|
|
23
|
-
description: item.description,
|
|
24
|
-
type,
|
|
25
|
-
table: {
|
|
26
|
-
category,
|
|
27
|
-
type: {
|
|
28
|
-
summary: ((_item$type2 = item.type) === null || _item$type2 === void 0 ? void 0 : _item$type2.text) || item.type
|
|
29
|
-
},
|
|
30
|
-
defaultValue: {
|
|
31
|
-
summary: item.default !== undefined ? item.default : item.defaultValue
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function mapEvent(item) {
|
|
38
|
-
let name = item.name.replace(/(-|_|:|\.|\s)+(.)?/g, (_match, _separator, chr) => {
|
|
39
|
-
return chr ? chr.toUpperCase() : '';
|
|
40
|
-
}).replace(/^([A-Z])/, match => match.toLowerCase());
|
|
41
|
-
name = `on${name.charAt(0).toUpperCase() + name.substr(1)}`;
|
|
42
|
-
return [{
|
|
43
|
-
name,
|
|
44
|
-
action: {
|
|
45
|
-
name: item.name
|
|
46
|
-
},
|
|
47
|
-
table: {
|
|
48
|
-
disable: true
|
|
49
|
-
}
|
|
50
|
-
}, mapItem(item, 'events')];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function mapData(data, category) {
|
|
54
|
-
return data && data.filter(item => item && item.name).reduce((acc, item) => {
|
|
55
|
-
if (item.kind === 'method') return acc;
|
|
56
|
-
|
|
57
|
-
switch (category) {
|
|
58
|
-
case 'events':
|
|
59
|
-
mapEvent(item).forEach(argType => {
|
|
60
|
-
acc[argType.name] = argType;
|
|
61
|
-
});
|
|
62
|
-
break;
|
|
63
|
-
|
|
64
|
-
default:
|
|
65
|
-
acc[item.name] = mapItem(item, category);
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return acc;
|
|
70
|
-
}, {});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const getMetaDataExperimental = (tagName, customElements) => {
|
|
74
|
-
if (!(0, _.isValidComponent)(tagName) || !(0, _.isValidMetaData)(customElements)) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const metaData = customElements.tags.find(tag => tag.name.toUpperCase() === tagName.toUpperCase());
|
|
79
|
-
|
|
80
|
-
if (!metaData) {
|
|
81
|
-
_clientLogger.logger.warn(`Component not found in custom-elements.json: ${tagName}`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return metaData;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const getMetaDataV1 = (tagName, customElements) => {
|
|
88
|
-
var _customElements$modul;
|
|
89
|
-
|
|
90
|
-
if (!(0, _.isValidComponent)(tagName) || !(0, _.isValidMetaData)(customElements)) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let metadata;
|
|
95
|
-
customElements === null || customElements === void 0 ? void 0 : (_customElements$modul = customElements.modules) === null || _customElements$modul === void 0 ? void 0 : _customElements$modul.forEach(_module => {
|
|
96
|
-
var _module$declarations;
|
|
97
|
-
|
|
98
|
-
_module === null || _module === void 0 ? void 0 : (_module$declarations = _module.declarations) === null || _module$declarations === void 0 ? void 0 : _module$declarations.forEach(declaration => {
|
|
99
|
-
if (declaration.tagName === tagName) {
|
|
100
|
-
metadata = declaration;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
if (!metadata) {
|
|
106
|
-
_clientLogger.logger.warn(`Component not found in custom-elements.json: ${tagName}`);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return metadata;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const getMetaData = (tagName, manifest) => {
|
|
113
|
-
if ((manifest === null || manifest === void 0 ? void 0 : manifest.version) === 'experimental') {
|
|
114
|
-
return getMetaDataExperimental(tagName, manifest);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return getMetaDataV1(tagName, manifest);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const extractArgTypesFromElements = (tagName, customElements) => {
|
|
121
|
-
const metaData = getMetaData(tagName, customElements);
|
|
122
|
-
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'));
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
exports.extractArgTypesFromElements = extractArgTypesFromElements;
|
|
126
|
-
|
|
127
|
-
const extractArgTypes = tagName => {
|
|
128
|
-
const cem = (0, _.getCustomElements)();
|
|
129
|
-
return extractArgTypesFromElements(tagName, cem);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
exports.extractArgTypes = extractArgTypes;
|
|
133
|
-
|
|
134
|
-
const extractComponentDescription = tagName => {
|
|
135
|
-
const metaData = getMetaData(tagName, (0, _.getCustomElements)());
|
|
136
|
-
return metaData && metaData.description;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
exports.extractComponentDescription = extractComponentDescription;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.sourceDecorator = sourceDecorator;
|
|
7
|
-
|
|
8
|
-
var _litHtml = require("lit-html");
|
|
9
|
-
|
|
10
|
-
var _addons = require("@storybook/addons");
|
|
11
|
-
|
|
12
|
-
var _docsTools = require("@storybook/docs-tools");
|
|
13
|
-
|
|
14
|
-
/* eslint-disable no-underscore-dangle */
|
|
15
|
-
|
|
16
|
-
/* global window */
|
|
17
|
-
// Taken from https://github.com/lit/lit/blob/main/packages/lit-html/src/test/test-utils/strip-markers.ts
|
|
18
|
-
const LIT_EXPRESSION_COMMENTS = /<!--\?lit\$[0-9]+\$-->|<!--\??-->/g;
|
|
19
|
-
|
|
20
|
-
function skipSourceRender(context) {
|
|
21
|
-
var _context$parameters$d;
|
|
22
|
-
|
|
23
|
-
const sourceParams = context === null || context === void 0 ? void 0 : (_context$parameters$d = context.parameters.docs) === null || _context$parameters$d === void 0 ? void 0 : _context$parameters$d.source;
|
|
24
|
-
const isArgsStory = context === null || context === void 0 ? void 0 : context.parameters.__isArgsStory; // always render if the user forces it
|
|
25
|
-
|
|
26
|
-
if ((sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.DYNAMIC) {
|
|
27
|
-
return false;
|
|
28
|
-
} // never render if the user is forcing the block to render code, or
|
|
29
|
-
// if the user provides code, or if it's not an args story.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return !isArgsStory || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.code) || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === _docsTools.SourceType.CODE;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function applyTransformSource(source, context) {
|
|
36
|
-
const {
|
|
37
|
-
transformSource
|
|
38
|
-
} = context.parameters.docs ?? {};
|
|
39
|
-
if (typeof transformSource !== 'function') return source;
|
|
40
|
-
return transformSource(source, context);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function sourceDecorator(storyFn, context) {
|
|
44
|
-
var _context$parameters$d2, _context$parameters$d3;
|
|
45
|
-
|
|
46
|
-
const story = context !== null && context !== void 0 && (_context$parameters$d2 = context.parameters.docs) !== null && _context$parameters$d2 !== void 0 && (_context$parameters$d3 = _context$parameters$d2.source) !== null && _context$parameters$d3 !== void 0 && _context$parameters$d3.excludeDecorators ? context.originalStoryFn(context.args, context) : storyFn();
|
|
47
|
-
let source;
|
|
48
|
-
(0, _addons.useEffect)(() => {
|
|
49
|
-
if (source) _addons.addons.getChannel().emit(_docsTools.SNIPPET_RENDERED, context.id, source);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if (!skipSourceRender(context)) {
|
|
53
|
-
const container = window.document.createElement('div');
|
|
54
|
-
(0, _litHtml.render)(story, container);
|
|
55
|
-
source = applyTransformSource(container.innerHTML.replace(LIT_EXPRESSION_COMMENTS, ''), context);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return story;
|
|
59
|
-
}
|