UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

148 lines (125 loc) 4.83 kB
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 _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; function _createSuper(Derived) { function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } return function () { var Super = _getPrototypeOf(Derived), result; if (isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 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, ["prefixCls", "className", "size", "notFoundContent", "dropdownStyle", "dropdownClassName"]); 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 = React.createElement("span", { className: "".concat(prefixCls, "-tree-checkbox-inner") }); } return 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 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