Anvil/assets/entry-preview-docs-BInlz0sG.js

9 lines
3.2 KiB
JavaScript
Raw Normal View History

2024-07-31 10:01:28 +02:00
import{z as m,e as _,s as c}from"./index-B659rHmc.js";const{logger:$,deprecate:h}=__STORYBOOK_MODULE_CLIENT_LOGGER__,{addons:E,useEffect:O}=__STORYBOOK_MODULE_PREVIEW_API__;function S(r,e){return e?e.find(n=>n.name===r)!=null:!1}var T=r=>{try{let e=r.__docgen;if(e)return w(e)}catch(e){$.log(`Error extracting argTypes: ${e}`)}return{}},w=r=>{let e={};return r.data&&r.data.forEach(n=>{var t,a;e[n.name]={control:A(n.type),name:n.name,description:n.description||void 0,type:{required:S("required",n.keywords||[]),name:(t=n.type)==null?void 0:t.text},table:{type:{summary:(a=n.type)==null?void 0:a.text},defaultValue:{summary:n.defaultValue},category:"properties"}}}),r.events&&r.events.forEach(n=>{e[`event_${n.name}`]={name:n.name,action:n.name,control:!1,...n.description?{description:n.description}:{},table:{category:"events"}}}),r.slots&&r.slots.forEach(n=>{var t;e[`slot_${n.name}`]={name:n.name,control:!1,description:[n.description,(t=n.params)==null?void 0:t.map(a=>`\`${a.name}\``).join(" ")].filter(a=>a).join(`
`),table:{category:"slots"}}}),e},A=r=>{if(!r)return null;if(r.kind==="type")switch(r.type){case"string":return{type:"text"};case"enum":return{type:"radio"};case"any":return{type:"object"};default:return{type:r.type}}else if(r.kind==="union"&&Array.isArray(r.type)&&!r.type.find(e=>e.type!=="string"))return{type:"radio",options:r.type.filter(e=>e.kind==="const").map(e=>e.value)};return null};function C(r){if(!r)return"";let{__docgen:e={}}=r;return e.description}var v=r=>{var t;let e=(t=r==null?void 0:r.parameters.docs)==null?void 0:t.source,n=r==null?void 0:r.parameters.__isArgsStory;return(e==null?void 0:e.type)===c.DYNAMIC?!1:!n||(e==null?void 0:e.code)||(e==null?void 0:e.type)===c.CODE};function b(r,e,n){if(e==null)return null;let t=n[r];return t&&t.defaultValue===e||t&&t.action?null:e===!0?r:typeof e=="string"?`${r}=${JSON.stringify(e)}`:typeof e=="function"?`${r}={<handler>}`:`${r}={${JSON.stringify(e)}}`}function j(r){if(r==null)return null;let{__docgen:e={}}=r,{name:n}=e;return n?(n.endsWith(".svelte")&&(n=n.substring(0,n.length-7)),n):r.name}function D(r,e,n,t){let a=j(r);if(!a)return null;let s=Object.entries(e).filter(([o])=>o!==t).map(([o,d])=>b(o,d,n)).filter(o=>o),i=s.join(" "),l=i.length>50,u=t?e[t]:null,p=l?`<${a}
${s.join(`
`)}`:`<${a} ${i}`;return u?`${p}>
${u}
</${a}>`:`${p}/>`}function N(r){var n,t,a;let{__docgen:e}=r||{};return e?(n=e.keywords)!=null&&n.find(s=>s.name==="wrapper")?{wrapper:!0,slotProperty:(a=(t=e.data)==null?void 0:t.find(s=>s.keywords.find(i=>i.name==="slot")))==null?void 0:a.name}:{wrapper:!1}:{wrapper:!1}}var R=(r,e)=>{let n=E.getChannel(),t=v(e),a=r(),s;if(O(()=>{if(!t&&s){let{id:y,unmappedArgs:g}=e;n.emit(_,{id:y,args:g,source:s})}}),t)return a;let{parameters:i={},args:l={},component:u}=e||{},{Component:p}=e.originalStoryFn(l,e),{wrapper:o,slotProperty:d}=N(p);o&&(i.component&&h("parameters.component is deprecated. Using context.component instead."),p=u);let f=D(p,l,e==null?void 0:e.argTypes,d);return f&&(s=f),a},I={docs:{story:{inline:!0},extractArgTypes:T,extractComponentDescription:C}},L=[R],k=[m];export{k as argTypesEnhancers,L as decorators,I as parameters};
//# sourceMappingURL=entry-preview-docs-BInlz0sG.js.map