bee-tree/build/index.js

128 lines
5.2 KiB
JavaScript
Raw Normal View History

2017-01-12 09:21:18 +08:00
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _Tree = require('./Tree');
var _Tree2 = _interopRequireDefault(_Tree);
var _TreeNode = require('./TreeNode');
var _TreeNode2 = _interopRequireDefault(_TreeNode);
var _openAnimation = require('./openAnimation');
var _openAnimation2 = _interopRequireDefault(_openAnimation);
2017-10-18 16:01:17 +08:00
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
2017-01-12 09:21:18 +08:00
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
var TreeProps = {
2017-10-18 16:01:17 +08:00
showLine: _propTypes2["default"].bool,
className: _propTypes2["default"].string,
2017-01-12 09:21:18 +08:00
/** 是否支持多选 */
2017-10-18 16:01:17 +08:00
multiple: _propTypes2["default"].bool,
2017-01-12 09:21:18 +08:00
/** 是否自动展开父节点 */
2017-10-18 16:01:17 +08:00
autoExpandParent: _propTypes2["default"].bool,
2017-01-12 09:21:18 +08:00
/** checkable状态下节点选择完全受控父子节点选中状态不再关联*/
2017-10-18 16:01:17 +08:00
checkStrictly: _propTypes2["default"].bool,
2017-01-12 09:21:18 +08:00
/** 是否支持选中 */
2017-10-18 16:01:17 +08:00
checkable: _propTypes2["default"].bool,
2017-01-12 09:21:18 +08:00
/** 默认展开所有树节点 */
2017-10-18 16:01:17 +08:00
defaultExpandAll: _propTypes2["default"].bool,
2017-01-12 09:21:18 +08:00
/** 默认展开指定的树节点 */
2017-10-18 16:01:17 +08:00
defaultExpandedKeys: _propTypes2["default"].array,
2017-01-12 09:21:18 +08:00
/** (受控)展开指定的树节点 */
2017-10-18 16:01:17 +08:00
expandedKeys: _propTypes2["default"].array,
2017-01-12 09:21:18 +08:00
/** (受控)选中复选框的树节点 */
2017-10-18 16:01:17 +08:00
checkedKeys: _propTypes2["default"].oneOfType([_propTypes2["default"].array, _propTypes2["default"].object]),
2017-01-12 09:21:18 +08:00
/** 默认选中复选框的树节点 */
2017-10-18 16:01:17 +08:00
defaultCheckedKeys: _propTypes2["default"].array,
2017-01-12 09:21:18 +08:00
/** (受控)设置选中的树节点 */
2017-10-18 16:01:17 +08:00
selectedKeys: _propTypes2["default"].array,
2017-01-12 09:21:18 +08:00
/** 默认选中的树节点 */
2017-10-18 16:01:17 +08:00
defaultSelectedKeys: _propTypes2["default"].array,
2017-01-12 09:21:18 +08:00
/** 展开/收起节点时触发 */
2017-10-18 16:01:17 +08:00
onExpand: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
/** 点击复选框触发 */
2017-10-18 16:01:17 +08:00
onCheck: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
/** 点击树节点触发 */
2017-10-18 16:01:17 +08:00
onSelect: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
/** filter some AntTreeNodes as you need. it should return true */
2017-10-18 16:01:17 +08:00
filterAntTreeNode: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
/** 异步加载数据 */
2017-10-18 16:01:17 +08:00
loadData: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
/** 响应右键点击 */
2017-10-18 16:01:17 +08:00
onRightClick: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
/** 设置节点可拖拽IE>8*/
2017-10-18 16:01:17 +08:00
draggable: _propTypes2["default"].bool,
2017-01-12 09:21:18 +08:00
/** 开始拖拽时调用 */
2017-10-18 16:01:17 +08:00
onDragStart: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
/** dragenter 触发时调用 */
2017-10-18 16:01:17 +08:00
onDragEnter: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
/** dragover 触发时调用 */
2017-10-18 16:01:17 +08:00
onDragOver: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
/** dragleave 触发时调用 */
2017-10-18 16:01:17 +08:00
onDragLeave: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
/** drop 触发时调用 */
2017-10-18 16:01:17 +08:00
onDrop: _propTypes2["default"].func,
2017-01-12 09:21:18 +08:00
style: _react2["default"].CSSProperties,
2017-10-18 16:01:17 +08:00
prefixCls: _propTypes2["default"].string,
filterTreeNode: _propTypes2["default"].func
2017-01-12 09:21:18 +08:00
};
var defaultProps = {
prefixCls: 'u-tree',
checkable: false,
showIcon: false,
openAnimation: _openAnimation2["default"]
};
2017-03-07 16:28:34 +08:00
var Tree = function (_Component) {
_inherits(Tree, _Component);
2017-01-12 09:21:18 +08:00
function Tree() {
_classCallCheck(this, Tree);
2017-03-07 16:28:34 +08:00
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
2017-01-12 09:21:18 +08:00
}
Tree.prototype.render = function render() {
var props = this.props;
var checkable = props.checkable;
return _react2["default"].createElement(
_Tree2["default"],
_extends({}, props, {
checkable: checkable ? _react2["default"].createElement('span', { className: props.prefixCls + '-checkbox-inner' }) : checkable
}),
this.props.children
);
};
return Tree;
}(_react.Component);
Tree.TreeNode = _TreeNode2["default"];
Tree.TreeProps = TreeProps;
Tree.defaultProps = defaultProps;
2017-03-07 16:28:34 +08:00
exports["default"] = Tree;
module.exports = exports['default'];