choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
115 lines (99 loc) • 4.02 kB
JavaScript
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _createSuper from "@babel/runtime/helpers/createSuper";
var _excluded = ["prefixCls", "className", "size", "notFoundContent", "dropdownStyle", "dropdownClassName"];
import React, { Component } from 'react';
import classNames from 'classnames';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import warning from '../_util/warning';
import RcTreeSelect, { SHOW_ALL, SHOW_CHILD, SHOW_PARENT, TreeNode } from '../rc-components/tree-select';
import { Size } from '../_util/enum';
import ConfigContext from '../config-provider/ConfigContext';
var TreeSelect = /*#__PURE__*/function (_Component) {
_inherits(TreeSelect, _Component);
var _super = _createSuper(TreeSelect);
function TreeSelect(props) {
var _this;
_classCallCheck(this, TreeSelect);
_this = _super.call(this, props);
_this.saveTreeSelect = function (node) {
_this.rcTreeSelect = node;
};
_this.renderTreeSelect = function (locale) {
var _classNames;
var _this$props = _this.props,
customizePrefixCls = _this$props.prefixCls,
className = _this$props.className,
size = _this$props.size,
notFoundContent = _this$props.notFoundContent,
dropdownStyle = _this$props.dropdownStyle,
dropdownClassName = _this$props.dropdownClassName,
restProps = _objectWithoutProperties(_this$props, _excluded);
var getPrefixCls = _this.context.getPrefixCls;
var prefixCls = getPrefixCls('select', customizePrefixCls);
var cls = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-lg"), size === Size.large), _defineProperty(_classNames, "".concat(prefixCls, "-sm"), size === Size.small), _classNames), className);
var checkable = restProps.treeCheckable;
if (checkable) {
checkable = /*#__PURE__*/React.createElement("span", {
className: "".concat(prefixCls, "-tree-checkbox-inner")
});
}
return /*#__PURE__*/React.createElement(RcTreeSelect, _extends({}, restProps, {
dropdownClassName: classNames(dropdownClassName, "".concat(prefixCls, "-tree-dropdown")),
prefixCls: prefixCls,
className: cls,
dropdownStyle: _objectSpread({
maxHeight: '100vh',
overflow: 'auto'
}, dropdownStyle),
treeCheckable: checkable,
notFoundContent: notFoundContent || locale.notFoundContent,
ref: _this.saveTreeSelect
}));
};
warning(props.multiple !== false || !props.treeCheckable, '`multiple` will alway be `true` when `treeCheckable` is true');
return _this;
}
_createClass(TreeSelect, [{
key: "focus",
value: function focus() {
this.rcTreeSelect.focus();
}
}, {
key: "blur",
value: function blur() {
this.rcTreeSelect.blur();
}
}, {
key: "render",
value: function render() {
return /*#__PURE__*/React.createElement(LocaleReceiver, {
componentName: "Select",
defaultLocale: {}
}, this.renderTreeSelect);
}
}], [{
key: "contextType",
get: function get() {
return ConfigContext;
}
}]);
return TreeSelect;
}(Component);
export { TreeSelect as default };
TreeSelect.displayName = 'TreeSelect';
TreeSelect.TreeNode = TreeNode;
TreeSelect.SHOW_ALL = SHOW_ALL;
TreeSelect.SHOW_PARENT = SHOW_PARENT;
TreeSelect.SHOW_CHILD = SHOW_CHILD;
TreeSelect.defaultProps = {
transitionName: 'slide-up',
choiceTransitionName: 'zoom',
showSearch: false
};
//# sourceMappingURL=index.js.map