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