@storybook/react 7.3.2 → 7.4.0-alpha.1

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.
Files changed (150) hide show
  1. package/package.json +10 -9
  2. package/src/__test__/README.md +0 -3
  3. package/src/typings.d.ts +0 -48
  4. package/template/components/Button.jsx +0 -13
  5. package/template/components/Form.jsx +0 -36
  6. package/template/components/Html.jsx +0 -9
  7. package/template/components/Pre.jsx +0 -20
  8. package/template/stories/decorators.stories.tsx +0 -48
  9. package/template/stories/docgen-components/10017-ts-union/argTypes.snapshot +0 -36
  10. package/template/stories/docgen-components/10017-ts-union/docgen.snapshot +0 -34
  11. package/template/stories/docgen-components/10017-ts-union/input.tsx +0 -12
  12. package/template/stories/docgen-components/10017-ts-union/properties.snapshot +0 -32
  13. package/template/stories/docgen-components/10278-ts-multiple-components/argTypes.snapshot +0 -26
  14. package/template/stories/docgen-components/10278-ts-multiple-components/docgen.snapshot +0 -49
  15. package/template/stories/docgen-components/10278-ts-multiple-components/input.tsx +0 -27
  16. package/template/stories/docgen-components/10278-ts-multiple-components/properties.snapshot +0 -22
  17. package/template/stories/docgen-components/8140-js-prop-types-oneof/argTypes.snapshot +0 -127
  18. package/template/stories/docgen-components/8140-js-prop-types-oneof/docgen.snapshot +0 -97
  19. package/template/stories/docgen-components/8140-js-prop-types-oneof/input.jsx +0 -27
  20. package/template/stories/docgen-components/8140-js-prop-types-oneof/properties.snapshot +0 -89
  21. package/template/stories/docgen-components/8143-ts-imported-types/argTypes.snapshot +0 -27
  22. package/template/stories/docgen-components/8143-ts-imported-types/docgen.snapshot +0 -22
  23. package/template/stories/docgen-components/8143-ts-imported-types/input.tsx +0 -10
  24. package/template/stories/docgen-components/8143-ts-imported-types/properties.snapshot +0 -23
  25. package/template/stories/docgen-components/8143-ts-imported-types/types.ts +0 -3
  26. package/template/stories/docgen-components/8143-ts-react-fc-generics/argTypes.snapshot +0 -27
  27. package/template/stories/docgen-components/8143-ts-react-fc-generics/docgen.snapshot +0 -24
  28. package/template/stories/docgen-components/8143-ts-react-fc-generics/input.tsx +0 -10
  29. package/template/stories/docgen-components/8143-ts-react-fc-generics/properties.snapshot +0 -21
  30. package/template/stories/docgen-components/8428-js-static-prop-types/argTypes.snapshot +0 -25
  31. package/template/stories/docgen-components/8428-js-static-prop-types/docgen.snapshot +0 -39
  32. package/template/stories/docgen-components/8428-js-static-prop-types/input.jsx +0 -20
  33. package/template/stories/docgen-components/8428-js-static-prop-types/properties.snapshot +0 -21
  34. package/template/stories/docgen-components/8740-ts-multi-props/argTypes.snapshot +0 -27
  35. package/template/stories/docgen-components/8740-ts-multi-props/docgen.snapshot +0 -49
  36. package/template/stories/docgen-components/8740-ts-multi-props/input.tsx +0 -23
  37. package/template/stories/docgen-components/8740-ts-multi-props/properties.snapshot +0 -21
  38. package/template/stories/docgen-components/8894-9511-ts-forward-ref/argTypes.snapshot +0 -48
  39. package/template/stories/docgen-components/8894-9511-ts-forward-ref/docgen.snapshot +0 -39
  40. package/template/stories/docgen-components/8894-9511-ts-forward-ref/input.tsx +0 -31
  41. package/template/stories/docgen-components/8894-9511-ts-forward-ref/properties.snapshot +0 -34
  42. package/template/stories/docgen-components/9023-js-hoc/argTypes.snapshot +0 -89
  43. package/template/stories/docgen-components/9023-js-hoc/docgen.snapshot +0 -84
  44. package/template/stories/docgen-components/9023-js-hoc/input.jsx +0 -40
  45. package/template/stories/docgen-components/9023-js-hoc/properties.snapshot +0 -67
  46. package/template/stories/docgen-components/9399-js-proptypes-shape/argTypes.snapshot +0 -39
  47. package/template/stories/docgen-components/9399-js-proptypes-shape/docgen.snapshot +0 -48
  48. package/template/stories/docgen-components/9399-js-proptypes-shape/input.jsx +0 -16
  49. package/template/stories/docgen-components/9399-js-proptypes-shape/properties.snapshot +0 -35
  50. package/template/stories/docgen-components/9465-ts-type-props/argTypes.snapshot +0 -28
  51. package/template/stories/docgen-components/9465-ts-type-props/docgen.snapshot +0 -33
  52. package/template/stories/docgen-components/9465-ts-type-props/input.tsx +0 -12
  53. package/template/stories/docgen-components/9465-ts-type-props/properties.snapshot +0 -24
  54. package/template/stories/docgen-components/9493-ts-display-name/argTypes.snapshot +0 -62
  55. package/template/stories/docgen-components/9493-ts-display-name/docgen.snapshot +0 -50
  56. package/template/stories/docgen-components/9493-ts-display-name/input.tsx +0 -30
  57. package/template/stories/docgen-components/9493-ts-display-name/properties.snapshot +0 -52
  58. package/template/stories/docgen-components/9556-ts-react-default-exports/argTypes.snapshot +0 -28
  59. package/template/stories/docgen-components/9556-ts-react-default-exports/docgen.snapshot +0 -32
  60. package/template/stories/docgen-components/9556-ts-react-default-exports/input.tsx +0 -12
  61. package/template/stories/docgen-components/9556-ts-react-default-exports/properties.snapshot +0 -24
  62. package/template/stories/docgen-components/9575-ts-camel-case/argTypes.snapshot +0 -28
  63. package/template/stories/docgen-components/9575-ts-camel-case/docgen.snapshot +0 -38
  64. package/template/stories/docgen-components/9575-ts-camel-case/input.tsx +0 -26
  65. package/template/stories/docgen-components/9575-ts-camel-case/properties.snapshot +0 -24
  66. package/template/stories/docgen-components/9586-js-react-memo/argTypes.snapshot +0 -41
  67. package/template/stories/docgen-components/9586-js-react-memo/docgen.snapshot +0 -42
  68. package/template/stories/docgen-components/9586-js-react-memo/input.jsx +0 -15
  69. package/template/stories/docgen-components/9586-js-react-memo/properties.snapshot +0 -34
  70. package/template/stories/docgen-components/9591-ts-import-types/Bar.tsx +0 -3
  71. package/template/stories/docgen-components/9591-ts-import-types/argTypes.snapshot +0 -25
  72. package/template/stories/docgen-components/9591-ts-import-types/docgen.snapshot +0 -21
  73. package/template/stories/docgen-components/9591-ts-import-types/input.tsx +0 -10
  74. package/template/stories/docgen-components/9591-ts-import-types/properties.snapshot +0 -21
  75. package/template/stories/docgen-components/9626-js-default-values/argTypes.snapshot +0 -27
  76. package/template/stories/docgen-components/9626-js-default-values/docgen.snapshot +0 -25
  77. package/template/stories/docgen-components/9626-js-default-values/input.jsx +0 -5
  78. package/template/stories/docgen-components/9626-js-default-values/properties.snapshot +0 -21
  79. package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/argTypes.snapshot +0 -42
  80. package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/docgen.snapshot +0 -36
  81. package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/input.jsx +0 -13
  82. package/template/stories/docgen-components/9668-js-proptypes-no-jsdoc/properties.snapshot +0 -35
  83. package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/argTypes.snapshot +0 -34
  84. package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/docgen.snapshot +0 -38
  85. package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/input.tsx +0 -12
  86. package/template/stories/docgen-components/9721-ts-deprecated-jsdoc/properties.snapshot +0 -30
  87. package/template/stories/docgen-components/9764-ts-extend-props/argTypes.snapshot +0 -72
  88. package/template/stories/docgen-components/9764-ts-extend-props/docgen.snapshot +0 -41
  89. package/template/stories/docgen-components/9764-ts-extend-props/input.tsx +0 -17
  90. package/template/stories/docgen-components/9764-ts-extend-props/properties.snapshot +0 -56
  91. package/template/stories/docgen-components/9827-ts-default-values/argTypes.snapshot +0 -72
  92. package/template/stories/docgen-components/9827-ts-default-values/docgen.snapshot +0 -52
  93. package/template/stories/docgen-components/9827-ts-default-values/input.tsx +0 -17
  94. package/template/stories/docgen-components/9827-ts-default-values/properties.snapshot +0 -56
  95. package/template/stories/docgen-components/9832-ts-enum-export/argTypes.snapshot +0 -3
  96. package/template/stories/docgen-components/9832-ts-enum-export/docgen.snapshot +0 -16
  97. package/template/stories/docgen-components/9832-ts-enum-export/input.tsx +0 -8
  98. package/template/stories/docgen-components/9832-ts-enum-export/properties.snapshot +0 -7
  99. package/template/stories/docgen-components/9922-ts-component-props/argTypes.snapshot +0 -25
  100. package/template/stories/docgen-components/9922-ts-component-props/docgen.snapshot +0 -35
  101. package/template/stories/docgen-components/9922-ts-component-props/input.tsx +0 -24
  102. package/template/stories/docgen-components/9922-ts-component-props/properties.snapshot +0 -21
  103. package/template/stories/docgen-components/js-class-component/argTypes.snapshot +0 -386
  104. package/template/stories/docgen-components/js-class-component/docgen.snapshot +0 -252
  105. package/template/stories/docgen-components/js-class-component/input.jsx +0 -57
  106. package/template/stories/docgen-components/js-class-component/properties.snapshot +0 -286
  107. package/template/stories/docgen-components/js-function-component/argTypes.snapshot +0 -386
  108. package/template/stories/docgen-components/js-function-component/docgen.snapshot +0 -236
  109. package/template/stories/docgen-components/js-function-component/input.jsx +0 -50
  110. package/template/stories/docgen-components/js-function-component/properties.snapshot +0 -286
  111. package/template/stories/docgen-components/js-function-component-inline-defaults/argTypes.snapshot +0 -386
  112. package/template/stories/docgen-components/js-function-component-inline-defaults/docgen.snapshot +0 -247
  113. package/template/stories/docgen-components/js-function-component-inline-defaults/input.jsx +0 -65
  114. package/template/stories/docgen-components/js-function-component-inline-defaults/properties.snapshot +0 -286
  115. package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/argTypes.snapshot +0 -237
  116. package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/docgen.snapshot +0 -124
  117. package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/input.jsx +0 -41
  118. package/template/stories/docgen-components/js-function-component-inline-defaults-no-propTypes/properties.snapshot +0 -151
  119. package/template/stories/docgen-components/js-proptypes/docgen.snapshot +0 -1770
  120. package/template/stories/docgen-components/js-proptypes/input.jsx +0 -497
  121. package/template/stories/docgen-components/jsdoc/argTypes.snapshot +0 -1129
  122. package/template/stories/docgen-components/jsdoc/docgen.snapshot +0 -548
  123. package/template/stories/docgen-components/jsdoc/input.jsx +0 -231
  124. package/template/stories/docgen-components/jsdoc/properties.snapshot +0 -1017
  125. package/template/stories/docgen-components/ts-function-component/argTypes.snapshot +0 -396
  126. package/template/stories/docgen-components/ts-function-component/docgen.snapshot +0 -241
  127. package/template/stories/docgen-components/ts-function-component/input.tsx +0 -52
  128. package/template/stories/docgen-components/ts-function-component/properties.snapshot +0 -296
  129. package/template/stories/docgen-components/ts-function-component-inline-defaults/argTypes.snapshot +0 -279
  130. package/template/stories/docgen-components/ts-function-component-inline-defaults/docgen.snapshot +0 -151
  131. package/template/stories/docgen-components/ts-function-component-inline-defaults/input.tsx +0 -80
  132. package/template/stories/docgen-components/ts-function-component-inline-defaults/properties.snapshot +0 -177
  133. package/template/stories/docgen-components/ts-html/argTypes.snapshot +0 -3
  134. package/template/stories/docgen-components/ts-html/docgen.snapshot +0 -12
  135. package/template/stories/docgen-components/ts-html/input.tsx +0 -12
  136. package/template/stories/docgen-components/ts-html/properties.snapshot +0 -7
  137. package/template/stories/docgen-components/ts-jsdoc/argTypes.snapshot +0 -3
  138. package/template/stories/docgen-components/ts-jsdoc/docgen.snapshot +0 -21
  139. package/template/stories/docgen-components/ts-jsdoc/input.tsx +0 -27
  140. package/template/stories/docgen-components/ts-jsdoc/properties.snapshot +0 -7
  141. package/template/stories/docgen-components/ts-types/argTypes.snapshot +0 -656
  142. package/template/stories/docgen-components/ts-types/docgen.snapshot +0 -317
  143. package/template/stories/docgen-components/ts-types/input.tsx +0 -130
  144. package/template/stories/docgen-components/ts-types/properties.snapshot +0 -410
  145. package/template/stories/errors.stories.tsx +0 -37
  146. package/template/stories/hooks.stories.tsx +0 -17
  147. package/template/stories/js-argtypes.stories.jsx +0 -91
  148. package/template/stories/react-mdx.stories.mdx +0 -26
  149. package/template/stories/teardown.stories.tsx +0 -23
  150. package/template/stories/ts-argtypes.stories.tsx +0 -104
@@ -1,497 +0,0 @@
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;