choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
90 lines (80 loc) • 3.46 kB
JavaScript
import PropTypes from 'prop-types';
import { SHOW_ALL, SHOW_CHILD, SHOW_PARENT } from './strategies';
function nonEmptyStringType(props, propsName) {
var value = props[propsName];
if (typeof value !== 'string' || !value) {
return new Error(); // Just a flag, so don't need message.
}
}
function valueType(props, propName, componentName) {
var labelInValueShape = PropTypes.shape({
value: nonEmptyStringType,
label: PropTypes.node
});
if (props.labelInValue) {
var validate = PropTypes.oneOfType([PropTypes.arrayOf(labelInValueShape), labelInValueShape]);
var error = validate.apply(void 0, arguments);
if (error) {
return new Error("Invalid prop `".concat(propName, "` supplied to `").concat(componentName, "`, ") + "when `labelInValue` is `true`, `".concat(propName, "` should in ") + "shape of `{ value: string, label?: string }`.");
}
} else if (props.treeCheckable && props.treeCheckStrictly) {
var _validate = PropTypes.oneOfType([PropTypes.arrayOf(labelInValueShape), labelInValueShape]);
var _error = _validate.apply(void 0, arguments);
if (_error) {
return new Error("Invalid prop `".concat(propName, "` supplied to `").concat(componentName, "`, ") + "when `treeCheckable` and `treeCheckStrictly` are `true`, " + "`".concat(propName, "` should in shape of `{ value: string, label?: string }`."));
}
} else if (props.multiple && props[propName] === '') {
return new Error("Invalid prop `".concat(propName, "` of type `string` supplied to `").concat(componentName, "`, ") + "expected `array` when `multiple` is `true`.");
} else {
var _validate2 = PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.string]);
return _validate2.apply(void 0, arguments);
}
}
export var SelectPropTypes = {
className: PropTypes.string,
prefixCls: PropTypes.string,
multiple: 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.node,
defaultLabel: PropTypes.any,
labelInValue: PropTypes.bool,
dropdownStyle: PropTypes.object,
dropdownPopupAlign: PropTypes.object,
onDropdownVisibleChange: PropTypes.func,
maxTagCount: PropTypes.number,
maxTagPlaceholder: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
maxTagTextLength: PropTypes.number,
showCheckedStrategy: PropTypes.oneOf([SHOW_ALL, SHOW_PARENT, SHOW_CHILD]),
treeCheckStrictly: PropTypes.bool,
treeIcon: PropTypes.bool,
treeLine: PropTypes.bool,
autoClearSearchValue: 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,
searchValue: PropTypes.string
};
//# sourceMappingURL=PropTypes.js.map