-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathPropTypes.js
More file actions
100 lines (98 loc) · 3.12 KB
/
Copy pathPropTypes.js
File metadata and controls
100 lines (98 loc) · 3.12 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import PropTypes from 'prop-types';
import { SHOW_ALL, SHOW_PARENT, SHOW_CHILD } from './strategies';
function valueType(props, propName, componentName) {
const labelInValueShape = PropTypes.shape({
value: PropTypes.string.isRequired,
label: PropTypes.string,
});
if (props.labelInValue) {
const validate = PropTypes.oneOfType([
PropTypes.arrayOf(labelInValueShape),
labelInValueShape,
]);
const error = validate(...arguments);
if (error) {
return new Error(
`Invalid prop \`${propName}\` supplied to \`${componentName}\`, ` +
`when \`labelInValue\` is \`true\`, \`${propName}\` should in ` +
`shape of \`{ value: string, label?: string }\`.`
);
}
} else if (props.treeCheckable && props.treeCheckStrictly) {
const validate = PropTypes.oneOfType([
PropTypes.arrayOf(labelInValueShape),
labelInValueShape,
]);
const error = validate(...arguments);
if (error) {
return new Error(
`Invalid prop \`${propName}\` supplied to \`${componentName}\`, ` +
`when \`treeCheckable\` and \`treeCheckStrictly\` are \`true\`, ` +
`\`${propName}\` should in shape of \`{ value: string, label?: string }\`.`
);
}
} else if (props.multiple && props[propName] === '') {
return new Error(
`Invalid prop \`${propName}\` of type \`string\` supplied to \`${componentName}\`, ` +
`expected \`array\` when \`multiple\` is \`true\`.`
);
} else {
const validate = PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.string),
PropTypes.string,
]);
return validate(...arguments);
}
}
export const SelectPropTypes = {
className: PropTypes.string,
prefixCls: PropTypes.string,
multiple: PropTypes.bool,
multipleShowArrow: PropTypes.bool,
filterTreeNode: PropTypes.any,
showSearch: PropTypes.bool,
disabled: PropTypes.bool,
showArrow: PropTypes.bool,
allowClear: PropTypes.bool,
defaultOpen: PropTypes.bool,
open: PropTypes.bool,
transitionName: PropTypes.string,
animation: PropTypes.string,
choiceTransitionName: PropTypes.string,
onClick: PropTypes.func,
onChange: PropTypes.func,
onSelect: PropTypes.func,
onDeselect: PropTypes.func,
onSearch: PropTypes.func,
searchPlaceholder: PropTypes.string,
placeholder: PropTypes.any,
inputValue: PropTypes.any,
value: valueType,
defaultValue: valueType,
label: PropTypes.any,
defaultLabel: PropTypes.any,
labelInValue: PropTypes.bool,
dropdownStyle: PropTypes.object,
drodownPopupAlign: PropTypes.object,
onDropdownVisibleChange: PropTypes.func,
maxTagTextLength: PropTypes.number,
showCheckedStrategy: PropTypes.oneOf([
SHOW_ALL, SHOW_PARENT, SHOW_CHILD,
]),
treeCheckStrictly: PropTypes.bool,
treeIcon: PropTypes.bool,
treeLine: PropTypes.bool,
treeDefaultExpandAll: PropTypes.bool,
treeCheckable: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.node,
]),
treeNodeLabelProp: PropTypes.string,
treeNodeFilterProp: PropTypes.string,
treeData: PropTypes.array,
treeDataSimpleMode: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.object,
]),
loadData: PropTypes.func,
};