@hi-ui/table 4.5.0 → 4.5.1

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,13 @@
1
1
  # @hi-ui/table
2
2
 
3
+ ## 4.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2760](https://github.com/XiaoMi/hiui/pull/2760) [`68afb78ed`](https://github.com/XiaoMi/hiui/commit/68afb78ed1fb8e42bc8eec68cfa5f1787ee052b0) Thanks [@zyprepare](https://github.com/zyprepare)! - fix: 修复 Safari 中设置 virtual 后只能表头滚动问题
8
+
9
+ - [#2759](https://github.com/XiaoMi/hiui/pull/2759) [`7437ca3b0`](https://github.com/XiaoMi/hiui/commit/7437ca3b07ce1fb66fe9fa3572b45c2928e64a73) Thanks [@zyprepare](https://github.com/zyprepare)! - fix: 修复 SettingDrawer 列更新问题
10
+
3
11
  ## 4.5.0
4
12
 
5
13
  ### Minor Changes
@@ -52,7 +52,8 @@ var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
52
52
  colWidths = _useTableContext.colWidths,
53
53
  virtual = _useTableContext.virtual,
54
54
  measureRowElementRef = _useTableContext.measureRowElementRef,
55
- scrollbar = _useTableContext.scrollbar;
55
+ scrollbar = _useTableContext.scrollbar,
56
+ scrollLeft = _useTableContext.scrollLeft;
56
57
  var cls = classname.cx(prefixCls + "-body");
57
58
  var getRequiredProps = useLatest.useLatestCallback(function (id) {
58
59
  return {
@@ -66,9 +67,6 @@ var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
66
67
  };
67
68
  });
68
69
 
69
- var _useState = React.useState(0),
70
- scrollLeft = _useState[0],
71
- setScrollLeft = _useState[1];
72
70
  var rowWidth = React.useMemo(function () {
73
71
  var tmpWidth = 0;
74
72
  colWidths.forEach(function (width) {
@@ -76,11 +74,6 @@ var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
76
74
  });
77
75
  return tmpWidth;
78
76
  }, [colWidths]);
79
- var onVirtualContainerScroll = React.useCallback(function (evt) {
80
- var _a;
81
- setScrollLeft(((_a = scrollBodyElementRef === null || scrollBodyElementRef === void 0 ? void 0 : scrollBodyElementRef.current) === null || _a === void 0 ? void 0 : _a.scrollLeft) || 0);
82
- onTableBodyScroll(evt);
83
- }, [scrollBodyElementRef, onTableBodyScroll]);
84
77
  if (virtual) {
85
78
  // TODO: avg和summay row的逻辑
86
79
  var realHeight = (_a = scrollBodyElementRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height;
@@ -88,7 +81,7 @@ var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
88
81
  return /*#__PURE__*/React__default["default"].createElement("div", {
89
82
  ref: scrollBodyElementRef,
90
83
  className: cls,
91
- onScroll: onVirtualContainerScroll,
84
+ onScroll: onTableBodyScroll,
92
85
  onWheel: onTableBodyScrollMock,
93
86
  style: {
94
87
  // 表格宽度大于div宽度才出现横向滚动条
@@ -105,7 +98,7 @@ var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
105
98
  }), /*#__PURE__*/React__default["default"].createElement("div", {
106
99
  ref: bodyTableRef,
107
100
  style: {
108
- height: 1,
101
+ height: 2,
109
102
  marginTop: -1,
110
103
  background: 'transparent',
111
104
  width: rowWidth
@@ -62,6 +62,9 @@ var useColSorter = function useColSorter(_ref) {
62
62
  var _useState = React.useState(sortedCols),
63
63
  _cacheSortedCols = _useState[0],
64
64
  setCacheSortedCols = _useState[1];
65
+ React.useEffect(function () {
66
+ setCacheSortedCols(sortedCols);
67
+ }, [sortedCols]);
65
68
  // 保证排序的 column,是有效的可展示的列
66
69
  var cacheSortedCols = React.useMemo(function () {
67
70
  return _cacheSortedCols.filter(function (col) {
@@ -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, useState, useMemo, useCallback } from 'react';
10
+ import React__default, { forwardRef, 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';
@@ -39,7 +39,8 @@ var TableBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
39
39
  colWidths = _useTableContext.colWidths,
40
40
  virtual = _useTableContext.virtual,
41
41
  measureRowElementRef = _useTableContext.measureRowElementRef,
42
- scrollbar = _useTableContext.scrollbar;
42
+ scrollbar = _useTableContext.scrollbar,
43
+ scrollLeft = _useTableContext.scrollLeft;
43
44
  var cls = cx(prefixCls + "-body");
44
45
  var getRequiredProps = useLatestCallback(function (id) {
45
46
  return {
@@ -53,9 +54,6 @@ var TableBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
53
54
  };
54
55
  });
55
56
 
56
- var _useState = useState(0),
57
- scrollLeft = _useState[0],
58
- setScrollLeft = _useState[1];
59
57
  var rowWidth = useMemo(function () {
60
58
  var tmpWidth = 0;
61
59
  colWidths.forEach(function (width) {
@@ -63,11 +61,6 @@ var TableBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
63
61
  });
64
62
  return tmpWidth;
65
63
  }, [colWidths]);
66
- var onVirtualContainerScroll = useCallback(function (evt) {
67
- var _a;
68
- setScrollLeft(((_a = scrollBodyElementRef === null || scrollBodyElementRef === void 0 ? void 0 : scrollBodyElementRef.current) === null || _a === void 0 ? void 0 : _a.scrollLeft) || 0);
69
- onTableBodyScroll(evt);
70
- }, [scrollBodyElementRef, onTableBodyScroll]);
71
64
  if (virtual) {
72
65
  // TODO: avg和summay row的逻辑
73
66
  var realHeight = (_a = scrollBodyElementRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height;
@@ -75,7 +68,7 @@ var TableBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
75
68
  return /*#__PURE__*/React__default.createElement("div", {
76
69
  ref: scrollBodyElementRef,
77
70
  className: cls,
78
- onScroll: onVirtualContainerScroll,
71
+ onScroll: onTableBodyScroll,
79
72
  onWheel: onTableBodyScrollMock,
80
73
  style: {
81
74
  // 表格宽度大于div宽度才出现横向滚动条
@@ -92,7 +85,7 @@ var TableBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
92
85
  }), /*#__PURE__*/React__default.createElement("div", {
93
86
  ref: bodyTableRef,
94
87
  style: {
95
- height: 1,
88
+ height: 2,
96
89
  marginTop: -1,
97
90
  background: 'transparent',
98
91
  width: rowWidth
@@ -57,6 +57,9 @@ var useColSorter = function useColSorter(_ref) {
57
57
  var _useState = useState(sortedCols),
58
58
  _cacheSortedCols = _useState[0],
59
59
  setCacheSortedCols = _useState[1];
60
+ useEffect(function () {
61
+ setCacheSortedCols(sortedCols);
62
+ }, [sortedCols]);
60
63
  // 保证排序的 column,是有效的可展示的列
61
64
  var cacheSortedCols = useMemo(function () {
62
65
  return _cacheSortedCols.filter(function (col) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/table",
3
- "version": "4.5.0",
3
+ "version": "4.5.1",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",