@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/lib/table/base/table.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
|
|
4
|
-
var _mapInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/map");
|
|
5
|
-
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
|
6
4
|
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
7
5
|
var _sliceInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
|
8
6
|
var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
|
|
@@ -23,9 +21,9 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
|
23
21
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
24
22
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
25
23
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
24
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
26
25
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
27
26
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
28
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
29
27
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
30
28
|
var _react = _interopRequireDefault(require("react"));
|
|
31
29
|
var _rxjs = require("rxjs");
|
|
@@ -36,6 +34,7 @@ var _header = _interopRequireDefault(require("./header"));
|
|
|
36
34
|
var _getRichVisibleRectsStream = require("./helpers/getRichVisibleRectsStream");
|
|
37
35
|
var _rowHeightManager = require("./helpers/rowHeightManager");
|
|
38
36
|
var _TableDOMUtils = require("./helpers/TableDOMUtils");
|
|
37
|
+
var _FastScrollManager = require("./helpers/FastScrollManager");
|
|
39
38
|
var _htmlTable = require("./html-table");
|
|
40
39
|
var _loading = _interopRequireDefault(require("./loading"));
|
|
41
40
|
var _styles = require("./styles");
|
|
@@ -43,13 +42,14 @@ var _globalStyleComponent = _interopRequireDefault(require("./globalStyleCompone
|
|
|
43
42
|
var _utils = require("./utils");
|
|
44
43
|
var _utils2 = require("../utils");
|
|
45
44
|
var _renderTemplates = _interopRequireDefault(require("./renderTemplates"));
|
|
46
|
-
|
|
47
|
-
function
|
|
48
|
-
function
|
|
49
|
-
function
|
|
50
|
-
function
|
|
51
|
-
function
|
|
52
|
-
function
|
|
45
|
+
var _BlankComponent = require("./BlankComponent");
|
|
46
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
47
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
48
|
+
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; } } }; }
|
|
49
|
+
function _unsupportedIterableToArray(o, minLen) { var _context2; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty2(_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); }
|
|
50
|
+
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; }
|
|
51
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
52
|
+
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; } }
|
|
53
53
|
var propsDotEmptyContentDeprecatedWarned = false;
|
|
54
54
|
function warnPropsDotEmptyContentIsDeprecated() {
|
|
55
55
|
if (!propsDotEmptyContentDeprecatedWarned) {
|
|
@@ -57,15 +57,20 @@ function warnPropsDotEmptyContentIsDeprecated() {
|
|
|
57
57
|
_utils2.console.warn('BaseTable props.emptyContent 已经过时,请使用 props.components.EmptyContent 来自定义数据为空时的表格表现');
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
var BaseTable =
|
|
60
|
+
var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
61
|
+
(0, _inherits2.default)(BaseTable, _React$Component);
|
|
62
|
+
var _super = _createSuper(BaseTable);
|
|
61
63
|
function BaseTable(props) {
|
|
62
64
|
var _this;
|
|
63
65
|
(0, _classCallCheck2.default)(this, BaseTable);
|
|
64
|
-
_this =
|
|
66
|
+
_this = _super.call(this, props);
|
|
65
67
|
_this.rowHeightManager = (0, _rowHeightManager.makeRowHeightManager)(_this.props.dataSource.length, _this.props.estimatedRowHeight);
|
|
66
68
|
_this.artTableWrapperRef = /*#__PURE__*/_react.default.createRef();
|
|
67
69
|
_this.hasScrollY = false;
|
|
68
70
|
_this.offsetY = 0;
|
|
71
|
+
// Blank组件的引用,用于快速滚动时直接更新
|
|
72
|
+
_this.topBlankRef = /*#__PURE__*/_react.default.createRef();
|
|
73
|
+
_this.bottomBlankRef = /*#__PURE__*/_react.default.createRef();
|
|
69
74
|
_this.handleRowMouseEnter = function (e) {
|
|
70
75
|
var nodeList = _this.domHelper.getRowNodeListByEvent(e);
|
|
71
76
|
nodeList && nodeList.forEach(function (node) {
|
|
@@ -85,8 +90,7 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
85
90
|
getRowProps = _this$props.getRowProps,
|
|
86
91
|
primaryKey = _this$props.primaryKey,
|
|
87
92
|
isLoading = _this$props.isLoading,
|
|
88
|
-
emptyCellHeight = _this$props.emptyCellHeight
|
|
89
|
-
footerDataSource = _this$props.footerDataSource;
|
|
93
|
+
emptyCellHeight = _this$props.emptyCellHeight;
|
|
90
94
|
var tableBodyClassName = (0, _classnames.default)(_styles.Classes.tableBody, _styles.Classes.horizontalScrollContainer);
|
|
91
95
|
// 低版本Edge浏览器下也会出现双滚动条,这里设置overflow: 'hidden',先去掉edge的方向键控制滚动条的功能
|
|
92
96
|
var virtualStyle = _utils2.browserType.isIE || _utils2.browserType.isEdge ? {
|
|
@@ -136,13 +140,10 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
136
140
|
className: _styles.Classes.virtual,
|
|
137
141
|
tabIndex: -1,
|
|
138
142
|
style: virtualStyle
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
height: topBlank
|
|
144
|
-
}
|
|
145
|
-
})), /*#__PURE__*/_react.default.createElement(_htmlTable.HtmlTable, {
|
|
143
|
+
}, /*#__PURE__*/_react.default.createElement(_BlankComponent.TopBlank, {
|
|
144
|
+
ref: _this.topBlankRef,
|
|
145
|
+
height: topBlank
|
|
146
|
+
}), /*#__PURE__*/_react.default.createElement(_htmlTable.HtmlTable, {
|
|
146
147
|
tbodyHtmlTag: "tbody",
|
|
147
148
|
getRowProps: getRowProps,
|
|
148
149
|
primaryKey: primaryKey,
|
|
@@ -154,13 +155,10 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
154
155
|
limit: bottomIndex,
|
|
155
156
|
last: dataSource.length - 1
|
|
156
157
|
}
|
|
157
|
-
}),
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
height: bottomBlank
|
|
162
|
-
}
|
|
163
|
-
}))));
|
|
158
|
+
}), /*#__PURE__*/_react.default.createElement(_BlankComponent.BottomBlank, {
|
|
159
|
+
ref: _this.bottomBlankRef,
|
|
160
|
+
height: bottomBlank
|
|
161
|
+
})));
|
|
164
162
|
};
|
|
165
163
|
_this.state = {
|
|
166
164
|
hasScroll: true,
|
|
@@ -174,11 +172,30 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
174
172
|
maxRenderHeight: 600,
|
|
175
173
|
maxRenderWidth: 800
|
|
176
174
|
};
|
|
175
|
+
// 初始化快速滚动管理器
|
|
176
|
+
var fastScrollCallbacks = {
|
|
177
|
+
onFastScrollStart: function onFastScrollStart(renderData) {
|
|
178
|
+
_this.setState({
|
|
179
|
+
previousRenderData: renderData
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
onFastScrollEnd: function onFastScrollEnd(scrollData) {
|
|
183
|
+
_this.setState({
|
|
184
|
+
previousRenderData: undefined,
|
|
185
|
+
offsetY: scrollData.offsetY,
|
|
186
|
+
maxRenderHeight: scrollData.maxRenderHeight,
|
|
187
|
+
maxRenderWidth: scrollData.maxRenderWidth
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
getCurrentRenderRange: function getCurrentRenderRange(offsetY, maxRenderHeight, dataLength) {
|
|
191
|
+
return _this.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, dataLength);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
_this.fastScrollManager = new _FastScrollManager.FastScrollManager(fastScrollCallbacks);
|
|
177
195
|
return _this;
|
|
178
196
|
}
|
|
179
197
|
/** @deprecated BaseTable.getDoms() 已经过时,请勿调用 */
|
|
180
|
-
(0,
|
|
181
|
-
return (0, _createClass2.default)(BaseTable, [{
|
|
198
|
+
(0, _createClass2.default)(BaseTable, [{
|
|
182
199
|
key: "getDoms",
|
|
183
200
|
value: function getDoms() {
|
|
184
201
|
_utils2.console.warn('[kd-table] BaseTable.getDoms() 已经过时');
|
|
@@ -296,11 +313,14 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
296
313
|
}, {
|
|
297
314
|
key: "syncHorizontalScroll",
|
|
298
315
|
value: function syncHorizontalScroll(x) {
|
|
299
|
-
|
|
316
|
+
var _x = Math.abs(x);
|
|
317
|
+
this.updateOffsetX(_x);
|
|
300
318
|
var flat = (0, _flat.default)(this.lastInfo);
|
|
319
|
+
var shouldShowLeftByScroll = _x > 0;
|
|
320
|
+
var shouldShowRighByScroll = _x < this.domHelper.virtual.scrollWidth - this.domHelper.virtual.clientWidth;
|
|
301
321
|
var leftLockShadow = this.domHelper.getLeftLockShadow();
|
|
302
322
|
if (leftLockShadow) {
|
|
303
|
-
var shouldShowLeftLockShadow = flat.left.length > 0 && this.state.needRenderLock &&
|
|
323
|
+
var shouldShowLeftLockShadow = flat.left.length > 0 && this.state.needRenderLock && shouldShowLeftByScroll;
|
|
304
324
|
if (shouldShowLeftLockShadow) {
|
|
305
325
|
leftLockShadow.classList.add('show-shadow');
|
|
306
326
|
} else {
|
|
@@ -309,7 +329,7 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
309
329
|
}
|
|
310
330
|
var rightLockShadow = this.domHelper.getRightLockShadow();
|
|
311
331
|
if (rightLockShadow) {
|
|
312
|
-
var shouldShowRightLockShadow = flat.right.length > 0 && this.state.needRenderLock &&
|
|
332
|
+
var shouldShowRightLockShadow = flat.right.length > 0 && this.state.needRenderLock && shouldShowRighByScroll;
|
|
313
333
|
if (shouldShowRightLockShadow) {
|
|
314
334
|
rightLockShadow.classList.add('show-shadow');
|
|
315
335
|
} else {
|
|
@@ -320,11 +340,18 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
320
340
|
}, {
|
|
321
341
|
key: "getVerticalRenderRange",
|
|
322
342
|
value: function getVerticalRenderRange(useVirtual) {
|
|
323
|
-
var
|
|
343
|
+
var _this$props4 = this.props,
|
|
344
|
+
dataSource = _this$props4.dataSource,
|
|
345
|
+
isLowPerformance = _this$props4.isLowPerformance;
|
|
324
346
|
var _this$state = this.state,
|
|
325
347
|
offsetY = _this$state.offsetY,
|
|
326
|
-
maxRenderHeight = _this$state.maxRenderHeight
|
|
348
|
+
maxRenderHeight = _this$state.maxRenderHeight,
|
|
349
|
+
previousRenderData = _this$state.previousRenderData;
|
|
327
350
|
var rowCount = dataSource.length;
|
|
351
|
+
// 只有在启用快速滚动时才使用 FastScrollManager 的判断
|
|
352
|
+
if (isLowPerformance && this.fastScrollManager.getIsFastScrolling() && (previousRenderData === null || previousRenderData === void 0 ? void 0 : previousRenderData.verticalRenderRange)) {
|
|
353
|
+
return previousRenderData.verticalRenderRange;
|
|
354
|
+
}
|
|
328
355
|
if (useVirtual.vertical) {
|
|
329
356
|
return this.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, rowCount);
|
|
330
357
|
} else {
|
|
@@ -335,12 +362,12 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
335
362
|
key: "renderTableFooter",
|
|
336
363
|
value: function renderTableFooter(info) {
|
|
337
364
|
// console.log('render footer')
|
|
338
|
-
var _this$
|
|
339
|
-
_this$
|
|
340
|
-
footerDataSource = _this$
|
|
341
|
-
getRowProps = _this$
|
|
342
|
-
primaryKey = _this$
|
|
343
|
-
stickyBottom = _this$
|
|
365
|
+
var _this$props5 = this.props,
|
|
366
|
+
_this$props5$footerDa = _this$props5.footerDataSource,
|
|
367
|
+
footerDataSource = _this$props5$footerDa === void 0 ? [] : _this$props5$footerDa,
|
|
368
|
+
getRowProps = _this$props5.getRowProps,
|
|
369
|
+
primaryKey = _this$props5.primaryKey,
|
|
370
|
+
stickyBottom = _this$props5.stickyBottom;
|
|
344
371
|
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
345
372
|
var renderFooter = (0, _renderTemplates.default)('footer');
|
|
346
373
|
if (typeof renderFooter === 'function') {
|
|
@@ -381,22 +408,19 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
381
408
|
}, {
|
|
382
409
|
key: "renderLockShadows",
|
|
383
410
|
value: function renderLockShadows(info) {
|
|
411
|
+
var _style, _style2;
|
|
384
412
|
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
385
413
|
// console.log('render LockShadows')
|
|
414
|
+
var leftLockShadowWidth = info.leftLockTotalWidth + _styles.LOCK_SHADOW_PADDING;
|
|
415
|
+
var rightLockShadownWidth = info.rightLockTotalWidth + _styles.LOCK_SHADOW_PADDING + stickyRightOffset;
|
|
386
416
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
387
417
|
className: _styles.Classes.lockShadowMask,
|
|
388
|
-
style: {
|
|
389
|
-
left: 0,
|
|
390
|
-
width: info.leftLockTotalWidth + _styles.LOCK_SHADOW_PADDING
|
|
391
|
-
}
|
|
418
|
+
style: (_style = {}, (0, _defineProperty2.default)(_style, (0, _utils.swapRTLDirection)(info.direction, 'left'), 0), (0, _defineProperty2.default)(_style, "width", leftLockShadowWidth), _style)
|
|
392
419
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
393
420
|
className: (0, _classnames.default)(_styles.Classes.lockShadow, _styles.Classes.leftLockShadow)
|
|
394
421
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
395
422
|
className: _styles.Classes.lockShadowMask,
|
|
396
|
-
style: {
|
|
397
|
-
right: 0,
|
|
398
|
-
width: info.rightLockTotalWidth + _styles.LOCK_SHADOW_PADDING + stickyRightOffset
|
|
399
|
-
}
|
|
423
|
+
style: (_style2 = {}, (0, _defineProperty2.default)(_style2, (0, _utils.swapRTLDirection)(info.direction, 'right'), 0), (0, _defineProperty2.default)(_style2, "width", rightLockShadownWidth), _style2)
|
|
400
424
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
401
425
|
className: (0, _classnames.default)(_styles.Classes.lockShadow, _styles.Classes.rightLockShadow)
|
|
402
426
|
})));
|
|
@@ -405,9 +429,9 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
405
429
|
key: "renderStickyScroll",
|
|
406
430
|
value: function renderStickyScroll(info) {
|
|
407
431
|
// console.log('render stickyscroll')
|
|
408
|
-
var _this$
|
|
409
|
-
hasStickyScroll = _this$
|
|
410
|
-
stickyBottom = _this$
|
|
432
|
+
var _this$props6 = this.props,
|
|
433
|
+
hasStickyScroll = _this$props6.hasStickyScroll,
|
|
434
|
+
stickyBottom = _this$props6.stickyBottom;
|
|
411
435
|
var hasScroll = this.state.hasScroll;
|
|
412
436
|
var isScroll = hasStickyScroll && hasScroll;
|
|
413
437
|
var stickyScrollContainerStyle = this.getStickyScrollContainerStyle();
|
|
@@ -444,9 +468,9 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
444
468
|
}, {
|
|
445
469
|
key: "getStickyScrollContainerStyle",
|
|
446
470
|
value: function getStickyScrollContainerStyle() {
|
|
447
|
-
var _this$
|
|
448
|
-
hasStickyScroll = _this$
|
|
449
|
-
stickyScrollHeight = _this$
|
|
471
|
+
var _this$props7 = this.props,
|
|
472
|
+
hasStickyScroll = _this$props7.hasStickyScroll,
|
|
473
|
+
stickyScrollHeight = _this$props7.stickyScrollHeight;
|
|
450
474
|
var hasScroll = this.state.hasScroll;
|
|
451
475
|
var isScroll = hasStickyScroll && hasScroll;
|
|
452
476
|
var height = stickyScrollHeight === 'auto' ? this.getScrollBarWidth() : stickyScrollHeight;
|
|
@@ -460,24 +484,27 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
460
484
|
}, {
|
|
461
485
|
key: "render",
|
|
462
486
|
value: function render() {
|
|
487
|
+
var _cx;
|
|
463
488
|
// console.log('render table')
|
|
464
489
|
var info = (0, _calculations.calculateRenderInfo)(this);
|
|
465
490
|
this.lastInfo = info;
|
|
466
|
-
var _this$
|
|
467
|
-
dataSource = _this$
|
|
468
|
-
className = _this$
|
|
469
|
-
style = _this$
|
|
470
|
-
hasHeader = _this$
|
|
471
|
-
useOuterBorder = _this$
|
|
472
|
-
isStickyHead = _this$
|
|
473
|
-
isStickyHeader = _this$
|
|
474
|
-
isStickyFooter = _this$
|
|
475
|
-
isLoading = _this$
|
|
476
|
-
getTableProps = _this$
|
|
477
|
-
footerDataSource = _this$
|
|
478
|
-
components = _this$
|
|
479
|
-
bordered = _this$
|
|
480
|
-
|
|
491
|
+
var _this$props8 = this.props,
|
|
492
|
+
dataSource = _this$props8.dataSource,
|
|
493
|
+
className = _this$props8.className,
|
|
494
|
+
style = _this$props8.style,
|
|
495
|
+
hasHeader = _this$props8.hasHeader,
|
|
496
|
+
useOuterBorder = _this$props8.useOuterBorder,
|
|
497
|
+
isStickyHead = _this$props8.isStickyHead,
|
|
498
|
+
isStickyHeader = _this$props8.isStickyHeader,
|
|
499
|
+
isStickyFooter = _this$props8.isStickyFooter,
|
|
500
|
+
isLoading = _this$props8.isLoading,
|
|
501
|
+
getTableProps = _this$props8.getTableProps,
|
|
502
|
+
footerDataSource = _this$props8.footerDataSource,
|
|
503
|
+
components = _this$props8.components,
|
|
504
|
+
bordered = _this$props8.bordered,
|
|
505
|
+
direction = _this$props8.direction;
|
|
506
|
+
info.direction = direction;
|
|
507
|
+
var artTableWrapperClassName = (0, _classnames.default)(_styles.Classes.artTableWrapper, (_cx = {
|
|
481
508
|
'use-outer-border': useOuterBorder,
|
|
482
509
|
empty: dataSource.length === 0,
|
|
483
510
|
lock: info.hasLockColumn,
|
|
@@ -485,13 +512,19 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
485
512
|
'sticky-header': isStickyHeader !== null && isStickyHeader !== void 0 ? isStickyHeader : isStickyHead,
|
|
486
513
|
'has-footer': footerDataSource.length > 0,
|
|
487
514
|
'sticky-footer': isStickyFooter
|
|
488
|
-
}, _styles.Classes.artTableBordered, bordered), 'ie-polyfill-wrapper', _utils2.browserType.isIE), 'sticky-polyfill-wrapper', (0, _utils2.isStickyUIDegrade)()), className);
|
|
515
|
+
}, (0, _defineProperty2.default)(_cx, _styles.Classes.artTableBordered, bordered), (0, _defineProperty2.default)(_cx, 'ie-polyfill-wrapper', _utils2.browserType.isIE), (0, _defineProperty2.default)(_cx, 'sticky-polyfill-wrapper', (0, _utils2.isStickyUIDegrade)()), _cx), className);
|
|
489
516
|
var artTableWrapperProps = (0, _defineProperty2.default)({
|
|
490
517
|
className: artTableWrapperClassName,
|
|
491
|
-
style: style
|
|
518
|
+
style: (0, _extends2.default)((0, _extends2.default)({}, style), {
|
|
519
|
+
direction: direction
|
|
520
|
+
})
|
|
492
521
|
}, _utils.STYLED_REF_PROP, this.artTableWrapperRef);
|
|
493
522
|
var tableProps = getTableProps() || {};
|
|
494
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_globalStyleComponent.default,
|
|
523
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_globalStyleComponent.default, {
|
|
524
|
+
direction: info.direction
|
|
525
|
+
}), /*#__PURE__*/_react.default.createElement(_styles.StyledArtTableWrapper, (0, _extends2.default)({}, artTableWrapperProps, {
|
|
526
|
+
direction: info.direction
|
|
527
|
+
}), /*#__PURE__*/_react.default.createElement(_loading.default, {
|
|
495
528
|
visible: isLoading,
|
|
496
529
|
LoadingIcon: components.LoadingIcon,
|
|
497
530
|
LoadingContentWrapper: components.LoadingContentWrapper
|
|
@@ -510,10 +543,10 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
510
543
|
this.initSubscriptions();
|
|
511
544
|
this.didMountOrUpdate();
|
|
512
545
|
// console.log('did mount end')
|
|
513
|
-
var _this$
|
|
514
|
-
cssVariables = _this$
|
|
515
|
-
enableCSSVariables = _this$
|
|
516
|
-
bordered = _this$
|
|
546
|
+
var _this$props9 = this.props,
|
|
547
|
+
cssVariables = _this$props9.cssVariables,
|
|
548
|
+
enableCSSVariables = _this$props9.enableCSSVariables,
|
|
549
|
+
bordered = _this$props9.bordered;
|
|
517
550
|
(0, _utils.cssPolifill)({
|
|
518
551
|
variables: cssVariables || {},
|
|
519
552
|
enableCSSVariables: enableCSSVariables,
|
|
@@ -528,10 +561,10 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
528
561
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
529
562
|
var _a;
|
|
530
563
|
// console.log('did update start')
|
|
531
|
-
var _this$
|
|
532
|
-
cssVariables = _this$
|
|
533
|
-
enableCSSVariables = _this$
|
|
534
|
-
bordered = _this$
|
|
564
|
+
var _this$props10 = this.props,
|
|
565
|
+
cssVariables = _this$props10.cssVariables,
|
|
566
|
+
enableCSSVariables = _this$props10.enableCSSVariables,
|
|
567
|
+
bordered = _this$props10.bordered;
|
|
535
568
|
if (!(0, _utils.shallowEqual)(prevProps === null || prevProps === void 0 ? void 0 : prevProps.cssVariables, (_a = this.props) === null || _a === void 0 ? void 0 : _a.cssVariables)) {
|
|
536
569
|
(0, _utils.cssPolifill)({
|
|
537
570
|
variables: cssVariables || {},
|
|
@@ -547,10 +580,13 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
547
580
|
}, {
|
|
548
581
|
key: "didMountOrUpdate",
|
|
549
582
|
value: function didMountOrUpdate(prevProps, prevState) {
|
|
550
|
-
this
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
583
|
+
var _this2 = this;
|
|
584
|
+
window.requestAnimationFrame(function () {
|
|
585
|
+
_this2.syncHorizontalScrollFromTableBody();
|
|
586
|
+
_this2.updateStickyScroll();
|
|
587
|
+
_this2.adjustNeedRenderLock();
|
|
588
|
+
_this2.updateRowHeightManager();
|
|
589
|
+
});
|
|
554
590
|
this.updateScrollLeftWhenLayoutChanged(prevProps, prevState);
|
|
555
591
|
}
|
|
556
592
|
}, {
|
|
@@ -572,31 +608,31 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
572
608
|
}, {
|
|
573
609
|
key: "initSubscriptions",
|
|
574
610
|
value: function initSubscriptions() {
|
|
575
|
-
var
|
|
611
|
+
var _this3 = this;
|
|
576
612
|
var _this$domHelper2 = this.domHelper,
|
|
577
613
|
virtual = _this$domHelper2.virtual,
|
|
578
614
|
stickyScroll = _this$domHelper2.stickyScroll;
|
|
579
615
|
this.rootSubscription.add(_utils.throttledWindowResize$.subscribe(function () {
|
|
580
|
-
|
|
581
|
-
|
|
616
|
+
_this3.updateStickyScroll();
|
|
617
|
+
_this3.adjustNeedRenderLock();
|
|
582
618
|
}));
|
|
583
619
|
this.resizeSubject.pipe(op.debounceTime(100)).subscribe(function () {
|
|
584
620
|
var _a, _b;
|
|
585
|
-
(_b = (_a =
|
|
621
|
+
(_b = (_a = _this3.props).setTableWidth) === null || _b === void 0 ? void 0 : _b.call(_a, _this3.domHelper.tableBody.clientWidth);
|
|
586
622
|
});
|
|
587
623
|
var handleTableWrapperResize = function handleTableWrapperResize() {
|
|
588
|
-
|
|
624
|
+
_this3.resizeSubject.next();
|
|
589
625
|
};
|
|
590
626
|
this.resizeObserver = (0, _utils.addResizeObserver)(this.domHelper.artTableWrapper, handleTableWrapperResize);
|
|
591
627
|
// 滚动同步
|
|
592
628
|
this.rootSubscription.add((0, _utils.syncScrollLeft)([(0, _utils.getTableScrollHeaderDOM)(this.domHelper), virtual, (0, _utils.getTableScrollFooterDOM)(this.domHelper), stickyScroll], function (scrollLeft) {
|
|
593
|
-
|
|
629
|
+
_this3.syncHorizontalScroll(scrollLeft);
|
|
594
630
|
}));
|
|
595
631
|
var richVisibleRects$ = (0, _getRichVisibleRectsStream.getRichVisibleRectsStream)(this.domHelper.virtual, this.props$.pipe(op.skip(1), op.mapTo('structure-may-change')), this.props.virtualDebugLabel).pipe(op.shareReplay());
|
|
596
632
|
// 每当可见部分发生变化的时候,调整 loading icon 的未知(如果 loading icon 存在的话)
|
|
597
|
-
this.rootSubscription.add((0, _rxjs.combineLatest)([richVisibleRects$.pipe(
|
|
633
|
+
this.rootSubscription.add((0, _rxjs.combineLatest)([richVisibleRects$.pipe(op.map(function (p) {
|
|
598
634
|
return p.clipRect;
|
|
599
|
-
}), op.distinctUntilChanged(_utils.shallowEqual)), this.props$.pipe(op.startWith(null), op.pairwise(),
|
|
635
|
+
}), op.distinctUntilChanged(_utils.shallowEqual)), this.props$.pipe(op.startWith(null), op.pairwise(), op.filter(function (_ref) {
|
|
600
636
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
601
637
|
prevProps = _ref2[0],
|
|
602
638
|
props = _ref2[1];
|
|
@@ -604,7 +640,7 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
604
640
|
}))]).subscribe(function (_ref3) {
|
|
605
641
|
var _ref4 = (0, _slicedToArray2.default)(_ref3, 1),
|
|
606
642
|
clipRect = _ref4[0];
|
|
607
|
-
var loadingIndicator =
|
|
643
|
+
var loadingIndicator = _this3.domHelper.getLoadingIndicator();
|
|
608
644
|
if (!loadingIndicator) {
|
|
609
645
|
return;
|
|
610
646
|
}
|
|
@@ -614,12 +650,12 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
614
650
|
loadingIndicator.style.marginTop = "".concat(height / 2, "px");
|
|
615
651
|
}));
|
|
616
652
|
// 每当可见部分发生变化的时候,如果开启了虚拟滚动,则重新触发 render
|
|
617
|
-
this.rootSubscription.add(richVisibleRects$.pipe(
|
|
618
|
-
var
|
|
619
|
-
horizontal =
|
|
620
|
-
vertical =
|
|
653
|
+
this.rootSubscription.add(richVisibleRects$.pipe(op.filter(function () {
|
|
654
|
+
var _this3$lastInfo$useVi = _this3.lastInfo.useVirtual,
|
|
655
|
+
horizontal = _this3$lastInfo$useVi.horizontal,
|
|
656
|
+
vertical = _this3$lastInfo$useVi.vertical;
|
|
621
657
|
return horizontal || vertical;
|
|
622
|
-
}),
|
|
658
|
+
}), op.map(function (_ref5) {
|
|
623
659
|
var clipRect = _ref5.clipRect,
|
|
624
660
|
offsetY = _ref5.offsetY;
|
|
625
661
|
return {
|
|
@@ -634,10 +670,31 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
634
670
|
}
|
|
635
671
|
// 因为 overscan 的存在,滚动较小的距离时不需要触发组件重渲染
|
|
636
672
|
return Math.abs(x.maxRenderWidth - y.maxRenderWidth) < _utils.OVERSCAN_SIZE / 2 && Math.abs(x.maxRenderHeight - y.maxRenderHeight) < _utils.OVERSCAN_SIZE / 2 && Math.abs(x.offsetY - y.offsetY) < _utils.OVERSCAN_SIZE / 2;
|
|
673
|
+
}),
|
|
674
|
+
// 快速滚动检测和处理
|
|
675
|
+
op.tap(function (sizeAndOffset) {
|
|
676
|
+
// 只有在启用快速滚动时才使用 FastScrollManager 处理滚动事件
|
|
677
|
+
if (_this3.props.isLowPerformance) {
|
|
678
|
+
_this3.fastScrollManager.handleScrollEvent(sizeAndOffset, {
|
|
679
|
+
offsetY: _this3.state.offsetY,
|
|
680
|
+
maxRenderHeight: _this3.state.maxRenderHeight,
|
|
681
|
+
maxRenderWidth: _this3.state.maxRenderWidth
|
|
682
|
+
}, _this3.props.dataSource.length, _this3.domHelper.virtual.scrollHeight);
|
|
683
|
+
}
|
|
637
684
|
})).subscribe(function (sizeAndOffset) {
|
|
638
|
-
|
|
685
|
+
var _a, _b;
|
|
686
|
+
// 正常滚动时也需要实时更新 blank 高度,确保缓慢滚动时的视觉连续性
|
|
687
|
+
var currentRange = _this3.rowHeightManager.getRenderRange(sizeAndOffset.offsetY, sizeAndOffset.maxRenderHeight, _this3.props.dataSource.length);
|
|
688
|
+
// 直接更新 DOM,避免等待下次渲染
|
|
689
|
+
(_a = _this3.topBlankRef.current) === null || _a === void 0 ? void 0 : _a.updateHeight(currentRange.topBlank);
|
|
690
|
+
(_b = _this3.bottomBlankRef.current) === null || _b === void 0 ? void 0 : _b.updateHeight(currentRange.bottomBlank);
|
|
691
|
+
// 只有在启用快速滚动时才检查快速滚动状态
|
|
692
|
+
if (_this3.props.isLowPerformance && _this3.fastScrollManager.getIsFastScrolling()) {
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
_this3.setState(sizeAndOffset);
|
|
639
696
|
}));
|
|
640
|
-
this.rootSubscription.add(richVisibleRects$.pipe(
|
|
697
|
+
this.rootSubscription.add(richVisibleRects$.pipe(op.map(function (_ref6) {
|
|
641
698
|
var clipRect = _ref6.clipRect,
|
|
642
699
|
offsetY = _ref6.offsetY;
|
|
643
700
|
return {
|
|
@@ -649,17 +706,17 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
649
706
|
return x.offsetY - y.offsetY === 0;
|
|
650
707
|
}),
|
|
651
708
|
// 计算得到当前行索引对应的数据块,blocks改成数组的形式,兼容快速拖动可视区域出现两个数据块的情况
|
|
652
|
-
|
|
709
|
+
op.map(function (sizeAndOffset) {
|
|
653
710
|
var _a;
|
|
654
711
|
var offsetY = sizeAndOffset.offsetY,
|
|
655
712
|
maxRenderHeight = sizeAndOffset.maxRenderHeight;
|
|
656
|
-
var scrollDirection = offsetY -
|
|
657
|
-
|
|
658
|
-
var rowCount =
|
|
659
|
-
var vertical =
|
|
713
|
+
var scrollDirection = offsetY - _this3.offsetY >= 0 ? 'down' : 'up';
|
|
714
|
+
_this3.offsetY = offsetY;
|
|
715
|
+
var rowCount = _this3.props.dataSource.length;
|
|
716
|
+
var vertical = _this3.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, rowCount);
|
|
660
717
|
var topIndex = vertical.topIndex,
|
|
661
718
|
bottomIndex = vertical.bottomIndex;
|
|
662
|
-
var blockSize = ((_a =
|
|
719
|
+
var blockSize = ((_a = _this3.props.scrollLoad) === null || _a === void 0 ? void 0 : _a.blockSize) || 200;
|
|
663
720
|
var topBlockStartIndex = Math.floor(Math.max(topIndex - 1, 0) / blockSize) * blockSize;
|
|
664
721
|
var bottomBlockStartIndex = Math.floor((bottomIndex + 1) / blockSize) * blockSize;
|
|
665
722
|
return scrollDirection === 'down' ? [topBlockStartIndex, bottomBlockStartIndex] : [bottomBlockStartIndex, topBlockStartIndex];
|
|
@@ -667,14 +724,14 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
667
724
|
return x[0] === y[0] && x[1] === y[1];
|
|
668
725
|
}), op.switchMap(function (startIndexs) {
|
|
669
726
|
var event$ = (0, _rxjs.from)(startIndexs);
|
|
670
|
-
return event$.pipe(
|
|
727
|
+
return event$.pipe(op.map(function (startIndex) {
|
|
671
728
|
return startIndex;
|
|
672
729
|
}));
|
|
673
730
|
}),
|
|
674
731
|
// 过滤掉重复掉值
|
|
675
732
|
op.distinctUntilChanged()).subscribe(function (startIndex) {
|
|
676
733
|
var _a;
|
|
677
|
-
(_a =
|
|
734
|
+
(_a = _this3.props.scrollLoad) === null || _a === void 0 ? void 0 : _a.callback(startIndex);
|
|
678
735
|
}));
|
|
679
736
|
}
|
|
680
737
|
}, {
|
|
@@ -684,6 +741,10 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
684
741
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
685
742
|
this.rootSubscription.unsubscribe();
|
|
686
743
|
this.resizeSubject.unsubscribe();
|
|
744
|
+
// 只有在启用快速滚动时才清理快速滚动管理器
|
|
745
|
+
if (this.props.isLowPerformance) {
|
|
746
|
+
this.fastScrollManager.cleanup();
|
|
747
|
+
}
|
|
687
748
|
}
|
|
688
749
|
/** 更新 DOM 节点的引用,方便其他方法直接操作 DOM */
|
|
689
750
|
}, {
|
|
@@ -765,7 +826,9 @@ var BaseTable = exports.BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
765
826
|
}
|
|
766
827
|
}
|
|
767
828
|
}]);
|
|
829
|
+
return BaseTable;
|
|
768
830
|
}(_react.default.Component);
|
|
831
|
+
exports.BaseTable = BaseTable;
|
|
769
832
|
BaseTable.defaultProps = {
|
|
770
833
|
hasHeader: true,
|
|
771
834
|
isStickyHeader: true,
|
|
@@ -777,6 +840,7 @@ BaseTable.defaultProps = {
|
|
|
777
840
|
stickyScrollHeight: 'auto',
|
|
778
841
|
useVirtual: 'auto',
|
|
779
842
|
estimatedRowHeight: 48,
|
|
843
|
+
isLowPerformance: false,
|
|
780
844
|
isLoading: false,
|
|
781
845
|
components: {},
|
|
782
846
|
getTableProps: _rxjs.noop,
|
|
@@ -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 {};
|