@kdcloudjs/table 1.2.1-canary.6 → 1.2.1-canary.7-hotfix.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.css.map +0 -0
- package/dist/@kdcloudjs/table.js +1755 -3334
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +16 -16
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/dist/default-theme.js +0 -0
- package/dist/kd-ui-complete.less +0 -0
- package/dist/kd-ui.less +0 -0
- package/dist/theme.js +0 -0
- package/es/_utils/arrayUtil.js +0 -3
- package/es/_utils/devwarning.js +0 -1
- package/es/_utils/formatUtil.js +35 -96
- package/es/_utils/hooks.js +18 -42
- package/es/_utils/index.js +0 -2
- package/es/_utils/numberUtil.js +32 -55
- package/es/_utils/omit.js +0 -2
- package/es/_utils/type.js +0 -2
- package/es/_utils/usePopper.js +74 -137
- package/es/config-provider/compDefaultProps.js +0 -1
- package/es/config-provider/configProvider.js +2 -7
- package/es/config-provider/defaultConfig.js +0 -1
- package/es/index.js +0 -2
- package/es/locale/locale.js +5 -43
- package/es/table/base/calculations.js +22 -72
- package/es/table/base/colgroup.js +0 -1
- package/es/table/base/empty.js +4 -4
- package/es/table/base/header.js +16 -69
- package/es/table/base/helpers/SpanManager.js +3 -9
- package/es/table/base/helpers/TableDOMUtils.js +4 -28
- package/es/table/base/helpers/__test__/SpanManager.test.js +2 -2
- package/es/table/base/helpers/__test__/TableDOMUtils.test.js +0 -1
- package/es/table/base/helpers/getRichVisibleRectsStream.js +13 -45
- package/es/table/base/helpers/rowHeightManager.js +0 -28
- package/es/table/base/html-table.js +14 -35
- package/es/table/base/loading.js +6 -8
- package/es/table/base/renderTemplates.js +26 -44
- package/es/table/base/styles.js +0 -9
- package/es/table/base/table.js +95 -181
- package/es/table/base/utils.js +14 -54
- package/es/table/common-views.js +0 -7
- package/es/table/internals.js +0 -13
- package/es/table/pipeline/features/autoFill.js +11 -40
- package/es/table/pipeline/features/autoRowSpan.js +1 -14
- package/es/table/pipeline/features/colGroupExtendable.js +4 -19
- package/es/table/pipeline/features/columnDrag.js +41 -96
- package/es/table/pipeline/features/columnFilter.js +11 -48
- package/es/table/pipeline/features/columnHover.js +1 -7
- package/es/table/pipeline/features/columnRangeHover.js +1 -8
- package/es/table/pipeline/features/columnResizeWidth.js +11 -37
- package/es/table/pipeline/features/contextMenu.js +18 -89
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +10 -25
- package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
- package/es/table/pipeline/features/filter/Filter.js +25 -48
- package/es/table/pipeline/features/filter/FilterPanel.js +11 -25
- package/es/table/pipeline/features/filter/util.js +0 -4
- package/es/table/pipeline/features/footerDataSource.js +0 -3
- package/es/table/pipeline/features/mergeCellHover.js +0 -1
- package/es/table/pipeline/features/multiSelect.js +15 -57
- package/es/table/pipeline/features/rangeSelection.js +63 -142
- package/es/table/pipeline/features/rowDetail.js +2 -41
- package/es/table/pipeline/features/rowDrag.js +38 -76
- package/es/table/pipeline/features/rowGrouping.js +2 -35
- package/es/table/pipeline/features/singleSelect.js +0 -24
- package/es/table/pipeline/features/sort.js +32 -89
- package/es/table/pipeline/features/tips.js +0 -6
- package/es/table/pipeline/features/treeMode.js +14 -46
- package/es/table/pipeline/features/treeSelect.js +0 -26
- package/es/table/pipeline/pipeline.js +11 -51
- package/es/table/pivot/cross-table/buildCrossTable.js +15 -64
- package/es/table/pivot/cross-table/cross-table.js +22 -28
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +14 -47
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +28 -50
- package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
- package/es/table/pivot/pivot-utils/builders.js +31 -71
- package/es/table/pivot/pivot-utils/convert-utils.js +13 -39
- package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
- package/es/table/transforms/autoRowSpan.js +1 -15
- package/es/table/transforms/autoWidth.js +10 -32
- package/es/table/transforms/buildTree.js +1 -2
- package/es/table/transforms/columnHover.js +9 -15
- package/es/table/transforms/columnRangeHover.js +12 -19
- package/es/table/transforms/columnResize.js +15 -37
- package/es/table/transforms/flatten.js +0 -3
- package/es/table/transforms/orderField.js +0 -3
- package/es/table/transforms/sort.js +36 -93
- package/es/table/transforms/tips.js +1 -6
- package/es/table/transforms/treeMode.js +30 -69
- package/es/table/transforms/visible.js +0 -2
- package/es/table/use/useResizeObserver.js +1 -4
- package/es/table/utils/applyTransforms.js +0 -1
- package/es/table/utils/browserType.js +12 -19
- package/es/table/utils/buildTree.js +4 -19
- package/es/table/utils/collectNodes.js +1 -10
- package/es/table/utils/console.js +0 -14
- package/es/table/utils/copyToClipboard.js +0 -4
- package/es/table/utils/element.js +14 -41
- package/es/table/utils/exportTableAsExcel.js +4 -40
- package/es/table/utils/getTreeDepth.js +1 -9
- package/es/table/utils/groupBy.js +1 -10
- package/es/table/utils/layeredFilter.js +0 -4
- package/es/table/utils/layeredSort.js +0 -5
- package/es/table/utils/makeRecursiveMapper.js +1 -12
- package/es/table/utils/mergeCellProps.js +6 -13
- package/es/table/utils/others.js +3 -16
- package/es/table/utils/proto.js +2 -30
- package/es/table/utils/smartCompare.js +4 -12
- package/es/table/utils/traverseColumn.js +2 -15
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +1 -22
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +15 -69
- package/es/table/utils/uiDegrade.js +0 -5
- package/lib/_utils/arrayUtil.js +0 -5
- package/lib/_utils/devwarning.js +0 -5
- package/lib/_utils/formatUtil.js +35 -100
- package/lib/_utils/hooks.js +18 -53
- package/lib/_utils/index.js +0 -6
- package/lib/_utils/numberUtil.js +32 -63
- package/lib/_utils/omit.js +0 -5
- package/lib/_utils/react-children.js +0 -5
- package/lib/_utils/type.js +0 -6
- package/lib/_utils/usePopper.js +74 -158
- package/lib/config-provider/ConfigContext.js +1 -4
- package/lib/config-provider/compDefaultProps.js +0 -1
- package/lib/config-provider/configProvider.js +3 -18
- package/lib/config-provider/defaultConfig.js +0 -5
- package/lib/config-provider/index.js +0 -6
- package/lib/index.js +2 -8
- package/lib/locale/index.js +0 -7
- package/lib/locale/locale.js +5 -57
- package/lib/table/base/calculations.js +22 -83
- package/lib/table/base/colgroup.js +0 -5
- package/lib/table/base/empty.js +4 -16
- package/lib/table/base/header.js +16 -79
- package/lib/table/base/helpers/SpanManager.js +3 -11
- package/lib/table/base/helpers/TableDOMUtils.js +2 -28
- package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
- package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
- package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +13 -63
- package/lib/table/base/helpers/rowHeightManager.js +0 -33
- package/lib/table/base/html-table.js +14 -45
- package/lib/table/base/index.js +0 -2
- package/lib/table/base/loading.js +6 -12
- package/lib/table/base/renderTemplates.js +27 -58
- package/lib/table/base/styles.js +0 -21
- package/lib/table/base/table.js +95 -214
- package/lib/table/base/utils.js +14 -89
- package/lib/table/common-views.js +0 -16
- package/lib/table/index.js +0 -13
- package/lib/table/internals.js +0 -14
- package/lib/table/pipeline/features/autoFill.js +11 -47
- package/lib/table/pipeline/features/autoRowSpan.js +1 -19
- package/lib/table/pipeline/features/buildTree.js +0 -2
- package/lib/table/pipeline/features/colGroupExtendable.js +4 -32
- package/lib/table/pipeline/features/columnDrag.js +41 -102
- package/lib/table/pipeline/features/columnFilter.js +11 -62
- package/lib/table/pipeline/features/columnHover.js +1 -11
- package/lib/table/pipeline/features/columnRangeHover.js +1 -13
- package/lib/table/pipeline/features/columnResizeWidth.js +11 -53
- package/lib/table/pipeline/features/contextMenu.js +18 -113
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +10 -43
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
- package/lib/table/pipeline/features/filter/Filter.js +25 -70
- package/lib/table/pipeline/features/filter/FilterPanel.js +11 -40
- package/lib/table/pipeline/features/filter/index.js +0 -5
- package/lib/table/pipeline/features/filter/util.js +0 -7
- package/lib/table/pipeline/features/footerDataSource.js +0 -10
- package/lib/table/pipeline/features/index.js +0 -23
- package/lib/table/pipeline/features/mergeCellHover.js +0 -5
- package/lib/table/pipeline/features/multiSelect.js +15 -71
- package/lib/table/pipeline/features/rangeSelection.js +63 -159
- package/lib/table/pipeline/features/rowDetail.js +2 -65
- package/lib/table/pipeline/features/rowDrag.js +38 -87
- package/lib/table/pipeline/features/rowGrouping.js +2 -55
- package/lib/table/pipeline/features/singleSelect.js +0 -34
- package/lib/table/pipeline/features/sort.js +31 -108
- package/lib/table/pipeline/features/tips.js +0 -15
- package/lib/table/pipeline/features/treeMode.js +14 -67
- package/lib/table/pipeline/features/treeSelect.js +0 -34
- package/lib/table/pipeline/index.js +0 -8
- package/lib/table/pipeline/pipeline.js +11 -60
- package/lib/table/pivot/cross-table/buildCrossTable.js +15 -75
- package/lib/table/pivot/cross-table/cross-table.js +22 -36
- package/lib/table/pivot/cross-table/index.js +0 -4
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +14 -60
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +28 -60
- package/lib/table/pivot/cross-tree-table/index.js +0 -3
- package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
- package/lib/table/pivot/pivot-utils/builders.js +31 -82
- package/lib/table/pivot/pivot-utils/convert-utils.js +13 -57
- package/lib/table/pivot/pivot-utils/index.js +0 -7
- package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
- package/lib/table/style/css.js +0 -1
- package/lib/table/style/index.js +0 -1
- package/lib/table/transforms/autoRowSpan.js +1 -21
- package/lib/table/transforms/autoWidth.js +10 -53
- package/lib/table/transforms/buildTree.js +1 -4
- package/lib/table/transforms/columnHover.js +9 -22
- package/lib/table/transforms/columnRangeHover.js +12 -27
- package/lib/table/transforms/columnResize.js +15 -56
- package/lib/table/transforms/flatten.js +0 -5
- package/lib/table/transforms/index.js +0 -12
- package/lib/table/transforms/orderField.js +0 -7
- package/lib/table/transforms/sort.js +36 -117
- package/lib/table/transforms/tips.js +1 -16
- package/lib/table/transforms/treeMode.js +30 -96
- package/lib/table/transforms/visible.js +0 -7
- package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
- package/lib/table/use/useResizeObserver.js +1 -8
- package/lib/table/utils/applyTransforms.js +0 -2
- package/lib/table/utils/browserType.js +12 -19
- package/lib/table/utils/buildTree.js +4 -30
- package/lib/table/utils/collectNodes.js +1 -15
- package/lib/table/utils/console.js +0 -16
- package/lib/table/utils/copyToClipboard.js +0 -6
- package/lib/table/utils/element.js +14 -46
- package/lib/table/utils/exportTableAsExcel.js +4 -49
- package/lib/table/utils/getTreeDepth.js +1 -14
- package/lib/table/utils/groupBy.js +1 -14
- package/lib/table/utils/index.js +0 -22
- package/lib/table/utils/isGroupColumn.js +0 -3
- package/lib/table/utils/isLeafNode.js +0 -1
- package/lib/table/utils/layeredFilter.js +0 -10
- package/lib/table/utils/layeredSort.js +0 -10
- package/lib/table/utils/makeRecursiveMapper.js +1 -21
- package/lib/table/utils/mergeCellProps.js +6 -17
- package/lib/table/utils/others.js +3 -31
- package/lib/table/utils/proto.js +2 -33
- package/lib/table/utils/selectColumn.js +0 -1
- package/lib/table/utils/smartCompare.js +4 -13
- package/lib/table/utils/traverseColumn.js +2 -22
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +1 -30
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +15 -82
- package/lib/table/utils/uiDegrade.js +1 -8
- package/package.json +2 -1
- package/lib/style/color/colors.less +0 -2
- package/lib/style/core/index.less +0 -2
- package/lib/style/core/motion/other.less +0 -28
- package/lib/style/core/motion/slide.less +0 -53
- package/lib/style/core/motion.less +0 -2
- package/lib/style/core/reset.less +0 -186
- package/lib/style/index.css +0 -410
- package/lib/style/index.less +0 -2
- package/lib/style/mixins/index.less +0 -19
- package/lib/style/mixins/overlay.less +0 -22
- package/lib/style/mixins/reset.less +0 -13
- package/lib/style/themes/default.less +0 -445
- package/lib/style/themes/index.less +0 -1
- package/lib/table/style/index.css +0 -0
- package/lib/table/style/index.less +0 -1
package/es/table/base/table.js
CHANGED
|
@@ -10,21 +10,14 @@ import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
|
10
10
|
import _inherits from "@babel/runtime-corejs3/helpers/inherits";
|
|
11
11
|
import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/possibleConstructorReturn";
|
|
12
12
|
import _getPrototypeOf from "@babel/runtime-corejs3/helpers/getPrototypeOf";
|
|
13
|
-
|
|
14
13
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
15
|
-
|
|
16
14
|
function _unsupportedIterableToArray(o, minLen) { var _context2; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
-
|
|
18
15
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
19
|
-
|
|
20
16
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
21
17
|
import _flatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/flat";
|
|
22
18
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
23
|
-
|
|
24
19
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
25
|
-
|
|
26
20
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
|
-
|
|
28
21
|
import cx from 'classnames';
|
|
29
22
|
import React from 'react';
|
|
30
23
|
import { BehaviorSubject, combineLatest, noop, Subscription, Subject, from } from 'rxjs';
|
|
@@ -42,75 +35,60 @@ import { addResizeObserver, getScrollbarSize, OVERSCAN_SIZE, shallowEqual, STYLE
|
|
|
42
35
|
import { console, browserType, isStickyUIDegrade } from '../utils';
|
|
43
36
|
import getTableRenderTemplate from './renderTemplates';
|
|
44
37
|
var propsDotEmptyContentDeprecatedWarned = false;
|
|
45
|
-
|
|
46
38
|
function warnPropsDotEmptyContentIsDeprecated() {
|
|
47
39
|
if (!propsDotEmptyContentDeprecatedWarned) {
|
|
48
40
|
propsDotEmptyContentDeprecatedWarned = true;
|
|
49
41
|
console.warn('BaseTable props.emptyContent 已经过时,请使用 props.components.EmptyContent 来自定义数据为空时的表格表现');
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
|
-
|
|
53
44
|
export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
54
45
|
_inherits(BaseTable, _React$Component);
|
|
55
|
-
|
|
56
46
|
var _super = _createSuper(BaseTable);
|
|
57
|
-
|
|
58
47
|
function BaseTable(props) {
|
|
59
48
|
var _this;
|
|
60
|
-
|
|
61
49
|
_classCallCheck(this, BaseTable);
|
|
62
|
-
|
|
63
50
|
_this = _super.call(this, props);
|
|
64
51
|
_this.rowHeightManager = makeRowHeightManager(_this.props.dataSource.length, _this.props.estimatedRowHeight);
|
|
65
52
|
_this.artTableWrapperRef = /*#__PURE__*/React.createRef();
|
|
66
53
|
_this.hasScrollY = false;
|
|
67
54
|
_this.offsetY = 0;
|
|
68
|
-
|
|
69
55
|
_this.handleRowMouseEnter = function (e) {
|
|
70
56
|
var nodeList = _this.domHelper.getRowNodeListByEvent(e);
|
|
71
|
-
|
|
72
57
|
nodeList && nodeList.forEach(function (node) {
|
|
73
58
|
node.classList.add('row-hover');
|
|
74
59
|
});
|
|
75
60
|
};
|
|
76
|
-
|
|
77
61
|
_this.handleRowMouseLeave = function (e) {
|
|
78
62
|
var nodeList = _this.domHelper.getRowNodeListByEvent(e);
|
|
79
|
-
|
|
80
63
|
nodeList && nodeList.forEach(function (node) {
|
|
81
64
|
node.classList.remove('row-hover');
|
|
82
65
|
});
|
|
83
66
|
};
|
|
84
|
-
|
|
85
67
|
_this.renderTableBody = function (info) {
|
|
86
68
|
// console.log('render body')
|
|
87
69
|
var _this$props = _this.props,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var tableBodyClassName = cx(Classes.tableBody, Classes.horizontalScrollContainer);
|
|
95
|
-
|
|
70
|
+
dataSource = _this$props.dataSource,
|
|
71
|
+
getRowProps = _this$props.getRowProps,
|
|
72
|
+
primaryKey = _this$props.primaryKey,
|
|
73
|
+
isLoading = _this$props.isLoading,
|
|
74
|
+
emptyCellHeight = _this$props.emptyCellHeight,
|
|
75
|
+
footerDataSource = _this$props.footerDataSource;
|
|
76
|
+
var tableBodyClassName = cx(Classes.tableBody, Classes.horizontalScrollContainer);
|
|
77
|
+
// 低版本Edge浏览器下也会出现双滚动条,这里设置overflow: 'hidden',先去掉edge的方向键控制滚动条的功能
|
|
96
78
|
var virtualStyle = browserType.isIE || browserType.isEdge ? {
|
|
97
79
|
overflow: 'hidden'
|
|
98
80
|
} : {};
|
|
99
|
-
|
|
100
81
|
if (dataSource.length === 0) {
|
|
101
82
|
var _this$props2 = _this.props,
|
|
102
|
-
|
|
103
|
-
|
|
83
|
+
components = _this$props2.components,
|
|
84
|
+
emptyContent = _this$props2.emptyContent;
|
|
104
85
|
var EmptyContent = components.EmptyContent;
|
|
105
|
-
|
|
106
86
|
if (EmptyContent == null && emptyContent != null) {
|
|
107
87
|
warnPropsDotEmptyContentIsDeprecated();
|
|
108
|
-
|
|
109
88
|
EmptyContent = function EmptyContent() {
|
|
110
89
|
return emptyContent;
|
|
111
90
|
};
|
|
112
91
|
}
|
|
113
|
-
|
|
114
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
115
93
|
className: cx(tableBodyClassName, 'empty')
|
|
116
94
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -124,14 +102,12 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
124
102
|
emptyCellHeight: emptyCellHeight
|
|
125
103
|
})));
|
|
126
104
|
}
|
|
127
|
-
|
|
128
105
|
var _info$verticalRenderR = info.verticalRenderRange,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
106
|
+
topIndex = _info$verticalRenderR.topIndex,
|
|
107
|
+
bottomBlank = _info$verticalRenderR.bottomBlank,
|
|
108
|
+
topBlank = _info$verticalRenderR.topBlank,
|
|
109
|
+
bottomIndex = _info$verticalRenderR.bottomIndex;
|
|
133
110
|
var renderBody = getTableRenderTemplate('body');
|
|
134
|
-
|
|
135
111
|
if (typeof renderBody === 'function') {
|
|
136
112
|
return renderBody(info, _this.props, {
|
|
137
113
|
rowProps: {
|
|
@@ -140,7 +116,6 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
140
116
|
}
|
|
141
117
|
});
|
|
142
118
|
}
|
|
143
|
-
|
|
144
119
|
return /*#__PURE__*/React.createElement("div", {
|
|
145
120
|
className: tableBodyClassName
|
|
146
121
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -173,7 +148,6 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
173
148
|
}
|
|
174
149
|
})));
|
|
175
150
|
};
|
|
176
|
-
|
|
177
151
|
_this.state = {
|
|
178
152
|
hasScroll: true,
|
|
179
153
|
hasScrollY: true,
|
|
@@ -189,8 +163,6 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
189
163
|
return _this;
|
|
190
164
|
}
|
|
191
165
|
/** @deprecated BaseTable.getDoms() 已经过时,请勿调用 */
|
|
192
|
-
|
|
193
|
-
|
|
194
166
|
_createClass(BaseTable, [{
|
|
195
167
|
key: "getDoms",
|
|
196
168
|
value: function getDoms() {
|
|
@@ -198,34 +170,29 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
198
170
|
return this.domHelper;
|
|
199
171
|
}
|
|
200
172
|
/** 自定义滚动条宽度为table宽度,使滚动条滑块宽度相同 */
|
|
201
|
-
|
|
202
173
|
}, {
|
|
203
174
|
key: "updateStickyScroll",
|
|
204
175
|
value: function updateStickyScroll() {
|
|
205
176
|
var _a, _b;
|
|
206
|
-
|
|
207
177
|
var _this$domHelper = this.domHelper,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
178
|
+
stickyScroll = _this$domHelper.stickyScroll,
|
|
179
|
+
artTable = _this$domHelper.artTable,
|
|
180
|
+
stickyScrollItem = _this$domHelper.stickyScrollItem;
|
|
211
181
|
var _lastHasScrollY = this.hasScrollY;
|
|
212
|
-
|
|
213
182
|
if (!artTable) {
|
|
214
183
|
return;
|
|
215
184
|
}
|
|
216
|
-
|
|
217
185
|
var tableBodyHtmlTable = this.domHelper.getTableBodyHtmlTable();
|
|
218
186
|
var innerTableWidth = tableBodyHtmlTable.offsetWidth;
|
|
219
187
|
var artTableWidth = artTable.offsetWidth;
|
|
220
|
-
var artTableHeight = artTable.offsetHeight;
|
|
221
|
-
|
|
188
|
+
var artTableHeight = artTable.offsetHeight;
|
|
189
|
+
// 表格隐藏后,不需要对表格的滚动条做额外的逻辑处理
|
|
222
190
|
if (artTableWidth === 0 && artTableHeight === 0) return;
|
|
223
191
|
var stickyScrollHeightProp = this.props.stickyScrollHeight;
|
|
224
|
-
var stickyScrollHeight = stickyScrollHeightProp === 'auto' ? this.getScrollBarWidth() : stickyScrollHeightProp;
|
|
192
|
+
var stickyScrollHeight = stickyScrollHeightProp === 'auto' ? this.getScrollBarWidth() : stickyScrollHeightProp;
|
|
193
|
+
// stickyScroll.style.marginTop = `-${stickyScrollHeight + 1}px`
|
|
225
194
|
// 设置滚动条高度
|
|
226
|
-
|
|
227
195
|
stickyScroll.style.height = "".concat(stickyScrollHeight, "px");
|
|
228
|
-
|
|
229
196
|
if (artTableWidth >= innerTableWidth) {
|
|
230
197
|
if (this.state.hasScroll) {
|
|
231
198
|
this.setState({
|
|
@@ -240,7 +207,6 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
240
207
|
});
|
|
241
208
|
}
|
|
242
209
|
}
|
|
243
|
-
|
|
244
210
|
if (this.domHelper.virtual.offsetHeight > this.domHelper.tableBody.offsetHeight) {
|
|
245
211
|
// if (!this.state.hasScroll) {
|
|
246
212
|
// this.setState({
|
|
@@ -255,34 +221,30 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
255
221
|
// })
|
|
256
222
|
this.hasScrollY = false;
|
|
257
223
|
}
|
|
258
|
-
|
|
259
224
|
if (_lastHasScrollY !== this.hasScrollY) {
|
|
260
225
|
(_b = (_a = this.props).setTableWidth) === null || _b === void 0 ? void 0 : _b.call(_a, this.domHelper.tableBody.clientWidth);
|
|
261
226
|
}
|
|
262
|
-
|
|
263
227
|
var _this$lastInfo = this.lastInfo,
|
|
264
|
-
|
|
265
|
-
|
|
228
|
+
leftLockTotalWidth = _this$lastInfo.leftLockTotalWidth,
|
|
229
|
+
rightLockTotalWidth = _this$lastInfo.rightLockTotalWidth;
|
|
266
230
|
var lockTotalWidth = leftLockTotalWidth + rightLockTotalWidth;
|
|
267
|
-
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
268
|
-
|
|
231
|
+
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
232
|
+
// 设置子节点宽度
|
|
269
233
|
stickyScrollItem.style.width = "".concat(innerTableWidth - lockTotalWidth + stickyRightOffset, "px");
|
|
270
234
|
}
|
|
271
235
|
}, {
|
|
272
236
|
key: "renderTableHeader",
|
|
273
237
|
value: function renderTableHeader(info) {
|
|
274
238
|
var _this$props3 = this.props,
|
|
275
|
-
|
|
276
|
-
|
|
239
|
+
stickyTop = _this$props3.stickyTop,
|
|
240
|
+
hasHeader = _this$props3.hasHeader;
|
|
277
241
|
var renderHeader = getTableRenderTemplate('header');
|
|
278
242
|
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
279
|
-
|
|
280
243
|
if (typeof renderHeader === 'function') {
|
|
281
244
|
return renderHeader(info, this.props, {
|
|
282
245
|
stickyRightOffset: stickyRightOffset
|
|
283
246
|
});
|
|
284
247
|
}
|
|
285
|
-
|
|
286
248
|
return /*#__PURE__*/React.createElement("div", {
|
|
287
249
|
className: cx(Classes.tableHeader, 'no-scrollbar'),
|
|
288
250
|
style: {
|
|
@@ -316,31 +278,23 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
316
278
|
this.syncHorizontalScroll(this.domHelper.virtual.scrollLeft);
|
|
317
279
|
}
|
|
318
280
|
/** 同步横向滚动偏移量 */
|
|
319
|
-
|
|
320
281
|
}, {
|
|
321
282
|
key: "syncHorizontalScroll",
|
|
322
283
|
value: function syncHorizontalScroll(x) {
|
|
323
284
|
this.updateOffsetX(x);
|
|
324
|
-
|
|
325
285
|
var flat = _flatInstanceProperty(this.lastInfo);
|
|
326
|
-
|
|
327
286
|
var leftLockShadow = this.domHelper.getLeftLockShadow();
|
|
328
|
-
|
|
329
287
|
if (leftLockShadow) {
|
|
330
288
|
var shouldShowLeftLockShadow = flat.left.length > 0 && this.state.needRenderLock && x > 0;
|
|
331
|
-
|
|
332
289
|
if (shouldShowLeftLockShadow) {
|
|
333
290
|
leftLockShadow.classList.add('show-shadow');
|
|
334
291
|
} else {
|
|
335
292
|
leftLockShadow.classList.remove('show-shadow');
|
|
336
293
|
}
|
|
337
294
|
}
|
|
338
|
-
|
|
339
295
|
var rightLockShadow = this.domHelper.getRightLockShadow();
|
|
340
|
-
|
|
341
296
|
if (rightLockShadow) {
|
|
342
297
|
var shouldShowRightLockShadow = flat.right.length > 0 && this.state.needRenderLock && x < this.domHelper.virtual.scrollWidth - this.domHelper.virtual.clientWidth;
|
|
343
|
-
|
|
344
298
|
if (shouldShowRightLockShadow) {
|
|
345
299
|
rightLockShadow.classList.add('show-shadow');
|
|
346
300
|
} else {
|
|
@@ -353,10 +307,9 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
353
307
|
value: function getVerticalRenderRange(useVirtual) {
|
|
354
308
|
var dataSource = this.props.dataSource;
|
|
355
309
|
var _this$state = this.state,
|
|
356
|
-
|
|
357
|
-
|
|
310
|
+
offsetY = _this$state.offsetY,
|
|
311
|
+
maxRenderHeight = _this$state.maxRenderHeight;
|
|
358
312
|
var rowCount = dataSource.length;
|
|
359
|
-
|
|
360
313
|
if (useVirtual.vertical) {
|
|
361
314
|
return this.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, rowCount);
|
|
362
315
|
} else {
|
|
@@ -368,14 +321,13 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
368
321
|
value: function renderTableFooter(info) {
|
|
369
322
|
// console.log('render footer')
|
|
370
323
|
var _this$props4 = this.props,
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
324
|
+
_this$props4$footerDa = _this$props4.footerDataSource,
|
|
325
|
+
footerDataSource = _this$props4$footerDa === void 0 ? [] : _this$props4$footerDa,
|
|
326
|
+
getRowProps = _this$props4.getRowProps,
|
|
327
|
+
primaryKey = _this$props4.primaryKey,
|
|
328
|
+
stickyBottom = _this$props4.stickyBottom;
|
|
376
329
|
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
377
330
|
var renderFooter = getTableRenderTemplate('footer');
|
|
378
|
-
|
|
379
331
|
if (typeof renderFooter === 'function') {
|
|
380
332
|
return renderFooter(info, this.props, {
|
|
381
333
|
rowProps: {
|
|
@@ -385,7 +337,6 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
385
337
|
stickyRightOffset: stickyRightOffset
|
|
386
338
|
});
|
|
387
339
|
}
|
|
388
|
-
|
|
389
340
|
return /*#__PURE__*/React.createElement("div", {
|
|
390
341
|
className: cx(Classes.tableFooter, Classes.horizontalScrollContainer),
|
|
391
342
|
style: {
|
|
@@ -415,8 +366,8 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
415
366
|
}, {
|
|
416
367
|
key: "renderLockShadows",
|
|
417
368
|
value: function renderLockShadows(info) {
|
|
418
|
-
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
419
|
-
|
|
369
|
+
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
370
|
+
// console.log('render LockShadows')
|
|
420
371
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
421
372
|
className: Classes.lockShadowMask,
|
|
422
373
|
style: {
|
|
@@ -440,8 +391,8 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
440
391
|
value: function renderStickyScroll(info) {
|
|
441
392
|
// console.log('render stickyscroll')
|
|
442
393
|
var _this$props5 = this.props,
|
|
443
|
-
|
|
444
|
-
|
|
394
|
+
hasStickyScroll = _this$props5.hasStickyScroll,
|
|
395
|
+
stickyBottom = _this$props5.stickyBottom;
|
|
445
396
|
var hasScroll = this.state.hasScroll;
|
|
446
397
|
var isScroll = hasStickyScroll && hasScroll;
|
|
447
398
|
var stickyScrollContainerStyle = this.getStickyScrollContainerStyle();
|
|
@@ -479,8 +430,8 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
479
430
|
key: "getStickyScrollContainerStyle",
|
|
480
431
|
value: function getStickyScrollContainerStyle() {
|
|
481
432
|
var _this$props6 = this.props,
|
|
482
|
-
|
|
483
|
-
|
|
433
|
+
hasStickyScroll = _this$props6.hasStickyScroll,
|
|
434
|
+
stickyScrollHeight = _this$props6.stickyScrollHeight;
|
|
484
435
|
var hasScroll = this.state.hasScroll;
|
|
485
436
|
var isScroll = hasStickyScroll && hasScroll;
|
|
486
437
|
var height = stickyScrollHeight === 'auto' ? this.getScrollBarWidth() : stickyScrollHeight;
|
|
@@ -495,24 +446,23 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
495
446
|
key: "render",
|
|
496
447
|
value: function render() {
|
|
497
448
|
var _cx;
|
|
498
|
-
|
|
499
449
|
// console.log('render table')
|
|
500
450
|
var info = calculateRenderInfo(this);
|
|
501
451
|
this.lastInfo = info;
|
|
502
452
|
var _this$props7 = this.props,
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
453
|
+
dataSource = _this$props7.dataSource,
|
|
454
|
+
className = _this$props7.className,
|
|
455
|
+
style = _this$props7.style,
|
|
456
|
+
hasHeader = _this$props7.hasHeader,
|
|
457
|
+
useOuterBorder = _this$props7.useOuterBorder,
|
|
458
|
+
isStickyHead = _this$props7.isStickyHead,
|
|
459
|
+
isStickyHeader = _this$props7.isStickyHeader,
|
|
460
|
+
isStickyFooter = _this$props7.isStickyFooter,
|
|
461
|
+
isLoading = _this$props7.isLoading,
|
|
462
|
+
getTableProps = _this$props7.getTableProps,
|
|
463
|
+
footerDataSource = _this$props7.footerDataSource,
|
|
464
|
+
components = _this$props7.components,
|
|
465
|
+
bordered = _this$props7.bordered;
|
|
516
466
|
var artTableWrapperClassName = cx(Classes.artTableWrapper, (_cx = {
|
|
517
467
|
'use-outer-border': useOuterBorder,
|
|
518
468
|
empty: dataSource.length === 0,
|
|
@@ -522,12 +472,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
522
472
|
'has-footer': footerDataSource.length > 0,
|
|
523
473
|
'sticky-footer': isStickyFooter
|
|
524
474
|
}, _defineProperty(_cx, Classes.artTableBordered, bordered), _defineProperty(_cx, 'ie-polyfill-wrapper', browserType.isIE), _defineProperty(_cx, 'sticky-polyfill-wrapper', isStickyUIDegrade()), _cx), className);
|
|
525
|
-
|
|
526
475
|
var artTableWrapperProps = _defineProperty({
|
|
527
476
|
className: artTableWrapperClassName,
|
|
528
477
|
style: style
|
|
529
478
|
}, STYLED_REF_PROP, this.artTableWrapperRef);
|
|
530
|
-
|
|
531
479
|
var tableProps = getTableProps() || {};
|
|
532
480
|
return /*#__PURE__*/React.createElement(StyledArtTableWrapper, _extends({}, artTableWrapperProps), /*#__PURE__*/React.createElement(Loading, {
|
|
533
481
|
visible: isLoading,
|
|
@@ -541,18 +489,17 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
541
489
|
key: "componentDidMount",
|
|
542
490
|
value: function componentDidMount() {
|
|
543
491
|
var _a, _b, _c, _d, _e, _f;
|
|
544
|
-
|
|
545
492
|
this.rootSubscription = new Subscription();
|
|
546
493
|
this.resizeSubject = new Subject();
|
|
547
494
|
this.updateDOMHelper();
|
|
548
495
|
this.props$ = new BehaviorSubject(this.props);
|
|
549
496
|
this.initSubscriptions();
|
|
550
|
-
this.didMountOrUpdate();
|
|
551
|
-
|
|
497
|
+
this.didMountOrUpdate();
|
|
498
|
+
// console.log('did mount end')
|
|
552
499
|
var _this$props8 = this.props,
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
500
|
+
cssVariables = _this$props8.cssVariables,
|
|
501
|
+
enableCSSVariables = _this$props8.enableCSSVariables,
|
|
502
|
+
bordered = _this$props8.bordered;
|
|
556
503
|
cssPolifill({
|
|
557
504
|
variables: cssVariables || {},
|
|
558
505
|
enableCSSVariables: enableCSSVariables,
|
|
@@ -565,14 +512,12 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
565
512
|
}, {
|
|
566
513
|
key: "componentDidUpdate",
|
|
567
514
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
568
|
-
var _a;
|
|
569
|
-
|
|
570
|
-
|
|
515
|
+
var _a;
|
|
516
|
+
// console.log('did update start')
|
|
571
517
|
var _this$props9 = this.props,
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
518
|
+
cssVariables = _this$props9.cssVariables,
|
|
519
|
+
enableCSSVariables = _this$props9.enableCSSVariables,
|
|
520
|
+
bordered = _this$props9.bordered;
|
|
576
521
|
if (!shallowEqual(prevProps === null || prevProps === void 0 ? void 0 : prevProps.cssVariables, (_a = this.props) === null || _a === void 0 ? void 0 : _a.cssVariables)) {
|
|
577
522
|
cssPolifill({
|
|
578
523
|
variables: cssVariables || {},
|
|
@@ -580,10 +525,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
580
525
|
bordered: bordered
|
|
581
526
|
});
|
|
582
527
|
}
|
|
583
|
-
|
|
584
528
|
this.updateDOMHelper();
|
|
585
529
|
this.props$.next(this.props);
|
|
586
|
-
this.didMountOrUpdate(prevProps, prevState);
|
|
530
|
+
this.didMountOrUpdate(prevProps, prevState);
|
|
531
|
+
// console.log('did update end')
|
|
587
532
|
}
|
|
588
533
|
}, {
|
|
589
534
|
key: "didMountOrUpdate",
|
|
@@ -602,11 +547,9 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
602
547
|
this.domHelper.stickyScroll.scrollLeft = 0;
|
|
603
548
|
}
|
|
604
549
|
}
|
|
605
|
-
|
|
606
550
|
if (prevProps != null) {
|
|
607
551
|
var prevHasFooter = prevProps.footerDataSource.length > 0;
|
|
608
552
|
var currentHasFooter = this.props.footerDataSource.length > 0;
|
|
609
|
-
|
|
610
553
|
if (!prevHasFooter && currentHasFooter) {
|
|
611
554
|
getTableScrollFooterDOM(this.domHelper).scrollLeft = this.domHelper.virtual.scrollLeft;
|
|
612
555
|
}
|
|
@@ -616,64 +559,55 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
616
559
|
key: "initSubscriptions",
|
|
617
560
|
value: function initSubscriptions() {
|
|
618
561
|
var _this2 = this;
|
|
619
|
-
|
|
620
562
|
var _this$domHelper2 = this.domHelper,
|
|
621
|
-
|
|
622
|
-
|
|
563
|
+
virtual = _this$domHelper2.virtual,
|
|
564
|
+
stickyScroll = _this$domHelper2.stickyScroll;
|
|
623
565
|
this.rootSubscription.add(throttledWindowResize$.subscribe(function () {
|
|
624
566
|
_this2.updateStickyScroll();
|
|
625
|
-
|
|
626
567
|
_this2.adjustNeedRenderLock();
|
|
627
568
|
}));
|
|
628
569
|
this.resizeSubject.pipe(op.debounceTime(100)).subscribe(function () {
|
|
629
570
|
var _a, _b;
|
|
630
|
-
|
|
631
571
|
(_b = (_a = _this2.props).setTableWidth) === null || _b === void 0 ? void 0 : _b.call(_a, _this2.domHelper.tableBody.clientWidth);
|
|
632
572
|
});
|
|
633
|
-
|
|
634
573
|
var handleTableWrapperResize = function handleTableWrapperResize() {
|
|
635
574
|
_this2.resizeSubject.next();
|
|
636
575
|
};
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
576
|
+
this.resizeObserver = addResizeObserver(this.domHelper.artTableWrapper, handleTableWrapperResize);
|
|
577
|
+
// 滚动同步
|
|
640
578
|
this.rootSubscription.add(syncScrollLeft([getTableScrollHeaderDOM(this.domHelper), virtual, getTableScrollFooterDOM(this.domHelper), stickyScroll], function (scrollLeft) {
|
|
641
579
|
_this2.syncHorizontalScroll(scrollLeft);
|
|
642
580
|
}));
|
|
643
|
-
var richVisibleRects$ = getRichVisibleRectsStream(this.domHelper.virtual, this.props$.pipe(op.skip(1), op.mapTo('structure-may-change')), this.props.virtualDebugLabel).pipe(op.shareReplay());
|
|
644
|
-
|
|
581
|
+
var richVisibleRects$ = getRichVisibleRectsStream(this.domHelper.virtual, this.props$.pipe(op.skip(1), op.mapTo('structure-may-change')), this.props.virtualDebugLabel).pipe(op.shareReplay());
|
|
582
|
+
// 每当可见部分发生变化的时候,调整 loading icon 的未知(如果 loading icon 存在的话)
|
|
645
583
|
this.rootSubscription.add(combineLatest([richVisibleRects$.pipe(op.map(function (p) {
|
|
646
584
|
return p.clipRect;
|
|
647
585
|
}), op.distinctUntilChanged(shallowEqual)), this.props$.pipe(op.startWith(null), op.pairwise(), op.filter(function (_ref) {
|
|
648
586
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
587
|
+
prevProps = _ref2[0],
|
|
588
|
+
props = _ref2[1];
|
|
652
589
|
return prevProps == null || !prevProps.isLoading && props.isLoading;
|
|
653
590
|
}))]).subscribe(function (_ref3) {
|
|
654
591
|
var _ref4 = _slicedToArray(_ref3, 1),
|
|
655
|
-
|
|
656
|
-
|
|
592
|
+
clipRect = _ref4[0];
|
|
657
593
|
var loadingIndicator = _this2.domHelper.getLoadingIndicator();
|
|
658
|
-
|
|
659
594
|
if (!loadingIndicator) {
|
|
660
595
|
return;
|
|
661
596
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
597
|
+
var height = clipRect.bottom - clipRect.top;
|
|
598
|
+
// fixme 这里的定位在有些特殊情况下可能会出错 see #132
|
|
665
599
|
loadingIndicator.style.top = "".concat(height / 2, "px");
|
|
666
600
|
loadingIndicator.style.marginTop = "".concat(height / 2, "px");
|
|
667
|
-
}));
|
|
668
|
-
|
|
601
|
+
}));
|
|
602
|
+
// 每当可见部分发生变化的时候,如果开启了虚拟滚动,则重新触发 render
|
|
669
603
|
this.rootSubscription.add(richVisibleRects$.pipe(op.filter(function () {
|
|
670
604
|
var _this2$lastInfo$useVi = _this2.lastInfo.useVirtual,
|
|
671
|
-
|
|
672
|
-
|
|
605
|
+
horizontal = _this2$lastInfo$useVi.horizontal,
|
|
606
|
+
vertical = _this2$lastInfo$useVi.vertical;
|
|
673
607
|
return horizontal || vertical;
|
|
674
608
|
}), op.map(function (_ref5) {
|
|
675
609
|
var clipRect = _ref5.clipRect,
|
|
676
|
-
|
|
610
|
+
offsetY = _ref5.offsetY;
|
|
677
611
|
return {
|
|
678
612
|
maxRenderHeight: clipRect.bottom - clipRect.top,
|
|
679
613
|
maxRenderWidth: clipRect.right - clipRect.left,
|
|
@@ -683,16 +617,15 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
683
617
|
// 如果表格区域被隐藏, 不需要触发组件重渲染
|
|
684
618
|
if (y.maxRenderHeight === 0 && y.maxRenderWidth === 0) {
|
|
685
619
|
return true;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
|
|
620
|
+
}
|
|
621
|
+
// 因为 overscan 的存在,滚动较小的距离时不需要触发组件重渲染
|
|
689
622
|
return Math.abs(x.maxRenderWidth - y.maxRenderWidth) < OVERSCAN_SIZE / 2 && Math.abs(x.maxRenderHeight - y.maxRenderHeight) < OVERSCAN_SIZE / 2 && Math.abs(x.offsetY - y.offsetY) < OVERSCAN_SIZE / 2;
|
|
690
623
|
})).subscribe(function (sizeAndOffset) {
|
|
691
624
|
_this2.setState(sizeAndOffset);
|
|
692
625
|
}));
|
|
693
626
|
this.rootSubscription.add(richVisibleRects$.pipe(op.map(function (_ref6) {
|
|
694
627
|
var clipRect = _ref6.clipRect,
|
|
695
|
-
|
|
628
|
+
offsetY = _ref6.offsetY;
|
|
696
629
|
return {
|
|
697
630
|
maxRenderHeight: clipRect.bottom - clipRect.top,
|
|
698
631
|
maxRenderWidth: clipRect.right - clipRect.left,
|
|
@@ -700,20 +633,18 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
700
633
|
};
|
|
701
634
|
}), op.distinctUntilChanged(function (x, y) {
|
|
702
635
|
return x.offsetY - y.offsetY === 0;
|
|
703
|
-
}),
|
|
636
|
+
}),
|
|
637
|
+
// 计算得到当前行索引对应的数据块,blocks改成数组的形式,兼容快速拖动可视区域出现两个数据块的情况
|
|
704
638
|
op.map(function (sizeAndOffset) {
|
|
705
639
|
var _a;
|
|
706
|
-
|
|
707
640
|
var offsetY = sizeAndOffset.offsetY,
|
|
708
|
-
|
|
641
|
+
maxRenderHeight = sizeAndOffset.maxRenderHeight;
|
|
709
642
|
var scrollDirection = offsetY - _this2.offsetY >= 0 ? 'down' : 'up';
|
|
710
643
|
_this2.offsetY = offsetY;
|
|
711
644
|
var rowCount = _this2.props.dataSource.length;
|
|
712
|
-
|
|
713
645
|
var vertical = _this2.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, rowCount);
|
|
714
|
-
|
|
715
646
|
var topIndex = vertical.topIndex,
|
|
716
|
-
|
|
647
|
+
bottomIndex = vertical.bottomIndex;
|
|
717
648
|
var blockSize = ((_a = _this2.props.scrollLoad) === null || _a === void 0 ? void 0 : _a.blockSize) || 200;
|
|
718
649
|
var topBlockStartIndex = Math.floor(Math.max(topIndex - 1, 0) / blockSize) * blockSize;
|
|
719
650
|
var bottomBlockStartIndex = Math.floor((bottomIndex + 1) / blockSize) * blockSize;
|
|
@@ -725,10 +656,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
725
656
|
return event$.pipe(op.map(function (startIndex) {
|
|
726
657
|
return startIndex;
|
|
727
658
|
}));
|
|
728
|
-
}),
|
|
659
|
+
}),
|
|
660
|
+
// 过滤掉重复掉值
|
|
729
661
|
op.distinctUntilChanged()).subscribe(function (startIndex) {
|
|
730
662
|
var _a;
|
|
731
|
-
|
|
732
663
|
(_a = _this2.props.scrollLoad) === null || _a === void 0 ? void 0 : _a.callback(startIndex);
|
|
733
664
|
}));
|
|
734
665
|
}
|
|
@@ -736,13 +667,11 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
736
667
|
key: "componentWillUnmount",
|
|
737
668
|
value: function componentWillUnmount() {
|
|
738
669
|
var _a;
|
|
739
|
-
|
|
740
670
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
741
671
|
this.rootSubscription.unsubscribe();
|
|
742
672
|
this.resizeSubject.unsubscribe();
|
|
743
673
|
}
|
|
744
674
|
/** 更新 DOM 节点的引用,方便其他方法直接操作 DOM */
|
|
745
|
-
|
|
746
675
|
}, {
|
|
747
676
|
key: "updateDOMHelper",
|
|
748
677
|
value: function updateDOMHelper() {
|
|
@@ -752,51 +681,42 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
752
681
|
key: "updateRowHeightManager",
|
|
753
682
|
value: function updateRowHeightManager() {
|
|
754
683
|
var _a;
|
|
755
|
-
|
|
756
684
|
var virtualTop = this.domHelper.getVirtualTop();
|
|
757
685
|
var virtualTopHeight = (_a = virtualTop === null || virtualTop === void 0 ? void 0 : virtualTop.clientHeight) !== null && _a !== void 0 ? _a : 0;
|
|
758
686
|
var maxTrRowIndex = -1;
|
|
759
687
|
var maxTrBottom = -1;
|
|
760
688
|
var zeroHeightRowCount = 0;
|
|
761
|
-
|
|
762
689
|
var _iterator = _createForOfIteratorHelper(this.domHelper.getTableRows()),
|
|
763
|
-
|
|
764
|
-
|
|
690
|
+
_step;
|
|
765
691
|
try {
|
|
766
692
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
767
693
|
var tr = _step.value;
|
|
768
694
|
var rowIndex = Number(tr.dataset.rowindex);
|
|
769
|
-
|
|
770
695
|
if (isNaN(rowIndex)) {
|
|
771
696
|
continue;
|
|
772
697
|
}
|
|
773
|
-
|
|
774
698
|
maxTrRowIndex = Math.max(maxTrRowIndex, rowIndex);
|
|
775
699
|
var offset = tr.offsetTop + virtualTopHeight;
|
|
776
700
|
var size = tr.offsetHeight;
|
|
777
|
-
|
|
778
701
|
if (size === 0) {
|
|
779
702
|
zeroHeightRowCount += 1;
|
|
780
703
|
} else {
|
|
781
704
|
// 渲染出来的行高度为0,说明是display=none情况,行高不存在该种异常情况,不保存当前的高度
|
|
782
705
|
this.rowHeightManager.updateRow(rowIndex, offset, size);
|
|
783
706
|
}
|
|
784
|
-
|
|
785
707
|
maxTrBottom = Math.max(maxTrBottom, offset + size);
|
|
786
|
-
}
|
|
708
|
+
}
|
|
709
|
+
// 当 estimatedRowHeight 过大时,可能出现「渲染行数过少,无法覆盖可视范围」的情况
|
|
787
710
|
// 出现这种情况时,我们判断「下一次渲染能够渲染更多行」是否满足,满足的话就直接调用 forceUpdate
|
|
788
711
|
// zeroHeightRowCount === 0 用于确保当前没有 display=none 的情况
|
|
789
|
-
|
|
790
712
|
} catch (err) {
|
|
791
713
|
_iterator.e(err);
|
|
792
714
|
} finally {
|
|
793
715
|
_iterator.f();
|
|
794
716
|
}
|
|
795
|
-
|
|
796
717
|
if (maxTrRowIndex !== -1 && zeroHeightRowCount === 0) {
|
|
797
718
|
if (maxTrBottom < this.state.offsetY + this.state.maxRenderHeight) {
|
|
798
719
|
var vertical = this.getVerticalRenderRange(this.lastInfo.useVirtual);
|
|
799
|
-
|
|
800
720
|
if (vertical.bottomIndex - 1 > maxTrRowIndex) {
|
|
801
721
|
this.forceUpdate();
|
|
802
722
|
}
|
|
@@ -804,24 +724,19 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
804
724
|
}
|
|
805
725
|
}
|
|
806
726
|
/** 计算表格所有列的渲染宽度之和,判断表格是否需要渲染锁列 */
|
|
807
|
-
|
|
808
727
|
}, {
|
|
809
728
|
key: "adjustNeedRenderLock",
|
|
810
729
|
value: function adjustNeedRenderLock() {
|
|
811
730
|
var needRenderLock = this.state.needRenderLock;
|
|
812
|
-
|
|
813
731
|
var _this$lastInfo2 = this.lastInfo,
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
732
|
+
flat = _flatInstanceProperty(_this$lastInfo2),
|
|
733
|
+
hasLockColumn = _this$lastInfo2.hasLockColumn;
|
|
817
734
|
if (hasLockColumn) {
|
|
818
735
|
var _context;
|
|
819
|
-
|
|
820
736
|
var sumOfColWidth = sum(_mapInstanceProperty(_context = flat.full).call(_context, function (col) {
|
|
821
737
|
return col.width;
|
|
822
738
|
}));
|
|
823
739
|
var nextNeedRenderLock = sumOfColWidth > this.domHelper.artTable.clientWidth;
|
|
824
|
-
|
|
825
740
|
if (needRenderLock !== nextNeedRenderLock) {
|
|
826
741
|
this.setState({
|
|
827
742
|
needRenderLock: nextNeedRenderLock
|
|
@@ -836,7 +751,6 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
836
751
|
}
|
|
837
752
|
}
|
|
838
753
|
}]);
|
|
839
|
-
|
|
840
754
|
return BaseTable;
|
|
841
755
|
}(React.Component);
|
|
842
756
|
BaseTable.defaultProps = {
|