warningPropsUtil.js 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. import _typeof from "@babel/runtime/helpers/esm/typeof";
  2. import warning from "rc-util/es/warning";
  3. import { toArray } from "./valueUtil";
  4. function warningProps(props) {
  5. var searchPlaceholder = props.searchPlaceholder,
  6. treeCheckStrictly = props.treeCheckStrictly,
  7. treeCheckable = props.treeCheckable,
  8. labelInValue = props.labelInValue,
  9. value = props.value,
  10. multiple = props.multiple,
  11. showCheckedStrategy = props.showCheckedStrategy,
  12. maxCount = props.maxCount;
  13. warning(!searchPlaceholder, '`searchPlaceholder` has been removed.');
  14. if (treeCheckStrictly && labelInValue === false) {
  15. warning(false, '`treeCheckStrictly` will force set `labelInValue` to `true`.');
  16. }
  17. if (labelInValue || treeCheckStrictly) {
  18. warning(toArray(value).every(function (val) {
  19. return val && _typeof(val) === 'object' && 'value' in val;
  20. }), 'Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead.');
  21. }
  22. if (treeCheckStrictly || multiple || treeCheckable) {
  23. warning(!value || Array.isArray(value), '`value` should be an array when `TreeSelect` is checkable or multiple.');
  24. } else {
  25. warning(!Array.isArray(value), '`value` should not be array when `TreeSelect` is single mode.');
  26. }
  27. if (maxCount && (showCheckedStrategy === 'SHOW_ALL' && !treeCheckStrictly || showCheckedStrategy === 'SHOW_PARENT')) {
  28. warning(false, '`maxCount` not work with `showCheckedStrategy=SHOW_ALL` (when `treeCheckStrictly=false`) or `showCheckedStrategy=SHOW_PARENT`.');
  29. }
  30. }
  31. export default warningProps;