warningPropsUtil.js 1.7 KB

123456789101112131415161718192021222324252627282930313233
  1. import warning from "rc-util/es/warning";
  2. function warningProps(props) {
  3. var onPopupVisibleChange = props.onPopupVisibleChange,
  4. popupVisible = props.popupVisible,
  5. popupClassName = props.popupClassName,
  6. popupPlacement = props.popupPlacement,
  7. onDropdownVisibleChange = props.onDropdownVisibleChange;
  8. warning(!onPopupVisibleChange, '`onPopupVisibleChange` is deprecated. Please use `onOpenChange` instead.');
  9. warning(!onDropdownVisibleChange, '`onDropdownVisibleChange` is deprecated. Please use `onOpenChange` instead.');
  10. warning(popupVisible === undefined, '`popupVisible` is deprecated. Please use `open` instead.');
  11. warning(popupClassName === undefined, '`popupClassName` is deprecated. Please use `dropdownClassName` instead.');
  12. warning(popupPlacement === undefined, '`popupPlacement` is deprecated. Please use `placement` instead.');
  13. }
  14. // value in Cascader options should not be null
  15. export function warningNullOptions(options, fieldNames) {
  16. if (options) {
  17. var recursiveOptions = function recursiveOptions(optionsList) {
  18. for (var i = 0; i < optionsList.length; i++) {
  19. var option = optionsList[i];
  20. if (option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value] === null) {
  21. warning(false, '`value` in Cascader options should not be `null`.');
  22. return true;
  23. }
  24. if (Array.isArray(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children]) && recursiveOptions(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children])) {
  25. return true;
  26. }
  27. }
  28. };
  29. recursiveOptions(options);
  30. }
  31. }
  32. export default warningProps;