7 lines
3.1 KiB
JavaScript
7 lines
3.1 KiB
JavaScript
import{e as m,S as _,a as f}from"./index-B4WlZuP_.js";import"./_commonjsHelpers-Cpj98o6Y.js";const{logger:E,deprecate:$}=__STORYBOOK_MODULE_CLIENT_LOGGER__,{addons:S,useEffect:h}=__STORYBOOK_MODULE_PREVIEW_API__;function T(r,e){return e?e.find(n=>n.name===r)!=null:!1}var O=r=>{try{let e=r.__docgen;if(e)return A(e)}catch(e){E.log(`Error extracting argTypes: ${e}`)}return{}},A=r=>{let e={};return r.data&&r.data.forEach(n=>{var t,a;e[n.name]={control:w(n.type),name:n.name,description:n.description||void 0,type:{required:T("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},w=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 D=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)===f.DYNAMIC?!1:!n||(e==null?void 0:e.code)||(e==null?void 0:e.type)===f.CODE};function v(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 N(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 R(r,e,n,t){let a=N(r);if(!a)return null;let s=Object.entries(e).filter(([o])=>o!==t).map(([o,d])=>v(o,d,n)).filter(o=>o),p=s.join(" "),l=p.length>50,u=t?e[t]:null,i=l?`<${a}
|
|
${s.join(`
|
|
`)}`:`<${a} ${p}`;return u?`${i}>
|
|
${u}
|
|
</${a}>`:`${i}/>`}function b(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(p=>p.name==="slot")))==null?void 0:a.name}:{wrapper:!1}:{wrapper:!1}}var j=(r,e)=>{let n=S.getChannel(),t=D(e),a=r(),s;if(h(()=>{if(!t&&s){let{id:y,unmappedArgs:g}=e;n.emit(_,{id:y,args:g,source:s})}}),t)return a;let{parameters:p={},args:l={},component:u}=e||{},{Component:i}=e.originalStoryFn(l,e),{wrapper:o,slotProperty:d}=b(i);o&&(p.component&&$("parameters.component is deprecated. Using context.component instead."),i=u);let c=R(i,l,e==null?void 0:e.argTypes,d);return c&&(s=c),a},L={docs:{story:{inline:!0},extractArgTypes:O,extractComponentDescription:C}},k=[j],K=[m];export{K as argTypesEnhancers,k as decorators,L as parameters};
|