@hi-ui/table 4.5.4 → 4.5.5

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @hi-ui/table
2
2
 
3
+ ## 4.5.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2867](https://github.com/XiaoMi/hiui/pull/2867) [`eec624313`](https://github.com/XiaoMi/hiui/commit/eec624313de88943869f592dd06248455bddedbc) Thanks [@aqiusen](https://github.com/aqiusen)! - 修复统计行中选中模式下显示异常问题(#2863)
8
+
9
+ - [#2859](https://github.com/XiaoMi/hiui/pull/2859) [`a8d3a1f26`](https://github.com/XiaoMi/hiui/commit/a8d3a1f2687709b986fc54408cb6c69b9eb56318) Thanks [@zyprepare](https://github.com/zyprepare)! - fix: 修复 onDragStart 事件不触发问题
10
+
11
+ - [#2847](https://github.com/XiaoMi/hiui/pull/2847) [`0e67d2263`](https://github.com/XiaoMi/hiui/commit/0e67d2263c7e1bf9213e1a2f74300ee201f3a52e) Thanks [@aqiusen](https://github.com/aqiusen)! - fix(table): 修复虚拟列表 maxHeight 无法支持字符串问题
12
+
13
+ - Updated dependencies [[`5508758ec`](https://github.com/XiaoMi/hiui/commit/5508758ec2fe241d635949828065111c9a465ef8)]:
14
+ - @hi-ui/pagination@4.0.16
15
+
3
16
  ## 4.5.4
4
17
 
5
18
  ### Patch Changes
@@ -32,6 +32,7 @@ var useEmbedExpand = require('./hooks/use-embed-expand.js');
32
32
  var TheadContent = require('./TheadContent.js');
33
33
  var ColGroupContent = require('./ColGroupContent.js');
34
34
  var TbodyContent = require('./TbodyContent.js');
35
+ var Table = require('./Table.js');
35
36
  function _interopDefaultCompat(e) {
36
37
  return e && _typeof(e) === 'object' && 'default' in e ? e : {
37
38
  'default': e
@@ -138,7 +139,8 @@ var BaseTable = /*#__PURE__*/React.forwardRef(function (_a, ref) {
138
139
  };
139
140
  var hasAvgColumn = false;
140
141
  columns.forEach(function (column, index$1) {
141
- if (index$1 === 0) {
142
+ // 行选中模式下,index=0是checkbox列,index=1才是第一列 ; fix issue: https://github.com/XiaoMi/hiui/issues/2863
143
+ if (index$1 === 0 || index$1 === 1 && columns[0].dataKey === Table.SELECTION_DATA_KEY) {
142
144
  // @ts-ignore
143
145
  avgRow.raw[column.dataKey] = i18n.get('table.average');
144
146
  }
@@ -166,7 +168,7 @@ var BaseTable = /*#__PURE__*/React.forwardRef(function (_a, ref) {
166
168
  };
167
169
  var hasSumColumn = false;
168
170
  columns.forEach(function (column, index$1) {
169
- if (index$1 === 0) {
171
+ if (index$1 === 0 || index$1 === 1 && columns[0].dataKey === Table.SELECTION_DATA_KEY) {
170
172
  // @ts-ignore
171
173
  sumRow.raw[column.dataKey] = i18n.get('table.total');
172
174
  }
@@ -33,7 +33,7 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
33
33
  var Scrollbar__default = /*#__PURE__*/_interopDefaultCompat(Scrollbar);
34
34
  var _role = 'table';
35
35
  var _prefix = classname.getPrefixCls(_role);
36
- var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
36
+ var TableBody = /*#__PURE__*/React.forwardRef(function (_ref) {
37
37
  var _ref$prefixCls = _ref.prefixCls,
38
38
  prefixCls = _ref$prefixCls === void 0 ? _prefix : _ref$prefixCls,
39
39
  emptyContent = _ref.emptyContent;
@@ -54,6 +54,7 @@ var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
54
54
  measureRowElementRef = _useTableContext.measureRowElementRef,
55
55
  scrollbar = _useTableContext.scrollbar,
56
56
  scrollLeft = _useTableContext.scrollLeft;
57
+ var virtualListRef = React.useRef(null);
57
58
  var cls = classname.cx(prefixCls + "-body");
58
59
  var getRequiredProps = useLatest.useLatestCallback(function (id) {
59
60
  return {
@@ -76,8 +77,9 @@ var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
76
77
  }, [colWidths]);
77
78
  if (virtual) {
78
79
  // TODO: avg和summay row的逻辑
79
- var realHeight = (_a = scrollBodyElementRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height;
80
- var vMaxHeight = maxHeight ? !isNaN(Number(String(maxHeight).replace(/px/, ''))) ? Number(maxHeight) : realHeight : 300;
80
+ var realHeight = (_a = virtualListRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height;
81
+ var maxHeightNumStr = String(maxHeight).replace(/px$/, '');
82
+ var vMaxHeight = maxHeight ? !isNaN(Number(maxHeightNumStr)) ? Number(maxHeightNumStr) : realHeight : 300;
81
83
  return /*#__PURE__*/React__default["default"].createElement("div", {
82
84
  ref: scrollBodyElementRef,
83
85
  className: cls,
@@ -104,10 +106,12 @@ var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
104
106
  width: rowWidth
105
107
  }
106
108
  }), typeAssertion.isArrayNonEmpty(transitionData) ? ( /*#__PURE__*/React__default["default"].createElement("div", {
109
+ ref: virtualListRef,
107
110
  style: {
108
111
  width: '100%',
109
112
  position: 'sticky',
110
- left: 0
113
+ left: 0,
114
+ maxHeight: maxHeight
111
115
  }
112
116
  }, /*#__PURE__*/React__default["default"].createElement(List["default"], {
113
117
  prefixCls: cls + "--virtual",
@@ -78,6 +78,7 @@ var useTable = function useTable(_a) {
78
78
  stickyTop = _a$stickyTop === void 0 ? 0 : _a$stickyTop,
79
79
  _a$draggable = _a.draggable,
80
80
  draggable = _a$draggable === void 0 ? false : _a$draggable,
81
+ onDragStart = _a.onDragStart,
81
82
  onDropProp = _a.onDrop,
82
83
  onDropEnd = _a.onDropEnd,
83
84
  showColMenu = _a.showColMenu,
@@ -574,6 +575,7 @@ var useTable = function useTable(_a) {
574
575
  draggable: draggable,
575
576
  highlightColumns: [],
576
577
  dragRowRef: dragRowRef,
578
+ onDragStart: onDragStart,
577
579
  onDrop: onDrop,
578
580
  groupedColumns: groupedColumns,
579
581
  // 子树展开
@@ -26,6 +26,7 @@ import { useEmbedExpand } from './hooks/use-embed-expand.js';
26
26
  import { TheadContent } from './TheadContent.js';
27
27
  import { ColGroupContent } from './ColGroupContent.js';
28
28
  import { TbodyContent } from './TbodyContent.js';
29
+ import { SELECTION_DATA_KEY } from './Table.js';
29
30
  var _role = 'table';
30
31
  var _prefix = getPrefixCls('table');
31
32
  var EMBED_DATA_KEY = "TABLE_EMBED_DATA_KEY_" + uuid();
@@ -125,7 +126,8 @@ var BaseTable = /*#__PURE__*/forwardRef(function (_a, ref) {
125
126
  };
126
127
  var hasAvgColumn = false;
127
128
  columns.forEach(function (column, index) {
128
- if (index === 0) {
129
+ // 行选中模式下,index=0是checkbox列,index=1才是第一列 ; fix issue: https://github.com/XiaoMi/hiui/issues/2863
130
+ if (index === 0 || index === 1 && columns[0].dataKey === SELECTION_DATA_KEY) {
129
131
  // @ts-ignore
130
132
  avgRow.raw[column.dataKey] = i18n.get('table.average');
131
133
  }
@@ -153,7 +155,7 @@ var BaseTable = /*#__PURE__*/forwardRef(function (_a, ref) {
153
155
  };
154
156
  var hasSumColumn = false;
155
157
  columns.forEach(function (column, index) {
156
- if (index === 0) {
158
+ if (index === 0 || index === 1 && columns[0].dataKey === SELECTION_DATA_KEY) {
157
159
  // @ts-ignore
158
160
  sumRow.raw[column.dataKey] = i18n.get('table.total');
159
161
  }
@@ -7,7 +7,7 @@
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
- import React__default, { forwardRef, useMemo } from 'react';
10
+ import React__default, { forwardRef, useRef, useMemo } from 'react';
11
11
  import List from './node_modules/rc-virtual-list/es/List.js';
12
12
  import { getPrefixCls, cx } from '@hi-ui/classname';
13
13
  import { __DEV__ } from '@hi-ui/env';
@@ -20,7 +20,7 @@ import { ColGroupContent } from './ColGroupContent.js';
20
20
  import { renderEmptyContent, TbodyContent } from './TbodyContent.js';
21
21
  var _role = 'table';
22
22
  var _prefix = getPrefixCls(_role);
23
- var TableBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
23
+ var TableBody = /*#__PURE__*/forwardRef(function (_ref) {
24
24
  var _ref$prefixCls = _ref.prefixCls,
25
25
  prefixCls = _ref$prefixCls === void 0 ? _prefix : _ref$prefixCls,
26
26
  emptyContent = _ref.emptyContent;
@@ -41,6 +41,7 @@ var TableBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
41
41
  measureRowElementRef = _useTableContext.measureRowElementRef,
42
42
  scrollbar = _useTableContext.scrollbar,
43
43
  scrollLeft = _useTableContext.scrollLeft;
44
+ var virtualListRef = useRef(null);
44
45
  var cls = cx(prefixCls + "-body");
45
46
  var getRequiredProps = useLatestCallback(function (id) {
46
47
  return {
@@ -63,8 +64,9 @@ var TableBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
63
64
  }, [colWidths]);
64
65
  if (virtual) {
65
66
  // TODO: avg和summay row的逻辑
66
- var realHeight = (_a = scrollBodyElementRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height;
67
- var vMaxHeight = maxHeight ? !isNaN(Number(String(maxHeight).replace(/px/, ''))) ? Number(maxHeight) : realHeight : 300;
67
+ var realHeight = (_a = virtualListRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height;
68
+ var maxHeightNumStr = String(maxHeight).replace(/px$/, '');
69
+ var vMaxHeight = maxHeight ? !isNaN(Number(maxHeightNumStr)) ? Number(maxHeightNumStr) : realHeight : 300;
68
70
  return /*#__PURE__*/React__default.createElement("div", {
69
71
  ref: scrollBodyElementRef,
70
72
  className: cls,
@@ -91,10 +93,12 @@ var TableBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
91
93
  width: rowWidth
92
94
  }
93
95
  }), isArrayNonEmpty(transitionData) ? ( /*#__PURE__*/React__default.createElement("div", {
96
+ ref: virtualListRef,
94
97
  style: {
95
98
  width: '100%',
96
99
  position: 'sticky',
97
- left: 0
100
+ left: 0,
101
+ maxHeight: maxHeight
98
102
  }
99
103
  }, /*#__PURE__*/React__default.createElement(List, {
100
104
  prefixCls: cls + "--virtual",
@@ -66,6 +66,7 @@ var useTable = function useTable(_a) {
66
66
  stickyTop = _a$stickyTop === void 0 ? 0 : _a$stickyTop,
67
67
  _a$draggable = _a.draggable,
68
68
  draggable = _a$draggable === void 0 ? false : _a$draggable,
69
+ onDragStart = _a.onDragStart,
69
70
  onDropProp = _a.onDrop,
70
71
  onDropEnd = _a.onDropEnd,
71
72
  showColMenu = _a.showColMenu,
@@ -562,6 +563,7 @@ var useTable = function useTable(_a) {
562
563
  draggable: draggable,
563
564
  highlightColumns: [],
564
565
  dragRowRef: dragRowRef,
566
+ onDragStart: onDragStart,
565
567
  onDrop: onDrop,
566
568
  groupedColumns: groupedColumns,
567
569
  // 子树展开
@@ -26,6 +26,9 @@ export declare const TableProvider: import("react").Provider<(Omit<{
26
26
  draggable: boolean;
27
27
  highlightColumns: any;
28
28
  dragRowRef: import("react").MutableRefObject<any>;
29
+ onDragStart: ((evt: import("react").DragEvent<Element>, option: {
30
+ dragNode: object;
31
+ }) => void) | undefined;
29
32
  onDrop: (evt: any, sourceId: any, targetId: any, dragDirection: any) => void;
30
33
  groupedColumns: import("./types").FlattedTableColumnItemData[][];
31
34
  onExpandTreeRowsChange: (expandedNode: import("./types").TableRowEventData, shouldExpanded: boolean) => void;
@@ -138,6 +141,9 @@ export declare const useTableContext: () => Omit<{
138
141
  draggable: boolean;
139
142
  highlightColumns: any;
140
143
  dragRowRef: import("react").MutableRefObject<any>;
144
+ onDragStart: ((evt: import("react").DragEvent<Element>, option: {
145
+ dragNode: object;
146
+ }) => void) | undefined;
141
147
  onDrop: (evt: any, sourceId: any, targetId: any, dragDirection: any) => void;
142
148
  groupedColumns: import("./types").FlattedTableColumnItemData[][];
143
149
  onExpandTreeRowsChange: (expandedNode: import("./types").TableRowEventData, shouldExpanded: boolean) => void;
@@ -28,6 +28,9 @@ export declare const useTable: ({ data, columns: columnsProp, defaultFixedToColu
28
28
  draggable: boolean;
29
29
  highlightColumns: any;
30
30
  dragRowRef: React.MutableRefObject<any>;
31
+ onDragStart: ((evt: React.DragEvent, option: {
32
+ dragNode: object;
33
+ }) => void) | undefined;
31
34
  onDrop: (evt: any, sourceId: any, targetId: any, dragDirection: any) => void;
32
35
  groupedColumns: FlattedTableColumnItemData[][];
33
36
  onExpandTreeRowsChange: (expandedNode: TableRowEventData, shouldExpanded: boolean) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/table",
3
- "version": "4.5.4",
3
+ "version": "4.5.5",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -56,7 +56,7 @@
56
56
  "@hi-ui/icons": "^4.0.19",
57
57
  "@hi-ui/loading": "^4.2.1",
58
58
  "@hi-ui/object-utils": "^4.0.4",
59
- "@hi-ui/pagination": "^4.0.15",
59
+ "@hi-ui/pagination": "^4.0.16",
60
60
  "@hi-ui/popper": "^4.1.5",
61
61
  "@hi-ui/react-utils": "^4.0.4",
62
62
  "@hi-ui/scrollbar": "^4.1.1",