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