@kdcloudjs/table 1.2.2-canary.11 → 1.2.2-canary.13
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/LICENSE +568 -568
- package/README.md +111 -111
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +3628 -3483
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +11 -13
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/dist/kd-ui-complete.less +777 -777
- package/es/_utils/formatUtil.js +5 -1
- package/es/_utils/hooks.js +3 -3
- package/es/_utils/usePopper.js +13 -13
- package/es/locale/locale.js +7 -6
- package/es/style/color/colors.less +1 -1
- package/es/style/core/index.less +1 -1
- package/es/style/core/motion/other.less +27 -27
- package/es/style/core/motion/slide.less +53 -53
- package/es/style/core/motion.less +1 -1
- package/es/style/core/reset.less +185 -185
- package/es/style/index.less +1 -1
- package/es/style/mixins/index.less +18 -18
- package/es/style/mixins/overlay.less +21 -21
- package/es/style/mixins/reset.less +12 -12
- package/es/style/themes/default.less +445 -445
- package/es/table/base/BlankComponent.d.ts +11 -0
- package/es/table/base/BlankComponent.js +61 -0
- package/es/table/base/calculations.js +3 -3
- package/es/table/base/empty.js +2 -2
- package/es/table/base/globalStyleComponent.d.ts +5 -1
- package/es/table/base/globalStyleComponent.js +11 -7
- package/es/table/base/header.js +19 -8
- package/es/table/base/helpers/FastScrollManager.d.ts +96 -0
- package/es/table/base/helpers/FastScrollManager.js +167 -0
- package/es/table/base/helpers/SpanManager.js +2 -1
- package/es/table/base/helpers/TableDOMUtils.js +6 -5
- package/es/table/base/html-table.d.ts +1 -1
- package/es/table/base/html-table.js +16 -5
- package/es/table/base/interfaces.d.ts +2 -0
- package/es/table/base/loading.js +2 -2
- package/es/table/base/renderTemplates.js +16 -16
- package/es/table/base/styles.d.ts +2 -2
- package/es/table/base/styles.js +59 -4
- package/es/table/base/table.d.ts +14 -0
- package/es/table/base/table.js +163 -98
- package/es/table/base/utils.d.ts +1 -0
- package/es/table/base/utils.js +9 -3
- package/es/table/pipeline/features/colGroupExtendable.d.ts +1 -1
- package/es/table/pipeline/features/colGroupExtendable.js +7 -3
- package/es/table/pipeline/features/columnDrag.js +21 -12
- package/es/table/pipeline/features/columnFilter.js +5 -2
- package/es/table/pipeline/features/columnResizeWidth.js +11 -4
- package/es/table/pipeline/features/contextMenu.js +15 -8
- package/es/table/pipeline/features/featureApi/RowDragApi.js +2 -1
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +5 -4
- package/es/table/pipeline/features/filter/Filter.d.ts +2 -1
- package/es/table/pipeline/features/filter/Filter.js +13 -8
- package/es/table/pipeline/features/filter/FilterPanel.d.ts +3 -1
- package/es/table/pipeline/features/filter/FilterPanel.js +15 -5
- package/es/table/pipeline/features/rangeSelection.js +10 -10
- package/es/table/pipeline/features/rowDetail.js +2 -2
- package/es/table/pipeline/features/rowDrag.js +47 -19
- package/es/table/pipeline/features/rowGrouping.js +2 -2
- package/es/table/pipeline/features/sort.js +7 -6
- package/es/table/pipeline/features/tips.js +10 -6
- package/es/table/pipeline/features/treeMode.js +5 -5
- package/es/table/pipeline/features/treeSelect.js +2 -2
- package/es/table/pipeline/pipeline.js +2 -1
- package/es/table/pivot/cross-table/buildCrossTable.js +8 -6
- package/es/table/pivot/cross-table/cross-table.js +3 -1
- package/es/table/pivot/cross-table/interfaces.d.ts +1 -1
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +10 -8
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +11 -8
- package/es/table/pivot/pivot-utils/builders.js +3 -3
- package/es/table/pivot/pivot-utils/convert-utils.js +3 -3
- package/es/table/style/index.less +1 -1
- package/es/table/transforms/autoWidth.js +3 -3
- package/es/table/transforms/columnResize.js +5 -3
- package/es/table/transforms/sort.js +8 -6
- package/es/table/transforms/tips.js +4 -4
- package/es/table/transforms/treeMode.js +8 -6
- package/es/table/utils/buildTree.js +3 -3
- package/es/table/utils/collectNodes.js +3 -3
- package/es/table/utils/element.d.ts +1 -1
- package/es/table/utils/element.js +5 -3
- package/es/table/utils/exportTableAsExcel.js +3 -3
- package/es/table/utils/getTreeDepth.js +3 -3
- package/es/table/utils/groupBy.js +3 -3
- package/es/table/utils/makeRecursiveMapper.js +3 -3
- package/es/table/utils/mergeCellProps.js +1 -0
- package/es/table/utils/others.js +3 -3
- package/es/table/utils/traverseColumn.js +3 -3
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +8 -7
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +5 -4
- package/lib/_utils/arrayUtil.js +3 -2
- package/lib/_utils/formatUtil.js +5 -1
- package/lib/_utils/hooks.js +3 -3
- package/lib/_utils/index.js +3 -2
- package/lib/_utils/type.js +5 -3
- package/lib/_utils/usePopper.js +21 -18
- package/lib/config-provider/ConfigContext.js +2 -1
- package/lib/config-provider/compDefaultProps.js +2 -1
- package/lib/config-provider/configProvider.js +4 -3
- package/lib/config-provider/defaultConfig.js +2 -1
- package/lib/config-provider/index.js +2 -1
- package/lib/locale/index.js +4 -3
- package/lib/locale/locale.js +14 -10
- package/lib/locale/zh-CN.js +2 -1
- package/lib/style/color/colors.less +1 -1
- package/lib/style/components.less +1 -1
- package/lib/style/core/index.less +1 -1
- package/lib/style/core/motion/other.less +27 -27
- package/lib/style/core/motion/slide.less +53 -53
- package/lib/style/core/motion.less +1 -1
- package/lib/style/core/reset.less +185 -185
- package/lib/style/index.less +1 -1
- package/lib/style/mixins/index.less +18 -18
- package/lib/style/mixins/overlay.less +21 -21
- package/lib/style/mixins/reset.less +12 -12
- package/lib/style/themes/default.less +445 -445
- package/lib/table/base/BlankComponent.d.ts +11 -0
- package/lib/table/base/BlankComponent.js +75 -0
- package/lib/table/base/calculations.js +3 -3
- package/lib/table/base/empty.js +4 -4
- package/lib/table/base/globalStyleComponent.d.ts +5 -1
- package/lib/table/base/globalStyleComponent.js +16 -11
- package/lib/table/base/header.js +19 -8
- package/lib/table/base/helpers/FastScrollManager.d.ts +96 -0
- package/lib/table/base/helpers/FastScrollManager.js +175 -0
- package/lib/table/base/helpers/SpanManager.js +5 -3
- package/lib/table/base/helpers/TableDOMUtils.js +9 -7
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +2 -2
- package/lib/table/base/html-table.d.ts +1 -1
- package/lib/table/base/html-table.js +16 -5
- package/lib/table/base/interfaces.d.ts +2 -0
- package/lib/table/base/loading.js +2 -2
- package/lib/table/base/renderTemplates.js +18 -18
- package/lib/table/base/styles.d.ts +2 -2
- package/lib/table/base/styles.js +74 -11
- package/lib/table/base/table.d.ts +14 -0
- package/lib/table/base/table.js +173 -109
- package/lib/table/base/utils.d.ts +1 -0
- package/lib/table/base/utils.js +28 -13
- package/lib/table/common-views.js +8 -4
- package/lib/table/internals.js +3 -2
- package/lib/table/pipeline/const.js +3 -2
- package/lib/table/pipeline/features/autoFill.js +6 -3
- package/lib/table/pipeline/features/colGroupExtendable.d.ts +1 -1
- package/lib/table/pipeline/features/colGroupExtendable.js +10 -5
- package/lib/table/pipeline/features/columnDrag.js +21 -12
- package/lib/table/pipeline/features/columnFilter.js +5 -2
- package/lib/table/pipeline/features/columnResizeWidth.js +19 -9
- package/lib/table/pipeline/features/contextMenu.js +16 -9
- package/lib/table/pipeline/features/featureApi/RowDragApi.js +5 -3
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +9 -7
- package/lib/table/pipeline/features/filter/Filter.d.ts +2 -1
- package/lib/table/pipeline/features/filter/Filter.js +17 -11
- package/lib/table/pipeline/features/filter/FilterPanel.d.ts +3 -1
- package/lib/table/pipeline/features/filter/FilterPanel.js +19 -8
- package/lib/table/pipeline/features/filter/util.js +3 -2
- package/lib/table/pipeline/features/footerDataSource.js +2 -1
- package/lib/table/pipeline/features/rangeSelection.js +14 -12
- package/lib/table/pipeline/features/rowDetail.js +2 -2
- package/lib/table/pipeline/features/rowDrag.js +53 -22
- package/lib/table/pipeline/features/rowGrouping.js +2 -2
- package/lib/table/pipeline/features/sort.js +7 -6
- package/lib/table/pipeline/features/tips.js +10 -6
- package/lib/table/pipeline/features/treeMode.js +9 -7
- package/lib/table/pipeline/features/treeSelect.js +2 -2
- package/lib/table/pipeline/index.js +2 -2
- package/lib/table/pipeline/pipeline.js +4 -2
- package/lib/table/pivot/cross-table/buildCrossTable.js +8 -6
- package/lib/table/pivot/cross-table/constants.js +2 -1
- package/lib/table/pivot/cross-table/cross-table.js +6 -3
- package/lib/table/pivot/cross-table/interfaces.d.ts +1 -1
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +10 -8
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +13 -9
- package/lib/table/pivot/pivot-utils/builders.js +3 -3
- package/lib/table/pivot/pivot-utils/convert-utils.js +3 -3
- package/lib/table/style/index.less +1 -1
- package/lib/table/transforms/autoWidth.js +5 -5
- package/lib/table/transforms/columnResize.js +7 -5
- package/lib/table/transforms/sort.js +10 -8
- package/lib/table/transforms/tips.js +4 -4
- package/lib/table/transforms/treeMode.js +10 -8
- package/lib/table/use/useResizeObserver.js +2 -1
- package/lib/table/utils/browserType.js +4 -2
- package/lib/table/utils/buildTree.js +3 -3
- package/lib/table/utils/collectNodes.js +3 -3
- package/lib/table/utils/console.js +3 -2
- package/lib/table/utils/copyToClipboard.js +2 -1
- package/lib/table/utils/element.d.ts +1 -1
- package/lib/table/utils/element.js +5 -3
- package/lib/table/utils/exportTableAsExcel.js +3 -3
- package/lib/table/utils/getTreeDepth.js +3 -3
- package/lib/table/utils/groupBy.js +3 -3
- package/lib/table/utils/keyCode.js +2 -1
- package/lib/table/utils/makeRecursiveMapper.js +3 -3
- package/lib/table/utils/mergeCellProps.js +1 -0
- package/lib/table/utils/others.js +5 -4
- package/lib/table/utils/proto.js +2 -1
- package/lib/table/utils/selectColumn.js +4 -2
- package/lib/table/utils/traverseColumn.js +3 -3
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +11 -9
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +8 -6
- package/package.json +218 -218
package/es/table/base/table.js
CHANGED
|
@@ -7,17 +7,17 @@ import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
|
7
7
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
8
8
|
import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
9
9
|
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
10
|
+
import _inherits from "@babel/runtime-corejs3/helpers/inherits";
|
|
10
11
|
import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/possibleConstructorReturn";
|
|
11
12
|
import _getPrototypeOf from "@babel/runtime-corejs3/helpers/getPrototypeOf";
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
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; } } }; }
|
|
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); }
|
|
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; }
|
|
16
16
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
17
17
|
import _flatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/flat";
|
|
18
18
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
19
|
-
function
|
|
20
|
-
function _isNativeReflectConstruct() {
|
|
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); }; }
|
|
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; } }
|
|
21
21
|
import cx from 'classnames';
|
|
22
22
|
import React from 'react';
|
|
23
23
|
import { BehaviorSubject, combineLatest, noop, Subscription, Subject, from } from 'rxjs';
|
|
@@ -28,13 +28,15 @@ import TableHeader from './header';
|
|
|
28
28
|
import { getRichVisibleRectsStream } from './helpers/getRichVisibleRectsStream';
|
|
29
29
|
import { getFullRenderRange, makeRowHeightManager } from './helpers/rowHeightManager';
|
|
30
30
|
import { TableDOMHelper } from './helpers/TableDOMUtils';
|
|
31
|
+
import { FastScrollManager } from './helpers/FastScrollManager';
|
|
31
32
|
import { HtmlTable } from './html-table';
|
|
32
33
|
import Loading from './loading';
|
|
33
34
|
import { Classes, LOCK_SHADOW_PADDING, StyledArtTableWrapper } from './styles';
|
|
34
35
|
import GlobalStyleComponent from './globalStyleComponent';
|
|
35
|
-
import { addResizeObserver, getScrollbarSize, OVERSCAN_SIZE, shallowEqual, STYLED_REF_PROP, sum, syncScrollLeft, throttledWindowResize$, getTableScrollFooterDOM, getTableScrollHeaderDOM, cssPolifill } from './utils';
|
|
36
|
+
import { addResizeObserver, getScrollbarSize, OVERSCAN_SIZE, shallowEqual, STYLED_REF_PROP, sum, syncScrollLeft, throttledWindowResize$, getTableScrollFooterDOM, getTableScrollHeaderDOM, cssPolifill, swapRTLDirection } from './utils';
|
|
36
37
|
import { console, browserType, isStickyUIDegrade } from '../utils';
|
|
37
38
|
import getTableRenderTemplate from './renderTemplates';
|
|
39
|
+
import { TopBlank, BottomBlank } from './BlankComponent';
|
|
38
40
|
var propsDotEmptyContentDeprecatedWarned = false;
|
|
39
41
|
function warnPropsDotEmptyContentIsDeprecated() {
|
|
40
42
|
if (!propsDotEmptyContentDeprecatedWarned) {
|
|
@@ -43,14 +45,19 @@ function warnPropsDotEmptyContentIsDeprecated() {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
48
|
+
_inherits(BaseTable, _React$Component);
|
|
49
|
+
var _super = _createSuper(BaseTable);
|
|
46
50
|
function BaseTable(props) {
|
|
47
51
|
var _this;
|
|
48
52
|
_classCallCheck(this, BaseTable);
|
|
49
|
-
_this =
|
|
53
|
+
_this = _super.call(this, props);
|
|
50
54
|
_this.rowHeightManager = makeRowHeightManager(_this.props.dataSource.length, _this.props.estimatedRowHeight);
|
|
51
55
|
_this.artTableWrapperRef = /*#__PURE__*/React.createRef();
|
|
52
56
|
_this.hasScrollY = false;
|
|
53
57
|
_this.offsetY = 0;
|
|
58
|
+
// Blank组件的引用,用于快速滚动时直接更新
|
|
59
|
+
_this.topBlankRef = /*#__PURE__*/React.createRef();
|
|
60
|
+
_this.bottomBlankRef = /*#__PURE__*/React.createRef();
|
|
54
61
|
_this.handleRowMouseEnter = function (e) {
|
|
55
62
|
var nodeList = _this.domHelper.getRowNodeListByEvent(e);
|
|
56
63
|
nodeList && nodeList.forEach(function (node) {
|
|
@@ -70,8 +77,7 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
70
77
|
getRowProps = _this$props.getRowProps,
|
|
71
78
|
primaryKey = _this$props.primaryKey,
|
|
72
79
|
isLoading = _this$props.isLoading,
|
|
73
|
-
emptyCellHeight = _this$props.emptyCellHeight
|
|
74
|
-
footerDataSource = _this$props.footerDataSource;
|
|
80
|
+
emptyCellHeight = _this$props.emptyCellHeight;
|
|
75
81
|
var tableBodyClassName = cx(Classes.tableBody, Classes.horizontalScrollContainer);
|
|
76
82
|
// 低版本Edge浏览器下也会出现双滚动条,这里设置overflow: 'hidden',先去掉edge的方向键控制滚动条的功能
|
|
77
83
|
var virtualStyle = browserType.isIE || browserType.isEdge ? {
|
|
@@ -121,13 +127,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
121
127
|
className: Classes.virtual,
|
|
122
128
|
tabIndex: -1,
|
|
123
129
|
style: virtualStyle
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
height: topBlank
|
|
129
|
-
}
|
|
130
|
-
})), /*#__PURE__*/React.createElement(HtmlTable, {
|
|
130
|
+
}, /*#__PURE__*/React.createElement(TopBlank, {
|
|
131
|
+
ref: _this.topBlankRef,
|
|
132
|
+
height: topBlank
|
|
133
|
+
}), /*#__PURE__*/React.createElement(HtmlTable, {
|
|
131
134
|
tbodyHtmlTag: "tbody",
|
|
132
135
|
getRowProps: getRowProps,
|
|
133
136
|
primaryKey: primaryKey,
|
|
@@ -139,13 +142,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
139
142
|
limit: bottomIndex,
|
|
140
143
|
last: dataSource.length - 1
|
|
141
144
|
}
|
|
142
|
-
}),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
height: bottomBlank
|
|
147
|
-
}
|
|
148
|
-
}))));
|
|
145
|
+
}), /*#__PURE__*/React.createElement(BottomBlank, {
|
|
146
|
+
ref: _this.bottomBlankRef,
|
|
147
|
+
height: bottomBlank
|
|
148
|
+
})));
|
|
149
149
|
};
|
|
150
150
|
_this.state = {
|
|
151
151
|
hasScroll: true,
|
|
@@ -159,11 +159,30 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
159
159
|
maxRenderHeight: 600,
|
|
160
160
|
maxRenderWidth: 800
|
|
161
161
|
};
|
|
162
|
+
// 初始化快速滚动管理器
|
|
163
|
+
var fastScrollCallbacks = {
|
|
164
|
+
onFastScrollStart: function onFastScrollStart(renderData) {
|
|
165
|
+
_this.setState({
|
|
166
|
+
previousRenderData: renderData
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
onFastScrollEnd: function onFastScrollEnd(scrollData) {
|
|
170
|
+
_this.setState({
|
|
171
|
+
previousRenderData: undefined,
|
|
172
|
+
offsetY: scrollData.offsetY,
|
|
173
|
+
maxRenderHeight: scrollData.maxRenderHeight,
|
|
174
|
+
maxRenderWidth: scrollData.maxRenderWidth
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
getCurrentRenderRange: function getCurrentRenderRange(offsetY, maxRenderHeight, dataLength) {
|
|
178
|
+
return _this.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, dataLength);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
_this.fastScrollManager = new FastScrollManager(fastScrollCallbacks);
|
|
162
182
|
return _this;
|
|
163
183
|
}
|
|
164
184
|
/** @deprecated BaseTable.getDoms() 已经过时,请勿调用 */
|
|
165
|
-
|
|
166
|
-
return _createClass(BaseTable, [{
|
|
185
|
+
_createClass(BaseTable, [{
|
|
167
186
|
key: "getDoms",
|
|
168
187
|
value: function getDoms() {
|
|
169
188
|
console.warn('[kd-table] BaseTable.getDoms() 已经过时');
|
|
@@ -281,11 +300,14 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
281
300
|
}, {
|
|
282
301
|
key: "syncHorizontalScroll",
|
|
283
302
|
value: function syncHorizontalScroll(x) {
|
|
284
|
-
|
|
303
|
+
var _x = Math.abs(x);
|
|
304
|
+
this.updateOffsetX(_x);
|
|
285
305
|
var flat = _flatInstanceProperty(this.lastInfo);
|
|
306
|
+
var shouldShowLeftByScroll = _x > 0;
|
|
307
|
+
var shouldShowRighByScroll = _x < this.domHelper.virtual.scrollWidth - this.domHelper.virtual.clientWidth;
|
|
286
308
|
var leftLockShadow = this.domHelper.getLeftLockShadow();
|
|
287
309
|
if (leftLockShadow) {
|
|
288
|
-
var shouldShowLeftLockShadow = flat.left.length > 0 && this.state.needRenderLock &&
|
|
310
|
+
var shouldShowLeftLockShadow = flat.left.length > 0 && this.state.needRenderLock && shouldShowLeftByScroll;
|
|
289
311
|
if (shouldShowLeftLockShadow) {
|
|
290
312
|
leftLockShadow.classList.add('show-shadow');
|
|
291
313
|
} else {
|
|
@@ -294,7 +316,7 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
294
316
|
}
|
|
295
317
|
var rightLockShadow = this.domHelper.getRightLockShadow();
|
|
296
318
|
if (rightLockShadow) {
|
|
297
|
-
var shouldShowRightLockShadow = flat.right.length > 0 && this.state.needRenderLock &&
|
|
319
|
+
var shouldShowRightLockShadow = flat.right.length > 0 && this.state.needRenderLock && shouldShowRighByScroll;
|
|
298
320
|
if (shouldShowRightLockShadow) {
|
|
299
321
|
rightLockShadow.classList.add('show-shadow');
|
|
300
322
|
} else {
|
|
@@ -305,11 +327,18 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
305
327
|
}, {
|
|
306
328
|
key: "getVerticalRenderRange",
|
|
307
329
|
value: function getVerticalRenderRange(useVirtual) {
|
|
308
|
-
var
|
|
330
|
+
var _this$props4 = this.props,
|
|
331
|
+
dataSource = _this$props4.dataSource,
|
|
332
|
+
isLowPerformance = _this$props4.isLowPerformance;
|
|
309
333
|
var _this$state = this.state,
|
|
310
334
|
offsetY = _this$state.offsetY,
|
|
311
|
-
maxRenderHeight = _this$state.maxRenderHeight
|
|
335
|
+
maxRenderHeight = _this$state.maxRenderHeight,
|
|
336
|
+
previousRenderData = _this$state.previousRenderData;
|
|
312
337
|
var rowCount = dataSource.length;
|
|
338
|
+
// 只有在启用快速滚动时才使用 FastScrollManager 的判断
|
|
339
|
+
if (isLowPerformance && this.fastScrollManager.getIsFastScrolling() && (previousRenderData === null || previousRenderData === void 0 ? void 0 : previousRenderData.verticalRenderRange)) {
|
|
340
|
+
return previousRenderData.verticalRenderRange;
|
|
341
|
+
}
|
|
313
342
|
if (useVirtual.vertical) {
|
|
314
343
|
return this.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, rowCount);
|
|
315
344
|
} else {
|
|
@@ -320,12 +349,12 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
320
349
|
key: "renderTableFooter",
|
|
321
350
|
value: function renderTableFooter(info) {
|
|
322
351
|
// console.log('render footer')
|
|
323
|
-
var _this$
|
|
324
|
-
_this$
|
|
325
|
-
footerDataSource = _this$
|
|
326
|
-
getRowProps = _this$
|
|
327
|
-
primaryKey = _this$
|
|
328
|
-
stickyBottom = _this$
|
|
352
|
+
var _this$props5 = this.props,
|
|
353
|
+
_this$props5$footerDa = _this$props5.footerDataSource,
|
|
354
|
+
footerDataSource = _this$props5$footerDa === void 0 ? [] : _this$props5$footerDa,
|
|
355
|
+
getRowProps = _this$props5.getRowProps,
|
|
356
|
+
primaryKey = _this$props5.primaryKey,
|
|
357
|
+
stickyBottom = _this$props5.stickyBottom;
|
|
329
358
|
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
330
359
|
var renderFooter = getTableRenderTemplate('footer');
|
|
331
360
|
if (typeof renderFooter === 'function') {
|
|
@@ -366,22 +395,19 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
366
395
|
}, {
|
|
367
396
|
key: "renderLockShadows",
|
|
368
397
|
value: function renderLockShadows(info) {
|
|
398
|
+
var _style, _style2;
|
|
369
399
|
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
370
400
|
// console.log('render LockShadows')
|
|
401
|
+
var leftLockShadowWidth = info.leftLockTotalWidth + LOCK_SHADOW_PADDING;
|
|
402
|
+
var rightLockShadownWidth = info.rightLockTotalWidth + LOCK_SHADOW_PADDING + stickyRightOffset;
|
|
371
403
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
372
404
|
className: Classes.lockShadowMask,
|
|
373
|
-
style: {
|
|
374
|
-
left: 0,
|
|
375
|
-
width: info.leftLockTotalWidth + LOCK_SHADOW_PADDING
|
|
376
|
-
}
|
|
405
|
+
style: (_style = {}, _defineProperty(_style, swapRTLDirection(info.direction, 'left'), 0), _defineProperty(_style, "width", leftLockShadowWidth), _style)
|
|
377
406
|
}, /*#__PURE__*/React.createElement("div", {
|
|
378
407
|
className: cx(Classes.lockShadow, Classes.leftLockShadow)
|
|
379
408
|
})), /*#__PURE__*/React.createElement("div", {
|
|
380
409
|
className: Classes.lockShadowMask,
|
|
381
|
-
style: {
|
|
382
|
-
right: 0,
|
|
383
|
-
width: info.rightLockTotalWidth + LOCK_SHADOW_PADDING + stickyRightOffset
|
|
384
|
-
}
|
|
410
|
+
style: (_style2 = {}, _defineProperty(_style2, swapRTLDirection(info.direction, 'right'), 0), _defineProperty(_style2, "width", rightLockShadownWidth), _style2)
|
|
385
411
|
}, /*#__PURE__*/React.createElement("div", {
|
|
386
412
|
className: cx(Classes.lockShadow, Classes.rightLockShadow)
|
|
387
413
|
})));
|
|
@@ -390,9 +416,9 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
390
416
|
key: "renderStickyScroll",
|
|
391
417
|
value: function renderStickyScroll(info) {
|
|
392
418
|
// console.log('render stickyscroll')
|
|
393
|
-
var _this$
|
|
394
|
-
hasStickyScroll = _this$
|
|
395
|
-
stickyBottom = _this$
|
|
419
|
+
var _this$props6 = this.props,
|
|
420
|
+
hasStickyScroll = _this$props6.hasStickyScroll,
|
|
421
|
+
stickyBottom = _this$props6.stickyBottom;
|
|
396
422
|
var hasScroll = this.state.hasScroll;
|
|
397
423
|
var isScroll = hasStickyScroll && hasScroll;
|
|
398
424
|
var stickyScrollContainerStyle = this.getStickyScrollContainerStyle();
|
|
@@ -429,9 +455,9 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
429
455
|
}, {
|
|
430
456
|
key: "getStickyScrollContainerStyle",
|
|
431
457
|
value: function getStickyScrollContainerStyle() {
|
|
432
|
-
var _this$
|
|
433
|
-
hasStickyScroll = _this$
|
|
434
|
-
stickyScrollHeight = _this$
|
|
458
|
+
var _this$props7 = this.props,
|
|
459
|
+
hasStickyScroll = _this$props7.hasStickyScroll,
|
|
460
|
+
stickyScrollHeight = _this$props7.stickyScrollHeight;
|
|
435
461
|
var hasScroll = this.state.hasScroll;
|
|
436
462
|
var isScroll = hasStickyScroll && hasScroll;
|
|
437
463
|
var height = stickyScrollHeight === 'auto' ? this.getScrollBarWidth() : stickyScrollHeight;
|
|
@@ -445,24 +471,27 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
445
471
|
}, {
|
|
446
472
|
key: "render",
|
|
447
473
|
value: function render() {
|
|
474
|
+
var _cx;
|
|
448
475
|
// console.log('render table')
|
|
449
476
|
var info = calculateRenderInfo(this);
|
|
450
477
|
this.lastInfo = info;
|
|
451
|
-
var _this$
|
|
452
|
-
dataSource = _this$
|
|
453
|
-
className = _this$
|
|
454
|
-
style = _this$
|
|
455
|
-
hasHeader = _this$
|
|
456
|
-
useOuterBorder = _this$
|
|
457
|
-
isStickyHead = _this$
|
|
458
|
-
isStickyHeader = _this$
|
|
459
|
-
isStickyFooter = _this$
|
|
460
|
-
isLoading = _this$
|
|
461
|
-
getTableProps = _this$
|
|
462
|
-
footerDataSource = _this$
|
|
463
|
-
components = _this$
|
|
464
|
-
bordered = _this$
|
|
465
|
-
|
|
478
|
+
var _this$props8 = this.props,
|
|
479
|
+
dataSource = _this$props8.dataSource,
|
|
480
|
+
className = _this$props8.className,
|
|
481
|
+
style = _this$props8.style,
|
|
482
|
+
hasHeader = _this$props8.hasHeader,
|
|
483
|
+
useOuterBorder = _this$props8.useOuterBorder,
|
|
484
|
+
isStickyHead = _this$props8.isStickyHead,
|
|
485
|
+
isStickyHeader = _this$props8.isStickyHeader,
|
|
486
|
+
isStickyFooter = _this$props8.isStickyFooter,
|
|
487
|
+
isLoading = _this$props8.isLoading,
|
|
488
|
+
getTableProps = _this$props8.getTableProps,
|
|
489
|
+
footerDataSource = _this$props8.footerDataSource,
|
|
490
|
+
components = _this$props8.components,
|
|
491
|
+
bordered = _this$props8.bordered,
|
|
492
|
+
direction = _this$props8.direction;
|
|
493
|
+
info.direction = direction;
|
|
494
|
+
var artTableWrapperClassName = cx(Classes.artTableWrapper, (_cx = {
|
|
466
495
|
'use-outer-border': useOuterBorder,
|
|
467
496
|
empty: dataSource.length === 0,
|
|
468
497
|
lock: info.hasLockColumn,
|
|
@@ -470,13 +499,19 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
470
499
|
'sticky-header': isStickyHeader !== null && isStickyHeader !== void 0 ? isStickyHeader : isStickyHead,
|
|
471
500
|
'has-footer': footerDataSource.length > 0,
|
|
472
501
|
'sticky-footer': isStickyFooter
|
|
473
|
-
}, Classes.artTableBordered, bordered), 'ie-polyfill-wrapper', browserType.isIE), 'sticky-polyfill-wrapper', isStickyUIDegrade()), className);
|
|
502
|
+
}, _defineProperty(_cx, Classes.artTableBordered, bordered), _defineProperty(_cx, 'ie-polyfill-wrapper', browserType.isIE), _defineProperty(_cx, 'sticky-polyfill-wrapper', isStickyUIDegrade()), _cx), className);
|
|
474
503
|
var artTableWrapperProps = _defineProperty({
|
|
475
504
|
className: artTableWrapperClassName,
|
|
476
|
-
style: style
|
|
505
|
+
style: _extends(_extends({}, style), {
|
|
506
|
+
direction: direction
|
|
507
|
+
})
|
|
477
508
|
}, STYLED_REF_PROP, this.artTableWrapperRef);
|
|
478
509
|
var tableProps = getTableProps() || {};
|
|
479
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStyleComponent,
|
|
510
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStyleComponent, {
|
|
511
|
+
direction: info.direction
|
|
512
|
+
}), /*#__PURE__*/React.createElement(StyledArtTableWrapper, _extends({}, artTableWrapperProps, {
|
|
513
|
+
direction: info.direction
|
|
514
|
+
}), /*#__PURE__*/React.createElement(Loading, {
|
|
480
515
|
visible: isLoading,
|
|
481
516
|
LoadingIcon: components.LoadingIcon,
|
|
482
517
|
LoadingContentWrapper: components.LoadingContentWrapper
|
|
@@ -495,10 +530,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
495
530
|
this.initSubscriptions();
|
|
496
531
|
this.didMountOrUpdate();
|
|
497
532
|
// console.log('did mount end')
|
|
498
|
-
var _this$
|
|
499
|
-
cssVariables = _this$
|
|
500
|
-
enableCSSVariables = _this$
|
|
501
|
-
bordered = _this$
|
|
533
|
+
var _this$props9 = this.props,
|
|
534
|
+
cssVariables = _this$props9.cssVariables,
|
|
535
|
+
enableCSSVariables = _this$props9.enableCSSVariables,
|
|
536
|
+
bordered = _this$props9.bordered;
|
|
502
537
|
cssPolifill({
|
|
503
538
|
variables: cssVariables || {},
|
|
504
539
|
enableCSSVariables: enableCSSVariables,
|
|
@@ -513,10 +548,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
513
548
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
514
549
|
var _a;
|
|
515
550
|
// console.log('did update start')
|
|
516
|
-
var _this$
|
|
517
|
-
cssVariables = _this$
|
|
518
|
-
enableCSSVariables = _this$
|
|
519
|
-
bordered = _this$
|
|
551
|
+
var _this$props10 = this.props,
|
|
552
|
+
cssVariables = _this$props10.cssVariables,
|
|
553
|
+
enableCSSVariables = _this$props10.enableCSSVariables,
|
|
554
|
+
bordered = _this$props10.bordered;
|
|
520
555
|
if (!shallowEqual(prevProps === null || prevProps === void 0 ? void 0 : prevProps.cssVariables, (_a = this.props) === null || _a === void 0 ? void 0 : _a.cssVariables)) {
|
|
521
556
|
cssPolifill({
|
|
522
557
|
variables: cssVariables || {},
|
|
@@ -532,10 +567,13 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
532
567
|
}, {
|
|
533
568
|
key: "didMountOrUpdate",
|
|
534
569
|
value: function didMountOrUpdate(prevProps, prevState) {
|
|
535
|
-
this
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
570
|
+
var _this2 = this;
|
|
571
|
+
window.requestAnimationFrame(function () {
|
|
572
|
+
_this2.syncHorizontalScrollFromTableBody();
|
|
573
|
+
_this2.updateStickyScroll();
|
|
574
|
+
_this2.adjustNeedRenderLock();
|
|
575
|
+
_this2.updateRowHeightManager();
|
|
576
|
+
});
|
|
539
577
|
this.updateScrollLeftWhenLayoutChanged(prevProps, prevState);
|
|
540
578
|
}
|
|
541
579
|
}, {
|
|
@@ -557,25 +595,25 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
557
595
|
}, {
|
|
558
596
|
key: "initSubscriptions",
|
|
559
597
|
value: function initSubscriptions() {
|
|
560
|
-
var
|
|
598
|
+
var _this3 = this;
|
|
561
599
|
var _this$domHelper2 = this.domHelper,
|
|
562
600
|
virtual = _this$domHelper2.virtual,
|
|
563
601
|
stickyScroll = _this$domHelper2.stickyScroll;
|
|
564
602
|
this.rootSubscription.add(throttledWindowResize$.subscribe(function () {
|
|
565
|
-
|
|
566
|
-
|
|
603
|
+
_this3.updateStickyScroll();
|
|
604
|
+
_this3.adjustNeedRenderLock();
|
|
567
605
|
}));
|
|
568
606
|
this.resizeSubject.pipe(op.debounceTime(100)).subscribe(function () {
|
|
569
607
|
var _a, _b;
|
|
570
|
-
(_b = (_a =
|
|
608
|
+
(_b = (_a = _this3.props).setTableWidth) === null || _b === void 0 ? void 0 : _b.call(_a, _this3.domHelper.tableBody.clientWidth);
|
|
571
609
|
});
|
|
572
610
|
var handleTableWrapperResize = function handleTableWrapperResize() {
|
|
573
|
-
|
|
611
|
+
_this3.resizeSubject.next();
|
|
574
612
|
};
|
|
575
613
|
this.resizeObserver = addResizeObserver(this.domHelper.artTableWrapper, handleTableWrapperResize);
|
|
576
614
|
// 滚动同步
|
|
577
615
|
this.rootSubscription.add(syncScrollLeft([getTableScrollHeaderDOM(this.domHelper), virtual, getTableScrollFooterDOM(this.domHelper), stickyScroll], function (scrollLeft) {
|
|
578
|
-
|
|
616
|
+
_this3.syncHorizontalScroll(scrollLeft);
|
|
579
617
|
}));
|
|
580
618
|
var richVisibleRects$ = getRichVisibleRectsStream(this.domHelper.virtual, this.props$.pipe(op.skip(1), op.mapTo('structure-may-change')), this.props.virtualDebugLabel).pipe(op.shareReplay());
|
|
581
619
|
// 每当可见部分发生变化的时候,调整 loading icon 的未知(如果 loading icon 存在的话)
|
|
@@ -589,7 +627,7 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
589
627
|
}))]).subscribe(function (_ref3) {
|
|
590
628
|
var _ref4 = _slicedToArray(_ref3, 1),
|
|
591
629
|
clipRect = _ref4[0];
|
|
592
|
-
var loadingIndicator =
|
|
630
|
+
var loadingIndicator = _this3.domHelper.getLoadingIndicator();
|
|
593
631
|
if (!loadingIndicator) {
|
|
594
632
|
return;
|
|
595
633
|
}
|
|
@@ -600,9 +638,9 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
600
638
|
}));
|
|
601
639
|
// 每当可见部分发生变化的时候,如果开启了虚拟滚动,则重新触发 render
|
|
602
640
|
this.rootSubscription.add(richVisibleRects$.pipe(op.filter(function () {
|
|
603
|
-
var
|
|
604
|
-
horizontal =
|
|
605
|
-
vertical =
|
|
641
|
+
var _this3$lastInfo$useVi = _this3.lastInfo.useVirtual,
|
|
642
|
+
horizontal = _this3$lastInfo$useVi.horizontal,
|
|
643
|
+
vertical = _this3$lastInfo$useVi.vertical;
|
|
606
644
|
return horizontal || vertical;
|
|
607
645
|
}), op.map(function (_ref5) {
|
|
608
646
|
var clipRect = _ref5.clipRect,
|
|
@@ -619,8 +657,29 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
619
657
|
}
|
|
620
658
|
// 因为 overscan 的存在,滚动较小的距离时不需要触发组件重渲染
|
|
621
659
|
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;
|
|
660
|
+
}),
|
|
661
|
+
// 快速滚动检测和处理
|
|
662
|
+
op.tap(function (sizeAndOffset) {
|
|
663
|
+
// 只有在启用快速滚动时才使用 FastScrollManager 处理滚动事件
|
|
664
|
+
if (_this3.props.isLowPerformance) {
|
|
665
|
+
_this3.fastScrollManager.handleScrollEvent(sizeAndOffset, {
|
|
666
|
+
offsetY: _this3.state.offsetY,
|
|
667
|
+
maxRenderHeight: _this3.state.maxRenderHeight,
|
|
668
|
+
maxRenderWidth: _this3.state.maxRenderWidth
|
|
669
|
+
}, _this3.props.dataSource.length, _this3.domHelper.virtual.scrollHeight);
|
|
670
|
+
}
|
|
622
671
|
})).subscribe(function (sizeAndOffset) {
|
|
623
|
-
|
|
672
|
+
var _a, _b;
|
|
673
|
+
// 正常滚动时也需要实时更新 blank 高度,确保缓慢滚动时的视觉连续性
|
|
674
|
+
var currentRange = _this3.rowHeightManager.getRenderRange(sizeAndOffset.offsetY, sizeAndOffset.maxRenderHeight, _this3.props.dataSource.length);
|
|
675
|
+
// 直接更新 DOM,避免等待下次渲染
|
|
676
|
+
(_a = _this3.topBlankRef.current) === null || _a === void 0 ? void 0 : _a.updateHeight(currentRange.topBlank);
|
|
677
|
+
(_b = _this3.bottomBlankRef.current) === null || _b === void 0 ? void 0 : _b.updateHeight(currentRange.bottomBlank);
|
|
678
|
+
// 只有在启用快速滚动时才检查快速滚动状态
|
|
679
|
+
if (_this3.props.isLowPerformance && _this3.fastScrollManager.getIsFastScrolling()) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
_this3.setState(sizeAndOffset);
|
|
624
683
|
}));
|
|
625
684
|
this.rootSubscription.add(richVisibleRects$.pipe(op.map(function (_ref6) {
|
|
626
685
|
var clipRect = _ref6.clipRect,
|
|
@@ -638,13 +697,13 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
638
697
|
var _a;
|
|
639
698
|
var offsetY = sizeAndOffset.offsetY,
|
|
640
699
|
maxRenderHeight = sizeAndOffset.maxRenderHeight;
|
|
641
|
-
var scrollDirection = offsetY -
|
|
642
|
-
|
|
643
|
-
var rowCount =
|
|
644
|
-
var vertical =
|
|
700
|
+
var scrollDirection = offsetY - _this3.offsetY >= 0 ? 'down' : 'up';
|
|
701
|
+
_this3.offsetY = offsetY;
|
|
702
|
+
var rowCount = _this3.props.dataSource.length;
|
|
703
|
+
var vertical = _this3.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, rowCount);
|
|
645
704
|
var topIndex = vertical.topIndex,
|
|
646
705
|
bottomIndex = vertical.bottomIndex;
|
|
647
|
-
var blockSize = ((_a =
|
|
706
|
+
var blockSize = ((_a = _this3.props.scrollLoad) === null || _a === void 0 ? void 0 : _a.blockSize) || 200;
|
|
648
707
|
var topBlockStartIndex = Math.floor(Math.max(topIndex - 1, 0) / blockSize) * blockSize;
|
|
649
708
|
var bottomBlockStartIndex = Math.floor((bottomIndex + 1) / blockSize) * blockSize;
|
|
650
709
|
return scrollDirection === 'down' ? [topBlockStartIndex, bottomBlockStartIndex] : [bottomBlockStartIndex, topBlockStartIndex];
|
|
@@ -659,7 +718,7 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
659
718
|
// 过滤掉重复掉值
|
|
660
719
|
op.distinctUntilChanged()).subscribe(function (startIndex) {
|
|
661
720
|
var _a;
|
|
662
|
-
(_a =
|
|
721
|
+
(_a = _this3.props.scrollLoad) === null || _a === void 0 ? void 0 : _a.callback(startIndex);
|
|
663
722
|
}));
|
|
664
723
|
}
|
|
665
724
|
}, {
|
|
@@ -669,6 +728,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
669
728
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
670
729
|
this.rootSubscription.unsubscribe();
|
|
671
730
|
this.resizeSubject.unsubscribe();
|
|
731
|
+
// 只有在启用快速滚动时才清理快速滚动管理器
|
|
732
|
+
if (this.props.isLowPerformance) {
|
|
733
|
+
this.fastScrollManager.cleanup();
|
|
734
|
+
}
|
|
672
735
|
}
|
|
673
736
|
/** 更新 DOM 节点的引用,方便其他方法直接操作 DOM */
|
|
674
737
|
}, {
|
|
@@ -750,6 +813,7 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
750
813
|
}
|
|
751
814
|
}
|
|
752
815
|
}]);
|
|
816
|
+
return BaseTable;
|
|
753
817
|
}(React.Component);
|
|
754
818
|
BaseTable.defaultProps = {
|
|
755
819
|
hasHeader: true,
|
|
@@ -762,6 +826,7 @@ BaseTable.defaultProps = {
|
|
|
762
826
|
stickyScrollHeight: 'auto',
|
|
763
827
|
useVirtual: 'auto',
|
|
764
828
|
estimatedRowHeight: 48,
|
|
829
|
+
isLowPerformance: false,
|
|
765
830
|
isLoading: false,
|
|
766
831
|
components: {},
|
|
767
832
|
getTableProps: noop,
|
package/es/table/base/utils.d.ts
CHANGED
|
@@ -43,4 +43,5 @@ export declare const cssPolifill: ({ variables, enableCSSVariables, bordered }:
|
|
|
43
43
|
enableCSSVariables?: boolean;
|
|
44
44
|
bordered?: boolean;
|
|
45
45
|
}) => void;
|
|
46
|
+
export declare const swapRTLDirection: (direction: string, directionKey: 'left' | 'right') => 'left' | 'right';
|
|
46
47
|
export {};
|
package/es/table/base/utils.js
CHANGED
|
@@ -4,9 +4,9 @@ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
|
4
4
|
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
5
5
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
6
6
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
7
|
-
function _createForOfIteratorHelper(
|
|
8
|
-
function _unsupportedIterableToArray(
|
|
9
|
-
function _arrayLikeToArray(
|
|
7
|
+
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(_e) { throw _e; }, 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(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 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); }
|
|
9
|
+
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; }
|
|
10
10
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
11
11
|
import _Object$is from "@babel/runtime-corejs3/core-js-stable/object/is";
|
|
12
12
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
@@ -205,4 +205,10 @@ export var cssPolifill = function cssPolifill(_ref) {
|
|
|
205
205
|
watch: true,
|
|
206
206
|
silent: true
|
|
207
207
|
});
|
|
208
|
+
};
|
|
209
|
+
export var swapRTLDirection = function swapRTLDirection(direction, directionKey) {
|
|
210
|
+
var isRTL = direction === 'rtl';
|
|
211
|
+
if (directionKey === 'left' && isRTL) return 'right';
|
|
212
|
+
if (directionKey === 'right' && isRTL) return 'left';
|
|
213
|
+
return directionKey;
|
|
208
214
|
};
|
|
@@ -9,7 +9,10 @@ import { internals } from '../../internals';
|
|
|
9
9
|
import { makeRecursiveMapper } from '../../utils';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import { Classes } from '../../base/styles';
|
|
12
|
-
|
|
12
|
+
import { swapRTLDirection } from '../../base/utils';
|
|
13
|
+
var ExtendIconStyle = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size:12px;\n margin-", ":4px;\n"])), function (props) {
|
|
14
|
+
return swapRTLDirection(props.direction, 'left');
|
|
15
|
+
});
|
|
13
16
|
var stateKey = 'colExtend';
|
|
14
17
|
var ExpandIcon = function ExpandIcon(_ref) {
|
|
15
18
|
var style = _ref.style,
|
|
@@ -56,13 +59,14 @@ export var colGroupExtendable = function colGroupExtendable() {
|
|
|
56
59
|
var addIconNode = /*#__PURE__*/React.createElement(React.Fragment, null, internals.safeRenderHeader(_extends({}, col)), /*#__PURE__*/React.createElement(ExtendIconStyle, {
|
|
57
60
|
onClick: function onClick() {
|
|
58
61
|
toggle(col);
|
|
59
|
-
}
|
|
62
|
+
},
|
|
63
|
+
direction: pipeline.ctx.direction
|
|
60
64
|
}, displaycolExtendIcon || /*#__PURE__*/React.createElement(ExpandIcon, {
|
|
61
65
|
style: {
|
|
62
66
|
userSelect: 'none',
|
|
63
67
|
marginLeft: 2,
|
|
64
68
|
flexShrink: 0,
|
|
65
|
-
cursor:
|
|
69
|
+
cursor: 'pointer',
|
|
66
70
|
verticalAlign: 'middle'
|
|
67
71
|
},
|
|
68
72
|
className: cx(_defineProperty({}, Classes.tableExtendIcon, true)),
|