@kdcloudjs/table 1.2.1-canary.6 → 1.2.2-canary.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +568 -568
- package/README.md +111 -111
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +5480 -6087
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +18 -16
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/dist/kd-ui-complete.less +777 -777
- package/es/_utils/arrayUtil.js +0 -3
- package/es/_utils/devwarning.js +0 -1
- package/es/_utils/formatUtil.js +36 -101
- package/es/_utils/hooks.js +21 -45
- package/es/_utils/index.js +0 -2
- package/es/_utils/numberUtil.js +32 -55
- package/es/_utils/omit.js +0 -2
- package/es/_utils/type.js +0 -2
- package/es/_utils/usePopper.js +81 -144
- package/es/config-provider/compDefaultProps.js +0 -1
- package/es/config-provider/configProvider.js +2 -7
- package/es/config-provider/defaultConfig.js +0 -1
- package/es/index.js +0 -2
- package/es/locale/locale.js +11 -50
- package/es/style/color/colors.less +1 -1
- package/es/style/core/index.less +1 -1
- package/es/style/core/motion/other.less +27 -27
- package/es/style/core/motion/slide.less +53 -53
- package/es/style/core/motion.less +1 -1
- package/es/style/core/reset.less +185 -185
- package/es/style/index.less +1 -1
- package/es/style/mixins/index.less +18 -18
- package/es/style/mixins/overlay.less +21 -21
- package/es/style/mixins/reset.less +12 -12
- package/es/style/themes/default.less +445 -445
- package/es/table/base/calculations.js +25 -75
- package/es/table/base/colgroup.js +0 -1
- package/es/table/base/empty.js +6 -6
- package/es/table/base/globalStyleComponent.d.ts +4 -0
- package/es/table/base/globalStyleComponent.js +24 -0
- package/es/table/base/header.js +21 -76
- package/es/table/base/helpers/SpanManager.js +4 -11
- package/es/table/base/helpers/TableDOMUtils.js +9 -34
- package/es/table/base/helpers/__test__/SpanManager.test.js +2 -2
- package/es/table/base/helpers/__test__/TableDOMUtils.test.js +0 -1
- package/es/table/base/helpers/getRichVisibleRectsStream.js +13 -45
- package/es/table/base/helpers/rowHeightManager.js +0 -28
- package/es/table/base/html-table.js +17 -39
- package/es/table/base/loading.js +8 -10
- package/es/table/base/renderTemplates.js +42 -60
- package/es/table/base/styles.d.ts +10 -0
- package/es/table/base/styles.js +17 -16
- package/es/table/base/table.js +113 -201
- package/es/table/base/utils.js +17 -57
- package/es/table/common-views.js +0 -7
- package/es/table/interfaces.d.ts +38 -0
- package/es/table/internals.js +0 -13
- package/es/table/pipeline/const.d.ts +3 -0
- package/es/table/pipeline/const.js +3 -0
- package/es/table/pipeline/features/autoFill.js +11 -40
- package/es/table/pipeline/features/autoRowSpan.js +1 -14
- package/es/table/pipeline/features/colGroupExtendable.js +4 -19
- package/es/table/pipeline/features/columnDrag.js +41 -97
- package/es/table/pipeline/features/columnFilter.js +12 -51
- package/es/table/pipeline/features/columnHover.js +1 -7
- package/es/table/pipeline/features/columnRangeHover.js +1 -8
- package/es/table/pipeline/features/columnResizeWidth.js +13 -39
- package/es/table/pipeline/features/contextMenu.js +22 -95
- package/es/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
- package/es/table/pipeline/features/featureApi/RowDragApi.js +66 -0
- package/es/table/pipeline/features/featureApi/utils.d.ts +2 -0
- package/es/table/pipeline/features/featureApi/utils.js +10 -0
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +14 -30
- package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
- package/es/table/pipeline/features/filter/Filter.js +27 -51
- package/es/table/pipeline/features/filter/FilterPanel.js +11 -25
- package/es/table/pipeline/features/filter/util.js +0 -4
- package/es/table/pipeline/features/footerDataSource.js +0 -3
- package/es/table/pipeline/features/mergeCellHover.js +0 -1
- package/es/table/pipeline/features/multiSelect.js +15 -57
- package/es/table/pipeline/features/rangeSelection.js +73 -152
- package/es/table/pipeline/features/rowDetail.js +4 -43
- package/es/table/pipeline/features/rowDrag.d.ts +10 -12
- package/es/table/pipeline/features/rowDrag.js +491 -236
- package/es/table/pipeline/features/rowGrouping.js +4 -37
- package/es/table/pipeline/features/singleSelect.js +0 -24
- package/es/table/pipeline/features/sort.js +38 -96
- package/es/table/pipeline/features/tips.js +4 -10
- package/es/table/pipeline/features/treeMode.d.ts +1 -0
- package/es/table/pipeline/features/treeMode.js +38 -57
- package/es/table/pipeline/features/treeSelect.js +2 -28
- package/es/table/pipeline/pipeline.d.ts +3 -0
- package/es/table/pipeline/pipeline.js +35 -54
- package/es/table/pivot/cross-table/buildCrossTable.js +21 -72
- package/es/table/pivot/cross-table/cross-table.js +23 -31
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -57
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +36 -61
- package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
- package/es/table/pivot/pivot-utils/builders.js +34 -74
- package/es/table/pivot/pivot-utils/convert-utils.js +16 -42
- package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
- package/es/table/style/index.less +1 -1
- package/es/table/transforms/autoRowSpan.js +1 -15
- package/es/table/transforms/autoWidth.js +13 -35
- package/es/table/transforms/buildTree.js +1 -2
- package/es/table/transforms/columnHover.js +9 -15
- package/es/table/transforms/columnRangeHover.js +12 -19
- package/es/table/transforms/columnResize.js +18 -42
- package/es/table/transforms/flatten.js +0 -3
- package/es/table/transforms/orderField.js +0 -3
- package/es/table/transforms/sort.js +42 -101
- package/es/table/transforms/tips.js +5 -10
- package/es/table/transforms/treeMode.js +36 -77
- package/es/table/transforms/visible.js +0 -2
- package/es/table/use/useResizeObserver.js +1 -4
- package/es/table/utils/applyTransforms.js +0 -1
- package/es/table/utils/browserType.js +12 -19
- package/es/table/utils/buildTree.js +7 -22
- package/es/table/utils/collectNodes.js +4 -13
- package/es/table/utils/console.js +0 -14
- package/es/table/utils/copyToClipboard.js +0 -4
- package/es/table/utils/element.js +14 -41
- package/es/table/utils/exportTableAsExcel.js +7 -43
- package/es/table/utils/getTreeDepth.js +4 -12
- package/es/table/utils/groupBy.js +4 -13
- package/es/table/utils/layeredFilter.js +0 -4
- package/es/table/utils/layeredSort.js +0 -5
- package/es/table/utils/makeRecursiveMapper.js +4 -15
- package/es/table/utils/mergeCellProps.js +6 -14
- package/es/table/utils/others.js +6 -19
- package/es/table/utils/proto.js +2 -30
- package/es/table/utils/smartCompare.js +4 -12
- package/es/table/utils/traverseColumn.js +5 -18
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +8 -30
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +19 -74
- package/es/table/utils/uiDegrade.js +0 -5
- package/lib/_utils/arrayUtil.js +2 -8
- package/lib/_utils/devwarning.js +0 -5
- package/lib/_utils/formatUtil.js +36 -105
- package/lib/_utils/hooks.js +21 -56
- package/lib/_utils/index.js +2 -9
- package/lib/_utils/numberUtil.js +32 -63
- package/lib/_utils/omit.js +0 -5
- package/lib/_utils/react-children.js +0 -5
- package/lib/_utils/type.js +3 -11
- package/lib/_utils/usePopper.js +86 -173
- package/lib/config-provider/ConfigContext.js +2 -6
- package/lib/config-provider/compDefaultProps.js +1 -3
- package/lib/config-provider/configProvider.js +6 -22
- package/lib/config-provider/defaultConfig.js +1 -7
- package/lib/config-provider/index.js +1 -8
- package/lib/index.js +2 -8
- package/lib/locale/index.js +3 -11
- package/lib/locale/locale.js +15 -71
- package/lib/locale/zh-CN.js +1 -2
- package/lib/style/color/colors.less +1 -1
- package/lib/style/components.less +1 -1
- package/lib/style/core/index.less +1 -1
- package/lib/style/core/motion/other.less +27 -27
- package/lib/style/core/motion/slide.less +53 -53
- package/lib/style/core/motion.less +1 -1
- package/lib/style/core/reset.less +185 -185
- package/lib/style/index.less +1 -1
- package/lib/style/mixins/index.less +18 -18
- package/lib/style/mixins/overlay.less +21 -21
- package/lib/style/mixins/reset.less +12 -12
- package/lib/style/themes/default.less +445 -445
- package/lib/table/base/calculations.js +25 -86
- package/lib/table/base/colgroup.js +0 -5
- package/lib/table/base/empty.js +8 -20
- package/lib/table/base/globalStyleComponent.d.ts +4 -0
- package/lib/table/base/globalStyleComponent.js +35 -0
- package/lib/table/base/header.js +21 -86
- package/lib/table/base/helpers/SpanManager.js +6 -16
- package/lib/table/base/helpers/TableDOMUtils.js +9 -37
- package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
- package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
- package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +15 -65
- package/lib/table/base/helpers/rowHeightManager.js +0 -33
- package/lib/table/base/html-table.js +17 -49
- package/lib/table/base/index.js +0 -2
- package/lib/table/base/loading.js +8 -14
- package/lib/table/base/renderTemplates.js +45 -76
- package/lib/table/base/styles.d.ts +10 -0
- package/lib/table/base/styles.js +24 -42
- package/lib/table/base/table.js +125 -245
- package/lib/table/base/utils.js +27 -109
- package/lib/table/common-views.js +4 -24
- package/lib/table/index.js +0 -13
- package/lib/table/interfaces.d.ts +38 -0
- package/lib/table/internals.js +2 -17
- package/lib/table/pipeline/const.d.ts +3 -0
- package/lib/table/pipeline/const.js +9 -0
- package/lib/table/pipeline/features/autoFill.js +14 -53
- package/lib/table/pipeline/features/autoRowSpan.js +1 -19
- package/lib/table/pipeline/features/buildTree.js +0 -2
- package/lib/table/pipeline/features/colGroupExtendable.js +6 -35
- package/lib/table/pipeline/features/columnDrag.js +41 -103
- package/lib/table/pipeline/features/columnFilter.js +12 -65
- package/lib/table/pipeline/features/columnHover.js +1 -11
- package/lib/table/pipeline/features/columnRangeHover.js +1 -13
- package/lib/table/pipeline/features/columnResizeWidth.js +18 -63
- package/lib/table/pipeline/features/contextMenu.js +24 -121
- package/lib/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
- package/lib/table/pipeline/features/featureApi/RowDragApi.js +72 -0
- package/lib/table/pipeline/features/featureApi/utils.d.ts +2 -0
- package/lib/table/pipeline/features/featureApi/utils.js +17 -0
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +17 -52
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
- package/lib/table/pipeline/features/filter/Filter.js +30 -77
- package/lib/table/pipeline/features/filter/FilterPanel.js +14 -44
- package/lib/table/pipeline/features/filter/index.js +0 -5
- package/lib/table/pipeline/features/filter/util.js +2 -10
- package/lib/table/pipeline/features/footerDataSource.js +1 -12
- package/lib/table/pipeline/features/index.js +0 -23
- package/lib/table/pipeline/features/mergeCellHover.js +0 -5
- package/lib/table/pipeline/features/multiSelect.js +15 -71
- package/lib/table/pipeline/features/rangeSelection.js +75 -173
- package/lib/table/pipeline/features/rowDetail.js +4 -67
- package/lib/table/pipeline/features/rowDrag.d.ts +10 -12
- package/lib/table/pipeline/features/rowDrag.js +494 -252
- package/lib/table/pipeline/features/rowGrouping.js +4 -57
- package/lib/table/pipeline/features/singleSelect.js +0 -34
- package/lib/table/pipeline/features/sort.js +37 -115
- package/lib/table/pipeline/features/tips.js +4 -19
- package/lib/table/pipeline/features/treeMode.d.ts +1 -0
- package/lib/table/pipeline/features/treeMode.js +40 -80
- package/lib/table/pipeline/features/treeSelect.js +2 -36
- package/lib/table/pipeline/index.js +2 -10
- package/lib/table/pipeline/pipeline.d.ts +3 -0
- package/lib/table/pipeline/pipeline.js +36 -65
- package/lib/table/pivot/cross-table/buildCrossTable.js +21 -83
- package/lib/table/pivot/cross-table/constants.js +1 -2
- package/lib/table/pivot/cross-table/cross-table.js +25 -42
- package/lib/table/pivot/cross-table/index.js +0 -4
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -70
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +37 -73
- package/lib/table/pivot/cross-tree-table/index.js +0 -3
- package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
- package/lib/table/pivot/pivot-utils/builders.js +34 -85
- package/lib/table/pivot/pivot-utils/convert-utils.js +16 -60
- package/lib/table/pivot/pivot-utils/index.js +0 -7
- package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
- package/lib/table/style/css.js +0 -1
- package/lib/table/style/index.js +0 -1
- package/lib/table/style/index.less +1 -1
- package/lib/table/transforms/autoRowSpan.js +1 -21
- package/lib/table/transforms/autoWidth.js +15 -58
- package/lib/table/transforms/buildTree.js +1 -4
- package/lib/table/transforms/columnHover.js +9 -22
- package/lib/table/transforms/columnRangeHover.js +12 -27
- package/lib/table/transforms/columnResize.js +20 -63
- package/lib/table/transforms/flatten.js +0 -5
- package/lib/table/transforms/index.js +0 -12
- package/lib/table/transforms/orderField.js +0 -7
- package/lib/table/transforms/sort.js +44 -127
- package/lib/table/transforms/tips.js +5 -20
- package/lib/table/transforms/treeMode.js +38 -106
- package/lib/table/transforms/visible.js +0 -7
- package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
- package/lib/table/use/useResizeObserver.js +2 -10
- package/lib/table/utils/applyTransforms.js +0 -2
- package/lib/table/utils/browserType.js +14 -23
- package/lib/table/utils/buildTree.js +7 -33
- package/lib/table/utils/collectNodes.js +4 -18
- package/lib/table/utils/console.js +2 -19
- package/lib/table/utils/copyToClipboard.js +1 -8
- package/lib/table/utils/element.js +14 -46
- package/lib/table/utils/exportTableAsExcel.js +7 -52
- package/lib/table/utils/getTreeDepth.js +4 -17
- package/lib/table/utils/groupBy.js +4 -17
- package/lib/table/utils/index.js +0 -22
- package/lib/table/utils/isGroupColumn.js +0 -3
- package/lib/table/utils/isLeafNode.js +0 -1
- package/lib/table/utils/keyCode.js +1 -2
- package/lib/table/utils/layeredFilter.js +0 -10
- package/lib/table/utils/layeredSort.js +0 -10
- package/lib/table/utils/makeRecursiveMapper.js +4 -24
- package/lib/table/utils/mergeCellProps.js +6 -18
- package/lib/table/utils/others.js +7 -36
- package/lib/table/utils/proto.js +3 -35
- package/lib/table/utils/selectColumn.js +2 -5
- package/lib/table/utils/smartCompare.js +4 -13
- package/lib/table/utils/traverseColumn.js +5 -25
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +10 -41
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +21 -90
- package/lib/table/utils/uiDegrade.js +1 -8
- package/package.json +218 -218
package/es/table/base/utils.js
CHANGED
|
@@ -4,13 +4,9 @@ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
|
4
4
|
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
5
5
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
6
6
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
|
|
12
|
-
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; }
|
|
13
|
-
|
|
7
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && _getIteratorMethod(r) || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(r, a) { if (r) { var _context; if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = _sliceInstanceProperty(_context = {}.toString.call(r)).call(_context, 8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
10
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
15
11
|
import _Object$is from "@babel/runtime-corejs3/core-js-stable/object/is";
|
|
16
12
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
@@ -24,7 +20,6 @@ import { isStickyUIDegrade } from '../utils';
|
|
|
24
20
|
import { defaultCSSVariables } from './styles';
|
|
25
21
|
import { hasScroll } from '../utils/element';
|
|
26
22
|
/** styled-components 类库的版本,ali-react-table 同时支持 v3 和 v5 */
|
|
27
|
-
|
|
28
23
|
export var STYLED_VERSION = styledComponents.createGlobalStyle != null ? 'v5' : 'v3';
|
|
29
24
|
export var STYLED_REF_PROP = STYLED_VERSION === 'v3' ? 'innerRef' : 'ref';
|
|
30
25
|
export var OVERSCAN_SIZE = 100;
|
|
@@ -35,8 +30,8 @@ export function sum(arr) {
|
|
|
35
30
|
result += x;
|
|
36
31
|
});
|
|
37
32
|
return result;
|
|
38
|
-
}
|
|
39
|
-
|
|
33
|
+
}
|
|
34
|
+
// 使用 defer 避免过早引用 window,导致在 SSR 场景下报错
|
|
40
35
|
export var throttledWindowResize$ = defer(function () {
|
|
41
36
|
return fromEvent(window, 'resize', {
|
|
42
37
|
passive: true
|
|
@@ -50,23 +45,18 @@ export var addResizeObserver = function addResizeObserver(element, handler) {
|
|
|
50
45
|
if (!entries[0] || !entries[0].contentRect) {
|
|
51
46
|
return;
|
|
52
47
|
}
|
|
53
|
-
|
|
54
48
|
var contentRect = entries[0].contentRect;
|
|
55
49
|
var hide = contentRect.width === 0 && contentRect.height === 0; // 隐藏条件:高宽都为0
|
|
56
|
-
|
|
57
50
|
var rect = _extends({
|
|
58
51
|
hide: hide
|
|
59
52
|
}, contentRect);
|
|
60
|
-
|
|
61
53
|
handler && handler(rect);
|
|
62
54
|
};
|
|
63
|
-
|
|
64
55
|
var resizeObserver = new ResizeObserver(measure);
|
|
65
56
|
resizeObserver && resizeObserver.observe(element);
|
|
66
57
|
return resizeObserver;
|
|
67
58
|
};
|
|
68
59
|
/** 获取默认的滚动条大小 */
|
|
69
|
-
|
|
70
60
|
function getScrollbarSizeImpl() {
|
|
71
61
|
var scrollDiv = document.createElement('div');
|
|
72
62
|
scrollDiv.style.position = 'absolute';
|
|
@@ -83,7 +73,6 @@ function getScrollbarSizeImpl() {
|
|
|
83
73
|
height: scrollbarHeight
|
|
84
74
|
};
|
|
85
75
|
}
|
|
86
|
-
|
|
87
76
|
var scrollBarSize$;
|
|
88
77
|
export function getScrollbarSize() {
|
|
89
78
|
if (scrollBarSize$ == null) {
|
|
@@ -92,28 +81,21 @@ export function getScrollbarSize() {
|
|
|
92
81
|
return getScrollbarSizeImpl();
|
|
93
82
|
})).subscribe(scrollBarSize$);
|
|
94
83
|
}
|
|
95
|
-
|
|
96
84
|
return scrollBarSize$.value;
|
|
97
85
|
}
|
|
98
86
|
/** 同步多个元素之间的 scrollLeft, 每当 scrollLeft 发生变化时 callback 会被调用 */
|
|
99
|
-
|
|
100
87
|
export function syncScrollLeft(elements, callback) {
|
|
101
88
|
var bypassSet = new _Set();
|
|
102
|
-
|
|
103
89
|
function publishScrollLeft(origin, scrollLeft) {
|
|
104
90
|
bypassSet.clear();
|
|
105
|
-
|
|
106
91
|
var _iterator = _createForOfIteratorHelper(elements),
|
|
107
|
-
|
|
108
|
-
|
|
92
|
+
_step;
|
|
109
93
|
try {
|
|
110
94
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
111
95
|
var elem = _step.value;
|
|
112
|
-
|
|
113
96
|
if (elem === origin) {
|
|
114
97
|
continue;
|
|
115
98
|
}
|
|
116
|
-
|
|
117
99
|
elem.scrollLeft = scrollLeft;
|
|
118
100
|
bypassSet.add(elem);
|
|
119
101
|
}
|
|
@@ -123,32 +105,25 @@ export function syncScrollLeft(elements, callback) {
|
|
|
123
105
|
_iterator.f();
|
|
124
106
|
}
|
|
125
107
|
}
|
|
126
|
-
|
|
127
108
|
var subscription = new Subscription();
|
|
128
|
-
|
|
129
109
|
var _iterator2 = _createForOfIteratorHelper(elements),
|
|
130
|
-
|
|
131
|
-
|
|
110
|
+
_step2;
|
|
132
111
|
try {
|
|
133
112
|
var _loop = function _loop() {
|
|
134
113
|
var ele = _step2.value;
|
|
135
|
-
|
|
136
114
|
var listener = function listener() {
|
|
137
115
|
if (bypassSet.has(ele)) {
|
|
138
116
|
bypassSet.delete(ele);
|
|
139
117
|
return;
|
|
140
118
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
119
|
+
var scrollLeft = ele.scrollLeft;
|
|
120
|
+
// 某一元素当滚动条消失时会触发scroll事件(scrolLeft重置为0),不同步其他其他元素的scrollLeft
|
|
144
121
|
if (scrollLeft === 0 && !hasScroll(ele)) {
|
|
145
122
|
return;
|
|
146
123
|
}
|
|
147
|
-
|
|
148
124
|
publishScrollLeft(ele, scrollLeft);
|
|
149
125
|
callback(scrollLeft);
|
|
150
126
|
};
|
|
151
|
-
|
|
152
127
|
ele.addEventListener('scroll', listener, {
|
|
153
128
|
passive: true
|
|
154
129
|
});
|
|
@@ -156,7 +131,6 @@ export function syncScrollLeft(elements, callback) {
|
|
|
156
131
|
return ele.removeEventListener('scroll', listener);
|
|
157
132
|
});
|
|
158
133
|
};
|
|
159
|
-
|
|
160
134
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
161
135
|
_loop();
|
|
162
136
|
}
|
|
@@ -165,7 +139,6 @@ export function syncScrollLeft(elements, callback) {
|
|
|
165
139
|
} finally {
|
|
166
140
|
_iterator2.f();
|
|
167
141
|
}
|
|
168
|
-
|
|
169
142
|
return subscription;
|
|
170
143
|
}
|
|
171
144
|
/**
|
|
@@ -173,45 +146,35 @@ export function syncScrollLeft(elements, callback) {
|
|
|
173
146
|
* when any key has values which are not strictly equal between the arguments.
|
|
174
147
|
* Returns true when the values of all keys are strictly equal.
|
|
175
148
|
*/
|
|
176
|
-
|
|
177
149
|
export function shallowEqual(objA, objB) {
|
|
178
150
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
179
|
-
|
|
180
151
|
if (_Object$is(objA, objB)) {
|
|
181
152
|
return true;
|
|
182
153
|
}
|
|
183
|
-
|
|
184
154
|
if (_typeof(objA) !== 'object' || objA === null || _typeof(objB) !== 'object' || objB === null) {
|
|
185
155
|
return false;
|
|
186
156
|
}
|
|
187
|
-
|
|
188
157
|
var keysA = _Object$keys(objA);
|
|
189
|
-
|
|
190
158
|
var keysB = _Object$keys(objB);
|
|
191
|
-
|
|
192
159
|
if (keysA.length !== keysB.length) {
|
|
193
160
|
return false;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
161
|
+
}
|
|
162
|
+
// Test for A's keys different from B.
|
|
197
163
|
for (var i = 0; i < keysA.length; i++) {
|
|
198
164
|
if (!hasOwnProperty.call(objB, keysA[i]) || !_Object$is(objA[keysA[i]], objB[keysA[i]])) {
|
|
199
165
|
return false;
|
|
200
166
|
}
|
|
201
167
|
}
|
|
202
|
-
|
|
203
168
|
return true;
|
|
204
|
-
}
|
|
205
|
-
|
|
169
|
+
}
|
|
170
|
+
// todo: 抽出mergeRowProps
|
|
206
171
|
export function composeRowPropsGetter(getRowProps, pendingRowProps) {
|
|
207
172
|
var keys = _Object$keys(pendingRowProps);
|
|
208
|
-
|
|
209
173
|
if (keys.length) {
|
|
210
174
|
return function (row, rowIndex) {
|
|
211
175
|
return mergeCellProps(getRowProps(row, rowIndex), pendingRowProps);
|
|
212
176
|
};
|
|
213
177
|
}
|
|
214
|
-
|
|
215
178
|
return getRowProps;
|
|
216
179
|
}
|
|
217
180
|
export function getTableScrollHeaderDOM(domHelper) {
|
|
@@ -222,20 +185,17 @@ export function getTableScrollFooterDOM(domHelper) {
|
|
|
222
185
|
}
|
|
223
186
|
export var cssPolifill = function cssPolifill(_ref) {
|
|
224
187
|
var variables = _ref.variables,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
188
|
+
enableCSSVariables = _ref.enableCSSVariables,
|
|
189
|
+
bordered = _ref.bordered;
|
|
228
190
|
if (enableCSSVariables === false) {
|
|
229
191
|
return;
|
|
230
192
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
193
|
+
var conditionCSSVariables = {};
|
|
194
|
+
// 默认情况下存在td、th无左右边框,开启`bordered`属性后才开启,否则隐藏这两种属性
|
|
234
195
|
if (!bordered) {
|
|
235
196
|
conditionCSSVariables['--cell-border-vertical'] = 'none';
|
|
236
197
|
conditionCSSVariables['--header-cell-border-vertical'] = 'none';
|
|
237
198
|
}
|
|
238
|
-
|
|
239
199
|
cssVars({
|
|
240
200
|
// exclude: 'link[href*="semantic-ui"]',
|
|
241
201
|
// onlyLegacy: false,
|
package/es/table/common-views.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
2
|
import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplateLiteral";
|
|
3
|
-
|
|
4
3
|
var _templateObject, _templateObject2, _templateObject3;
|
|
5
|
-
|
|
6
4
|
import React from 'react';
|
|
7
5
|
import styled from 'styled-components';
|
|
8
6
|
import { MenuClasses, Classes } from './base/styles';
|
|
@@ -10,7 +8,6 @@ export var InlineFlexCell = styled.div(_templateObject || (_templateObject = _ta
|
|
|
10
8
|
export var ExpansionCell = styled(function (props) {
|
|
11
9
|
return /*#__PURE__*/React.createElement(InlineFlexCell, _extends({}, props));
|
|
12
10
|
})(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\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"])), Classes.leaf, Classes.expanded);
|
|
13
|
-
|
|
14
11
|
function CaretDownIcon(props) {
|
|
15
12
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
16
13
|
focusable: "false",
|
|
@@ -23,7 +20,6 @@ function CaretDownIcon(props) {
|
|
|
23
20
|
d: "M24 12L16 22 8 12z"
|
|
24
21
|
}));
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
function InfoIcon(props) {
|
|
28
24
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
29
25
|
focusable: "false",
|
|
@@ -38,7 +34,6 @@ function InfoIcon(props) {
|
|
|
38
34
|
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"
|
|
39
35
|
}));
|
|
40
36
|
}
|
|
41
|
-
|
|
42
37
|
function CaretRightIcon(props) {
|
|
43
38
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
44
39
|
focusable: "false",
|
|
@@ -51,7 +46,6 @@ function CaretRightIcon(props) {
|
|
|
51
46
|
d: "M12 8L22 16 12 24z"
|
|
52
47
|
}));
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
function LoadingIcon(props) {
|
|
56
50
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
57
51
|
width: "16",
|
|
@@ -62,7 +56,6 @@ function LoadingIcon(props) {
|
|
|
62
56
|
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"
|
|
63
57
|
}));
|
|
64
58
|
}
|
|
65
|
-
|
|
66
59
|
export var icons = {
|
|
67
60
|
Loading: LoadingIcon,
|
|
68
61
|
CaretDown: CaretDownIcon,
|
package/es/table/interfaces.d.ts
CHANGED
|
@@ -101,3 +101,41 @@ export interface CustomeFilterPanelProps extends FilterPanelProps {
|
|
|
101
101
|
filterModel: FilterItem;
|
|
102
102
|
}
|
|
103
103
|
export declare type FilterPanel = React.ComponentType<DefaultFilterPanelProps | CustomeFilterPanelProps>;
|
|
104
|
+
export interface RowDragEvent {
|
|
105
|
+
startRowIndex: number;
|
|
106
|
+
startRow: any;
|
|
107
|
+
endRowIndex: number;
|
|
108
|
+
endRow: any;
|
|
109
|
+
isFinished: boolean;
|
|
110
|
+
dragPosition: string;
|
|
111
|
+
startDropZoneTagret: Element;
|
|
112
|
+
dropZoneTarget: Element;
|
|
113
|
+
event: MouseEvent;
|
|
114
|
+
source: string;
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
}
|
|
118
|
+
export interface DragEvent {
|
|
119
|
+
dragItem: any;
|
|
120
|
+
startDropZoneTagret: Element;
|
|
121
|
+
dropZoneTarget: Element;
|
|
122
|
+
dropZoneTableParams?: RowDropZoneTableParams;
|
|
123
|
+
event: MouseEvent;
|
|
124
|
+
x: number;
|
|
125
|
+
y: number;
|
|
126
|
+
}
|
|
127
|
+
export interface RowDropZoneParams {
|
|
128
|
+
getContainer: () => HTMLElement;
|
|
129
|
+
onDragEnter?: (params: DragEvent) => void;
|
|
130
|
+
onDragLeave?: (params: DragEvent) => void;
|
|
131
|
+
onDragging?: (params: DragEvent) => void;
|
|
132
|
+
onDragStop?: (params: DragEvent, source?: string) => void;
|
|
133
|
+
isTable?: boolean;
|
|
134
|
+
tableParams?: RowDropZoneTableParams;
|
|
135
|
+
}
|
|
136
|
+
interface RowDropZoneTableParams {
|
|
137
|
+
getDataSource: () => any[];
|
|
138
|
+
getTreeModeOptions: () => any;
|
|
139
|
+
getRowDragOptions: () => any;
|
|
140
|
+
}
|
|
141
|
+
export {};
|
package/es/table/internals.js
CHANGED
|
@@ -1,52 +1,39 @@
|
|
|
1
1
|
function safeRenderHeader(column) {
|
|
2
2
|
var _a;
|
|
3
|
-
|
|
4
3
|
return (_a = column.title) !== null && _a !== void 0 ? _a : column.name;
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
function safeGetValue(column, record, rowIndex) {
|
|
8
6
|
if (column.getValue) {
|
|
9
7
|
return column.getValue(record, rowIndex);
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
return record[column.code];
|
|
13
10
|
}
|
|
14
|
-
|
|
15
11
|
function safeGetRowKey(primaryKey, record, rowIndex) {
|
|
16
12
|
var key;
|
|
17
|
-
|
|
18
13
|
if (typeof primaryKey === 'string') {
|
|
19
14
|
key = record[primaryKey];
|
|
20
15
|
} else if (typeof primaryKey === 'function') {
|
|
21
16
|
key = primaryKey(record);
|
|
22
17
|
}
|
|
23
|
-
|
|
24
18
|
if (key == null) {
|
|
25
19
|
key = String(rowIndex);
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
return key;
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
function safeGetCellProps(column, record, rowIndex) {
|
|
32
24
|
if (column.getCellProps) {
|
|
33
25
|
var value = safeGetValue(column, record, rowIndex);
|
|
34
26
|
return column.getCellProps(value, record, rowIndex) || {};
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
return {};
|
|
38
29
|
}
|
|
39
|
-
|
|
40
30
|
function safeRender(column, record, rowIndex) {
|
|
41
31
|
var value = safeGetValue(column, record, rowIndex);
|
|
42
|
-
|
|
43
32
|
if (column.render) {
|
|
44
33
|
return column.render(value, record, rowIndex);
|
|
45
34
|
}
|
|
46
|
-
|
|
47
35
|
return value;
|
|
48
36
|
}
|
|
49
|
-
|
|
50
37
|
export var internals = {
|
|
51
38
|
safeRenderHeader: safeRenderHeader,
|
|
52
39
|
safeGetValue: safeGetValue,
|
|
@@ -11,18 +11,14 @@ import { Classes } from '../../base/styles';
|
|
|
11
11
|
import { COLUMN_SIZE_KEY, LAST_RESIZED_COLUMN_KEY, RESIZED_COLUMN_KEY } from './columnResizeWidth';
|
|
12
12
|
export var FILL_COLUMN_CODE = '$_fill_column_&';
|
|
13
13
|
export var tableWidthKey = 'tableWidth';
|
|
14
|
-
|
|
15
14
|
var FLEX_COLUMN_COUNT = _Symbol('flexCount');
|
|
16
|
-
|
|
17
15
|
export var autoFillTableWidth = function autoFillTableWidth() {
|
|
18
16
|
return function (pipeline) {
|
|
19
17
|
var flexColumnResult = findFlexColumns(pipeline);
|
|
20
18
|
var flexCount = flexColumnResult.get(FLEX_COLUMN_COUNT);
|
|
21
|
-
|
|
22
19
|
if (flexCount) {
|
|
23
20
|
// 设置了flex宽度,flex列平分剩余宽度
|
|
24
21
|
var remainingWidth = getTableRemainingWidth(pipeline) || 0;
|
|
25
|
-
|
|
26
22
|
if (remainingWidth > 0) {
|
|
27
23
|
// 保存剩余的flex总和和剩余宽度总和宽度
|
|
28
24
|
var residualFlexCount = flexCount;
|
|
@@ -31,28 +27,25 @@ export var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
31
27
|
var enableColumnResizeWidthFeature = !!columnSize;
|
|
32
28
|
pipeline.mapColumns(makeRecursiveMapper(function (col, recursiveFlatMapInfo) {
|
|
33
29
|
var isLeaf = recursiveFlatMapInfo.isLeaf;
|
|
34
|
-
|
|
35
30
|
if (isLeaf && isValidFlexColumn(col, pipeline)) {
|
|
36
31
|
var code = col.code,
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
_col$features = col.features,
|
|
33
|
+
features = _col$features === void 0 ? {} : _col$features;
|
|
39
34
|
var flex = features.flex,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
_features$minWidth = features.minWidth,
|
|
36
|
+
minWidth = _features$minWidth === void 0 ? 0 : _features$minWidth,
|
|
37
|
+
_features$maxWidth = features.maxWidth,
|
|
38
|
+
maxWidth = _features$maxWidth === void 0 ? _Number$MAX_SAFE_INTEGER : _features$maxWidth;
|
|
44
39
|
var usedRemainingWidth = Math.floor(remainingWidth * flex / flexCount);
|
|
45
|
-
var preColWidth = col.width;
|
|
46
|
-
|
|
40
|
+
var preColWidth = col.width;
|
|
41
|
+
// 如果当前已经是最后一个flex列,将剩余的宽度添加到该列,其他计算相应的列
|
|
47
42
|
col.width = clamp(minWidth, preColWidth + (residualFlexCount === flex ? residualFlexWidth : usedRemainingWidth), maxWidth);
|
|
48
43
|
residualFlexCount -= flex;
|
|
49
44
|
residualFlexWidth -= col.width - preColWidth;
|
|
50
|
-
|
|
51
45
|
if (enableColumnResizeWidthFeature) {
|
|
52
46
|
columnSize[code] = col.width;
|
|
53
47
|
}
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
return col;
|
|
57
50
|
}));
|
|
58
51
|
enableColumnResizeWidthFeature && pipeline.setFeatureOptions(COLUMN_SIZE_KEY, columnSize);
|
|
@@ -60,13 +53,10 @@ export var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
60
53
|
} else {
|
|
61
54
|
// 未设置了flex宽度,创建占位列
|
|
62
55
|
var columns = pipeline.getColumns();
|
|
63
|
-
|
|
64
56
|
var fillColumns = _findInstanceProperty(columns).call(columns, function (col) {
|
|
65
57
|
return col.code === FILL_COLUMN_CODE;
|
|
66
58
|
});
|
|
67
|
-
|
|
68
59
|
var width = getTableRemainingWidth(pipeline) || 0;
|
|
69
|
-
|
|
70
60
|
if (fillColumns) {
|
|
71
61
|
fillColumns.width = width;
|
|
72
62
|
} else {
|
|
@@ -85,20 +75,15 @@ export var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
85
75
|
};
|
|
86
76
|
}
|
|
87
77
|
};
|
|
88
|
-
|
|
89
78
|
_spliceInstanceProperty(columns).call(columns, spliceIndex || columns.length, 0, _fillColumns);
|
|
90
79
|
}
|
|
91
|
-
|
|
92
80
|
pipeline.columns(columns);
|
|
93
81
|
}
|
|
94
|
-
|
|
95
82
|
return pipeline;
|
|
96
|
-
|
|
97
83
|
function findFlexColumns(pipeline) {
|
|
98
84
|
var result = new _Map([[FLEX_COLUMN_COUNT, 0]]);
|
|
99
85
|
dfs(pipeline.getColumns(), result);
|
|
100
86
|
return result;
|
|
101
|
-
|
|
102
87
|
function dfs(columns, result) {
|
|
103
88
|
columns.forEach(function (col) {
|
|
104
89
|
if (isLeafNode(col)) {
|
|
@@ -113,15 +98,12 @@ export var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
113
98
|
}
|
|
114
99
|
};
|
|
115
100
|
};
|
|
116
|
-
|
|
117
101
|
function getColumnWidthSum(pipeline) {
|
|
118
102
|
return dfs(pipeline.getColumns());
|
|
119
|
-
|
|
120
103
|
function dfs(columns) {
|
|
121
104
|
return columns.reduce(function (acc, col) {
|
|
122
105
|
var width = col.width,
|
|
123
|
-
|
|
124
|
-
|
|
106
|
+
code = col.code;
|
|
125
107
|
if (isLeafNode(col) && code !== FILL_COLUMN_CODE) {
|
|
126
108
|
var resizeColumn = pipeline.getFeatureOptions(COLUMN_SIZE_KEY);
|
|
127
109
|
return acc + (resizeColumn && resizeColumn[code] || width);
|
|
@@ -131,46 +113,35 @@ function getColumnWidthSum(pipeline) {
|
|
|
131
113
|
}, 0);
|
|
132
114
|
}
|
|
133
115
|
}
|
|
134
|
-
|
|
135
116
|
function getTableRemainingWidth(pipeline) {
|
|
136
117
|
var _a, _b;
|
|
137
|
-
|
|
138
118
|
var tableWidth = ((_b = (_a = pipeline.ref.current.domHelper) === null || _a === void 0 ? void 0 : _a.tableBody) === null || _b === void 0 ? void 0 : _b.clientWidth) || pipeline.getStateAtKey(tableWidthKey);
|
|
139
119
|
if (!tableWidth) return;
|
|
140
120
|
var remainingWidth = Math.floor(tableWidth - getColumnWidthSum(pipeline));
|
|
141
121
|
return remainingWidth > 0 ? remainingWidth : 0;
|
|
142
122
|
}
|
|
143
|
-
|
|
144
123
|
function isAfterLastResizeCol(column, pipeline) {
|
|
145
124
|
var _context, _context2;
|
|
146
|
-
|
|
147
125
|
var lastResizedColumnCode = pipeline.getFeatureOptions(LAST_RESIZED_COLUMN_KEY);
|
|
148
126
|
if (lastResizedColumnCode === undefined) return true;
|
|
149
|
-
|
|
150
127
|
var lastResizedColumnIndex = _findIndexInstanceProperty(_context = pipeline.getColumns()).call(_context, function (col) {
|
|
151
128
|
return col.code === lastResizedColumnCode;
|
|
152
129
|
});
|
|
153
|
-
|
|
154
130
|
var colIndex = _findIndexInstanceProperty(_context2 = pipeline.getColumns()).call(_context2, function (col) {
|
|
155
131
|
return col.code === column.code;
|
|
156
132
|
});
|
|
157
|
-
|
|
158
133
|
return colIndex > lastResizedColumnIndex;
|
|
159
134
|
}
|
|
160
|
-
|
|
161
135
|
function isValidFlexColumn(col, pipeline) {
|
|
162
136
|
var _a;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
137
|
+
var resizeColumn = pipeline.getFeatureOptions(RESIZED_COLUMN_KEY);
|
|
138
|
+
// 拖拽列自动禁止flex
|
|
166
139
|
if (resizeColumn === null || resizeColumn === void 0 ? void 0 : resizeColumn.has(col.code)) {
|
|
167
140
|
return false;
|
|
168
141
|
}
|
|
169
|
-
|
|
170
142
|
var flex = (_a = col.features) === null || _a === void 0 ? void 0 : _a.flex;
|
|
171
143
|
return typeof flex === 'number' && flex > 0 && isAfterLastResizeCol(col, pipeline);
|
|
172
144
|
}
|
|
173
|
-
|
|
174
145
|
function clamp(min, x, max) {
|
|
175
146
|
return Math.max(min, Math.min(max, x));
|
|
176
147
|
}
|
|
@@ -1,39 +1,31 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
2
|
import { internals } from '../../internals';
|
|
3
3
|
import { isLeafNode, makeRecursiveMapper } from '../../utils';
|
|
4
|
-
|
|
5
4
|
function isIdentity(x, y) {
|
|
6
5
|
return x === y;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
export function autoRowSpan() {
|
|
10
8
|
return function autoRowSpanStep(pipeline) {
|
|
11
9
|
var dataSource = pipeline.getDataSource();
|
|
12
10
|
return pipeline.mapColumns(makeRecursiveMapper(function (col, _ref) {
|
|
13
11
|
var startIndex = _ref.startIndex,
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
endIndex = _ref.endIndex;
|
|
16
13
|
var _a;
|
|
17
|
-
|
|
18
14
|
if (!((_a = col.features) === null || _a === void 0 ? void 0 : _a.autoRowSpan)) {
|
|
19
15
|
return col;
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
if (!isLeafNode(col)) {
|
|
23
18
|
return col;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
var isFunc = typeof col.features.autoRowSpan === 'function';
|
|
27
21
|
var shouldMergeCell = isFunc ? col.features.autoRowSpan : isIdentity;
|
|
28
22
|
var spanRects = [];
|
|
29
23
|
var lastBottom = 0;
|
|
30
24
|
var prevValue = null;
|
|
31
25
|
var prevRow = null;
|
|
32
|
-
|
|
33
26
|
for (var rowIndex = 0; rowIndex < dataSource.length; rowIndex++) {
|
|
34
27
|
var row = dataSource[rowIndex];
|
|
35
28
|
var value = internals.safeGetValue(col, row, rowIndex);
|
|
36
|
-
|
|
37
29
|
if (rowIndex === 0 || !shouldMergeCell(prevValue, value, prevRow, row)) {
|
|
38
30
|
var spanRect = {
|
|
39
31
|
top: lastBottom,
|
|
@@ -41,18 +33,14 @@ export function autoRowSpan() {
|
|
|
41
33
|
left: startIndex,
|
|
42
34
|
right: endIndex
|
|
43
35
|
};
|
|
44
|
-
|
|
45
36
|
for (var i = lastBottom; i < rowIndex; i++) {
|
|
46
37
|
spanRects.push(spanRect);
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
lastBottom = rowIndex;
|
|
50
40
|
}
|
|
51
|
-
|
|
52
41
|
prevValue = value;
|
|
53
42
|
prevRow = row;
|
|
54
43
|
}
|
|
55
|
-
|
|
56
44
|
for (var _i = lastBottom; _i < dataSource.length; _i++) {
|
|
57
45
|
spanRects.push({
|
|
58
46
|
top: lastBottom,
|
|
@@ -61,7 +49,6 @@ export function autoRowSpan() {
|
|
|
61
49
|
right: endIndex
|
|
62
50
|
});
|
|
63
51
|
}
|
|
64
|
-
|
|
65
52
|
return _extends(_extends({}, col), {
|
|
66
53
|
getSpanRect: function getSpanRect(value, row, rowIndex) {
|
|
67
54
|
return spanRects[rowIndex];
|