@storybook/svelte-vite 9.0.0-alpha.13 → 9.0.0-alpha.15
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/preset.js +1 -9
- package/package.json +5 -5
- package/template/stories_svelte-vite-default-js/docgen/jsdoc.stories.js +17 -0
- package/template/stories_svelte-vite-default-js/docgen/jsdoc.svelte +92 -0
- package/template/stories_svelte-vite-default-ts/docgen/jsdoc.stories.js +17 -0
- package/template/stories_svelte-vite-default-ts/docgen/jsdoc.svelte +91 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-inline-prop-types.stories.ts +16 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-inline-prop-types.svelte +103 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-legacy.stories.ts +16 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-legacy.svelte +98 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-referenced-prop-types.stories.ts +16 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts-referenced-prop-types.svelte +107 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts.stories.ts +16 -0
- package/template/stories_svelte-vite-default-ts/docgen/ts.svelte +125 -0
- package/template/cli/js/Button.stories.js +0 -43
- package/template/cli/js/Button.svelte +0 -36
- package/template/cli/js/Header.stories.js +0 -22
- package/template/cli/js/Header.svelte +0 -52
- package/template/cli/js/Page.stories.js +0 -28
- package/template/cli/js/Page.svelte +0 -70
- package/template/cli/svelte-5-js/Button.stories.svelte +0 -31
- package/template/cli/svelte-5-js/Button.svelte +0 -26
- package/template/cli/svelte-5-js/Header.stories.svelte +0 -26
- package/template/cli/svelte-5-js/Header.svelte +0 -47
- package/template/cli/svelte-5-js/Page.stories.svelte +0 -30
- package/template/cli/svelte-5-js/Page.svelte +0 -70
- package/template/cli/svelte-5-ts-3-8/Button.stories.svelte +0 -31
- package/template/cli/svelte-5-ts-3-8/Button.svelte +0 -29
- package/template/cli/svelte-5-ts-3-8/Header.stories.svelte +0 -26
- package/template/cli/svelte-5-ts-3-8/Header.svelte +0 -45
- package/template/cli/svelte-5-ts-3-8/Page.stories.svelte +0 -30
- package/template/cli/svelte-5-ts-3-8/Page.svelte +0 -70
- package/template/cli/svelte-5-ts-4-9/Button.stories.svelte +0 -31
- package/template/cli/svelte-5-ts-4-9/Button.svelte +0 -29
- package/template/cli/svelte-5-ts-4-9/Header.stories.svelte +0 -26
- package/template/cli/svelte-5-ts-4-9/Header.svelte +0 -45
- package/template/cli/svelte-5-ts-4-9/Page.stories.svelte +0 -30
- package/template/cli/svelte-5-ts-4-9/Page.svelte +0 -70
- package/template/cli/ts-4-9/Button.stories.ts +0 -48
- package/template/cli/ts-4-9/Button.svelte +0 -34
- package/template/cli/ts-4-9/Header.stories.ts +0 -27
- package/template/cli/ts-4-9/Header.svelte +0 -52
- package/template/cli/ts-4-9/Page.stories.ts +0 -33
- package/template/cli/ts-4-9/Page.svelte +0 -70
- package/template/stories_svelte-vite-default-ts/DocsTS.svelte +0 -97
- package/template/stories_svelte-vite-default-ts/docs-ts.stories.js +0 -10
- /package/template/stories_svelte-vite-default-ts/{types.ts → docgen/types.ts} +0 -0
package/dist/preset.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__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 __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var preset_exports={};__export(preset_exports,{core:()=>core,viteFinal:()=>viteFinal});module.exports=__toCommonJS(preset_exports);var import_node_path3=require("path");var import_node_fs=require("fs"),import_node_path2=require("path"),import_node_logger=require("storybook/internal/node-logger"),import_magic_string=__toESM(require("magic-string")),import_svelte_preprocess=require("svelte-preprocess"),import_compiler2=require("svelte/compiler"),import_sveltedoc_parser=__toESM(require("sveltedoc-parser"));var import_node_path=__toESM(require("path")),import_svelte2tsx=__toESM(require("svelte2tsx")),import_compiler=require("svelte/compiler"),import_typescript=__toESM(require("typescript"));function convertType(type,checker){if(type.flags&import_typescript.default.TypeFlags.Any)return{type:"any"};if(type.flags&import_typescript.default.TypeFlags.Number)return{type:"number"};if(type.flags&import_typescript.default.TypeFlags.String)return{type:"string"};if(type.flags&import_typescript.default.TypeFlags.Boolean)return{type:"boolean"};if(type.flags&import_typescript.default.TypeFlags.ESSymbol)return{type:"symbol"};if(type.flags&import_typescript.default.TypeFlags.Null)return{type:"null"};if(type.flags&import_typescript.default.TypeFlags.Undefined)return{type:"undefined"};if(type.flags&import_typescript.default.TypeFlags.Void)return{type:"void"};if(type.getCallSignatures().length>0)return{type:"function",text:checker.typeToString(type)};if(type.flags&import_typescript.default.TypeFlags.Object)return checker.getIndexTypeOfType(type,import_typescript.default.IndexKind.Number)?{type:"array",text:checker.typeToString(type)}:{type:"object",text:checker.typeToString(type)};if(type.isNumberLiteral()||type.isStringLiteral())return{type:"literal",value:type.value,text:type.flags&import_typescript.default.TypeFlags.EnumLiteral?checker.typeToString(type):JSON.stringify(type.value)};if(type.flags&import_typescript.default.TypeFlags.BooleanLiteral){let text=checker.typeToString(type);return{type:"literal",value:text==="true",text}}if(type.isUnion()){let types=type.types.map(t=>convertType(t,checker)).filter(t=>t!==void 0&&t.type!=="undefined"),idxTrue=types.findIndex(t=>t.type==="literal"&&t.value===!0),idxFalse=types.findIndex(t=>t.type==="literal"&&t.value===!1);return idxTrue!==-1&&idxFalse!==-1&&(types.splice(Math.max(idxTrue,idxFalse),1),types.splice(Math.min(idxTrue,idxFalse),1,{type:"boolean"})),types.length>1?{type:"union",types}:types[0]}if(type.isIntersection())return{type:"intersection",types:type.types.map(t=>convertType(t,checker)).filter(t=>t!==void 0)}}function initializerToDefaultValue(expr,checker){if(import_typescript.default.isNumericLiteral(expr))return{text:expr.text};if(import_typescript.default.isStringLiteral(expr))return{text:JSON.stringify(expr.text)};if(import_typescript.default.isIdentifier(expr)||import_typescript.default.isPropertyAccessExpression(expr)){let symbol=checker.getSymbolAtLocation(expr);if(symbol&&checker.isUndefinedSymbol(symbol))return;let type=checker.getTypeAtLocation(expr);if(type.flags&import_typescript.default.TypeFlags.EnumLiteral)return{text:checker.typeToString(type)};if(type.isLiteral())return{text:JSON.stringify(type.value)};if(type.flags&import_typescript.default.TypeFlags.Null)return{text:"null"};if(type.flags&import_typescript.default.TypeFlags.BooleanLiteral)return{text:checker.typeToString(type)};if(type.getCallSignatures().length>0)return{text:"function"}}else{if(import_typescript.default.isArrayLiteralExpression(expr)||import_typescript.default.isObjectLiteralExpression(expr)||import_typescript.default.isNewExpression(expr))return{text:expr.getText()};if(import_typescript.default.isArrowFunction(expr))return{text:"function"}}switch(expr.kind){case import_typescript.default.SyntaxKind.TrueKeyword:return{text:"true"};case import_typescript.default.SyntaxKind.FalseKeyword:return{text:"false"};case import_typescript.default.SyntaxKind.NullKeyword:return{text:"null"}}return{text:"..."}}function loadConfig(basepath){let configPath=import_typescript.default.findConfigFile(basepath,import_typescript.default.sys.fileExists)||import_typescript.default.findConfigFile(basepath,import_typescript.default.sys.fileExists,"jsconfig.json"),forcedOptions={sourceMap:!1,noEmit:!0,strict:!0,allowJs:!0,checkJs:!0,skipLibCheck:!0,skipDefaultLibCheck:!0};if(!configPath)return[forcedOptions,new Set];let configFile=import_typescript.default.readConfigFile(configPath,import_typescript.default.sys.readFile),config=import_typescript.default.parseJsonConfigFileContent(configFile.config,import_typescript.default.sys,import_node_path.default.dirname(configPath),void 0,configPath,void 0,[{extension:"svelte",isMixedContent:!0,scriptKind:import_typescript.default.ScriptKind.Deferred}]),fileNames=new Set(config.fileNames.filter(fileName=>fileName.endsWith(".svelte")).map(fileName=>fileName+".tsx"));return[{...config.options,...forcedOptions},fileNames]}function createDocgenCache(){return{filenameToModifiedTime:{},filenameToSourceFile:{},fileCache:{}}}function generateDocgen(targetFileName,cache){targetFileName.endsWith(".svelte")&&(targetFileName=targetFileName+".tsx");let propsRuneUsed=!1;if(cache.options===void 0||!cache.rootNames?.has(targetFileName)){[cache.options,cache.rootNames]=loadConfig(targetFileName);let shimFilename=require.resolve("svelte2tsx/svelte-shims-v4.d.ts");cache.rootNames.add(shimFilename),cache.rootNames.add(targetFileName)}let originalHost=import_typescript.default.createCompilerHost(cache.options),host={...originalHost,readFile(fileName){let isCacheTarget=fileName.endsWith(import_node_path.default.sep+"package.json");if(isCacheTarget&&cache.fileCache[fileName])return cache.fileCache[fileName];let content=originalHost.readFile(fileName);return content&&isCacheTarget&&(cache.fileCache[fileName]=content),content},fileExists(fileName){if(fileName.endsWith(import_node_path.default.sep+"package.json")&&cache.fileCache[fileName])return!0;let exists=originalHost.fileExists(fileName);return exists||(fileName.endsWith(".svelte.tsx")||fileName.endsWith(".svelte.jsx")?(fileName=fileName.slice(0,-4),exists=originalHost.fileExists(fileName),exists):!1)},getSourceFile(fileName,languageVersion,onError){if(fileName.endsWith(".svelte.tsx")||fileName.endsWith(".svelte.jsx")){let realFileName=fileName.slice(0,-4),modifiedTime=import_typescript.default.sys.getModifiedTime?import_typescript.default.sys.getModifiedTime(realFileName):void 0;if(modifiedTime&&cache.filenameToModifiedTime[fileName]?.getTime()===modifiedTime.getTime())return cache.filenameToSourceFile[fileName];let content=originalHost.readFile(realFileName);if(content===void 0)return;let isTsFile=/<script\s+[^>]*?lang=('|")(ts|typescript)('|")/.test(content),tsx=import_svelte2tsx.default.svelte2tsx(content,{version:import_compiler.VERSION,isTsFile,mode:"dts"}),sourceFile2=import_typescript.default.createSourceFile(fileName,tsx.code,languageVersion,!0,isTsFile?import_typescript.default.ScriptKind.TS:import_typescript.default.ScriptKind.JS);return cache.filenameToSourceFile[fileName]=sourceFile2,cache.filenameToModifiedTime[fileName]=modifiedTime,sourceFile2}else{let staticCaching=!1;staticCaching||=fileName.split(import_node_path.default.sep).some(part=>part.toLowerCase()==="node_modules");let cachedSourceFile=cache.filenameToSourceFile[fileName];if(cachedSourceFile&&staticCaching)return cachedSourceFile;let modifiedTime=import_typescript.default.sys.getModifiedTime?import_typescript.default.sys.getModifiedTime(fileName):void 0;if(modifiedTime&&cache.filenameToModifiedTime[fileName]?.getTime()===modifiedTime.getTime())return cache.filenameToSourceFile[fileName];let content=originalHost.readFile(fileName);if(content===void 0)return;let sourceFile2=import_typescript.default.createSourceFile(fileName,content,languageVersion,!0);return cache.filenameToSourceFile[fileName]=sourceFile2,cache.filenameToModifiedTime[fileName]=modifiedTime,sourceFile2}},writeFile(){}},program=import_typescript.default.createProgram({rootNames:Array.from(cache.rootNames),options:cache.options,host,oldProgram:cache.oldProgram});cache.oldProgram=program;let checker=program.getTypeChecker(),sourceFile=program.getSourceFile(targetFileName);if(sourceFile===void 0)return{props:[]};let propMap=new Map,renderFunction=sourceFile.statements.find(statement=>import_typescript.default.isFunctionDeclaration(statement)&&statement.name?.text===import_svelte2tsx.internalHelpers.renderName);if(renderFunction===void 0)return{props:[]};let propsType,signature=checker.getSignatureFromDeclaration(renderFunction);return signature&&signature.declaration&&checker.getReturnTypeOfSignature(signature).getProperties().forEach(retObjProp=>{if(retObjProp.name==="props"){let decl=signature.getDeclaration();propsType=checker.getTypeOfSymbolAtLocation(retObjProp,decl),propsType.getProperties().forEach(prop=>{let name=prop.getName(),description=import_typescript.default.displayPartsToString(prop.getDocumentationComment(checker))||void 0,propType=checker.getTypeOfSymbolAtLocation(prop,decl);if(prop.valueDeclaration){let typeTag=import_typescript.default.getJSDocTypeTag(prop.valueDeclaration);typeTag?.comment&&(description=((description||"")+`
|
|
2
2
|
`+typeTag.comment).trim())}if(prop.valueDeclaration?.getSourceFile().fileName.includes("node_modules/svelte/elements.d.ts"))return;let optional=(prop.flags&import_typescript.default.SymbolFlags.Optional)!==0;propMap.set(name,{name,optional,description,type:convertType(propType,checker)})})}}),renderFunction.body?.forEachChild(node=>{import_typescript.default.isVariableStatement(node)&&node.declarationList.declarations.forEach(declaration=>{if(import_typescript.default.isObjectBindingPattern(declaration.name)){let isPropsRune=declaration.initializer&&import_typescript.default.isCallExpression(declaration.initializer)&&import_typescript.default.isIdentifier(declaration.initializer.expression)&&declaration.initializer.expression.text==="$props",isPropsType=declaration.type&&propsType===checker.getTypeFromTypeNode(declaration.type);(isPropsRune||isPropsType)&&(propsRuneUsed=!0,declaration.name.elements.forEach(element=>{let name=element.name.getText(),prop=propMap.get(name);if(prop&&element.initializer){let defaultValue=initializerToDefaultValue(element.initializer,checker);defaultValue&&(prop.defaultValue=defaultValue)}}))}if(import_typescript.default.isVariableDeclaration(declaration)&&import_typescript.default.isIdentifier(declaration.name)&&propMap.has(declaration.name.text)){let prop=propMap.get(declaration.name.text);if(prop&&declaration.initializer){prop.optional=!0;let defaultValue=initializerToDefaultValue(declaration.initializer,checker);defaultValue&&(prop.defaultValue=defaultValue)}}})}),{props:Array.from(propMap.values()),propsRuneUsed}}var svelteDocParserOptions=require("sveltedoc-parser/lib/options.js");svelteDocParserOptions.getAstDefaultOptions=()=>({range:!0,loc:!0,comment:!0,tokens:!0,ecmaVersion:12,sourceType:"module",ecmaFeatures:{}});function getComponentName(ast){let exportDefaultDeclaration=ast.body.find(n=>n.type==="ExportDefaultDeclaration");if(!exportDefaultDeclaration)throw new Error("Unreachable - no default export found");if(exportDefaultDeclaration.declaration.type==="Identifier")return exportDefaultDeclaration.declaration.name;if(exportDefaultDeclaration.declaration.type!=="ClassDeclaration"&&exportDefaultDeclaration.declaration.type!=="FunctionDeclaration")throw new Error("Unreachable - not a class or a function");if(!exportDefaultDeclaration.declaration.id)throw new Error("Unreachable - unnamed class/function");return exportDefaultDeclaration.declaration.id.name}function transformToSvelteDocParserType(type){switch(type.type){case"string":return{kind:"type",type:"string",text:"string"};case"number":return{kind:"type",type:"number",text:"number"};case"boolean":return{kind:"type",type:"boolean",text:"boolean"};case"symbol":return{kind:"type",type:"other",text:"symbol"};case"null":return{kind:"type",type:"other",text:"null"};case"undefined":return{kind:"type",type:"other",text:"undefined"};case"void":return{kind:"type",type:"other",text:"void"};case"any":return{kind:"type",type:"any",text:"any"};case"object":return{kind:"type",type:"object",text:type.text};case"array":return{kind:"type",type:"array",text:type.text};case"function":return{kind:"function",text:type.text};case"literal":return{kind:"const",type:typeof type.value,value:type.value,text:type.text};case"union":{let nonNull=type.types.filter(t=>t.type!=="null"),text=nonNull.map(t=>transformToSvelteDocParserType(t).text).join(" | "),types=nonNull.map(t=>transformToSvelteDocParserType(t));return types.length===1?types[0]:{kind:"union",type:types,text}}case"intersection":return{kind:"type",type:"intersection",text:type.types.map(t=>transformToSvelteDocParserType(t).text).join(" & ")}}}function transformToSvelteDocParserDataItems(docgen){return docgen.props.map(p=>{let required=p.optional===!1&&p.defaultValue===void 0;return{name:p.name,visibility:"public",description:p.description,keywords:required?[{name:"required",description:""}]:[],kind:"let",type:p.type?transformToSvelteDocParserType(p.type):void 0,static:!1,readonly:!1,importPath:void 0,originalName:void 0,localName:void 0,defaultValue:p.defaultValue?p.defaultValue.text:void 0}})}async function svelteDocgen(svelteOptions={}){let cwd=process.cwd(),{preprocess:preprocessOptions,logDocgen=!1}=svelteOptions,include=/\.svelte$/,exclude=/node_modules\/.*/,{createFilter}=await import("vite"),filter=createFilter(include,exclude),sourceFileCache=createDocgenCache(),docPreprocessOptions;return{name:"storybook:svelte-docgen-plugin",async transform(src,id){if(id.startsWith("\0")||!filter(id))return;let resource=(0,import_node_path2.relative)(cwd,id),docgen=generateDocgen(resource,sourceFileCache),data=transformToSvelteDocParserDataItems(docgen),componentDoc={};if(!docgen.propsRuneUsed){if(preprocessOptions&&!docPreprocessOptions){docPreprocessOptions=[(0,import_svelte_preprocess.replace)([[/<style.+<\/style>/gims,""]])];try{require.resolve("typescript")&&docPreprocessOptions.unshift((0,import_svelte_preprocess.typescript)())}catch{}}let docOptions;if(docPreprocessOptions){let rawSource;try{rawSource=(0,import_node_fs.readFileSync)(resource).toString()}catch{return}let{code:fileContent}=await(0,import_compiler2.preprocess)(rawSource,docPreprocessOptions,{filename:resource});docOptions={fileContent}}else docOptions={filename:resource};let options={...docOptions,version:3};try{componentDoc=await import_sveltedoc_parser.default.parse(options)}catch(error){componentDoc={keywords:[],data:[]},logDocgen&&import_node_logger.logger.error(error)}}componentDoc.data=data;let file=(0,import_node_path2.basename)(resource);componentDoc.name=(0,import_node_path2.basename)(file);let s=new import_magic_string.default(src),outputAst=this.parse(src),componentName=getComponentName(outputAst);return s.append(`
|
|
3
|
-
;${componentName}.__docgen = ${JSON.stringify(componentDoc)}`),{code:s.toString(),map:s.generateMap({hires:!0,source:id})}}}}var
|
|
4
|
-
We've detected a SvelteKit project using the @storybook/svelte-vite framework, which is not supported in Storybook 7.0
|
|
5
|
-
Please use the @storybook/sveltekit framework instead.
|
|
6
|
-
You can migrate automatically by running
|
|
7
|
-
|
|
8
|
-
npx storybook@latest automigrate
|
|
9
|
-
|
|
10
|
-
See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#sveltekit-needs-the-storybooksveltekit-framework
|
|
11
|
-
`)}var getAbsolutePath=input=>(0,import_node_path3.dirname)(require.resolve((0,import_node_path3.join)(input,"package.json"))),core={builder:getAbsolutePath("@storybook/builder-vite"),renderer:getAbsolutePath("@storybook/svelte")},viteFinal=async(config,options)=>{let{plugins=[]}=config,{loadSvelteConfig}=await import("@sveltejs/vite-plugin-svelte"),svelteConfig=await loadSvelteConfig();return plugins.push(await svelteDocgen(svelteConfig)),await handleSvelteKit(plugins,options),{...config,plugins}};0&&(module.exports={core,viteFinal});
|
|
3
|
+
;${componentName}.__docgen = ${JSON.stringify(componentDoc)}`),{code:s.toString(),map:s.generateMap({hires:!0,source:id})}}}}var import_server_errors=require("storybook/internal/server-errors"),import_builder_vite=require("@storybook/builder-vite");async function handleSvelteKit(plugins,options){let frameworkPreset=await options.presets.apply("framework",{},options),framework=typeof frameworkPreset=="string"?frameworkPreset:frameworkPreset.name;if(await(0,import_builder_vite.hasVitePlugins)(plugins,["vite-plugin-svelte-kit","vite-plugin-sveltekit-setup","vite-plugin-sveltekit-compile"])&&!framework.includes("@storybook/sveltekit"))throw new import_server_errors.SvelteViteWithSvelteKitError}var getAbsolutePath=input=>(0,import_node_path3.dirname)(require.resolve((0,import_node_path3.join)(input,"package.json"))),core={builder:getAbsolutePath("@storybook/builder-vite"),renderer:getAbsolutePath("@storybook/svelte")},viteFinal=async(config,options)=>{let{plugins=[]}=config,{loadSvelteConfig}=await import("@sveltejs/vite-plugin-svelte"),svelteConfig=await loadSvelteConfig();return plugins.push(await svelteDocgen(svelteConfig)),await handleSvelteKit(plugins,options),{...config,plugins}};0&&(module.exports={core,viteFinal});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/svelte-vite",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.15",
|
|
4
4
|
"description": "Storybook for Svelte and Vite: Develop Svelte components in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"prep": "jiti ../../../scripts/prepare/bundle.ts"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@storybook/builder-vite": "9.0.0-alpha.
|
|
58
|
-
"@storybook/svelte": "9.0.0-alpha.
|
|
57
|
+
"@storybook/builder-vite": "9.0.0-alpha.15",
|
|
58
|
+
"@storybook/svelte": "9.0.0-alpha.15",
|
|
59
59
|
"magic-string": "^0.30.0",
|
|
60
60
|
"svelte-preprocess": "^5.1.1",
|
|
61
61
|
"svelte2tsx": "^0.7.35",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@sveltejs/vite-plugin-svelte": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0",
|
|
75
|
-
"storybook": "^9.0.0-alpha.
|
|
76
|
-
"svelte": "^
|
|
75
|
+
"storybook": "^9.0.0-alpha.15",
|
|
76
|
+
"svelte": "^5.0.0",
|
|
77
77
|
"vite": "^5.0.0 || ^6.0.0"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import JSDoc from './jsdoc.svelte';
|
|
2
|
+
|
|
3
|
+
/** @typedef {import('@storybook/svelte-vite').StoryObj} StoryObj */
|
|
4
|
+
|
|
5
|
+
/** @type {Meta<typeof JSDoc>} */
|
|
6
|
+
const meta = {
|
|
7
|
+
component: JSDoc,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
render: (args, { argTypes }) => ({
|
|
10
|
+
Component: JSDoc,
|
|
11
|
+
props: { ...args, argTypes },
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
export const Default = {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Object} MyObject
|
|
4
|
+
* @property {string} foo
|
|
5
|
+
* @property {number} bar
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} MyProps
|
|
10
|
+
* @property {boolean} [boolean] Boolean
|
|
11
|
+
* @property {string} [string] String
|
|
12
|
+
* @property {string} stringRequired String (required)
|
|
13
|
+
* @property {number} [number] Number
|
|
14
|
+
* @property {true} [trueLiteral] True literal
|
|
15
|
+
* @property {symbol} [symbol] Symbol
|
|
16
|
+
* @property {null} [nullValue] Null
|
|
17
|
+
* @property {undefined} [undefinedValue] Undefined
|
|
18
|
+
* @property {any} [any] Any
|
|
19
|
+
* @property {Date} [date] Date
|
|
20
|
+
* @property {import('./types').LiteralStrings} [unionLiteralStrings] Union of literal strings
|
|
21
|
+
* @property {import('./types').LiteralNumbers} [unionLiteralNumbers] Union of literal numbers
|
|
22
|
+
* @property {MyObject} [object] Object
|
|
23
|
+
* @property {{ foo: string; bar: number }} [inlineObject] Inline object
|
|
24
|
+
* @property {Record<string, number>} [record] Record
|
|
25
|
+
* @property {number | string} [unionTypes] Union of types
|
|
26
|
+
* @property {{ a: number } & { b: string }} [intersection] Intersection of types
|
|
27
|
+
* @property {(event: MouseEvent) => number} [func] Event callback function
|
|
28
|
+
* @property {import('svelte').Snippet} children Snippet contents
|
|
29
|
+
* @property {Record<string, any>} [argTypes] Actual arg types inferred from the component
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** @type {MyProps} */
|
|
33
|
+
let {
|
|
34
|
+
boolean = true,
|
|
35
|
+
string = 'default',
|
|
36
|
+
stringRequired,
|
|
37
|
+
number = 123,
|
|
38
|
+
trueLiteral = undefined,
|
|
39
|
+
symbol = undefined,
|
|
40
|
+
nullValue = null,
|
|
41
|
+
undefinedValue = undefined,
|
|
42
|
+
any = undefined,
|
|
43
|
+
date = new Date('20 Jan 1983'),
|
|
44
|
+
unionLiteralStrings = 'apple',
|
|
45
|
+
unionLiteralNumbers = 1000,
|
|
46
|
+
object = undefined,
|
|
47
|
+
inlineObject = undefined,
|
|
48
|
+
record = { a: 1, b: 2 },
|
|
49
|
+
unionTypes = 123,
|
|
50
|
+
intersection = undefined,
|
|
51
|
+
func = () => 10,
|
|
52
|
+
children,
|
|
53
|
+
argTypes,
|
|
54
|
+
} = $props();
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<h1>Docgen: JS - JSDoc</h1>
|
|
58
|
+
|
|
59
|
+
<h2>Args</h2>
|
|
60
|
+
<pre>{JSON.stringify(
|
|
61
|
+
{
|
|
62
|
+
boolean,
|
|
63
|
+
string,
|
|
64
|
+
stringRequired,
|
|
65
|
+
number,
|
|
66
|
+
trueLiteral,
|
|
67
|
+
symbol,
|
|
68
|
+
nullValue,
|
|
69
|
+
undefinedValue,
|
|
70
|
+
any,
|
|
71
|
+
date,
|
|
72
|
+
unionLiteralStrings,
|
|
73
|
+
unionLiteralNumbers,
|
|
74
|
+
object,
|
|
75
|
+
inlineObject,
|
|
76
|
+
record,
|
|
77
|
+
unionTypes,
|
|
78
|
+
intersection,
|
|
79
|
+
func,
|
|
80
|
+
argTypes,
|
|
81
|
+
},
|
|
82
|
+
null,
|
|
83
|
+
2
|
|
84
|
+
)}</pre>
|
|
85
|
+
|
|
86
|
+
<h2>Children</h2>
|
|
87
|
+
{#if children}
|
|
88
|
+
{@render children()}
|
|
89
|
+
{/if}
|
|
90
|
+
|
|
91
|
+
<h2>Arg Types</h2>
|
|
92
|
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import JSDoc from './jsdoc.svelte';
|
|
2
|
+
|
|
3
|
+
/** @typedef {import('@storybook/svelte-vite').StoryObj} StoryObj */
|
|
4
|
+
|
|
5
|
+
/** @type {Meta<typeof JSDoc>} */
|
|
6
|
+
const meta = {
|
|
7
|
+
component: JSDoc,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
render: (args, { argTypes }) => ({
|
|
10
|
+
Component: JSDoc,
|
|
11
|
+
props: { ...args, argTypes },
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
export const Default = {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Object} MyObject
|
|
4
|
+
* @property {string} foo
|
|
5
|
+
* @property {number} bar
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} MyProps
|
|
10
|
+
* @property {boolean} [boolean] Boolean
|
|
11
|
+
* @property {string} [string] String
|
|
12
|
+
* @property {string} stringRequired String (required)
|
|
13
|
+
* @property {number} [number] Number
|
|
14
|
+
* @property {true} [trueLiteral] True literal
|
|
15
|
+
* @property {symbol} [symbol] Symbol
|
|
16
|
+
* @property {null} [nullValue] Null
|
|
17
|
+
* @property {undefined} [undefinedValue] Undefined
|
|
18
|
+
* @property {any} [any] Any
|
|
19
|
+
* @property {import('./types').LiteralStrings} [unionLiteralStrings] Union of literal strings
|
|
20
|
+
* @property {import('./types').LiteralNumbers} [unionLiteralNumbers] Union of literal numbers
|
|
21
|
+
* @property {MyObject} [object] Object
|
|
22
|
+
* @property {{ foo: string; bar: number }} [inlineObject] Inline object
|
|
23
|
+
* @property {Record<string, number>} [record] Record
|
|
24
|
+
* @property {Date} [date] Date
|
|
25
|
+
* @property {number | string} [unionTypes] Union of types
|
|
26
|
+
* @property {{ a: number } & { b: string }} [intersection] Intersection of types
|
|
27
|
+
* @property {import('svelte').Snippet} children Snippet contents
|
|
28
|
+
* @property {(event: MouseEvent) => number} [func] Event callback function
|
|
29
|
+
* @property {Record<string, any>} [argTypes] Actual arg types inferred from the component
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** @type {MyProps} */
|
|
33
|
+
let {
|
|
34
|
+
boolean = true,
|
|
35
|
+
string = 'default',
|
|
36
|
+
stringRequired,
|
|
37
|
+
number = 123,
|
|
38
|
+
trueLiteral = undefined,
|
|
39
|
+
symbol = undefined,
|
|
40
|
+
nullValue = null,
|
|
41
|
+
undefinedValue = undefined,
|
|
42
|
+
any = undefined,
|
|
43
|
+
unionLiteralStrings = 'apple',
|
|
44
|
+
unionLiteralNumbers = 1000,
|
|
45
|
+
object = undefined,
|
|
46
|
+
inlineObject = undefined,
|
|
47
|
+
record = { a: 1, b: 2 },
|
|
48
|
+
date = new Date('20 Jan 1983'),
|
|
49
|
+
unionTypes = 123,
|
|
50
|
+
intersection = undefined,
|
|
51
|
+
children,
|
|
52
|
+
func = () => 10,
|
|
53
|
+
argTypes,
|
|
54
|
+
} = $props();
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<h1>Docgen: JS - JSDoc</h1>
|
|
58
|
+
|
|
59
|
+
<h2>Args</h2>
|
|
60
|
+
<pre>{JSON.stringify(
|
|
61
|
+
{
|
|
62
|
+
boolean,
|
|
63
|
+
string,
|
|
64
|
+
stringRequired,
|
|
65
|
+
number,
|
|
66
|
+
trueLiteral,
|
|
67
|
+
symbol,
|
|
68
|
+
nullValue,
|
|
69
|
+
undefinedValue,
|
|
70
|
+
any,
|
|
71
|
+
date,
|
|
72
|
+
unionLiteralStrings,
|
|
73
|
+
unionLiteralNumbers,
|
|
74
|
+
object,
|
|
75
|
+
inlineObject,
|
|
76
|
+
record,
|
|
77
|
+
unionTypes,
|
|
78
|
+
intersection,
|
|
79
|
+
func,
|
|
80
|
+
},
|
|
81
|
+
null,
|
|
82
|
+
2
|
|
83
|
+
)}</pre>
|
|
84
|
+
|
|
85
|
+
<h2>Children</h2>
|
|
86
|
+
{#if children}
|
|
87
|
+
{@render children()}
|
|
88
|
+
{/if}
|
|
89
|
+
|
|
90
|
+
<h2>Arg Types</h2>
|
|
91
|
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/svelte-vite';
|
|
2
|
+
|
|
3
|
+
import TSInlinePropTypes from './ts-inline-prop-types.svelte';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
component: TSInlinePropTypes,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
render: (args, { argTypes }) => ({
|
|
9
|
+
Component: TSInlinePropTypes,
|
|
10
|
+
props: { ...args, argTypes },
|
|
11
|
+
}),
|
|
12
|
+
} satisfies Meta<typeof TSInlinePropTypes>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
export const Default = {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { LiteralNumbers, LiteralStrings } from './types';
|
|
4
|
+
import { MyEnum } from './types';
|
|
5
|
+
|
|
6
|
+
type MyObject = {
|
|
7
|
+
foo: string;
|
|
8
|
+
bar: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
boolean = true,
|
|
13
|
+
string = 'default',
|
|
14
|
+
stringRequired,
|
|
15
|
+
number = 123,
|
|
16
|
+
nullValue = null,
|
|
17
|
+
arrayOfNumbers = [1, 20, 300],
|
|
18
|
+
enumValue = MyEnum.FOO,
|
|
19
|
+
record = { a: 1, b: 2 },
|
|
20
|
+
date = new Date('20 Jan 1983'),
|
|
21
|
+
unionTypes = 123,
|
|
22
|
+
func = () => 10,
|
|
23
|
+
children,
|
|
24
|
+
argTypes,
|
|
25
|
+
}: {
|
|
26
|
+
/** Boolean */
|
|
27
|
+
boolean?: boolean;
|
|
28
|
+
/** String */
|
|
29
|
+
string?: string;
|
|
30
|
+
/** String (required) */
|
|
31
|
+
stringRequired: string;
|
|
32
|
+
/** Number */
|
|
33
|
+
number?: number;
|
|
34
|
+
/** True literal */
|
|
35
|
+
trueLiteral?: true;
|
|
36
|
+
/** Symbol */
|
|
37
|
+
symbol?: symbol;
|
|
38
|
+
/** Null */
|
|
39
|
+
nullValue?: null;
|
|
40
|
+
/** Undefined */
|
|
41
|
+
undefinedValue?: undefined;
|
|
42
|
+
/** Any */
|
|
43
|
+
any?: any;
|
|
44
|
+
/** Date */
|
|
45
|
+
date?: Date;
|
|
46
|
+
/** Array of numbers */
|
|
47
|
+
arrayOfNumbers?: number[];
|
|
48
|
+
/** Enum */
|
|
49
|
+
enumValue?: MyEnum;
|
|
50
|
+
/** Union of literal strings */
|
|
51
|
+
unionLiteralStrings?: LiteralStrings;
|
|
52
|
+
/** Union of literal numbers */
|
|
53
|
+
unionLiteralNumbers?: LiteralNumbers;
|
|
54
|
+
/** Object */
|
|
55
|
+
object?: MyObject;
|
|
56
|
+
/** Inline object */
|
|
57
|
+
inlineObject?: {
|
|
58
|
+
foo: string;
|
|
59
|
+
bar: number;
|
|
60
|
+
};
|
|
61
|
+
/** Record */
|
|
62
|
+
record?: Record<string, number>;
|
|
63
|
+
/** Union of types */
|
|
64
|
+
unionTypes?: number | string;
|
|
65
|
+
/** Intersection of types */
|
|
66
|
+
intersection?: { a: number } & { b: string };
|
|
67
|
+
/** Event callback function */
|
|
68
|
+
func?: (event: MouseEvent) => number;
|
|
69
|
+
/** Snippet contents */
|
|
70
|
+
children: Snippet;
|
|
71
|
+
/** Actual arg types inferred from the component */
|
|
72
|
+
argTypes: Record<string, any>;
|
|
73
|
+
} = $props();
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<h1>Docgen: TS - inline prop types</h1>
|
|
77
|
+
|
|
78
|
+
<h2>Args</h2>
|
|
79
|
+
<pre>{JSON.stringify(
|
|
80
|
+
{
|
|
81
|
+
boolean,
|
|
82
|
+
string,
|
|
83
|
+
stringRequired,
|
|
84
|
+
number,
|
|
85
|
+
nullValue,
|
|
86
|
+
date,
|
|
87
|
+
arrayOfNumbers,
|
|
88
|
+
enumValue,
|
|
89
|
+
record,
|
|
90
|
+
unionTypes,
|
|
91
|
+
func,
|
|
92
|
+
},
|
|
93
|
+
null,
|
|
94
|
+
2
|
|
95
|
+
)}</pre>
|
|
96
|
+
|
|
97
|
+
<h2>Children</h2>
|
|
98
|
+
{#if children}
|
|
99
|
+
{@render children()}
|
|
100
|
+
{/if}
|
|
101
|
+
|
|
102
|
+
<h2>Arg Types</h2>
|
|
103
|
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/svelte-vite';
|
|
2
|
+
|
|
3
|
+
import TSLegacy from './ts-legacy.svelte';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
component: TSLegacy,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
render: (args, { argTypes }) => ({
|
|
9
|
+
Component: TSLegacy,
|
|
10
|
+
props: { ...args, argTypes } as any,
|
|
11
|
+
}),
|
|
12
|
+
} satisfies Meta<typeof TSLegacy>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
export const Default = {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { LiteralNumbers, LiteralStrings } from './types';
|
|
4
|
+
import { MyEnum } from './types';
|
|
5
|
+
|
|
6
|
+
type MyObject = {
|
|
7
|
+
foo: string;
|
|
8
|
+
bar: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Boolean */
|
|
12
|
+
export let boolean: boolean = true;
|
|
13
|
+
/** String */
|
|
14
|
+
export let string: string = 'default';
|
|
15
|
+
/** String (required) */
|
|
16
|
+
export let stringRequired: string;
|
|
17
|
+
/** Number */
|
|
18
|
+
export let number: number = 123;
|
|
19
|
+
/** True literal */
|
|
20
|
+
export let trueLiteral: true | undefined = undefined;
|
|
21
|
+
/** Symbol */
|
|
22
|
+
export let symbol: symbol | undefined = undefined;
|
|
23
|
+
/** Null */
|
|
24
|
+
export let nullValue: null = null;
|
|
25
|
+
/** Undefined */
|
|
26
|
+
export let undefinedValue: undefined = undefined;
|
|
27
|
+
/** Any */
|
|
28
|
+
export let any: any = null;
|
|
29
|
+
/** Date */
|
|
30
|
+
export let date: Date = new Date('20 Jan 1983');
|
|
31
|
+
/** Array of numbers */
|
|
32
|
+
export let arrayOfNumbers: number[] = [1, 20, 300];
|
|
33
|
+
/** Enum */
|
|
34
|
+
export let enumValue: MyEnum = MyEnum.FOO;
|
|
35
|
+
/** Union of literal strings */
|
|
36
|
+
export let unionLiteralStrings: LiteralStrings = 'apple';
|
|
37
|
+
/** Union of literal numbers */
|
|
38
|
+
export let unionLiteralNumbers: LiteralNumbers = 1000;
|
|
39
|
+
/** Object */
|
|
40
|
+
export let object: MyObject | undefined = undefined;
|
|
41
|
+
/** Inline object */
|
|
42
|
+
export let inlineObject:
|
|
43
|
+
| {
|
|
44
|
+
foo: string;
|
|
45
|
+
bar: number;
|
|
46
|
+
}
|
|
47
|
+
| undefined = undefined;
|
|
48
|
+
/** Record */
|
|
49
|
+
export let record: Record<string, number> = { a: 1, b: 2 };
|
|
50
|
+
/** Union of types */
|
|
51
|
+
export let unionTypes: number | string = 123;
|
|
52
|
+
/** Intersection of types */
|
|
53
|
+
export let intersection: ({ a: number } & { b: string }) | undefined = undefined;
|
|
54
|
+
/** Event callback function */
|
|
55
|
+
export let func: (event: MouseEvent) => number = () => 10;
|
|
56
|
+
/** Snippet contents */
|
|
57
|
+
export let children: Snippet;
|
|
58
|
+
/** Actual arg types inferred from the component */
|
|
59
|
+
export let argTypes: Record<string, any> = {};
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<h1>Docgen: TS - legacy</h1>
|
|
63
|
+
|
|
64
|
+
<h2>Args</h2>
|
|
65
|
+
<pre>{JSON.stringify(
|
|
66
|
+
{
|
|
67
|
+
boolean,
|
|
68
|
+
string,
|
|
69
|
+
stringRequired,
|
|
70
|
+
number,
|
|
71
|
+
trueLiteral,
|
|
72
|
+
symbol,
|
|
73
|
+
nullValue,
|
|
74
|
+
undefinedValue,
|
|
75
|
+
any,
|
|
76
|
+
date,
|
|
77
|
+
arrayOfNumbers,
|
|
78
|
+
enumValue,
|
|
79
|
+
unionLiteralStrings,
|
|
80
|
+
unionLiteralNumbers,
|
|
81
|
+
object,
|
|
82
|
+
inlineObject,
|
|
83
|
+
record,
|
|
84
|
+
unionTypes,
|
|
85
|
+
intersection,
|
|
86
|
+
func,
|
|
87
|
+
},
|
|
88
|
+
null,
|
|
89
|
+
2
|
|
90
|
+
)}</pre>
|
|
91
|
+
|
|
92
|
+
<h2>Children</h2>
|
|
93
|
+
{#if children}
|
|
94
|
+
{@render children()}
|
|
95
|
+
{/if}
|
|
96
|
+
|
|
97
|
+
<h2>Arg Types</h2>
|
|
98
|
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/svelte-vite';
|
|
2
|
+
|
|
3
|
+
import TSReferencedPropTypes from './ts-referenced-prop-types.svelte';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
component: TSReferencedPropTypes,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
render: (args, { argTypes }) => ({
|
|
9
|
+
Component: TSReferencedPropTypes,
|
|
10
|
+
props: { ...args, argTypes },
|
|
11
|
+
}),
|
|
12
|
+
} satisfies Meta<typeof TSReferencedPropTypes>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
export const Default = {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { LiteralNumbers, LiteralStrings } from './types';
|
|
4
|
+
import { MyEnum } from './types';
|
|
5
|
+
|
|
6
|
+
type MyObject = {
|
|
7
|
+
foo: string;
|
|
8
|
+
bar: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type PropsA = {
|
|
12
|
+
/** Boolean */
|
|
13
|
+
boolean?: boolean;
|
|
14
|
+
/** String */
|
|
15
|
+
string?: string;
|
|
16
|
+
/** String (required) */
|
|
17
|
+
stringRequired: string;
|
|
18
|
+
/** Number */
|
|
19
|
+
number?: number;
|
|
20
|
+
};
|
|
21
|
+
type PropsB = {
|
|
22
|
+
/** True literal */
|
|
23
|
+
trueLiteral?: true;
|
|
24
|
+
/** Symbol */
|
|
25
|
+
symbol?: symbol;
|
|
26
|
+
/** Null */
|
|
27
|
+
nullValue?: null;
|
|
28
|
+
/** Undefined */
|
|
29
|
+
undefinedValue?: undefined;
|
|
30
|
+
/** Any */
|
|
31
|
+
any?: any;
|
|
32
|
+
/** Date */
|
|
33
|
+
date?: Date;
|
|
34
|
+
/** Array of numbers */
|
|
35
|
+
arrayOfNumbers?: number[];
|
|
36
|
+
/** Enum */
|
|
37
|
+
enumValue?: MyEnum;
|
|
38
|
+
/** Union of literal strings */
|
|
39
|
+
unionLiteralStrings?: LiteralStrings;
|
|
40
|
+
/** Union of literal numbers */
|
|
41
|
+
unionLiteralNumbers?: LiteralNumbers;
|
|
42
|
+
/** Object */
|
|
43
|
+
object?: MyObject;
|
|
44
|
+
/** Inline object */
|
|
45
|
+
inlineObject?: {
|
|
46
|
+
foo: string;
|
|
47
|
+
bar: number;
|
|
48
|
+
};
|
|
49
|
+
/** Record */
|
|
50
|
+
record?: Record<string, number>;
|
|
51
|
+
/** Union of types */
|
|
52
|
+
unionTypes?: number | string;
|
|
53
|
+
/** Intersection of types */
|
|
54
|
+
intersection?: { a: number } & { b: string };
|
|
55
|
+
/** Event callback function */
|
|
56
|
+
func?: (event: MouseEvent) => number;
|
|
57
|
+
/** Snippet contents */
|
|
58
|
+
children: Snippet;
|
|
59
|
+
/** Actual arg types inferred from the component */
|
|
60
|
+
argTypes: Record<string, any>;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
let {
|
|
64
|
+
boolean = true,
|
|
65
|
+
string = 'default',
|
|
66
|
+
stringRequired,
|
|
67
|
+
number = 123,
|
|
68
|
+
nullValue = null,
|
|
69
|
+
arrayOfNumbers = [1, 20, 300],
|
|
70
|
+
enumValue = MyEnum.FOO,
|
|
71
|
+
record = { a: 1, b: 2 },
|
|
72
|
+
date = new Date('20 Jan 1983'),
|
|
73
|
+
unionTypes = 123,
|
|
74
|
+
children,
|
|
75
|
+
func = () => 10,
|
|
76
|
+
argTypes,
|
|
77
|
+
}: PropsA & PropsB = $props();
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<h1>Docgen: TS - referenced prop types</h1>
|
|
81
|
+
|
|
82
|
+
<h2>Args</h2>
|
|
83
|
+
<pre>{JSON.stringify(
|
|
84
|
+
{
|
|
85
|
+
boolean,
|
|
86
|
+
string,
|
|
87
|
+
stringRequired,
|
|
88
|
+
number,
|
|
89
|
+
nullValue,
|
|
90
|
+
arrayOfNumbers,
|
|
91
|
+
enumValue,
|
|
92
|
+
record,
|
|
93
|
+
date,
|
|
94
|
+
unionTypes,
|
|
95
|
+
func,
|
|
96
|
+
},
|
|
97
|
+
null,
|
|
98
|
+
2
|
|
99
|
+
)}</pre>
|
|
100
|
+
|
|
101
|
+
<h2>Children</h2>
|
|
102
|
+
{#if children}
|
|
103
|
+
{@render children()}
|
|
104
|
+
{/if}
|
|
105
|
+
|
|
106
|
+
<h2>Arg Types</h2>
|
|
107
|
+
<pre>{JSON.stringify(argTypes, null, 2)}</pre>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/svelte-vite';
|
|
2
|
+
|
|
3
|
+
import TS from './ts.svelte';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
component: TS,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
render: (args, { argTypes }) => ({
|
|
9
|
+
Component: TS,
|
|
10
|
+
props: { ...args, argTypes },
|
|
11
|
+
}),
|
|
12
|
+
} satisfies Meta<typeof TS>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
export const Default = {};
|