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