@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/utils.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _typeof3 = require("@babel/runtime-corejs3/helpers/typeof");
|
|
4
|
-
|
|
5
4
|
var _mapInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/map");
|
|
6
|
-
|
|
7
5
|
var _sliceInstanceProperty = 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
|
});
|
|
@@ -31,45 +22,25 @@ exports.shallowEqual = shallowEqual;
|
|
|
31
22
|
exports.sum = sum;
|
|
32
23
|
exports.syncScrollLeft = syncScrollLeft;
|
|
33
24
|
exports.throttledWindowResize$ = void 0;
|
|
34
|
-
|
|
35
25
|
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
|
36
|
-
|
|
37
26
|
var _is = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/is"));
|
|
38
|
-
|
|
39
27
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
40
|
-
|
|
41
28
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
42
|
-
|
|
43
29
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
44
|
-
|
|
45
30
|
var _rxjs = require("rxjs");
|
|
46
|
-
|
|
47
31
|
var _operators = require("rxjs/operators");
|
|
48
|
-
|
|
49
32
|
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
|
50
|
-
|
|
51
33
|
var styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
52
|
-
|
|
53
34
|
var _cssVarsPonyfill = _interopRequireDefault(require("css-vars-ponyfill"));
|
|
54
|
-
|
|
55
35
|
var _mergeCellProps = _interopRequireDefault(require("../utils/mergeCellProps"));
|
|
56
|
-
|
|
57
36
|
var _utils = require("../utils");
|
|
58
|
-
|
|
59
37
|
var _styles = require("./styles");
|
|
60
|
-
|
|
61
38
|
var _element = require("../utils/element");
|
|
62
|
-
|
|
63
39
|
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); }
|
|
64
|
-
|
|
65
40
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
|
|
66
|
-
|
|
67
41
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
68
|
-
|
|
69
42
|
function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
70
|
-
|
|
71
43
|
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; }
|
|
72
|
-
|
|
73
44
|
/** styled-components 类库的版本,ali-react-table 同时支持 v3 和 v5 */
|
|
74
45
|
var STYLED_VERSION = styledComponents.createGlobalStyle != null ? 'v5' : 'v3';
|
|
75
46
|
exports.STYLED_VERSION = STYLED_VERSION;
|
|
@@ -79,16 +50,14 @@ var OVERSCAN_SIZE = 100;
|
|
|
79
50
|
exports.OVERSCAN_SIZE = OVERSCAN_SIZE;
|
|
80
51
|
var AUTO_VIRTUAL_THRESHOLD = 100;
|
|
81
52
|
exports.AUTO_VIRTUAL_THRESHOLD = AUTO_VIRTUAL_THRESHOLD;
|
|
82
|
-
|
|
83
53
|
function sum(arr) {
|
|
84
54
|
var result = 0;
|
|
85
55
|
arr.forEach(function (x) {
|
|
86
56
|
result += x;
|
|
87
57
|
});
|
|
88
58
|
return result;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
59
|
+
}
|
|
60
|
+
// 使用 defer 避免过早引用 window,导致在 SSR 场景下报错
|
|
92
61
|
var throttledWindowResize$ = (0, _rxjs.defer)(function () {
|
|
93
62
|
return (0, _rxjs.fromEvent)(window, 'resize', {
|
|
94
63
|
passive: true
|
|
@@ -98,31 +67,24 @@ var throttledWindowResize$ = (0, _rxjs.defer)(function () {
|
|
|
98
67
|
}));
|
|
99
68
|
});
|
|
100
69
|
exports.throttledWindowResize$ = throttledWindowResize$;
|
|
101
|
-
|
|
102
70
|
var addResizeObserver = function addResizeObserver(element, handler) {
|
|
103
71
|
var measure = function measure(entries) {
|
|
104
72
|
if (!entries[0] || !entries[0].contentRect) {
|
|
105
73
|
return;
|
|
106
74
|
}
|
|
107
|
-
|
|
108
75
|
var contentRect = entries[0].contentRect;
|
|
109
76
|
var hide = contentRect.width === 0 && contentRect.height === 0; // 隐藏条件:高宽都为0
|
|
110
|
-
|
|
111
77
|
var rect = (0, _extends2.default)({
|
|
112
78
|
hide: hide
|
|
113
79
|
}, contentRect);
|
|
114
80
|
handler && handler(rect);
|
|
115
81
|
};
|
|
116
|
-
|
|
117
82
|
var resizeObserver = new _resizeObserverPolyfill.default(measure);
|
|
118
83
|
resizeObserver && resizeObserver.observe(element);
|
|
119
84
|
return resizeObserver;
|
|
120
85
|
};
|
|
121
86
|
/** 获取默认的滚动条大小 */
|
|
122
|
-
|
|
123
|
-
|
|
124
87
|
exports.addResizeObserver = addResizeObserver;
|
|
125
|
-
|
|
126
88
|
function getScrollbarSizeImpl() {
|
|
127
89
|
var scrollDiv = document.createElement('div');
|
|
128
90
|
scrollDiv.style.position = 'absolute';
|
|
@@ -139,9 +101,7 @@ function getScrollbarSizeImpl() {
|
|
|
139
101
|
height: scrollbarHeight
|
|
140
102
|
};
|
|
141
103
|
}
|
|
142
|
-
|
|
143
104
|
var scrollBarSize$;
|
|
144
|
-
|
|
145
105
|
function getScrollbarSize() {
|
|
146
106
|
if (scrollBarSize$ == null) {
|
|
147
107
|
scrollBarSize$ = new _rxjs.BehaviorSubject(getScrollbarSizeImpl());
|
|
@@ -149,29 +109,21 @@ function getScrollbarSize() {
|
|
|
149
109
|
return getScrollbarSizeImpl();
|
|
150
110
|
})).subscribe(scrollBarSize$);
|
|
151
111
|
}
|
|
152
|
-
|
|
153
112
|
return scrollBarSize$.value;
|
|
154
113
|
}
|
|
155
114
|
/** 同步多个元素之间的 scrollLeft, 每当 scrollLeft 发生变化时 callback 会被调用 */
|
|
156
|
-
|
|
157
|
-
|
|
158
115
|
function syncScrollLeft(elements, callback) {
|
|
159
116
|
var bypassSet = new _set.default();
|
|
160
|
-
|
|
161
117
|
function publishScrollLeft(origin, scrollLeft) {
|
|
162
118
|
bypassSet.clear();
|
|
163
|
-
|
|
164
119
|
var _iterator = _createForOfIteratorHelper(elements),
|
|
165
|
-
|
|
166
|
-
|
|
120
|
+
_step;
|
|
167
121
|
try {
|
|
168
122
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
169
123
|
var elem = _step.value;
|
|
170
|
-
|
|
171
124
|
if (elem === origin) {
|
|
172
125
|
continue;
|
|
173
126
|
}
|
|
174
|
-
|
|
175
127
|
elem.scrollLeft = scrollLeft;
|
|
176
128
|
bypassSet.add(elem);
|
|
177
129
|
}
|
|
@@ -181,32 +133,25 @@ function syncScrollLeft(elements, callback) {
|
|
|
181
133
|
_iterator.f();
|
|
182
134
|
}
|
|
183
135
|
}
|
|
184
|
-
|
|
185
136
|
var subscription = new _rxjs.Subscription();
|
|
186
|
-
|
|
187
137
|
var _iterator2 = _createForOfIteratorHelper(elements),
|
|
188
|
-
|
|
189
|
-
|
|
138
|
+
_step2;
|
|
190
139
|
try {
|
|
191
140
|
var _loop = function _loop() {
|
|
192
141
|
var ele = _step2.value;
|
|
193
|
-
|
|
194
142
|
var listener = function listener() {
|
|
195
143
|
if (bypassSet.has(ele)) {
|
|
196
144
|
bypassSet.delete(ele);
|
|
197
145
|
return;
|
|
198
146
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
147
|
+
var scrollLeft = ele.scrollLeft;
|
|
148
|
+
// 某一元素当滚动条消失时会触发scroll事件(scrolLeft重置为0),不同步其他其他元素的scrollLeft
|
|
202
149
|
if (scrollLeft === 0 && !(0, _element.hasScroll)(ele)) {
|
|
203
150
|
return;
|
|
204
151
|
}
|
|
205
|
-
|
|
206
152
|
publishScrollLeft(ele, scrollLeft);
|
|
207
153
|
callback(scrollLeft);
|
|
208
154
|
};
|
|
209
|
-
|
|
210
155
|
ele.addEventListener('scroll', listener, {
|
|
211
156
|
passive: true
|
|
212
157
|
});
|
|
@@ -214,7 +159,6 @@ function syncScrollLeft(elements, callback) {
|
|
|
214
159
|
return ele.removeEventListener('scroll', listener);
|
|
215
160
|
});
|
|
216
161
|
};
|
|
217
|
-
|
|
218
162
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
219
163
|
_loop();
|
|
220
164
|
}
|
|
@@ -223,7 +167,6 @@ function syncScrollLeft(elements, callback) {
|
|
|
223
167
|
} finally {
|
|
224
168
|
_iterator2.f();
|
|
225
169
|
}
|
|
226
|
-
|
|
227
170
|
return subscription;
|
|
228
171
|
}
|
|
229
172
|
/**
|
|
@@ -231,73 +174,56 @@ function syncScrollLeft(elements, callback) {
|
|
|
231
174
|
* when any key has values which are not strictly equal between the arguments.
|
|
232
175
|
* Returns true when the values of all keys are strictly equal.
|
|
233
176
|
*/
|
|
234
|
-
|
|
235
|
-
|
|
236
177
|
function shallowEqual(objA, objB) {
|
|
237
178
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
238
|
-
|
|
239
179
|
if ((0, _is.default)(objA, objB)) {
|
|
240
180
|
return true;
|
|
241
181
|
}
|
|
242
|
-
|
|
243
182
|
if ((0, _typeof2.default)(objA) !== 'object' || objA === null || (0, _typeof2.default)(objB) !== 'object' || objB === null) {
|
|
244
183
|
return false;
|
|
245
184
|
}
|
|
246
|
-
|
|
247
185
|
var keysA = (0, _keys.default)(objA);
|
|
248
186
|
var keysB = (0, _keys.default)(objB);
|
|
249
|
-
|
|
250
187
|
if (keysA.length !== keysB.length) {
|
|
251
188
|
return false;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
189
|
+
}
|
|
190
|
+
// Test for A's keys different from B.
|
|
255
191
|
for (var i = 0; i < keysA.length; i++) {
|
|
256
192
|
if (!hasOwnProperty.call(objB, keysA[i]) || !(0, _is.default)(objA[keysA[i]], objB[keysA[i]])) {
|
|
257
193
|
return false;
|
|
258
194
|
}
|
|
259
195
|
}
|
|
260
|
-
|
|
261
196
|
return true;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
197
|
+
}
|
|
198
|
+
// todo: 抽出mergeRowProps
|
|
265
199
|
function composeRowPropsGetter(getRowProps, pendingRowProps) {
|
|
266
200
|
var keys = (0, _keys.default)(pendingRowProps);
|
|
267
|
-
|
|
268
201
|
if (keys.length) {
|
|
269
202
|
return function (row, rowIndex) {
|
|
270
203
|
return (0, _mergeCellProps.default)(getRowProps(row, rowIndex), pendingRowProps);
|
|
271
204
|
};
|
|
272
205
|
}
|
|
273
|
-
|
|
274
206
|
return getRowProps;
|
|
275
207
|
}
|
|
276
|
-
|
|
277
208
|
function getTableScrollHeaderDOM(domHelper) {
|
|
278
209
|
return _utils.browserType.isIE ? domHelper.tableHeaderMain : domHelper.tableHeader;
|
|
279
210
|
}
|
|
280
|
-
|
|
281
211
|
function getTableScrollFooterDOM(domHelper) {
|
|
282
212
|
return _utils.browserType.isIE ? domHelper.tableFooterMain : domHelper.tableFooter;
|
|
283
213
|
}
|
|
284
|
-
|
|
285
214
|
var cssPolifill = function cssPolifill(_ref) {
|
|
286
215
|
var variables = _ref.variables,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
216
|
+
enableCSSVariables = _ref.enableCSSVariables,
|
|
217
|
+
bordered = _ref.bordered;
|
|
290
218
|
if (enableCSSVariables === false) {
|
|
291
219
|
return;
|
|
292
220
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
221
|
+
var conditionCSSVariables = {};
|
|
222
|
+
// 默认情况下存在td、th无左右边框,开启`bordered`属性后才开启,否则隐藏这两种属性
|
|
296
223
|
if (!bordered) {
|
|
297
224
|
conditionCSSVariables['--cell-border-vertical'] = 'none';
|
|
298
225
|
conditionCSSVariables['--header-cell-border-vertical'] = 'none';
|
|
299
226
|
}
|
|
300
|
-
|
|
301
227
|
(0, _cssVarsPonyfill.default)({
|
|
302
228
|
// exclude: 'link[href*="semantic-ui"]',
|
|
303
229
|
// onlyLegacy: false,
|
|
@@ -308,5 +234,4 @@ var cssPolifill = function cssPolifill(_ref) {
|
|
|
308
234
|
silent: true
|
|
309
235
|
});
|
|
310
236
|
};
|
|
311
|
-
|
|
312
237
|
exports.cssPolifill = cssPolifill;
|
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.icons = exports.InlineFlexCell = exports.ExpansionCell = exports.ContextMenuStyleWrap = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
|
|
16
11
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
17
|
-
|
|
18
12
|
var _styles = require("./base/styles");
|
|
19
|
-
|
|
20
13
|
var _templateObject, _templateObject2, _templateObject3;
|
|
21
|
-
|
|
22
14
|
var InlineFlexCell = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n align-items: center;\n"])));
|
|
23
|
-
|
|
24
15
|
exports.InlineFlexCell = InlineFlexCell;
|
|
25
16
|
var ExpansionCell = (0, _styledComponents.default)(function (props) {
|
|
26
17
|
return /*#__PURE__*/_react.default.createElement(InlineFlexCell, (0, _extends2.default)({}, props));
|
|
27
18
|
})(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n &.", " {\n cursor: default;\n }\n\n .expansion-icon {\n fill: #999;\n flex: 0 0 16px;\n transition: transform 200ms;\n\n &.", " {\n transform-origin: center center;\n transform: rotate(90deg);\n }\n }\n"])), _styles.Classes.leaf, _styles.Classes.expanded);
|
|
28
19
|
exports.ExpansionCell = ExpansionCell;
|
|
29
|
-
|
|
30
20
|
function CaretDownIcon(props) {
|
|
31
21
|
return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({
|
|
32
22
|
focusable: "false",
|
|
@@ -39,7 +29,6 @@ function CaretDownIcon(props) {
|
|
|
39
29
|
d: "M24 12L16 22 8 12z"
|
|
40
30
|
}));
|
|
41
31
|
}
|
|
42
|
-
|
|
43
32
|
function InfoIcon(props) {
|
|
44
33
|
return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({
|
|
45
34
|
focusable: "false",
|
|
@@ -54,7 +43,6 @@ function InfoIcon(props) {
|
|
|
54
43
|
d: "M8,15c-3.9,0-7-3.1-7-7s3.1-7,7-7s7,3.1,7,7S11.9,15,8,15z M8,2C4.7,2,2,4.7,2,8s2.7,6,6,6s6-2.7,6-6S11.3,2,8,2z"
|
|
55
44
|
}));
|
|
56
45
|
}
|
|
57
|
-
|
|
58
46
|
function CaretRightIcon(props) {
|
|
59
47
|
return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({
|
|
60
48
|
focusable: "false",
|
|
@@ -67,7 +55,6 @@ function CaretRightIcon(props) {
|
|
|
67
55
|
d: "M12 8L22 16 12 24z"
|
|
68
56
|
}));
|
|
69
57
|
}
|
|
70
|
-
|
|
71
58
|
function LoadingIcon(props) {
|
|
72
59
|
return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({
|
|
73
60
|
width: "16",
|
|
@@ -78,7 +65,6 @@ function LoadingIcon(props) {
|
|
|
78
65
|
d: "M512 74.667c-17.067 0-32 14.933-32 32V256c0 17.067 14.933 32 32 32s32-14.933 32-32V106.667c0-17.067-14.933-32-32-32zm181.333 288c8.534 0 17.067-2.134 23.467-8.534L821.333 249.6c12.8-12.8 12.8-32 0-44.8-12.8-12.8-32-12.8-44.8 0L672 309.333c-12.8 12.8-12.8 32 0 44.8 4.267 6.4 12.8 8.534 21.333 8.534zm224 117.333H768c-17.067 0-32 14.933-32 32s14.933 32 32 32h149.333c17.067 0 32-14.933 32-32s-14.933-32-32-32zM714.667 669.867c-12.8-12.8-32-12.8-44.8 0s-12.8 32 0 44.8L774.4 819.2c6.4 6.4 14.933 8.533 23.467 8.533s17.066-2.133 23.466-8.533c12.8-12.8 12.8-32 0-44.8L714.667 669.867zM512 736c-17.067 0-32 14.933-32 32v149.333c0 17.067 14.933 32 32 32s32-14.933 32-32V768c0-17.067-14.933-32-32-32zm-202.667-66.133L204.8 774.4c-12.8 12.8-12.8 32 0 44.8 6.4 6.4 14.933 8.533 23.467 8.533s17.066-2.133 23.466-8.533l104.534-104.533c12.8-12.8 12.8-32 0-44.8s-36.267-12.8-46.934 0zM288 512c0-17.067-14.933-32-32-32H106.667c-17.067 0-32 14.933-32 32s14.933 32 32 32H256c17.067 0 32-14.933 32-32zm-40.533-309.333c-12.8-12.8-32-12.8-44.8 0-12.8 12.8-12.8 32 0 44.8L307.2 352c6.4 6.4 14.933 8.533 23.467 8.533s17.066-2.133 23.466-8.533c12.8-12.8 12.8-32 0-44.8L247.467 202.667z"
|
|
79
66
|
}));
|
|
80
67
|
}
|
|
81
|
-
|
|
82
68
|
var icons = {
|
|
83
69
|
Loading: LoadingIcon,
|
|
84
70
|
CaretDown: CaretDownIcon,
|
|
@@ -86,7 +72,5 @@ var icons = {
|
|
|
86
72
|
Info: InfoIcon
|
|
87
73
|
};
|
|
88
74
|
exports.icons = icons;
|
|
89
|
-
|
|
90
75
|
var ContextMenuStyleWrap = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n &.", "{\n border: 1px solid #e9ecf1;\n border-radius: 2px;\n background-color: #Fff;\n box-shadow: 0px 0px 5px 0px rgb(154 154 154 / 50%);\n cursor: default;\n font-size: 12px;\n position:absolute;\n z-index: 1050;\n max-width: 600px;\n padding: 8px 0;\n }\n\n .", "{\n width:100%;\n display: table;\n }\n\n .", " .", "{\n display: table-row;\n color: #212121;\n }\n\n .", " .", "{\n background-color: var(--hover-bgcolor);\n }\n\n .", " .", " .", "{\n display: table-cell;\n padding: 8px 12px;\n max-width: 576px;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n line-height: 16px;\n }\n .", " .", ".", "{\n opacity: .5;\n }\n\n"])), _styles.MenuClasses.menu, _styles.MenuClasses.menuList, _styles.MenuClasses.menuList, _styles.MenuClasses.menuOption, _styles.MenuClasses.menuList, _styles.MenuClasses.menuOptionActive, _styles.MenuClasses.menuList, _styles.MenuClasses.menuOption, _styles.MenuClasses.menuOptionText, _styles.MenuClasses.menuList, _styles.MenuClasses.menuOption, _styles.MenuClasses.menuOptionDisable);
|
|
91
|
-
|
|
92
76
|
exports.ContextMenuStyleWrap = ContextMenuStyleWrap;
|
package/lib/table/index.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
|
|
9
7
|
var _base = require("./base");
|
|
10
|
-
|
|
11
8
|
_Object$keys(_base).forEach(function (key) {
|
|
12
9
|
if (key === "default" || key === "__esModule") return;
|
|
13
10
|
if (key in exports && exports[key] === _base[key]) return;
|
|
@@ -18,9 +15,7 @@ _Object$keys(_base).forEach(function (key) {
|
|
|
18
15
|
}
|
|
19
16
|
});
|
|
20
17
|
});
|
|
21
|
-
|
|
22
18
|
var _interfaces = require("./interfaces");
|
|
23
|
-
|
|
24
19
|
_Object$keys(_interfaces).forEach(function (key) {
|
|
25
20
|
if (key === "default" || key === "__esModule") return;
|
|
26
21
|
if (key in exports && exports[key] === _interfaces[key]) return;
|
|
@@ -31,9 +26,7 @@ _Object$keys(_interfaces).forEach(function (key) {
|
|
|
31
26
|
}
|
|
32
27
|
});
|
|
33
28
|
});
|
|
34
|
-
|
|
35
29
|
var _utils = require("./utils");
|
|
36
|
-
|
|
37
30
|
_Object$keys(_utils).forEach(function (key) {
|
|
38
31
|
if (key === "default" || key === "__esModule") return;
|
|
39
32
|
if (key in exports && exports[key] === _utils[key]) return;
|
|
@@ -44,9 +37,7 @@ _Object$keys(_utils).forEach(function (key) {
|
|
|
44
37
|
}
|
|
45
38
|
});
|
|
46
39
|
});
|
|
47
|
-
|
|
48
40
|
var _transforms = require("./transforms");
|
|
49
|
-
|
|
50
41
|
_Object$keys(_transforms).forEach(function (key) {
|
|
51
42
|
if (key === "default" || key === "__esModule") return;
|
|
52
43
|
if (key in exports && exports[key] === _transforms[key]) return;
|
|
@@ -57,9 +48,7 @@ _Object$keys(_transforms).forEach(function (key) {
|
|
|
57
48
|
}
|
|
58
49
|
});
|
|
59
50
|
});
|
|
60
|
-
|
|
61
51
|
var _pipeline = require("./pipeline");
|
|
62
|
-
|
|
63
52
|
_Object$keys(_pipeline).forEach(function (key) {
|
|
64
53
|
if (key === "default" || key === "__esModule") return;
|
|
65
54
|
if (key in exports && exports[key] === _pipeline[key]) return;
|
|
@@ -70,9 +59,7 @@ _Object$keys(_pipeline).forEach(function (key) {
|
|
|
70
59
|
}
|
|
71
60
|
});
|
|
72
61
|
});
|
|
73
|
-
|
|
74
62
|
var _internals = require("./internals");
|
|
75
|
-
|
|
76
63
|
_Object$keys(_internals).forEach(function (key) {
|
|
77
64
|
if (key === "default" || key === "__esModule") return;
|
|
78
65
|
if (key in exports && exports[key] === _internals[key]) return;
|
package/lib/table/internals.js
CHANGED
|
@@ -4,56 +4,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.internals = void 0;
|
|
7
|
-
|
|
8
7
|
function safeRenderHeader(column) {
|
|
9
8
|
var _a;
|
|
10
|
-
|
|
11
9
|
return (_a = column.title) !== null && _a !== void 0 ? _a : column.name;
|
|
12
10
|
}
|
|
13
|
-
|
|
14
11
|
function safeGetValue(column, record, rowIndex) {
|
|
15
12
|
if (column.getValue) {
|
|
16
13
|
return column.getValue(record, rowIndex);
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
return record[column.code];
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
function safeGetRowKey(primaryKey, record, rowIndex) {
|
|
23
18
|
var key;
|
|
24
|
-
|
|
25
19
|
if (typeof primaryKey === 'string') {
|
|
26
20
|
key = record[primaryKey];
|
|
27
21
|
} else if (typeof primaryKey === 'function') {
|
|
28
22
|
key = primaryKey(record);
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
if (key == null) {
|
|
32
25
|
key = String(rowIndex);
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
return key;
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
function safeGetCellProps(column, record, rowIndex) {
|
|
39
30
|
if (column.getCellProps) {
|
|
40
31
|
var value = safeGetValue(column, record, rowIndex);
|
|
41
32
|
return column.getCellProps(value, record, rowIndex) || {};
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
return {};
|
|
45
35
|
}
|
|
46
|
-
|
|
47
36
|
function safeRender(column, record, rowIndex) {
|
|
48
37
|
var value = safeGetValue(column, record, rowIndex);
|
|
49
|
-
|
|
50
38
|
if (column.render) {
|
|
51
39
|
return column.render(value, record, rowIndex);
|
|
52
40
|
}
|
|
53
|
-
|
|
54
41
|
return value;
|
|
55
42
|
}
|
|
56
|
-
|
|
57
43
|
var internals = {
|
|
58
44
|
safeRenderHeader: safeRenderHeader,
|
|
59
45
|
safeGetValue: safeGetValue,
|
|
@@ -1,49 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.tableWidthKey = exports.autoFillTableWidth = exports.FILL_COLUMN_CODE = void 0;
|
|
9
|
-
|
|
10
8
|
var _symbol = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/symbol"));
|
|
11
|
-
|
|
12
9
|
var _maxSafeInteger = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/number/max-safe-integer"));
|
|
13
|
-
|
|
14
10
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
15
|
-
|
|
16
11
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
17
|
-
|
|
18
12
|
var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
|
|
19
|
-
|
|
20
13
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
|
|
21
|
-
|
|
22
14
|
var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
|
|
23
|
-
|
|
24
15
|
var _calculations = require("../../base/calculations");
|
|
25
|
-
|
|
26
16
|
var _utils = require("../../utils");
|
|
27
|
-
|
|
28
17
|
var _styles = require("../../base/styles");
|
|
29
|
-
|
|
30
18
|
var _columnResizeWidth = require("./columnResizeWidth");
|
|
31
|
-
|
|
32
19
|
var FILL_COLUMN_CODE = '$_fill_column_&';
|
|
33
20
|
exports.FILL_COLUMN_CODE = FILL_COLUMN_CODE;
|
|
34
21
|
var tableWidthKey = 'tableWidth';
|
|
35
22
|
exports.tableWidthKey = tableWidthKey;
|
|
36
23
|
var FLEX_COLUMN_COUNT = (0, _symbol.default)('flexCount');
|
|
37
|
-
|
|
38
24
|
var autoFillTableWidth = function autoFillTableWidth() {
|
|
39
25
|
return function (pipeline) {
|
|
40
26
|
var flexColumnResult = findFlexColumns(pipeline);
|
|
41
27
|
var flexCount = flexColumnResult.get(FLEX_COLUMN_COUNT);
|
|
42
|
-
|
|
43
28
|
if (flexCount) {
|
|
44
29
|
// 设置了flex宽度,flex列平分剩余宽度
|
|
45
30
|
var remainingWidth = getTableRemainingWidth(pipeline) || 0;
|
|
46
|
-
|
|
47
31
|
if (remainingWidth > 0) {
|
|
48
32
|
// 保存剩余的flex总和和剩余宽度总和宽度
|
|
49
33
|
var residualFlexCount = flexCount;
|
|
@@ -51,25 +35,23 @@ var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
51
35
|
var columnSize = pipeline.getFeatureOptions(_columnResizeWidth.COLUMN_SIZE_KEY) || {};
|
|
52
36
|
pipeline.mapColumns((0, _utils.makeRecursiveMapper)(function (col, recursiveFlatMapInfo) {
|
|
53
37
|
var isLeaf = recursiveFlatMapInfo.isLeaf;
|
|
54
|
-
|
|
55
38
|
if (isLeaf && isValidFlexColumn(col, pipeline)) {
|
|
56
39
|
var code = col.code,
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
_col$features = col.features,
|
|
41
|
+
features = _col$features === void 0 ? {} : _col$features;
|
|
59
42
|
var flex = features.flex,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
43
|
+
_features$minWidth = features.minWidth,
|
|
44
|
+
minWidth = _features$minWidth === void 0 ? 0 : _features$minWidth,
|
|
45
|
+
_features$maxWidth = features.maxWidth,
|
|
46
|
+
maxWidth = _features$maxWidth === void 0 ? _maxSafeInteger.default : _features$maxWidth;
|
|
64
47
|
var usedRemainingWidth = Math.floor(remainingWidth * flex / flexCount);
|
|
65
|
-
var preColWidth = col.width;
|
|
66
|
-
|
|
48
|
+
var preColWidth = col.width;
|
|
49
|
+
// 如果当前已经是最后一个flex列,将剩余的宽度添加到该列,其他计算相应的列
|
|
67
50
|
col.width = clamp(minWidth, preColWidth + (residualFlexCount === flex ? residualFlexWidth : usedRemainingWidth), maxWidth);
|
|
68
51
|
residualFlexCount -= flex;
|
|
69
52
|
residualFlexWidth -= col.width - preColWidth;
|
|
70
53
|
columnSize[code] = col.width;
|
|
71
54
|
}
|
|
72
|
-
|
|
73
55
|
return col;
|
|
74
56
|
}));
|
|
75
57
|
pipeline.setFeatureOptions(_columnResizeWidth.COLUMN_SIZE_KEY, columnSize);
|
|
@@ -81,7 +63,6 @@ var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
81
63
|
return col.code === FILL_COLUMN_CODE;
|
|
82
64
|
});
|
|
83
65
|
var width = getTableRemainingWidth(pipeline) || 0;
|
|
84
|
-
|
|
85
66
|
if (fillColumns) {
|
|
86
67
|
fillColumns.width = width;
|
|
87
68
|
} else {
|
|
@@ -102,17 +83,13 @@ var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
102
83
|
};
|
|
103
84
|
(0, _splice.default)(columns).call(columns, spliceIndex || columns.length, 0, _fillColumns);
|
|
104
85
|
}
|
|
105
|
-
|
|
106
86
|
pipeline.columns(columns);
|
|
107
87
|
}
|
|
108
|
-
|
|
109
88
|
return pipeline;
|
|
110
|
-
|
|
111
89
|
function findFlexColumns(pipeline) {
|
|
112
90
|
var result = new _map.default([[FLEX_COLUMN_COUNT, 0]]);
|
|
113
91
|
dfs(pipeline.getColumns(), result);
|
|
114
92
|
return result;
|
|
115
|
-
|
|
116
93
|
function dfs(columns, result) {
|
|
117
94
|
columns.forEach(function (col) {
|
|
118
95
|
if ((0, _utils.isLeafNode)(col)) {
|
|
@@ -127,17 +104,13 @@ var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
127
104
|
}
|
|
128
105
|
};
|
|
129
106
|
};
|
|
130
|
-
|
|
131
107
|
exports.autoFillTableWidth = autoFillTableWidth;
|
|
132
|
-
|
|
133
108
|
function getColumnWidthSum(pipeline) {
|
|
134
109
|
return dfs(pipeline.getColumns());
|
|
135
|
-
|
|
136
110
|
function dfs(columns) {
|
|
137
111
|
return columns.reduce(function (acc, col) {
|
|
138
112
|
var width = col.width,
|
|
139
|
-
|
|
140
|
-
|
|
113
|
+
code = col.code;
|
|
141
114
|
if ((0, _utils.isLeafNode)(col) && code !== FILL_COLUMN_CODE) {
|
|
142
115
|
var resizeColumn = pipeline.getFeatureOptions(_columnResizeWidth.COLUMN_SIZE_KEY);
|
|
143
116
|
return acc + (resizeColumn && resizeColumn[code] || width);
|
|
@@ -147,17 +120,14 @@ function getColumnWidthSum(pipeline) {
|
|
|
147
120
|
}, 0);
|
|
148
121
|
}
|
|
149
122
|
}
|
|
150
|
-
|
|
151
123
|
function getTableRemainingWidth(pipeline) {
|
|
152
124
|
var tableWidth = pipeline.getStateAtKey(tableWidthKey);
|
|
153
125
|
if (!tableWidth) return;
|
|
154
126
|
var remainingWidth = Math.floor(tableWidth - getColumnWidthSum(pipeline));
|
|
155
127
|
return remainingWidth > 0 ? remainingWidth : 0;
|
|
156
128
|
}
|
|
157
|
-
|
|
158
129
|
function isAfterLastResizeCol(column, pipeline) {
|
|
159
130
|
var _context, _context2;
|
|
160
|
-
|
|
161
131
|
var lastResizedColumnCode = pipeline.getFeatureOptions(_columnResizeWidth.LAST_RESIZED_COLUMN_KEY);
|
|
162
132
|
if (lastResizedColumnCode === undefined) return true;
|
|
163
133
|
var lastResizedColumnIndex = (0, _findIndex.default)(_context = pipeline.getColumns()).call(_context, function (col) {
|
|
@@ -168,20 +138,16 @@ function isAfterLastResizeCol(column, pipeline) {
|
|
|
168
138
|
});
|
|
169
139
|
return colIndex > lastResizedColumnIndex;
|
|
170
140
|
}
|
|
171
|
-
|
|
172
141
|
function isValidFlexColumn(col, pipeline) {
|
|
173
142
|
var _a;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
143
|
+
var resizeColumn = pipeline.getFeatureOptions(_columnResizeWidth.RESIZED_COLUMN_KEY);
|
|
144
|
+
// 拖拽列自动禁止flex
|
|
177
145
|
if (resizeColumn === null || resizeColumn === void 0 ? void 0 : resizeColumn.has(col.code)) {
|
|
178
146
|
return false;
|
|
179
147
|
}
|
|
180
|
-
|
|
181
148
|
var flex = (_a = col.features) === null || _a === void 0 ? void 0 : _a.flex;
|
|
182
149
|
return typeof flex === 'number' && flex > 0 && isAfterLastResizeCol(col, pipeline);
|
|
183
150
|
}
|
|
184
|
-
|
|
185
151
|
function clamp(min, x, max) {
|
|
186
152
|
return Math.max(min, Math.min(max, x));
|
|
187
153
|
}
|