@hi-ui/table 4.3.1 → 4.3.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/CHANGELOG.md +40 -0
- package/lib/cjs/BaseTable.js +136 -189
- package/lib/cjs/ColGroupContent.js +5 -28
- package/lib/cjs/SettingDrawer.js +76 -127
- package/lib/cjs/Table.js +107 -171
- package/lib/cjs/TableAdvancedFilter.js +49 -85
- package/lib/cjs/TableBody.js +33 -69
- package/lib/cjs/TableCell.js +56 -102
- package/lib/cjs/TableColumnMenu.js +39 -77
- package/lib/cjs/TableEmbedRow.js +11 -38
- package/lib/cjs/TableHeader.js +8 -33
- package/lib/cjs/TableRow.js +48 -88
- package/lib/cjs/TableSettingMenu.js +48 -94
- package/lib/cjs/TbodyContent.js +28 -56
- package/lib/cjs/TheadContent.js +20 -49
- package/lib/cjs/_virtual/index.js +0 -3
- package/lib/cjs/_virtual/index2.js +0 -3
- package/lib/cjs/_virtual/react-is.development.js +0 -3
- package/lib/cjs/_virtual/react-is.production.min.js +0 -3
- package/lib/cjs/context.js +0 -9
- package/lib/cjs/hooks/use-async-switch.js +13 -51
- package/lib/cjs/hooks/use-check.js +47 -77
- package/lib/cjs/hooks/use-col-hidden.js +16 -28
- package/lib/cjs/hooks/use-col-set.js +5 -18
- package/lib/cjs/hooks/use-col-sorter.js +18 -32
- package/lib/cjs/hooks/use-col-width.js +21 -57
- package/lib/cjs/hooks/use-colgroup.js +63 -85
- package/lib/cjs/hooks/use-drag.js +10 -31
- package/lib/cjs/hooks/use-embed-expand.js +23 -68
- package/lib/cjs/hooks/use-expand.js +32 -64
- package/lib/cjs/hooks/use-pagination.js +19 -50
- package/lib/cjs/hooks/use-queue.js +2 -14
- package/lib/cjs/icons/index.js +4 -21
- package/lib/cjs/index.js +0 -4
- package/lib/cjs/node_modules/classnames/index.js +2 -11
- package/lib/cjs/node_modules/perfect-scrollbar/dist/perfect-scrollbar.esm.js +31 -227
- package/lib/cjs/node_modules/rc-resize-observer/es/index.js +10 -68
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +1 -17
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +1 -14
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +1 -25
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +1 -5
- package/lib/cjs/node_modules/rc-util/es/Dom/canUseDom.js +0 -2
- package/lib/cjs/node_modules/rc-util/es/Dom/findDOMNode.js +1 -14
- package/lib/cjs/node_modules/rc-util/es/hooks/useLayoutEffect.js +2 -9
- package/lib/cjs/node_modules/rc-util/es/raf.js +0 -11
- package/lib/cjs/node_modules/rc-virtual-list/es/Filler.js +6 -25
- package/lib/cjs/node_modules/rc-virtual-list/es/Item.js +3 -14
- package/lib/cjs/node_modules/rc-virtual-list/es/List.js +103 -194
- package/lib/cjs/node_modules/rc-virtual-list/es/ScrollBar.js +16 -96
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useChildren.js +2 -11
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +8 -34
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +0 -10
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useHeights.js +6 -39
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +0 -16
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +4 -9
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +3 -28
- package/lib/cjs/node_modules/rc-virtual-list/es/index.js +0 -2
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/CacheMap.js +2 -9
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +0 -15
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/isFirefox.js +0 -2
- package/lib/cjs/node_modules/react-is/cjs/react-is.development.js +3 -29
- package/lib/cjs/node_modules/react-is/cjs/react-is.production.min.js +19 -45
- package/lib/cjs/node_modules/react-is/index.js +0 -5
- package/lib/cjs/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +83 -248
- package/lib/cjs/packages/hooks/use-merge-refs/lib/esm/index.js +3 -14
- package/lib/cjs/packages/ui/scrollbar/lib/esm/Scrollbar.js +48 -86
- package/lib/cjs/packages/ui/scrollbar/lib/esm/styles/index.scss.js +1 -15
- package/lib/cjs/packages/ui/scrollbar/lib/esm/utils/index.js +0 -13
- package/lib/cjs/styles/index.scss.js +1 -4
- package/lib/cjs/use-table.js +268 -355
- package/lib/cjs/utils/index.js +11 -45
- package/lib/esm/BaseTable.js +117 -138
- package/lib/esm/ColGroupContent.js +3 -9
- package/lib/esm/SettingDrawer.js +64 -83
- package/lib/esm/Table.js +97 -124
- package/lib/esm/TableAdvancedFilter.js +37 -47
- package/lib/esm/TableBody.js +24 -34
- package/lib/esm/TableCell.js +48 -72
- package/lib/esm/TableColumnMenu.js +24 -38
- package/lib/esm/TableEmbedRow.js +8 -15
- package/lib/esm/TableHeader.js +5 -11
- package/lib/esm/TableRow.js +36 -51
- package/lib/esm/TableSettingMenu.js +33 -49
- package/lib/esm/TbodyContent.js +20 -27
- package/lib/esm/TheadContent.js +14 -21
- package/lib/esm/context.js +0 -4
- package/lib/esm/hooks/use-async-switch.js +9 -28
- package/lib/esm/hooks/use-check.js +42 -55
- package/lib/esm/hooks/use-col-hidden.js +16 -21
- package/lib/esm/hooks/use-col-set.js +5 -13
- package/lib/esm/hooks/use-col-sorter.js +18 -23
- package/lib/esm/hooks/use-col-width.js +14 -34
- package/lib/esm/hooks/use-colgroup.js +60 -66
- package/lib/esm/hooks/use-drag.js +9 -13
- package/lib/esm/hooks/use-embed-expand.js +20 -42
- package/lib/esm/hooks/use-expand.js +32 -56
- package/lib/esm/hooks/use-pagination.js +13 -25
- package/lib/esm/hooks/use-queue.js +2 -10
- package/lib/esm/node_modules/classnames/index.js +2 -9
- package/lib/esm/node_modules/perfect-scrollbar/dist/perfect-scrollbar.esm.js +31 -228
- package/lib/esm/node_modules/rc-resize-observer/es/index.js +3 -26
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +0 -3
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +1 -2
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +0 -8
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +0 -5
- package/lib/esm/node_modules/rc-util/es/Dom/canUseDom.js +0 -1
- package/lib/esm/node_modules/rc-util/es/Dom/findDOMNode.js +1 -2
- package/lib/esm/node_modules/rc-util/es/hooks/useLayoutEffect.js +1 -0
- package/lib/esm/node_modules/rc-util/es/raf.js +0 -10
- package/lib/esm/node_modules/rc-virtual-list/es/Filler.js +4 -15
- package/lib/esm/node_modules/rc-virtual-list/es/Item.js +1 -3
- package/lib/esm/node_modules/rc-virtual-list/es/List.js +101 -174
- package/lib/esm/node_modules/rc-virtual-list/es/ScrollBar.js +14 -86
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useChildren.js +0 -2
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +6 -25
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +0 -6
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useHeights.js +4 -28
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +0 -13
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +4 -8
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +1 -19
- package/lib/esm/node_modules/rc-virtual-list/es/index.js +1 -1
- package/lib/esm/node_modules/rc-virtual-list/es/utils/CacheMap.js +2 -8
- package/lib/esm/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +1 -12
- package/lib/esm/node_modules/rc-virtual-list/es/utils/isFirefox.js +0 -1
- package/lib/esm/node_modules/react-is/cjs/react-is.development.js +4 -27
- package/lib/esm/node_modules/react-is/cjs/react-is.production.min.js +20 -44
- package/lib/esm/node_modules/react-is/index.js +0 -1
- package/lib/esm/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +82 -248
- package/lib/esm/packages/hooks/use-merge-refs/lib/esm/index.js +3 -9
- package/lib/esm/packages/ui/scrollbar/lib/esm/Scrollbar.js +47 -64
- package/lib/esm/packages/ui/scrollbar/lib/esm/styles/index.scss.js +1 -3
- package/lib/esm/packages/ui/scrollbar/lib/esm/utils/index.js +0 -10
- package/lib/esm/styles/index.scss.js +1 -3
- package/lib/esm/use-table.js +261 -318
- package/lib/esm/utils/index.js +11 -41
- package/lib/types/BaseTable.d.ts +2 -2
- package/package.json +33 -33
package/lib/cjs/utils/index.js
CHANGED
|
@@ -9,19 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
|
13
|
-
value: true
|
|
14
|
-
});
|
|
15
|
-
|
|
16
12
|
var typeAssertion = require('@hi-ui/type-assertion');
|
|
17
|
-
|
|
18
13
|
var setColumnsDefaultWidth = function setColumnsDefaultWidth(columns, defaultWidth) {
|
|
19
14
|
var _columns = columns.concat();
|
|
20
|
-
|
|
21
15
|
var setWidth = function setWidth(_columns) {
|
|
22
16
|
_columns.forEach(function (item) {
|
|
23
17
|
var children = item.children;
|
|
24
|
-
|
|
25
18
|
if (children) {
|
|
26
19
|
setWidth(children);
|
|
27
20
|
} else if (item.dataKey) {
|
|
@@ -29,7 +22,6 @@ var setColumnsDefaultWidth = function setColumnsDefaultWidth(columns, defaultWid
|
|
|
29
22
|
}
|
|
30
23
|
});
|
|
31
24
|
};
|
|
32
|
-
|
|
33
25
|
setWidth(_columns);
|
|
34
26
|
return _columns;
|
|
35
27
|
};
|
|
@@ -37,36 +29,28 @@ var setColumnsDefaultWidth = function setColumnsDefaultWidth(columns, defaultWid
|
|
|
37
29
|
* 获取每个 Column 的真实列宽度(排除合并列头)
|
|
38
30
|
* 如果是多级表头,将会递归 children 得到叶子结点层每项的宽度
|
|
39
31
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
32
|
var getGroupItemWidth = function getGroupItemWidth(columns) {
|
|
43
33
|
var baseColWidths = [];
|
|
44
|
-
|
|
45
34
|
var dig = function dig(column) {
|
|
46
35
|
column.forEach(function (_ref) {
|
|
47
36
|
var children = _ref.children,
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
width = _ref.width;
|
|
50
38
|
if (Array.isArray(children)) {
|
|
51
39
|
dig(children);
|
|
52
40
|
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
}
|
|
42
|
+
// 如果没有设置列宽度,css 宽度默认是 `auto`,这里对于非数字 width 均设置为 0
|
|
56
43
|
var colWidth = typeAssertion.isNumeric(width) ? Number(width) : 0;
|
|
57
44
|
baseColWidths.push(colWidth);
|
|
58
45
|
});
|
|
59
46
|
};
|
|
60
|
-
|
|
61
47
|
dig(columns);
|
|
62
48
|
return baseColWidths;
|
|
63
49
|
};
|
|
64
|
-
|
|
65
50
|
var parseFixedColumns = function parseFixedColumns(item, index, columns, arr, key, parentStickyWidth) {
|
|
66
51
|
if (parentStickyWidth === void 0) {
|
|
67
52
|
parentStickyWidth = 0;
|
|
68
53
|
}
|
|
69
|
-
|
|
70
54
|
var width = (arr[index - 1] || {
|
|
71
55
|
width: 0
|
|
72
56
|
}).width || 0;
|
|
@@ -75,11 +59,10 @@ var parseFixedColumns = function parseFixedColumns(item, index, columns, arr, ke
|
|
|
75
59
|
})[key] || 0;
|
|
76
60
|
item = Object.assign({}, item);
|
|
77
61
|
item[key] = width + stickyWidth + parentStickyWidth;
|
|
78
|
-
|
|
79
62
|
if (item.children) {
|
|
80
63
|
var _parentStickyWidth = item[key];
|
|
81
64
|
var _item = item,
|
|
82
|
-
|
|
65
|
+
children = _item.children;
|
|
83
66
|
item.children = [];
|
|
84
67
|
children.forEach(function (childrenItem, idx) {
|
|
85
68
|
var child = parseFixedColumns(childrenItem, idx, columns, children, key, index === 0 ? 0 : _parentStickyWidth);
|
|
@@ -87,9 +70,9 @@ var parseFixedColumns = function parseFixedColumns(item, index, columns, arr, ke
|
|
|
87
70
|
columns[child.index] = child;
|
|
88
71
|
});
|
|
89
72
|
}
|
|
90
|
-
|
|
91
73
|
return item;
|
|
92
|
-
};
|
|
74
|
+
};
|
|
75
|
+
// export const parseFixedColumnsByRoot = ({
|
|
93
76
|
// column,
|
|
94
77
|
// prevColumn,
|
|
95
78
|
// key,
|
|
@@ -116,73 +99,56 @@ var parseFixedColumns = function parseFixedColumns(item, index, columns, arr, ke
|
|
|
116
99
|
// })
|
|
117
100
|
// }
|
|
118
101
|
// }
|
|
119
|
-
|
|
120
102
|
/**
|
|
121
103
|
* 生成 uuid
|
|
122
104
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
105
|
var uuid = function uuid() {
|
|
126
106
|
return Math.random().toString(36).substring(5).split('').join('.');
|
|
127
107
|
};
|
|
128
|
-
|
|
129
108
|
var parseLocalArray = function parseLocalArray(_ref3) {
|
|
130
109
|
var key = _ref3.key,
|
|
131
|
-
|
|
132
|
-
|
|
110
|
+
defaultValue = _ref3.defaultValue;
|
|
133
111
|
if (key) {
|
|
134
112
|
try {
|
|
135
113
|
var localArr = window.localStorage.getItem(key);
|
|
136
|
-
|
|
137
114
|
if (localArr) {
|
|
138
115
|
localArr = JSON.parse(localArr);
|
|
139
|
-
|
|
140
116
|
if (Array.isArray(localArr)) {
|
|
141
117
|
return localArr;
|
|
142
118
|
}
|
|
143
119
|
}
|
|
144
120
|
} catch (error) {}
|
|
145
121
|
}
|
|
146
|
-
|
|
147
122
|
return defaultValue;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
|
|
123
|
+
};
|
|
124
|
+
// 检查是否需要展示Total或average
|
|
151
125
|
var checkNeedTotalOrEvg = function checkNeedTotalOrEvg(_data, item, calcKey) {
|
|
152
126
|
if (item[calcKey]) {
|
|
153
127
|
// 当每一项都为数字类型字符串时,才进行求和计算
|
|
154
128
|
var isDataKeyValueAllNumber = _data.every(function (dataItem) {
|
|
155
129
|
return typeAssertion.isNumeric(dataItem[item.dataKey]);
|
|
156
130
|
});
|
|
157
|
-
|
|
158
131
|
return isDataKeyValueAllNumber;
|
|
159
132
|
}
|
|
160
|
-
|
|
161
133
|
return false;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
|
|
134
|
+
};
|
|
135
|
+
// 获取总和或取平均值
|
|
165
136
|
var getTotalOrEvgRowData = function getTotalOrEvgRowData(_data, c, isAvg) {
|
|
166
137
|
var dataPointCountList = _data.map(function (dataItem) {
|
|
167
138
|
var strNum = dataItem[c.dataKey] + '';
|
|
168
139
|
var afterPonterStr = strNum.split('.')[1];
|
|
169
140
|
return afterPonterStr ? afterPonterStr.length : 0;
|
|
170
141
|
});
|
|
171
|
-
|
|
172
142
|
var maxPointCount = dataPointCountList && dataPointCountList.length ? Math.max.apply(Math, dataPointCountList) : 0;
|
|
173
|
-
|
|
174
143
|
var columnSumData = _data.reduce(function (acc, cur) {
|
|
175
144
|
return acc += Number(cur[c.dataKey]);
|
|
176
145
|
}, 0);
|
|
177
|
-
|
|
178
146
|
if (isAvg) {
|
|
179
147
|
var avgData = columnSumData / _data.length;
|
|
180
148
|
return maxPointCount > 0 ? avgData.toFixed(maxPointCount) : avgData;
|
|
181
149
|
}
|
|
182
|
-
|
|
183
150
|
return maxPointCount > 0 ? columnSumData.toFixed(maxPointCount) : columnSumData;
|
|
184
151
|
};
|
|
185
|
-
|
|
186
152
|
exports.checkNeedTotalOrEvg = checkNeedTotalOrEvg;
|
|
187
153
|
exports.getGroupItemWidth = getGroupItemWidth;
|
|
188
154
|
exports.getTotalOrEvgRowData = getTotalOrEvgRowData;
|
package/lib/esm/BaseTable.js
CHANGED
|
@@ -26,63 +26,58 @@ import { TheadContent } from './TheadContent.js';
|
|
|
26
26
|
import { ColGroupContent } from './ColGroupContent.js';
|
|
27
27
|
import { TbodyContent } from './TbodyContent.js';
|
|
28
28
|
var _role = 'table';
|
|
29
|
-
|
|
30
29
|
var _prefix = getPrefixCls('table');
|
|
31
|
-
|
|
32
30
|
var EMBED_DATA_KEY = "TABLE_EMBED_DATA_KEY_" + uuid();
|
|
33
31
|
var DEFAULT_COLUMNS = [];
|
|
34
32
|
var DEFAULT_DATA = [];
|
|
35
33
|
var BaseTable = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
36
34
|
var _a$prefixCls = _a.prefixCls,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
35
|
+
prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls,
|
|
36
|
+
_a$role = _a.role,
|
|
37
|
+
role = _a$role === void 0 ? _role : _a$role,
|
|
38
|
+
className = _a.className,
|
|
39
|
+
_a$columns = _a.columns,
|
|
40
|
+
columns = _a$columns === void 0 ? DEFAULT_COLUMNS : _a$columns,
|
|
41
|
+
_a$data = _a.data,
|
|
42
|
+
data = _a$data === void 0 ? DEFAULT_DATA : _a$data,
|
|
43
|
+
_a$striped = _a.striped,
|
|
44
|
+
striped = _a$striped === void 0 ? false : _a$striped,
|
|
45
|
+
borderedProp = _a.bordered,
|
|
46
|
+
rowExpandable = _a.rowExpandable,
|
|
47
|
+
defaultExpandedEmbedRowKeys = _a.defaultExpandedEmbedRowKeys,
|
|
48
|
+
expandedEmbedRowKeys = _a.expandedEmbedRowKeys,
|
|
49
|
+
onEmbedExpand = _a.onEmbedExpand,
|
|
50
|
+
expandedRender = _a.expandedRender,
|
|
51
|
+
_a$size = _a.size,
|
|
52
|
+
size = _a$size === void 0 ? 'md' : _a$size,
|
|
53
|
+
extra = _a.extra,
|
|
54
|
+
onRow = _a.onRow,
|
|
55
|
+
stickyFooter = _a.stickyFooter,
|
|
56
|
+
_a$stickyFooterBottom = _a.stickyFooterBottom,
|
|
57
|
+
stickyFooterBottom = _a$stickyFooterBottom === void 0 ? 0 : _a$stickyFooterBottom,
|
|
58
|
+
_a$fixedColumnTrigger = _a.fixedColumnTrigger,
|
|
59
|
+
fixedColumnTrigger = _a$fixedColumnTrigger === void 0 ? 'auto' : _a$fixedColumnTrigger,
|
|
60
|
+
emptyContent = _a.emptyContent,
|
|
61
|
+
virtual = _a.virtual,
|
|
62
|
+
needDoubleTable = _a.needDoubleTable,
|
|
63
|
+
rest = __rest(_a, ["prefixCls", "role", "className", "columns", "data", "striped", "bordered", "rowExpandable", "defaultExpandedEmbedRowKeys", "expandedEmbedRowKeys", "onEmbedExpand", "expandedRender", "size", "extra", "onRow", "onHeaderRow", "stickyFooter", "stickyFooterBottom", "fixedColumnTrigger", "emptyContent", "virtual", "needDoubleTable"]);
|
|
64
|
+
// ********************** 内嵌式面板 *********************** //
|
|
68
65
|
var _useEmbedExpand = useEmbedExpand({
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
defaultExpandedEmbedRowKeys: defaultExpandedEmbedRowKeys,
|
|
67
|
+
rowExpandable: rowExpandable,
|
|
68
|
+
expandedEmbedRowKeys: expandedEmbedRowKeys,
|
|
69
|
+
onEmbedExpand: onEmbedExpand,
|
|
70
|
+
expandedRender: expandedRender
|
|
71
|
+
}),
|
|
72
|
+
embedExpandable = _useEmbedExpand.embedExpandable,
|
|
73
|
+
onEmbedSwitch = _useEmbedExpand.onEmbedSwitch,
|
|
74
|
+
isEmbedLoadingId = _useEmbedExpand.isEmbedLoadingId,
|
|
75
|
+
getEmbedPanelById = _useEmbedExpand.getEmbedPanelById,
|
|
76
|
+
isExpandEmbedRows = _useEmbedExpand.isExpandEmbedRows,
|
|
77
|
+
onExpandEmbedRowsChange = _useEmbedExpand.onExpandEmbedRowsChange;
|
|
81
78
|
/**
|
|
82
79
|
* 表格列展开折叠操作区
|
|
83
80
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
81
|
var getEmbedPanelColumn = React__default.useCallback(function (embedExpandable) {
|
|
87
82
|
var embedPanelColumn = {
|
|
88
83
|
dataKey: EMBED_DATA_KEY,
|
|
@@ -116,97 +111,90 @@ var BaseTable = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
116
111
|
var embedColumn = getEmbedPanelColumn(embedExpandable);
|
|
117
112
|
return [embedColumn].concat(columns);
|
|
118
113
|
}
|
|
119
|
-
|
|
120
114
|
return columns;
|
|
121
115
|
}, [embedExpandable, getEmbedPanelColumn, columns]);
|
|
122
116
|
var i18n = useLocaleContext();
|
|
123
|
-
|
|
124
117
|
var _useMemo = useMemo(function () {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
hasAvgColumn = _useMemo.hasAvgColumn;
|
|
153
|
-
|
|
118
|
+
// 确保包含 avg 属性,且值为数字类型的字符串
|
|
119
|
+
var avgRow = {
|
|
120
|
+
id: 'avg',
|
|
121
|
+
raw: {
|
|
122
|
+
key: 'avg'
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var hasAvgColumn = false;
|
|
126
|
+
columns.forEach(function (column, index) {
|
|
127
|
+
if (index === 0) {
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
avgRow.raw[column.dataKey] = i18n.get('table.average');
|
|
130
|
+
}
|
|
131
|
+
if (checkNeedTotalOrEvg(data, column, 'avg')) {
|
|
132
|
+
hasAvgColumn = true;
|
|
133
|
+
// @ts-ignore
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
avgRow.raw[column.dataKey] = getTotalOrEvgRowData(data, column, true);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
avgRow: avgRow,
|
|
140
|
+
hasAvgColumn: hasAvgColumn
|
|
141
|
+
};
|
|
142
|
+
}, [columns, data, i18n]),
|
|
143
|
+
avgRow = _useMemo.avgRow,
|
|
144
|
+
hasAvgColumn = _useMemo.hasAvgColumn;
|
|
154
145
|
var _useMemo2 = useMemo(function () {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
hasSumColumn = _useMemo2.hasSumColumn;
|
|
185
|
-
|
|
146
|
+
// 确保包含total属性,且值为数字类型的字符串
|
|
147
|
+
var sumRow = {
|
|
148
|
+
id: 'sum',
|
|
149
|
+
raw: {
|
|
150
|
+
key: 'sum'
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var hasSumColumn = false;
|
|
154
|
+
columns.forEach(function (column, index) {
|
|
155
|
+
if (index === 0) {
|
|
156
|
+
// @ts-ignore
|
|
157
|
+
sumRow.raw[column.dataKey] = i18n.get('table.total');
|
|
158
|
+
}
|
|
159
|
+
if (checkNeedTotalOrEvg(data, column, 'total')) {
|
|
160
|
+
hasSumColumn = true;
|
|
161
|
+
// 获取当前数据最大小数点个数,并设置最后总和值小数点
|
|
162
|
+
// @ts-ignore
|
|
163
|
+
// 获取当前数据最大小数点个数,并设置最后总和值小数点
|
|
164
|
+
// @ts-ignore
|
|
165
|
+
sumRow.raw[column.dataKey] = getTotalOrEvgRowData(data, column, false);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
sumRow: sumRow,
|
|
170
|
+
hasSumColumn: hasSumColumn
|
|
171
|
+
};
|
|
172
|
+
}, [columns, data, i18n]),
|
|
173
|
+
sumRow = _useMemo2.sumRow,
|
|
174
|
+
hasSumColumn = _useMemo2.hasSumColumn;
|
|
186
175
|
var providedValue = useTable(Object.assign(Object.assign({}, rest), {
|
|
187
176
|
columns: mergedColumns,
|
|
188
177
|
data: data,
|
|
189
178
|
virtual: virtual
|
|
190
179
|
}));
|
|
191
180
|
var rootProps = providedValue.rootProps,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
181
|
+
bordered = providedValue.bordered,
|
|
182
|
+
leftFrozenColKeys = providedValue.leftFrozenColKeys,
|
|
183
|
+
rightFrozenColKeys = providedValue.rightFrozenColKeys,
|
|
184
|
+
leftFixedColumnsWidth = providedValue.leftFixedColumnsWidth,
|
|
185
|
+
rightFixedColumnsWidth = providedValue.rightFixedColumnsWidth,
|
|
186
|
+
scrollSize = providedValue.scrollSize,
|
|
187
|
+
getTableHeaderProps = providedValue.getTableHeaderProps,
|
|
188
|
+
scrollBodyElementRef = providedValue.scrollBodyElementRef,
|
|
189
|
+
onTableBodyScroll = providedValue.onTableBodyScroll,
|
|
190
|
+
canScroll = providedValue.canScroll,
|
|
191
|
+
bodyTableRef = providedValue.bodyTableRef,
|
|
192
|
+
scrollWidth = providedValue.scrollWidth,
|
|
193
|
+
footerRender = providedValue.footerRender;
|
|
205
194
|
var hasBorder = borderedProp !== null && borderedProp !== void 0 ? borderedProp : bordered;
|
|
206
195
|
var extraHeader = extra && extra.header;
|
|
207
196
|
var extraFooter = extra && extra.footer;
|
|
208
197
|
var alwaysFixedColumn = fixedColumnTrigger === 'always';
|
|
209
|
-
|
|
210
198
|
var renderTable = function renderTable() {
|
|
211
199
|
return needDoubleTable ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", Object.assign({}, getTableHeaderProps()), /*#__PURE__*/React__default.createElement(TableHeader, null), extraHeader ? /*#__PURE__*/React__default.createElement("div", {
|
|
212
200
|
style: {
|
|
@@ -235,7 +223,6 @@ var BaseTable = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
235
223
|
emptyContent: emptyContent
|
|
236
224
|
})));
|
|
237
225
|
};
|
|
238
|
-
|
|
239
226
|
var renderFreezeShadow = function renderFreezeShadow() {
|
|
240
227
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, (alwaysFixedColumn || scrollSize.scrollLeft > 0) && leftFrozenColKeys.length > 0 ? /*#__PURE__*/React__default.createElement("div", {
|
|
241
228
|
className: prefixCls + "-freeze-shadow " + prefixCls + "-freeze-shadow--left",
|
|
@@ -249,7 +236,6 @@ var BaseTable = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
249
236
|
}
|
|
250
237
|
}) : null);
|
|
251
238
|
};
|
|
252
|
-
|
|
253
239
|
var tableFooter = /*#__PURE__*/React__default.createElement("div", {
|
|
254
240
|
className: prefixCls + "-footer",
|
|
255
241
|
style: stickyFooter ? {
|
|
@@ -282,24 +268,20 @@ var BaseTable = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
282
268
|
})
|
|
283
269
|
}, renderTable()), renderFreezeShadow()), tableFooter);
|
|
284
270
|
});
|
|
285
|
-
|
|
286
271
|
if (__DEV__) {
|
|
287
272
|
BaseTable.displayName = 'BaseTable';
|
|
288
273
|
}
|
|
289
|
-
|
|
290
274
|
var renderSwitcher = function renderSwitcher(_ref) {
|
|
291
275
|
var prefixCls = _ref.prefixCls,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
276
|
+
rowExpand = _ref.rowExpand,
|
|
277
|
+
loading = _ref.loading,
|
|
278
|
+
expanded = _ref.expanded,
|
|
279
|
+
onSwitch = _ref.onSwitch,
|
|
280
|
+
expandedIcon = _ref.expandedIcon,
|
|
281
|
+
collapsedIcon = _ref.collapsedIcon;
|
|
299
282
|
if ( /*#__PURE__*/React__default.isValidElement(rowExpand)) {
|
|
300
283
|
return rowExpand;
|
|
301
284
|
}
|
|
302
|
-
|
|
303
285
|
if (rowExpand === true) {
|
|
304
286
|
if (loading) {
|
|
305
287
|
return /*#__PURE__*/React__default.createElement(IconButton, {
|
|
@@ -307,7 +289,6 @@ var renderSwitcher = function renderSwitcher(_ref) {
|
|
|
307
289
|
icon: defaultLoadingIcon
|
|
308
290
|
});
|
|
309
291
|
}
|
|
310
|
-
|
|
311
292
|
return /*#__PURE__*/React__default.createElement(IconButton, {
|
|
312
293
|
tabIndex: -1,
|
|
313
294
|
className: cx(prefixCls + "__switcher", prefixCls + "__switcher--" + (expanded ? 'expanded' : 'collapse')),
|
|
@@ -319,8 +300,6 @@ var renderSwitcher = function renderSwitcher(_ref) {
|
|
|
319
300
|
}
|
|
320
301
|
});
|
|
321
302
|
}
|
|
322
|
-
|
|
323
303
|
return null;
|
|
324
304
|
};
|
|
325
|
-
|
|
326
305
|
export { BaseTable, EMBED_DATA_KEY };
|
|
@@ -11,17 +11,13 @@ import React__default, { forwardRef } from 'react';
|
|
|
11
11
|
import { getPrefixCls } from '@hi-ui/classname';
|
|
12
12
|
import { __DEV__ } from '@hi-ui/env';
|
|
13
13
|
import { useTableContext } from './context.js';
|
|
14
|
-
|
|
15
14
|
var _prefix = getPrefixCls('table-colgroup');
|
|
16
|
-
|
|
17
15
|
var ColGroupContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
18
16
|
var _ref$prefixCls = _ref.prefixCls,
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
prefixCls = _ref$prefixCls === void 0 ? _prefix : _ref$prefixCls;
|
|
21
18
|
var _useTableContext = useTableContext(),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
getColgroupProps = _useTableContext.getColgroupProps,
|
|
20
|
+
leafColumns = _useTableContext.leafColumns;
|
|
25
21
|
return /*#__PURE__*/React__default.createElement("colgroup", null, leafColumns.map(function (col, idx) {
|
|
26
22
|
return /*#__PURE__*/React__default.createElement("col", Object.assign({
|
|
27
23
|
key: idx,
|
|
@@ -29,9 +25,7 @@ var ColGroupContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
29
25
|
}, getColgroupProps(col, idx)));
|
|
30
26
|
}));
|
|
31
27
|
});
|
|
32
|
-
|
|
33
28
|
if (__DEV__) {
|
|
34
29
|
ColGroupContent.displayName = 'ColGroupContent';
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
export { ColGroupContent };
|