|
- {"ast":null,"code":"\"use strict\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\");\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _typeof2 = _interopRequireDefault(require(\"@babel/runtime/helpers/typeof\"));\n\nvar _reactIs = require(\"react-is\");\n/**\n * A factory that returns a propTypes validator that only accepts values that\n * are also accepted by React.createElement\n * e.g. \"div\", functional, class components, forwardRef etc.\n *\n * @param {boolean} isRequired If `true` returns a validator\n * that will throw if nullish values are passed\n */\n\n\nfunction createComponentProp(isRequired) {\n /* istanbul ignore if */\n if (process.env.NODE_ENV === 'production') {\n return function () {\n return null;\n };\n }\n\n return function componentPropType(props, key, componentName, location, propFullName) {\n var prop = props[key];\n var propName = propFullName || key;\n var message;\n\n if (prop == null) {\n if (isRequired) {\n message = \"The \".concat(location, \" `\").concat(propName, \"` is marked as required in `\").concat(componentName, \"`, \") + \"but its value is `\".concat((0, _typeof2.default)(prop), \"`.\");\n }\n } else if (!(0, _reactIs.isValidElementType)(prop)) {\n var preciseType = (0, _typeof2.default)(prop);\n message = \"Invalid \".concat(location, \" `\").concat(propName, \"` of type `\").concat(preciseType, \"` \") + \"supplied to `\".concat(componentName, \"`, expected a component.\");\n }\n\n if (message != null) {\n // change error message slightly on every check to prevent caching when testing\n // which would not trigger console errors on subsequent fails\n return new Error(\"\".concat(message).concat(process.env.NODE_ENV === 'test' ? Date.now() : ''));\n }\n\n return null;\n };\n}\n\nvar componentPropType = createComponentProp(false);\ncomponentPropType.isRequired = createComponentProp(true);\nvar _default = componentPropType;\nexports.default = _default;","map":null,"metadata":{},"sourceType":"script"}
|