@storybook/react 7.0.0-alpha.7 → 7.0.0-beta.0
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-LSK4KSW4.mjs +1 -0
- package/dist/config.d.ts +11 -13
- package/dist/config.js +3 -7
- package/dist/config.mjs +3 -7
- package/dist/index.d.ts +57 -37
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/types-0a347bb9.d.ts +10 -0
- package/jest.config.js +7 -0
- package/package.json +27 -22
- package/template/cli/.eslintrc.json +5 -0
- package/template/cli/js/Button.jsx +50 -0
- package/template/cli/js/Button.stories.js +39 -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 +44 -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/cli/ts-legacy/Button.stories.ts +45 -0
- package/template/cli/ts-legacy/Button.tsx +48 -0
- package/template/cli/ts-legacy/Header.stories.ts +24 -0
- package/template/cli/ts-legacy/Header.tsx +56 -0
- package/template/cli/ts-legacy/Page.stories.ts +29 -0
- package/template/cli/ts-legacy/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 +39 -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/chunk-DGYCFUMN.mjs +0 -1
- package/dist/types-9f8d440a.d.ts +0 -17
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @ts-expect-error (Converted from ts-ignore)
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
export const PRESET_SHAPE = {
|
|
5
|
+
text: PropTypes.string.isRequired,
|
|
6
|
+
startDate: PropTypes.object.isRequired,
|
|
7
|
+
endDate: PropTypes.object.isRequired,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const SOME_PROP_TYPES = {
|
|
11
|
+
ext1: PropTypes.string,
|
|
12
|
+
ext2: PropTypes.number,
|
|
13
|
+
};
|
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
/* eslint-disable react/no-unused-prop-types */
|
|
2
|
+
/* eslint-disable react/forbid-prop-types */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes, { string, shape } from 'prop-types';
|
|
5
|
+
import { PRESET_SHAPE, SOME_PROP_TYPES } from './ext';
|
|
6
|
+
|
|
7
|
+
const NAMED_OBJECT = {
|
|
8
|
+
text: PropTypes.string.isRequired,
|
|
9
|
+
value: PropTypes.string.isRequired,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const ANOTHER_OBJECT = {
|
|
13
|
+
foo: PropTypes.string,
|
|
14
|
+
bar: PropTypes.string,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const NAMED_SHAPE = PropTypes.shape({
|
|
18
|
+
foo: PropTypes.string,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const POSITIONS = ['top-left', 'top-right', 'top-center'];
|
|
22
|
+
|
|
23
|
+
const FunctionalComponent = () => {
|
|
24
|
+
return <div>FunctionalComponent!</div>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
class ClassComponent extends React.PureComponent {
|
|
28
|
+
render() {
|
|
29
|
+
return <div>ClassComponent!</div>;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function concat(a, b) {
|
|
34
|
+
return a + b;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function customPropType() {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const nestedCustomPropType = {
|
|
42
|
+
custom: customPropType,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const SOME_INLINE_PROP_TYPES = {
|
|
46
|
+
/**
|
|
47
|
+
* Hey Hey!
|
|
48
|
+
*/
|
|
49
|
+
inlineString: PropTypes.string,
|
|
50
|
+
inlineBool: PropTypes.bool,
|
|
51
|
+
inlineNumber: PropTypes.number,
|
|
52
|
+
inlineObj: PropTypes.shape({
|
|
53
|
+
foo: PropTypes.string,
|
|
54
|
+
}),
|
|
55
|
+
inlineArray: PropTypes.arrayOf(PropTypes.number),
|
|
56
|
+
inlineArrayOfObjects: PropTypes.arrayOf({ foo: PropTypes.string }),
|
|
57
|
+
inlineFunctionalElement: PropTypes.element,
|
|
58
|
+
inlineFunctionalElementInline: PropTypes.element,
|
|
59
|
+
inlineFunctionalElementInlineReturningNull: PropTypes.element,
|
|
60
|
+
inlineHtmlElement: PropTypes.element,
|
|
61
|
+
inlineFunctionalElementInlineWithProps: PropTypes.element,
|
|
62
|
+
inlineFunctionalElementNamedInline: PropTypes.element,
|
|
63
|
+
inlineClassElement: PropTypes.element,
|
|
64
|
+
inlineClassElementWithProps: PropTypes.element,
|
|
65
|
+
inlineClassElementWithChildren: PropTypes.element,
|
|
66
|
+
inlineClassElementInline: PropTypes.element,
|
|
67
|
+
inlineFunc: PropTypes.func,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const SOME_INLINE_DEFAULT_PROPS = {
|
|
71
|
+
inlineString: 'Inline prop default value',
|
|
72
|
+
inlineBool: true,
|
|
73
|
+
inlineNumber: 10,
|
|
74
|
+
inlineObj: { foo: 'bar' },
|
|
75
|
+
inlineArray: [1, 2, 3],
|
|
76
|
+
inlineArrayOfObjects: [
|
|
77
|
+
{ foo: 'bar' },
|
|
78
|
+
{ foo: 'bar' },
|
|
79
|
+
{ foo: 'bar' },
|
|
80
|
+
{ foo: 'bar' },
|
|
81
|
+
{ foo: 'bar' },
|
|
82
|
+
],
|
|
83
|
+
inlineFunctionalElement: <FunctionalComponent />,
|
|
84
|
+
inlineFunctionalElementInline: () => {
|
|
85
|
+
return <div>Inlined FunctionalComponent!</div>;
|
|
86
|
+
},
|
|
87
|
+
inlineFunctionalElementInlineReturningNull: () => {
|
|
88
|
+
return null;
|
|
89
|
+
},
|
|
90
|
+
inlineHtmlElement: <div>Hey!</div>,
|
|
91
|
+
inlineFunctionalElementInlineWithProps: ({ foo }) => {
|
|
92
|
+
return <div>{foo}</div>;
|
|
93
|
+
},
|
|
94
|
+
inlineFunctionalElementNamedInline: function InlinedFunctionalComponent() {
|
|
95
|
+
return <div>Inlined FunctionalComponent!</div>;
|
|
96
|
+
},
|
|
97
|
+
inlineClassElement: <ClassComponent />,
|
|
98
|
+
inlineClassElementWithProps: <ClassComponent className="toto" />,
|
|
99
|
+
inlineClassElementWithChildren: (
|
|
100
|
+
<ClassComponent>
|
|
101
|
+
<div>hey!</div>
|
|
102
|
+
</ClassComponent>
|
|
103
|
+
),
|
|
104
|
+
inlineClassElementInline: class InlinedClassComponent extends React.PureComponent {
|
|
105
|
+
render() {
|
|
106
|
+
return <div>Inlined ClassComponent!</div>;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
inlineFunc: function add(a, b) {
|
|
110
|
+
return a + b;
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const PropTypesProps = () => <div>PropTypes!</div>;
|
|
115
|
+
|
|
116
|
+
PropTypesProps.propTypes = {
|
|
117
|
+
any: PropTypes.any,
|
|
118
|
+
bool: PropTypes.bool,
|
|
119
|
+
string: PropTypes.string,
|
|
120
|
+
func: PropTypes.func,
|
|
121
|
+
/**
|
|
122
|
+
* A function with JSDoc tags.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} foo - A foo value.
|
|
125
|
+
* @param {number} bar - A bar value.
|
|
126
|
+
* @returns {ComplexObject} - Returns a complex object.
|
|
127
|
+
*/
|
|
128
|
+
funcWithJsDoc: PropTypes.func,
|
|
129
|
+
/**
|
|
130
|
+
* @param {string} foo - A foo value.
|
|
131
|
+
* @param {number} bar - A bar value.
|
|
132
|
+
* @param {number} bar1 - A bar value.
|
|
133
|
+
* @param {number} bar2 - A bar value.
|
|
134
|
+
* @param {number} bar3 - A bar value.
|
|
135
|
+
* @param {number} bar4 - A bar value.
|
|
136
|
+
* @param {number} bar5 - A bar value.
|
|
137
|
+
* @returns {ComplexObject} - Returns a complex object.
|
|
138
|
+
*/
|
|
139
|
+
semiLongFuncWithJsDoc: PropTypes.func,
|
|
140
|
+
/**
|
|
141
|
+
* @param {string} foo - A foo value.
|
|
142
|
+
* @param {number} bar - A bar value.
|
|
143
|
+
* @param {number} bar1 - A bar value.
|
|
144
|
+
* @param {number} bar2 - A bar value.
|
|
145
|
+
* @param {number} bar3 - A bar value.
|
|
146
|
+
* @param {number} bar4 - A bar value.
|
|
147
|
+
* @param {number} bar5 - A bar value.
|
|
148
|
+
* @param {number} bar6 - A bar value.
|
|
149
|
+
* @param {number} bar7 - A bar value.
|
|
150
|
+
* @param {number} bar8 - A bar value.
|
|
151
|
+
* @param {number} bar9 - A bar value.
|
|
152
|
+
* @param {number} bar10 - A bar value.
|
|
153
|
+
* @returns {ComplexObject} - Returns a complex object.
|
|
154
|
+
*/
|
|
155
|
+
veryLongFuncWithJsDoc: PropTypes.func,
|
|
156
|
+
namedDefaultFunc: PropTypes.func,
|
|
157
|
+
number: PropTypes.number,
|
|
158
|
+
/**
|
|
159
|
+
* Plain object propType (use shape!!)
|
|
160
|
+
*/
|
|
161
|
+
obj: PropTypes.object,
|
|
162
|
+
symbol: PropTypes.symbol,
|
|
163
|
+
node: PropTypes.node,
|
|
164
|
+
useCustomPropType: customPropType,
|
|
165
|
+
useNestedCustomPropType: nestedCustomPropType.custom,
|
|
166
|
+
functionalElement: PropTypes.element,
|
|
167
|
+
functionalElementInline: PropTypes.element,
|
|
168
|
+
functionalElementNamedInline: PropTypes.element,
|
|
169
|
+
classElement: PropTypes.element,
|
|
170
|
+
classElementInline: PropTypes.element,
|
|
171
|
+
functionalElementType: PropTypes.elementType,
|
|
172
|
+
classElementType: PropTypes.elementType,
|
|
173
|
+
elementWithProps: PropTypes.elementType,
|
|
174
|
+
/**
|
|
175
|
+
* `instanceOf` is also supported and the custom type will be shown instead of `instanceOf`
|
|
176
|
+
*/
|
|
177
|
+
instanceOf: PropTypes.instanceOf(Set),
|
|
178
|
+
/**
|
|
179
|
+
* `oneOf` is basically an Enum which is also supported but can be pretty big.
|
|
180
|
+
*/
|
|
181
|
+
oneOfString: PropTypes.oneOf(['News', 'Photos']),
|
|
182
|
+
oneOfNumeric: PropTypes.oneOf([0, 1, 2, 3]),
|
|
183
|
+
oneOfShapes: PropTypes.oneOf([
|
|
184
|
+
PropTypes.shape({ foo: PropTypes.string }),
|
|
185
|
+
PropTypes.shape({ bar: PropTypes.number }),
|
|
186
|
+
]),
|
|
187
|
+
oneOfComplexShapes: PropTypes.oneOf([
|
|
188
|
+
PropTypes.shape({
|
|
189
|
+
/**
|
|
190
|
+
* Just an internal propType for a shape.
|
|
191
|
+
* It's also required, and as you can see it supports multi-line comments!
|
|
192
|
+
*/
|
|
193
|
+
id: PropTypes.number.isRequired,
|
|
194
|
+
/**
|
|
195
|
+
* A simple non-required function
|
|
196
|
+
*/
|
|
197
|
+
func: PropTypes.func,
|
|
198
|
+
/**
|
|
199
|
+
* An `arrayOf` shape
|
|
200
|
+
*/
|
|
201
|
+
arr: PropTypes.arrayOf(
|
|
202
|
+
PropTypes.shape({
|
|
203
|
+
/**
|
|
204
|
+
* 5-level deep propType definition and still works.
|
|
205
|
+
*/
|
|
206
|
+
index: PropTypes.number.isRequired,
|
|
207
|
+
})
|
|
208
|
+
),
|
|
209
|
+
}),
|
|
210
|
+
shape({ bar: PropTypes.number }),
|
|
211
|
+
]),
|
|
212
|
+
oneOfComplexType: PropTypes.oneOf([NAMED_OBJECT, ANOTHER_OBJECT]),
|
|
213
|
+
oneOfComponents: PropTypes.oneOf([FunctionalComponent, ClassComponent]),
|
|
214
|
+
oneOfEval: PropTypes.oneOf((() => ['News', 'Photos'])()),
|
|
215
|
+
oneOfVar: PropTypes.oneOf(POSITIONS),
|
|
216
|
+
oneOfNested: PropTypes.oneOf(['News', ['bottom-left', 'bottom-center', 'bottom-right']]),
|
|
217
|
+
oneOfNestedSimpleInlineObject: PropTypes.oneOf(['News', [{ foo: PropTypes.string }]]),
|
|
218
|
+
oneOfNestedComplexInlineObject: PropTypes.oneOf([
|
|
219
|
+
'News',
|
|
220
|
+
[{ nested: { foo: PropTypes.string } }],
|
|
221
|
+
]),
|
|
222
|
+
oneOfNestedComplexShape: PropTypes.oneOf([
|
|
223
|
+
'News',
|
|
224
|
+
[{ nested: PropTypes.shape({ foo: PropTypes.string }) }],
|
|
225
|
+
]),
|
|
226
|
+
/**
|
|
227
|
+
* A multi-type prop is also valid and is displayed as `Union<String|Message>`
|
|
228
|
+
*/
|
|
229
|
+
oneOfType: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Set)]),
|
|
230
|
+
/**
|
|
231
|
+
* array of a primitive type
|
|
232
|
+
*/
|
|
233
|
+
arrayOfPrimitive: PropTypes.arrayOf(PropTypes.number),
|
|
234
|
+
arrayOfNamedObject: PropTypes.arrayOf(NAMED_OBJECT),
|
|
235
|
+
arrayOfShortInlineObject: PropTypes.arrayOf({
|
|
236
|
+
foo: PropTypes.string,
|
|
237
|
+
}),
|
|
238
|
+
arrayOfInlineObject: PropTypes.arrayOf({
|
|
239
|
+
text: PropTypes.string.isRequired,
|
|
240
|
+
value: PropTypes.string.isRequired,
|
|
241
|
+
}),
|
|
242
|
+
arrayOfComplexInlineObject: PropTypes.arrayOf({
|
|
243
|
+
text: PropTypes.string.isRequired,
|
|
244
|
+
value: PropTypes.string.isRequired,
|
|
245
|
+
shape: {
|
|
246
|
+
id: PropTypes.string.isRequired,
|
|
247
|
+
age: PropTypes.number.isRequired,
|
|
248
|
+
},
|
|
249
|
+
}),
|
|
250
|
+
arrayOfShortShape: PropTypes.arrayOf(
|
|
251
|
+
PropTypes.shape({
|
|
252
|
+
bar: PropTypes.string,
|
|
253
|
+
})
|
|
254
|
+
),
|
|
255
|
+
arrayOfComplexShape: PropTypes.arrayOf(
|
|
256
|
+
PropTypes.shape({
|
|
257
|
+
/**
|
|
258
|
+
* Just an internal propType for a shape.
|
|
259
|
+
* It's also required, and as you can see it supports multi-line comments!
|
|
260
|
+
*/
|
|
261
|
+
id: PropTypes.number.isRequired,
|
|
262
|
+
/**
|
|
263
|
+
* A simple non-required function
|
|
264
|
+
*/
|
|
265
|
+
func: PropTypes.func,
|
|
266
|
+
/**
|
|
267
|
+
* An `arrayOf` shape
|
|
268
|
+
*/
|
|
269
|
+
arr: PropTypes.arrayOf(
|
|
270
|
+
PropTypes.shape({
|
|
271
|
+
/**
|
|
272
|
+
* 5-level deep propType definition and still works.
|
|
273
|
+
*/
|
|
274
|
+
index: PropTypes.number.isRequired,
|
|
275
|
+
})
|
|
276
|
+
),
|
|
277
|
+
})
|
|
278
|
+
),
|
|
279
|
+
arrayExternalShape: PropTypes.arrayOf(PropTypes.shape(PRESET_SHAPE)),
|
|
280
|
+
/**
|
|
281
|
+
* A simple `objectOf` propType.
|
|
282
|
+
*/
|
|
283
|
+
simpleObjectOf: PropTypes.objectOf(PropTypes.number),
|
|
284
|
+
objectOfShortInlineObject: PropTypes.objectOf({
|
|
285
|
+
foo: PropTypes.string,
|
|
286
|
+
}),
|
|
287
|
+
objectOfInlineObject: PropTypes.objectOf({
|
|
288
|
+
foo: PropTypes.string,
|
|
289
|
+
bar: PropTypes.string,
|
|
290
|
+
barry: PropTypes.string,
|
|
291
|
+
}),
|
|
292
|
+
objectOfShortShape: PropTypes.objectOf(
|
|
293
|
+
PropTypes.shape({
|
|
294
|
+
foo: string,
|
|
295
|
+
})
|
|
296
|
+
),
|
|
297
|
+
/**
|
|
298
|
+
* A very complex `objectOf` propType.
|
|
299
|
+
*/
|
|
300
|
+
objectOfComplexShape: PropTypes.objectOf(
|
|
301
|
+
PropTypes.shape({
|
|
302
|
+
/**
|
|
303
|
+
* Just an internal propType for a shape.
|
|
304
|
+
* It's also required, and as you can see it supports multi-line comments!
|
|
305
|
+
*/
|
|
306
|
+
id: PropTypes.number.isRequired,
|
|
307
|
+
/**
|
|
308
|
+
* A simple non-required function
|
|
309
|
+
*/
|
|
310
|
+
func: PropTypes.func,
|
|
311
|
+
/**
|
|
312
|
+
* An `arrayOf` shape
|
|
313
|
+
*/
|
|
314
|
+
arr: PropTypes.arrayOf(
|
|
315
|
+
PropTypes.shape({
|
|
316
|
+
/**
|
|
317
|
+
* 5-level deep propType definition and still works.
|
|
318
|
+
*/
|
|
319
|
+
index: PropTypes.number.isRequired,
|
|
320
|
+
})
|
|
321
|
+
),
|
|
322
|
+
})
|
|
323
|
+
),
|
|
324
|
+
namedObjectOf: PropTypes.objectOf(NAMED_OBJECT),
|
|
325
|
+
shapeShort: PropTypes.shape({
|
|
326
|
+
foo: string,
|
|
327
|
+
}),
|
|
328
|
+
shapeLong: PropTypes.shape({
|
|
329
|
+
foo: string,
|
|
330
|
+
prop1: string,
|
|
331
|
+
prop2: string,
|
|
332
|
+
prop3: string,
|
|
333
|
+
prop4: string,
|
|
334
|
+
prop5: string,
|
|
335
|
+
prop6: string,
|
|
336
|
+
prop7: string,
|
|
337
|
+
}),
|
|
338
|
+
/**
|
|
339
|
+
* propType for shape with nested arrayOf
|
|
340
|
+
*
|
|
341
|
+
* Also, multi-line description
|
|
342
|
+
*/
|
|
343
|
+
shapeComplex: PropTypes.shape({
|
|
344
|
+
/**
|
|
345
|
+
* Just an internal propType for a shape.
|
|
346
|
+
* It's also required, and as you can see it supports multi-line comments!
|
|
347
|
+
*/
|
|
348
|
+
id: PropTypes.number.isRequired,
|
|
349
|
+
/**
|
|
350
|
+
* A simple non-required function
|
|
351
|
+
*/
|
|
352
|
+
func: PropTypes.func,
|
|
353
|
+
/**
|
|
354
|
+
* An `arrayOf` shape
|
|
355
|
+
*/
|
|
356
|
+
arr: PropTypes.arrayOf(
|
|
357
|
+
PropTypes.shape({
|
|
358
|
+
/**
|
|
359
|
+
* 5-level deep propType definition and still works.
|
|
360
|
+
*/
|
|
361
|
+
index: PropTypes.number.isRequired,
|
|
362
|
+
})
|
|
363
|
+
),
|
|
364
|
+
shape: PropTypes.shape({
|
|
365
|
+
shape: PropTypes.shape({
|
|
366
|
+
foo: PropTypes.string,
|
|
367
|
+
oneOf: PropTypes.oneOf(['one', 'two']),
|
|
368
|
+
}),
|
|
369
|
+
}),
|
|
370
|
+
oneOf: PropTypes.oneOf(['one', 'two']),
|
|
371
|
+
}),
|
|
372
|
+
shapeWithArray: PropTypes.shape({
|
|
373
|
+
arr: PropTypes.arrayOf({ foo: PropTypes.string }),
|
|
374
|
+
}),
|
|
375
|
+
namedShape: NAMED_SHAPE,
|
|
376
|
+
namedObjectInShape: PropTypes.shape(NAMED_OBJECT),
|
|
377
|
+
exact: PropTypes.exact({
|
|
378
|
+
name: PropTypes.string,
|
|
379
|
+
quantity: PropTypes.number,
|
|
380
|
+
}),
|
|
381
|
+
namedExact: PropTypes.exact(NAMED_OBJECT),
|
|
382
|
+
/**
|
|
383
|
+
* test string with a comment that has
|
|
384
|
+
* two identical lines
|
|
385
|
+
* two identical lines
|
|
386
|
+
*/
|
|
387
|
+
optionalString: PropTypes.string,
|
|
388
|
+
requiredString: PropTypes.string.isRequired,
|
|
389
|
+
nullDefaultValue: PropTypes.string,
|
|
390
|
+
undefinedDefaultValue: PropTypes.string,
|
|
391
|
+
...SOME_INLINE_PROP_TYPES,
|
|
392
|
+
...SOME_PROP_TYPES,
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
PropTypesProps.defaultProps = {
|
|
396
|
+
any: 'Default any',
|
|
397
|
+
bool: false,
|
|
398
|
+
string: 'Default string',
|
|
399
|
+
func: () => {},
|
|
400
|
+
funcWithJsDoc: (foo, bar) => {
|
|
401
|
+
// eslint-disable-next-line no-undef
|
|
402
|
+
const yo = window.document;
|
|
403
|
+
// eslint-disable-next-line no-undef
|
|
404
|
+
const pouf = souffle;
|
|
405
|
+
|
|
406
|
+
return { foo, bar };
|
|
407
|
+
},
|
|
408
|
+
namedDefaultFunc: concat,
|
|
409
|
+
number: 5,
|
|
410
|
+
obj: {
|
|
411
|
+
key: 'value',
|
|
412
|
+
},
|
|
413
|
+
symbol: Symbol('Default symbol'),
|
|
414
|
+
node: <div>Hello!</div>,
|
|
415
|
+
functionalElement: <FunctionalComponent className="toto" />,
|
|
416
|
+
functionalElementInline: () => {
|
|
417
|
+
return <div>Inlined FunctionalComponent!</div>;
|
|
418
|
+
},
|
|
419
|
+
functionalElementNamedInline: function InlinedFunctionalComponent() {
|
|
420
|
+
return <div>Inlined FunctionalComponent!</div>;
|
|
421
|
+
},
|
|
422
|
+
classElement: <ClassComponent />,
|
|
423
|
+
classElementInline: class InlinedClassComponent extends React.PureComponent {
|
|
424
|
+
render() {
|
|
425
|
+
return <div>Inlined ClassComponent!</div>;
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
functionalElementType: FunctionalComponent,
|
|
429
|
+
classElementType: ClassComponent,
|
|
430
|
+
elementWithProps: <ClassComponent className="w8 h8 fill-marine-500" />,
|
|
431
|
+
instanceOf: new Set(),
|
|
432
|
+
oneOfString: 'News',
|
|
433
|
+
oneOfNumeric: 1,
|
|
434
|
+
oneOfShapes: { foo: 'bar' },
|
|
435
|
+
oneOfComplexShapes: {
|
|
436
|
+
thing: {
|
|
437
|
+
id: 2,
|
|
438
|
+
func: () => {},
|
|
439
|
+
arr: [],
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
oneOfComplexType: { text: 'foo', value: 'bar' },
|
|
443
|
+
oneOfComponents: <FunctionalComponent />,
|
|
444
|
+
oneOfEval: 'Photos',
|
|
445
|
+
oneOfVar: 'top-right',
|
|
446
|
+
oneOfNested: 'top-right',
|
|
447
|
+
oneOfType: 'hello',
|
|
448
|
+
arrayOfPrimitive: [1, 2, 3],
|
|
449
|
+
arrayOfString: ['0px', '0px'],
|
|
450
|
+
arrayOfNamedObject: [{ text: 'foo', value: 'bar' }],
|
|
451
|
+
arrayOfShortInlineObject: [{ foo: 'bar' }],
|
|
452
|
+
arrayOfInlineObject: [{ text: 'foo', value: 'bar' }],
|
|
453
|
+
arrayOfComplexInlineObject: [{ text: 'foo', value: 'bar' }],
|
|
454
|
+
arrayOfShortShape: [{ bar: 'foo' }],
|
|
455
|
+
arrayOfComplexShape: [
|
|
456
|
+
{
|
|
457
|
+
thing: {
|
|
458
|
+
id: 2,
|
|
459
|
+
func: () => {},
|
|
460
|
+
arr: [],
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
simpleObjectOf: { key: 1 },
|
|
465
|
+
objectOfShortInlineObject: { foo: 'bar' },
|
|
466
|
+
objectOfInlineObject: { foo: 'bar', bar: 'foo' },
|
|
467
|
+
objectOfShortShape: { foo: 'bar' },
|
|
468
|
+
objectOfComplexShape: {
|
|
469
|
+
thing: {
|
|
470
|
+
id: 2,
|
|
471
|
+
func: () => {},
|
|
472
|
+
arr: [],
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
namedObjectOf: { text: 'foo', value: 'bar' },
|
|
476
|
+
shapeShort: { foo: 'bar' },
|
|
477
|
+
shapeComplex: {
|
|
478
|
+
id: 3,
|
|
479
|
+
func: () => {},
|
|
480
|
+
arr: [],
|
|
481
|
+
shape: {
|
|
482
|
+
shape: {
|
|
483
|
+
foo: 'bar',
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
namedShape: { foo: 'bar' },
|
|
488
|
+
namedObjectInShape: { text: 'foo', value: 'bar' },
|
|
489
|
+
exact: { name: 'foo', quantity: 2 },
|
|
490
|
+
namedExact: { text: 'foo', value: 'bar' },
|
|
491
|
+
optionalString: 'Default String',
|
|
492
|
+
nullDefaultValue: null,
|
|
493
|
+
undefinedDefaultValue: undefined,
|
|
494
|
+
...SOME_INLINE_DEFAULT_PROPS,
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
export const component = PropTypesProps;
|