@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/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
7
|
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; } } }; }
|
|
9
|
-
|
|
10
8
|
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
9
|
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
|
-
|
|
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 { browserType } 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/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;
|
|
@@ -30,25 +26,23 @@ export var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
30
26
|
var columnSize = pipeline.getFeatureOptions(COLUMN_SIZE_KEY) || {};
|
|
31
27
|
pipeline.mapColumns(makeRecursiveMapper(function (col, recursiveFlatMapInfo) {
|
|
32
28
|
var isLeaf = recursiveFlatMapInfo.isLeaf;
|
|
33
|
-
|
|
34
29
|
if (isLeaf && isValidFlexColumn(col, pipeline)) {
|
|
35
30
|
var code = col.code,
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
_col$features = col.features,
|
|
32
|
+
features = _col$features === void 0 ? {} : _col$features;
|
|
38
33
|
var flex = features.flex,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
_features$minWidth = features.minWidth,
|
|
35
|
+
minWidth = _features$minWidth === void 0 ? 0 : _features$minWidth,
|
|
36
|
+
_features$maxWidth = features.maxWidth,
|
|
37
|
+
maxWidth = _features$maxWidth === void 0 ? _Number$MAX_SAFE_INTEGER : _features$maxWidth;
|
|
43
38
|
var usedRemainingWidth = Math.floor(remainingWidth * flex / flexCount);
|
|
44
|
-
var preColWidth = col.width;
|
|
45
|
-
|
|
39
|
+
var preColWidth = col.width;
|
|
40
|
+
// 如果当前已经是最后一个flex列,将剩余的宽度添加到该列,其他计算相应的列
|
|
46
41
|
col.width = clamp(minWidth, preColWidth + (residualFlexCount === flex ? residualFlexWidth : usedRemainingWidth), maxWidth);
|
|
47
42
|
residualFlexCount -= flex;
|
|
48
43
|
residualFlexWidth -= col.width - preColWidth;
|
|
49
44
|
columnSize[code] = col.width;
|
|
50
45
|
}
|
|
51
|
-
|
|
52
46
|
return col;
|
|
53
47
|
}));
|
|
54
48
|
pipeline.setFeatureOptions(COLUMN_SIZE_KEY, columnSize);
|
|
@@ -56,13 +50,10 @@ export var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
56
50
|
} else {
|
|
57
51
|
// 未设置了flex宽度,创建占位列
|
|
58
52
|
var columns = pipeline.getColumns();
|
|
59
|
-
|
|
60
53
|
var fillColumns = _findInstanceProperty(columns).call(columns, function (col) {
|
|
61
54
|
return col.code === FILL_COLUMN_CODE;
|
|
62
55
|
});
|
|
63
|
-
|
|
64
56
|
var width = getTableRemainingWidth(pipeline) || 0;
|
|
65
|
-
|
|
66
57
|
if (fillColumns) {
|
|
67
58
|
fillColumns.width = width;
|
|
68
59
|
} else {
|
|
@@ -81,20 +72,15 @@ export var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
81
72
|
};
|
|
82
73
|
}
|
|
83
74
|
};
|
|
84
|
-
|
|
85
75
|
_spliceInstanceProperty(columns).call(columns, spliceIndex || columns.length, 0, _fillColumns);
|
|
86
76
|
}
|
|
87
|
-
|
|
88
77
|
pipeline.columns(columns);
|
|
89
78
|
}
|
|
90
|
-
|
|
91
79
|
return pipeline;
|
|
92
|
-
|
|
93
80
|
function findFlexColumns(pipeline) {
|
|
94
81
|
var result = new _Map([[FLEX_COLUMN_COUNT, 0]]);
|
|
95
82
|
dfs(pipeline.getColumns(), result);
|
|
96
83
|
return result;
|
|
97
|
-
|
|
98
84
|
function dfs(columns, result) {
|
|
99
85
|
columns.forEach(function (col) {
|
|
100
86
|
if (isLeafNode(col)) {
|
|
@@ -109,15 +95,12 @@ export var autoFillTableWidth = function autoFillTableWidth() {
|
|
|
109
95
|
}
|
|
110
96
|
};
|
|
111
97
|
};
|
|
112
|
-
|
|
113
98
|
function getColumnWidthSum(pipeline) {
|
|
114
99
|
return dfs(pipeline.getColumns());
|
|
115
|
-
|
|
116
100
|
function dfs(columns) {
|
|
117
101
|
return columns.reduce(function (acc, col) {
|
|
118
102
|
var width = col.width,
|
|
119
|
-
|
|
120
|
-
|
|
103
|
+
code = col.code;
|
|
121
104
|
if (isLeafNode(col) && code !== FILL_COLUMN_CODE) {
|
|
122
105
|
var resizeColumn = pipeline.getFeatureOptions(COLUMN_SIZE_KEY);
|
|
123
106
|
return acc + (resizeColumn && resizeColumn[code] || width);
|
|
@@ -127,44 +110,34 @@ function getColumnWidthSum(pipeline) {
|
|
|
127
110
|
}, 0);
|
|
128
111
|
}
|
|
129
112
|
}
|
|
130
|
-
|
|
131
113
|
function getTableRemainingWidth(pipeline) {
|
|
132
114
|
var tableWidth = pipeline.getStateAtKey(tableWidthKey);
|
|
133
115
|
if (!tableWidth) return;
|
|
134
116
|
var remainingWidth = Math.floor(tableWidth - getColumnWidthSum(pipeline));
|
|
135
117
|
return remainingWidth > 0 ? remainingWidth : 0;
|
|
136
118
|
}
|
|
137
|
-
|
|
138
119
|
function isAfterLastResizeCol(column, pipeline) {
|
|
139
120
|
var _context, _context2;
|
|
140
|
-
|
|
141
121
|
var lastResizedColumnCode = pipeline.getFeatureOptions(LAST_RESIZED_COLUMN_KEY);
|
|
142
122
|
if (lastResizedColumnCode === undefined) return true;
|
|
143
|
-
|
|
144
123
|
var lastResizedColumnIndex = _findIndexInstanceProperty(_context = pipeline.getColumns()).call(_context, function (col) {
|
|
145
124
|
return col.code === lastResizedColumnCode;
|
|
146
125
|
});
|
|
147
|
-
|
|
148
126
|
var colIndex = _findIndexInstanceProperty(_context2 = pipeline.getColumns()).call(_context2, function (col) {
|
|
149
127
|
return col.code === column.code;
|
|
150
128
|
});
|
|
151
|
-
|
|
152
129
|
return colIndex > lastResizedColumnIndex;
|
|
153
130
|
}
|
|
154
|
-
|
|
155
131
|
function isValidFlexColumn(col, pipeline) {
|
|
156
132
|
var _a;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
133
|
+
var resizeColumn = pipeline.getFeatureOptions(RESIZED_COLUMN_KEY);
|
|
134
|
+
// 拖拽列自动禁止flex
|
|
160
135
|
if (resizeColumn === null || resizeColumn === void 0 ? void 0 : resizeColumn.has(col.code)) {
|
|
161
136
|
return false;
|
|
162
137
|
}
|
|
163
|
-
|
|
164
138
|
var flex = (_a = col.features) === null || _a === void 0 ? void 0 : _a.flex;
|
|
165
139
|
return typeof flex === 'number' && flex > 0 && isAfterLastResizeCol(col, pipeline);
|
|
166
140
|
}
|
|
167
|
-
|
|
168
141
|
function clamp(min, x, max) {
|
|
169
142
|
return Math.max(min, Math.min(max, x));
|
|
170
143
|
}
|
|
@@ -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];
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
3
3
|
import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplateLiteral";
|
|
4
|
-
|
|
5
4
|
var _templateObject;
|
|
6
|
-
|
|
7
5
|
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
|
|
8
6
|
import React from 'react';
|
|
9
7
|
import styled from 'styled-components';
|
|
@@ -13,12 +11,11 @@ import cx from 'classnames';
|
|
|
13
11
|
import { Classes } from '../../base/styles';
|
|
14
12
|
var ExtendIconStyle = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size:12px;\n margin-left:4px;\n"])));
|
|
15
13
|
var stateKey = 'colExtend';
|
|
16
|
-
|
|
17
14
|
var ExpandIcon = function ExpandIcon(_ref) {
|
|
18
15
|
var style = _ref.style,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
className = _ref.className,
|
|
17
|
+
size = _ref.size,
|
|
18
|
+
isExtend = _ref.isExtend;
|
|
22
19
|
return isExtend ? /*#__PURE__*/React.createElement("svg", {
|
|
23
20
|
className: className,
|
|
24
21
|
width: size,
|
|
@@ -37,29 +34,23 @@ var ExpandIcon = function ExpandIcon(_ref) {
|
|
|
37
34
|
d: "M321.652913 178.347087C309.449029 166.143203 309.449029 146.356797 321.652913 134.152913C333.856797 121.949029 353.643203 121.949029 365.847088 134.152913L709.597087 477.902913C721.800972 490.106797 721.800972 509.893203 709.597087 522.097087L365.847088 865.847087C353.643203 878.050972 333.856797 878.050972 321.652913 865.847087C309.449029 853.643203 309.449029 833.856797 321.652913 821.652913L643.305825 500L321.652913 178.347087z"
|
|
38
35
|
}));
|
|
39
36
|
};
|
|
40
|
-
|
|
41
37
|
export var colGroupExtendable = function colGroupExtendable() {
|
|
42
38
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
43
39
|
return function (pipeline) {
|
|
44
40
|
var _a, _b;
|
|
45
|
-
|
|
46
41
|
var columns = pipeline.getColumns();
|
|
47
42
|
var curState = (_b = (_a = opts.extendStatus) !== null && _a !== void 0 ? _a : pipeline.getStateAtKey(stateKey)) !== null && _b !== void 0 ? _b : {};
|
|
48
|
-
|
|
49
43
|
var processColumns = function processColumns(columns) {
|
|
50
44
|
// 当组合列可伸缩,且处于收缩状态时,只渲染一个子列,其他不渲染
|
|
51
45
|
var toggle = function toggle(col) {
|
|
52
46
|
// 对应的 col 进行状态切换
|
|
53
47
|
var changedValue = _defineProperty({}, col.code, !curState[col.code]);
|
|
54
|
-
|
|
55
48
|
curState[col.code] = !curState[col.code];
|
|
56
49
|
pipeline.setStateAtKey(stateKey, _extends({}, curState));
|
|
57
50
|
(opts === null || opts === void 0 ? void 0 : opts.onChangeExtendStatus) && opts.onChangeExtendStatus(curState, changedValue);
|
|
58
51
|
};
|
|
59
|
-
|
|
60
52
|
var addIcon = function addIcon(col) {
|
|
61
53
|
var result = _extends({}, col);
|
|
62
|
-
|
|
63
54
|
var curColState = curState[col.code];
|
|
64
55
|
var displaycolExtendIcon = typeof opts.extendIcon === 'function' ? opts.extendIcon(curColState) : opts.extendIcon;
|
|
65
56
|
var addIconNode = /*#__PURE__*/React.createElement(React.Fragment, null, internals.safeRenderHeader(_extends({}, col)), /*#__PURE__*/React.createElement(ExtendIconStyle, {
|
|
@@ -81,24 +72,18 @@ export var colGroupExtendable = function colGroupExtendable() {
|
|
|
81
72
|
result.title = addIconNode;
|
|
82
73
|
return result;
|
|
83
74
|
};
|
|
84
|
-
|
|
85
75
|
return makeRecursiveMapper(function (col) {
|
|
86
76
|
var _a;
|
|
87
|
-
|
|
88
77
|
var _ref2 = (col === null || col === void 0 ? void 0 : col.features) || {},
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
showExtendIcon = _ref2.showExtendIcon;
|
|
91
79
|
if (showExtendIcon === true && ((_a = col.children) === null || _a === void 0 ? void 0 : _a.length) > 1) {
|
|
92
80
|
var _context;
|
|
93
|
-
|
|
94
81
|
col = addIcon(col);
|
|
95
82
|
curState[col.code] === false && _spliceInstanceProperty(_context = col.children).call(_context, 1, col.children.length);
|
|
96
83
|
}
|
|
97
|
-
|
|
98
84
|
return col;
|
|
99
85
|
})(columns);
|
|
100
86
|
};
|
|
101
|
-
|
|
102
87
|
pipeline.columns(processColumns(columns));
|
|
103
88
|
return pipeline;
|
|
104
89
|
};
|