Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

58 строки
1.8 KiB

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  6. exports.deprecate = deprecate;
  7. exports.addIsDeprecated = addIsDeprecated;
  8. /**
  9. * Wraps a singular React.PropTypes.[type] with
  10. * a console.warn call that is only called if the
  11. * prop is not undefined/null and is only called
  12. * once.
  13. * @param {Object} propType React.PropType type
  14. * @param {String} message Deprecation message
  15. * @return {Function} ReactPropTypes checkType
  16. */
  17. function deprecate(propType, message) {
  18. var warned = false;
  19. return function () {
  20. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  21. args[_key] = arguments[_key];
  22. }
  23. var props = args[0];
  24. var propName = args[1];
  25. var prop = props[propName];
  26. if (prop !== undefined && prop !== null && !warned) {
  27. warned = true;
  28. console.warn(message);
  29. }
  30. return propType.call.apply(propType, [this].concat(args));
  31. };
  32. }
  33. /**
  34. * Returns a copy of `PropTypes` with an `isDeprecated`
  35. * method available on all top-level propType options.
  36. * @param {React.PropTypes} PropTypes
  37. * @return {React.PropTypes} newPropTypes
  38. */
  39. function addIsDeprecated(PropTypes) {
  40. var newPropTypes = _extends({}, PropTypes);
  41. for (var type in newPropTypes) {
  42. if (newPropTypes.hasOwnProperty(type)) {
  43. var propType = newPropTypes[type];
  44. propType = propType.bind(newPropTypes);
  45. propType.isDeprecated = deprecate.bind(newPropTypes, propType);
  46. newPropTypes[type] = propType;
  47. }
  48. }
  49. return newPropTypes;
  50. }