warningPropsUtil.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. exports.warningNullOptions = warningNullOptions;
  8. var _warning = _interopRequireDefault(require("rc-util/lib/warning"));
  9. function warningProps(props) {
  10. var onPopupVisibleChange = props.onPopupVisibleChange,
  11. popupVisible = props.popupVisible,
  12. popupClassName = props.popupClassName,
  13. popupPlacement = props.popupPlacement,
  14. onDropdownVisibleChange = props.onDropdownVisibleChange;
  15. (0, _warning.default)(!onPopupVisibleChange, '`onPopupVisibleChange` is deprecated. Please use `onOpenChange` instead.');
  16. (0, _warning.default)(!onDropdownVisibleChange, '`onDropdownVisibleChange` is deprecated. Please use `onOpenChange` instead.');
  17. (0, _warning.default)(popupVisible === undefined, '`popupVisible` is deprecated. Please use `open` instead.');
  18. (0, _warning.default)(popupClassName === undefined, '`popupClassName` is deprecated. Please use `dropdownClassName` instead.');
  19. (0, _warning.default)(popupPlacement === undefined, '`popupPlacement` is deprecated. Please use `placement` instead.');
  20. }
  21. // value in Cascader options should not be null
  22. function warningNullOptions(options, fieldNames) {
  23. if (options) {
  24. var recursiveOptions = function recursiveOptions(optionsList) {
  25. for (var i = 0; i < optionsList.length; i++) {
  26. var option = optionsList[i];
  27. if (option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value] === null) {
  28. (0, _warning.default)(false, '`value` in Cascader options should not be `null`.');
  29. return true;
  30. }
  31. if (Array.isArray(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children]) && recursiveOptions(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children])) {
  32. return true;
  33. }
  34. }
  35. };
  36. recursiveOptions(options);
  37. }
  38. }
  39. var _default = exports.default = warningProps;