@storybook/react 7.0.0-alpha.5 → 7.0.0-alpha.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-3ETZESFO.mjs +1 -0
- package/dist/config.d.ts +22 -0
- package/dist/config.js +3 -0
- package/dist/config.mjs +3 -0
- package/dist/index.d.ts +193 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/types-f5aed487.d.ts +10 -0
- package/jest.config.js +7 -0
- package/package.json +47 -19
- package/preview.js +1 -1
- package/template/cli/.eslintrc.json +5 -0
- package/template/cli/js/Button.jsx +50 -0
- package/template/cli/js/Button.stories.js +41 -0
- package/template/cli/js/Header.jsx +59 -0
- package/template/cli/js/Header.stories.js +22 -0
- package/template/cli/js/Page.jsx +69 -0
- package/template/cli/js/Page.stories.js +25 -0
- package/template/cli/ts/Button.stories.ts +47 -0
- package/template/cli/ts/Button.tsx +48 -0
- package/template/cli/ts/Header.stories.ts +26 -0
- package/template/cli/ts/Header.tsx +56 -0
- package/template/cli/ts/Page.stories.ts +29 -0
- package/template/cli/ts/Page.tsx +73 -0
- package/template/components/Button.jsx +13 -0
- package/template/components/Form.jsx +36 -0
- package/template/components/Html.jsx +9 -0
- package/template/components/Pre.jsx +20 -0
- package/template/components/index.js +9 -0
- package/template/stories/decorators.stories.tsx +28 -0
- package/template/stories/docgen-components/10017-ts-union/argTypes.snapshot +36 -0
- package/template/stories/docgen-components/10017-ts-union/docgen.snapshot +34 -0
- package/template/stories/docgen-components/10017-ts-union/input.tsx +12 -0
- package/template/stories/docgen-components/10017-ts-union/properties.snapshot +32 -0
- package/template/stories/docgen-components/10278-ts-multiple-components/argTypes.snapshot +26 -0
- package/template/stories/docgen-components/10278-ts-multiple-components/docgen.snapshot +49 -0
- package/template/stories/docgen-components/10278-ts-multiple-components/input.tsx +27 -0
- package/template/stories/docgen-components/10278-ts-multiple-components/properties.snapshot +22 -0
- package/template/stories/docgen-components/8140-js-prop-types-oneof/argTypes.snapshot +127 -0
- package/template/stories/docgen-components/8140-js-prop-types-oneof/docgen.snapshot +97 -0
- package/template/stories/docgen-components/8140-js-prop-types-oneof/input.jsx +27 -0
- package/template/stories/docgen-components/8140-js-prop-types-oneof/properties.snapshot +89 -0
- package/template/stories/docgen-components/8143-ts-imported-types/argTypes.snapshot +27 -0
- package/template/stories/docgen-components/8143-ts-imported-types/docgen.snapshot +22 -0
- package/template/stories/docgen-components/8143-ts-imported-types/input.tsx +10 -0
- package/template/stories/docgen-components/8143-ts-imported-types/properties.snapshot +23 -0
- package/template/stories/docgen-components/8143-ts-imported-types/types.ts +3 -0
- package/template/stories/docgen-components/8143-ts-react-fc-generics/argTypes.snapshot +27 -0
- package/template/stories/docgen-components/8143-ts-react-fc-generics/docgen.snapshot +24 -0
- package/template/stories/docgen-components/8143-ts-react-fc-generics/input.tsx +10 -0
- package/template/stories/docgen-components/8143-ts-react-fc-generics/properties.snapshot +21 -0
- package/template/stories/docgen-components/8428-js-static-prop-types/argTypes.snapshot +25 -0
- package/template/stories/docgen-components/8428-js-static-prop-types/docgen.snapshot +37 -0
- package/template/stories/docgen-components/8428-js-static-prop-types/input.jsx +20 -0
- package/template/stories/docgen-components/8428-js-static-prop-types/properties.snapshot +21 -0
- package/template/stories/docgen-components/8740-ts-multi-props/argTypes.snapshot +27 -0
- package/template/stories/docgen-components/8740-ts-multi-props/docgen.snapshot +49 -0
- package/template/stories/docgen-components/8740-ts-multi-props/input.tsx +23 -0
- package/template/stories/docgen-components/8740-ts-multi-props/properties.snapshot +21 -0
- package/template/stories/docgen-components/8894-9511-ts-forward-ref/argTypes.snapshot +48 -0
- package/template/stories/docgen-components/8894-9511-ts-forward-ref/docgen.snapshot +39 -0
- package/template/stories/docgen-components/8894-9511-ts-forward-ref/input.tsx +31 -0
- package/template/stories/docgen-components/8894-9511-ts-forward-ref/properties.snapshot +34 -0
- package/template/stories/docgen-components/9023-js-hoc/argTypes.snapshot +89 -0
- package/template/stories/docgen-components/9023-js-hoc/docgen.snapshot +84 -0
- package/template/stories/docgen-components/9023-js-hoc/input.jsx +40 -0
- package/template/stories/docgen-components/9023-js-hoc/properties.snapshot +67 -0
- package/template/stories/docgen-components/9399-js-proptypes-shape/argTypes.snapshot +39 -0
- package/template/stories/docgen-components/9399-js-proptypes-shape/docgen.snapshot +48 -0
- package/template/stories/docgen-components/9399-js-proptypes-shape/input.jsx +16 -0
- package/template/stories/docgen-components/9399-js-proptypes-shape/properties.snapshot +35 -0
- package/template/stories/docgen-components/9465-ts-type-props/argTypes.snapshot +28 -0
- package/template/stories/docgen-components/9465-ts-type-props/docgen.snapshot +33 -0
- package/template/stories/docgen-components/9465-ts-type-props/input.tsx +12 -0
- package/template/stories/docgen-components/9465-ts-type-props/properties.snapshot +24 -0
- package/template/stories/docgen-components/9493-ts-display-name/argTypes.snapshot +62 -0
- package/template/stories/docgen-components/9493-ts-display-name/docgen.snapshot +50 -0
- package/template/stories/docgen-components/9493-ts-display-name/input.tsx +30 -0
- package/template/stories/docgen-components/9493-ts-display-name/properties.snapshot +52 -0
- package/template/stories/docgen-components/9556-ts-react-default-exports/argTypes.snapshot +28 -0
- package/template/stories/docgen-components/9556-ts-react-default-exports/docgen.snapshot +32 -0
- package/template/stories/docgen-components/9556-ts-react-default-exports/input.tsx +12 -0
- package/template/stories/docgen-components/9556-ts-react-default-exports/properties.snapshot +24 -0
- package/template/stories/docgen-components/9575-ts-camel-case/argTypes.snapshot +28 -0
- package/template/stories/docgen-components/9575-ts-camel-case/docgen.snapshot +38 -0
- package/template/stories/docgen-components/9575-ts-camel-case/input.tsx +26 -0
- package/template/stories/docgen-components/9575-ts-camel-case/properties.snapshot +24 -0
- package/template/stories/docgen-components/9586-js-react-memo/argTypes.snapshot +41 -0
- package/template/stories/docgen-components/9586-js-react-memo/docgen.snapshot +42 -0
- package/template/stories/docgen-components/9586-js-react-memo/input.jsx +15 -0
- package/template/stories/docgen-components/9586-js-react-memo/properties.snapshot +34 -0
- package/template/stories/docgen-components/9591-ts-import-types/Bar.tsx +3 -0
- package/template/stories/docgen-components/9591-ts-import-types/argTypes.snapshot +25 -0
- package/template/stories/docgen-components/9591-ts-import-types/docgen.snapshot +21 -0
- package/template/stories/docgen-components/9591-ts-import-types/input.tsx +10 -0
- package/template/stories/docgen-components/9591-ts-import-types/properties.snapshot +21 -0
- package/template/stories/docgen-components/9626-js-default-values/argTypes.snapshot +27 -0
- package/template/stories/docgen-components/9626-js-default-values/docgen.snapshot +25 -0
- package/template/stories/docgen-components/9626-js-default-values/input.jsx +5 -0
- package/template/stories/docgen-components/9626-js-default-values/properties.snapshot +21 -0
- package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/argTypes.snapshot +42 -0
- package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/docgen.snapshot +36 -0
- package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/input.jsx +13 -0
- package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/properties.snapshot +35 -0
- package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/argTypes.snapshot +53 -0
- package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/docgen.snapshot +45 -0
- package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/input.tsx +18 -0
- package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/properties.snapshot +43 -0
- package/template/stories/docgen-components/9764-ts-extend-props/argTypes.snapshot +72 -0
- package/template/stories/docgen-components/9764-ts-extend-props/docgen.snapshot +41 -0
- package/template/stories/docgen-components/9764-ts-extend-props/input.tsx +17 -0
- package/template/stories/docgen-components/9764-ts-extend-props/properties.snapshot +56 -0
- package/template/stories/docgen-components/9827-ts-default-values/argTypes.snapshot +72 -0
- package/template/stories/docgen-components/9827-ts-default-values/docgen.snapshot +52 -0
- package/template/stories/docgen-components/9827-ts-default-values/input.tsx +17 -0
- package/template/stories/docgen-components/9827-ts-default-values/properties.snapshot +56 -0
- package/template/stories/docgen-components/9832-ts-enum-export/argTypes.snapshot +3 -0
- package/template/stories/docgen-components/9832-ts-enum-export/docgen.snapshot +16 -0
- package/template/stories/docgen-components/9832-ts-enum-export/input.tsx +8 -0
- package/template/stories/docgen-components/9832-ts-enum-export/properties.snapshot +7 -0
- package/template/stories/docgen-components/9922-ts-component-props/argTypes.snapshot +25 -0
- package/template/stories/docgen-components/9922-ts-component-props/docgen.snapshot +35 -0
- package/template/stories/docgen-components/9922-ts-component-props/input.tsx +24 -0
- package/template/stories/docgen-components/9922-ts-component-props/properties.snapshot +21 -0
- package/template/stories/docgen-components/imported.js +1 -0
- package/template/stories/docgen-components/js-class-component/argTypes.snapshot +386 -0
- package/template/stories/docgen-components/js-class-component/docgen.snapshot +252 -0
- package/template/stories/docgen-components/js-class-component/input.jsx +57 -0
- package/template/stories/docgen-components/js-class-component/properties.snapshot +286 -0
- package/template/stories/docgen-components/js-function-component/argTypes.snapshot +386 -0
- package/template/stories/docgen-components/js-function-component/docgen.snapshot +236 -0
- package/template/stories/docgen-components/js-function-component/input.jsx +50 -0
- package/template/stories/docgen-components/js-function-component/properties.snapshot +286 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults/argTypes.snapshot +386 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults/docgen.snapshot +247 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults/input.jsx +65 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults/properties.snapshot +286 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/argTypes.snapshot +237 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/docgen.snapshot +124 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/input.jsx +41 -0
- package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/properties.snapshot +151 -0
- package/template/stories/docgen-components/js-proptypes/docgen.snapshot +1770 -0
- package/template/stories/docgen-components/js-proptypes/ext.js +13 -0
- package/template/stories/docgen-components/js-proptypes/input.jsx +497 -0
- package/template/stories/docgen-components/jsdoc/argTypes.snapshot +969 -0
- package/template/stories/docgen-components/jsdoc/docgen.snapshot +548 -0
- package/template/stories/docgen-components/jsdoc/input.jsx +231 -0
- package/template/stories/docgen-components/jsdoc/properties.snapshot +857 -0
- package/template/stories/docgen-components/ts-function-component/argTypes.snapshot +396 -0
- package/template/stories/docgen-components/ts-function-component/docgen.snapshot +241 -0
- package/template/stories/docgen-components/ts-function-component/input.tsx +52 -0
- package/template/stories/docgen-components/ts-function-component/properties.snapshot +296 -0
- package/template/stories/docgen-components/ts-function-component-inline-defaults/argTypes.snapshot +279 -0
- package/template/stories/docgen-components/ts-function-component-inline-defaults/docgen.snapshot +151 -0
- package/template/stories/docgen-components/ts-function-component-inline-defaults/input.tsx +80 -0
- package/template/stories/docgen-components/ts-function-component-inline-defaults/properties.snapshot +177 -0
- package/template/stories/docgen-components/ts-html/argTypes.snapshot +3 -0
- package/template/stories/docgen-components/ts-html/docgen.snapshot +12 -0
- package/template/stories/docgen-components/ts-html/input.tsx +12 -0
- package/template/stories/docgen-components/ts-html/properties.snapshot +7 -0
- package/template/stories/docgen-components/ts-jsdoc/argTypes.snapshot +3 -0
- package/template/stories/docgen-components/ts-jsdoc/docgen.snapshot +21 -0
- package/template/stories/docgen-components/ts-jsdoc/input.tsx +27 -0
- package/template/stories/docgen-components/ts-jsdoc/properties.snapshot +7 -0
- package/template/stories/docgen-components/ts-types/argTypes.snapshot +656 -0
- package/template/stories/docgen-components/ts-types/docgen.snapshot +317 -0
- package/template/stories/docgen-components/ts-types/input.tsx +130 -0
- package/template/stories/docgen-components/ts-types/properties.snapshot +410 -0
- package/template/stories/errors.stories.tsx +37 -0
- package/template/stories/hooks.stories.tsx +17 -0
- package/template/stories/js-argtypes.stories.jsx +91 -0
- package/template/stories/react-mdx.stories.mdx +26 -0
- package/template/stories/ts-argtypes.stories.tsx +81 -0
- package/LICENSE +0 -21
- package/dist/cjs/config.js +0 -43
- package/dist/cjs/docs/config.js +0 -25
- package/dist/cjs/docs/extractArgTypes.js +0 -47
- package/dist/cjs/docs/extractProps.js +0 -57
- package/dist/cjs/docs/jsxDecorator.js +0 -210
- package/dist/cjs/docs/lib/captions.js +0 -18
- package/dist/cjs/docs/lib/componentTypes.js +0 -14
- package/dist/cjs/docs/lib/defaultValues/createDefaultValue.js +0 -86
- package/dist/cjs/docs/lib/defaultValues/createFromRawDefaultProp.js +0 -206
- package/dist/cjs/docs/lib/defaultValues/generateArray.js +0 -31
- package/dist/cjs/docs/lib/defaultValues/generateObject.js +0 -31
- package/dist/cjs/docs/lib/defaultValues/index.js +0 -31
- package/dist/cjs/docs/lib/defaultValues/prettyIdentifier.js +0 -38
- package/dist/cjs/docs/lib/generateCode.js +0 -74
- package/dist/cjs/docs/lib/index.js +0 -57
- package/dist/cjs/docs/lib/inspection/acornParser.js +0 -230
- package/dist/cjs/docs/lib/inspection/index.js +0 -31
- package/dist/cjs/docs/lib/inspection/inspectValue.js +0 -24
- package/dist/cjs/docs/lib/inspection/types.js +0 -19
- package/dist/cjs/docs/lib/isHtmlTag.js +0 -14
- package/dist/cjs/docs/propTypes/createType.js +0 -458
- package/dist/cjs/docs/propTypes/generateFuncSignature.js +0 -68
- package/dist/cjs/docs/propTypes/handleProp.js +0 -52
- package/dist/cjs/docs/propTypes/rawDefaultPropResolvers.js +0 -43
- package/dist/cjs/docs/propTypes/sortProps.js +0 -21
- package/dist/cjs/docs/react-argtypes.stories.js +0 -67
- package/dist/cjs/docs/typeScript/handleProp.js +0 -38
- package/dist/cjs/index.js +0 -98
- package/dist/cjs/preview/config.js +0 -19
- package/dist/cjs/preview/globals.js +0 -13
- package/dist/cjs/preview/index.js +0 -44
- package/dist/cjs/preview/render.js +0 -166
- package/dist/cjs/preview/types-6-0.js +0 -5
- package/dist/cjs/preview/types-6-3.js +0 -18
- package/dist/cjs/preview/types-7-0.js +0 -5
- package/dist/cjs/preview/types.js +0 -5
- package/dist/cjs/testing/index.js +0 -113
- package/dist/esm/config.js +0 -6
- package/dist/esm/docs/config.js +0 -12
- package/dist/esm/docs/extractArgTypes.js +0 -37
- package/dist/esm/docs/extractProps.js +0 -42
- package/dist/esm/docs/jsxDecorator.js +0 -170
- package/dist/esm/docs/lib/captions.js +0 -6
- package/dist/esm/docs/lib/componentTypes.js +0 -2
- package/dist/esm/docs/lib/defaultValues/createDefaultValue.js +0 -72
- package/dist/esm/docs/lib/defaultValues/createFromRawDefaultProp.js +0 -183
- package/dist/esm/docs/lib/defaultValues/generateArray.js +0 -21
- package/dist/esm/docs/lib/defaultValues/generateObject.js +0 -21
- package/dist/esm/docs/lib/defaultValues/index.js +0 -2
- package/dist/esm/docs/lib/defaultValues/prettyIdentifier.js +0 -26
- package/dist/esm/docs/lib/generateCode.js +0 -59
- package/dist/esm/docs/lib/index.js +0 -4
- package/dist/esm/docs/lib/inspection/acornParser.js +0 -211
- package/dist/esm/docs/lib/inspection/index.js +0 -2
- package/dist/esm/docs/lib/inspection/inspectValue.js +0 -15
- package/dist/esm/docs/lib/inspection/types.js +0 -12
- package/dist/esm/docs/lib/isHtmlTag.js +0 -4
- package/dist/esm/docs/propTypes/createType.js +0 -447
- package/dist/esm/docs/propTypes/generateFuncSignature.js +0 -57
- package/dist/esm/docs/propTypes/handleProp.js +0 -39
- package/dist/esm/docs/propTypes/rawDefaultPropResolvers.js +0 -31
- package/dist/esm/docs/propTypes/sortProps.js +0 -14
- package/dist/esm/docs/react-argtypes.stories.js +0 -54
- package/dist/esm/docs/typeScript/handleProp.js +0 -28
- package/dist/esm/index.js +0 -5
- package/dist/esm/preview/config.js +0 -1
- package/dist/esm/preview/globals.js +0 -8
- package/dist/esm/preview/index.js +0 -21
- package/dist/esm/preview/render.js +0 -142
- package/dist/esm/preview/types-6-0.js +0 -1
- package/dist/esm/preview/types-6-3.js +0 -10
- package/dist/esm/preview/types-7-0.js +0 -1
- package/dist/esm/preview/types.js +0 -1
- package/dist/esm/testing/index.js +0 -97
- package/dist/types/config.d.ts +0 -10
- package/dist/types/docs/config.d.ts +0 -10
- package/dist/types/docs/extractArgTypes.d.ts +0 -2
- package/dist/types/docs/extractProps.d.ts +0 -9
- package/dist/types/docs/jsxDecorator.d.ts +0 -23
- package/dist/types/docs/lib/captions.d.ts +0 -6
- package/dist/types/docs/lib/componentTypes.d.ts +0 -2
- package/dist/types/docs/lib/defaultValues/createDefaultValue.d.ts +0 -2
- package/dist/types/docs/lib/defaultValues/createFromRawDefaultProp.d.ts +0 -11
- package/dist/types/docs/lib/defaultValues/generateArray.d.ts +0 -3
- package/dist/types/docs/lib/defaultValues/generateObject.d.ts +0 -3
- package/dist/types/docs/lib/defaultValues/index.d.ts +0 -2
- package/dist/types/docs/lib/defaultValues/prettyIdentifier.d.ts +0 -4
- package/dist/types/docs/lib/generateCode.d.ts +0 -3
- package/dist/types/docs/lib/index.d.ts +0 -4
- package/dist/types/docs/lib/inspection/acornParser.d.ts +0 -7
- package/dist/types/docs/lib/inspection/index.d.ts +0 -2
- package/dist/types/docs/lib/inspection/inspectValue.d.ts +0 -2
- package/dist/types/docs/lib/inspection/types.d.ts +0 -50
- package/dist/types/docs/lib/isHtmlTag.d.ts +0 -1
- package/dist/types/docs/propTypes/createType.d.ts +0 -2
- package/dist/types/docs/propTypes/generateFuncSignature.d.ts +0 -4
- package/dist/types/docs/propTypes/handleProp.d.ts +0 -5
- package/dist/types/docs/propTypes/rawDefaultPropResolvers.d.ts +0 -1
- package/dist/types/docs/propTypes/sortProps.d.ts +0 -4
- package/dist/types/docs/react-argtypes.stories.d.ts +0 -1
- package/dist/types/docs/typeScript/handleProp.d.ts +0 -3
- package/dist/types/index.d.ts +0 -4
- package/dist/types/preview/config.d.ts +0 -1
- package/dist/types/preview/globals.d.ts +0 -1
- package/dist/types/preview/index.d.ts +0 -25
- package/dist/types/preview/render.d.ts +0 -5
- package/dist/types/preview/types-6-0.d.ts +0 -35
- package/dist/types/preview/types-6-3.d.ts +0 -40
- package/dist/types/preview/types-7-0.d.ts +0 -21
- package/dist/types/preview/types.d.ts +0 -16
- package/dist/types/testing/index.d.ts +0 -84
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _types = require("./types");
|
|
8
|
-
|
|
9
|
-
Object.keys(_types).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _types[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _inspectValue = require("./inspectValue");
|
|
21
|
-
|
|
22
|
-
Object.keys(_inspectValue).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _inspectValue[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _inspectValue[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.inspectValue = inspectValue;
|
|
7
|
-
|
|
8
|
-
var _acornParser = require("./acornParser");
|
|
9
|
-
|
|
10
|
-
var _types = require("./types");
|
|
11
|
-
|
|
12
|
-
function inspectValue(value) {
|
|
13
|
-
try {
|
|
14
|
-
const parsingResult = (0, _acornParser.parse)(value);
|
|
15
|
-
return Object.assign({}, parsingResult);
|
|
16
|
-
} catch (e) {// do nothing.
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
inferredType: {
|
|
21
|
-
type: _types.InspectionType.UNKNOWN
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.InspectionType = void 0;
|
|
7
|
-
let InspectionType;
|
|
8
|
-
exports.InspectionType = InspectionType;
|
|
9
|
-
|
|
10
|
-
(function (InspectionType) {
|
|
11
|
-
InspectionType["IDENTIFIER"] = "Identifier";
|
|
12
|
-
InspectionType["LITERAL"] = "Literal";
|
|
13
|
-
InspectionType["OBJECT"] = "Object";
|
|
14
|
-
InspectionType["ARRAY"] = "Array";
|
|
15
|
-
InspectionType["FUNCTION"] = "Function";
|
|
16
|
-
InspectionType["CLASS"] = "Class";
|
|
17
|
-
InspectionType["ELEMENT"] = "Element";
|
|
18
|
-
InspectionType["UNKNOWN"] = "Unknown";
|
|
19
|
-
})(InspectionType || (exports.InspectionType = InspectionType = {}));
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isHtmlTag = isHtmlTag;
|
|
7
|
-
|
|
8
|
-
var _htmlTags = _interopRequireDefault(require("html-tags"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
function isHtmlTag(tagName) {
|
|
13
|
-
return _htmlTags.default.includes(tagName.toLowerCase());
|
|
14
|
-
}
|
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createType = createType;
|
|
7
|
-
|
|
8
|
-
var _docsTools = require("@storybook/docs-tools");
|
|
9
|
-
|
|
10
|
-
var _generateFuncSignature = require("./generateFuncSignature");
|
|
11
|
-
|
|
12
|
-
var _lib = require("../lib");
|
|
13
|
-
|
|
14
|
-
var _inspection = require("../lib/inspection");
|
|
15
|
-
|
|
16
|
-
const MAX_FUNC_LENGTH = 150;
|
|
17
|
-
var PropTypesType;
|
|
18
|
-
|
|
19
|
-
(function (PropTypesType) {
|
|
20
|
-
PropTypesType["CUSTOM"] = "custom";
|
|
21
|
-
PropTypesType["ANY"] = "any";
|
|
22
|
-
PropTypesType["FUNC"] = "func";
|
|
23
|
-
PropTypesType["SHAPE"] = "shape";
|
|
24
|
-
PropTypesType["OBJECT"] = "object";
|
|
25
|
-
PropTypesType["INSTANCEOF"] = "instanceOf";
|
|
26
|
-
PropTypesType["OBJECTOF"] = "objectOf";
|
|
27
|
-
PropTypesType["UNION"] = "union";
|
|
28
|
-
PropTypesType["ENUM"] = "enum";
|
|
29
|
-
PropTypesType["ARRAYOF"] = "arrayOf";
|
|
30
|
-
PropTypesType["ELEMENT"] = "element";
|
|
31
|
-
PropTypesType["ELEMENTTYPE"] = "elementType";
|
|
32
|
-
PropTypesType["NODE"] = "node";
|
|
33
|
-
})(PropTypesType || (PropTypesType = {}));
|
|
34
|
-
|
|
35
|
-
function createTypeDef({
|
|
36
|
-
name,
|
|
37
|
-
short,
|
|
38
|
-
compact,
|
|
39
|
-
full,
|
|
40
|
-
inferredType
|
|
41
|
-
}) {
|
|
42
|
-
return {
|
|
43
|
-
name,
|
|
44
|
-
short,
|
|
45
|
-
compact,
|
|
46
|
-
full: full != null ? full : short,
|
|
47
|
-
inferredType
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function cleanPropTypes(value) {
|
|
52
|
-
return value.replace(/PropTypes./g, '').replace(/.isRequired/g, '');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function splitIntoLines(value) {
|
|
56
|
-
return value.split(/\r?\n/);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function prettyObject(ast, compact = false) {
|
|
60
|
-
return cleanPropTypes((0, _lib.generateObjectCode)(ast, compact));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function prettyArray(ast, compact = false) {
|
|
64
|
-
return cleanPropTypes((0, _lib.generateCode)(ast, compact));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function getCaptionForInspectionType(type) {
|
|
68
|
-
switch (type) {
|
|
69
|
-
case _inspection.InspectionType.OBJECT:
|
|
70
|
-
return _lib.OBJECT_CAPTION;
|
|
71
|
-
|
|
72
|
-
case _inspection.InspectionType.ARRAY:
|
|
73
|
-
return _lib.ARRAY_CAPTION;
|
|
74
|
-
|
|
75
|
-
case _inspection.InspectionType.CLASS:
|
|
76
|
-
return _lib.CLASS_CAPTION;
|
|
77
|
-
|
|
78
|
-
case _inspection.InspectionType.FUNCTION:
|
|
79
|
-
return _lib.FUNCTION_CAPTION;
|
|
80
|
-
|
|
81
|
-
case _inspection.InspectionType.ELEMENT:
|
|
82
|
-
return _lib.ELEMENT_CAPTION;
|
|
83
|
-
|
|
84
|
-
default:
|
|
85
|
-
return _lib.CUSTOM_CAPTION;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function generateTypeFromString(value, originalTypeName) {
|
|
90
|
-
const {
|
|
91
|
-
inferredType,
|
|
92
|
-
ast
|
|
93
|
-
} = (0, _inspection.inspectValue)(value);
|
|
94
|
-
const {
|
|
95
|
-
type
|
|
96
|
-
} = inferredType;
|
|
97
|
-
let short;
|
|
98
|
-
let compact;
|
|
99
|
-
let full;
|
|
100
|
-
|
|
101
|
-
switch (type) {
|
|
102
|
-
case _inspection.InspectionType.IDENTIFIER:
|
|
103
|
-
case _inspection.InspectionType.LITERAL:
|
|
104
|
-
short = value;
|
|
105
|
-
compact = value;
|
|
106
|
-
break;
|
|
107
|
-
|
|
108
|
-
case _inspection.InspectionType.OBJECT:
|
|
109
|
-
{
|
|
110
|
-
const {
|
|
111
|
-
depth
|
|
112
|
-
} = inferredType;
|
|
113
|
-
short = _lib.OBJECT_CAPTION;
|
|
114
|
-
compact = depth === 1 ? prettyObject(ast, true) : null;
|
|
115
|
-
full = prettyObject(ast);
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
case _inspection.InspectionType.ELEMENT:
|
|
120
|
-
{
|
|
121
|
-
const {
|
|
122
|
-
identifier
|
|
123
|
-
} = inferredType;
|
|
124
|
-
short = identifier != null && !(0, _lib.isHtmlTag)(identifier) ? identifier : _lib.ELEMENT_CAPTION;
|
|
125
|
-
compact = splitIntoLines(value).length === 1 ? value : null;
|
|
126
|
-
full = value;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
case _inspection.InspectionType.ARRAY:
|
|
131
|
-
{
|
|
132
|
-
const {
|
|
133
|
-
depth
|
|
134
|
-
} = inferredType;
|
|
135
|
-
short = _lib.ARRAY_CAPTION;
|
|
136
|
-
compact = depth <= 2 ? prettyArray(ast, true) : null;
|
|
137
|
-
full = prettyArray(ast);
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
default:
|
|
142
|
-
short = getCaptionForInspectionType(type);
|
|
143
|
-
compact = splitIntoLines(value).length === 1 ? value : null;
|
|
144
|
-
full = value;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return createTypeDef({
|
|
149
|
-
name: originalTypeName,
|
|
150
|
-
short,
|
|
151
|
-
compact,
|
|
152
|
-
full,
|
|
153
|
-
inferredType: type
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function generateCustom({
|
|
158
|
-
raw
|
|
159
|
-
}) {
|
|
160
|
-
if (raw != null) {
|
|
161
|
-
return generateTypeFromString(raw, PropTypesType.CUSTOM);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return createTypeDef({
|
|
165
|
-
name: PropTypesType.CUSTOM,
|
|
166
|
-
short: _lib.CUSTOM_CAPTION,
|
|
167
|
-
compact: _lib.CUSTOM_CAPTION
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function generateFunc(extractedProp) {
|
|
172
|
-
const {
|
|
173
|
-
jsDocTags
|
|
174
|
-
} = extractedProp;
|
|
175
|
-
|
|
176
|
-
if (jsDocTags != null) {
|
|
177
|
-
if (jsDocTags.params != null || jsDocTags.returns != null) {
|
|
178
|
-
return createTypeDef({
|
|
179
|
-
name: PropTypesType.FUNC,
|
|
180
|
-
// @ts-ignore
|
|
181
|
-
short: (0, _generateFuncSignature.generateShortFuncSignature)(jsDocTags.params, jsDocTags.returns),
|
|
182
|
-
compact: null,
|
|
183
|
-
// @ts-ignore
|
|
184
|
-
full: (0, _generateFuncSignature.generateFuncSignature)(jsDocTags.params, jsDocTags.returns)
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return createTypeDef({
|
|
190
|
-
name: PropTypesType.FUNC,
|
|
191
|
-
short: _lib.FUNCTION_CAPTION,
|
|
192
|
-
compact: _lib.FUNCTION_CAPTION
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function generateShape(type, extractedProp) {
|
|
197
|
-
const fields = Object.keys(type.value).map(key => `${key}: ${generateType(type.value[key], extractedProp).full}`).join(', ');
|
|
198
|
-
const {
|
|
199
|
-
inferredType,
|
|
200
|
-
ast
|
|
201
|
-
} = (0, _inspection.inspectValue)(`{ ${fields} }`);
|
|
202
|
-
const {
|
|
203
|
-
depth
|
|
204
|
-
} = inferredType;
|
|
205
|
-
return createTypeDef({
|
|
206
|
-
name: PropTypesType.SHAPE,
|
|
207
|
-
short: _lib.OBJECT_CAPTION,
|
|
208
|
-
compact: depth === 1 && ast ? prettyObject(ast, true) : null,
|
|
209
|
-
full: ast ? prettyObject(ast) : null
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function objectOf(of) {
|
|
214
|
-
return `objectOf(${of})`;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function generateObjectOf(type, extractedProp) {
|
|
218
|
-
const {
|
|
219
|
-
short,
|
|
220
|
-
compact,
|
|
221
|
-
full
|
|
222
|
-
} = generateType(type.value, extractedProp);
|
|
223
|
-
return createTypeDef({
|
|
224
|
-
name: PropTypesType.OBJECTOF,
|
|
225
|
-
short: objectOf(short),
|
|
226
|
-
compact: compact != null ? objectOf(compact) : null,
|
|
227
|
-
full: full ? objectOf(full) : full
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function generateUnion(type, extractedProp) {
|
|
232
|
-
if (Array.isArray(type.value)) {
|
|
233
|
-
const values = type.value.reduce((acc, v) => {
|
|
234
|
-
const {
|
|
235
|
-
short,
|
|
236
|
-
compact,
|
|
237
|
-
full
|
|
238
|
-
} = generateType(v, extractedProp);
|
|
239
|
-
acc.short.push(short);
|
|
240
|
-
acc.compact.push(compact);
|
|
241
|
-
acc.full.push(full);
|
|
242
|
-
return acc;
|
|
243
|
-
}, {
|
|
244
|
-
short: [],
|
|
245
|
-
compact: [],
|
|
246
|
-
full: []
|
|
247
|
-
});
|
|
248
|
-
return createTypeDef({
|
|
249
|
-
name: PropTypesType.UNION,
|
|
250
|
-
short: values.short.join(' | '),
|
|
251
|
-
compact: values.compact.every(x => x != null) ? values.compact.join(' | ') : null,
|
|
252
|
-
full: values.full.join(' | ')
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return createTypeDef({
|
|
257
|
-
name: PropTypesType.UNION,
|
|
258
|
-
short: type.value,
|
|
259
|
-
compact: null
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function generateEnumValue({
|
|
264
|
-
value,
|
|
265
|
-
computed
|
|
266
|
-
}) {
|
|
267
|
-
return computed ? generateTypeFromString(value, 'enumvalue') : createTypeDef({
|
|
268
|
-
name: 'enumvalue',
|
|
269
|
-
short: value,
|
|
270
|
-
compact: value
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function generateEnum(type) {
|
|
275
|
-
if (Array.isArray(type.value)) {
|
|
276
|
-
const values = type.value.reduce((acc, v) => {
|
|
277
|
-
const {
|
|
278
|
-
short,
|
|
279
|
-
compact,
|
|
280
|
-
full
|
|
281
|
-
} = generateEnumValue(v);
|
|
282
|
-
acc.short.push(short);
|
|
283
|
-
acc.compact.push(compact);
|
|
284
|
-
acc.full.push(full);
|
|
285
|
-
return acc;
|
|
286
|
-
}, {
|
|
287
|
-
short: [],
|
|
288
|
-
compact: [],
|
|
289
|
-
full: []
|
|
290
|
-
});
|
|
291
|
-
return createTypeDef({
|
|
292
|
-
name: PropTypesType.ENUM,
|
|
293
|
-
short: values.short.join(' | '),
|
|
294
|
-
compact: values.compact.every(x => x != null) ? values.compact.join(' | ') : null,
|
|
295
|
-
full: values.full.join(' | ')
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return createTypeDef({
|
|
300
|
-
name: PropTypesType.ENUM,
|
|
301
|
-
short: type.value,
|
|
302
|
-
compact: type.value
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function braceAfter(of) {
|
|
307
|
-
return `${of}[]`;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function braceAround(of) {
|
|
311
|
-
return `[${of}]`;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
function createArrayOfObjectTypeDef(short, compact, full) {
|
|
315
|
-
return createTypeDef({
|
|
316
|
-
name: PropTypesType.ARRAYOF,
|
|
317
|
-
short: braceAfter(short),
|
|
318
|
-
compact: compact != null ? braceAround(compact) : null,
|
|
319
|
-
full: full ? braceAround(full) : full
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function generateArray(type, extractedProp) {
|
|
324
|
-
const {
|
|
325
|
-
name,
|
|
326
|
-
short,
|
|
327
|
-
compact,
|
|
328
|
-
full,
|
|
329
|
-
inferredType
|
|
330
|
-
} = generateType(type.value, extractedProp);
|
|
331
|
-
|
|
332
|
-
if (name === PropTypesType.CUSTOM) {
|
|
333
|
-
if (inferredType === _inspection.InspectionType.OBJECT) {
|
|
334
|
-
return createArrayOfObjectTypeDef(short, compact, full);
|
|
335
|
-
}
|
|
336
|
-
} else if (name === PropTypesType.SHAPE) {
|
|
337
|
-
return createArrayOfObjectTypeDef(short, compact, full);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return createTypeDef({
|
|
341
|
-
name: PropTypesType.ARRAYOF,
|
|
342
|
-
short: braceAfter(short),
|
|
343
|
-
compact: braceAfter(short)
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
function generateType(type, extractedProp) {
|
|
348
|
-
try {
|
|
349
|
-
switch (type.name) {
|
|
350
|
-
case PropTypesType.CUSTOM:
|
|
351
|
-
return generateCustom(type);
|
|
352
|
-
|
|
353
|
-
case PropTypesType.FUNC:
|
|
354
|
-
return generateFunc(extractedProp);
|
|
355
|
-
|
|
356
|
-
case PropTypesType.SHAPE:
|
|
357
|
-
return generateShape(type, extractedProp);
|
|
358
|
-
|
|
359
|
-
case PropTypesType.INSTANCEOF:
|
|
360
|
-
return createTypeDef({
|
|
361
|
-
name: PropTypesType.INSTANCEOF,
|
|
362
|
-
short: type.value,
|
|
363
|
-
compact: type.value
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
case PropTypesType.OBJECTOF:
|
|
367
|
-
return generateObjectOf(type, extractedProp);
|
|
368
|
-
|
|
369
|
-
case PropTypesType.UNION:
|
|
370
|
-
return generateUnion(type, extractedProp);
|
|
371
|
-
|
|
372
|
-
case PropTypesType.ENUM:
|
|
373
|
-
return generateEnum(type);
|
|
374
|
-
|
|
375
|
-
case PropTypesType.ARRAYOF:
|
|
376
|
-
return generateArray(type, extractedProp);
|
|
377
|
-
|
|
378
|
-
default:
|
|
379
|
-
return createTypeDef({
|
|
380
|
-
name: type.name,
|
|
381
|
-
short: type.name,
|
|
382
|
-
compact: type.name
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
} catch (e) {
|
|
386
|
-
// eslint-disable-next-line no-console
|
|
387
|
-
console.error(e);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
return createTypeDef({
|
|
391
|
-
name: 'unknown',
|
|
392
|
-
short: 'unknown',
|
|
393
|
-
compact: 'unknown'
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
function createType(extractedProp) {
|
|
398
|
-
const {
|
|
399
|
-
type
|
|
400
|
-
} = extractedProp.docgenInfo; // A type could be null if a defaultProp has been provided without a type definition.
|
|
401
|
-
|
|
402
|
-
if (type == null) {
|
|
403
|
-
return null;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
try {
|
|
407
|
-
switch (type.name) {
|
|
408
|
-
case PropTypesType.CUSTOM:
|
|
409
|
-
case PropTypesType.SHAPE:
|
|
410
|
-
case PropTypesType.INSTANCEOF:
|
|
411
|
-
case PropTypesType.OBJECTOF:
|
|
412
|
-
case PropTypesType.UNION:
|
|
413
|
-
case PropTypesType.ENUM:
|
|
414
|
-
case PropTypesType.ARRAYOF:
|
|
415
|
-
{
|
|
416
|
-
const {
|
|
417
|
-
short,
|
|
418
|
-
compact,
|
|
419
|
-
full
|
|
420
|
-
} = generateType(type, extractedProp);
|
|
421
|
-
|
|
422
|
-
if (compact != null) {
|
|
423
|
-
if (!(0, _docsTools.isTooLongForTypeSummary)(compact)) {
|
|
424
|
-
return (0, _docsTools.createSummaryValue)(compact);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
return full ? (0, _docsTools.createSummaryValue)(short, full) : (0, _docsTools.createSummaryValue)(short);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
case PropTypesType.FUNC:
|
|
432
|
-
{
|
|
433
|
-
const {
|
|
434
|
-
short,
|
|
435
|
-
full
|
|
436
|
-
} = generateType(type, extractedProp);
|
|
437
|
-
let summary = short;
|
|
438
|
-
let detail;
|
|
439
|
-
|
|
440
|
-
if (full && full.length < MAX_FUNC_LENGTH) {
|
|
441
|
-
summary = full;
|
|
442
|
-
} else if (full) {
|
|
443
|
-
detail = (0, _generateFuncSignature.toMultilineSignature)(full);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
return (0, _docsTools.createSummaryValue)(summary, detail);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
default:
|
|
450
|
-
return null;
|
|
451
|
-
}
|
|
452
|
-
} catch (e) {
|
|
453
|
-
// eslint-disable-next-line no-console
|
|
454
|
-
console.error(e);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
return null;
|
|
458
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.generateFuncSignature = generateFuncSignature;
|
|
7
|
-
exports.generateShortFuncSignature = generateShortFuncSignature;
|
|
8
|
-
exports.toMultilineSignature = toMultilineSignature;
|
|
9
|
-
|
|
10
|
-
function generateFuncSignature(params, returns) {
|
|
11
|
-
const hasParams = params != null;
|
|
12
|
-
const hasReturns = returns != null;
|
|
13
|
-
|
|
14
|
-
if (!hasParams && !hasReturns) {
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const funcParts = [];
|
|
19
|
-
|
|
20
|
-
if (hasParams) {
|
|
21
|
-
const funcParams = params.map(x => {
|
|
22
|
-
const prettyName = x.getPrettyName();
|
|
23
|
-
const typeName = x.getTypeName();
|
|
24
|
-
|
|
25
|
-
if (typeName != null) {
|
|
26
|
-
return `${prettyName}: ${typeName}`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return prettyName;
|
|
30
|
-
});
|
|
31
|
-
funcParts.push(`(${funcParams.join(', ')})`);
|
|
32
|
-
} else {
|
|
33
|
-
funcParts.push('()');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (hasReturns) {
|
|
37
|
-
funcParts.push(`=> ${returns.getTypeName()}`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return funcParts.join(' ');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function generateShortFuncSignature(params, returns) {
|
|
44
|
-
const hasParams = params != null;
|
|
45
|
-
const hasReturns = returns != null;
|
|
46
|
-
|
|
47
|
-
if (!hasParams && !hasReturns) {
|
|
48
|
-
return '';
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const funcParts = [];
|
|
52
|
-
|
|
53
|
-
if (hasParams) {
|
|
54
|
-
funcParts.push('( ... )');
|
|
55
|
-
} else {
|
|
56
|
-
funcParts.push('()');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (hasReturns) {
|
|
60
|
-
funcParts.push(`=> ${returns.getTypeName()}`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return funcParts.join(' ');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function toMultilineSignature(signature) {
|
|
67
|
-
return signature.replace(/,/g, ',\r\n');
|
|
68
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.enhancePropTypesProp = enhancePropTypesProp;
|
|
7
|
-
exports.enhancePropTypesProps = enhancePropTypesProps;
|
|
8
|
-
|
|
9
|
-
var _createType = require("./createType");
|
|
10
|
-
|
|
11
|
-
var _defaultValues = require("../lib/defaultValues");
|
|
12
|
-
|
|
13
|
-
var _sortProps = require("./sortProps");
|
|
14
|
-
|
|
15
|
-
var _rawDefaultPropResolvers = require("./rawDefaultPropResolvers");
|
|
16
|
-
|
|
17
|
-
function enhancePropTypesProp(extractedProp, rawDefaultProp) {
|
|
18
|
-
const {
|
|
19
|
-
propDef
|
|
20
|
-
} = extractedProp;
|
|
21
|
-
const newtype = (0, _createType.createType)(extractedProp);
|
|
22
|
-
|
|
23
|
-
if (newtype != null) {
|
|
24
|
-
propDef.type = newtype;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
defaultValue
|
|
29
|
-
} = extractedProp.docgenInfo;
|
|
30
|
-
|
|
31
|
-
if (defaultValue != null && defaultValue.value != null) {
|
|
32
|
-
const newDefaultValue = (0, _defaultValues.createDefaultValue)(defaultValue.value);
|
|
33
|
-
|
|
34
|
-
if (newDefaultValue != null) {
|
|
35
|
-
propDef.defaultValue = newDefaultValue;
|
|
36
|
-
}
|
|
37
|
-
} else if (rawDefaultProp != null) {
|
|
38
|
-
const newDefaultValue = (0, _defaultValues.createDefaultValueFromRawDefaultProp)(rawDefaultProp, propDef, _rawDefaultPropResolvers.rawDefaultPropTypeResolvers);
|
|
39
|
-
|
|
40
|
-
if (newDefaultValue != null) {
|
|
41
|
-
propDef.defaultValue = newDefaultValue;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return propDef;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function enhancePropTypesProps(extractedProps, component) {
|
|
49
|
-
const rawDefaultProps = component.defaultProps != null ? component.defaultProps : {};
|
|
50
|
-
const enhancedProps = extractedProps.map(x => enhancePropTypesProp(x, rawDefaultProps[x.propDef.name]));
|
|
51
|
-
return (0, _sortProps.keepOriginalDefinitionOrder)(enhancedProps, component);
|
|
52
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.rawDefaultPropTypeResolvers = void 0;
|
|
7
|
-
|
|
8
|
-
var _docsTools = require("@storybook/docs-tools");
|
|
9
|
-
|
|
10
|
-
var _defaultValues = require("../lib/defaultValues");
|
|
11
|
-
|
|
12
|
-
var _lib = require("../lib");
|
|
13
|
-
|
|
14
|
-
var _prettyIdentifier = require("../lib/defaultValues/prettyIdentifier");
|
|
15
|
-
|
|
16
|
-
var _inspection = require("../lib/inspection");
|
|
17
|
-
|
|
18
|
-
const funcResolver = (rawDefaultProp, {
|
|
19
|
-
name,
|
|
20
|
-
type
|
|
21
|
-
}) => {
|
|
22
|
-
const isElement = type.summary === 'element' || type.summary === 'elementType';
|
|
23
|
-
const funcName = (0, _defaultValues.extractFunctionName)(rawDefaultProp, name);
|
|
24
|
-
|
|
25
|
-
if (funcName != null) {
|
|
26
|
-
// Try to display the name of the component. The body of the component is omitted since the code has been transpiled.
|
|
27
|
-
if (isElement) {
|
|
28
|
-
return (0, _docsTools.createSummaryValue)((0, _prettyIdentifier.getPrettyElementIdentifier)(funcName));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const {
|
|
32
|
-
hasParams
|
|
33
|
-
} = (0, _inspection.inspectValue)(rawDefaultProp.toString()).inferredType;
|
|
34
|
-
return (0, _docsTools.createSummaryValue)((0, _prettyIdentifier.getPrettyFuncIdentifier)(funcName, hasParams));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return (0, _docsTools.createSummaryValue)(isElement ? _lib.ELEMENT_CAPTION : _lib.FUNCTION_CAPTION);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const rawDefaultPropTypeResolvers = (0, _defaultValues.createTypeResolvers)({
|
|
41
|
-
function: funcResolver
|
|
42
|
-
});
|
|
43
|
-
exports.rawDefaultPropTypeResolvers = rawDefaultPropTypeResolvers;
|