1 line
9.3 KiB
Text
1 line
9.3 KiB
Text
|
{"version":3,"file":"entry-preview-docs-BInlz0sG.js","sources":["../../node_modules/@storybook/svelte/dist/entry-preview-docs.mjs"],"sourcesContent":["import './chunk-CEH6MNVV.mjs';\nimport { enhanceArgTypes, SNIPPET_RENDERED, SourceType } from 'storybook/internal/docs-tools';\nimport { logger, deprecate } from 'storybook/internal/client-logger';\nimport { addons, useEffect } from 'storybook/internal/preview-api';\n\nfunction hasKeyword(keyword,keywords){return keywords?keywords.find(k=>k.name===keyword)!=null:!1}var extractArgTypes=component=>{try{let docgen=component.__docgen;if(docgen)return createArgTypes(docgen)}catch(err){logger.log(`Error extracting argTypes: ${err}`);}return {}},createArgTypes=docgen=>{let results={};return docgen.data&&docgen.data.forEach(item=>{results[item.name]={control:parseTypeToControl(item.type),name:item.name,description:item.description||void 0,type:{required:hasKeyword(\"required\",item.keywords||[]),name:item.type?.text},table:{type:{summary:item.type?.text},defaultValue:{summary:item.defaultValue},category:\"properties\"}};}),docgen.events&&docgen.events.forEach(item=>{results[`event_${item.name}`]={name:item.name,action:item.name,control:!1,...item.description?{description:item.description}:{},table:{category:\"events\"}};}),docgen.slots&&docgen.slots.forEach(item=>{results[`slot_${item.name}`]={name:item.name,control:!1,description:[item.description,item.params?.map(p=>`\\`${p.name}\\``).join(\" \")].filter(p=>p).join(`\n\n`),table:{category:\"slots\"}};}),results},parseTypeToControl=type=>{if(!type)return null;if(type.kind===\"type\")switch(type.type){case\"string\":return {type:\"text\"};case\"enum\":return {type:\"radio\"};case\"any\":return {type:\"object\"};default:return {type:type.type}}else if(type.kind===\"union\"&&Array.isArray(type.type)&&!type.type.find(t=>t.type!==\"string\"))return {type:\"radio\",options:type.type.filter(t=>t.kind===\"const\").map(t=>t.value)};return null};function extractComponentDescription(component){if(!component)return \"\";let{__docgen={}}=component;return __docgen.description}var skipSourceRender=context=>{let sourceParams=context?.parameters.docs?.source,isArgsStory=context?.parameters.__isArgsStory;return sourceParams?.type===SourceType.DYNAMIC?!1:!isArgsStory||sourceParams?.code||sourceParams?.type===SourceType.CODE};function toSvelteProperty(key,value,argTypes){if(value==null)return null;let argType=argTypes[key];return argType&&argType.defaultValue===value||argType&&argType.action?null:value===!0?key:typeof value==\"string\"?`${key}=${JSON.stringify(value)}`:typeof value==\"function\"?`${key}={<handler>}`:`${key}={${JSON.stringify(value)}}`}function getComponentName(component){if(component==null)return null;let{__docgen={}}=component,{name}=__docgen;return name?(name.endsWith(\".svelte\")&&(name=name.substring(0,name.length-7)),name):component.name}function generateSvelteSource(component,args,argTypes,slotProperty){let name=getComponentName(component);if(!name)return null;let propsArray=Object.entries(args).filter(([k])=>k!==slotProperty).map(([k,v])=>toSvelteProperty(k,v,argTypes)).filter(p=>p),props=propsArray.join(\" \"),multiline=props.length>50,slotValue=slotProperty?args[slotProperty]:null,srcStart=multiline?`<${name}\n ${propsArray.join(`\n `)}`:`<${name} ${props}`;return slotValue?`${srcStart}>\n ${slotValue}\n</${name}>`:`${srcStart}/>`}function getWrapperProperties(component){let{__docgen}=component||{};return __docgen?__docgen.keywords?.find(kw=>kw.name===\"wrapper\")?{wrapper:!0,slotProperty:__docgen.data?.find(prop=>prop.keywords.find(kw=>kw.name===\"slot\"))?.name}:{wrapper:!1}:{wrapper:!1}}var sourceDecorator=(storyFn,context)=>{let channel=addons.getChannel(),skip=skipSourceRender(context),story=storyFn(),source;if(useEffect(()=>{if(!skip&&source){let{id,unmappedArgs}=context;channel.emit(SNIPPET_RENDERED,{id,args:unmappedArgs,source});}}),skip)return story;let{parameters:parameters2={},args={},component:ctxComponent}=context||{},{Component:component}=context.originalStoryFn(args,context),{wrapper,slotProperty}=getWr
|