@storybook/addon-docs 6.5.0-alpha.5 → 6.5.0-alpha.52
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/README.md +4 -13
- package/angular/README.md +0 -6
- package/angular/index.d.ts +1 -1
- package/angular/index.js +7 -1
- package/dist/cjs/blocks/Anchor.js +1 -1
- package/dist/cjs/blocks/ArgsTable.js +13 -9
- package/dist/cjs/blocks/Canvas.js +13 -11
- package/dist/cjs/blocks/Description.js +10 -10
- package/dist/cjs/blocks/DocsContainer.js +8 -6
- package/dist/cjs/blocks/DocsContext.js +2 -2
- package/dist/cjs/blocks/Heading.js +2 -2
- package/dist/cjs/blocks/Meta.js +8 -6
- package/dist/cjs/blocks/Primary.js +7 -7
- package/dist/cjs/blocks/Source.js +23 -10
- package/dist/cjs/blocks/SourceContainer.js +28 -18
- package/dist/cjs/blocks/Stories.js +14 -7
- package/dist/cjs/blocks/Story.js +12 -30
- package/dist/cjs/blocks/Subheading.js +2 -2
- package/dist/cjs/blocks/Subtitle.js +5 -5
- package/dist/cjs/blocks/Title.js +8 -8
- package/dist/cjs/blocks/enhanceSource.js +5 -5
- package/dist/cjs/blocks/index.js +6 -4
- package/dist/cjs/blocks/mdx.js +17 -9
- package/dist/cjs/blocks/useStory.js +8 -6
- package/dist/cjs/blocks/utils.js +3 -3
- package/dist/cjs/frameworks/common/config.js +8 -12
- package/dist/cjs/frameworks/common/preset.js +167 -112
- package/dist/cjs/index.js +2 -0
- package/dist/esm/blocks/ArgsTable.js +5 -3
- package/dist/esm/blocks/Canvas.js +5 -3
- package/dist/esm/blocks/Description.js +1 -1
- package/dist/esm/blocks/DocsContainer.js +3 -2
- package/dist/esm/blocks/DocsContext.js +2 -2
- package/dist/esm/blocks/Heading.js +1 -1
- package/dist/esm/blocks/Meta.js +3 -2
- package/dist/esm/blocks/Primary.js +1 -0
- package/dist/esm/blocks/Source.js +16 -2
- package/dist/esm/blocks/SourceContainer.js +22 -13
- package/dist/esm/blocks/Stories.js +7 -0
- package/dist/esm/blocks/Story.js +6 -25
- package/dist/esm/blocks/Subheading.js +1 -1
- package/dist/esm/blocks/Title.js +1 -1
- package/dist/esm/blocks/enhanceSource.js +3 -3
- package/dist/esm/blocks/mdx.js +15 -8
- package/dist/esm/blocks/useStory.js +15 -15
- package/dist/esm/blocks/utils.js +1 -1
- package/dist/esm/frameworks/common/config.js +2 -4
- package/dist/esm/frameworks/common/preset.js +161 -110
- package/dist/modern/blocks/Canvas.js +3 -1
- package/dist/modern/blocks/Description.js +1 -1
- package/dist/modern/blocks/DocsContext.js +2 -2
- package/dist/modern/blocks/Source.js +17 -2
- package/dist/modern/blocks/SourceContainer.js +18 -12
- package/dist/modern/blocks/Stories.js +5 -0
- package/dist/modern/blocks/Story.js +2 -24
- package/dist/modern/blocks/mdx.js +12 -7
- package/dist/modern/frameworks/common/config.js +1 -3
- package/dist/modern/frameworks/common/preset.js +23 -17
- package/dist/ts3.4/blocks/Source.d.ts +5 -3
- package/dist/ts3.4/blocks/SourceContainer.d.ts +5 -1
- package/dist/ts3.4/frameworks/common/config.d.ts +0 -2
- package/dist/ts3.4/frameworks/common/preset.d.ts +11 -1
- package/dist/ts3.9/blocks/DocsContext.d.ts +2 -2
- package/dist/ts3.9/blocks/Source.d.ts +5 -3
- package/dist/ts3.9/blocks/SourceContainer.d.ts +6 -2
- package/dist/ts3.9/blocks/enhanceSource.d.ts +2 -2
- package/dist/ts3.9/blocks/useStory.d.ts +2 -2
- package/dist/ts3.9/frameworks/common/config.d.ts +0 -2
- package/dist/ts3.9/frameworks/common/preset.d.ts +11 -1
- package/ember/index.js +6 -1
- package/jest-transform-mdx.js +2 -5
- package/mdx-compiler-plugin.js +1 -1
- package/package.json +23 -107
- package/preset.js +14 -14
- package/register.js +1 -0
- package/{dist/cjs/frameworks/svelte → svelte}/HOC.svelte +0 -0
- package/common-preset.js +0 -19
- package/dist/cjs/frameworks/angular/compodoc.js +0 -397
- package/dist/cjs/frameworks/angular/config.js +0 -31
- package/dist/cjs/frameworks/angular/index.js +0 -22
- package/dist/cjs/frameworks/angular/prepareForInline.js +0 -96
- package/dist/cjs/frameworks/angular/sourceDecorator.js +0 -159
- package/dist/cjs/frameworks/angular/types.js +0 -1
- package/dist/cjs/frameworks/common/enhanceArgTypes.js +0 -21
- package/dist/cjs/frameworks/ember/config.js +0 -17
- package/dist/cjs/frameworks/ember/index.js +0 -13
- package/dist/cjs/frameworks/ember/jsondoc.js +0 -87
- package/dist/cjs/frameworks/html/config.js +0 -26
- package/dist/cjs/frameworks/html/prepareForInline.js +0 -29
- package/dist/cjs/frameworks/html/sourceDecorator.js +0 -67
- package/dist/cjs/frameworks/react/config.js +0 -27
- package/dist/cjs/frameworks/react/extractArgTypes.js +0 -52
- package/dist/cjs/frameworks/react/extractProps.js +0 -77
- package/dist/cjs/frameworks/react/jsxDecorator.js +0 -277
- package/dist/cjs/frameworks/react/lib/captions.js +0 -18
- package/dist/cjs/frameworks/react/lib/componentTypes.js +0 -24
- package/dist/cjs/frameworks/react/lib/defaultValues/createDefaultValue.js +0 -81
- package/dist/cjs/frameworks/react/lib/defaultValues/createFromRawDefaultProp.js +0 -225
- package/dist/cjs/frameworks/react/lib/defaultValues/generateArray.js +0 -29
- package/dist/cjs/frameworks/react/lib/defaultValues/generateObject.js +0 -29
- package/dist/cjs/frameworks/react/lib/defaultValues/index.js +0 -35
- package/dist/cjs/frameworks/react/lib/defaultValues/prettyIdentifier.js +0 -34
- package/dist/cjs/frameworks/react/lib/generateCode.js +0 -89
- package/dist/cjs/frameworks/react/lib/index.js +0 -61
- package/dist/cjs/frameworks/react/lib/inspection/acornParser.js +0 -254
- package/dist/cjs/frameworks/react/lib/inspection/index.js +0 -35
- package/dist/cjs/frameworks/react/lib/inspection/inspectValue.js +0 -26
- package/dist/cjs/frameworks/react/lib/inspection/types.js +0 -19
- package/dist/cjs/frameworks/react/lib/isHtmlTag.js +0 -18
- package/dist/cjs/frameworks/react/propTypes/createType.js +0 -467
- package/dist/cjs/frameworks/react/propTypes/generateFuncSignature.js +0 -78
- package/dist/cjs/frameworks/react/propTypes/handleProp.js +0 -54
- package/dist/cjs/frameworks/react/propTypes/rawDefaultPropResolvers.js +0 -47
- package/dist/cjs/frameworks/react/propTypes/sortProps.js +0 -35
- package/dist/cjs/frameworks/react/react-argtypes.stories.js +0 -153
- package/dist/cjs/frameworks/react/typeScript/handleProp.js +0 -38
- package/dist/cjs/frameworks/svelte/config.js +0 -26
- package/dist/cjs/frameworks/svelte/extractArgTypes.js +0 -159
- package/dist/cjs/frameworks/svelte/extractComponentDescription.js +0 -21
- package/dist/cjs/frameworks/svelte/prepareForInline.js +0 -35
- package/dist/cjs/frameworks/svelte/preset.js +0 -54
- package/dist/cjs/frameworks/svelte/sample/MockButton.svelte +0 -45
- package/dist/cjs/frameworks/svelte/sourceDecorator.js +0 -262
- package/dist/cjs/frameworks/svelte/svelte-docgen-loader.js +0 -191
- package/dist/cjs/frameworks/vue/config.js +0 -26
- package/dist/cjs/frameworks/vue/extractArgTypes.js +0 -153
- package/dist/cjs/frameworks/vue/prepareForInline.js +0 -56
- package/dist/cjs/frameworks/vue/preset.js +0 -43
- package/dist/cjs/frameworks/vue/sourceDecorator.js +0 -343
- package/dist/cjs/frameworks/vue3/config.js +0 -22
- package/dist/cjs/frameworks/vue3/extractArgTypes.js +0 -62
- package/dist/cjs/frameworks/vue3/prepareForInline.js +0 -61
- package/dist/cjs/frameworks/vue3/preset.js +0 -43
- package/dist/cjs/frameworks/web-components/config.js +0 -30
- package/dist/cjs/frameworks/web-components/custom-elements.js +0 -163
- package/dist/cjs/frameworks/web-components/prepareForInline.js +0 -96
- package/dist/cjs/frameworks/web-components/sourceDecorator.js +0 -60
- package/dist/cjs/lib/convert/flow/convert.js +0 -112
- package/dist/cjs/lib/convert/flow/index.js +0 -35
- package/dist/cjs/lib/convert/flow/types.js +0 -1
- package/dist/cjs/lib/convert/index.js +0 -24
- package/dist/cjs/lib/convert/proptypes/convert.js +0 -135
- package/dist/cjs/lib/convert/proptypes/index.js +0 -35
- package/dist/cjs/lib/convert/proptypes/types.js +0 -1
- package/dist/cjs/lib/convert/typescript/convert.js +0 -82
- package/dist/cjs/lib/convert/typescript/index.js +0 -35
- package/dist/cjs/lib/convert/typescript/types.js +0 -1
- package/dist/cjs/lib/convert/utils.js +0 -18
- package/dist/cjs/lib/docgen/PropDef.js +0 -1
- package/dist/cjs/lib/docgen/createPropDef.js +0 -171
- package/dist/cjs/lib/docgen/extractDocgenProps.js +0 -113
- package/dist/cjs/lib/docgen/flow/createDefaultValue.js +0 -24
- package/dist/cjs/lib/docgen/flow/createPropDef.js +0 -30
- package/dist/cjs/lib/docgen/flow/createType.js +0 -119
- package/dist/cjs/lib/docgen/index.js +0 -48
- package/dist/cjs/lib/docgen/typeScript/createDefaultValue.js +0 -24
- package/dist/cjs/lib/docgen/typeScript/createPropDef.js +0 -28
- package/dist/cjs/lib/docgen/typeScript/createType.js +0 -30
- package/dist/cjs/lib/docgen/types.js +0 -17
- package/dist/cjs/lib/docgen/utils/defaultValue.js +0 -13
- package/dist/cjs/lib/docgen/utils/docgenInfo.js +0 -34
- package/dist/cjs/lib/docgen/utils/index.js +0 -48
- package/dist/cjs/lib/docgen/utils/string.js +0 -20
- package/dist/cjs/lib/index.js +0 -22
- package/dist/cjs/lib/jsdocParser.js +0 -229
- package/dist/cjs/lib/utils.js +0 -45
- package/dist/cjs/typings.d.js +0 -1
- package/dist/esm/frameworks/angular/compodoc.js +0 -347
- package/dist/esm/frameworks/angular/config.js +0 -18
- package/dist/esm/frameworks/angular/index.js +0 -1
- package/dist/esm/frameworks/angular/prepareForInline.js +0 -75
- package/dist/esm/frameworks/angular/sourceDecorator.js +0 -116
- package/dist/esm/frameworks/angular/types.js +0 -0
- package/dist/esm/frameworks/common/enhanceArgTypes.js +0 -11
- package/dist/esm/frameworks/ember/config.js +0 -8
- package/dist/esm/frameworks/ember/index.js +0 -1
- package/dist/esm/frameworks/ember/jsondoc.js +0 -66
- package/dist/esm/frameworks/html/config.js +0 -14
- package/dist/esm/frameworks/html/prepareForInline.js +0 -19
- package/dist/esm/frameworks/html/sourceDecorator.js +0 -56
- package/dist/esm/frameworks/react/config.js +0 -15
- package/dist/esm/frameworks/react/extractArgTypes.js +0 -38
- package/dist/esm/frameworks/react/extractProps.js +0 -53
- package/dist/esm/frameworks/react/jsxDecorator.js +0 -218
- package/dist/esm/frameworks/react/lib/captions.js +0 -6
- package/dist/esm/frameworks/react/lib/componentTypes.js +0 -9
- package/dist/esm/frameworks/react/lib/defaultValues/createDefaultValue.js +0 -67
- package/dist/esm/frameworks/react/lib/defaultValues/createFromRawDefaultProp.js +0 -191
- package/dist/esm/frameworks/react/lib/defaultValues/generateArray.js +0 -19
- package/dist/esm/frameworks/react/lib/defaultValues/generateObject.js +0 -19
- package/dist/esm/frameworks/react/lib/defaultValues/index.js +0 -2
- package/dist/esm/frameworks/react/lib/defaultValues/prettyIdentifier.js +0 -22
- package/dist/esm/frameworks/react/lib/generateCode.js +0 -68
- package/dist/esm/frameworks/react/lib/index.js +0 -4
- package/dist/esm/frameworks/react/lib/inspection/acornParser.js +0 -213
- package/dist/esm/frameworks/react/lib/inspection/index.js +0 -2
- package/dist/esm/frameworks/react/lib/inspection/inspectValue.js +0 -16
- package/dist/esm/frameworks/react/lib/inspection/types.js +0 -12
- package/dist/esm/frameworks/react/lib/isHtmlTag.js +0 -6
- package/dist/esm/frameworks/react/propTypes/createType.js +0 -448
- package/dist/esm/frameworks/react/propTypes/generateFuncSignature.js +0 -62
- package/dist/esm/frameworks/react/propTypes/handleProp.js +0 -39
- package/dist/esm/frameworks/react/propTypes/rawDefaultPropResolvers.js +0 -32
- package/dist/esm/frameworks/react/propTypes/sortProps.js +0 -23
- package/dist/esm/frameworks/react/react-argtypes.stories.js +0 -122
- package/dist/esm/frameworks/react/typeScript/handleProp.js +0 -27
- package/dist/esm/frameworks/svelte/HOC.svelte +0 -7
- package/dist/esm/frameworks/svelte/config.js +0 -13
- package/dist/esm/frameworks/svelte/extractArgTypes.js +0 -138
- package/dist/esm/frameworks/svelte/extractComponentDescription.js +0 -12
- package/dist/esm/frameworks/svelte/prepareForInline.js +0 -20
- package/dist/esm/frameworks/svelte/preset.js +0 -42
- package/dist/esm/frameworks/svelte/sample/MockButton.svelte +0 -45
- package/dist/esm/frameworks/svelte/sourceDecorator.js +0 -232
- package/dist/esm/frameworks/svelte/svelte-docgen-loader.js +0 -142
- package/dist/esm/frameworks/vue/config.js +0 -13
- package/dist/esm/frameworks/vue/extractArgTypes.js +0 -128
- package/dist/esm/frameworks/vue/prepareForInline.js +0 -39
- package/dist/esm/frameworks/vue/preset.js +0 -31
- package/dist/esm/frameworks/vue/sourceDecorator.js +0 -292
- package/dist/esm/frameworks/vue3/config.js +0 -11
- package/dist/esm/frameworks/vue3/extractArgTypes.js +0 -45
- package/dist/esm/frameworks/vue3/prepareForInline.js +0 -22
- package/dist/esm/frameworks/vue3/preset.js +0 -31
- package/dist/esm/frameworks/web-components/config.js +0 -17
- package/dist/esm/frameworks/web-components/custom-elements.js +0 -139
- package/dist/esm/frameworks/web-components/prepareForInline.js +0 -74
- package/dist/esm/frameworks/web-components/sourceDecorator.js +0 -50
- package/dist/esm/lib/convert/flow/convert.js +0 -98
- package/dist/esm/lib/convert/flow/index.js +0 -2
- package/dist/esm/lib/convert/flow/types.js +0 -0
- package/dist/esm/lib/convert/index.js +0 -12
- package/dist/esm/lib/convert/proptypes/convert.js +0 -116
- package/dist/esm/lib/convert/proptypes/index.js +0 -2
- package/dist/esm/lib/convert/proptypes/types.js +0 -0
- package/dist/esm/lib/convert/typescript/convert.js +0 -70
- package/dist/esm/lib/convert/typescript/index.js +0 -2
- package/dist/esm/lib/convert/typescript/types.js +0 -0
- package/dist/esm/lib/convert/utils.js +0 -6
- package/dist/esm/lib/docgen/PropDef.js +0 -0
- package/dist/esm/lib/docgen/createPropDef.js +0 -141
- package/dist/esm/lib/docgen/extractDocgenProps.js +0 -87
- package/dist/esm/lib/docgen/flow/createDefaultValue.js +0 -14
- package/dist/esm/lib/docgen/flow/createPropDef.js +0 -17
- package/dist/esm/lib/docgen/flow/createType.js +0 -106
- package/dist/esm/lib/docgen/index.js +0 -3
- package/dist/esm/lib/docgen/typeScript/createDefaultValue.js +0 -15
- package/dist/esm/lib/docgen/typeScript/createPropDef.js +0 -15
- package/dist/esm/lib/docgen/typeScript/createType.js +0 -19
- package/dist/esm/lib/docgen/types.js +0 -10
- package/dist/esm/lib/docgen/utils/defaultValue.js +0 -6
- package/dist/esm/lib/docgen/utils/docgenInfo.js +0 -18
- package/dist/esm/lib/docgen/utils/index.js +0 -3
- package/dist/esm/lib/docgen/utils/string.js +0 -11
- package/dist/esm/lib/index.js +0 -1
- package/dist/esm/lib/jsdocParser.js +0 -207
- package/dist/esm/lib/utils.js +0 -25
- package/dist/esm/typings.d.js +0 -0
- package/dist/modern/frameworks/angular/compodoc.js +0 -296
- package/dist/modern/frameworks/angular/config.js +0 -18
- package/dist/modern/frameworks/angular/index.js +0 -1
- package/dist/modern/frameworks/angular/prepareForInline.js +0 -36
- package/dist/modern/frameworks/angular/sourceDecorator.js +0 -81
- package/dist/modern/frameworks/angular/types.js +0 -0
- package/dist/modern/frameworks/common/enhanceArgTypes.js +0 -16
- package/dist/modern/frameworks/ember/config.js +0 -8
- package/dist/modern/frameworks/ember/index.js +0 -1
- package/dist/modern/frameworks/ember/jsondoc.js +0 -57
- package/dist/modern/frameworks/html/config.js +0 -14
- package/dist/modern/frameworks/html/prepareForInline.js +0 -17
- package/dist/modern/frameworks/html/sourceDecorator.js +0 -56
- package/dist/modern/frameworks/react/config.js +0 -13
- package/dist/modern/frameworks/react/extractArgTypes.js +0 -38
- package/dist/modern/frameworks/react/extractProps.js +0 -41
- package/dist/modern/frameworks/react/jsxDecorator.js +0 -176
- package/dist/modern/frameworks/react/lib/captions.js +0 -6
- package/dist/modern/frameworks/react/lib/componentTypes.js +0 -2
- package/dist/modern/frameworks/react/lib/defaultValues/createDefaultValue.js +0 -72
- package/dist/modern/frameworks/react/lib/defaultValues/createFromRawDefaultProp.js +0 -181
- package/dist/modern/frameworks/react/lib/defaultValues/generateArray.js +0 -21
- package/dist/modern/frameworks/react/lib/defaultValues/generateObject.js +0 -21
- package/dist/modern/frameworks/react/lib/defaultValues/index.js +0 -2
- package/dist/modern/frameworks/react/lib/defaultValues/prettyIdentifier.js +0 -24
- package/dist/modern/frameworks/react/lib/generateCode.js +0 -59
- package/dist/modern/frameworks/react/lib/index.js +0 -4
- package/dist/modern/frameworks/react/lib/inspection/acornParser.js +0 -212
- package/dist/modern/frameworks/react/lib/inspection/index.js +0 -2
- package/dist/modern/frameworks/react/lib/inspection/inspectValue.js +0 -15
- package/dist/modern/frameworks/react/lib/inspection/types.js +0 -12
- package/dist/modern/frameworks/react/lib/isHtmlTag.js +0 -4
- package/dist/modern/frameworks/react/propTypes/createType.js +0 -446
- package/dist/modern/frameworks/react/propTypes/generateFuncSignature.js +0 -57
- package/dist/modern/frameworks/react/propTypes/handleProp.js +0 -39
- package/dist/modern/frameworks/react/propTypes/rawDefaultPropResolvers.js +0 -31
- package/dist/modern/frameworks/react/propTypes/sortProps.js +0 -14
- package/dist/modern/frameworks/react/react-argtypes.stories.js +0 -78
- package/dist/modern/frameworks/react/typeScript/handleProp.js +0 -28
- package/dist/modern/frameworks/svelte/HOC.svelte +0 -7
- package/dist/modern/frameworks/svelte/config.js +0 -13
- package/dist/modern/frameworks/svelte/extractArgTypes.js +0 -118
- package/dist/modern/frameworks/svelte/extractComponentDescription.js +0 -10
- package/dist/modern/frameworks/svelte/prepareForInline.js +0 -18
- package/dist/modern/frameworks/svelte/preset.js +0 -11
- package/dist/modern/frameworks/svelte/sample/MockButton.svelte +0 -45
- package/dist/modern/frameworks/svelte/sourceDecorator.js +0 -187
- package/dist/modern/frameworks/svelte/svelte-docgen-loader.js +0 -89
- package/dist/modern/frameworks/vue/config.js +0 -13
- package/dist/modern/frameworks/vue/extractArgTypes.js +0 -103
- package/dist/modern/frameworks/vue/prepareForInline.js +0 -40
- package/dist/modern/frameworks/vue/preset.js +0 -24
- package/dist/modern/frameworks/vue/sourceDecorator.js +0 -195
- package/dist/modern/frameworks/vue3/config.js +0 -11
- package/dist/modern/frameworks/vue3/extractArgTypes.js +0 -43
- package/dist/modern/frameworks/vue3/prepareForInline.js +0 -22
- package/dist/modern/frameworks/vue3/preset.js +0 -24
- package/dist/modern/frameworks/web-components/config.js +0 -17
- package/dist/modern/frameworks/web-components/custom-elements.js +0 -125
- package/dist/modern/frameworks/web-components/prepareForInline.js +0 -23
- package/dist/modern/frameworks/web-components/sourceDecorator.js +0 -47
- package/dist/modern/lib/convert/flow/convert.js +0 -89
- package/dist/modern/lib/convert/flow/index.js +0 -2
- package/dist/modern/lib/convert/flow/types.js +0 -0
- package/dist/modern/lib/convert/index.js +0 -14
- package/dist/modern/lib/convert/proptypes/convert.js +0 -102
- package/dist/modern/lib/convert/proptypes/index.js +0 -2
- package/dist/modern/lib/convert/proptypes/types.js +0 -0
- package/dist/modern/lib/convert/typescript/convert.js +0 -67
- package/dist/modern/lib/convert/typescript/index.js +0 -2
- package/dist/modern/lib/convert/typescript/types.js +0 -0
- package/dist/modern/lib/convert/utils.js +0 -2
- package/dist/modern/lib/docgen/PropDef.js +0 -0
- package/dist/modern/lib/docgen/createPropDef.js +0 -142
- package/dist/modern/lib/docgen/extractDocgenProps.js +0 -80
- package/dist/modern/lib/docgen/flow/createDefaultValue.js +0 -15
- package/dist/modern/lib/docgen/flow/createPropDef.js +0 -17
- package/dist/modern/lib/docgen/flow/createType.js +0 -103
- package/dist/modern/lib/docgen/index.js +0 -3
- package/dist/modern/lib/docgen/typeScript/createDefaultValue.js +0 -17
- package/dist/modern/lib/docgen/typeScript/createPropDef.js +0 -15
- package/dist/modern/lib/docgen/typeScript/createType.js +0 -16
- package/dist/modern/lib/docgen/types.js +0 -10
- package/dist/modern/lib/docgen/utils/defaultValue.js +0 -4
- package/dist/modern/lib/docgen/utils/docgenInfo.js +0 -14
- package/dist/modern/lib/docgen/utils/index.js +0 -3
- package/dist/modern/lib/docgen/utils/string.js +0 -11
- package/dist/modern/lib/index.js +0 -1
- package/dist/modern/lib/jsdocParser.js +0 -195
- package/dist/modern/lib/utils.js +0 -21
- package/dist/modern/typings.d.js +0 -0
- package/dist/ts3.4/frameworks/angular/compodoc.d.ts +0 -18
- package/dist/ts3.4/frameworks/angular/config.d.ts +0 -15
- package/dist/ts3.4/frameworks/angular/index.d.ts +0 -1
- package/dist/ts3.4/frameworks/angular/prepareForInline.d.ts +0 -7
- package/dist/ts3.4/frameworks/angular/sourceDecorator.d.ts +0 -9
- package/dist/ts3.4/frameworks/angular/types.d.ts +0 -102
- package/dist/ts3.4/frameworks/common/enhanceArgTypes.d.ts +0 -2
- package/dist/ts3.4/frameworks/html/config.d.ts +0 -14
- package/dist/ts3.4/frameworks/html/prepareForInline.d.ts +0 -2
- package/dist/ts3.4/frameworks/html/sourceDecorator.d.ts +0 -3
- package/dist/ts3.4/frameworks/react/config.d.ts +0 -12
- package/dist/ts3.4/frameworks/react/extractArgTypes.d.ts +0 -2
- package/dist/ts3.4/frameworks/react/extractProps.d.ts +0 -5
- package/dist/ts3.4/frameworks/react/jsxDecorator.d.ts +0 -23
- package/dist/ts3.4/frameworks/react/lib/captions.d.ts +0 -6
- package/dist/ts3.4/frameworks/react/lib/componentTypes.d.ts +0 -2
- package/dist/ts3.4/frameworks/react/lib/defaultValues/createDefaultValue.d.ts +0 -2
- package/dist/ts3.4/frameworks/react/lib/defaultValues/createFromRawDefaultProp.d.ts +0 -12
- package/dist/ts3.4/frameworks/react/lib/defaultValues/generateArray.d.ts +0 -3
- package/dist/ts3.4/frameworks/react/lib/defaultValues/generateObject.d.ts +0 -3
- package/dist/ts3.4/frameworks/react/lib/defaultValues/index.d.ts +0 -2
- package/dist/ts3.4/frameworks/react/lib/defaultValues/prettyIdentifier.d.ts +0 -4
- package/dist/ts3.4/frameworks/react/lib/generateCode.d.ts +0 -3
- package/dist/ts3.4/frameworks/react/lib/index.d.ts +0 -4
- package/dist/ts3.4/frameworks/react/lib/inspection/acornParser.d.ts +0 -7
- package/dist/ts3.4/frameworks/react/lib/inspection/index.d.ts +0 -2
- package/dist/ts3.4/frameworks/react/lib/inspection/inspectValue.d.ts +0 -2
- package/dist/ts3.4/frameworks/react/lib/inspection/types.d.ts +0 -50
- package/dist/ts3.4/frameworks/react/lib/isHtmlTag.d.ts +0 -1
- package/dist/ts3.4/frameworks/react/propTypes/createType.d.ts +0 -3
- package/dist/ts3.4/frameworks/react/propTypes/generateFuncSignature.d.ts +0 -4
- package/dist/ts3.4/frameworks/react/propTypes/handleProp.d.ts +0 -4
- package/dist/ts3.4/frameworks/react/propTypes/rawDefaultPropResolvers.d.ts +0 -1
- package/dist/ts3.4/frameworks/react/propTypes/sortProps.d.ts +0 -3
- package/dist/ts3.4/frameworks/react/typeScript/handleProp.d.ts +0 -3
- package/dist/ts3.4/frameworks/svelte/config.d.ts +0 -11
- package/dist/ts3.4/frameworks/svelte/extractArgTypes.d.ts +0 -5
- package/dist/ts3.4/frameworks/svelte/extractComponentDescription.d.ts +0 -2
- package/dist/ts3.4/frameworks/svelte/prepareForInline.d.ts +0 -3
- package/dist/ts3.4/frameworks/svelte/preset.d.ts +0 -3
- package/dist/ts3.4/frameworks/svelte/sourceDecorator.d.ts +0 -16
- package/dist/ts3.4/frameworks/svelte/svelte-docgen-loader.d.ts +0 -5
- package/dist/ts3.4/frameworks/vue/config.d.ts +0 -11
- package/dist/ts3.4/frameworks/vue/extractArgTypes.d.ts +0 -2
- package/dist/ts3.4/frameworks/vue/prepareForInline.d.ts +0 -4
- package/dist/ts3.4/frameworks/vue/preset.d.ts +0 -2
- package/dist/ts3.4/frameworks/vue/sourceDecorator.d.ts +0 -5
- package/dist/ts3.4/frameworks/vue3/config.d.ts +0 -10
- package/dist/ts3.4/frameworks/vue3/extractArgTypes.d.ts +0 -2
- package/dist/ts3.4/frameworks/vue3/prepareForInline.d.ts +0 -4
- package/dist/ts3.4/frameworks/vue3/preset.d.ts +0 -2
- package/dist/ts3.4/frameworks/web-components/config.d.ts +0 -18
- package/dist/ts3.4/frameworks/web-components/custom-elements.d.ts +0 -36
- package/dist/ts3.4/frameworks/web-components/prepareForInline.d.ts +0 -4
- package/dist/ts3.4/frameworks/web-components/sourceDecorator.d.ts +0 -3
- package/dist/ts3.4/lib/convert/flow/convert.d.ts +0 -3
- package/dist/ts3.4/lib/convert/flow/index.d.ts +0 -2
- package/dist/ts3.4/lib/convert/flow/types.d.ts +0 -43
- package/dist/ts3.4/lib/convert/index.d.ts +0 -2
- package/dist/ts3.4/lib/convert/proptypes/convert.d.ts +0 -3
- package/dist/ts3.4/lib/convert/proptypes/index.d.ts +0 -2
- package/dist/ts3.4/lib/convert/proptypes/types.d.ts +0 -11
- package/dist/ts3.4/lib/convert/typescript/convert.d.ts +0 -3
- package/dist/ts3.4/lib/convert/typescript/index.d.ts +0 -2
- package/dist/ts3.4/lib/convert/typescript/types.d.ts +0 -39
- package/dist/ts3.4/lib/convert/utils.d.ts +0 -1
- package/dist/ts3.4/lib/docgen/PropDef.d.ts +0 -26
- package/dist/ts3.4/lib/docgen/createPropDef.d.ts +0 -8
- package/dist/ts3.4/lib/docgen/extractDocgenProps.d.ts +0 -14
- package/dist/ts3.4/lib/docgen/flow/createDefaultValue.d.ts +0 -3
- package/dist/ts3.4/lib/docgen/flow/createPropDef.d.ts +0 -2
- package/dist/ts3.4/lib/docgen/flow/createType.d.ts +0 -3
- package/dist/ts3.4/lib/docgen/index.d.ts +0 -3
- package/dist/ts3.4/lib/docgen/typeScript/createDefaultValue.d.ts +0 -3
- package/dist/ts3.4/lib/docgen/typeScript/createPropDef.d.ts +0 -2
- package/dist/ts3.4/lib/docgen/typeScript/createType.d.ts +0 -3
- package/dist/ts3.4/lib/docgen/types.d.ts +0 -46
- package/dist/ts3.4/lib/docgen/utils/defaultValue.d.ts +0 -1
- package/dist/ts3.4/lib/docgen/utils/docgenInfo.d.ts +0 -5
- package/dist/ts3.4/lib/docgen/utils/index.d.ts +0 -3
- package/dist/ts3.4/lib/docgen/utils/string.d.ts +0 -1
- package/dist/ts3.4/lib/index.d.ts +0 -1
- package/dist/ts3.4/lib/jsdocParser.d.ts +0 -28
- package/dist/ts3.4/lib/utils.d.ts +0 -7
- package/dist/ts3.9/frameworks/angular/compodoc.d.ts +0 -18
- package/dist/ts3.9/frameworks/angular/config.d.ts +0 -15
- package/dist/ts3.9/frameworks/angular/index.d.ts +0 -1
- package/dist/ts3.9/frameworks/angular/prepareForInline.d.ts +0 -7
- package/dist/ts3.9/frameworks/angular/sourceDecorator.d.ts +0 -9
- package/dist/ts3.9/frameworks/angular/types.d.ts +0 -102
- package/dist/ts3.9/frameworks/common/enhanceArgTypes.d.ts +0 -2
- package/dist/ts3.9/frameworks/html/config.d.ts +0 -14
- package/dist/ts3.9/frameworks/html/prepareForInline.d.ts +0 -2
- package/dist/ts3.9/frameworks/html/sourceDecorator.d.ts +0 -3
- package/dist/ts3.9/frameworks/react/config.d.ts +0 -12
- package/dist/ts3.9/frameworks/react/extractArgTypes.d.ts +0 -2
- package/dist/ts3.9/frameworks/react/extractProps.d.ts +0 -5
- package/dist/ts3.9/frameworks/react/jsxDecorator.d.ts +0 -23
- package/dist/ts3.9/frameworks/react/lib/captions.d.ts +0 -6
- package/dist/ts3.9/frameworks/react/lib/componentTypes.d.ts +0 -2
- package/dist/ts3.9/frameworks/react/lib/defaultValues/createDefaultValue.d.ts +0 -2
- package/dist/ts3.9/frameworks/react/lib/defaultValues/createFromRawDefaultProp.d.ts +0 -12
- package/dist/ts3.9/frameworks/react/lib/defaultValues/generateArray.d.ts +0 -3
- package/dist/ts3.9/frameworks/react/lib/defaultValues/generateObject.d.ts +0 -3
- package/dist/ts3.9/frameworks/react/lib/defaultValues/index.d.ts +0 -2
- package/dist/ts3.9/frameworks/react/lib/defaultValues/prettyIdentifier.d.ts +0 -4
- package/dist/ts3.9/frameworks/react/lib/generateCode.d.ts +0 -3
- package/dist/ts3.9/frameworks/react/lib/index.d.ts +0 -4
- package/dist/ts3.9/frameworks/react/lib/inspection/acornParser.d.ts +0 -7
- package/dist/ts3.9/frameworks/react/lib/inspection/index.d.ts +0 -2
- package/dist/ts3.9/frameworks/react/lib/inspection/inspectValue.d.ts +0 -2
- package/dist/ts3.9/frameworks/react/lib/inspection/types.d.ts +0 -50
- package/dist/ts3.9/frameworks/react/lib/isHtmlTag.d.ts +0 -1
- package/dist/ts3.9/frameworks/react/propTypes/createType.d.ts +0 -3
- package/dist/ts3.9/frameworks/react/propTypes/generateFuncSignature.d.ts +0 -4
- package/dist/ts3.9/frameworks/react/propTypes/handleProp.d.ts +0 -4
- package/dist/ts3.9/frameworks/react/propTypes/rawDefaultPropResolvers.d.ts +0 -1
- package/dist/ts3.9/frameworks/react/propTypes/sortProps.d.ts +0 -3
- package/dist/ts3.9/frameworks/react/typeScript/handleProp.d.ts +0 -3
- package/dist/ts3.9/frameworks/svelte/config.d.ts +0 -11
- package/dist/ts3.9/frameworks/svelte/extractArgTypes.d.ts +0 -5
- package/dist/ts3.9/frameworks/svelte/extractComponentDescription.d.ts +0 -2
- package/dist/ts3.9/frameworks/svelte/prepareForInline.d.ts +0 -3
- package/dist/ts3.9/frameworks/svelte/preset.d.ts +0 -3
- package/dist/ts3.9/frameworks/svelte/sourceDecorator.d.ts +0 -16
- package/dist/ts3.9/frameworks/svelte/svelte-docgen-loader.d.ts +0 -5
- package/dist/ts3.9/frameworks/vue/config.d.ts +0 -11
- package/dist/ts3.9/frameworks/vue/extractArgTypes.d.ts +0 -2
- package/dist/ts3.9/frameworks/vue/prepareForInline.d.ts +0 -4
- package/dist/ts3.9/frameworks/vue/preset.d.ts +0 -2
- package/dist/ts3.9/frameworks/vue/sourceDecorator.d.ts +0 -5
- package/dist/ts3.9/frameworks/vue3/config.d.ts +0 -10
- package/dist/ts3.9/frameworks/vue3/extractArgTypes.d.ts +0 -2
- package/dist/ts3.9/frameworks/vue3/prepareForInline.d.ts +0 -4
- package/dist/ts3.9/frameworks/vue3/preset.d.ts +0 -2
- package/dist/ts3.9/frameworks/web-components/config.d.ts +0 -18
- package/dist/ts3.9/frameworks/web-components/custom-elements.d.ts +0 -35
- package/dist/ts3.9/frameworks/web-components/prepareForInline.d.ts +0 -4
- package/dist/ts3.9/frameworks/web-components/sourceDecorator.d.ts +0 -3
- package/dist/ts3.9/lib/convert/flow/convert.d.ts +0 -3
- package/dist/ts3.9/lib/convert/flow/index.d.ts +0 -2
- package/dist/ts3.9/lib/convert/flow/types.d.ts +0 -43
- package/dist/ts3.9/lib/convert/index.d.ts +0 -2
- package/dist/ts3.9/lib/convert/proptypes/convert.d.ts +0 -3
- package/dist/ts3.9/lib/convert/proptypes/index.d.ts +0 -2
- package/dist/ts3.9/lib/convert/proptypes/types.d.ts +0 -11
- package/dist/ts3.9/lib/convert/typescript/convert.d.ts +0 -3
- package/dist/ts3.9/lib/convert/typescript/index.d.ts +0 -2
- package/dist/ts3.9/lib/convert/typescript/types.d.ts +0 -39
- package/dist/ts3.9/lib/convert/utils.d.ts +0 -1
- package/dist/ts3.9/lib/docgen/PropDef.d.ts +0 -26
- package/dist/ts3.9/lib/docgen/createPropDef.d.ts +0 -8
- package/dist/ts3.9/lib/docgen/extractDocgenProps.d.ts +0 -14
- package/dist/ts3.9/lib/docgen/flow/createDefaultValue.d.ts +0 -3
- package/dist/ts3.9/lib/docgen/flow/createPropDef.d.ts +0 -2
- package/dist/ts3.9/lib/docgen/flow/createType.d.ts +0 -3
- package/dist/ts3.9/lib/docgen/index.d.ts +0 -3
- package/dist/ts3.9/lib/docgen/typeScript/createDefaultValue.d.ts +0 -3
- package/dist/ts3.9/lib/docgen/typeScript/createPropDef.d.ts +0 -2
- package/dist/ts3.9/lib/docgen/typeScript/createType.d.ts +0 -3
- package/dist/ts3.9/lib/docgen/types.d.ts +0 -46
- package/dist/ts3.9/lib/docgen/utils/defaultValue.d.ts +0 -1
- package/dist/ts3.9/lib/docgen/utils/docgenInfo.d.ts +0 -5
- package/dist/ts3.9/lib/docgen/utils/index.d.ts +0 -3
- package/dist/ts3.9/lib/docgen/utils/string.d.ts +0 -1
- package/dist/ts3.9/lib/index.d.ts +0 -1
- package/dist/ts3.9/lib/jsdocParser.d.ts +0 -28
- package/dist/ts3.9/lib/utils.d.ts +0 -7
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import "core-js/modules/es.array.reduce.js";
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-underscore-dangle */
|
|
4
|
-
|
|
5
|
-
/* global window */
|
|
6
|
-
export const setJSONDoc = jsondoc => {
|
|
7
|
-
window.__EMBER_GENERATED_DOC_JSON__ = jsondoc;
|
|
8
|
-
};
|
|
9
|
-
export const getJSONDoc = () => {
|
|
10
|
-
return window.__EMBER_GENERATED_DOC_JSON__;
|
|
11
|
-
};
|
|
12
|
-
export const extractArgTypes = componentName => {
|
|
13
|
-
const json = getJSONDoc();
|
|
14
|
-
|
|
15
|
-
if (!(json && json.included)) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const componentDoc = json.included.find(doc => doc.attributes.name === componentName);
|
|
20
|
-
|
|
21
|
-
if (!componentDoc) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return componentDoc.attributes.arguments.reduce((acc, prop) => {
|
|
26
|
-
acc[prop.name] = {
|
|
27
|
-
name: prop.name,
|
|
28
|
-
defaultValue: prop.defaultValue,
|
|
29
|
-
description: prop.description,
|
|
30
|
-
table: {
|
|
31
|
-
defaultValue: {
|
|
32
|
-
summary: prop.defaultValue
|
|
33
|
-
},
|
|
34
|
-
type: {
|
|
35
|
-
summary: prop.type,
|
|
36
|
-
required: prop.tags.length ? prop.tags.some(tag => tag.name === 'required') : false
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
return acc;
|
|
41
|
-
}, {});
|
|
42
|
-
};
|
|
43
|
-
export const extractComponentDescription = componentName => {
|
|
44
|
-
const json = getJSONDoc();
|
|
45
|
-
|
|
46
|
-
if (!(json && json.included)) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const componentDoc = json.included.find(doc => doc.attributes.name === componentName);
|
|
51
|
-
|
|
52
|
-
if (!componentDoc) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return componentDoc.attributes.description;
|
|
57
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { sourceDecorator } from './sourceDecorator';
|
|
2
|
-
import { prepareForInline } from './prepareForInline';
|
|
3
|
-
import { SourceType } from '../../shared';
|
|
4
|
-
export const decorators = [sourceDecorator];
|
|
5
|
-
export const parameters = {
|
|
6
|
-
docs: {
|
|
7
|
-
inlineStories: true,
|
|
8
|
-
prepareForInline,
|
|
9
|
-
source: {
|
|
10
|
-
type: SourceType.DYNAMIC,
|
|
11
|
-
language: 'html'
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export function prepareForInline(storyFn) {
|
|
3
|
-
const html = storyFn();
|
|
4
|
-
|
|
5
|
-
if (typeof html === 'string') {
|
|
6
|
-
// eslint-disable-next-line react/no-danger
|
|
7
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
8
|
-
dangerouslySetInnerHTML: {
|
|
9
|
-
__html: html
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
-
ref: node => node ? node.appendChild(html) : null
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/* global window */
|
|
2
|
-
import { addons, useEffect } from '@storybook/addons';
|
|
3
|
-
import dedent from 'ts-dedent';
|
|
4
|
-
import { SNIPPET_RENDERED, SourceType } from '../../shared';
|
|
5
|
-
|
|
6
|
-
function skipSourceRender(context) {
|
|
7
|
-
var _context$parameters$d;
|
|
8
|
-
|
|
9
|
-
const sourceParams = context === null || context === void 0 ? void 0 : (_context$parameters$d = context.parameters.docs) === null || _context$parameters$d === void 0 ? void 0 : _context$parameters$d.source;
|
|
10
|
-
const isArgsStory = context === null || context === void 0 ? void 0 : context.parameters.__isArgsStory; // always render if the user forces it
|
|
11
|
-
|
|
12
|
-
if ((sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === SourceType.DYNAMIC) {
|
|
13
|
-
return false;
|
|
14
|
-
} // never render if the user is forcing the block to render code, or
|
|
15
|
-
// if the user provides code, or if it's not an args story.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return !isArgsStory || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.code) || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === SourceType.CODE;
|
|
19
|
-
} // By default, just remove indentation
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function defaultTransformSource(source) {
|
|
23
|
-
// Have to wrap dedent so it doesn't serialize the context
|
|
24
|
-
return dedent(source);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function applyTransformSource(source, context) {
|
|
28
|
-
var _context$parameters$d2, _docs$transformSource;
|
|
29
|
-
|
|
30
|
-
const docs = (_context$parameters$d2 = context.parameters.docs) !== null && _context$parameters$d2 !== void 0 ? _context$parameters$d2 : {};
|
|
31
|
-
const transformSource = (_docs$transformSource = docs.transformSource) !== null && _docs$transformSource !== void 0 ? _docs$transformSource : defaultTransformSource;
|
|
32
|
-
return transformSource(source, context);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function sourceDecorator(storyFn, context) {
|
|
36
|
-
var _context$parameters$d3, _context$parameters$d4;
|
|
37
|
-
|
|
38
|
-
const story = context !== null && context !== void 0 && (_context$parameters$d3 = context.parameters.docs) !== null && _context$parameters$d3 !== void 0 && (_context$parameters$d4 = _context$parameters$d3.source) !== null && _context$parameters$d4 !== void 0 && _context$parameters$d4.excludeDecorators ? context.originalStoryFn(context.args, context) : storyFn();
|
|
39
|
-
let source;
|
|
40
|
-
|
|
41
|
-
if (!skipSourceRender(context)) {
|
|
42
|
-
if (typeof story === 'string') {
|
|
43
|
-
source = story;
|
|
44
|
-
} // eslint-disable-next-line no-undef
|
|
45
|
-
else if (story instanceof Element) {
|
|
46
|
-
source = story.outerHTML;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (source) source = applyTransformSource(source, context);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (source) addons.getChannel().emit(SNIPPET_RENDERED, context.id, source);
|
|
54
|
-
});
|
|
55
|
-
return story;
|
|
56
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { extractArgTypes } from './extractArgTypes';
|
|
2
|
-
import { extractComponentDescription } from '../../lib/docgen';
|
|
3
|
-
import { jsxDecorator } from './jsxDecorator';
|
|
4
|
-
export const parameters = {
|
|
5
|
-
docs: {
|
|
6
|
-
inlineStories: true,
|
|
7
|
-
// NOTE: that the result is a react element. Hooks support is provided by the outer code.
|
|
8
|
-
prepareForInline: storyFn => storyFn(),
|
|
9
|
-
extractArgTypes,
|
|
10
|
-
extractComponentDescription
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
export const decorators = [jsxDecorator];
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import "core-js/modules/es.array.reduce.js";
|
|
2
|
-
import { extractProps } from './extractProps';
|
|
3
|
-
export const extractArgTypes = component => {
|
|
4
|
-
if (component) {
|
|
5
|
-
const {
|
|
6
|
-
rows
|
|
7
|
-
} = extractProps(component);
|
|
8
|
-
|
|
9
|
-
if (rows) {
|
|
10
|
-
return rows.reduce((acc, row) => {
|
|
11
|
-
const {
|
|
12
|
-
name,
|
|
13
|
-
description,
|
|
14
|
-
type,
|
|
15
|
-
sbType,
|
|
16
|
-
defaultValue: defaultSummary,
|
|
17
|
-
jsDocTags,
|
|
18
|
-
required
|
|
19
|
-
} = row;
|
|
20
|
-
acc[name] = {
|
|
21
|
-
name,
|
|
22
|
-
description,
|
|
23
|
-
type: Object.assign({
|
|
24
|
-
required
|
|
25
|
-
}, sbType),
|
|
26
|
-
table: {
|
|
27
|
-
type,
|
|
28
|
-
jsDocTags,
|
|
29
|
-
defaultValue: defaultSummary
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
return acc;
|
|
33
|
-
}, {});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return null;
|
|
38
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import { hasDocgen, extractComponentProps, TypeSystem } from '../../lib/docgen';
|
|
3
|
-
import { enhancePropTypesProps } from './propTypes/handleProp';
|
|
4
|
-
import { enhanceTypeScriptProps } from './typeScript/handleProp';
|
|
5
|
-
import { isMemo } from './lib';
|
|
6
|
-
const propTypesMap = new Map();
|
|
7
|
-
Object.keys(PropTypes).forEach(typeName => {
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
const type = PropTypes[typeName];
|
|
10
|
-
propTypesMap.set(type, typeName);
|
|
11
|
-
propTypesMap.set(type.isRequired, typeName);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
function getPropDefs(component, section) {
|
|
15
|
-
let processedComponent = component; // eslint-disable-next-line react/forbid-foreign-prop-types
|
|
16
|
-
|
|
17
|
-
if (!hasDocgen(component) && !component.propTypes && isMemo(component)) {
|
|
18
|
-
processedComponent = component.type;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const extractedProps = extractComponentProps(processedComponent, section);
|
|
22
|
-
|
|
23
|
-
if (extractedProps.length === 0) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
switch (extractedProps[0].typeSystem) {
|
|
28
|
-
case TypeSystem.JAVASCRIPT:
|
|
29
|
-
return enhancePropTypesProps(extractedProps, component);
|
|
30
|
-
|
|
31
|
-
case TypeSystem.TYPESCRIPT:
|
|
32
|
-
return enhanceTypeScriptProps(extractedProps);
|
|
33
|
-
|
|
34
|
-
default:
|
|
35
|
-
return extractedProps.map(x => x.propDef);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const extractProps = component => ({
|
|
40
|
-
rows: getPropDefs(component, 'props')
|
|
41
|
-
});
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
2
|
-
|
|
3
|
-
import React, { createElement } from 'react';
|
|
4
|
-
import reactElementToJSXString from 'react-element-to-jsx-string';
|
|
5
|
-
import dedent from 'ts-dedent';
|
|
6
|
-
import deprecate from 'util-deprecate';
|
|
7
|
-
import { addons, useEffect } from '@storybook/addons';
|
|
8
|
-
import { logger } from '@storybook/client-logger';
|
|
9
|
-
import { SourceType, SNIPPET_RENDERED } from '../../shared';
|
|
10
|
-
import { getDocgenSection } from '../../lib/docgen';
|
|
11
|
-
import { isMemo, isForwardRef } from './lib';
|
|
12
|
-
|
|
13
|
-
/** Run the user supplied onBeforeRender function if it exists */
|
|
14
|
-
const applyBeforeRender = (domString, options) => {
|
|
15
|
-
if (typeof options.onBeforeRender !== 'function') {
|
|
16
|
-
return domString;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const deprecatedOnBeforeRender = deprecate(options.onBeforeRender, dedent`
|
|
20
|
-
StoryFn.parameters.jsx.onBeforeRender was deprecated.
|
|
21
|
-
Prefer StoryFn.parameters.jsx.transformSource instead.
|
|
22
|
-
See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-onbeforerender for details.
|
|
23
|
-
`);
|
|
24
|
-
return deprecatedOnBeforeRender(domString);
|
|
25
|
-
};
|
|
26
|
-
/** Run the user supplied transformSource function if it exists */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const applyTransformSource = (domString, options, context) => {
|
|
30
|
-
if (typeof options.transformSource !== 'function') {
|
|
31
|
-
return domString;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return options.transformSource(domString, context);
|
|
35
|
-
};
|
|
36
|
-
/** Apply the users parameters and render the jsx for a story */
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export const renderJsx = (code, options) => {
|
|
40
|
-
if (typeof code === 'undefined') {
|
|
41
|
-
logger.warn('Too many skip or undefined component');
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let renderedJSX = code;
|
|
46
|
-
const Type = renderedJSX.type;
|
|
47
|
-
|
|
48
|
-
for (let i = 0; i < options.skip; i += 1) {
|
|
49
|
-
if (typeof renderedJSX === 'undefined') {
|
|
50
|
-
logger.warn('Cannot skip undefined element');
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (React.Children.count(renderedJSX) > 1) {
|
|
55
|
-
logger.warn('Trying to skip an array of elements');
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (typeof renderedJSX.props.children === 'undefined') {
|
|
60
|
-
logger.warn('Not enough children to skip elements.');
|
|
61
|
-
|
|
62
|
-
if (typeof renderedJSX.type === 'function' && renderedJSX.type.name === '') {
|
|
63
|
-
renderedJSX = /*#__PURE__*/React.createElement(Type, renderedJSX.props);
|
|
64
|
-
}
|
|
65
|
-
} else if (typeof renderedJSX.props.children === 'function') {
|
|
66
|
-
renderedJSX = renderedJSX.props.children();
|
|
67
|
-
} else {
|
|
68
|
-
renderedJSX = renderedJSX.props.children;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const displayNameDefaults = typeof options.displayName === 'string' ? {
|
|
73
|
-
showFunctions: true,
|
|
74
|
-
displayName: () => options.displayName
|
|
75
|
-
} : {
|
|
76
|
-
// To get exotic component names resolving properly
|
|
77
|
-
displayName: el => el.type.displayName || getDocgenSection(el.type, 'displayName') || (el.type.name !== '_default' ? el.type.name : null) || (typeof el.type === 'function' ? 'No Display Name' : null) || (isForwardRef(el.type) ? el.type.render.name : null) || (isMemo(el.type) ? el.type.type.name : null) || el.type
|
|
78
|
-
};
|
|
79
|
-
const filterDefaults = {
|
|
80
|
-
filterProps: (value, key) => value !== undefined
|
|
81
|
-
};
|
|
82
|
-
const opts = Object.assign({}, displayNameDefaults, filterDefaults, options);
|
|
83
|
-
const result = React.Children.map(code, c => {
|
|
84
|
-
// @ts-ignore FIXME: workaround react-element-to-jsx-string
|
|
85
|
-
const child = typeof c === 'number' ? c.toString() : c;
|
|
86
|
-
let string = applyBeforeRender(reactElementToJSXString(child, opts), options);
|
|
87
|
-
|
|
88
|
-
if (string.indexOf('"') > -1) {
|
|
89
|
-
const matches = string.match(/\S+=\\"([^"]*)\\"/g);
|
|
90
|
-
|
|
91
|
-
if (matches) {
|
|
92
|
-
matches.forEach(match => {
|
|
93
|
-
string = string.replace(match, match.replace(/"/g, "'"));
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return string;
|
|
99
|
-
}).join('\n');
|
|
100
|
-
return result.replace(/function\s+noRefCheck\(\)\s+\{\}/, '() => {}');
|
|
101
|
-
};
|
|
102
|
-
const defaultOpts = {
|
|
103
|
-
skip: 0,
|
|
104
|
-
showFunctions: false,
|
|
105
|
-
enableBeautify: true,
|
|
106
|
-
showDefaultProps: false
|
|
107
|
-
};
|
|
108
|
-
export const skipJsxRender = context => {
|
|
109
|
-
var _context$parameters$d;
|
|
110
|
-
|
|
111
|
-
const sourceParams = context === null || context === void 0 ? void 0 : (_context$parameters$d = context.parameters.docs) === null || _context$parameters$d === void 0 ? void 0 : _context$parameters$d.source;
|
|
112
|
-
const isArgsStory = context === null || context === void 0 ? void 0 : context.parameters.__isArgsStory; // always render if the user forces it
|
|
113
|
-
|
|
114
|
-
if ((sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === SourceType.DYNAMIC) {
|
|
115
|
-
return false;
|
|
116
|
-
} // never render if the user is forcing the block to render code, or
|
|
117
|
-
// if the user provides code, or if it's not an args story.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return !isArgsStory || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.code) || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === SourceType.CODE;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const isMdx = node => {
|
|
124
|
-
var _node$type, _node$props;
|
|
125
|
-
|
|
126
|
-
return ((_node$type = node.type) === null || _node$type === void 0 ? void 0 : _node$type.displayName) === 'MDXCreateElement' && !!((_node$props = node.props) !== null && _node$props !== void 0 && _node$props.mdxType);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const mdxToJsx = node => {
|
|
130
|
-
if (!isMdx(node)) return node;
|
|
131
|
-
|
|
132
|
-
const _node$props2 = node.props,
|
|
133
|
-
{
|
|
134
|
-
originalType,
|
|
135
|
-
children
|
|
136
|
-
} = _node$props2,
|
|
137
|
-
rest = _objectWithoutPropertiesLoose(_node$props2, ["mdxType", "originalType", "children"]);
|
|
138
|
-
|
|
139
|
-
let jsxChildren = [];
|
|
140
|
-
|
|
141
|
-
if (children) {
|
|
142
|
-
const array = Array.isArray(children) ? children : [children];
|
|
143
|
-
jsxChildren = array.map(mdxToJsx);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return /*#__PURE__*/createElement(originalType, rest, ...jsxChildren);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
export const jsxDecorator = (storyFn, context) => {
|
|
150
|
-
var _context$parameters$d2, _context$parameters$d3;
|
|
151
|
-
|
|
152
|
-
const channel = addons.getChannel();
|
|
153
|
-
const skip = skipJsxRender(context);
|
|
154
|
-
const story = storyFn();
|
|
155
|
-
let jsx = '';
|
|
156
|
-
useEffect(() => {
|
|
157
|
-
if (!skip) channel.emit(SNIPPET_RENDERED, (context || {}).id, jsx);
|
|
158
|
-
}); // We only need to render JSX if the source block is actually going to
|
|
159
|
-
// consume it. Otherwise it's just slowing us down.
|
|
160
|
-
|
|
161
|
-
if (skip) {
|
|
162
|
-
return story;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const options = Object.assign({}, defaultOpts, (context === null || context === void 0 ? void 0 : context.parameters.jsx) || {}); // Exclude decorators from source code snippet by default
|
|
166
|
-
|
|
167
|
-
const storyJsx = context !== null && context !== void 0 && (_context$parameters$d2 = context.parameters.docs) !== null && _context$parameters$d2 !== void 0 && (_context$parameters$d3 = _context$parameters$d2.source) !== null && _context$parameters$d3 !== void 0 && _context$parameters$d3.excludeDecorators ? context.originalStoryFn(context.args, context) : story;
|
|
168
|
-
const sourceJsx = mdxToJsx(storyJsx);
|
|
169
|
-
const rendered = renderJsx(sourceJsx, options);
|
|
170
|
-
|
|
171
|
-
if (rendered) {
|
|
172
|
-
jsx = applyTransformSource(rendered, options, context);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return story;
|
|
176
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { FUNCTION_CAPTION, ELEMENT_CAPTION } from '../captions';
|
|
2
|
-
import { InspectionType, inspectValue } from '../inspection';
|
|
3
|
-
import { isHtmlTag } from '../isHtmlTag';
|
|
4
|
-
import { createSummaryValue, isTooLongForDefaultValueSummary } from '../../../../lib';
|
|
5
|
-
import { generateCode } from '../generateCode';
|
|
6
|
-
import { generateObject } from './generateObject';
|
|
7
|
-
import { generateArray } from './generateArray';
|
|
8
|
-
import { getPrettyIdentifier } from './prettyIdentifier';
|
|
9
|
-
|
|
10
|
-
function generateFunc({
|
|
11
|
-
inferredType,
|
|
12
|
-
ast
|
|
13
|
-
}) {
|
|
14
|
-
const {
|
|
15
|
-
identifier
|
|
16
|
-
} = inferredType;
|
|
17
|
-
|
|
18
|
-
if (identifier != null) {
|
|
19
|
-
return createSummaryValue(getPrettyIdentifier(inferredType), generateCode(ast));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const prettyCaption = generateCode(ast, true);
|
|
23
|
-
return !isTooLongForDefaultValueSummary(prettyCaption) ? createSummaryValue(prettyCaption) : createSummaryValue(FUNCTION_CAPTION, generateCode(ast));
|
|
24
|
-
} // All elements are JSX elements.
|
|
25
|
-
// JSX elements are not supported by escodegen.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function generateElement(defaultValue, inspectionResult) {
|
|
29
|
-
const {
|
|
30
|
-
inferredType
|
|
31
|
-
} = inspectionResult;
|
|
32
|
-
const {
|
|
33
|
-
identifier
|
|
34
|
-
} = inferredType;
|
|
35
|
-
|
|
36
|
-
if (identifier != null) {
|
|
37
|
-
if (!isHtmlTag(identifier)) {
|
|
38
|
-
const prettyIdentifier = getPrettyIdentifier(inferredType);
|
|
39
|
-
return createSummaryValue(prettyIdentifier, defaultValue);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return !isTooLongForDefaultValueSummary(defaultValue) ? createSummaryValue(defaultValue) : createSummaryValue(ELEMENT_CAPTION, defaultValue);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function createDefaultValue(defaultValue) {
|
|
47
|
-
try {
|
|
48
|
-
const inspectionResult = inspectValue(defaultValue);
|
|
49
|
-
|
|
50
|
-
switch (inspectionResult.inferredType.type) {
|
|
51
|
-
case InspectionType.OBJECT:
|
|
52
|
-
return generateObject(inspectionResult);
|
|
53
|
-
|
|
54
|
-
case InspectionType.FUNCTION:
|
|
55
|
-
return generateFunc(inspectionResult);
|
|
56
|
-
|
|
57
|
-
case InspectionType.ELEMENT:
|
|
58
|
-
return generateElement(defaultValue, inspectionResult);
|
|
59
|
-
|
|
60
|
-
case InspectionType.ARRAY:
|
|
61
|
-
return generateArray(inspectionResult);
|
|
62
|
-
|
|
63
|
-
default:
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
} catch (e) {
|
|
67
|
-
// eslint-disable-next-line no-console
|
|
68
|
-
console.error(e);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import isPlainObject from 'lodash/isPlainObject';
|
|
2
|
-
import isFunction from 'lodash/isFunction';
|
|
3
|
-
import isString from 'lodash/isString'; // @ts-ignore
|
|
4
|
-
|
|
5
|
-
import reactElementToJSXString from 'react-element-to-jsx-string';
|
|
6
|
-
import { createSummaryValue, isTooLongForDefaultValueSummary } from '../../../../lib';
|
|
7
|
-
import { inspectValue } from '../inspection';
|
|
8
|
-
import { generateObject } from './generateObject';
|
|
9
|
-
import { generateArray } from './generateArray';
|
|
10
|
-
import { getPrettyElementIdentifier, getPrettyFuncIdentifier } from './prettyIdentifier';
|
|
11
|
-
import { OBJECT_CAPTION, FUNCTION_CAPTION, ELEMENT_CAPTION } from '../captions';
|
|
12
|
-
import { isHtmlTag } from '../isHtmlTag';
|
|
13
|
-
|
|
14
|
-
function isReactElement(element) {
|
|
15
|
-
return element.$$typeof != null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function extractFunctionName(func, propName) {
|
|
19
|
-
const {
|
|
20
|
-
name
|
|
21
|
-
} = func; // Comparison with the prop name is to discard inferred function names.
|
|
22
|
-
|
|
23
|
-
if (name !== '' && name !== 'anonymous' && name !== propName) {
|
|
24
|
-
return name;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const stringResolver = rawDefaultProp => {
|
|
31
|
-
return createSummaryValue(JSON.stringify(rawDefaultProp));
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function generateReactObject(rawDefaultProp) {
|
|
35
|
-
const {
|
|
36
|
-
type
|
|
37
|
-
} = rawDefaultProp;
|
|
38
|
-
const {
|
|
39
|
-
displayName
|
|
40
|
-
} = type;
|
|
41
|
-
const jsx = reactElementToJSXString(rawDefaultProp, {});
|
|
42
|
-
|
|
43
|
-
if (displayName != null) {
|
|
44
|
-
const prettyIdentifier = getPrettyElementIdentifier(displayName);
|
|
45
|
-
return createSummaryValue(prettyIdentifier, jsx);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (isString(type)) {
|
|
49
|
-
// This is an HTML element.
|
|
50
|
-
if (isHtmlTag(type)) {
|
|
51
|
-
const jsxCompact = reactElementToJSXString(rawDefaultProp, {
|
|
52
|
-
tabStop: 0
|
|
53
|
-
});
|
|
54
|
-
const jsxSummary = jsxCompact.replace(/\r?\n|\r/g, '');
|
|
55
|
-
|
|
56
|
-
if (!isTooLongForDefaultValueSummary(jsxSummary)) {
|
|
57
|
-
return createSummaryValue(jsxSummary);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return createSummaryValue(ELEMENT_CAPTION, jsx);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const objectResolver = rawDefaultProp => {
|
|
66
|
-
if (isReactElement(rawDefaultProp) && rawDefaultProp.type != null) {
|
|
67
|
-
return generateReactObject(rawDefaultProp);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (isPlainObject(rawDefaultProp)) {
|
|
71
|
-
const inspectionResult = inspectValue(JSON.stringify(rawDefaultProp));
|
|
72
|
-
return generateObject(inspectionResult);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (Array.isArray(rawDefaultProp)) {
|
|
76
|
-
const inspectionResult = inspectValue(JSON.stringify(rawDefaultProp));
|
|
77
|
-
return generateArray(inspectionResult);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return createSummaryValue(OBJECT_CAPTION);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const functionResolver = (rawDefaultProp, propDef) => {
|
|
84
|
-
let isElement = false;
|
|
85
|
-
let inspectionResult; // Try to display the name of the component. The body of the component is omitted since the code has been transpiled.
|
|
86
|
-
|
|
87
|
-
if (isFunction(rawDefaultProp.render)) {
|
|
88
|
-
isElement = true;
|
|
89
|
-
} else if (rawDefaultProp.prototype != null && isFunction(rawDefaultProp.prototype.render)) {
|
|
90
|
-
isElement = true;
|
|
91
|
-
} else {
|
|
92
|
-
let innerElement;
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
inspectionResult = inspectValue(rawDefaultProp.toString());
|
|
96
|
-
const {
|
|
97
|
-
hasParams,
|
|
98
|
-
params
|
|
99
|
-
} = inspectionResult.inferredType;
|
|
100
|
-
|
|
101
|
-
if (hasParams) {
|
|
102
|
-
// It might be a functional component accepting props.
|
|
103
|
-
if (params.length === 1 && params[0].type === 'ObjectPattern') {
|
|
104
|
-
innerElement = rawDefaultProp({});
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
innerElement = rawDefaultProp();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (innerElement != null) {
|
|
111
|
-
if (isReactElement(innerElement)) {
|
|
112
|
-
isElement = true;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
} catch (e) {// do nothing.
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const funcName = extractFunctionName(rawDefaultProp, propDef.name);
|
|
120
|
-
|
|
121
|
-
if (funcName != null) {
|
|
122
|
-
if (isElement) {
|
|
123
|
-
return createSummaryValue(getPrettyElementIdentifier(funcName));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (inspectionResult != null) {
|
|
127
|
-
inspectionResult = inspectValue(rawDefaultProp.toString());
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const {
|
|
131
|
-
hasParams
|
|
132
|
-
} = inspectionResult.inferredType;
|
|
133
|
-
return createSummaryValue(getPrettyFuncIdentifier(funcName, hasParams));
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return createSummaryValue(isElement ? ELEMENT_CAPTION : FUNCTION_CAPTION);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const defaultResolver = rawDefaultProp => {
|
|
140
|
-
return createSummaryValue(rawDefaultProp.toString());
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const DEFAULT_TYPE_RESOLVERS = {
|
|
144
|
-
string: stringResolver,
|
|
145
|
-
object: objectResolver,
|
|
146
|
-
function: functionResolver,
|
|
147
|
-
default: defaultResolver
|
|
148
|
-
};
|
|
149
|
-
export function createTypeResolvers(customResolvers = {}) {
|
|
150
|
-
return Object.assign({}, DEFAULT_TYPE_RESOLVERS, customResolvers);
|
|
151
|
-
} // When react-docgen cannot provide a defaultValue we take it from the raw defaultProp.
|
|
152
|
-
// It works fine for types that are not transpiled. For the types that are transpiled, we can only provide partial support.
|
|
153
|
-
// This means that:
|
|
154
|
-
// - The detail might not be available.
|
|
155
|
-
// - Identifiers might not be "prettified" for all the types.
|
|
156
|
-
|
|
157
|
-
export function createDefaultValueFromRawDefaultProp(rawDefaultProp, propDef, typeResolvers = DEFAULT_TYPE_RESOLVERS) {
|
|
158
|
-
try {
|
|
159
|
-
// Keep the extra () otherwise it will fail for functions.
|
|
160
|
-
switch (typeof rawDefaultProp) {
|
|
161
|
-
case 'string':
|
|
162
|
-
return typeResolvers.string(rawDefaultProp, propDef);
|
|
163
|
-
|
|
164
|
-
case 'object':
|
|
165
|
-
return typeResolvers.object(rawDefaultProp, propDef);
|
|
166
|
-
|
|
167
|
-
case 'function':
|
|
168
|
-
{
|
|
169
|
-
return typeResolvers.function(rawDefaultProp, propDef);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
default:
|
|
173
|
-
return typeResolvers.default(rawDefaultProp, propDef);
|
|
174
|
-
}
|
|
175
|
-
} catch (e) {
|
|
176
|
-
// eslint-disable-next-line no-console
|
|
177
|
-
console.error(e);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return null;
|
|
181
|
-
}
|