@kdcloudjs/table 1.0.0 → 1.0.3
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 +1 -1
- package/README.md +34 -33
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.css.map +1 -1
- package/dist/@kdcloudjs/table.js +6554 -3389
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +32 -24
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/es/_utils/hooks.js +1 -2
- package/es/_utils/numberUtil.js +3 -4
- package/es/locale/locale.js +1 -2
- package/es/table/base/calculations.js +3 -4
- package/es/table/base/empty.js +2 -2
- package/es/table/base/header.d.ts +6 -2
- package/es/table/base/header.js +41 -22
- package/es/table/base/helpers/SpanManager.js +1 -1
- package/es/table/base/helpers/TableDOMUtils.d.ts +3 -0
- package/es/table/base/helpers/TableDOMUtils.js +23 -5
- package/es/table/base/helpers/getRichVisibleRectsStream.d.ts +23 -0
- package/es/table/base/helpers/getRichVisibleRectsStream.js +216 -0
- package/es/table/base/html-table.d.ts +3 -1
- package/es/table/base/html-table.js +43 -26
- package/es/table/base/interfaces.d.ts +1 -0
- package/es/table/base/renderTemplates.d.ts +1 -0
- package/es/table/base/renderTemplates.js +344 -0
- package/es/table/base/styles.d.ts +24 -0
- package/es/table/base/styles.js +31 -9
- package/es/table/base/table.d.ts +12 -4
- package/es/table/base/table.js +183 -136
- package/es/table/base/utils.d.ts +6 -3
- package/es/table/base/utils.js +27 -6
- package/es/table/common-views.js +3 -3
- package/es/table/pipeline/features/__test__/treeMode.test.js +2 -1
- package/es/table/pipeline/features/autoFill.js +7 -1
- package/es/table/pipeline/features/columnDrag.js +168 -59
- package/es/table/pipeline/features/columnFilter.js +7 -9
- package/es/table/pipeline/features/columnResizeWidth.d.ts +3 -0
- package/es/table/pipeline/features/columnResizeWidth.js +11 -4
- package/es/table/pipeline/features/contextMenu.js +78 -31
- package/es/table/pipeline/features/filter/Filter.js +74 -37
- package/es/table/pipeline/features/index.d.ts +1 -0
- package/es/table/pipeline/features/index.js +2 -1
- package/es/table/pipeline/features/multiSelect.js +83 -79
- package/es/table/pipeline/features/rangeSelection.d.ts +10 -0
- package/es/table/pipeline/features/rangeSelection.js +231 -0
- package/es/table/pipeline/features/rowDetail.js +39 -16
- package/es/table/pipeline/features/rowGrouping.js +2 -1
- package/es/table/pipeline/features/singleSelect.js +4 -1
- package/es/table/pipeline/features/sort.js +2 -3
- package/es/table/pipeline/features/treeMode.js +4 -4
- package/es/table/pipeline/pipeline.d.ts +8 -0
- package/es/table/pipeline/pipeline.js +49 -5
- package/es/table/pivot/cross-table/buildCrossTable.js +1 -2
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +1 -2
- package/es/table/pivot/pivot-utils/builders.js +1 -2
- package/es/table/pivot/pivot-utils/convert-utils.js +5 -4
- package/es/table/transforms/autoWidth.js +1 -2
- package/es/table/transforms/sort.js +1 -2
- package/es/table/transforms/treeMode.js +1 -2
- package/es/table/utils/applyTransforms.js +1 -3
- package/es/table/utils/browserType.d.ts +6 -0
- package/es/table/utils/browserType.js +6 -0
- package/es/table/utils/buildTree.js +4 -5
- package/es/table/utils/collectNodes.js +1 -2
- package/es/table/utils/exportTableAsExcel.js +1 -2
- package/es/table/utils/getTreeDepth.js +1 -2
- package/es/table/utils/groupBy.js +1 -2
- package/es/table/utils/index.d.ts +1 -0
- package/es/table/utils/index.js +2 -1
- package/es/table/utils/layeredSort.js +5 -2
- package/es/table/utils/makeRecursiveMapper.js +4 -5
- package/es/table/utils/others.d.ts +1 -1
- package/es/table/utils/others.js +20 -14
- package/es/table/utils/traverseColumn.js +1 -2
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +4 -5
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +4 -5
- package/lib/_utils/formatUtil.js +1 -1
- package/lib/_utils/hooks.js +2 -4
- package/lib/_utils/numberUtil.js +7 -9
- package/lib/_utils/usePopper.js +9 -1
- package/lib/config-provider/configProvider.js +9 -1
- package/lib/config-provider/index.js +5 -5
- package/lib/locale/index.js +14 -6
- package/lib/locale/locale.js +2 -4
- package/lib/table/base/calculations.js +4 -6
- package/lib/table/base/empty.js +11 -3
- package/lib/table/base/header.d.ts +6 -2
- package/lib/table/base/header.js +39 -19
- package/lib/table/base/helpers/SpanManager.js +1 -1
- package/lib/table/base/helpers/TableDOMUtils.d.ts +3 -0
- package/lib/table/base/helpers/TableDOMUtils.js +21 -5
- package/lib/table/base/helpers/getRichVisibleRectsStream.d.ts +23 -0
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +246 -0
- package/lib/table/base/html-table.d.ts +3 -1
- package/lib/table/base/html-table.js +44 -26
- package/lib/table/base/index.js +4 -4
- package/lib/table/base/interfaces.d.ts +1 -0
- package/lib/table/base/renderTemplates.d.ts +1 -0
- package/lib/table/base/renderTemplates.js +370 -0
- package/lib/table/base/styles.d.ts +24 -0
- package/lib/table/base/styles.js +42 -13
- package/lib/table/base/table.d.ts +12 -4
- package/lib/table/base/table.js +191 -137
- package/lib/table/base/utils.d.ts +6 -3
- package/lib/table/base/utils.js +47 -10
- package/lib/table/common-views.js +3 -3
- package/lib/table/pipeline/features/__test__/sort.test.js +5 -3
- package/lib/table/pipeline/features/__test__/treeMode.test.js +3 -1
- package/lib/table/pipeline/features/autoFill.js +9 -2
- package/lib/table/pipeline/features/columnDrag.js +168 -59
- package/lib/table/pipeline/features/columnFilter.js +6 -9
- package/lib/table/pipeline/features/columnResizeWidth.d.ts +3 -0
- package/lib/table/pipeline/features/columnResizeWidth.js +21 -5
- package/lib/table/pipeline/features/contextMenu.js +89 -32
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +10 -2
- package/lib/table/pipeline/features/filter/Filter.js +88 -37
- package/lib/table/pipeline/features/filter/FilterPanel.js +10 -2
- package/lib/table/pipeline/features/filter/index.js +4 -4
- package/lib/table/pipeline/features/index.d.ts +1 -0
- package/lib/table/pipeline/features/index.js +37 -27
- package/lib/table/pipeline/features/multiSelect.js +79 -75
- package/lib/table/pipeline/features/rangeSelection.d.ts +10 -0
- package/lib/table/pipeline/features/rangeSelection.js +256 -0
- package/lib/table/pipeline/features/rowDetail.js +42 -16
- package/lib/table/pipeline/features/rowGrouping.js +3 -1
- package/lib/table/pipeline/features/singleSelect.js +4 -1
- package/lib/table/pipeline/features/sort.js +2 -4
- package/lib/table/pipeline/features/treeMode.js +6 -6
- package/lib/table/pipeline/index.js +11 -3
- package/lib/table/pipeline/pipeline.d.ts +8 -0
- package/lib/table/pipeline/pipeline.js +50 -7
- package/lib/table/pivot/cross-table/buildCrossTable.js +1 -3
- package/lib/table/pivot/cross-table/index.js +4 -4
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +1 -3
- package/lib/table/pivot/pivot-utils/builders.js +2 -4
- package/lib/table/pivot/pivot-utils/convert-utils.js +7 -5
- package/lib/table/pivot/pivot-utils/index.js +4 -4
- package/lib/table/transforms/autoWidth.js +10 -4
- package/lib/table/transforms/columnResize.js +10 -2
- package/lib/table/transforms/index.js +32 -32
- package/lib/table/transforms/sort.js +10 -4
- package/lib/table/transforms/treeMode.js +9 -3
- package/lib/table/utils/applyTransforms.js +1 -5
- package/lib/table/utils/browserType.d.ts +6 -0
- package/lib/table/utils/browserType.js +13 -0
- package/lib/table/utils/buildTree.js +1 -3
- package/lib/table/utils/collectNodes.js +1 -3
- package/lib/table/utils/copyToClipboard.js +1 -1
- package/lib/table/utils/element.js +3 -3
- package/lib/table/utils/exportTableAsExcel.js +1 -3
- package/lib/table/utils/getTreeDepth.js +1 -3
- package/lib/table/utils/groupBy.js +1 -3
- package/lib/table/utils/index.d.ts +1 -0
- package/lib/table/utils/index.js +57 -49
- package/lib/table/utils/layeredSort.js +6 -2
- package/lib/table/utils/makeRecursiveMapper.js +1 -3
- package/lib/table/utils/others.d.ts +1 -1
- package/lib/table/utils/others.js +23 -18
- package/lib/table/utils/traverseColumn.js +1 -3
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +5 -7
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +5 -7
- package/package.json +7 -2
- package/dist/kd-table.css +0 -422
- package/dist/kd-table.css.map +0 -1
- package/dist/kd-table.js +0 -38578
- package/dist/kd-table.js.map +0 -1
- package/dist/kd-table.min.css +0 -9
- package/dist/kd-table.min.js +0 -208
- package/dist/kd-table.min.js.map +0 -1
- package/es/table/base/helpers/__test__/visible-part.test.d.ts +0 -1
- package/es/table/base/helpers/__test__/visible-part.test.js +0 -28
- package/es/table/base/helpers/visible-part.d.ts +0 -23
- package/es/table/base/helpers/visible-part.js +0 -58
- package/lib/table/base/helpers/__test__/visible-part.test.d.ts +0 -1
- package/lib/table/base/helpers/__test__/visible-part.test.js +0 -31
- package/lib/table/base/helpers/visible-part.d.ts +0 -23
- package/lib/table/base/helpers/visible-part.js +0 -72
package/es/_utils/hooks.js
CHANGED
|
@@ -2,11 +2,10 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
|
|
|
2
2
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
3
3
|
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
4
4
|
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
5
|
-
import _getIterator from "@babel/runtime-corejs3/core-js/get-iterator";
|
|
6
5
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
7
6
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
8
7
|
|
|
9
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it
|
|
8
|
+
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; } } }; }
|
|
10
9
|
|
|
11
10
|
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); }
|
|
12
11
|
|
package/es/_utils/numberUtil.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _Number$isNaN from "@babel/runtime-corejs3/core-js-stable/number/is-nan";
|
|
2
2
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
3
|
-
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
|
4
3
|
import _fillInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/fill";
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -131,13 +130,13 @@ export function serialization(strNumber) {
|
|
|
131
130
|
} // 根据整数精度和小数精度获取最大值
|
|
132
131
|
|
|
133
132
|
export function getMaxNumberByPrecision(integerPrecision, decimalPrecision) {
|
|
134
|
-
var _context2, _context3
|
|
133
|
+
var _context2, _context3;
|
|
135
134
|
|
|
136
|
-
var integerString =
|
|
135
|
+
var integerString = _fillInstanceProperty(_context2 = Array(integerPrecision)).call(_context2, '9').reduce(function (res, value) {
|
|
137
136
|
return res += value;
|
|
138
137
|
}, '');
|
|
139
138
|
|
|
140
|
-
return decimalPrecision <= 0 ? Number(integerString) : Number(
|
|
139
|
+
return decimalPrecision <= 0 ? Number(integerString) : Number(_fillInstanceProperty(_context3 = Array(decimalPrecision)).call(_context3, '9').reduce(function (res, value) {
|
|
141
140
|
return res += value;
|
|
142
141
|
}, integerString + '.'));
|
|
143
142
|
}
|
package/es/locale/locale.js
CHANGED
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
|
3
3
|
import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
4
4
|
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
5
5
|
|
|
6
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it
|
|
6
|
+
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; } } }; }
|
|
7
7
|
|
|
8
8
|
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); }
|
|
9
9
|
|
|
@@ -14,7 +14,6 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
|
|
|
14
14
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
15
15
|
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
16
16
|
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
17
|
-
import _getIterator from "@babel/runtime-corejs3/core-js/get-iterator";
|
|
18
17
|
import React from 'react';
|
|
19
18
|
import zhCNData from './zh-CN';
|
|
20
19
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
2
2
|
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
3
3
|
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
4
|
-
import _getIterator from "@babel/runtime-corejs3/core-js/get-iterator";
|
|
5
4
|
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
6
5
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
7
6
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
@@ -12,7 +11,7 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
|
|
|
12
11
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
13
12
|
import _Map from "@babel/runtime-corejs3/core-js-stable/map";
|
|
14
13
|
|
|
15
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it
|
|
14
|
+
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; } } }; }
|
|
16
15
|
|
|
17
16
|
function _unsupportedIterableToArray(o, minLen) { var _context10; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context10 = Object.prototype.toString.call(o)).call(_context10, 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); }
|
|
18
17
|
|
|
@@ -177,7 +176,7 @@ function getHorizontalRenderRange(_ref) {
|
|
|
177
176
|
while (leftIndex + centerCount < flat.center.length) {
|
|
178
177
|
var _col = flat.center[leftIndex + centerCount];
|
|
179
178
|
|
|
180
|
-
if (
|
|
179
|
+
if (centerRenderWidth < minCenterRenderWidth) {
|
|
181
180
|
centerRenderWidth += _col.width;
|
|
182
181
|
centerCount += 1;
|
|
183
182
|
} else {
|
|
@@ -192,7 +191,7 @@ function getHorizontalRenderRange(_ref) {
|
|
|
192
191
|
return {
|
|
193
192
|
leftIndex: leftIndex,
|
|
194
193
|
leftBlank: leftBlank,
|
|
195
|
-
rightIndex: leftIndex + centerCount
|
|
194
|
+
rightIndex: leftIndex + centerCount,
|
|
196
195
|
rightBlank: rightBlank
|
|
197
196
|
};
|
|
198
197
|
} // 一顿计算,将表格本次渲染所需要的数据都给算出来(代码写得有点乱,有较大优化空间)
|
package/es/table/base/empty.js
CHANGED
|
@@ -23,10 +23,10 @@ export function EmptyHtmlTable(_ref) {
|
|
|
23
23
|
}, /*#__PURE__*/React.createElement(Colgroup, {
|
|
24
24
|
descriptors: descriptors
|
|
25
25
|
}), /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", {
|
|
26
|
-
className: cx(Classes.tableRow,
|
|
26
|
+
className: cx(Classes.tableRow, Classes.first, Classes.last, 'no-hover'),
|
|
27
27
|
"data-rowindex": 0
|
|
28
28
|
}, /*#__PURE__*/React.createElement("td", {
|
|
29
|
-
className: cx(Classes.tableCell,
|
|
29
|
+
className: cx(Classes.tableCell, Classes.first, Classes.last),
|
|
30
30
|
colSpan: descriptors.length,
|
|
31
31
|
style: {
|
|
32
32
|
height: emptyCellHeight !== null && emptyCellHeight !== void 0 ? emptyCellHeight : 200
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { RenderInfo } from './interfaces';
|
|
3
|
-
|
|
3
|
+
interface TableHeaderProps {
|
|
4
4
|
info: RenderInfo;
|
|
5
|
-
|
|
5
|
+
theaderPosition?: 'left' | 'center' | 'right';
|
|
6
|
+
rowCount?: number;
|
|
7
|
+
}
|
|
8
|
+
export default function TableHeader({ info, theaderPosition, rowCount: _rowCount }: TableHeaderProps): JSX.Element;
|
|
9
|
+
export {};
|
package/es/table/base/header.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
3
|
-
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
4
|
-
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
5
|
-
import _getIterator from "@babel/runtime-corejs3/core-js/get-iterator";
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
6
2
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
7
3
|
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
8
4
|
import _flatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/flat";
|
|
9
5
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
10
6
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
7
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
8
|
+
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
9
|
+
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
10
|
+
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
11
11
|
|
|
12
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it
|
|
12
|
+
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; } } }; }
|
|
13
13
|
|
|
14
14
|
function _unsupportedIterableToArray(o, minLen) { var _context6; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context6 = Object.prototype.toString.call(o)).call(_context6, 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
15
|
|
|
@@ -226,24 +226,43 @@ function calculateHeaderRenderInfo(_ref, rowCount) {
|
|
|
226
226
|
export default function TableHeader(_ref2) {
|
|
227
227
|
var _context4, _context5;
|
|
228
228
|
|
|
229
|
-
var info = _ref2.info
|
|
229
|
+
var info = _ref2.info,
|
|
230
|
+
theaderPosition = _ref2.theaderPosition,
|
|
231
|
+
_rowCount = _ref2.rowCount;
|
|
230
232
|
|
|
231
233
|
var nested = info.nested,
|
|
232
234
|
flat = _flatInstanceProperty(info),
|
|
233
235
|
stickyLeftMap = info.stickyLeftMap,
|
|
234
236
|
stickyRightMap = info.stickyRightMap;
|
|
235
237
|
|
|
236
|
-
var rowCount = getTreeDepth(nested.full) + 1;
|
|
238
|
+
var rowCount = _rowCount !== null && _rowCount !== void 0 ? _rowCount : getTreeDepth(nested.full) + 1;
|
|
237
239
|
var headerRenderInfo = calculateHeaderRenderInfo(info, rowCount);
|
|
238
240
|
var fullFlatCount = flat.full.length;
|
|
239
241
|
var leftFlatCount = flat.left.length;
|
|
240
242
|
var rightFlatCount = flat.right.length;
|
|
241
243
|
|
|
242
244
|
var thead = _mapInstanceProperty(_context4 = headerRenderInfo.leveled).call(_context4, function (wrappedCols, level) {
|
|
243
|
-
var
|
|
245
|
+
var _cx2;
|
|
246
|
+
|
|
247
|
+
var _wrappedCols = _concatInstanceProperty(wrappedCols).call(wrappedCols); // 左中右区域渲染,分组列可能单独位于一个区域,此时其他区域也需要适配分组的高度
|
|
248
|
+
// rowspan 需要空白的列头去占位, 需要补充额外的空白列头
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
if (rowCount > 1 && ['left', 'right'].indexOf(theaderPosition) > -1) {
|
|
252
|
+
_wrappedCols.push({
|
|
253
|
+
type: 'blank',
|
|
254
|
+
blankSide: 'left',
|
|
255
|
+
width: 1,
|
|
256
|
+
isPlacehoder: true
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
var headerCells = _mapInstanceProperty(_wrappedCols).call(_wrappedCols, function (wrapped, index) {
|
|
244
261
|
var _a, _b, _c;
|
|
245
262
|
|
|
246
263
|
if (wrapped.type === 'normal') {
|
|
264
|
+
var _cx;
|
|
265
|
+
|
|
247
266
|
var colIndex = wrapped.colIndex,
|
|
248
267
|
colSpan = wrapped.colSpan,
|
|
249
268
|
isLeaf = wrapped.isLeaf,
|
|
@@ -259,16 +278,11 @@ export default function TableHeader(_ref2) {
|
|
|
259
278
|
positionStyle.right = stickyRightMap.get(colIndex);
|
|
260
279
|
}
|
|
261
280
|
|
|
281
|
+
var justifyContent = col.align === 'right' ? 'flex-end' : col.align === 'center' ? 'center' : 'flex-start';
|
|
262
282
|
var cell = /*#__PURE__*/React.createElement("th", _extends({
|
|
263
283
|
key: colIndex
|
|
264
284
|
}, headerCellProps, {
|
|
265
|
-
className: cx(Classes.tableHeaderCell, headerCellProps.className, {
|
|
266
|
-
first: colIndex === 0,
|
|
267
|
-
last: colIndex + colSpan === fullFlatCount,
|
|
268
|
-
'lock-left': colIndex < leftFlatCount,
|
|
269
|
-
'lock-right': colIndex >= fullFlatCount - rightFlatCount,
|
|
270
|
-
leaf: wrapped.isLeaf
|
|
271
|
-
}),
|
|
285
|
+
className: cx(Classes.tableHeaderCell, headerCellProps.className, (_cx = {}, _defineProperty(_cx, Classes.first, colIndex === 0), _defineProperty(_cx, Classes.last, colIndex + colSpan === fullFlatCount), _defineProperty(_cx, Classes.lockLeft, colIndex < leftFlatCount || theaderPosition === 'left'), _defineProperty(_cx, Classes.lockRight, colIndex >= fullFlatCount - rightFlatCount || theaderPosition === 'right'), _defineProperty(_cx, Classes.leaf, wrapped.isLeaf), _cx)),
|
|
272
286
|
colSpan: colSpan,
|
|
273
287
|
rowSpan: isLeaf ? rowCount - level : undefined,
|
|
274
288
|
style: _extends(_extends({
|
|
@@ -276,12 +290,20 @@ export default function TableHeader(_ref2) {
|
|
|
276
290
|
verticalAlign: (_b = col.verticalAlign) !== null && _b !== void 0 ? _b : 'middle'
|
|
277
291
|
}, headerCellProps.style), positionStyle),
|
|
278
292
|
"data-code": col.code
|
|
279
|
-
}),
|
|
293
|
+
}), theaderPosition === 'center' && positionStyle.position === 'sticky' ? null : /*#__PURE__*/React.createElement("div", {
|
|
294
|
+
className: Classes.tableHeaderCellContent,
|
|
295
|
+
style: {
|
|
296
|
+
justifyContent: justifyContent
|
|
297
|
+
}
|
|
298
|
+
}, (_c = col.title) !== null && _c !== void 0 ? _c : col.name));
|
|
280
299
|
return cell;
|
|
281
300
|
} else {
|
|
282
301
|
if (wrapped.width > 0) {
|
|
283
302
|
return /*#__PURE__*/React.createElement("th", {
|
|
284
|
-
key: wrapped.blankSide
|
|
303
|
+
key: wrapped.blankSide,
|
|
304
|
+
style: {
|
|
305
|
+
visibility: wrapped.isPlacehoder ? 'hidden' : undefined
|
|
306
|
+
}
|
|
285
307
|
});
|
|
286
308
|
} else {
|
|
287
309
|
return null;
|
|
@@ -291,10 +313,7 @@ export default function TableHeader(_ref2) {
|
|
|
291
313
|
|
|
292
314
|
return /*#__PURE__*/React.createElement("tr", {
|
|
293
315
|
key: level,
|
|
294
|
-
className: cx(Classes.tableHeaderRow, {
|
|
295
|
-
first: level === 0,
|
|
296
|
-
last: level === rowCount - 1
|
|
297
|
-
})
|
|
316
|
+
className: cx(Classes.tableHeaderRow, (_cx2 = {}, _defineProperty(_cx2, Classes.first, level === 0), _defineProperty(_cx2, Classes.last, level === rowCount - 1), _cx2))
|
|
298
317
|
}, headerCells);
|
|
299
318
|
});
|
|
300
319
|
|
|
@@ -37,7 +37,7 @@ var SpanManager = /*#__PURE__*/function () {
|
|
|
37
37
|
value: function add(rowIndex, colIndex, colSpan, rowSpan) {
|
|
38
38
|
this.rects.push({
|
|
39
39
|
left: colIndex,
|
|
40
|
-
right: colIndex + colSpan,
|
|
40
|
+
right: colIndex + (colSpan < 1 ? 1 : colSpan),
|
|
41
41
|
top: rowIndex,
|
|
42
42
|
bottom: rowIndex + rowSpan
|
|
43
43
|
});
|
|
@@ -8,6 +8,8 @@ export declare class TableDOMHelper {
|
|
|
8
8
|
readonly tableFooter: HTMLDivElement;
|
|
9
9
|
readonly stickyScroll: HTMLDivElement;
|
|
10
10
|
readonly stickyScrollItem: HTMLDivElement;
|
|
11
|
+
readonly tableHeaderMain: HTMLDivElement;
|
|
12
|
+
readonly tableFooterMain: HTMLDivElement;
|
|
11
13
|
constructor(artTableWrapper: HTMLDivElement);
|
|
12
14
|
getVirtualTop(): HTMLDivElement;
|
|
13
15
|
getTableRows(): NodeListOf<HTMLTableRowElement>;
|
|
@@ -15,4 +17,5 @@ export declare class TableDOMHelper {
|
|
|
15
17
|
getLeftLockShadow(): HTMLDivElement;
|
|
16
18
|
getRightLockShadow(): HTMLDivElement;
|
|
17
19
|
getLoadingIndicator(): HTMLDivElement;
|
|
20
|
+
getRowTop(rowIndex: number): number;
|
|
18
21
|
}
|
|
@@ -48,10 +48,12 @@ export var TableDOMHelper = /*#__PURE__*/function () {
|
|
|
48
48
|
this.artTableWrapper = artTableWrapper;
|
|
49
49
|
this.artTable = artTableWrapper.querySelector(".".concat(Classes.artTable));
|
|
50
50
|
this.tableHeader = this.artTable.querySelector(".".concat(Classes.tableHeader));
|
|
51
|
+
this.tableHeaderMain = this.artTable.querySelector(".".concat(Classes.tableHeaderMain));
|
|
51
52
|
this.tableBody = this.artTable.querySelector(".".concat(Classes.tableBody));
|
|
52
53
|
this.virtual = this.artTable.querySelector(".".concat(Classes.virtual));
|
|
53
54
|
this.tableElement = this.artTable.querySelector(".".concat(Classes.tableBody, " table"));
|
|
54
55
|
this.tableFooter = this.artTable.querySelector(".".concat(Classes.tableFooter));
|
|
56
|
+
this.tableFooterMain = this.artTable.querySelector(".".concat(Classes.tableFooterMain));
|
|
55
57
|
|
|
56
58
|
var stickyScrollSelector = _concatInstanceProperty(_context = ".".concat(Classes.artTable, " + .")).call(_context, Classes.stickyScroll);
|
|
57
59
|
|
|
@@ -73,23 +75,25 @@ export var TableDOMHelper = /*#__PURE__*/function () {
|
|
|
73
75
|
}, {
|
|
74
76
|
key: "getTableBodyHtmlTable",
|
|
75
77
|
value: function getTableBodyHtmlTable() {
|
|
76
|
-
|
|
78
|
+
var _context2;
|
|
79
|
+
|
|
80
|
+
return this.artTable.querySelector(_concatInstanceProperty(_context2 = ".".concat(Classes.tableBody, " .")).call(_context2, Classes.virtual, " table"));
|
|
77
81
|
}
|
|
78
82
|
}, {
|
|
79
83
|
key: "getLeftLockShadow",
|
|
80
84
|
value: function getLeftLockShadow() {
|
|
81
|
-
var
|
|
85
|
+
var _context3;
|
|
82
86
|
|
|
83
|
-
var selector = _concatInstanceProperty(
|
|
87
|
+
var selector = _concatInstanceProperty(_context3 = ".".concat(Classes.lockShadowMask, " .")).call(_context3, Classes.leftLockShadow);
|
|
84
88
|
|
|
85
89
|
return this.artTable.querySelector(selector);
|
|
86
90
|
}
|
|
87
91
|
}, {
|
|
88
92
|
key: "getRightLockShadow",
|
|
89
93
|
value: function getRightLockShadow() {
|
|
90
|
-
var
|
|
94
|
+
var _context4;
|
|
91
95
|
|
|
92
|
-
var selector = _concatInstanceProperty(
|
|
96
|
+
var selector = _concatInstanceProperty(_context4 = ".".concat(Classes.lockShadowMask, " .")).call(_context4, Classes.rightLockShadow);
|
|
93
97
|
|
|
94
98
|
return this.artTable.querySelector(selector);
|
|
95
99
|
}
|
|
@@ -98,6 +102,20 @@ export var TableDOMHelper = /*#__PURE__*/function () {
|
|
|
98
102
|
value: function getLoadingIndicator() {
|
|
99
103
|
return this.artTableWrapper.querySelector(".".concat(Classes.loadingIndicator));
|
|
100
104
|
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "getRowTop",
|
|
107
|
+
value: function getRowTop(rowIndex) {
|
|
108
|
+
var _context5, _context6;
|
|
109
|
+
|
|
110
|
+
if (rowIndex === 0) return 0;
|
|
111
|
+
|
|
112
|
+
var selector = _concatInstanceProperty(_context5 = _concatInstanceProperty(_context6 = ".".concat(Classes.tableBody, " .")).call(_context6, Classes.tableRow, "[data-rowindex=\"")).call(_context5, rowIndex, "\"]");
|
|
113
|
+
|
|
114
|
+
var row = this.artTable.querySelector(selector);
|
|
115
|
+
var rowOffsetTop = row && row.offsetTop || 0;
|
|
116
|
+
var tableOffsetTop = this.tableElement.offsetTop || 0;
|
|
117
|
+
return rowOffsetTop + tableOffsetTop;
|
|
118
|
+
}
|
|
101
119
|
}]);
|
|
102
120
|
|
|
103
121
|
return TableDOMHelper;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
export declare function getRichVisibleRectsStream(target: HTMLElement, structureMayChange$: Observable<'structure-may-change'>, virtualDebugLabel?: string): Observable<{
|
|
3
|
+
event: unknown;
|
|
4
|
+
targetRect: {
|
|
5
|
+
top: number;
|
|
6
|
+
left: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
right: number;
|
|
9
|
+
};
|
|
10
|
+
scrollParentRect: {
|
|
11
|
+
top: number;
|
|
12
|
+
left: number;
|
|
13
|
+
bottom: number;
|
|
14
|
+
right: number;
|
|
15
|
+
};
|
|
16
|
+
offsetY: number;
|
|
17
|
+
clipRect: {
|
|
18
|
+
left: number;
|
|
19
|
+
top: number;
|
|
20
|
+
right: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
};
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
2
|
+
import getNodeName from '@popperjs/core/lib/dom-utils/getNodeName';
|
|
3
|
+
import getOffsetParent from '@popperjs/core/lib/dom-utils/getOffsetParent';
|
|
4
|
+
import getParentNode from '@popperjs/core/lib/dom-utils/getParentNode';
|
|
5
|
+
import getWindow from '@popperjs/core/lib/dom-utils/getWindow';
|
|
6
|
+
import getWindowScroll from '@popperjs/core/lib/dom-utils/getWindowScroll';
|
|
7
|
+
import { isHTMLElement } from '@popperjs/core/lib/dom-utils/instanceOf';
|
|
8
|
+
import isScrollParent from '@popperjs/core/lib/dom-utils/isScrollParent';
|
|
9
|
+
import ResizeObserver from 'resize-observer-polyfill';
|
|
10
|
+
import { fromEvent, merge, Observable } from 'rxjs';
|
|
11
|
+
import * as op from 'rxjs/operators';
|
|
12
|
+
import { shallowEqual } from '../utils';
|
|
13
|
+
|
|
14
|
+
function isWindow(arg) {
|
|
15
|
+
return arg.toString() === '[object Window]';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isBody(arg) {
|
|
19
|
+
return getNodeName(arg) === 'body';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isHtml(arg) {
|
|
23
|
+
return getNodeName(arg) === 'html';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isHtmlOrBody(arg) {
|
|
27
|
+
return isHtml(arg) || isBody(arg);
|
|
28
|
+
} // 计算从 start(子元素)到 stop(祖先元素)之间所有元素的 scrollTop 或 scrollLeft 的和
|
|
29
|
+
// 注意 start 和 stop 都是 INCLUSIVE 的,即两者的 scrollTop 或 scrollLeft 都会统计在内
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
function accumulateScrollOffset(start, stop, scrollOffsetKey) {
|
|
33
|
+
var result = 0;
|
|
34
|
+
var elem = start;
|
|
35
|
+
|
|
36
|
+
while (elem != null) {
|
|
37
|
+
result += elem[scrollOffsetKey];
|
|
38
|
+
|
|
39
|
+
if (elem === stop || isWindow(stop) && isHtmlOrBody(elem)) {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
elem = elem.parentElement;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (isWindow(stop)) {
|
|
47
|
+
result += getWindowScroll(elem)[scrollOffsetKey];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 获取 target 相对于 base 的布局大小和相对位置。
|
|
54
|
+
* 注意该方法会考虑滚动所带来的影响
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
function getRelativeLayoutRect(base, target) {
|
|
59
|
+
if (isWindow(target) || isHtmlOrBody(target)) {
|
|
60
|
+
return {
|
|
61
|
+
left: 0,
|
|
62
|
+
right: window.innerWidth,
|
|
63
|
+
top: 0,
|
|
64
|
+
bottom: window.innerHeight
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var deltaX = 0;
|
|
69
|
+
var deltaY = 0;
|
|
70
|
+
var elem = target;
|
|
71
|
+
|
|
72
|
+
while (elem != null && elem != base) {
|
|
73
|
+
deltaY += elem.offsetTop;
|
|
74
|
+
deltaX += elem.offsetLeft;
|
|
75
|
+
var offsetParent = getOffsetParent(elem);
|
|
76
|
+
deltaY -= accumulateScrollOffset(elem.parentElement, offsetParent, 'scrollTop');
|
|
77
|
+
deltaX -= accumulateScrollOffset(elem.parentElement, offsetParent, 'scrollLeft');
|
|
78
|
+
|
|
79
|
+
if (isWindow(offsetParent)) {
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
deltaY += offsetParent.clientTop;
|
|
84
|
+
deltaX += offsetParent.clientLeft;
|
|
85
|
+
elem = offsetParent;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
top: deltaY,
|
|
90
|
+
bottom: deltaY + target.offsetHeight,
|
|
91
|
+
left: deltaX,
|
|
92
|
+
right: deltaX + target.offsetWidth
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function findCommonOffsetAncestor(target, scrollParent) {
|
|
97
|
+
if (isWindow(scrollParent)) {
|
|
98
|
+
return scrollParent;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
var offsetParents = listOffsetParents(target);
|
|
102
|
+
|
|
103
|
+
if (_includesInstanceProperty(offsetParents).call(offsetParents, scrollParent)) {
|
|
104
|
+
return scrollParent;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return getOffsetParent(scrollParent);
|
|
108
|
+
} // 列出 target 元素上层的所有 offset parents
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
function listOffsetParents(target) {
|
|
112
|
+
var result = [];
|
|
113
|
+
var elem = target;
|
|
114
|
+
|
|
115
|
+
while (true) {
|
|
116
|
+
if (isWindow(elem)) {
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
elem = getOffsetParent(elem);
|
|
121
|
+
result.push(elem);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function fromScrollEvent(element) {
|
|
128
|
+
return fromEvent(element, 'scroll', {
|
|
129
|
+
passive: true
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function fromResizeEvent(element) {
|
|
134
|
+
if (isWindow(element)) {
|
|
135
|
+
return fromEvent(element, 'resize', {
|
|
136
|
+
passive: true
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return new Observable(function (subscriber) {
|
|
141
|
+
var resizeObserver = new ResizeObserver(function (entries) {
|
|
142
|
+
subscriber.next(entries);
|
|
143
|
+
});
|
|
144
|
+
resizeObserver.observe(element);
|
|
145
|
+
return function () {
|
|
146
|
+
resizeObserver.disconnect();
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function getScrollParent(elem) {
|
|
152
|
+
var _context;
|
|
153
|
+
|
|
154
|
+
if (_includesInstanceProperty(_context = ['html', 'body', '#document']).call(_context, getNodeName(elem))) {
|
|
155
|
+
return getWindow(elem);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (isHTMLElement(elem) && isScrollParent(elem)) {
|
|
159
|
+
return elem;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return getScrollParent(getParentNode(elem));
|
|
163
|
+
} // 获取 target 相对于「它的滚动父元素」的可见部分的大小与位置
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
export function getRichVisibleRectsStream(target, structureMayChange$, virtualDebugLabel) {
|
|
167
|
+
return structureMayChange$.pipe(op.startWith('init'), op.map(function () {
|
|
168
|
+
// target 的第一个滚动父元素,我们认为这就是虚拟滚动发生的地方
|
|
169
|
+
// 即虚拟滚动不考虑「更上层元素发生滚动」的情况
|
|
170
|
+
// 直接从父元素开始查找,防止自身设置overflow属性导致是同一个元素
|
|
171
|
+
var scrollParent = getScrollParent(getParentNode(target)); // target 和 scrollParent 的共同 offset 祖先,作为布局尺寸计算时的参照元素
|
|
172
|
+
|
|
173
|
+
var commonOffsetAncestor = findCommonOffsetAncestor(target, scrollParent);
|
|
174
|
+
return {
|
|
175
|
+
scrollParent: scrollParent,
|
|
176
|
+
commonOffsetAncestor: commonOffsetAncestor
|
|
177
|
+
};
|
|
178
|
+
}), op.distinctUntilChanged(shallowEqual), op.tap(function (structure) {
|
|
179
|
+
if (virtualDebugLabel) {
|
|
180
|
+
console.log("%c[ali-react-table STRUCTURE ".concat(virtualDebugLabel, "]"), 'color: #4f9052; font-weight: bold', '\ntarget:', target, '\nscrollParent:', structure.scrollParent, '\ncommonOffsetAncestor:', structure.commonOffsetAncestor);
|
|
181
|
+
}
|
|
182
|
+
}), op.switchMap(function (_ref) {
|
|
183
|
+
var scrollParent = _ref.scrollParent,
|
|
184
|
+
commonOffsetAncestor = _ref.commonOffsetAncestor;
|
|
185
|
+
var events$ = merge(fromScrollEvent(scrollParent), fromResizeEvent(scrollParent), fromResizeEvent(target));
|
|
186
|
+
return events$.pipe(op.map(function (event) {
|
|
187
|
+
return {
|
|
188
|
+
targetRect: getRelativeLayoutRect(commonOffsetAncestor, target),
|
|
189
|
+
scrollParentRect: getRelativeLayoutRect(commonOffsetAncestor, scrollParent),
|
|
190
|
+
event: event
|
|
191
|
+
};
|
|
192
|
+
}), op.map(function (_ref2) {
|
|
193
|
+
var event = _ref2.event,
|
|
194
|
+
scrollParentRect = _ref2.scrollParentRect,
|
|
195
|
+
targetRect = _ref2.targetRect;
|
|
196
|
+
return {
|
|
197
|
+
event: event,
|
|
198
|
+
targetRect: targetRect,
|
|
199
|
+
scrollParentRect: scrollParentRect,
|
|
200
|
+
offsetY: Math.max(0, scrollParentRect.top - targetRect.top),
|
|
201
|
+
// 表格的横向滚动总是发生在表格内部,所以这里不需要计算 offsetX
|
|
202
|
+
// offsetX: Math.max(0, scrollParentRect.left - targetRect.left),
|
|
203
|
+
clipRect: {
|
|
204
|
+
left: Math.max(targetRect.left, scrollParentRect.left),
|
|
205
|
+
top: Math.max(targetRect.top, scrollParentRect.top),
|
|
206
|
+
right: Math.min(targetRect.right, scrollParentRect.right),
|
|
207
|
+
bottom: Math.min(targetRect.bottom, scrollParentRect.bottom)
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}));
|
|
211
|
+
}), op.tap(function (rects) {
|
|
212
|
+
if (virtualDebugLabel) {
|
|
213
|
+
console.log("%c[ali-react-table RECTS ".concat(virtualDebugLabel, "]"), 'color: #4f9052; font-weight: bold', '\noffsetY:', rects.offsetY, '\ntargetRect:', rects.targetRect, '\nscrollParentRect:', rects.scrollParentRect, '\nclipRect:', rects.clipRect, '\nevent:', rects.event);
|
|
214
|
+
}
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
@@ -4,6 +4,7 @@ import { BaseTableProps } from './table';
|
|
|
4
4
|
export interface HtmlTableProps extends Required<Pick<BaseTableProps, 'getRowProps' | 'primaryKey'>> {
|
|
5
5
|
tbodyHtmlTag: 'tbody' | 'tfoot';
|
|
6
6
|
data: any[];
|
|
7
|
+
hasScrollY?: boolean;
|
|
7
8
|
horizontalRenderInfo: Pick<RenderInfo, 'flat' | 'visible' | 'horizontalRenderRange' | 'stickyLeftMap' | 'stickyRightMap'>;
|
|
8
9
|
verticalRenderInfo: {
|
|
9
10
|
offset: number;
|
|
@@ -11,5 +12,6 @@ export interface HtmlTableProps extends Required<Pick<BaseTableProps, 'getRowPro
|
|
|
11
12
|
last: number;
|
|
12
13
|
limit: number;
|
|
13
14
|
};
|
|
15
|
+
tbodyPosition?: 'left' | 'center' | 'right';
|
|
14
16
|
}
|
|
15
|
-
export declare function HtmlTable({ tbodyHtmlTag, getRowProps, primaryKey, data, verticalRenderInfo: verInfo, horizontalRenderInfo: hozInfo }: HtmlTableProps): JSX.Element;
|
|
17
|
+
export declare function HtmlTable({ tbodyHtmlTag, getRowProps, primaryKey, hasScrollY, data, verticalRenderInfo: verInfo, horizontalRenderInfo: hozInfo, tbodyPosition }: HtmlTableProps): JSX.Element;
|