@storybook/react
Advanced tools
Comparing version 0.0.0-pr-28607-sha-b9bf7d39 to 0.0.0-pr-28609-sha-1103d7ff
@@ -1,3 +0,3 @@ | ||
"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 entry_preview_docs_exports={};__export(entry_preview_docs_exports,{applyDecorators:()=>applyDecorators,argTypesEnhancers:()=>argTypesEnhancers,decorators:()=>decorators,parameters:()=>parameters});module.exports=__toCommonJS(entry_preview_docs_exports);var import_docs_tools9=require("storybook/internal/docs-tools");var import_prop_types=__toESM(require("prop-types")),import_docs_tools7=require("storybook/internal/docs-tools");var import_docs_tools=require("storybook/internal/docs-tools");function generateFuncSignature(params,returns){let hasParams=params!=null,hasReturns=returns!=null;if(!hasParams&&!hasReturns)return"";let funcParts=[];if(hasParams){let funcParams=params.map(x=>{let prettyName=x.getPrettyName(),typeName=x.getTypeName();return typeName!=null?`${prettyName}: ${typeName}`:prettyName});funcParts.push(`(${funcParams.join(", ")})`)}else funcParts.push("()");return hasReturns&&funcParts.push(`=> ${returns.getTypeName()}`),funcParts.join(" ")}function generateShortFuncSignature(params,returns){let hasParams=params!=null,hasReturns=returns!=null;if(!hasParams&&!hasReturns)return"";let funcParts=[];return hasParams?funcParts.push("( ... )"):funcParts.push("()"),hasReturns&&funcParts.push(`=> ${returns.getTypeName()}`),funcParts.join(" ")}function toMultilineSignature(signature){return signature.replace(/,/g,`,\r | ||
`)}var CUSTOM_CAPTION="custom",OBJECT_CAPTION="object",ARRAY_CAPTION="array",CLASS_CAPTION="class",FUNCTION_CAPTION="func",ELEMENT_CAPTION="element";var import_html_tags=__toESM(require("html-tags"));function isHtmlTag(tagName){return import_html_tags.default.includes(tagName.toLowerCase())}var import_escodegen=require("escodegen"),import_ts_dedent=require("ts-dedent"),BASIC_OPTIONS={format:{indent:{style:" "},semicolons:!1}},COMPACT_OPTIONS={...BASIC_OPTIONS,format:{newline:""}},PRETTY_OPTIONS={...BASIC_OPTIONS};function generateCode(ast,compact=!1){return(0,import_escodegen.generate)(ast,compact?COMPACT_OPTIONS:PRETTY_OPTIONS)}function generateObjectCode(ast,compact=!1){return compact?generateCompactObjectCode(ast):generateCode(ast)}function generateCompactObjectCode(ast){let result=generateCode(ast,!0);return result.endsWith(" }")||(result=`${result.slice(0,-1)} }`),result}function generateArrayCode(ast,compact=!1){return compact?generateCompactArrayCode(ast):generateMultilineArrayCode(ast)}function generateMultilineArrayCode(ast){let result=generateCode(ast);return result.endsWith(" }]")&&(result=(0,import_ts_dedent.dedent)(result)),result}function generateCompactArrayCode(ast){let result=generateCode(ast,!0);return result.startsWith("[ ")&&(result=result.replace("[ ","[")),result}var isMemo=component=>component.$$typeof===Symbol.for("react.memo"),isForwardRef=component=>component.$$typeof===Symbol.for("react.forward_ref");var import_acorn=require("acorn"),import_acorn_jsx=__toESM(require("acorn-jsx")),acornWalk=__toESM(require("acorn-walk"));var ACORN_WALK_VISITORS={...acornWalk.base,JSXElement:()=>{}},acornParser=import_acorn.Parser.extend((0,import_acorn_jsx.default)());function extractIdentifierName(identifierNode){return identifierNode!=null?identifierNode.name:null}function filterAncestors(ancestors){return ancestors.filter(x=>x.type==="ObjectExpression"||x.type==="ArrayExpression")}function calculateNodeDepth(node){let depths=[];return acornWalk.ancestor(node,{ObjectExpression(_,ancestors){depths.push(filterAncestors(ancestors).length)},ArrayExpression(_,ancestors){depths.push(filterAncestors(ancestors).length)}},ACORN_WALK_VISITORS),Math.max(...depths)}function parseIdentifier(identifierNode){return{inferredType:{type:"Identifier",identifier:extractIdentifierName(identifierNode)},ast:identifierNode}}function parseLiteral(literalNode){return{inferredType:{type:"Literal"},ast:literalNode}}function parseFunction(funcNode){let innerJsxElementNode;acornWalk.simple(funcNode.body,{JSXElement(node){innerJsxElementNode=node}},ACORN_WALK_VISITORS);let inferredType={type:innerJsxElementNode!=null?"Element":"Function",params:funcNode.params,hasParams:funcNode.params.length!==0},identifierName=extractIdentifierName(funcNode.id);return identifierName!=null&&(inferredType.identifier=identifierName),{inferredType,ast:funcNode}}function parseClass(classNode){let innerJsxElementNode;return acornWalk.simple(classNode.body,{JSXElement(node){innerJsxElementNode=node}},ACORN_WALK_VISITORS),{inferredType:{type:innerJsxElementNode!=null?"Element":"Class",identifier:extractIdentifierName(classNode.id)},ast:classNode}}function parseJsxElement(jsxElementNode){let inferredType={type:"Element"},identifierName=extractIdentifierName(jsxElementNode.openingElement.name);return identifierName!=null&&(inferredType.identifier=identifierName),{inferredType,ast:jsxElementNode}}function parseCall(callNode){let identifierNode=callNode.callee.type==="MemberExpression"?callNode.callee.property:callNode.callee;return extractIdentifierName(identifierNode)==="shape"?parseObject(callNode.arguments[0]):null}function parseObject(objectNode){return{inferredType:{type:"Object",depth:calculateNodeDepth(objectNode)},ast:objectNode}}function parseArray(arrayNode){return{inferredType:{type:"Array",depth:calculateNodeDepth(arrayNode)},ast:arrayNode}}function parseExpression(expression){switch(expression.type){case"Identifier":return parseIdentifier(expression);case"Literal":return parseLiteral(expression);case"FunctionExpression":case"ArrowFunctionExpression":return parseFunction(expression);case"ClassExpression":return parseClass(expression);case"JSXElement":return parseJsxElement(expression);case"CallExpression":return parseCall(expression);case"ObjectExpression":return parseObject(expression);case"ArrayExpression":return parseArray(expression);default:return null}}function parse(value){let ast=acornParser.parse(`(${value})`,{ecmaVersion:2020}),parsingResult={inferredType:{type:"Unknown"},ast};if(ast.body[0]!=null){let rootNode=ast.body[0];switch(rootNode.type){case"ExpressionStatement":{let expressionResult=parseExpression(rootNode.expression);expressionResult!=null&&(parsingResult=expressionResult);break}default:break}}return parsingResult}function inspectValue(value){try{return{...parse(value)}}catch{}return{inferredType:{type:"Unknown"}}}var MAX_FUNC_LENGTH=150;function createTypeDef({name,short,compact,full,inferredType}){return{name,short,compact,full:full??short,inferredType}}function cleanPropTypes(value){return value.replace(/PropTypes./g,"").replace(/.isRequired/g,"")}function splitIntoLines(value){return value.split(/\r?\n/)}function prettyObject(ast,compact=!1){return cleanPropTypes(generateObjectCode(ast,compact))}function prettyArray(ast,compact=!1){return cleanPropTypes(generateCode(ast,compact))}function getCaptionForInspectionType(type){switch(type){case"Object":return OBJECT_CAPTION;case"Array":return ARRAY_CAPTION;case"Class":return CLASS_CAPTION;case"Function":return FUNCTION_CAPTION;case"Element":return ELEMENT_CAPTION;default:return CUSTOM_CAPTION}}function generateTypeFromString(value,originalTypeName){let{inferredType,ast}=inspectValue(value),{type}=inferredType,short,compact,full;switch(type){case"Identifier":case"Literal":short=value,compact=value;break;case"Object":{let{depth}=inferredType;short=OBJECT_CAPTION,compact=depth===1?prettyObject(ast,!0):null,full=prettyObject(ast);break}case"Element":{let{identifier}=inferredType;short=identifier!=null&&!isHtmlTag(identifier)?identifier:ELEMENT_CAPTION,compact=splitIntoLines(value).length===1?value:null,full=value;break}case"Array":{let{depth}=inferredType;short=ARRAY_CAPTION,compact=depth<=2?prettyArray(ast,!0):null,full=prettyArray(ast);break}default:short=getCaptionForInspectionType(type),compact=splitIntoLines(value).length===1?value:null,full=value;break}return createTypeDef({name:originalTypeName,short,compact,full,inferredType:type})}function generateCustom({raw}){return raw!=null?generateTypeFromString(raw,"custom"):createTypeDef({name:"custom",short:CUSTOM_CAPTION,compact:CUSTOM_CAPTION})}function generateFunc(extractedProp){let{jsDocTags}=extractedProp;return jsDocTags!=null&&(jsDocTags.params!=null||jsDocTags.returns!=null)?createTypeDef({name:"func",short:generateShortFuncSignature(jsDocTags.params,jsDocTags.returns),compact:null,full:generateFuncSignature(jsDocTags.params,jsDocTags.returns)}):createTypeDef({name:"func",short:FUNCTION_CAPTION,compact:FUNCTION_CAPTION})}function generateShape(type,extractedProp){let fields=Object.keys(type.value).map(key=>`${key}: ${generateType(type.value[key],extractedProp).full}`).join(", "),{inferredType,ast}=inspectValue(`{ ${fields} }`),{depth}=inferredType;return createTypeDef({name:"shape",short:OBJECT_CAPTION,compact:depth===1&&ast?prettyObject(ast,!0):null,full:ast?prettyObject(ast):null})}function objectOf(of){return`objectOf(${of})`}function generateObjectOf(type,extractedProp){let{short,compact,full}=generateType(type.value,extractedProp);return createTypeDef({name:"objectOf",short:objectOf(short),compact:compact!=null?objectOf(compact):null,full:full&&objectOf(full)})}function generateUnion(type,extractedProp){if(Array.isArray(type.value)){let values=type.value.reduce((acc,v)=>{let{short,compact,full}=generateType(v,extractedProp);return acc.short.push(short),acc.compact.push(compact),acc.full.push(full),acc},{short:[],compact:[],full:[]});return createTypeDef({name:"union",short:values.short.join(" | "),compact:values.compact.every(x=>x!=null)?values.compact.join(" | "):null,full:values.full.join(" | ")})}return createTypeDef({name:"union",short:type.value,compact:null})}function generateEnumValue({value,computed}){return computed?generateTypeFromString(value,"enumvalue"):createTypeDef({name:"enumvalue",short:value,compact:value})}function generateEnum(type){if(Array.isArray(type.value)){let values=type.value.reduce((acc,v)=>{let{short,compact,full}=generateEnumValue(v);return acc.short.push(short),acc.compact.push(compact),acc.full.push(full),acc},{short:[],compact:[],full:[]});return createTypeDef({name:"enum",short:values.short.join(" | "),compact:values.compact.every(x=>x!=null)?values.compact.join(" | "):null,full:values.full.join(" | ")})}return createTypeDef({name:"enum",short:type.value,compact:type.value})}function braceAfter(of){return`${of}[]`}function braceAround(of){return`[${of}]`}function createArrayOfObjectTypeDef(short,compact,full){return createTypeDef({name:"arrayOf",short:braceAfter(short),compact:compact!=null?braceAround(compact):null,full:full&&braceAround(full)})}function generateArray(type,extractedProp){let{name,short,compact,full,inferredType}=generateType(type.value,extractedProp);if(name==="custom"){if(inferredType==="Object")return createArrayOfObjectTypeDef(short,compact,full)}else if(name==="shape")return createArrayOfObjectTypeDef(short,compact,full);return createTypeDef({name:"arrayOf",short:braceAfter(short),compact:braceAfter(short)})}function generateType(type,extractedProp){try{switch(type.name){case"custom":return generateCustom(type);case"func":return generateFunc(extractedProp);case"shape":return generateShape(type,extractedProp);case"instanceOf":return createTypeDef({name:"instanceOf",short:type.value,compact:type.value});case"objectOf":return generateObjectOf(type,extractedProp);case"union":return generateUnion(type,extractedProp);case"enum":return generateEnum(type);case"arrayOf":return generateArray(type,extractedProp);default:return createTypeDef({name:type.name,short:type.name,compact:type.name})}}catch(e){console.error(e)}return createTypeDef({name:"unknown",short:"unknown",compact:"unknown"})}function createType(extractedProp){let{type}=extractedProp.docgenInfo;if(type==null)return null;try{switch(type.name){case"custom":case"shape":case"instanceOf":case"objectOf":case"union":case"enum":case"arrayOf":{let{short,compact,full}=generateType(type,extractedProp);return compact!=null&&!(0,import_docs_tools.isTooLongForTypeSummary)(compact)?(0,import_docs_tools.createSummaryValue)(compact):full?(0,import_docs_tools.createSummaryValue)(short,full):(0,import_docs_tools.createSummaryValue)(short)}case"func":{let{short,full}=generateType(type,extractedProp),summary=short,detail;return full&&full.length<MAX_FUNC_LENGTH?summary=full:full&&(detail=toMultilineSignature(full)),(0,import_docs_tools.createSummaryValue)(summary,detail)}default:return null}}catch(e){console.error(e)}return null}var import_docs_tools4=require("storybook/internal/docs-tools");var import_docs_tools2=require("storybook/internal/docs-tools");function generateObject({inferredType,ast}){let{depth}=inferredType;if(depth===1){let compactObject=generateObjectCode(ast,!0);if(!(0,import_docs_tools2.isTooLongForDefaultValueSummary)(compactObject))return(0,import_docs_tools2.createSummaryValue)(compactObject)}return(0,import_docs_tools2.createSummaryValue)(OBJECT_CAPTION,generateObjectCode(ast))}var import_docs_tools3=require("storybook/internal/docs-tools");function generateArray2({inferredType,ast}){let{depth}=inferredType;if(depth<=2){let compactArray=generateArrayCode(ast,!0);if(!(0,import_docs_tools3.isTooLongForDefaultValueSummary)(compactArray))return(0,import_docs_tools3.createSummaryValue)(compactArray)}return(0,import_docs_tools3.createSummaryValue)(ARRAY_CAPTION,generateArrayCode(ast))}function getPrettyFuncIdentifier(identifier,hasArguments){return hasArguments?`${identifier}( ... )`:`${identifier}()`}function getPrettyElementIdentifier(identifier){return`<${identifier} />`}function getPrettyIdentifier(inferredType){let{type,identifier}=inferredType;switch(type){case"Function":return getPrettyFuncIdentifier(identifier,inferredType.hasParams);case"Element":return getPrettyElementIdentifier(identifier);default:return identifier}}function generateFunc2({inferredType,ast}){let{identifier}=inferredType;if(identifier!=null)return(0,import_docs_tools4.createSummaryValue)(getPrettyIdentifier(inferredType),generateCode(ast));let prettyCaption=generateCode(ast,!0);return(0,import_docs_tools4.isTooLongForDefaultValueSummary)(prettyCaption)?(0,import_docs_tools4.createSummaryValue)(FUNCTION_CAPTION,generateCode(ast)):(0,import_docs_tools4.createSummaryValue)(prettyCaption)}function generateElement(defaultValue,inspectionResult){let{inferredType}=inspectionResult,{identifier}=inferredType;if(identifier!=null&&!isHtmlTag(identifier)){let prettyIdentifier=getPrettyIdentifier(inferredType);return(0,import_docs_tools4.createSummaryValue)(prettyIdentifier,defaultValue)}return(0,import_docs_tools4.isTooLongForDefaultValueSummary)(defaultValue)?(0,import_docs_tools4.createSummaryValue)(ELEMENT_CAPTION,defaultValue):(0,import_docs_tools4.createSummaryValue)(defaultValue)}function createDefaultValue(defaultValue){try{let inspectionResult=inspectValue(defaultValue);switch(inspectionResult.inferredType.type){case"Object":return generateObject(inspectionResult);case"Function":return generateFunc2(inspectionResult);case"Element":return generateElement(defaultValue,inspectionResult);case"Array":return generateArray2(inspectionResult);default:return null}}catch(e){console.error(e)}return null}var import_isPlainObject=__toESM(require("lodash/isPlainObject.js")),import_isFunction=__toESM(require("lodash/isFunction.js")),import_isString=__toESM(require("lodash/isString.js")),import_react_element_to_jsx_string=__toESM(require("react-element-to-jsx-string")),import_docs_tools5=require("storybook/internal/docs-tools");function isReactElement(element){return element.$$typeof!=null}function extractFunctionName(func,propName){let{name}=func;return name!==""&&name!=="anonymous"&&name!==propName?name:null}var stringResolver=rawDefaultProp=>(0,import_docs_tools5.createSummaryValue)(JSON.stringify(rawDefaultProp));function generateReactObject(rawDefaultProp){let{type}=rawDefaultProp,{displayName}=type,jsx2=(0,import_react_element_to_jsx_string.default)(rawDefaultProp,{});if(displayName!=null){let prettyIdentifier=getPrettyElementIdentifier(displayName);return(0,import_docs_tools5.createSummaryValue)(prettyIdentifier,jsx2)}if((0,import_isString.default)(type)&&isHtmlTag(type)){let jsxSummary=(0,import_react_element_to_jsx_string.default)(rawDefaultProp,{tabStop:0}).replace(/\r?\n|\r/g,"");if(!(0,import_docs_tools5.isTooLongForDefaultValueSummary)(jsxSummary))return(0,import_docs_tools5.createSummaryValue)(jsxSummary)}return(0,import_docs_tools5.createSummaryValue)(ELEMENT_CAPTION,jsx2)}var objectResolver=rawDefaultProp=>{if(isReactElement(rawDefaultProp)&&rawDefaultProp.type!=null)return generateReactObject(rawDefaultProp);if((0,import_isPlainObject.default)(rawDefaultProp)){let inspectionResult=inspectValue(JSON.stringify(rawDefaultProp));return generateObject(inspectionResult)}if(Array.isArray(rawDefaultProp)){let inspectionResult=inspectValue(JSON.stringify(rawDefaultProp));return generateArray2(inspectionResult)}return(0,import_docs_tools5.createSummaryValue)(OBJECT_CAPTION)},functionResolver=(rawDefaultProp,propDef)=>{let isElement=!1,inspectionResult;if((0,import_isFunction.default)(rawDefaultProp.render))isElement=!0;else if(rawDefaultProp.prototype!=null&&(0,import_isFunction.default)(rawDefaultProp.prototype.render))isElement=!0;else{let innerElement;try{inspectionResult=inspectValue(rawDefaultProp.toString());let{hasParams,params}=inspectionResult.inferredType;hasParams?params.length===1&¶ms[0].type==="ObjectPattern"&&(innerElement=rawDefaultProp({})):innerElement=rawDefaultProp(),innerElement!=null&&isReactElement(innerElement)&&(isElement=!0)}catch{}}let funcName=extractFunctionName(rawDefaultProp,propDef.name);if(funcName!=null){if(isElement)return(0,import_docs_tools5.createSummaryValue)(getPrettyElementIdentifier(funcName));inspectionResult!=null&&(inspectionResult=inspectValue(rawDefaultProp.toString()));let{hasParams}=inspectionResult.inferredType;return(0,import_docs_tools5.createSummaryValue)(getPrettyFuncIdentifier(funcName,hasParams))}return(0,import_docs_tools5.createSummaryValue)(isElement?ELEMENT_CAPTION:FUNCTION_CAPTION)},defaultResolver=rawDefaultProp=>(0,import_docs_tools5.createSummaryValue)(rawDefaultProp.toString()),DEFAULT_TYPE_RESOLVERS={string:stringResolver,object:objectResolver,function:functionResolver,default:defaultResolver};function createTypeResolvers(customResolvers={}){return{...DEFAULT_TYPE_RESOLVERS,...customResolvers}}function createDefaultValueFromRawDefaultProp(rawDefaultProp,propDef,typeResolvers=DEFAULT_TYPE_RESOLVERS){try{switch(typeof rawDefaultProp){case"string":return typeResolvers.string(rawDefaultProp,propDef);case"object":return typeResolvers.object(rawDefaultProp,propDef);case"function":return typeResolvers.function(rawDefaultProp,propDef);default:return typeResolvers.default(rawDefaultProp,propDef)}}catch(e){console.error(e)}return null}function keepOriginalDefinitionOrder(extractedProps,component){let{propTypes}=component;return propTypes!=null?Object.keys(propTypes).map(x=>extractedProps.find(y=>y.name===x)).filter(Boolean):extractedProps}var import_docs_tools6=require("storybook/internal/docs-tools");var funcResolver=(rawDefaultProp,{name,type})=>{let isElement=type?.summary==="element"||type?.summary==="elementType",funcName=extractFunctionName(rawDefaultProp,name);if(funcName!=null){if(isElement)return(0,import_docs_tools6.createSummaryValue)(getPrettyElementIdentifier(funcName));let{hasParams}=inspectValue(rawDefaultProp.toString()).inferredType;return(0,import_docs_tools6.createSummaryValue)(getPrettyFuncIdentifier(funcName,hasParams))}return(0,import_docs_tools6.createSummaryValue)(isElement?ELEMENT_CAPTION:FUNCTION_CAPTION)},rawDefaultPropTypeResolvers=createTypeResolvers({function:funcResolver});function enhancePropTypesProp(extractedProp,rawDefaultProp){let{propDef}=extractedProp,newtype=createType(extractedProp);newtype!=null&&(propDef.type=newtype);let{defaultValue}=extractedProp.docgenInfo;if(defaultValue!=null&&defaultValue.value!=null){let newDefaultValue=createDefaultValue(defaultValue.value);newDefaultValue!=null&&(propDef.defaultValue=newDefaultValue)}else if(rawDefaultProp!=null){let newDefaultValue=createDefaultValueFromRawDefaultProp(rawDefaultProp,propDef,rawDefaultPropTypeResolvers);newDefaultValue!=null&&(propDef.defaultValue=newDefaultValue)}return propDef}function enhancePropTypesProps(extractedProps,component){let rawDefaultProps=component.defaultProps!=null?component.defaultProps:{},enhancedProps=extractedProps.map(x=>enhancePropTypesProp(x,rawDefaultProps[x.propDef.name]));return keepOriginalDefinitionOrder(enhancedProps,component)}function enhanceTypeScriptProp(extractedProp,rawDefaultProp){let{propDef}=extractedProp,{defaultValue}=extractedProp.docgenInfo;if(defaultValue!=null&&defaultValue.value!=null){let newDefaultValue=createDefaultValue(defaultValue.value);newDefaultValue!=null&&(propDef.defaultValue=newDefaultValue)}else if(rawDefaultProp!=null){let newDefaultValue=createDefaultValueFromRawDefaultProp(rawDefaultProp,propDef);newDefaultValue!=null&&(propDef.defaultValue=newDefaultValue)}return propDef}function enhanceTypeScriptProps(extractedProps){return extractedProps.map(prop=>enhanceTypeScriptProp(prop))}var propTypesMap=new Map;Object.keys(import_prop_types.default).forEach(typeName=>{let type=import_prop_types.default[typeName];propTypesMap.set(type,typeName),propTypesMap.set(type.isRequired,typeName)});function getPropDefs(component,section){let processedComponent=component;!(0,import_docs_tools7.hasDocgen)(component)&&!component.propTypes&&isMemo(component)&&(processedComponent=component.type);let extractedProps=(0,import_docs_tools7.extractComponentProps)(processedComponent,section);if(extractedProps.length===0)return[];switch(extractedProps[0].typeSystem){case import_docs_tools7.TypeSystem.JAVASCRIPT:return enhancePropTypesProps(extractedProps,component);case import_docs_tools7.TypeSystem.TYPESCRIPT:return enhanceTypeScriptProps(extractedProps);default:return extractedProps.map(x=>x.propDef)}}var extractProps=component=>({rows:getPropDefs(component,"props")});var extractArgTypes=component=>{if(component){let{rows}=extractProps(component);if(rows)return rows.reduce((acc,row)=>{let{name,description,type,sbType,defaultValue:defaultSummary,jsDocTags,required}=row;return acc[name]={name,description,type:{required,...sbType},table:{type:type??void 0,jsDocTags,defaultValue:defaultSummary??void 0}},acc},{})}return null};var import_react=__toESM(require("react")),import_react_element_to_jsx_string2=__toESM(require("react-element-to-jsx-string")),import_preview_api=require("storybook/internal/preview-api"),import_docs_tools8=require("storybook/internal/docs-tools"),import_client_logger=require("storybook/internal/client-logger");var toPascalCase=str=>str.charAt(0).toUpperCase()+str.slice(1),getReactSymbolName=elementType=>(elementType.$$typeof||elementType).toString().replace(/^Symbol\((.*)\)$/,"$1").split(".").map(segment=>segment.split("_").map(toPascalCase).join("")).join(".");function simplifyNodeForStringify(node){if((0,import_react.isValidElement)(node)){let props=Object.keys(node.props).reduce((acc,cur)=>(acc[cur]=simplifyNodeForStringify(node.props[cur]),acc),{});return{...node,props,_owner:null}}return Array.isArray(node)?node.map(simplifyNodeForStringify):node}var renderJsx=(code,options)=>{if(typeof code>"u")return import_client_logger.logger.warn("Too many skip or undefined component"),null;let renderedJSX=code,Type=renderedJSX.type;for(let i=0;i<options?.skip;i+=1){if(typeof renderedJSX>"u")return import_client_logger.logger.warn("Cannot skip undefined element"),null;if(import_react.default.Children.count(renderedJSX)>1)return import_client_logger.logger.warn("Trying to skip an array of elements"),null;typeof renderedJSX.props.children>"u"?(import_client_logger.logger.warn("Not enough children to skip elements."),typeof renderedJSX.type=="function"&&renderedJSX.type.name===""&&(renderedJSX=import_react.default.createElement(Type,{...renderedJSX.props}))):typeof renderedJSX.props.children=="function"?renderedJSX=renderedJSX.props.children():renderedJSX=renderedJSX.props.children}let displayNameDefaults;typeof options?.displayName=="string"?displayNameDefaults={showFunctions:!0,displayName:()=>options.displayName}:displayNameDefaults={displayName:el=>el.type.displayName?el.type.displayName:(0,import_docs_tools8.getDocgenSection)(el.type,"displayName")?(0,import_docs_tools8.getDocgenSection)(el.type,"displayName"):el.type.render?.displayName?el.type.render.displayName:typeof el.type=="symbol"||el.type.$$typeof&&typeof el.type.$$typeof=="symbol"?getReactSymbolName(el.type):el.type.name&&el.type.name!=="_default"?el.type.name:typeof el.type=="function"?"No Display Name":isForwardRef(el.type)?el.type.render.name:isMemo(el.type)?el.type.type.name:el.type};let opts={...displayNameDefaults,...{filterProps:(value,key)=>value!==void 0},...options};return import_react.default.Children.map(code,c=>{let child=typeof c=="number"?c.toString():c,string=(typeof import_react_element_to_jsx_string2.default=="function"?import_react_element_to_jsx_string2.default:import_react_element_to_jsx_string2.default.default)(simplifyNodeForStringify(child),opts);if(string.indexOf(""")>-1){let matches=string.match(/\S+=\\"([^"]*)\\"/g);matches&&matches.forEach(match=>{string=string.replace(match,match.replace(/"/g,"'"))})}return string}).join(` | ||
"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 __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};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 require_freeGlobal=__commonJS({"../../node_modules/lodash/_freeGlobal.js"(exports2,module2){"use strict";var freeGlobal=typeof global=="object"&&global&&global.Object===Object&&global;module2.exports=freeGlobal}});var require_root=__commonJS({"../../node_modules/lodash/_root.js"(exports2,module2){"use strict";var freeGlobal=require_freeGlobal(),freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")();module2.exports=root}});var require_Symbol=__commonJS({"../../node_modules/lodash/_Symbol.js"(exports2,module2){"use strict";var root=require_root(),Symbol2=root.Symbol;module2.exports=Symbol2}});var require_getRawTag=__commonJS({"../../node_modules/lodash/_getRawTag.js"(exports2,module2){"use strict";var Symbol2=require_Symbol(),objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,nativeObjectToString=objectProto.toString,symToStringTag=Symbol2?Symbol2.toStringTag:void 0;function getRawTag(value){var isOwn=hasOwnProperty.call(value,symToStringTag),tag=value[symToStringTag];try{value[symToStringTag]=void 0;var unmasked=!0}catch{}var result=nativeObjectToString.call(value);return unmasked&&(isOwn?value[symToStringTag]=tag:delete value[symToStringTag]),result}module2.exports=getRawTag}});var require_objectToString=__commonJS({"../../node_modules/lodash/_objectToString.js"(exports2,module2){"use strict";var objectProto=Object.prototype,nativeObjectToString=objectProto.toString;function objectToString(value){return nativeObjectToString.call(value)}module2.exports=objectToString}});var require_baseGetTag=__commonJS({"../../node_modules/lodash/_baseGetTag.js"(exports2,module2){"use strict";var Symbol2=require_Symbol(),getRawTag=require_getRawTag(),objectToString=require_objectToString(),nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol2?Symbol2.toStringTag:void 0;function baseGetTag(value){return value==null?value===void 0?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(value)?getRawTag(value):objectToString(value)}module2.exports=baseGetTag}});var require_overArg=__commonJS({"../../node_modules/lodash/_overArg.js"(exports2,module2){"use strict";function overArg(func,transform){return function(arg){return func(transform(arg))}}module2.exports=overArg}});var require_getPrototype=__commonJS({"../../node_modules/lodash/_getPrototype.js"(exports2,module2){"use strict";var overArg=require_overArg(),getPrototype=overArg(Object.getPrototypeOf,Object);module2.exports=getPrototype}});var require_isObjectLike=__commonJS({"../../node_modules/lodash/isObjectLike.js"(exports2,module2){"use strict";function isObjectLike(value){return value!=null&&typeof value=="object"}module2.exports=isObjectLike}});var require_isPlainObject=__commonJS({"../../node_modules/lodash/isPlainObject.js"(exports2,module2){"use strict";var baseGetTag=require_baseGetTag(),getPrototype=require_getPrototype(),isObjectLike=require_isObjectLike(),objectTag="[object Object]",funcProto=Function.prototype,objectProto=Object.prototype,funcToString=funcProto.toString,hasOwnProperty=objectProto.hasOwnProperty,objectCtorString=funcToString.call(Object);function isPlainObject2(value){if(!isObjectLike(value)||baseGetTag(value)!=objectTag)return!1;var proto=getPrototype(value);if(proto===null)return!0;var Ctor=hasOwnProperty.call(proto,"constructor")&&proto.constructor;return typeof Ctor=="function"&&Ctor instanceof Ctor&&funcToString.call(Ctor)==objectCtorString}module2.exports=isPlainObject2}});var require_isObject=__commonJS({"../../node_modules/lodash/isObject.js"(exports2,module2){"use strict";function isObject(value){var type=typeof value;return value!=null&&(type=="object"||type=="function")}module2.exports=isObject}});var require_isFunction=__commonJS({"../../node_modules/lodash/isFunction.js"(exports2,module2){"use strict";var baseGetTag=require_baseGetTag(),isObject=require_isObject(),asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction2(value){if(!isObject(value))return!1;var tag=baseGetTag(value);return tag==funcTag||tag==genTag||tag==asyncTag||tag==proxyTag}module2.exports=isFunction2}});var require_isArray=__commonJS({"../../node_modules/lodash/isArray.js"(exports2,module2){"use strict";var isArray=Array.isArray;module2.exports=isArray}});var require_isString=__commonJS({"../../node_modules/lodash/isString.js"(exports2,module2){"use strict";var baseGetTag=require_baseGetTag(),isArray=require_isArray(),isObjectLike=require_isObjectLike(),stringTag="[object String]";function isString2(value){return typeof value=="string"||!isArray(value)&&isObjectLike(value)&&baseGetTag(value)==stringTag}module2.exports=isString2}});var entry_preview_docs_exports={};__export(entry_preview_docs_exports,{applyDecorators:()=>applyDecorators,argTypesEnhancers:()=>argTypesEnhancers,decorators:()=>decorators,parameters:()=>parameters});module.exports=__toCommonJS(entry_preview_docs_exports);var import_docs_tools9=require("storybook/internal/docs-tools");var import_prop_types=__toESM(require("prop-types")),import_docs_tools7=require("storybook/internal/docs-tools");var import_docs_tools=require("storybook/internal/docs-tools");function generateFuncSignature(params,returns){let hasParams=params!=null,hasReturns=returns!=null;if(!hasParams&&!hasReturns)return"";let funcParts=[];if(hasParams){let funcParams=params.map(x=>{let prettyName=x.getPrettyName(),typeName=x.getTypeName();return typeName!=null?`${prettyName}: ${typeName}`:prettyName});funcParts.push(`(${funcParams.join(", ")})`)}else funcParts.push("()");return hasReturns&&funcParts.push(`=> ${returns.getTypeName()}`),funcParts.join(" ")}function generateShortFuncSignature(params,returns){let hasParams=params!=null,hasReturns=returns!=null;if(!hasParams&&!hasReturns)return"";let funcParts=[];return hasParams?funcParts.push("( ... )"):funcParts.push("()"),hasReturns&&funcParts.push(`=> ${returns.getTypeName()}`),funcParts.join(" ")}function toMultilineSignature(signature){return signature.replace(/,/g,`,\r | ||
`)}var CUSTOM_CAPTION="custom",OBJECT_CAPTION="object",ARRAY_CAPTION="array",CLASS_CAPTION="class",FUNCTION_CAPTION="func",ELEMENT_CAPTION="element";var import_html_tags=__toESM(require("html-tags"));function isHtmlTag(tagName){return import_html_tags.default.includes(tagName.toLowerCase())}var import_escodegen=require("escodegen"),import_ts_dedent=require("ts-dedent"),BASIC_OPTIONS={format:{indent:{style:" "},semicolons:!1}},COMPACT_OPTIONS={...BASIC_OPTIONS,format:{newline:""}},PRETTY_OPTIONS={...BASIC_OPTIONS};function generateCode(ast,compact=!1){return(0,import_escodegen.generate)(ast,compact?COMPACT_OPTIONS:PRETTY_OPTIONS)}function generateObjectCode(ast,compact=!1){return compact?generateCompactObjectCode(ast):generateCode(ast)}function generateCompactObjectCode(ast){let result=generateCode(ast,!0);return result.endsWith(" }")||(result=`${result.slice(0,-1)} }`),result}function generateArrayCode(ast,compact=!1){return compact?generateCompactArrayCode(ast):generateMultilineArrayCode(ast)}function generateMultilineArrayCode(ast){let result=generateCode(ast);return result.endsWith(" }]")&&(result=(0,import_ts_dedent.dedent)(result)),result}function generateCompactArrayCode(ast){let result=generateCode(ast,!0);return result.startsWith("[ ")&&(result=result.replace("[ ","[")),result}var isMemo=component=>component.$$typeof===Symbol.for("react.memo"),isForwardRef=component=>component.$$typeof===Symbol.for("react.forward_ref");var import_acorn=require("acorn"),import_acorn_jsx=__toESM(require("acorn-jsx")),acornWalk=__toESM(require("acorn-walk"));var ACORN_WALK_VISITORS={...acornWalk.base,JSXElement:()=>{}},acornParser=import_acorn.Parser.extend((0,import_acorn_jsx.default)());function extractIdentifierName(identifierNode){return identifierNode!=null?identifierNode.name:null}function filterAncestors(ancestors){return ancestors.filter(x=>x.type==="ObjectExpression"||x.type==="ArrayExpression")}function calculateNodeDepth(node){let depths=[];return acornWalk.ancestor(node,{ObjectExpression(_,ancestors){depths.push(filterAncestors(ancestors).length)},ArrayExpression(_,ancestors){depths.push(filterAncestors(ancestors).length)}},ACORN_WALK_VISITORS),Math.max(...depths)}function parseIdentifier(identifierNode){return{inferredType:{type:"Identifier",identifier:extractIdentifierName(identifierNode)},ast:identifierNode}}function parseLiteral(literalNode){return{inferredType:{type:"Literal"},ast:literalNode}}function parseFunction(funcNode){let innerJsxElementNode;acornWalk.simple(funcNode.body,{JSXElement(node){innerJsxElementNode=node}},ACORN_WALK_VISITORS);let inferredType={type:innerJsxElementNode!=null?"Element":"Function",params:funcNode.params,hasParams:funcNode.params.length!==0},identifierName=extractIdentifierName(funcNode.id);return identifierName!=null&&(inferredType.identifier=identifierName),{inferredType,ast:funcNode}}function parseClass(classNode){let innerJsxElementNode;return acornWalk.simple(classNode.body,{JSXElement(node){innerJsxElementNode=node}},ACORN_WALK_VISITORS),{inferredType:{type:innerJsxElementNode!=null?"Element":"Class",identifier:extractIdentifierName(classNode.id)},ast:classNode}}function parseJsxElement(jsxElementNode){let inferredType={type:"Element"},identifierName=extractIdentifierName(jsxElementNode.openingElement.name);return identifierName!=null&&(inferredType.identifier=identifierName),{inferredType,ast:jsxElementNode}}function parseCall(callNode){let identifierNode=callNode.callee.type==="MemberExpression"?callNode.callee.property:callNode.callee;return extractIdentifierName(identifierNode)==="shape"?parseObject(callNode.arguments[0]):null}function parseObject(objectNode){return{inferredType:{type:"Object",depth:calculateNodeDepth(objectNode)},ast:objectNode}}function parseArray(arrayNode){return{inferredType:{type:"Array",depth:calculateNodeDepth(arrayNode)},ast:arrayNode}}function parseExpression(expression){switch(expression.type){case"Identifier":return parseIdentifier(expression);case"Literal":return parseLiteral(expression);case"FunctionExpression":case"ArrowFunctionExpression":return parseFunction(expression);case"ClassExpression":return parseClass(expression);case"JSXElement":return parseJsxElement(expression);case"CallExpression":return parseCall(expression);case"ObjectExpression":return parseObject(expression);case"ArrayExpression":return parseArray(expression);default:return null}}function parse(value){let ast=acornParser.parse(`(${value})`,{ecmaVersion:2020}),parsingResult={inferredType:{type:"Unknown"},ast};if(ast.body[0]!=null){let rootNode=ast.body[0];switch(rootNode.type){case"ExpressionStatement":{let expressionResult=parseExpression(rootNode.expression);expressionResult!=null&&(parsingResult=expressionResult);break}default:break}}return parsingResult}function inspectValue(value){try{return{...parse(value)}}catch{}return{inferredType:{type:"Unknown"}}}var MAX_FUNC_LENGTH=150;function createTypeDef({name,short,compact,full,inferredType}){return{name,short,compact,full:full??short,inferredType}}function cleanPropTypes(value){return value.replace(/PropTypes./g,"").replace(/.isRequired/g,"")}function splitIntoLines(value){return value.split(/\r?\n/)}function prettyObject(ast,compact=!1){return cleanPropTypes(generateObjectCode(ast,compact))}function prettyArray(ast,compact=!1){return cleanPropTypes(generateCode(ast,compact))}function getCaptionForInspectionType(type){switch(type){case"Object":return OBJECT_CAPTION;case"Array":return ARRAY_CAPTION;case"Class":return CLASS_CAPTION;case"Function":return FUNCTION_CAPTION;case"Element":return ELEMENT_CAPTION;default:return CUSTOM_CAPTION}}function generateTypeFromString(value,originalTypeName){let{inferredType,ast}=inspectValue(value),{type}=inferredType,short,compact,full;switch(type){case"Identifier":case"Literal":short=value,compact=value;break;case"Object":{let{depth}=inferredType;short=OBJECT_CAPTION,compact=depth===1?prettyObject(ast,!0):null,full=prettyObject(ast);break}case"Element":{let{identifier}=inferredType;short=identifier!=null&&!isHtmlTag(identifier)?identifier:ELEMENT_CAPTION,compact=splitIntoLines(value).length===1?value:null,full=value;break}case"Array":{let{depth}=inferredType;short=ARRAY_CAPTION,compact=depth<=2?prettyArray(ast,!0):null,full=prettyArray(ast);break}default:short=getCaptionForInspectionType(type),compact=splitIntoLines(value).length===1?value:null,full=value;break}return createTypeDef({name:originalTypeName,short,compact,full,inferredType:type})}function generateCustom({raw}){return raw!=null?generateTypeFromString(raw,"custom"):createTypeDef({name:"custom",short:CUSTOM_CAPTION,compact:CUSTOM_CAPTION})}function generateFunc(extractedProp){let{jsDocTags}=extractedProp;return jsDocTags!=null&&(jsDocTags.params!=null||jsDocTags.returns!=null)?createTypeDef({name:"func",short:generateShortFuncSignature(jsDocTags.params,jsDocTags.returns),compact:null,full:generateFuncSignature(jsDocTags.params,jsDocTags.returns)}):createTypeDef({name:"func",short:FUNCTION_CAPTION,compact:FUNCTION_CAPTION})}function generateShape(type,extractedProp){let fields=Object.keys(type.value).map(key=>`${key}: ${generateType(type.value[key],extractedProp).full}`).join(", "),{inferredType,ast}=inspectValue(`{ ${fields} }`),{depth}=inferredType;return createTypeDef({name:"shape",short:OBJECT_CAPTION,compact:depth===1&&ast?prettyObject(ast,!0):null,full:ast?prettyObject(ast):null})}function objectOf(of){return`objectOf(${of})`}function generateObjectOf(type,extractedProp){let{short,compact,full}=generateType(type.value,extractedProp);return createTypeDef({name:"objectOf",short:objectOf(short),compact:compact!=null?objectOf(compact):null,full:full&&objectOf(full)})}function generateUnion(type,extractedProp){if(Array.isArray(type.value)){let values=type.value.reduce((acc,v)=>{let{short,compact,full}=generateType(v,extractedProp);return acc.short.push(short),acc.compact.push(compact),acc.full.push(full),acc},{short:[],compact:[],full:[]});return createTypeDef({name:"union",short:values.short.join(" | "),compact:values.compact.every(x=>x!=null)?values.compact.join(" | "):null,full:values.full.join(" | ")})}return createTypeDef({name:"union",short:type.value,compact:null})}function generateEnumValue({value,computed}){return computed?generateTypeFromString(value,"enumvalue"):createTypeDef({name:"enumvalue",short:value,compact:value})}function generateEnum(type){if(Array.isArray(type.value)){let values=type.value.reduce((acc,v)=>{let{short,compact,full}=generateEnumValue(v);return acc.short.push(short),acc.compact.push(compact),acc.full.push(full),acc},{short:[],compact:[],full:[]});return createTypeDef({name:"enum",short:values.short.join(" | "),compact:values.compact.every(x=>x!=null)?values.compact.join(" | "):null,full:values.full.join(" | ")})}return createTypeDef({name:"enum",short:type.value,compact:type.value})}function braceAfter(of){return`${of}[]`}function braceAround(of){return`[${of}]`}function createArrayOfObjectTypeDef(short,compact,full){return createTypeDef({name:"arrayOf",short:braceAfter(short),compact:compact!=null?braceAround(compact):null,full:full&&braceAround(full)})}function generateArray(type,extractedProp){let{name,short,compact,full,inferredType}=generateType(type.value,extractedProp);if(name==="custom"){if(inferredType==="Object")return createArrayOfObjectTypeDef(short,compact,full)}else if(name==="shape")return createArrayOfObjectTypeDef(short,compact,full);return createTypeDef({name:"arrayOf",short:braceAfter(short),compact:braceAfter(short)})}function generateType(type,extractedProp){try{switch(type.name){case"custom":return generateCustom(type);case"func":return generateFunc(extractedProp);case"shape":return generateShape(type,extractedProp);case"instanceOf":return createTypeDef({name:"instanceOf",short:type.value,compact:type.value});case"objectOf":return generateObjectOf(type,extractedProp);case"union":return generateUnion(type,extractedProp);case"enum":return generateEnum(type);case"arrayOf":return generateArray(type,extractedProp);default:return createTypeDef({name:type.name,short:type.name,compact:type.name})}}catch(e){console.error(e)}return createTypeDef({name:"unknown",short:"unknown",compact:"unknown"})}function createType(extractedProp){let{type}=extractedProp.docgenInfo;if(type==null)return null;try{switch(type.name){case"custom":case"shape":case"instanceOf":case"objectOf":case"union":case"enum":case"arrayOf":{let{short,compact,full}=generateType(type,extractedProp);return compact!=null&&!(0,import_docs_tools.isTooLongForTypeSummary)(compact)?(0,import_docs_tools.createSummaryValue)(compact):full?(0,import_docs_tools.createSummaryValue)(short,full):(0,import_docs_tools.createSummaryValue)(short)}case"func":{let{short,full}=generateType(type,extractedProp),summary=short,detail;return full&&full.length<MAX_FUNC_LENGTH?summary=full:full&&(detail=toMultilineSignature(full)),(0,import_docs_tools.createSummaryValue)(summary,detail)}default:return null}}catch(e){console.error(e)}return null}var import_docs_tools4=require("storybook/internal/docs-tools");var import_docs_tools2=require("storybook/internal/docs-tools");function generateObject({inferredType,ast}){let{depth}=inferredType;if(depth===1){let compactObject=generateObjectCode(ast,!0);if(!(0,import_docs_tools2.isTooLongForDefaultValueSummary)(compactObject))return(0,import_docs_tools2.createSummaryValue)(compactObject)}return(0,import_docs_tools2.createSummaryValue)(OBJECT_CAPTION,generateObjectCode(ast))}var import_docs_tools3=require("storybook/internal/docs-tools");function generateArray2({inferredType,ast}){let{depth}=inferredType;if(depth<=2){let compactArray=generateArrayCode(ast,!0);if(!(0,import_docs_tools3.isTooLongForDefaultValueSummary)(compactArray))return(0,import_docs_tools3.createSummaryValue)(compactArray)}return(0,import_docs_tools3.createSummaryValue)(ARRAY_CAPTION,generateArrayCode(ast))}function getPrettyFuncIdentifier(identifier,hasArguments){return hasArguments?`${identifier}( ... )`:`${identifier}()`}function getPrettyElementIdentifier(identifier){return`<${identifier} />`}function getPrettyIdentifier(inferredType){let{type,identifier}=inferredType;switch(type){case"Function":return getPrettyFuncIdentifier(identifier,inferredType.hasParams);case"Element":return getPrettyElementIdentifier(identifier);default:return identifier}}function generateFunc2({inferredType,ast}){let{identifier}=inferredType;if(identifier!=null)return(0,import_docs_tools4.createSummaryValue)(getPrettyIdentifier(inferredType),generateCode(ast));let prettyCaption=generateCode(ast,!0);return(0,import_docs_tools4.isTooLongForDefaultValueSummary)(prettyCaption)?(0,import_docs_tools4.createSummaryValue)(FUNCTION_CAPTION,generateCode(ast)):(0,import_docs_tools4.createSummaryValue)(prettyCaption)}function generateElement(defaultValue,inspectionResult){let{inferredType}=inspectionResult,{identifier}=inferredType;if(identifier!=null&&!isHtmlTag(identifier)){let prettyIdentifier=getPrettyIdentifier(inferredType);return(0,import_docs_tools4.createSummaryValue)(prettyIdentifier,defaultValue)}return(0,import_docs_tools4.isTooLongForDefaultValueSummary)(defaultValue)?(0,import_docs_tools4.createSummaryValue)(ELEMENT_CAPTION,defaultValue):(0,import_docs_tools4.createSummaryValue)(defaultValue)}function createDefaultValue(defaultValue){try{let inspectionResult=inspectValue(defaultValue);switch(inspectionResult.inferredType.type){case"Object":return generateObject(inspectionResult);case"Function":return generateFunc2(inspectionResult);case"Element":return generateElement(defaultValue,inspectionResult);case"Array":return generateArray2(inspectionResult);default:return null}}catch(e){console.error(e)}return null}var import_isPlainObject=__toESM(require_isPlainObject()),import_isFunction=__toESM(require_isFunction()),import_isString=__toESM(require_isString()),import_react_element_to_jsx_string=__toESM(require("react-element-to-jsx-string")),import_docs_tools5=require("storybook/internal/docs-tools");function isReactElement(element){return element.$$typeof!=null}function extractFunctionName(func,propName){let{name}=func;return name!==""&&name!=="anonymous"&&name!==propName?name:null}var stringResolver=rawDefaultProp=>(0,import_docs_tools5.createSummaryValue)(JSON.stringify(rawDefaultProp));function generateReactObject(rawDefaultProp){let{type}=rawDefaultProp,{displayName}=type,jsx2=(0,import_react_element_to_jsx_string.default)(rawDefaultProp,{});if(displayName!=null){let prettyIdentifier=getPrettyElementIdentifier(displayName);return(0,import_docs_tools5.createSummaryValue)(prettyIdentifier,jsx2)}if((0,import_isString.default)(type)&&isHtmlTag(type)){let jsxSummary=(0,import_react_element_to_jsx_string.default)(rawDefaultProp,{tabStop:0}).replace(/\r?\n|\r/g,"");if(!(0,import_docs_tools5.isTooLongForDefaultValueSummary)(jsxSummary))return(0,import_docs_tools5.createSummaryValue)(jsxSummary)}return(0,import_docs_tools5.createSummaryValue)(ELEMENT_CAPTION,jsx2)}var objectResolver=rawDefaultProp=>{if(isReactElement(rawDefaultProp)&&rawDefaultProp.type!=null)return generateReactObject(rawDefaultProp);if((0,import_isPlainObject.default)(rawDefaultProp)){let inspectionResult=inspectValue(JSON.stringify(rawDefaultProp));return generateObject(inspectionResult)}if(Array.isArray(rawDefaultProp)){let inspectionResult=inspectValue(JSON.stringify(rawDefaultProp));return generateArray2(inspectionResult)}return(0,import_docs_tools5.createSummaryValue)(OBJECT_CAPTION)},functionResolver=(rawDefaultProp,propDef)=>{let isElement=!1,inspectionResult;if((0,import_isFunction.default)(rawDefaultProp.render))isElement=!0;else if(rawDefaultProp.prototype!=null&&(0,import_isFunction.default)(rawDefaultProp.prototype.render))isElement=!0;else{let innerElement;try{inspectionResult=inspectValue(rawDefaultProp.toString());let{hasParams,params}=inspectionResult.inferredType;hasParams?params.length===1&¶ms[0].type==="ObjectPattern"&&(innerElement=rawDefaultProp({})):innerElement=rawDefaultProp(),innerElement!=null&&isReactElement(innerElement)&&(isElement=!0)}catch{}}let funcName=extractFunctionName(rawDefaultProp,propDef.name);if(funcName!=null){if(isElement)return(0,import_docs_tools5.createSummaryValue)(getPrettyElementIdentifier(funcName));inspectionResult!=null&&(inspectionResult=inspectValue(rawDefaultProp.toString()));let{hasParams}=inspectionResult.inferredType;return(0,import_docs_tools5.createSummaryValue)(getPrettyFuncIdentifier(funcName,hasParams))}return(0,import_docs_tools5.createSummaryValue)(isElement?ELEMENT_CAPTION:FUNCTION_CAPTION)},defaultResolver=rawDefaultProp=>(0,import_docs_tools5.createSummaryValue)(rawDefaultProp.toString()),DEFAULT_TYPE_RESOLVERS={string:stringResolver,object:objectResolver,function:functionResolver,default:defaultResolver};function createTypeResolvers(customResolvers={}){return{...DEFAULT_TYPE_RESOLVERS,...customResolvers}}function createDefaultValueFromRawDefaultProp(rawDefaultProp,propDef,typeResolvers=DEFAULT_TYPE_RESOLVERS){try{switch(typeof rawDefaultProp){case"string":return typeResolvers.string(rawDefaultProp,propDef);case"object":return typeResolvers.object(rawDefaultProp,propDef);case"function":return typeResolvers.function(rawDefaultProp,propDef);default:return typeResolvers.default(rawDefaultProp,propDef)}}catch(e){console.error(e)}return null}function keepOriginalDefinitionOrder(extractedProps,component){let{propTypes}=component;return propTypes!=null?Object.keys(propTypes).map(x=>extractedProps.find(y=>y.name===x)).filter(Boolean):extractedProps}var import_docs_tools6=require("storybook/internal/docs-tools");var funcResolver=(rawDefaultProp,{name,type})=>{let isElement=type?.summary==="element"||type?.summary==="elementType",funcName=extractFunctionName(rawDefaultProp,name);if(funcName!=null){if(isElement)return(0,import_docs_tools6.createSummaryValue)(getPrettyElementIdentifier(funcName));let{hasParams}=inspectValue(rawDefaultProp.toString()).inferredType;return(0,import_docs_tools6.createSummaryValue)(getPrettyFuncIdentifier(funcName,hasParams))}return(0,import_docs_tools6.createSummaryValue)(isElement?ELEMENT_CAPTION:FUNCTION_CAPTION)},rawDefaultPropTypeResolvers=createTypeResolvers({function:funcResolver});function enhancePropTypesProp(extractedProp,rawDefaultProp){let{propDef}=extractedProp,newtype=createType(extractedProp);newtype!=null&&(propDef.type=newtype);let{defaultValue}=extractedProp.docgenInfo;if(defaultValue!=null&&defaultValue.value!=null){let newDefaultValue=createDefaultValue(defaultValue.value);newDefaultValue!=null&&(propDef.defaultValue=newDefaultValue)}else if(rawDefaultProp!=null){let newDefaultValue=createDefaultValueFromRawDefaultProp(rawDefaultProp,propDef,rawDefaultPropTypeResolvers);newDefaultValue!=null&&(propDef.defaultValue=newDefaultValue)}return propDef}function enhancePropTypesProps(extractedProps,component){let rawDefaultProps=component.defaultProps!=null?component.defaultProps:{},enhancedProps=extractedProps.map(x=>enhancePropTypesProp(x,rawDefaultProps[x.propDef.name]));return keepOriginalDefinitionOrder(enhancedProps,component)}function enhanceTypeScriptProp(extractedProp,rawDefaultProp){let{propDef}=extractedProp,{defaultValue}=extractedProp.docgenInfo;if(defaultValue!=null&&defaultValue.value!=null){let newDefaultValue=createDefaultValue(defaultValue.value);newDefaultValue!=null&&(propDef.defaultValue=newDefaultValue)}else if(rawDefaultProp!=null){let newDefaultValue=createDefaultValueFromRawDefaultProp(rawDefaultProp,propDef);newDefaultValue!=null&&(propDef.defaultValue=newDefaultValue)}return propDef}function enhanceTypeScriptProps(extractedProps){return extractedProps.map(prop=>enhanceTypeScriptProp(prop))}var propTypesMap=new Map;Object.keys(import_prop_types.default).forEach(typeName=>{let type=import_prop_types.default[typeName];propTypesMap.set(type,typeName),propTypesMap.set(type.isRequired,typeName)});function getPropDefs(component,section){let processedComponent=component;!(0,import_docs_tools7.hasDocgen)(component)&&!component.propTypes&&isMemo(component)&&(processedComponent=component.type);let extractedProps=(0,import_docs_tools7.extractComponentProps)(processedComponent,section);if(extractedProps.length===0)return[];switch(extractedProps[0].typeSystem){case import_docs_tools7.TypeSystem.JAVASCRIPT:return enhancePropTypesProps(extractedProps,component);case import_docs_tools7.TypeSystem.TYPESCRIPT:return enhanceTypeScriptProps(extractedProps);default:return extractedProps.map(x=>x.propDef)}}var extractProps=component=>({rows:getPropDefs(component,"props")});var extractArgTypes=component=>{if(component){let{rows}=extractProps(component);if(rows)return rows.reduce((acc,row)=>{let{name,description,type,sbType,defaultValue:defaultSummary,jsDocTags,required}=row;return acc[name]={name,description,type:{required,...sbType},table:{type:type??void 0,jsDocTags,defaultValue:defaultSummary??void 0}},acc},{})}return null};var import_react=__toESM(require("react")),import_react_element_to_jsx_string2=__toESM(require("react-element-to-jsx-string")),import_preview_api=require("storybook/internal/preview-api"),import_docs_tools8=require("storybook/internal/docs-tools"),import_client_logger=require("storybook/internal/client-logger");var toPascalCase=str=>str.charAt(0).toUpperCase()+str.slice(1),getReactSymbolName=elementType=>(elementType.$$typeof||elementType).toString().replace(/^Symbol\((.*)\)$/,"$1").split(".").map(segment=>segment.split("_").map(toPascalCase).join("")).join(".");function simplifyNodeForStringify(node){if((0,import_react.isValidElement)(node)){let props=Object.keys(node.props).reduce((acc,cur)=>(acc[cur]=simplifyNodeForStringify(node.props[cur]),acc),{});return{...node,props,_owner:null}}return Array.isArray(node)?node.map(simplifyNodeForStringify):node}var renderJsx=(code,options)=>{if(typeof code>"u")return import_client_logger.logger.warn("Too many skip or undefined component"),null;let renderedJSX=code,Type=renderedJSX.type;for(let i=0;i<options?.skip;i+=1){if(typeof renderedJSX>"u")return import_client_logger.logger.warn("Cannot skip undefined element"),null;if(import_react.default.Children.count(renderedJSX)>1)return import_client_logger.logger.warn("Trying to skip an array of elements"),null;typeof renderedJSX.props.children>"u"?(import_client_logger.logger.warn("Not enough children to skip elements."),typeof renderedJSX.type=="function"&&renderedJSX.type.name===""&&(renderedJSX=import_react.default.createElement(Type,{...renderedJSX.props}))):typeof renderedJSX.props.children=="function"?renderedJSX=renderedJSX.props.children():renderedJSX=renderedJSX.props.children}let displayNameDefaults;typeof options?.displayName=="string"?displayNameDefaults={showFunctions:!0,displayName:()=>options.displayName}:displayNameDefaults={displayName:el=>el.type.displayName?el.type.displayName:(0,import_docs_tools8.getDocgenSection)(el.type,"displayName")?(0,import_docs_tools8.getDocgenSection)(el.type,"displayName"):el.type.render?.displayName?el.type.render.displayName:typeof el.type=="symbol"||el.type.$$typeof&&typeof el.type.$$typeof=="symbol"?getReactSymbolName(el.type):el.type.name&&el.type.name!=="_default"?el.type.name:typeof el.type=="function"?"No Display Name":isForwardRef(el.type)?el.type.render.name:isMemo(el.type)?el.type.type.name:el.type};let opts={...displayNameDefaults,...{filterProps:(value,key)=>value!==void 0},...options};return import_react.default.Children.map(code,c=>{let child=typeof c=="number"?c.toString():c,string=(typeof import_react_element_to_jsx_string2.default=="function"?import_react_element_to_jsx_string2.default:import_react_element_to_jsx_string2.default.default)(simplifyNodeForStringify(child),opts);if(string.indexOf(""")>-1){let matches=string.match(/\S+=\\"([^"]*)\\"/g);matches&&matches.forEach(match=>{string=string.replace(match,match.replace(/"/g,"'"))})}return string}).join(` | ||
`).replace(/function\s+noRefCheck\(\)\s*\{\}/g,"() => {}")},defaultOpts={skip:0,showFunctions:!1,enableBeautify:!0,showDefaultProps:!1},skipJsxRender=context=>{let sourceParams=context?.parameters.docs?.source,isArgsStory=context?.parameters.__isArgsStory;return sourceParams?.type===import_docs_tools8.SourceType.DYNAMIC?!1:!isArgsStory||sourceParams?.code||sourceParams?.type===import_docs_tools8.SourceType.CODE},isMdx=node=>node.type?.displayName==="MDXCreateElement"&&!!node.props?.mdxType,mdxToJsx=node=>{if(!isMdx(node))return node;let{mdxType,originalType,children,...rest}=node.props,jsxChildren=[];return children&&(jsxChildren=(Array.isArray(children)?children:[children]).map(mdxToJsx)),(0,import_react.createElement)(originalType,rest,...jsxChildren)},jsxDecorator=(storyFn,context)=>{let channel=import_preview_api.addons.getChannel(),skip=skipJsxRender(context),jsx2="";(0,import_preview_api.useEffect)(()=>{if(!skip){let{id,unmappedArgs}=context;channel.emit(import_docs_tools8.SNIPPET_RENDERED,{id,source:jsx2,args:unmappedArgs})}});let story=storyFn();if(skip)return story;let options={...defaultOpts,...context?.parameters.jsx||{}},storyJsx=context?.parameters.docs?.source?.excludeDecorators?context.originalStoryFn(context.args,context):story,sourceJsx=mdxToJsx(storyJsx),rendered=renderJsx(sourceJsx,options);return rendered&&(jsx2=rendered),story};var import_preview_api2=require("storybook/internal/preview-api");var applyDecorators=(storyFn,decorators2)=>{let jsxIndex=decorators2.findIndex(d=>d.originalFn===jsxDecorator),reorderedDecorators=jsxIndex===-1?decorators2:[...decorators2.splice(jsxIndex,1),...decorators2];return(0,import_preview_api2.defaultDecorateStory)(storyFn,reorderedDecorators)};var parameters={docs:{story:{inline:!0},extractArgTypes,extractComponentDescription:import_docs_tools9.extractComponentDescription}},decorators=[jsxDecorator],argTypesEnhancers=[import_docs_tools9.enhanceArgTypes];0&&(module.exports={applyDecorators,argTypesEnhancers,decorators,parameters}); |
{ | ||
"name": "@storybook/react", | ||
"version": "0.0.0-pr-28607-sha-b9bf7d39", | ||
"version": "0.0.0-pr-28609-sha-1103d7ff", | ||
"description": "Storybook React renderer", | ||
@@ -67,8 +67,8 @@ "keywords": [ | ||
"dependencies": { | ||
"@storybook/components": "^0.0.0-pr-28607-sha-b9bf7d39", | ||
"@storybook/components": "^0.0.0-pr-28609-sha-1103d7ff", | ||
"@storybook/global": "^5.0.0", | ||
"@storybook/manager-api": "^0.0.0-pr-28607-sha-b9bf7d39", | ||
"@storybook/preview-api": "^0.0.0-pr-28607-sha-b9bf7d39", | ||
"@storybook/react-dom-shim": "0.0.0-pr-28607-sha-b9bf7d39", | ||
"@storybook/theming": "^0.0.0-pr-28607-sha-b9bf7d39", | ||
"@storybook/manager-api": "^0.0.0-pr-28609-sha-1103d7ff", | ||
"@storybook/preview-api": "^0.0.0-pr-28609-sha-1103d7ff", | ||
"@storybook/react-dom-shim": "0.0.0-pr-28609-sha-1103d7ff", | ||
"@storybook/theming": "^0.0.0-pr-28609-sha-1103d7ff", | ||
"@types/escodegen": "^0.0.6", | ||
@@ -82,3 +82,2 @@ "@types/estree": "^0.0.51", | ||
"html-tags": "^3.1.0", | ||
"lodash": "^4.17.21", | ||
"prop-types": "^15.7.2", | ||
@@ -92,3 +91,3 @@ "react-element-to-jsx-string": "^15.0.0", | ||
"devDependencies": { | ||
"@storybook/test": "0.0.0-pr-28607-sha-b9bf7d39", | ||
"@storybook/test": "0.0.0-pr-28609-sha-1103d7ff", | ||
"@types/babel-plugin-react-docgen": "^4", | ||
@@ -99,2 +98,3 @@ "@types/semver": "^7.3.4", | ||
"expect-type": "^0.15.0", | ||
"lodash": "^4.17.21", | ||
"require-from-string": "^2.0.2" | ||
@@ -105,3 +105,3 @@ }, | ||
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta", | ||
"storybook": "^0.0.0-pr-28607-sha-b9bf7d39", | ||
"storybook": "^0.0.0-pr-28609-sha-1103d7ff", | ||
"typescript": ">= 4.2.x" | ||
@@ -108,0 +108,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118991
24
1329
8
2
+ Added@storybook/components@0.0.0-pr-29014-sha-a0ccf5b8(transitive)
+ Added@storybook/manager-api@0.0.0-pr-29014-sha-a0ccf5b8(transitive)
+ Added@storybook/preview-api@0.0.0-pr-29014-sha-a0ccf5b8(transitive)
+ Added@storybook/react-dom-shim@0.0.0-pr-28609-sha-1103d7ff(transitive)
+ Added@storybook/theming@0.0.0-pr-29014-sha-a0ccf5b8(transitive)
- Removedlodash@^4.17.21
- Removed@storybook/components@0.0.0-pr-28993-sha-5e4d9ae9(transitive)
- Removed@storybook/manager-api@0.0.0-pr-28993-sha-5e4d9ae9(transitive)
- Removed@storybook/preview-api@0.0.0-pr-28993-sha-5e4d9ae9(transitive)
- Removed@storybook/react-dom-shim@0.0.0-pr-28607-sha-b9bf7d39(transitive)
- Removed@storybook/theming@0.0.0-pr-28993-sha-5e4d9ae9(transitive)
- Removedlodash@4.17.21(transitive)
Updated@storybook/react-dom-shim@0.0.0-pr-28609-sha-1103d7ff