fix: add loading text for infinite table

This commit is contained in:
gx 2021-03-29 01:53:18 +08:00
parent 3ccd8210a2
commit 1ed2de9c61
11 changed files with 182 additions and 25 deletions

View File

@ -902,3 +902,17 @@
line-height: 30px; }
.u-dropdown ul.u-table-inline-op-dropdowm li.u-dropdown-menu-item i.uf {
font-size: 12px; }
.loading-td {
position: relative !important;
display: block !important; }
.loading-td.pre-td {
bottom: 0; }
.loading-div {
position: absolute;
border: none !important; }
.loading-div.pre {
bottom: 0; }
.loading-div.suf {
top: 0; }

View File

@ -982,7 +982,7 @@ var Table = function (_Component) {
var expandIconAsCell = fixed !== 'right' ? props.expandIconAsCell : false;
var expandIconColumnIndex = props.expandIconColumnIndex;
if (props.lazyLoad && props.lazyLoad.preHeight && indent == 0) {
rst.push(_react2["default"].createElement(_TableRow2["default"], { onPaste: onPaste, height: props.lazyLoad.preHeight, columns: [], className: '', key: 'table_row_first', store: this.store, visible: true }));
rst.push(_react2["default"].createElement(_TableRow2["default"], { onPaste: onPaste, containerWidth: this.contentDomWidth, isPre: true, height: props.lazyLoad.preHeight, columns: [], className: '', key: 'table_row_first', store: this.store, visible: true }));
}
var lazyCurrentIndex = props.lazyLoad && props.lazyLoad.startIndex ? props.lazyLoad.startIndex : 0;
var lazyParentIndex = props.lazyLoad && props.lazyLoad.startParentIndex ? props.lazyLoad.startParentIndex : 0;
@ -1115,7 +1115,7 @@ var Table = function (_Component) {
}
if (props.lazyLoad && props.lazyLoad.sufHeight && indent == 0) {
rst.push(_react2["default"].createElement(_TableRow2["default"], { onPaste: onPaste, height: props.lazyLoad.sufHeight, key: 'table_row_end', columns: [], className: '', store: this.store, visible: true }));
rst.push(_react2["default"].createElement(_TableRow2["default"], { onPaste: onPaste, containerWidth: this.contentDomWidth, isSuf: true, height: props.lazyLoad.sufHeight, key: 'table_row_end', columns: [], className: '', store: this.store, visible: true }));
}
if (!this.isTreeType) {
this.treeType = false;

View File

@ -345,6 +345,15 @@ var TableRow = function (_Component) {
_this.element = el;
};
_this.getLoadingStyle = function (isPre, isSuf) {
if (isPre) {
return _this.element && _this.element.nextSibling ? _this.element.nextSibling.getBoundingClientRect() : {};
}
if (isSuf) {
return _this.element && _this.element.previousSibling ? _this.element.previousSibling.getBoundingClientRect() : {};
}
};
_this._timeout = null;
_this.state = {
hovered: false
@ -583,6 +592,9 @@ var TableRow = function (_Component) {
visible = _props10.visible,
index = _props10.index,
onPaste = _props10.onPaste,
isPre = _props10.isPre,
isSuf = _props10.isSuf,
containerWidth = _props10.containerWidth,
expandIconColumnIndex = _props10.expandIconColumnIndex,
expandIconAsCell = _props10.expandIconAsCell,
expanded = _props10.expanded,
@ -605,6 +617,7 @@ var TableRow = function (_Component) {
getCellClassName = _props10.getCellClassName;
var notRowDrag = this.state.notRowDrag;
var isEmptyTr = isPre || isSuf;
var showSum = false;
var className = this.props.className;
@ -680,7 +693,7 @@ var TableRow = function (_Component) {
if (rowDraggAble && !useDragHandle && !notRowDrag) {
className += ' row-dragg-able';
}
var tdStyle = !isEmptyTr ? {} : this.getLoadingStyle(isPre, isSuf);
return _react2["default"].createElement(
'tr',
{
@ -696,7 +709,15 @@ var TableRow = function (_Component) {
// key={hoverKey}
, ref: this.bindElement
},
cells.length > 0 ? cells : _react2["default"].createElement('td', { style: { width: 0, padding: 0 } })
cells.length > 0 ? cells : isEmptyTr ? _react2["default"].createElement(
'td',
{ className: 'loading-td ' + (isPre ? 'pre-td' : 'suf-td'), style: { width: tdStyle.width || 1200, height: tdStyle.height || 100 } },
_react2["default"].createElement(
'div',
{ style: { left: (containerWidth || 1200) / 2 - 23 }, className: 'loading-div ' + (isPre ? 'pre' : 'suf') },
'\u52A0\u8F7D\u4E2D...'
)
) : _react2["default"].createElement('td', { style: { width: 0, padding: 0 } })
);
};

14
dist/demo.css vendored
View File

@ -894,6 +894,20 @@
.u-dropdown ul.u-table-inline-op-dropdowm li.u-dropdown-menu-item i.uf {
font-size: 12px; }
.loading-td {
position: relative !important;
display: block !important; }
.loading-td.pre-td {
bottom: 0; }
.loading-div {
position: absolute;
border: none !important; }
.loading-div.pre {
bottom: 0; }
.loading-div.suf {
top: 0; }
.selected {
background: #FFF7E7; }

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

99
dist/demo.js vendored
View File

@ -48443,8 +48443,6 @@
// 此处应该对比一下实际的
if (this.computeWidth > this.contentDomWidth) {
this.bodyTable.style.overflowX = 'scroll';
} else {
this.bodyTable.style.overflowX = 'hidden';
}
}
}
@ -48893,7 +48891,7 @@
var expandIconAsCell = fixed !== 'right' ? props.expandIconAsCell : false;
var expandIconColumnIndex = props.expandIconColumnIndex;
if (props.lazyLoad && props.lazyLoad.preHeight && indent == 0) {
rst.push(_react2['default'].createElement(_TableRow2['default'], { onPaste: onPaste, height: props.lazyLoad.preHeight, columns: [], className: '', key: 'table_row_first', store: this.store, visible: true }));
rst.push(_react2['default'].createElement(_TableRow2['default'], { onPaste: onPaste, containerWidth: this.contentDomWidth, isPre: true, height: props.lazyLoad.preHeight, columns: [], className: '', key: 'table_row_first', store: this.store, visible: true }));
}
var lazyCurrentIndex = props.lazyLoad && props.lazyLoad.startIndex ? props.lazyLoad.startIndex : 0;
var lazyParentIndex = props.lazyLoad && props.lazyLoad.startParentIndex ? props.lazyLoad.startParentIndex : 0;
@ -49026,7 +49024,7 @@
}
if (props.lazyLoad && props.lazyLoad.sufHeight && indent == 0) {
rst.push(_react2['default'].createElement(_TableRow2['default'], { onPaste: onPaste, height: props.lazyLoad.sufHeight, key: 'table_row_end', columns: [], className: '', store: this.store, visible: true }));
rst.push(_react2['default'].createElement(_TableRow2['default'], { onPaste: onPaste, containerWidth: this.contentDomWidth, isSuf: true, height: props.lazyLoad.sufHeight, key: 'table_row_end', columns: [], className: '', store: this.store, visible: true }));
}
if (!this.isTreeType) {
this.treeType = false;
@ -49156,7 +49154,7 @@
innerBodyStyle.overflowY = bodyStyle.overflowY || 'scroll';
if (this.computeWidth > this.contentDomWidth) {
innerBodyStyle.overflowX = 'scroll';
} else {
} else if (this.contentWidth === this.contentDomWidth) {
innerBodyStyle.overflowX = 'hidden';
}
} else {
@ -49230,6 +49228,9 @@
if (!fixed && _this4.contentDomWidth < _this4.contentWidth) {
tableStyle.width = _this4.contentWidth - _this4.columnManager.getLeftColumnsWidth(_this4.contentWidth) - _this4.columnManager.getRightColumnsWidth(_this4.contentWidth);
}
if (_this4.bodyTable && !fixed && _this4.contentDomWidth === _this4.contentWidth) {
tableStyle.width = _this4.bodyTable.clientWidth;
}
var tableBody = hasBody ? getBodyWrapper(_react2['default'].createElement(
'tbody',
{ className: clsPrefix + '-tbody', onMouseLeave: _this4.onBodyMouseLeave },
@ -49421,7 +49422,8 @@
headerHeight = _props9.headerHeight,
columns = _props9.columns,
heightConsistent = _props9.heightConsistent,
bodyDisplayInRow = _props9.bodyDisplayInRow;
bodyDisplayInRow = _props9.bodyDisplayInRow,
lazyLoad = _props9.lazyLoad;
var headRows = this.headTable ? this.headTable.querySelectorAll('thead') : this.bodyTable.querySelectorAll('thead');
var expandedRows = this.bodyTable.querySelectorAll('.' + clsPrefix + '-expanded-row') || [];
@ -50110,6 +50112,15 @@
_this.element = el;
};
_this.getLoadingStyle = function (isPre, isSuf) {
if (isPre) {
return _this.element && _this.element.nextSibling ? _this.element.nextSibling.getBoundingClientRect() : {};
}
if (isSuf) {
return _this.element && _this.element.previousSibling ? _this.element.previousSibling.getBoundingClientRect() : {};
}
};
_this._timeout = null;
_this.state = {
hovered: false
@ -50348,6 +50359,9 @@
visible = _props10.visible,
index = _props10.index,
onPaste = _props10.onPaste,
isPre = _props10.isPre,
isSuf = _props10.isSuf,
containerWidth = _props10.containerWidth,
expandIconColumnIndex = _props10.expandIconColumnIndex,
expandIconAsCell = _props10.expandIconAsCell,
expanded = _props10.expanded,
@ -50370,6 +50384,7 @@
getCellClassName = _props10.getCellClassName;
var notRowDrag = this.state.notRowDrag;
var isEmptyTr = isPre || isSuf;
var showSum = false;
var className = this.props.className;
@ -50445,7 +50460,7 @@
if (rowDraggAble && !useDragHandle && !notRowDrag) {
className += ' row-dragg-able';
}
var tdStyle = !isEmptyTr ? {} : this.getLoadingStyle(isPre, isSuf);
return _react2['default'].createElement(
'tr',
{
@ -50461,7 +50476,15 @@
// key={hoverKey}
, ref: this.bindElement
},
cells.length > 0 ? cells : _react2['default'].createElement('td', { style: { width: 0, padding: 0 } })
cells.length > 0 ? cells : isEmptyTr ? _react2['default'].createElement(
'td',
{ className: 'loading-td ' + (isPre ? 'pre-td' : 'suf-td'), style: { width: tdStyle.width || 1200, height: tdStyle.height || 100 } },
_react2['default'].createElement(
'div',
{ style: { left: (containerWidth || 1200) / 2 - 23 }, className: 'loading-div ' + (isPre ? 'pre' : 'suf') },
'\u52A0\u8F7D\u4E2D...'
)
) : _react2['default'].createElement('td', { style: { width: 0, padding: 0 } })
);
};
@ -50490,6 +50513,7 @@
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; };
exports.measureScrollbar = measureScrollbar;
exports.myBrowser = myBrowser;
exports.debounce = debounce;
exports.warningOnce = warningOnce;
exports.getOffset = getOffset;
@ -50557,6 +50581,30 @@
return scrollbarSize;
}
function myBrowser() {
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
var isOpera = userAgent.indexOf("Opera") > -1;
if (isOpera) {
//判断是否Opera浏览器
return "Opera";
}
if (userAgent.indexOf("Firefox") > -1) {
//判断是否Firefox浏览器
return "FF";
}
if (userAgent.indexOf("Chrome") > -1) {
return "Chrome";
}
if (userAgent.indexOf("Safari") > -1) {
//判断是否Safari浏览器
return "Safari";
}
if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
//判断是否IE浏览器
return "IE";
}
}
function debounce(func, wait, immediate) {
var timeout = void 0;
return function debounceFunc() {
@ -62002,8 +62050,10 @@
};
TableHeader.prototype.doEventList = function doEventList(trs, action) {
for (var index = 0; index < trs.length; index++) {
action(trs[index]);
if (trs && HTMLCollection.prototype.isPrototypeOf(trs) && action) {
for (var index = 0; index < trs.length; index++) {
action(trs[index]);
}
}
};
@ -62562,14 +62612,15 @@
_this7.optTableMargin(_this7.table.fixedRighHeadertTable, 0);
}
} else {
var scrollContainers = _this7.table.tableBody.querySelectorAll('.scroll-container') || [];
if (showScroll < 0) {
_this7.table.tableBody.style.overflowX = 'auto';
scrollContainers[0] ? scrollContainers[0].style.overflowX = 'auto' : null;
_this7.optTableMargin(_this7.table.fixedLeftBodyTable, '-' + scrollbarWidth);
_this7.optTableMargin(_this7.table.fixedRightBodyTable, '-' + scrollbarWidth);
_this7.optTableScroll(_this7.table.fixedLeftBodyTable, { x: 'scroll' });
_this7.optTableScroll(_this7.table.fixedRightBodyTable, { x: 'scroll' });
} else {
_this7.table.tableBody.style.overflowX = 'hidden';
scrollContainers[0] ? scrollContainers[0].style.overflowX = 'hidden' : null;
_this7.optTableMargin(_this7.table.fixedLeftBodyTable, 0);
_this7.optTableMargin(_this7.table.fixedRightBodyTable, 0);
_this7.optTableScroll(_this7.table.fixedLeftBodyTable, { x: 'auto' });
@ -62600,6 +62651,22 @@
} else {
contentTablePar.style.marginRight = _this7.drag.contentTableMR + diff + 'px';
}
var containerWidth = contentTablePar.getBoundingClientRect().width;
var tableWidth = _this7.table.innerTableBody.getBoundingClientRect().width;
var _scrollContainers = _this7.table.tableBody.querySelectorAll('.scroll-container') || [];
if (tableWidth > containerWidth) {
_scrollContainers[0] ? _scrollContainers[0].style.overflowX = 'auto' : null;
_this7.optTableMargin(_this7.table.fixedLeftBodyTable, '-' + scrollbarWidth);
_this7.optTableMargin(_this7.table.fixedRightBodyTable, '-' + scrollbarWidth);
_this7.optTableScroll(_this7.table.fixedLeftBodyTable, { x: 'scroll' });
_this7.optTableScroll(_this7.table.fixedRightBodyTable, { x: 'scroll' });
} else {
_scrollContainers[0] ? _scrollContainers[0].style.overflowX = 'hidden' : null;
_this7.optTableMargin(_this7.table.fixedLeftBodyTable, 0);
_this7.optTableMargin(_this7.table.fixedRightBodyTable, 0);
_this7.optTableScroll(_this7.table.fixedLeftBodyTable, { x: 'auto' });
_this7.optTableScroll(_this7.table.fixedRightBodyTable, { x: 'auto' });
}
}
} else {
_this7.drag.newWidth = _this7.minWidth;
@ -62643,7 +62710,13 @@
var innerTable = table.querySelector('.u-table-body-inner');
if (innerTable) {
//fixbug: 拖拽列宽后,滚动条滚到表格底部,会导致固定列和非固定列错行
overflow.x && (innerTable.style.overflowX = overflow.x);
if (overflow.x) {
var fixedScrollContainers = innerTable.querySelectorAll('.fixed-scroll-container');
if (fixedScrollContainers && fixedScrollContainers.length) {
fixedScrollContainers[0] && (fixedScrollContainers[0].style.overflowX = overflow.x);
fixedScrollContainers[1] && (fixedScrollContainers[1].style.overflowX = overflow.x);
}
}
overflow.y && (innerTable.style.overflowY = overflow.y);
}
}

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "bee-table",
"version": "2.3.15-beta.16",
"version": "2.3.15-beta.17",
"description": "Table ui component for react",
"keywords": [
"react",

View File

@ -780,7 +780,7 @@ class Table extends Component {
const expandIconColumnIndex = props.expandIconColumnIndex
if(props.lazyLoad && props.lazyLoad.preHeight && indent == 0){
rst.push(
<TableRow onPaste={onPaste} height={props.lazyLoad.preHeight} columns={[]} className='' key={'table_row_first'} store={this.store} visible = {true}/>
<TableRow onPaste={onPaste} containerWidth={this.contentDomWidth} isPre height={props.lazyLoad.preHeight} columns={[]} className='' key={'table_row_first'} store={this.store} visible = {true}/>
)
}
const lazyCurrentIndex = props.lazyLoad && props.lazyLoad.startIndex ?props.lazyLoad.startIndex :0;
@ -923,7 +923,7 @@ class Table extends Component {
if(props.lazyLoad && props.lazyLoad.sufHeight && indent == 0){
rst.push(
<TableRow onPaste={onPaste} height={props.lazyLoad.sufHeight} key={'table_row_end'} columns={[]} className='' store={this.store} visible = {true}/>
<TableRow onPaste={onPaste} containerWidth={this.contentDomWidth} isSuf height={props.lazyLoad.sufHeight} key={'table_row_end'} columns={[]} className='' store={this.store} visible = {true}/>
)
}
if (!this.isTreeType) {

View File

@ -1139,3 +1139,22 @@ $icon-color:#505F79;
}
}
}
.loading-td {
position: relative !important;
display: block !important;
&.pre-td {
bottom: 0;
}
}
.loading-div {
position: absolute;
border: none !important;
&.pre {
bottom: 0;
}
&.suf {
top: 0;
}
}

View File

@ -467,14 +467,24 @@ class TableRow extends Component{
this.element = el
}
getLoadingStyle = (isPre, isSuf) => {
if (isPre) {
return this.element && this.element.nextSibling ? this.element.nextSibling .getBoundingClientRect() : {}
}
if (isSuf) {
return this.element && this.element.previousSibling ? this.element.previousSibling.getBoundingClientRect() : {}
}
}
render() {
const {
clsPrefix, columns, record, height, visible, index,onPaste,
clsPrefix, columns, record, height, visible, index,onPaste, isPre, isSuf, containerWidth,
expandIconColumnIndex, expandIconAsCell, expanded, useDragHandle,rowDraggAble,
expandable, onExpand, needIndentSpaced, indent, indentSize,isHiddenExpandIcon,fixed,bodyDisplayInRow
,expandedIcon,collapsedIcon, hoverKey,lazyStartIndex,lazyEndIndex, expandIconCellWidth, getCellClassName
} = this.props;
const {notRowDrag} = this.state;
const isEmptyTr = isPre || isSuf
let showSum = false;
let { className } = this.props;
if (this.state.hovered) {
@ -555,7 +565,7 @@ class TableRow extends Component{
if(rowDraggAble && !useDragHandle && !notRowDrag) {
className += ' row-dragg-able'
}
const tdStyle = !isEmptyTr ? {} : this.getLoadingStyle(isPre, isSuf)
return (
<tr
draggable={rowDraggAble && !useDragHandle && !notRowDrag}
@ -570,7 +580,13 @@ class TableRow extends Component{
// key={hoverKey}
ref={this.bindElement}
>
{cells.length>0?cells:<td style={{width:0,padding:0}}></td>}
{cells.length > 0 ? cells : isEmptyTr ?
<td className={`loading-td ${ isPre ? 'pre-td' : 'suf-td' }`} style={{ width: tdStyle.width || 1200, height: tdStyle.height || 100 }}>
<div style={{ left: (containerWidth || 1200) / 2 - 23 }} className={`loading-div ${ isPre ? 'pre' : 'suf' }`}>
加载中...
</div>
</td> : <td style={{width: 0,padding: 0}}>
</td>}
</tr>
);
}