bee-table
Version:
Table ui component for react
746 lines (669 loc) • 27.7 kB
JavaScript
'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 _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _utils = require('./lib/utils');
var _TableCell = require('./TableCell');
var _TableCell2 = _interopRequireDefault(_TableCell);
var _ExpandIcon = require('./ExpandIcon');
var _ExpandIcon2 = _interopRequireDefault(_ExpandIcon);
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 propTypes = {
onDestroy: _propTypes2["default"].func,
onRowClick: _propTypes2["default"].func,
onRowDoubleClick: _propTypes2["default"].func,
record: _propTypes2["default"].object,
clsPrefix: _propTypes2["default"].string,
expandIconColumnIndex: _propTypes2["default"].number,
onHover: _propTypes2["default"].func,
columns: _propTypes2["default"].array,
height: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].number]),
visible: _propTypes2["default"].bool,
index: _propTypes2["default"].number,
hoverKey: _propTypes2["default"].any,
expanded: _propTypes2["default"].bool,
expandable: _propTypes2["default"].any,
onExpand: _propTypes2["default"].func,
needIndentSpaced: _propTypes2["default"].bool,
className: _propTypes2["default"].string,
indent: _propTypes2["default"].number,
indentSize: _propTypes2["default"].number,
expandIconAsCell: _propTypes2["default"].bool,
expandRowByClick: _propTypes2["default"].bool,
store: _propTypes2["default"].object.isRequired,
rowDraggAble: _propTypes2["default"].bool,
// onRowDragDrop: PropTypes.func, //拖拽行放置时触发
// onRowDragStart: PropTypes.func,//拖拽行开始时触发 传递参数:startRowKey,startRowIndex
// onRowDragEnter: PropTypes.func, //拖拽行经过时触发
syncRowHeight: _propTypes2["default"].bool
};
var defaultProps = {
onRowClick: function onRowClick() {},
// onRowDoubleClick() {},
onDestroy: function onDestroy() {},
expandIconColumnIndex: 0,
expandRowByClick: false,
onHover: function onHover() {},
className: '',
setRowParentIndex: function setRowParentIndex() {},
rowDraggAble: false,
syncRowHeight: false
};
var TableRow = function (_Component) {
_inherits(TableRow, _Component);
function TableRow(props) {
_classCallCheck(this, TableRow);
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
_this.stopRowDrag = function (isStop) {
var rowDraggAble = _this.props.rowDraggAble;
var notRowDrag = _this.state.notRowDrag;
if (rowDraggAble && isStop !== notRowDrag) {
_this.setState({
notRowDrag: isStop
});
}
};
_this.set = function (fn) {
_this.clear();
_this._timeout = window.setTimeout(fn, 300);
};
_this.clear = function (event) {
if (_this._timeout) {
window.clearTimeout(_this._timeout);
}
};
_this.bindElement = function (el) {
_this.element = el;
};
_this._timeout = null;
_this.state = {
hovered: false
};
_this.onRowClick = _this.onRowClick.bind(_this);
_this.onRowDoubleClick = _this.onRowDoubleClick.bind(_this);
_this.onMouseEnter = _this.onMouseEnter.bind(_this);
_this.onMouseLeave = _this.onMouseLeave.bind(_this);
_this.expandHeight = 0;
_this.event = false;
_this.cacheCurrentIndex = null;
_this.canBeTouch = true; //受否允许拖动该行
return _this;
}
TableRow.prototype.componentDidMount = function componentDidMount() {
var _this2 = this;
var _props = this.props,
store = _props.store,
hoverKey = _props.hoverKey,
syncHover = _props.syncHover,
treeType = _props.treeType;
this.unsubscribe = store.subscribe(function () {
if (store.getState().currentHoverKey !== null && store.getState().currentHoverKey !== undefined && store.getState().currentHoverKey === hoverKey && syncHover) {
_this2.setState({ hovered: true });
} else if (syncHover) {
// 显示hover状态,加hoverclass类名
if (_this2.state.hovered === true && store.getState().currentHoverKey !== hoverKey) {
// 原本是hover状态然后离开该行
_this2.setState({ hovered: false });
}
}
});
this.setRowHeight();
if (treeType) {
this.setRowParentIndex();
}
};
/**
* 事件初始化
*/
// initEvent=()=>{
// let events = [
// {key:'touchstart', fun:this.onTouchStart},//手指触摸到一个 DOM 元素时触发
// {key:'touchmove', fun:this.onTouchMove}, //手指在一个 DOM 元素上滑动时触发
// {key:'touchend', fun:this.onTouchEnd}, //手指从一个 DOM 元素上移开时触发
//
// {key:'dragstart',fun:this.onDragStart},//用户开始拖动元素时触发
// {key:'dragend',fun:this.onDragEnd},//用户结束拖动元素时触发
// {key:'dragover', fun:this.onDragOver},//当某被拖动的对象在另一对象容器范围内拖动时触发此事件
// // {key:'drop', fun:this.onDrop}, //在一个拖动过程中,释放鼠标键时触发此事件
// {key:'dragenter', fun:this.onDragEnter},
// // {key:'dragleave', fun:this.onDragLeave},
// ];
// this.eventListen(events,'',this.element);
// }
/**
* 事件移除,提供性能以及内存泄漏等问题。
*/
// removeDragAbleEvent=()=>{
// let events = [
// {key:'touchstart', fun:this.onTouchStart},//手指触摸到一个 DOM 元素时触发
// {key:'touchmove', fun:this.onTouchMove}, //手指在一个 DOM 元素上滑动时触发
// {key:'touchend', fun:this.onTouchEnd}, //手指从一个 DOM 元素上移开时触发
//
// // {key:'dragstart',fun:this.onDragStart},//用户开始拖动元素时触发
// {key:'dragend',fun:this.onDragEnd},//用户结束拖动元素时触发
// {key:'dragover', fun:this.onDragOver},//当某被拖动的对象在另一对象容器范围内拖动时触发此事件
// // {key:'drop', fun:this.onDrop}, //在一个拖动过程中,释放鼠标键时触发此事件
// {key:'dragenter', fun:this.onDragEnter},
// // {key:'dragleave', fun:this.onDragLeave},
// ];
// this.eventListen(events,'remove',this.element);
// }
/**
* 事件绑定和移除函数
*/
// eventListen(events,type,eventSource){
// for (let i = 0; i < events.length; i++) {
// const _event = events[i];
// if(type === "remove"){
// EventUtil.removeHandler(eventSource,_event.key,_event.fun);
// }else{
// EventUtil.addHandler(eventSource,_event.key,_event.fun);
// }
// }
// }
/**
* 【交换行】开始拖拽
*/
/* onDragStart = (e) => {
let {onRowDragStart,contentTable} = this.props;
if (!this.props.rowDraggAble || this.notRowDrag) return;
let event = Event.getEvent(e) ,
target = Event.getTarget(event);
if(target.nodeName.toUpperCase() !== "TR")return;//如果是TD,则继续冒泡至TR
let dragStartKey = target.getAttribute("data-row-key");
let dragStartIndex = target.getAttribute("data-row-index");
console.log("AAA---row-1--onDragStart"+dragStartKey)
event.dataTransfer.effectAllowed = "move";
event.dataTransfer.setData("Text", JSON.stringify({dragStartKey, dragStartIndex}));
if(contentTable){
contentTable.dragStartKey = dragStartKey;
contentTable.dragStartIndex = dragStartIndex;
}
onRowDragStart && onRowDragStart({dragStartKey, dragStartIndex});
}*/
/**
* 【交换行】结束拖拽
*/
/* onDragEnd = (e) =>{
if (!this.props.rowDraggAble || this.notRowDrag) return;
let {onRowDragDrop,contentTable} = this.props;
let event = Event.getEvent(e) ,
target = Event.getTarget(event);
if(target.nodeName.toUpperCase() !== "TR")return;//如果是TD,则继续冒泡至TR
if(!contentTable)return;
let {dragStartKey,dragStartIndex,dragEnterKey,dragEnterIndex} = contentTable||{};
console.log("AAA---row-3--onDragEnd:"+dragStartKey+"->"+dragEnterKey)
onRowDragDrop && onRowDragDrop({dragTargetKey:dragStartKey,dragTargetIndex:dragStartIndex,dropTargetKey:dragEnterKey,dropTargetIndex:dragEnterIndex});
}*/
/*onDragOver = (e) => {
let event = Event.getEvent(e);
event.preventDefault();
};*/
/**
* 【交换行】拖拽释放
*/
/*
onDrop = (e) => {
let {onRowDragDrop} = this.props;
let event = Event.getEvent(e) ,
_target = Event.getTarget(event),
target = _target.parentNode;
// event.preventDefault()
// event.stopPropagation();
let dropTargetKey = target.getAttribute("data-row-key");
let dropTargetIndex = target.getAttribute("data-row-index");
if(!dropTargetKey || dropTargetKey === dragStartKey)return;
if(target.nodeName.toUpperCase() === "TR"){
this.synchronizeTableTr(dragStartKey,null);
this.synchronizeTableTr(targetKey,null);
}
};
*/
/**
* 获取当前触摸的Dom节点
*/
/* getTouchDom = (event) => {
let currentLocation = event.changedTouches[0];
let realTarget = document.elementFromPoint(currentLocation.clientX, currentLocation.clientY);
return realTarget;
}*/
/**
* 开始调整交换行的事件
*/
/* onTouchStart = (e) => {
e.stopPropagation()
let event = Event.getEvent(e) ,
_target = Event.getTarget(event),
target = _target.parentNode;
if (target.tagName === 'TR') {
this.onDragStart(e);
}else{
this.canBeTouch = false
}
}*/
/*onTouchMove = (e) => {
if (!this.canBeTouch) return;
e.stopPropagation()
let event = Event.getEvent(e);
event.preventDefault();
let touchTarget = this.getTouchDom(event),
target = touchTarget.parentNode,
targetKey = target.getAttribute("data-row-key");
if(!targetKey || targetKey === this.dragStartKey)return;
if(target.nodeName.toUpperCase() === "TR"){
if(this.cacheCurrentIndex !== targetKey){ //模拟 touchenter toucheleave 事件
this.cacheCurrentIndex && this.synchronizeTableTr(this.cacheCurrentIndex,null); //去掉虚线
this.synchronizeTableTr(targetKey,true); //添加虚线
}
}
}*/
/**
* 手指移开时触发
*/
/*onTouchEnd = (e) => {
if(!this.canBeTouch){
this.canBeTouch = true
return
}
e.stopPropagation()
let {onRowDragDrop} = this.props;
let event = Event.getEvent(e),
dragStartKey = this.dragStartKey, //拖拽行的key
touchTarget = this.getTouchDom(event), //当前触摸的DOM节点
target = touchTarget.parentNode, //目标位置的行
targetKey = target.getAttribute("data-row-key"); //目标位置的行key
if(!targetKey || targetKey === dragStartKey)return;
if(target.nodeName.toUpperCase() === "TR"){
this.synchronizeTableTr(dragStartKey,null);
this.synchronizeTableTr(targetKey,null);
}
onRowDragDrop && onRowDragDrop(dragStartKey,targetKey);
}*/
/**
*同步当前拖拽到阴影
* @memberof TableRow
*/
/* synchronizeTableTrShadow = ()=>{
let {contentTable,index} = this.props;
let cont = contentTable.querySelector(`.${prefix}-table-scroll table tbody`).getElementsByTagName("tr")[index],
trs = cont.getBoundingClientRect(),
fixed_left_trs = contentTable.querySelector(`.${prefix}-table-fixed-left table tbody`),
fixed_right_trs = contentTable.querySelector(`.${prefix}-table-fixed-right table tbody`);
fixed_left_trs = fixed_left_trs && fixed_left_trs.getElementsByTagName("tr")[index].getBoundingClientRect();
fixed_right_trs = fixed_right_trs && fixed_right_trs.getElementsByTagName("tr")[index].getBoundingClientRect()
let div = document.createElement("div");
let style = "wdith:"+(trs.width + (fixed_left_trs ? fixed_left_trs.width : 0) + (fixed_right_trs ? fixed_right_trs.width : 0))+"px";
style += ";height:"+ trs.height+"px";
style += ";classname:"+ cont.className;
div.setAttribute("style",style);
return div;
}*/
/**
* 同步自己,也需要同步当前行的行显示
*/
/*
synchronizeTableTr = (dragStartKey,type)=>{
if(type){ //同步 this.cacheCurrentIndex
this.cacheCurrentIndex = dragStartKey;
}
let {contentTable} = this.props;
let _table_trs = contentTable.querySelector(`.${prefix}-table-scroll table tbody`),
_table_fixed_left_trs = contentTable.querySelector(`.${prefix}-table-fixed-left table tbody`),
_table_fixed_right_trs = contentTable.querySelector(`.${prefix}-table-fixed-right table tbody`);
_table_trs = _table_trs?_table_trs:contentTable.querySelector(`.${prefix}-table table tbody`);
this.synchronizeTrStyle(_table_trs,dragStartKey,type);
if(_table_fixed_left_trs){
this.synchronizeTrStyle(_table_fixed_left_trs,dragStartKey,type);
}
if(_table_fixed_right_trs){
this.synchronizeTrStyle(_table_fixed_right_trs,dragStartKey,type);
}
}
*/
/**
* 设置同步的style
*/
/*
synchronizeTrStyle = (_elementBody,id,type)=>{
let {contentTable} = this.props,
trs = _elementBody.getElementsByTagName("tr"),
currentObj;
for (let index = 0; index < trs.length; index++) {
const element = trs[index];
if(element.getAttribute("data-row-key") == id){
currentObj = element;
}
}
if(type == 'down'){
currentObj && currentObj.setAttribute("style","border-bottom:2px solid #02B1FD");
}else if(type){
currentObj && currentObj.setAttribute("style","border-top:2px solid #02B1FD");
}else{
currentObj && currentObj.setAttribute("style","");
}
}
*/
/**
* 【交换行】拖拽经过目标行
*/
/*onDragEnter = (e) => {
const {onRowDragEnter,contentTable} = this.props;
let event = Event.getEvent(e) ,
_target = Event.getTarget(event),target = _target.parentNode;
if(target.nodeName.toUpperCase() !== "TR")return;//如果是TD,则继续冒泡至TR
if(!contentTable)return;
let dragEnterKey = target.getAttribute("data-row-key");
let dragEnterIndex = target.getAttribute("data-row-index");
if(!dragEnterKey)return;
if(dragEnterKey !== contentTable.dragStartKey){
contentTable.dragEnterKey = dragEnterKey;
contentTable.dragEnterIndex = dragEnterIndex;
onRowDragEnter && onRowDragEnter(dragEnterKey,parseInt(dragEnterIndex) >= parseInt(contentTable.dragStartIndex)+1 ? 'bottom' : 'top',target);
console.log("AAAA---1.1--enter-->"+contentTable.dragStartIndex+"->"+dragEnterIndex)
}else{
contentTable.dragEnterKey = null;
contentTable.dragEnterIndex = null;
console.log("AAAA---1.1--enter-hidden-->"+contentTable.dragStartIndex+"->"+dragEnterIndex)
onRowDragEnter && onRowDragEnter(dragEnterKey,null,null);
}
}*/
/**
* 【交换行】拖拽离开目标行
*/
/*
onDragLeave = (e) => {
let event = Event.getEvent(e) ,
_target = Event.getTarget(event),target = _target.parentNode;
let dragLeaveKey = target.getAttribute("data-row-key");
if(!dragLeaveKey || dragLeaveKey === this.dragStartKey)return;
if(target.nodeName.toUpperCase() === "TR"){
this.synchronizeTableTr(dragLeaveKey,null);
}
}
*/
TableRow.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
var _props2 = this.props,
rowDraggAble = _props2.rowDraggAble,
syncRowHeight = _props2.syncRowHeight;
// if(!this.event){
// this.event = true;
// if(rowDraggAble){
// console.time("AABB");
// this.removeDragAbleEvent();
// this.initEvent();
// console.timeEnd("AABB");
// }
// }
if (this.props.treeType) {
this.setRowParentIndex();
}
// if(syncRowHeight){
// this.setRowHeight()
// }
this.setRowHeight();
};
TableRow.prototype.componentWillUnmount = function componentWillUnmount() {
var _props3 = this.props,
record = _props3.record,
onDestroy = _props3.onDestroy,
index = _props3.index,
rowDraggAble = _props3.rowDraggAble;
onDestroy(record, index);
if (this.unsubscribe) {
this.unsubscribe();
}
// if(rowDraggAble){
// this.removeDragAbleEvent();
// }
};
TableRow.prototype.setRowHeight = function setRowHeight() {
var _props4 = this.props,
setRowHeight = _props4.setRowHeight,
_props4$expandedConte = _props4.expandedContentHeight,
expandedContentHeight = _props4$expandedConte === undefined ? 0 : _props4$expandedConte,
fixed = _props4.fixed,
fixedIndex = _props4.fixedIndex,
isExpandedRow = _props4.isExpandedRow;
if (!setRowHeight || !this.element || fixed) return;
// setRowHeight(this.element.clientHeight + expandedContentHeight, fixedIndex,this.getRecordKey())
setRowHeight(this.element.clientHeight, fixedIndex, this.getRecordKey(), isExpandedRow);
};
TableRow.prototype.setRowParentIndex = function setRowParentIndex() {
var _props5 = this.props,
index = _props5.index,
setRowParentIndex = _props5.setRowParentIndex,
fixedIndex = _props5.fixedIndex,
rootIndex = _props5.rootIndex;
setRowParentIndex(rootIndex < 0 ? index : rootIndex, fixedIndex);
};
TableRow.prototype.onRowClick = function onRowClick(event) {
// fix: 解决 onRowClick 回调函数中,事件对象属性均为 null 的问题
// 异步访问事件属性
// 调用 event.persist() 会从事件池中移除该合成函数并允许对该合成事件的引用被保留下来。
event.persist();
var _props6 = this.props,
record = _props6.record,
index = _props6.index,
onRowClick = _props6.onRowClick,
expandable = _props6.expandable,
expandRowByClick = _props6.expandRowByClick,
expanded = _props6.expanded,
onExpand = _props6.onExpand,
fixedIndex = _props6.fixedIndex,
onRowDoubleClick = _props6.onRowDoubleClick;
if (expandable && expandRowByClick) {
onExpand(!expanded, record, fixedIndex, event);
}
if (!onRowDoubleClick) {
onRowClick(record, fixedIndex, event);
return;
}
this.set(function (e) {
onRowClick(record, fixedIndex, event);
});
};
TableRow.prototype.onRowDoubleClick = function onRowDoubleClick(event) {
var _props7 = this.props,
record = _props7.record,
index = _props7.index,
onRowDoubleClick = _props7.onRowDoubleClick,
fixedIndex = _props7.fixedIndex;
this.clear();
onRowDoubleClick && onRowDoubleClick(record, fixedIndex, event);
};
TableRow.prototype.onMouseEnter = function onMouseEnter(e) {
var _props8 = this.props,
onHover = _props8.onHover,
hoverKey = _props8.hoverKey,
fixedIndex = _props8.fixedIndex,
syncHover = _props8.syncHover,
record = _props8.record;
if (syncHover) {
this.setState({ hovered: true });
}
onHover(true, hoverKey, e, fixedIndex, record);
};
TableRow.prototype.onMouseLeave = function onMouseLeave(e) {
var _props9 = this.props,
onHover = _props9.onHover,
hoverKey = _props9.hoverKey,
fixedIndex = _props9.fixedIndex,
syncHover = _props9.syncHover,
record = _props9.record;
if (syncHover) {
this.setState({ hovered: false });
}
onHover(false, hoverKey, e, fixedIndex, record);
};
//TODO column.notRowDrag供TableCell禁用行拖拽,待优化
//获取当前行唯一键值
TableRow.prototype.getRecordKey = function getRecordKey() {
var _props10 = this.props,
record = _props10.record,
hoverKey = _props10.hoverKey;
return record && record.key ? record.key : hoverKey;
};
TableRow.prototype.render = function render() {
var _props11 = this.props,
clsPrefix = _props11.clsPrefix,
columns = _props11.columns,
record = _props11.record,
height = _props11.height,
visible = _props11.visible,
index = _props11.index,
onPaste = _props11.onPaste,
hasLeftFixed = _props11.hasLeftFixed,
expandIconColumnIndex = _props11.expandIconColumnIndex,
expandIconAsCell = _props11.expandIconAsCell,
expanded = _props11.expanded,
useDragHandle = _props11.useDragHandle,
rowDraggAble = _props11.rowDraggAble,
expandable = _props11.expandable,
onExpand = _props11.onExpand,
needIndentSpaced = _props11.needIndentSpaced,
indent = _props11.indent,
indentSize = _props11.indentSize,
isHiddenExpandIcon = _props11.isHiddenExpandIcon,
fixed = _props11.fixed,
bodyDisplayInRow = _props11.bodyDisplayInRow,
expandedIcon = _props11.expandedIcon,
collapsedIcon = _props11.collapsedIcon,
hoverKey = _props11.hoverKey,
lazyStartIndex = _props11.lazyStartIndex,
lazyEndIndex = _props11.lazyEndIndex,
expandIconCellWidth = _props11.expandIconCellWidth,
getCellClassName = _props11.getCellClassName;
var notRowDrag = this.state.notRowDrag;
// const isEmptyTr = isPre || isSuf//暂时不用 滚动loading相关
var showSum = false;
var cls = [];
if (clsPrefix) {
cls.push(clsPrefix);
}
var className = this.props.className;
if (this.state.hovered) {
className += ' ' + clsPrefix + '-hover';
}
//判断是否为合计行
if (className.indexOf('sumrow') > -1) {
showSum = true;
}
var cells = [];
var expandIcon = _react2["default"].createElement(_ExpandIcon2["default"], {
expandable: expandable,
clsPrefix: clsPrefix,
onExpand: onExpand,
needIndentSpaced: needIndentSpaced,
expanded: expanded,
record: record,
expandedIcon: expandedIcon,
collapsedIcon: collapsedIcon,
isHiddenExpandIcon: isHiddenExpandIcon
});
var expandIndexInThisTable;
if (this.props.fixed === 'right') {
expandIndexInThisTable = expandIconColumnIndex - this.props.leftColumnsLength - this.props.centerColumnsLength;
} else {
expandIndexInThisTable = expandIconColumnIndex;
}
for (var i = 0; i < columns.length; i++) {
var createExpandIconCell = false;
if (i == 0) {
if (hasLeftFixed && fixed == 'left' && expandIconAsCell) {
//存在左侧固定列则在左侧固定区域下渲染展开列
createExpandIconCell = true;
} else if (!hasLeftFixed && !fixed && expandIconAsCell) {
//不存在左侧固定列则在中间区域第一列渲染展开列
createExpandIconCell = true;
}
if (createExpandIconCell) {
showSum ? cells.push(_react2["default"].createElement('td', { width: expandIconCellWidth, dangerouslySetInnerHTML: { __html: ' ' } })) : cells.push(_react2["default"].createElement(
'td',
{
className: clsPrefix + '-expand-icon-cell',
key: clsPrefix + '-expand-icon-cell-' + i,
width: expandIconCellWidth
},
expandIcon
));
}
}
// bugfix 设置expandRowByClick,无法显示箭头,去掉 expandRowByClick 判断
var isColumnHaveExpandIcon = expandIconAsCell || showSum ? false : i === expandIndexInThisTable;
//注意:中间表格区域不需要渲染出固定列的单元格,以节省多余的性能消耗
if (!fixed && columns[i].fixed) continue;
cells.push(_react2["default"].createElement(_TableCell2["default"], {
clsPrefix: clsPrefix,
record: record,
indentSize: indentSize,
indent: indent,
index: index,
column: columns[i],
key: index + "_" + (columns[i].key || columns[i].dataIndex || i),
fixed: fixed,
showSum: showSum,
expandIcon: isColumnHaveExpandIcon ? expandIcon : null,
bodyDisplayInRow: bodyDisplayInRow,
lazyStartIndex: lazyStartIndex,
lazyEndIndex: lazyEndIndex,
onPaste: onPaste,
stopRowDrag: this.stopRowDrag,
col: i,
getCellClassName: getCellClassName
}));
}
var style = _extends({ height: height }, record ? record.style : undefined);
if (!visible) {
style.display = 'none';
}
if (record && record._checked) {
className += ' selected';
}
if (rowDraggAble && !useDragHandle && !notRowDrag) {
className += ' row-dragg-able';
}
if (className) {
cls.push(className);
}
if (clsPrefix && indent) {
cls.push(clsPrefix + '-level-' + indent);
}
// const tdStyle = !isEmptyTr ? {} : this.getLoadingStyle(isPre, isSuf)//暂时不用 滚动loading相关
return _react2["default"].createElement(
'tr',
{
draggable: rowDraggAble && !useDragHandle && !notRowDrag,
onClick: this.onRowClick,
onDoubleClick: this.onRowDoubleClick,
onMouseEnter: this.onMouseEnter,
onMouseLeave: this.onMouseLeave,
className: cls.join(' '),
style: style,
'data-for-table': this.props.tableUid,
'data-row-key': this.getRecordKey(),
'data-row-index': this.props.fixedIndex
// key={hoverKey}
, ref: this.bindElement
},
cells.length > 0 ? cells : _react2["default"].createElement('td', { style: { width: 0, padding: 0 } })
);
};
return TableRow;
}(_react.Component);
TableRow.defaultProps = {
tableUid: null
};
;
TableRow.propTypes = propTypes;
TableRow.defaultProps = defaultProps;
exports["default"] = TableRow;
module.exports = exports['default'];