@elliemae/ds-props-helpers 2.3.0-alpha.6 → 2.3.0-next.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/cjs/defaultProps/index.js +9 -0
- package/cjs/defaultProps/useMemoMergePropsWithDefault.js +48 -0
- package/cjs/getProps/index.js +20 -0
- package/cjs/globalProps/constants.js +15 -0
- package/cjs/globalProps/globalAttributesPropTypes.js +382 -0
- package/cjs/globalProps/index.js +11 -0
- package/cjs/globalProps/useGetGlobalAttributes.js +36 -0
- package/cjs/index.js +28 -0
- package/cjs/propTypes/PropTypes.js +130 -0
- package/cjs/propTypes/customPropTypes.js +21 -0
- package/cjs/propTypes/describe.js +64 -0
- package/cjs/propTypes/describeConversions.js +104 -0
- package/cjs/propTypes/describeGuards.js +21 -0
- package/cjs/propTypes/index.js +11 -0
- package/cjs/propTypes/toTypescript.js +160 -0
- package/cjs/propTypes/types.js +2 -0
- package/cjs/validation/errorTemplates.js +16 -0
- package/cjs/validation/index.js +15 -0
- package/cjs/validation/typescriptGuards.js +36 -0
- package/cjs/validation/typescriptParsers.js +45 -0
- package/cjs/validation/typescriptValidator.js +208 -0
- package/cjs/validation/validator.js +36 -0
- package/esm/defaultProps/index.js +1 -0
- package/esm/defaultProps/useMemoMergePropsWithDefault.js +39 -0
- package/esm/getProps/index.js +15 -0
- package/esm/globalProps/constants.js +11 -0
- package/{dist/esm → esm}/globalProps/globalAttributesPropTypes.js +67 -58
- package/esm/globalProps/index.js +2 -0
- package/esm/globalProps/useGetGlobalAttributes.js +32 -0
- package/esm/index.js +9 -0
- package/esm/propTypes/PropTypes.js +124 -0
- package/esm/propTypes/customPropTypes.js +17 -0
- package/esm/propTypes/describe.js +62 -0
- package/esm/propTypes/describeConversions.js +96 -0
- package/esm/propTypes/describeGuards.js +10 -0
- package/esm/propTypes/index.js +2 -0
- package/esm/propTypes/toTypescript.js +154 -0
- package/esm/propTypes/types.js +1 -0
- package/esm/validation/errorTemplates.js +11 -0
- package/esm/validation/index.js +3 -0
- package/esm/validation/typescriptGuards.js +23 -0
- package/esm/validation/typescriptParsers.js +41 -0
- package/esm/validation/typescriptValidator.js +203 -0
- package/esm/validation/validator.js +32 -0
- package/package.json +63 -65
- package/types/defaultProps/index.d.ts +1 -0
- package/types/defaultProps/useMemoMergePropsWithDefault.d.ts +1 -0
- package/types/getProps/index.d.ts +2 -0
- package/types/globalProps/constants.d.ts +3 -0
- package/types/globalProps/globalAttributesPropTypes.d.ts +363 -0
- package/types/globalProps/index.d.ts +2 -0
- package/types/globalProps/useGetGlobalAttributes.d.ts +5 -0
- package/types/index.d.ts +5 -0
- package/types/propTypes/PropTypes.d.ts +3 -0
- package/types/propTypes/customPropTypes.d.ts +2 -0
- package/types/propTypes/describe.d.ts +3 -0
- package/types/propTypes/describeConversions.d.ts +3 -0
- package/types/propTypes/describeGuards.d.ts +9 -0
- package/types/propTypes/index.d.ts +3 -0
- package/types/propTypes/toTypescript.d.ts +3 -0
- package/types/propTypes/types.d.ts +96 -0
- package/types/tests/globalProps/TestComponent.d.ts +1 -0
- package/types/tests/globalProps/globalAttributes.test.d.ts +1 -0
- package/types/tests/validation/any.validation.test.d.ts +1 -0
- package/types/tests/validation/array.validation.test.d.ts +1 -0
- package/types/tests/validation/boolean.validation.test.d.ts +1 -0
- package/types/tests/validation/function.validation.test.d.ts +1 -0
- package/types/tests/validation/number.validation.test.d.ts +1 -0
- package/types/tests/validation/object.validation.test.d.ts +1 -0
- package/types/tests/validation/schema.validation.test.d.ts +1 -0
- package/types/tests/validation/string.validation.test.d.ts +1 -0
- package/types/tests/validation/test.schema.d.ts +1 -0
- package/types/tests/validation/union.validation.test.d.ts +1 -0
- package/types/validation/errorTemplates.d.ts +2 -0
- package/types/validation/index.d.ts +3 -0
- package/types/validation/typescriptGuards.d.ts +12 -0
- package/types/validation/typescriptParsers.d.ts +1 -0
- package/types/validation/typescriptValidator.d.ts +15 -0
- package/types/validation/validator.d.ts +1 -0
- package/dist/cjs/defaultProps/index.js +0 -28
- package/dist/cjs/defaultProps/index.js.map +0 -7
- package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js +0 -48
- package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js.map +0 -7
- package/dist/cjs/getProps/index.js +0 -37
- package/dist/cjs/getProps/index.js.map +0 -7
- package/dist/cjs/globalProps/constants.js +0 -398
- package/dist/cjs/globalProps/constants.js.map +0 -7
- package/dist/cjs/globalProps/globalAttributesPropTypes.js +0 -398
- package/dist/cjs/globalProps/globalAttributesPropTypes.js.map +0 -7
- package/dist/cjs/globalProps/index.js +0 -29
- package/dist/cjs/globalProps/index.js.map +0 -7
- package/dist/cjs/globalProps/useGetGlobalAttributes.js +0 -56
- package/dist/cjs/globalProps/useGetGlobalAttributes.js.map +0 -7
- package/dist/cjs/index.js +0 -32
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/propTypes/PropTypes.js +0 -136
- package/dist/cjs/propTypes/PropTypes.js.map +0 -7
- package/dist/cjs/propTypes/customPropTypes.js +0 -38
- package/dist/cjs/propTypes/customPropTypes.js.map +0 -7
- package/dist/cjs/propTypes/describe.js +0 -81
- package/dist/cjs/propTypes/describe.js.map +0 -7
- package/dist/cjs/propTypes/describeConversions.js +0 -96
- package/dist/cjs/propTypes/describeConversions.js.map +0 -7
- package/dist/cjs/propTypes/describeGuards.js +0 -49
- package/dist/cjs/propTypes/describeGuards.js.map +0 -7
- package/dist/cjs/propTypes/index.js +0 -37
- package/dist/cjs/propTypes/index.js.map +0 -7
- package/dist/cjs/propTypes/toTypescript.js +0 -139
- package/dist/cjs/propTypes/toTypescript.js.map +0 -7
- package/dist/cjs/propTypes/types.js +0 -27
- package/dist/cjs/propTypes/types.js.map +0 -7
- package/dist/cjs/tests/globalProps/TestComponent.js +0 -42
- package/dist/cjs/tests/globalProps/TestComponent.js.map +0 -7
- package/dist/cjs/tests/validation/test.schema.js +0 -67
- package/dist/cjs/tests/validation/test.schema.js.map +0 -7
- package/dist/cjs/validation/errorTemplates.js +0 -48
- package/dist/cjs/validation/errorTemplates.js.map +0 -7
- package/dist/cjs/validation/index.js +0 -30
- package/dist/cjs/validation/index.js.map +0 -7
- package/dist/cjs/validation/typescriptGuards.js +0 -65
- package/dist/cjs/validation/typescriptGuards.js.map +0 -7
- package/dist/cjs/validation/typescriptParsers.js +0 -76
- package/dist/cjs/validation/typescriptParsers.js.map +0 -7
- package/dist/cjs/validation/typescriptValidator.js +0 -171
- package/dist/cjs/validation/typescriptValidator.js.map +0 -7
- package/dist/cjs/validation/validator.js +0 -55
- package/dist/cjs/validation/validator.js.map +0 -7
- package/dist/esm/defaultProps/index.js +0 -3
- package/dist/esm/defaultProps/index.js.map +0 -7
- package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js +0 -19
- package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js.map +0 -7
- package/dist/esm/getProps/index.js +0 -8
- package/dist/esm/getProps/index.js.map +0 -7
- package/dist/esm/globalProps/constants.js +0 -369
- package/dist/esm/globalProps/constants.js.map +0 -7
- package/dist/esm/globalProps/globalAttributesPropTypes.js.map +0 -7
- package/dist/esm/globalProps/index.js +0 -4
- package/dist/esm/globalProps/index.js.map +0 -7
- package/dist/esm/globalProps/useGetGlobalAttributes.js +0 -27
- package/dist/esm/globalProps/useGetGlobalAttributes.js.map +0 -7
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/propTypes/PropTypes.js +0 -107
- package/dist/esm/propTypes/PropTypes.js.map +0 -7
- package/dist/esm/propTypes/customPropTypes.js +0 -9
- package/dist/esm/propTypes/customPropTypes.js.map +0 -7
- package/dist/esm/propTypes/describe.js +0 -52
- package/dist/esm/propTypes/describe.js.map +0 -7
- package/dist/esm/propTypes/describeConversions.js +0 -76
- package/dist/esm/propTypes/describeConversions.js.map +0 -7
- package/dist/esm/propTypes/describeGuards.js +0 -20
- package/dist/esm/propTypes/describeGuards.js.map +0 -7
- package/dist/esm/propTypes/index.js +0 -8
- package/dist/esm/propTypes/index.js.map +0 -7
- package/dist/esm/propTypes/toTypescript.js +0 -110
- package/dist/esm/propTypes/toTypescript.js.map +0 -7
- package/dist/esm/propTypes/types.js +0 -2
- package/dist/esm/propTypes/types.js.map +0 -7
- package/dist/esm/tests/globalProps/TestComponent.js +0 -13
- package/dist/esm/tests/globalProps/TestComponent.js.map +0 -7
- package/dist/esm/tests/validation/test.schema.js +0 -38
- package/dist/esm/tests/validation/test.schema.js.map +0 -7
- package/dist/esm/validation/errorTemplates.js +0 -19
- package/dist/esm/validation/errorTemplates.js.map +0 -7
- package/dist/esm/validation/index.js +0 -5
- package/dist/esm/validation/index.js.map +0 -7
- package/dist/esm/validation/typescriptGuards.js +0 -36
- package/dist/esm/validation/typescriptGuards.js.map +0 -7
- package/dist/esm/validation/typescriptParsers.js +0 -47
- package/dist/esm/validation/typescriptParsers.js.map +0 -7
- package/dist/esm/validation/typescriptValidator.js +0 -153
- package/dist/esm/validation/typescriptValidator.js.map +0 -7
- package/dist/esm/validation/validator.js +0 -26
- package/dist/esm/validation/validator.js.map +0 -7
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable max-params */
|
|
4
|
+
const tupleValidator = tupleShape => {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
6
|
+
const func = function (value, index) {
|
|
7
|
+
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
8
|
+
rest[_key - 2] = arguments[_key];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return tupleShape[index](value, index, ...rest);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return func;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { tupleValidator };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import { convertPropType } from './describeConversions.js';
|
|
5
|
+
import descToTypescript from './toTypescript.js';
|
|
6
|
+
|
|
7
|
+
function describe(ComponentInstance) {
|
|
8
|
+
if (!ComponentInstance) {
|
|
9
|
+
throw new Error('react-desc: component is required');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const documentation = {
|
|
13
|
+
propTypes: {}
|
|
14
|
+
};
|
|
15
|
+
const DocumentedComponent = ComponentInstance;
|
|
16
|
+
|
|
17
|
+
const addDocumentationProp = propName => {
|
|
18
|
+
const func = value => {
|
|
19
|
+
documentation[propName] = value;
|
|
20
|
+
return DocumentedComponent;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return func;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
DocumentedComponent.availableAt = addDocumentationProp('availableAt');
|
|
27
|
+
DocumentedComponent.description = addDocumentationProp('description');
|
|
28
|
+
DocumentedComponent.details = addDocumentationProp('details');
|
|
29
|
+
DocumentedComponent.deprecated = addDocumentationProp('deprecated');
|
|
30
|
+
DocumentedComponent.usage = addDocumentationProp('usage');
|
|
31
|
+
DocumentedComponent.intrinsicElement = addDocumentationProp('intrinsicElement');
|
|
32
|
+
|
|
33
|
+
DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);
|
|
34
|
+
|
|
35
|
+
Object.defineProperty(DocumentedComponent, 'propTypes', {
|
|
36
|
+
get: () => DocumentedComponent.propTypesValue,
|
|
37
|
+
set: value => {
|
|
38
|
+
if (!DocumentedComponent.propTypesValue) {
|
|
39
|
+
DocumentedComponent.propTypesValue = {};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Object.keys(value).forEach(name => {
|
|
43
|
+
const propType = value[name];
|
|
44
|
+
let realPropType;
|
|
45
|
+
documentation.propTypes[name] = propType;
|
|
46
|
+
realPropType = convertPropType(propType);
|
|
47
|
+
|
|
48
|
+
if (value[name].reactDesc.required) {
|
|
49
|
+
realPropType = realPropType.isRequired;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
DocumentedComponent.propTypesValue[name] = realPropType;
|
|
53
|
+
return propType;
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true
|
|
58
|
+
});
|
|
59
|
+
return DocumentedComponent;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { describe as default };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { tupleValidator } from './customPropTypes.js';
|
|
9
|
+
import { hasArguments, isOneOfType, isArrayOf, isShape, isInstanceOf, isOneOf, isObjectOf, isExact } from './describeGuards.js';
|
|
10
|
+
|
|
11
|
+
const enrichPropType = (propType, reactDesc) => {
|
|
12
|
+
const func = function (props, propName, componentName) {
|
|
13
|
+
if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {
|
|
14
|
+
const {
|
|
15
|
+
version = '',
|
|
16
|
+
message = ''
|
|
17
|
+
} = reactDesc.deprecated;
|
|
18
|
+
const warning = "\"".concat(propName, "\" property of \"").concat(componentName, "\" will be deprecated on VERSION: ").concat(version, ".\n").concat(message);
|
|
19
|
+
console.warn(warning);
|
|
20
|
+
reactDesc.warned = true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
24
|
+
rest[_key - 3] = arguments[_key];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return propType(props, propName, componentName, ...rest);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Object.defineProperty(func, 'isRequired', Object.getOwnPropertyDescriptor(propType, 'isRequired'));
|
|
31
|
+
return func;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const convertArray = array => array.map(type => convertPropType(type));
|
|
35
|
+
|
|
36
|
+
const convertShape = _shape => {
|
|
37
|
+
const result = {};
|
|
38
|
+
Object.keys(_shape).forEach(key => {
|
|
39
|
+
result[key] = convertPropType(_shape[key]);
|
|
40
|
+
});
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const convertPropType = propType => {
|
|
45
|
+
if (!propType || !propType.type) {
|
|
46
|
+
throw new Error("react-desc: unknown error -- proptype is not well defined");
|
|
47
|
+
} // DimSum PropTypes conversion
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if (propType.type === 'tuple') {
|
|
51
|
+
return enrichPropType(PropTypes.arrayOf(tupleValidator(convertArray(propType.args))), propType.reactDesc);
|
|
52
|
+
} // Default PropType conversion
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
const realPropType = PropTypes[propType.type];
|
|
56
|
+
|
|
57
|
+
if (!realPropType) {
|
|
58
|
+
throw new Error("react-desc: unknown type ".concat(propType.type));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (hasArguments(propType)) {
|
|
62
|
+
if (isOneOfType(propType)) {
|
|
63
|
+
return enrichPropType(realPropType(convertArray(propType.args)), propType.reactDesc);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (isArrayOf(propType)) {
|
|
67
|
+
return enrichPropType(realPropType(convertPropType(propType.args)), propType.reactDesc);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (isShape(propType)) {
|
|
71
|
+
return enrichPropType(realPropType(convertShape(propType.args)), propType.reactDesc);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (isInstanceOf(propType)) {
|
|
75
|
+
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (isOneOf(propType)) {
|
|
79
|
+
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (isObjectOf(propType)) {
|
|
83
|
+
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (isExact(propType)) {
|
|
87
|
+
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
throw new Error("react-desc: unknown error -- proptype with args is not matching");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return enrichPropType(realPropType, propType.reactDesc);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export { convertPropType };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const hasArguments = (propType, realPropType) => !!propType.args;
|
|
2
|
+
const isOneOfType = (propType, realPropType) => propType.type === 'oneOfType';
|
|
3
|
+
const isArrayOf = (propType, realPropType) => propType.type === 'arrayOf';
|
|
4
|
+
const isShape = (propType, realPropType) => propType.type === 'shape';
|
|
5
|
+
const isInstanceOf = (propType, realPropType) => propType.type === 'instanceOf';
|
|
6
|
+
const isOneOf = (propType, realPropType) => propType.type === 'oneOf';
|
|
7
|
+
const isObjectOf = (propType, realPropType) => propType.type === 'objectOf';
|
|
8
|
+
const isExact = (propType, realPropType) => propType.type === 'exact';
|
|
9
|
+
|
|
10
|
+
export { hasArguments, isArrayOf, isExact, isInstanceOf, isObjectOf, isOneOf, isOneOfType, isShape };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
9
|
+
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
+
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
+
|
|
14
|
+
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
15
|
+
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
17
|
+
|
|
18
|
+
/* eslint-disable complexity */
|
|
19
|
+
|
|
20
|
+
/* eslint-disable react/forbid-foreign-prop-types */
|
|
21
|
+
const arrayFormat = array => array.map(propType => propTypeFormat(propType));
|
|
22
|
+
|
|
23
|
+
const shapeFormat = shape => {
|
|
24
|
+
const props = Object.keys(shape).map(key => {
|
|
25
|
+
const value = shape[key];
|
|
26
|
+
let valueFormat;
|
|
27
|
+
|
|
28
|
+
if (value.type && (value.type === 'arrayOf' || value.type === 'oneOfType' || value.type === 'oneOf') && Array.isArray(value.args)) {
|
|
29
|
+
valueFormat = "".concat(propTypeFormat(value));
|
|
30
|
+
} else if (value.type === 'shape') {
|
|
31
|
+
valueFormat = "".concat(propTypeFormat(value));
|
|
32
|
+
} else {
|
|
33
|
+
valueFormat = propTypeFormat(value);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return "".concat(key).concat(value.reactDesc && value.reactDesc.required ? '' : '?', ": ").concat(valueFormat);
|
|
37
|
+
});
|
|
38
|
+
return "{".concat(props.join(','), "}");
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const propTypeFormat = function (propType) {
|
|
42
|
+
let joinWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
43
|
+
let result;
|
|
44
|
+
|
|
45
|
+
if (Array.isArray(propType)) {
|
|
46
|
+
result = arrayFormat(propType).join(joinWith);
|
|
47
|
+
} else if (typeof propType !== 'function' && propType.type) {
|
|
48
|
+
switch (propType.type) {
|
|
49
|
+
case 'array':
|
|
50
|
+
result = 'any[]';
|
|
51
|
+
break;
|
|
52
|
+
|
|
53
|
+
case 'arrayOf':
|
|
54
|
+
if (propType.args.type === 'oneOfType') {
|
|
55
|
+
result = "(".concat(propTypeFormat(propType.args, ' | '), ")[]");
|
|
56
|
+
} else {
|
|
57
|
+
result = "".concat(propTypeFormat(propType.args, '\n'), "[]");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
case 'tuple':
|
|
63
|
+
result = "[".concat(propTypeFormat(propType.args, ', '), "]");
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
case 'bool':
|
|
67
|
+
result = 'boolean';
|
|
68
|
+
break;
|
|
69
|
+
|
|
70
|
+
case 'func':
|
|
71
|
+
result = '((...args: any[]) => any)';
|
|
72
|
+
break;
|
|
73
|
+
|
|
74
|
+
case 'node':
|
|
75
|
+
result = 'React.ReactNode';
|
|
76
|
+
break;
|
|
77
|
+
|
|
78
|
+
case 'element':
|
|
79
|
+
result = 'JSX.Element';
|
|
80
|
+
break;
|
|
81
|
+
|
|
82
|
+
case 'instanceOf':
|
|
83
|
+
result = 'any';
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case 'symbol':
|
|
87
|
+
result = 'any';
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
case 'objectOf':
|
|
91
|
+
result = "{ [key: string]: ".concat(propTypeFormat(propType.args), " }");
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
case 'oneOf':
|
|
95
|
+
result = propType.args.map(a => "\"".concat(a, "\"")).join(' | ');
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case 'oneOfType':
|
|
99
|
+
result = "".concat(propTypeFormat(propType.args, ' | '));
|
|
100
|
+
break;
|
|
101
|
+
|
|
102
|
+
case 'shape':
|
|
103
|
+
result = "".concat(shapeFormat(propType.args));
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
default:
|
|
107
|
+
result = "".concat(propType.type);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
result = 'any';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return result;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const propTypeAsTypescript = (propType, propName) => {
|
|
118
|
+
const documentation = _objectSpread(_objectSpread({}, propType.reactDesc), {}, {
|
|
119
|
+
name: propName
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
documentation.format = propTypeFormat(propType);
|
|
123
|
+
return documentation;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
function descToTypescript(component, reactDesc) {
|
|
127
|
+
if (!component) {
|
|
128
|
+
throw new Error('react-desc: component is required');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const documentation = _objectSpread({
|
|
132
|
+
name: component.displayName || component.name
|
|
133
|
+
}, reactDesc);
|
|
134
|
+
|
|
135
|
+
if (reactDesc) {
|
|
136
|
+
delete documentation.propTypes;
|
|
137
|
+
|
|
138
|
+
if (reactDesc.propTypes) {
|
|
139
|
+
const propTypes = [];
|
|
140
|
+
Object.keys(reactDesc.propTypes).forEach(propName => {
|
|
141
|
+
const propType = reactDesc.propTypes[propName];
|
|
142
|
+
propTypes.push(propTypeAsTypescript(propType, propName));
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
if (propTypes.length > 0) {
|
|
146
|
+
documentation.properties = propTypes;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return documentation;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export { descToTypescript as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import 'core-js/modules/es.string.replace.js';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable max-params */
|
|
4
|
+
const throwTypeError = (componentName, validPropKey, invalidProp, validFormat) => {
|
|
5
|
+
throw new Error("".concat(componentName, ":: You are trying to pass a not valid \"").concat(validPropKey, "\" property, \n please provide a valid type.\n\n Received: ").concat(invalidProp, " (").concat(typeof invalidProp, ")\n Expected: (").concat(validFormat.replace('\n', ' or '), ")\n "));
|
|
6
|
+
};
|
|
7
|
+
const throwRequiredError = (componentName, validPropKey) => {
|
|
8
|
+
throw new Error("".concat(componentName, ":: Please provide a/an \"").concat(validPropKey, "\" property to use this component. \n This property is required.\n "));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { throwRequiredError, throwTypeError };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
|
|
5
|
+
const isPrimitiveType = format => ['string', 'number', 'boolean'].includes(format);
|
|
6
|
+
const isUndefined = format => format === '"undefined"';
|
|
7
|
+
const isNull = format => format === '"null"';
|
|
8
|
+
const isUnion = format => {
|
|
9
|
+
let depth = 0;
|
|
10
|
+
let satisfies = false;
|
|
11
|
+
format.split('').forEach(char => {
|
|
12
|
+
if (['{', '('].includes(char)) depth += 1;else if (['}', ')'].includes(char)) depth -= 1;else if (char === '|' && depth === 0) satisfies = true;
|
|
13
|
+
});
|
|
14
|
+
return satisfies;
|
|
15
|
+
};
|
|
16
|
+
const isString = format => !isUnion(format) && format[0] === '"' && format.slice(-1) === '"';
|
|
17
|
+
const isArray = format => !isUnion(format) && format.slice(-2) === '[]';
|
|
18
|
+
const isObject = format => format === 'object' || !isUnion(format) && format[0] === '{' && format.slice(-1) === '}';
|
|
19
|
+
const isFunction = format => !isUnion(format) && format === '((...args: any[]) => any)';
|
|
20
|
+
const isJSXorNode = format => !isUnion(format) && ['React.ReactNode', 'JSX.Element'].includes(format);
|
|
21
|
+
const isSomethingWithParenthesis = format => !isUnion(format) && format[0] === '(' && format.slice(-1) === ')';
|
|
22
|
+
|
|
23
|
+
export { isArray, isFunction, isJSXorNode, isNull, isObject, isPrimitiveType, isSomethingWithParenthesis, isString, isUndefined, isUnion };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
|
|
5
|
+
/* eslint-disable complexity */
|
|
6
|
+
const typescriptObjectParser = format => {
|
|
7
|
+
const keyValuePairs = []; // State of the algorithm
|
|
8
|
+
|
|
9
|
+
let lastKey = '';
|
|
10
|
+
let lastValue = '';
|
|
11
|
+
let shouldAppendToKey = true;
|
|
12
|
+
|
|
13
|
+
const pushPair = () => {
|
|
14
|
+
if (lastKey) keyValuePairs.push([lastKey, lastValue]);
|
|
15
|
+
lastKey = '';
|
|
16
|
+
lastValue = '';
|
|
17
|
+
shouldAppendToKey = true;
|
|
18
|
+
}; // Complex -- but working -- logic
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
let depth = 0;
|
|
22
|
+
format.split('').forEach(char => {
|
|
23
|
+
if (char === '{') {
|
|
24
|
+
depth += 1;
|
|
25
|
+
if (depth > 1) lastValue += char;
|
|
26
|
+
} else if (char === '}') {
|
|
27
|
+
if (depth > 1) lastValue += char;
|
|
28
|
+
depth -= 1;
|
|
29
|
+
if (depth === 1) pushPair();
|
|
30
|
+
} else if (char === ':') {
|
|
31
|
+
shouldAppendToKey = false;
|
|
32
|
+
if (depth > 1) lastValue += char;
|
|
33
|
+
} else if (char === ',') {
|
|
34
|
+
if (depth === 1) pushPair();else lastValue += char;
|
|
35
|
+
} else if (char === ' ') ; else if (shouldAppendToKey) lastKey += char;else lastValue += char;
|
|
36
|
+
});
|
|
37
|
+
pushPair();
|
|
38
|
+
return keyValuePairs;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { typescriptObjectParser };
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import { useState, useMemo } from 'react';
|
|
6
|
+
import '../propTypes/PropTypes.js';
|
|
7
|
+
import describe from '../propTypes/describe.js';
|
|
8
|
+
import { throwRequiredError, throwTypeError } from './errorTemplates.js';
|
|
9
|
+
import { isUndefined, isNull, isPrimitiveType, isUnion, isString, isArray, isObject, isFunction, isJSXorNode, isSomethingWithParenthesis } from './typescriptGuards.js';
|
|
10
|
+
import { typescriptObjectParser } from './typescriptParsers.js';
|
|
11
|
+
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// Atom Validators
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// This functions will validate something from the data
|
|
16
|
+
// and optionally recursively apply `validateValueWithFormat`
|
|
17
|
+
// in smaller parts
|
|
18
|
+
const validateUndefined = (schemaName, key, value, format) => {
|
|
19
|
+
if (value !== undefined || value === 'undefined') {
|
|
20
|
+
throwTypeError(schemaName, key, value, format);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const validateNull = (schemaName, key, value, format) => {
|
|
25
|
+
if (value !== null || value === 'null') {
|
|
26
|
+
throwTypeError(schemaName, key, value, format);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const validatePrimitiveType = (schemaName, key, value, format) => {
|
|
31
|
+
if (typeof value !== format) {
|
|
32
|
+
throwTypeError(schemaName, key, value, format);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const validateString = (schemaName, key, value, format) => {
|
|
37
|
+
if (value !== format.slice(1, -1)) {
|
|
38
|
+
throwTypeError(schemaName, key, value, format);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const validateArray = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
43
|
+
// Check that we have an array
|
|
44
|
+
if (!Array.isArray(value)) {
|
|
45
|
+
throwTypeError(schemaName, key, value, format);
|
|
46
|
+
} // Check that each element inside satisfies the format
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
value.forEach((val, index) => {
|
|
50
|
+
// this is a recursive func, we need to invoke it before it's defined.
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
52
|
+
validateValueWithFormat(schemaName, "".concat(key, "[").concat(index, "]"), val, format.slice(0, -2), validationsMemo, nextValidationsMemo);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function isObjectType(value) {
|
|
57
|
+
return !(typeof value !== 'object' || Array.isArray(value));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const validateObject = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
61
|
+
const valuesIsObject = isObjectType(value); // Check that we have an object
|
|
62
|
+
|
|
63
|
+
if (!valuesIsObject) {
|
|
64
|
+
throwTypeError(schemaName, key, value, format);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (format === 'object') return;
|
|
69
|
+
const keyValuePairs = typescriptObjectParser(format); // Now we have the key - value pairs
|
|
70
|
+
// Each key could either be required or not
|
|
71
|
+
// Just recursively check the object
|
|
72
|
+
|
|
73
|
+
keyValuePairs.forEach(_ref => {
|
|
74
|
+
let [objectKey, objectValue] = _ref;
|
|
75
|
+
const trueKey = objectKey.slice(-1) === '?' ? objectKey.slice(0, -1) : objectKey;
|
|
76
|
+
|
|
77
|
+
if (trueKey === objectKey && !(trueKey in value)) {
|
|
78
|
+
throwRequiredError(schemaName, key);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (trueKey in value) {
|
|
82
|
+
// this is a recursive func, we need to invoke it before it's defined.
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
84
|
+
validateValueWithFormat(schemaName, "".concat(key, "[").concat(trueKey, "]"), value[trueKey], objectValue, validationsMemo, nextValidationsMemo);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const validateUnion = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
90
|
+
const possibilities = format.split(/\s?\|\s?/);
|
|
91
|
+
const errors = [];
|
|
92
|
+
possibilities.forEach(possibility => {
|
|
93
|
+
try {
|
|
94
|
+
// this is a recursive func, we need to invoke it before it's defined.
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
96
|
+
validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
errors.push(e);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (errors.length === possibilities.length) {
|
|
103
|
+
throwTypeError(schemaName, key, value, format);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const validateFunction = (schemaName, key, value, format) => {
|
|
108
|
+
// Check that we have a function
|
|
109
|
+
if (typeof value !== 'function') {
|
|
110
|
+
throwTypeError(schemaName, key, value, format);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
function isJSXElement(value) {
|
|
115
|
+
return value === null || typeof value === 'object' && value !== null && '$$typeof' in value;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const validateJSXorNode = (schemaName, key, value, format) => {
|
|
119
|
+
const valueIsJSX = isJSXElement(value);
|
|
120
|
+
|
|
121
|
+
if (format === 'JSX.Element' && !valueIsJSX) {
|
|
122
|
+
throwTypeError(schemaName, key, value, format);
|
|
123
|
+
}
|
|
124
|
+
}; // =============================================================================
|
|
125
|
+
// Schema validator
|
|
126
|
+
// =============================================================================
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
const validateValueWithFormat = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
130
|
+
nextValidationsMemo[value] = format;
|
|
131
|
+
|
|
132
|
+
if (value in validationsMemo) {
|
|
133
|
+
// We already validated this value on this format
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (isUndefined(format)) {
|
|
138
|
+
validateUndefined(schemaName, key, value, format);
|
|
139
|
+
} else if (isNull(format)) {
|
|
140
|
+
validateNull(schemaName, key, value, format);
|
|
141
|
+
} else if (isPrimitiveType(format)) {
|
|
142
|
+
validatePrimitiveType(schemaName, key, value, format);
|
|
143
|
+
} else if (isUnion(format)) {
|
|
144
|
+
validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
145
|
+
} else if (isString(format)) {
|
|
146
|
+
validateString(schemaName, key, value, format);
|
|
147
|
+
} else if (isArray(format)) {
|
|
148
|
+
validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
149
|
+
} else if (isObject(format)) {
|
|
150
|
+
validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
151
|
+
} else if (isFunction(format)) {
|
|
152
|
+
validateFunction(schemaName, key, value, format);
|
|
153
|
+
} else if (isJSXorNode(format)) {
|
|
154
|
+
validateJSXorNode(schemaName, key, value, format);
|
|
155
|
+
} else if (isSomethingWithParenthesis(format)) {
|
|
156
|
+
validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const validateTypescriptPropTypesImplementation = function (props, schema) {
|
|
161
|
+
let validationsMemo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
162
|
+
let nextValidationsMemo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
163
|
+
const {
|
|
164
|
+
properties,
|
|
165
|
+
name: schemaName
|
|
166
|
+
} = schema;
|
|
167
|
+
properties.forEach(property => {
|
|
168
|
+
const {
|
|
169
|
+
name,
|
|
170
|
+
format,
|
|
171
|
+
required
|
|
172
|
+
} = property;
|
|
173
|
+
|
|
174
|
+
if (required && !(name in props)) {
|
|
175
|
+
throwRequiredError(schema.name, name);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (name in props && (props[name] !== undefined || required)) {
|
|
179
|
+
validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
+
|
|
184
|
+
const useValidateTypescriptPropTypes = (props, propTypes) => {
|
|
185
|
+
const [validationsMemo, setValidationsMemo] = useState({}); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
186
|
+
|
|
187
|
+
const ComponentWithSchema = useMemo(() => {
|
|
188
|
+
const Component = () => {}; // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
return describe(Component);
|
|
192
|
+
}, []); // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
|
193
|
+
|
|
194
|
+
ComponentWithSchema.propTypes = propTypes;
|
|
195
|
+
useMemo(() => {
|
|
196
|
+
const nextValidationsMemo = {};
|
|
197
|
+
validateTypescriptPropTypesImplementation(props, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
198
|
+
ComponentWithSchema.toTypescript(), validationsMemo, nextValidationsMemo);
|
|
199
|
+
setValidationsMemo(nextValidationsMemo); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
200
|
+
}, [props]);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export { useValidateTypescriptPropTypes, validateTypescriptPropTypesImplementation };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import { throwRequiredError, throwTypeError } from './errorTemplates.js';
|
|
5
|
+
|
|
6
|
+
const useValidatePropTypes = (props, schema) => {
|
|
7
|
+
schema.properties.forEach(property => {
|
|
8
|
+
const propertyName = property.name;
|
|
9
|
+
const currentProp = props[propertyName];
|
|
10
|
+
const currentPropTypeOf = typeof currentProp; // eslint-disable-next-line max-len
|
|
11
|
+
|
|
12
|
+
const currentFormat = property.format; // this is csv representing types e.g.: "string"/"string,number"/"[object],string"
|
|
13
|
+
|
|
14
|
+
let isValidReactElement = false; // this depends on react desc definition
|
|
15
|
+
|
|
16
|
+
if (property.required && !Object.prototype.hasOwnProperty.call(props, property.name)) {
|
|
17
|
+
throwRequiredError(schema.name, property.name);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (currentPropTypeOf !== 'undefined' && currentProp !== null) {
|
|
21
|
+
if (currentPropTypeOf === 'object' && Object.prototype.hasOwnProperty.call(currentProp, '$$typeof') && (currentFormat.includes('node') || currentFormat.includes('element'))) {
|
|
22
|
+
isValidReactElement = true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!currentFormat.includes(currentPropTypeOf) && !currentFormat.includes(currentProp) && !isValidReactElement) {
|
|
26
|
+
throwTypeError(schema.name, propertyName, currentProp, currentFormat);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useValidatePropTypes };
|