支持自定义属性

This commit is contained in:
yangchch6 2019-09-19 20:47:49 +08:00
parent 0184974d73
commit 9be1255a9e
4 changed files with 35 additions and 15 deletions

View File

@ -40,10 +40,10 @@ var _createStore2 = _interopRequireDefault(_createStore);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
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 _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@ -990,6 +990,7 @@ var Tree = function (_React$Component) {
var _this6 = this;
var props = this.props;
var _props3 = this.props,
showLine = _props3.showLine,
prefixCls = _props3.prefixCls,
@ -1000,7 +1001,14 @@ var Tree = function (_React$Component) {
checkStrictly = _props3.checkStrictly,
tabIndexValue = _props3.tabIndexValue,
lazyLoad = _props3.lazyLoad,
getScrollContainer = _props3.getScrollContainer;
getScrollContainer = _props3.getScrollContainer,
defaultExpandedKeys = _props3.defaultExpandedKeys,
defaultSelectedKeys = _props3.defaultSelectedKeys,
defaultCheckedKeys = _props3.defaultCheckedKeys,
openAnimation = _props3.openAnimation,
draggable = _props3.draggable,
others = _objectWithoutProperties(_props3, ['showLine', 'prefixCls', 'className', 'focusable', 'checkable', 'loadData', 'checkStrictly', 'tabIndexValue', 'lazyLoad', 'getScrollContainer', 'defaultExpandedKeys', 'defaultSelectedKeys', 'defaultCheckedKeys', 'openAnimation', 'draggable']);
var _state = this.state,
treeData = _state.treeData,
flatTreeData = _state.flatTreeData;
@ -1102,7 +1110,7 @@ var Tree = function (_React$Component) {
'ul',
_extends({}, domProps, { unselectable: 'true', ref: function ref(el) {
_this6.tree = el;
}, tabIndex: focusable && tabIndexValue }),
}, tabIndex: focusable && tabIndexValue }, others),
_react2["default"].createElement('li', { style: { height: preHeight }, className: 'u-treenode-start', key: 'tree_node_start' }),
_react2["default"].Children.map(treeChildren, this.renderTreeNode, this),
_react2["default"].createElement('li', { style: { height: sufHeight }, className: 'u-treenode-end', key: 'tree_node_end' })
@ -1111,7 +1119,7 @@ var Tree = function (_React$Component) {
'ul',
_extends({}, domProps, { unselectable: 'true', ref: function ref(el) {
_this6.tree = el;
}, tabIndex: focusable && tabIndexValue }),
}, tabIndex: focusable && tabIndexValue }, others),
_react2["default"].Children.map(treeChildren, this.renderTreeNode, this)
);
};

20
dist/demo.js vendored
View File

@ -34384,12 +34384,12 @@
var _createStore2 = _interopRequireDefault(_createStore);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
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 _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@ -35336,6 +35336,7 @@
var _this6 = this;
var props = this.props;
var _props3 = this.props,
showLine = _props3.showLine,
prefixCls = _props3.prefixCls,
@ -35346,7 +35347,14 @@
checkStrictly = _props3.checkStrictly,
tabIndexValue = _props3.tabIndexValue,
lazyLoad = _props3.lazyLoad,
getScrollContainer = _props3.getScrollContainer;
getScrollContainer = _props3.getScrollContainer,
defaultExpandedKeys = _props3.defaultExpandedKeys,
defaultSelectedKeys = _props3.defaultSelectedKeys,
defaultCheckedKeys = _props3.defaultCheckedKeys,
openAnimation = _props3.openAnimation,
draggable = _props3.draggable,
others = _objectWithoutProperties(_props3, ['showLine', 'prefixCls', 'className', 'focusable', 'checkable', 'loadData', 'checkStrictly', 'tabIndexValue', 'lazyLoad', 'getScrollContainer', 'defaultExpandedKeys', 'defaultSelectedKeys', 'defaultCheckedKeys', 'openAnimation', 'draggable']);
var _state = this.state,
treeData = _state.treeData,
flatTreeData = _state.flatTreeData;
@ -35448,7 +35456,7 @@
'ul',
_extends({}, domProps, { unselectable: 'true', ref: function ref(el) {
_this6.tree = el;
}, tabIndex: focusable && tabIndexValue }),
}, tabIndex: focusable && tabIndexValue }, others),
_react2['default'].createElement('li', { style: { height: preHeight }, className: 'u-treenode-start', key: 'tree_node_start' }),
_react2['default'].Children.map(treeChildren, this.renderTreeNode, this),
_react2['default'].createElement('li', { style: { height: sufHeight }, className: 'u-treenode-end', key: 'tree_node_end' })
@ -35457,7 +35465,7 @@
'ul',
_extends({}, domProps, { unselectable: 'true', ref: function ref(el) {
_this6.tree = el;
}, tabIndex: focusable && tabIndexValue }),
}, tabIndex: focusable && tabIndexValue }, others),
_react2['default'].Children.map(treeChildren, this.renderTreeNode, this)
);
};

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1008,7 +1008,11 @@ onExpand(treeNode,keyType) {
render() {
const props = this.props;
const { showLine, prefixCls, className, focusable, checkable, loadData, checkStrictly, tabIndexValue, lazyLoad, getScrollContainer } = this.props;
const {
showLine, prefixCls, className, focusable, checkable, loadData, checkStrictly, tabIndexValue, lazyLoad, getScrollContainer,
defaultExpandedKeys, defaultSelectedKeys, defaultCheckedKeys, openAnimation, draggable,
...others
} = this.props;
const { treeData,flatTreeData } = this.state;
let { startIndex, endIndex } = this, //数据截取的开始位置和结束位置
preHeight = 0, //前置占位高度
@ -1102,14 +1106,14 @@ onExpand(treeNode,keyType) {
getScrollParent={getScrollContainer}
store={this.store}
>
<ul {...domProps} unselectable="true" ref={(el)=>{this.tree = el}} tabIndex={focusable && tabIndexValue}>
<ul {...domProps} unselectable="true" ref={(el)=>{this.tree = el}} tabIndex={focusable && tabIndexValue} {...others}>
<li style={{height : preHeight}} className='u-treenode-start' key={'tree_node_start'}></li>
{ React.Children.map(treeChildren, this.renderTreeNode, this) }
<li style={{height : sufHeight}} className='u-treenode-end' key={'tree_node_end'}></li>
</ul>
</InfiniteScroll>
:
<ul {...domProps} unselectable="true" ref={(el)=>{this.tree = el}} tabIndex={focusable && tabIndexValue}>
<ul {...domProps} unselectable="true" ref={(el)=>{this.tree = el}} tabIndex={focusable && tabIndexValue} {...others}>
{ React.Children.map(treeChildren, this.renderTreeNode, this) }
</ul>
);