@storybook/vue3
Advanced tools
Comparing version 0.0.0-pr-30055-sha-75c4665d to 0.0.0-pr-30070-sha-0b45cb37
@@ -12,3 +12,3 @@ "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var entry_preview_docs_exports={};__export(entry_preview_docs_exports,{argTypesEnhancers:()=>argTypesEnhancers,decorators:()=>decorators,parameters:()=>parameters});module.exports=__toCommonJS(entry_preview_docs_exports);var import_docs_tools3=require("storybook/internal/docs-tools");var import_docs_tools=require("storybook/internal/docs-tools"),ARG_TYPE_SECTIONS=["props","events","slots","exposed","expose"],extractArgTypes=component=>{if(!(0,import_docs_tools.hasDocgen)(component))return null;let usedDocgenPlugin="exposed"in component.__docgenInfo?"vue-component-meta":"vue-docgen-api",argTypes={};return ARG_TYPE_SECTIONS.forEach(section=>{(0,import_docs_tools.extractComponentProps)(component,section).forEach(extractedProp=>{let argType;if(usedDocgenPlugin==="vue-docgen-api"){let docgenInfo=extractedProp.docgenInfo;argType=extractFromVueDocgenApi(docgenInfo,section,extractedProp)}else{let docgenInfo=extractedProp.docgenInfo;argType=extractFromVueComponentMeta(docgenInfo,section)}if(!argType||argTypes[argType.name])return;["events","expose","exposed"].includes(section)&&(argType.control={disable:!0}),argTypes[argType.name]=argType})}),argTypes},extractFromVueDocgenApi=(docgenInfo,section,extractedProp)=>{let type,sbType;if(section==="events"&&(type=docgenInfo.type?.names.join(),sbType={name:"other",value:type??"",required:!1}),section==="slots"){let slotBindings=docgenInfo.bindings?.filter(binding=>!!binding.name).map(binding=>`${binding.name}: ${binding.type?.name??"unknown"}`).join("; ");type=slotBindings?`{ ${slotBindings} }`:void 0,sbType={name:"other",value:type??"",required:!1}}if(section==="props"){let propInfo=docgenInfo;if(type=propInfo.type?.name,sbType=extractedProp?(0,import_docs_tools.convert)(extractedProp.docgenInfo):{name:"other",value:type},propInfo.type&&"elements"in propInfo.type&&Array.isArray(propInfo.type.elements)&&propInfo.type.elements.length>0){let elements=propInfo.type.elements.map(i=>i.name);type==="Array"&&(type=`${elements.length===1?elements[0]:`(${elements.join(" | ")})`}[]`),type==="union"?type=elements.join(" | "):type==="intersection"&&(type=elements.join(" & "))}}let required="required"in docgenInfo?docgenInfo.required??!1:!1;return{name:docgenInfo.name,description:docgenInfo.description,type:sbType?{...sbType,required}:{name:"other",value:type??""},table:{type:type?{summary:type}:void 0,defaultValue:extractedProp?.propDef.defaultValue??void 0,jsDocTags:extractedProp?.propDef.jsDocTags,category:section}}},extractFromVueComponentMeta=(docgenInfo,section)=>{if("global"in docgenInfo&&docgenInfo.global)return;let tableType={summary:docgenInfo.type.replace(" | undefined","")};if(section==="props"){let propInfo=docgenInfo,defaultValue=propInfo.default?{summary:propInfo.default}:void 0;return{name:propInfo.name,description:formatDescriptionWithTags(propInfo.description,propInfo.tags),defaultValue,type:convertVueComponentMetaProp(propInfo),table:{type:tableType,defaultValue,category:section}}}else return{name:docgenInfo.name,description:"description"in docgenInfo?docgenInfo.description:"",type:{name:"other",value:docgenInfo.type},table:{type:tableType,category:section}}},convertVueComponentMetaProp=propInfo=>{let schema=propInfo.schema,required=propInfo.required,fallbackSbType={name:"other",value:propInfo.type,required},KNOWN_SCHEMAS=["string","number","function","boolean","symbol"];if(typeof schema=="string")return KNOWN_SCHEMAS.includes(schema)?{name:schema,required}:fallbackSbType;switch(schema.kind){case"enum":{let definedSchemas=schema.schema?.filter(item=>item!=="undefined")??[];return isBooleanSchema(definedSchemas)?{name:"boolean",required}:isLiteralUnionSchema(definedSchemas)||isEnumSchema(definedSchemas)?{name:"enum",value:definedSchemas.map(literal=>literal.replace(/"/g,"")),required}:definedSchemas.length===1?convertVueComponentMetaProp({schema:definedSchemas[0],type:propInfo.type,required}):(definedSchemas.length>2&&definedSchemas.includes("true")&&definedSchemas.includes("false")&&(definedSchemas=definedSchemas.filter(i=>i!=="true"&&i!=="false"),definedSchemas.push("boolean")),{name:"union",value:definedSchemas.map(i=>convertVueComponentMetaProp(typeof i=="object"?{schema:i,type:i.type,required:!1}:{schema:i,type:i,required:!1})),required})}case"array":{let definedSchemas=schema.schema?.filter(item=>item!=="undefined")??[];return definedSchemas.length===0?fallbackSbType:definedSchemas.length===1?{name:"array",value:convertVueComponentMetaProp({schema:definedSchemas[0],type:propInfo.type,required:!1}),required}:{name:"union",value:definedSchemas.map(i=>convertVueComponentMetaProp(typeof i=="object"?{schema:i,type:i.type,required:!1}:{schema:i,type:i,required:!1})),required}}case"object":return{name:"object",value:{},required};default:return fallbackSbType}},formatDescriptionWithTags=(description,tags)=>!tags?.length||!description?description??"":`${tags.map(tag=>`@${tag.name}: ${tag.text}`).join("<br>")}<br><br>${description}`,isLiteralUnionSchema=schemas=>schemas.every(schema=>typeof schema=="string"&&schema.startsWith('"')&&schema.endsWith('"')),isEnumSchema=schemas=>schemas.every(schema=>typeof schema=="string"&&schema.includes(".")),isBooleanSchema=schemas=>schemas.length===2&&schemas.includes("true")&&schemas.includes("false");var import_docs_tools2=require("storybook/internal/docs-tools"),import_preview_api=require("storybook/internal/preview-api"),import_vue=require("vue"),sourceDecorator=(storyFn,ctx)=>{let story=storyFn();if(shouldSkipSourceCodeGeneration(ctx))return story;let channel=import_preview_api.addons.getChannel();return(0,import_vue.watch)(()=>ctx.args,()=>{let sourceCode=generateSourceCode(ctx);channel.emit(import_docs_tools2.SNIPPET_RENDERED,{id:ctx.id,args:ctx.args,source:sourceCode,format:"vue"})},{immediate:!0,deep:!0}),story},generateSourceCode=ctx=>{let sourceCodeContext={imports:{},scriptVariables:{}},{displayName,slotNames,eventNames}=parseDocgenInfo(ctx.component),props=generatePropsSourceCode(ctx.args,slotNames,eventNames,sourceCodeContext),slotSourceCode=generateSlotSourceCode(ctx.args,slotNames,sourceCodeContext),componentName=displayName||ctx.title.split("/").at(-1),templateCode=slotSourceCode?`<${componentName} ${props}> ${slotSourceCode} </${componentName}>`:`<${componentName} ${props} />`,variablesCode=Object.entries(sourceCodeContext.scriptVariables).map(([name,value])=>`const ${name} = ${value};`).join(` | ||
${template}`},shouldSkipSourceCodeGeneration=context=>{let sourceParams=context?.parameters.docs?.source;if(sourceParams?.type===import_docs_tools2.SourceType.DYNAMIC)return!1;let isArgsStory=context?.parameters.__isArgsStory;return!(context?.viewMode==="docs")||!isArgsStory||sourceParams?.code||sourceParams?.type===import_docs_tools2.SourceType.CODE},parseDocgenInfo=component=>{if(!component||!("__docgenInfo"in component)||!component.__docgenInfo||typeof component.__docgenInfo!="object")return{displayName:component?.__name,eventNames:[],slotNames:[]};let docgenInfo=component.__docgenInfo,displayName="displayName"in docgenInfo&&typeof docgenInfo.displayName=="string"?docgenInfo.displayName:void 0,parseNames=key=>!(key in docgenInfo)||!Array.isArray(docgenInfo[key])?[]:docgenInfo[key].map(i=>i&&typeof i=="object"&&"name"in i?i.name:void 0).filter(i=>typeof i=="string");return{displayName:displayName||component.__name,slotNames:parseNames("slots").sort((a,b)=>a==="default"?-1:b==="default"?1:a.localeCompare(b)),eventNames:parseNames("events")}},generatePropsSourceCode=(args,slotNames,eventNames,ctx)=>{let properties=[];Object.entries(args).forEach(([propName,value])=>{if(!slotNames.includes(propName)&&value!=null)switch(typeof value){case"string":if(value==="")return;properties.push({name:propName,value:value.includes('"')?`'${value}'`:`"${value}"`,templateFn:(name,propValue)=>`${name}=${propValue}`});break;case"number":properties.push({name:propName,value:value.toString(),templateFn:(name,propValue)=>`:${name}="${propValue}"`});break;case"bigint":properties.push({name:propName,value:`BigInt(${value.toString()})`,templateFn:(name,propValue)=>`:${name}="${propValue}"`});break;case"boolean":properties.push({name:propName,value:value?"true":"false",templateFn:(name,propValue)=>propValue==="true"?name:`:${name}="false"`});break;case"symbol":properties.push({name:propName,value:`Symbol(${value.description?`'${value.description}'`:""})`,templateFn:(name,propValue)=>`:${name}="${propValue}"`});break;case"object":{properties.push({name:propName,value:formatObject(value),templateFn:void 0});break}case"function":break}}),properties.sort((a,b)=>a.name.localeCompare(b.name));let props=[];return properties.forEach(prop=>{let isVModel=eventNames.includes(`update:${prop.name}`);if(!isVModel&&prop.templateFn){props.push(prop.templateFn(prop.name,prop.value));return}let variableName=prop.name;if(variableName in ctx.scriptVariables){let index=1;do variableName=`${prop.name}${index}`,index++;while(variableName in ctx.scriptVariables)}if(!isVModel){ctx.scriptVariables[variableName]=prop.value,props.push(`:${prop.name}="${variableName}"`);return}ctx.scriptVariables[variableName]=`ref(${prop.value})`,ctx.imports.vue||(ctx.imports.vue=new Set),ctx.imports.vue.add("ref"),prop.name==="modelValue"?props.push(`v-model="${variableName}"`):props.push(`v-model:${prop.name}="${variableName}"`)}),props.join(" ")},generateSlotSourceCode=(args,slotNames,ctx)=>{let slotSourceCodes=[];return slotNames.forEach(slotName=>{let arg=args[slotName];if(!arg)return;let slotContent=generateSlotChildrenSourceCode([arg],ctx);if(!slotContent)return;let slotBindings=typeof arg=="function"?getFunctionParamNames(arg):[];slotName==="default"&&!slotBindings.length?slotSourceCodes.push(slotContent):slotSourceCodes.push(`<template ${slotBindingsToString(slotName,slotBindings)}>${slotContent}</template>`)}),slotSourceCodes.join(` | ||
${template}`},shouldSkipSourceCodeGeneration=context=>{let sourceParams=context?.parameters.docs?.source;return sourceParams?.type===import_docs_tools2.SourceType.DYNAMIC?!1:!context?.parameters.__isArgsStory||sourceParams?.code||sourceParams?.type===import_docs_tools2.SourceType.CODE},parseDocgenInfo=component=>{if(!component||!("__docgenInfo"in component)||!component.__docgenInfo||typeof component.__docgenInfo!="object")return{displayName:component?.__name,eventNames:[],slotNames:[]};let docgenInfo=component.__docgenInfo,displayName="displayName"in docgenInfo&&typeof docgenInfo.displayName=="string"?docgenInfo.displayName:void 0,parseNames=key=>!(key in docgenInfo)||!Array.isArray(docgenInfo[key])?[]:docgenInfo[key].map(i=>i&&typeof i=="object"&&"name"in i?i.name:void 0).filter(i=>typeof i=="string");return{displayName:displayName||component.__name,slotNames:parseNames("slots").sort((a,b)=>a==="default"?-1:b==="default"?1:a.localeCompare(b)),eventNames:parseNames("events")}},generatePropsSourceCode=(args,slotNames,eventNames,ctx)=>{let properties=[];Object.entries(args).forEach(([propName,value])=>{if(!slotNames.includes(propName)&&value!=null)switch(typeof value){case"string":if(value==="")return;properties.push({name:propName,value:value.includes('"')?`'${value}'`:`"${value}"`,templateFn:(name,propValue)=>`${name}=${propValue}`});break;case"number":properties.push({name:propName,value:value.toString(),templateFn:(name,propValue)=>`:${name}="${propValue}"`});break;case"bigint":properties.push({name:propName,value:`BigInt(${value.toString()})`,templateFn:(name,propValue)=>`:${name}="${propValue}"`});break;case"boolean":properties.push({name:propName,value:value?"true":"false",templateFn:(name,propValue)=>propValue==="true"?name:`:${name}="false"`});break;case"symbol":properties.push({name:propName,value:`Symbol(${value.description?`'${value.description}'`:""})`,templateFn:(name,propValue)=>`:${name}="${propValue}"`});break;case"object":{properties.push({name:propName,value:formatObject(value),templateFn:void 0});break}case"function":break}}),properties.sort((a,b)=>a.name.localeCompare(b.name));let props=[];return properties.forEach(prop=>{let isVModel=eventNames.includes(`update:${prop.name}`);if(!isVModel&&prop.templateFn){props.push(prop.templateFn(prop.name,prop.value));return}let variableName=prop.name;if(variableName in ctx.scriptVariables){let index=1;do variableName=`${prop.name}${index}`,index++;while(variableName in ctx.scriptVariables)}if(!isVModel){ctx.scriptVariables[variableName]=prop.value,props.push(`:${prop.name}="${variableName}"`);return}ctx.scriptVariables[variableName]=`ref(${prop.value})`,ctx.imports.vue||(ctx.imports.vue=new Set),ctx.imports.vue.add("ref"),prop.name==="modelValue"?props.push(`v-model="${variableName}"`):props.push(`v-model:${prop.name}="${variableName}"`)}),props.join(" ")},generateSlotSourceCode=(args,slotNames,ctx)=>{let slotSourceCodes=[];return slotNames.forEach(slotName=>{let arg=args[slotName];if(!arg)return;let slotContent=generateSlotChildrenSourceCode([arg],ctx);if(!slotContent)return;let slotBindings=typeof arg=="function"?getFunctionParamNames(arg):[];slotName==="default"&&!slotBindings.length?slotSourceCodes.push(slotContent):slotSourceCodes.push(`<template ${slotBindingsToString(slotName,slotBindings)}>${slotContent}</template>`)}),slotSourceCodes.join(` | ||
@@ -15,0 +15,0 @@ `)},generateSlotChildrenSourceCode=(children,ctx)=>{let slotChildrenSourceCodes=[],generateSingleChildSourceCode=child=>{if((0,import_vue.isVNode)(child))return generateVNodeSourceCode(child,ctx);switch(typeof child){case"string":case"number":case"boolean":return child.toString();case"object":return child===null?"":Array.isArray(child)?child.map(generateSingleChildSourceCode).filter(code=>code!=="").join(` |
{ | ||
"name": "@storybook/vue3", | ||
"version": "0.0.0-pr-30055-sha-75c4665d", | ||
"version": "0.0.0-pr-30070-sha-0b45cb37", | ||
"description": "Storybook Vue 3 renderer", | ||
@@ -64,7 +64,7 @@ "keywords": [ | ||
"dependencies": { | ||
"@storybook/components": "0.0.0-pr-30055-sha-75c4665d", | ||
"@storybook/components": "0.0.0-pr-30070-sha-0b45cb37", | ||
"@storybook/global": "^5.0.0", | ||
"@storybook/manager-api": "0.0.0-pr-30055-sha-75c4665d", | ||
"@storybook/preview-api": "0.0.0-pr-30055-sha-75c4665d", | ||
"@storybook/theming": "0.0.0-pr-30055-sha-75c4665d", | ||
"@storybook/manager-api": "0.0.0-pr-30070-sha-0b45cb37", | ||
"@storybook/preview-api": "0.0.0-pr-30070-sha-0b45cb37", | ||
"@storybook/theming": "0.0.0-pr-30070-sha-0b45cb37", | ||
"@vue/compiler-core": "^3.0.0", | ||
@@ -85,3 +85,3 @@ "ts-dedent": "^2.0.0", | ||
"peerDependencies": { | ||
"storybook": "^0.0.0-pr-30055-sha-75c4665d", | ||
"storybook": "^0.0.0-pr-30070-sha-0b45cb37", | ||
"vue": "^3.0.0" | ||
@@ -88,0 +88,0 @@ }, |
Sorry, the diff of this file is not supported yet
86111
837
+ Added@storybook/components@0.0.0-pr-30070-sha-0b45cb37(transitive)
+ Added@storybook/manager-api@0.0.0-pr-30070-sha-0b45cb37(transitive)
+ Added@storybook/preview-api@0.0.0-pr-30070-sha-0b45cb37(transitive)
+ Added@storybook/theming@0.0.0-pr-30070-sha-0b45cb37(transitive)
- Removed@storybook/components@0.0.0-pr-30055-sha-75c4665d(transitive)
- Removed@storybook/manager-api@0.0.0-pr-30055-sha-75c4665d(transitive)
- Removed@storybook/preview-api@0.0.0-pr-30055-sha-75c4665d(transitive)
- Removed@storybook/theming@0.0.0-pr-30055-sha-75c4665d(transitive)