-
-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathwarningPropsUtil.ts
More file actions
51 lines (44 loc) · 1.63 KB
/
warningPropsUtil.ts
File metadata and controls
51 lines (44 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import warning from 'rc-util/lib/warning';
import type { DefaultOptionType, FieldNames, BaseCascaderProps } from '../Cascader';
function warningProps(props: BaseCascaderProps) {
const { onPopupVisibleChange, popupVisible, popupClassName, popupPlacement,dropdownMenuColumnStyle} = props;
warning(
!onPopupVisibleChange,
'`onPopupVisibleChange` is deprecated. Please use `onDropdownVisibleChange` instead.',
);
warning(popupVisible === undefined, '`popupVisible` is deprecated. Please use `open` instead.');
warning(
popupClassName === undefined,
'`popupClassName` is deprecated. Please use `dropdownClassName` instead.',
);
warning(
popupPlacement === undefined,
'`popupPlacement` is deprecated. Please use `placement` instead.',
);
warning(
dropdownMenuColumnStyle === undefined,
'`dropdownMenuColumnStyle` is deprecated. Please use `styles.dropdownMenuColumn` instead.',
);
}
// value in Cascader options should not be null
export function warningNullOptions(options: DefaultOptionType[], fieldNames: FieldNames) {
if (options) {
const recursiveOptions = (optionsList: DefaultOptionType[]) => {
for (let i = 0; i < optionsList.length; i++) {
const option = optionsList[i];
if (option[fieldNames?.value] === null) {
warning(false, '`value` in Cascader options should not be `null`.');
return true;
}
if (
Array.isArray(option[fieldNames?.children]) &&
recursiveOptions(option[fieldNames?.children])
) {
return true;
}
}
};
recursiveOptions(options);
}
}
export default warningProps;