@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.
Files changed (137) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/lib/cjs/BaseTable.js +136 -189
  3. package/lib/cjs/ColGroupContent.js +5 -28
  4. package/lib/cjs/SettingDrawer.js +76 -127
  5. package/lib/cjs/Table.js +107 -171
  6. package/lib/cjs/TableAdvancedFilter.js +49 -85
  7. package/lib/cjs/TableBody.js +33 -69
  8. package/lib/cjs/TableCell.js +56 -102
  9. package/lib/cjs/TableColumnMenu.js +39 -77
  10. package/lib/cjs/TableEmbedRow.js +11 -38
  11. package/lib/cjs/TableHeader.js +8 -33
  12. package/lib/cjs/TableRow.js +48 -88
  13. package/lib/cjs/TableSettingMenu.js +48 -94
  14. package/lib/cjs/TbodyContent.js +28 -56
  15. package/lib/cjs/TheadContent.js +20 -49
  16. package/lib/cjs/_virtual/index.js +0 -3
  17. package/lib/cjs/_virtual/index2.js +0 -3
  18. package/lib/cjs/_virtual/react-is.development.js +0 -3
  19. package/lib/cjs/_virtual/react-is.production.min.js +0 -3
  20. package/lib/cjs/context.js +0 -9
  21. package/lib/cjs/hooks/use-async-switch.js +13 -51
  22. package/lib/cjs/hooks/use-check.js +47 -77
  23. package/lib/cjs/hooks/use-col-hidden.js +16 -28
  24. package/lib/cjs/hooks/use-col-set.js +5 -18
  25. package/lib/cjs/hooks/use-col-sorter.js +18 -32
  26. package/lib/cjs/hooks/use-col-width.js +21 -57
  27. package/lib/cjs/hooks/use-colgroup.js +63 -85
  28. package/lib/cjs/hooks/use-drag.js +10 -31
  29. package/lib/cjs/hooks/use-embed-expand.js +23 -68
  30. package/lib/cjs/hooks/use-expand.js +32 -64
  31. package/lib/cjs/hooks/use-pagination.js +19 -50
  32. package/lib/cjs/hooks/use-queue.js +2 -14
  33. package/lib/cjs/icons/index.js +4 -21
  34. package/lib/cjs/index.js +0 -4
  35. package/lib/cjs/node_modules/classnames/index.js +2 -11
  36. package/lib/cjs/node_modules/perfect-scrollbar/dist/perfect-scrollbar.esm.js +31 -227
  37. package/lib/cjs/node_modules/rc-resize-observer/es/index.js +10 -68
  38. package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +1 -17
  39. package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +1 -14
  40. package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +1 -25
  41. package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +1 -5
  42. package/lib/cjs/node_modules/rc-util/es/Dom/canUseDom.js +0 -2
  43. package/lib/cjs/node_modules/rc-util/es/Dom/findDOMNode.js +1 -14
  44. package/lib/cjs/node_modules/rc-util/es/hooks/useLayoutEffect.js +2 -9
  45. package/lib/cjs/node_modules/rc-util/es/raf.js +0 -11
  46. package/lib/cjs/node_modules/rc-virtual-list/es/Filler.js +6 -25
  47. package/lib/cjs/node_modules/rc-virtual-list/es/Item.js +3 -14
  48. package/lib/cjs/node_modules/rc-virtual-list/es/List.js +103 -194
  49. package/lib/cjs/node_modules/rc-virtual-list/es/ScrollBar.js +16 -96
  50. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useChildren.js +2 -11
  51. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +8 -34
  52. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +0 -10
  53. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useHeights.js +6 -39
  54. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +0 -16
  55. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +4 -9
  56. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +3 -28
  57. package/lib/cjs/node_modules/rc-virtual-list/es/index.js +0 -2
  58. package/lib/cjs/node_modules/rc-virtual-list/es/utils/CacheMap.js +2 -9
  59. package/lib/cjs/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +0 -15
  60. package/lib/cjs/node_modules/rc-virtual-list/es/utils/isFirefox.js +0 -2
  61. package/lib/cjs/node_modules/react-is/cjs/react-is.development.js +3 -29
  62. package/lib/cjs/node_modules/react-is/cjs/react-is.production.min.js +19 -45
  63. package/lib/cjs/node_modules/react-is/index.js +0 -5
  64. package/lib/cjs/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +83 -248
  65. package/lib/cjs/packages/hooks/use-merge-refs/lib/esm/index.js +3 -14
  66. package/lib/cjs/packages/ui/scrollbar/lib/esm/Scrollbar.js +48 -86
  67. package/lib/cjs/packages/ui/scrollbar/lib/esm/styles/index.scss.js +1 -15
  68. package/lib/cjs/packages/ui/scrollbar/lib/esm/utils/index.js +0 -13
  69. package/lib/cjs/styles/index.scss.js +1 -4
  70. package/lib/cjs/use-table.js +268 -355
  71. package/lib/cjs/utils/index.js +11 -45
  72. package/lib/esm/BaseTable.js +117 -138
  73. package/lib/esm/ColGroupContent.js +3 -9
  74. package/lib/esm/SettingDrawer.js +64 -83
  75. package/lib/esm/Table.js +97 -124
  76. package/lib/esm/TableAdvancedFilter.js +37 -47
  77. package/lib/esm/TableBody.js +24 -34
  78. package/lib/esm/TableCell.js +48 -72
  79. package/lib/esm/TableColumnMenu.js +24 -38
  80. package/lib/esm/TableEmbedRow.js +8 -15
  81. package/lib/esm/TableHeader.js +5 -11
  82. package/lib/esm/TableRow.js +36 -51
  83. package/lib/esm/TableSettingMenu.js +33 -49
  84. package/lib/esm/TbodyContent.js +20 -27
  85. package/lib/esm/TheadContent.js +14 -21
  86. package/lib/esm/context.js +0 -4
  87. package/lib/esm/hooks/use-async-switch.js +9 -28
  88. package/lib/esm/hooks/use-check.js +42 -55
  89. package/lib/esm/hooks/use-col-hidden.js +16 -21
  90. package/lib/esm/hooks/use-col-set.js +5 -13
  91. package/lib/esm/hooks/use-col-sorter.js +18 -23
  92. package/lib/esm/hooks/use-col-width.js +14 -34
  93. package/lib/esm/hooks/use-colgroup.js +60 -66
  94. package/lib/esm/hooks/use-drag.js +9 -13
  95. package/lib/esm/hooks/use-embed-expand.js +20 -42
  96. package/lib/esm/hooks/use-expand.js +32 -56
  97. package/lib/esm/hooks/use-pagination.js +13 -25
  98. package/lib/esm/hooks/use-queue.js +2 -10
  99. package/lib/esm/node_modules/classnames/index.js +2 -9
  100. package/lib/esm/node_modules/perfect-scrollbar/dist/perfect-scrollbar.esm.js +31 -228
  101. package/lib/esm/node_modules/rc-resize-observer/es/index.js +3 -26
  102. package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +0 -3
  103. package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +1 -2
  104. package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +0 -8
  105. package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +0 -5
  106. package/lib/esm/node_modules/rc-util/es/Dom/canUseDom.js +0 -1
  107. package/lib/esm/node_modules/rc-util/es/Dom/findDOMNode.js +1 -2
  108. package/lib/esm/node_modules/rc-util/es/hooks/useLayoutEffect.js +1 -0
  109. package/lib/esm/node_modules/rc-util/es/raf.js +0 -10
  110. package/lib/esm/node_modules/rc-virtual-list/es/Filler.js +4 -15
  111. package/lib/esm/node_modules/rc-virtual-list/es/Item.js +1 -3
  112. package/lib/esm/node_modules/rc-virtual-list/es/List.js +101 -174
  113. package/lib/esm/node_modules/rc-virtual-list/es/ScrollBar.js +14 -86
  114. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useChildren.js +0 -2
  115. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +6 -25
  116. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +0 -6
  117. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useHeights.js +4 -28
  118. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +0 -13
  119. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +4 -8
  120. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +1 -19
  121. package/lib/esm/node_modules/rc-virtual-list/es/index.js +1 -1
  122. package/lib/esm/node_modules/rc-virtual-list/es/utils/CacheMap.js +2 -8
  123. package/lib/esm/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +1 -12
  124. package/lib/esm/node_modules/rc-virtual-list/es/utils/isFirefox.js +0 -1
  125. package/lib/esm/node_modules/react-is/cjs/react-is.development.js +4 -27
  126. package/lib/esm/node_modules/react-is/cjs/react-is.production.min.js +20 -44
  127. package/lib/esm/node_modules/react-is/index.js +0 -1
  128. package/lib/esm/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +82 -248
  129. package/lib/esm/packages/hooks/use-merge-refs/lib/esm/index.js +3 -9
  130. package/lib/esm/packages/ui/scrollbar/lib/esm/Scrollbar.js +47 -64
  131. package/lib/esm/packages/ui/scrollbar/lib/esm/styles/index.scss.js +1 -3
  132. package/lib/esm/packages/ui/scrollbar/lib/esm/utils/index.js +0 -10
  133. package/lib/esm/styles/index.scss.js +1 -3
  134. package/lib/esm/use-table.js +261 -318
  135. package/lib/esm/utils/index.js +11 -41
  136. package/lib/types/BaseTable.d.ts +2 -2
  137. package/package.json +33 -33
@@ -8,14 +8,11 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
  import { isNumeric } from '@hi-ui/type-assertion';
11
-
12
11
  var setColumnsDefaultWidth = function setColumnsDefaultWidth(columns, defaultWidth) {
13
12
  var _columns = columns.concat();
14
-
15
13
  var setWidth = function setWidth(_columns) {
16
14
  _columns.forEach(function (item) {
17
15
  var children = item.children;
18
-
19
16
  if (children) {
20
17
  setWidth(children);
21
18
  } else if (item.dataKey) {
@@ -23,7 +20,6 @@ var setColumnsDefaultWidth = function setColumnsDefaultWidth(columns, defaultWid
23
20
  }
24
21
  });
25
22
  };
26
-
27
23
  setWidth(_columns);
28
24
  return _columns;
29
25
  };
@@ -31,36 +27,28 @@ var setColumnsDefaultWidth = function setColumnsDefaultWidth(columns, defaultWid
31
27
  * 获取每个 Column 的真实列宽度(排除合并列头)
32
28
  * 如果是多级表头,将会递归 children 得到叶子结点层每项的宽度
33
29
  */
34
-
35
-
36
30
  var getGroupItemWidth = function getGroupItemWidth(columns) {
37
31
  var baseColWidths = [];
38
-
39
32
  var dig = function dig(column) {
40
33
  column.forEach(function (_ref) {
41
34
  var children = _ref.children,
42
- width = _ref.width;
43
-
35
+ width = _ref.width;
44
36
  if (Array.isArray(children)) {
45
37
  dig(children);
46
38
  return;
47
- } // 如果没有设置列宽度,css 宽度默认是 `auto`,这里对于非数字 width 均设置为 0
48
-
49
-
39
+ }
40
+ // 如果没有设置列宽度,css 宽度默认是 `auto`,这里对于非数字 width 均设置为 0
50
41
  var colWidth = isNumeric(width) ? Number(width) : 0;
51
42
  baseColWidths.push(colWidth);
52
43
  });
53
44
  };
54
-
55
45
  dig(columns);
56
46
  return baseColWidths;
57
47
  };
58
-
59
48
  var parseFixedColumns = function parseFixedColumns(item, index, columns, arr, key, parentStickyWidth) {
60
49
  if (parentStickyWidth === void 0) {
61
50
  parentStickyWidth = 0;
62
51
  }
63
-
64
52
  var width = (arr[index - 1] || {
65
53
  width: 0
66
54
  }).width || 0;
@@ -69,11 +57,10 @@ var parseFixedColumns = function parseFixedColumns(item, index, columns, arr, ke
69
57
  })[key] || 0;
70
58
  item = Object.assign({}, item);
71
59
  item[key] = width + stickyWidth + parentStickyWidth;
72
-
73
60
  if (item.children) {
74
61
  var _parentStickyWidth = item[key];
75
62
  var _item = item,
76
- children = _item.children;
63
+ children = _item.children;
77
64
  item.children = [];
78
65
  children.forEach(function (childrenItem, idx) {
79
66
  var child = parseFixedColumns(childrenItem, idx, columns, children, key, index === 0 ? 0 : _parentStickyWidth);
@@ -81,9 +68,9 @@ var parseFixedColumns = function parseFixedColumns(item, index, columns, arr, ke
81
68
  columns[child.index] = child;
82
69
  });
83
70
  }
84
-
85
71
  return item;
86
- }; // export const parseFixedColumnsByRoot = ({
72
+ };
73
+ // export const parseFixedColumnsByRoot = ({
87
74
  // column,
88
75
  // prevColumn,
89
76
  // key,
@@ -110,71 +97,54 @@ var parseFixedColumns = function parseFixedColumns(item, index, columns, arr, ke
110
97
  // })
111
98
  // }
112
99
  // }
113
-
114
100
  /**
115
101
  * 生成 uuid
116
102
  */
117
-
118
-
119
103
  var uuid = function uuid() {
120
104
  return Math.random().toString(36).substring(5).split('').join('.');
121
105
  };
122
-
123
106
  var parseLocalArray = function parseLocalArray(_ref3) {
124
107
  var key = _ref3.key,
125
- defaultValue = _ref3.defaultValue;
126
-
108
+ defaultValue = _ref3.defaultValue;
127
109
  if (key) {
128
110
  try {
129
111
  var localArr = window.localStorage.getItem(key);
130
-
131
112
  if (localArr) {
132
113
  localArr = JSON.parse(localArr);
133
-
134
114
  if (Array.isArray(localArr)) {
135
115
  return localArr;
136
116
  }
137
117
  }
138
118
  } catch (error) {}
139
119
  }
140
-
141
120
  return defaultValue;
142
- }; // 检查是否需要展示Total或average
143
-
144
-
121
+ };
122
+ // 检查是否需要展示Total或average
145
123
  var checkNeedTotalOrEvg = function checkNeedTotalOrEvg(_data, item, calcKey) {
146
124
  if (item[calcKey]) {
147
125
  // 当每一项都为数字类型字符串时,才进行求和计算
148
126
  var isDataKeyValueAllNumber = _data.every(function (dataItem) {
149
127
  return isNumeric(dataItem[item.dataKey]);
150
128
  });
151
-
152
129
  return isDataKeyValueAllNumber;
153
130
  }
154
-
155
131
  return false;
156
- }; // 获取总和或取平均值
157
-
158
-
132
+ };
133
+ // 获取总和或取平均值
159
134
  var getTotalOrEvgRowData = function getTotalOrEvgRowData(_data, c, isAvg) {
160
135
  var dataPointCountList = _data.map(function (dataItem) {
161
136
  var strNum = dataItem[c.dataKey] + '';
162
137
  var afterPonterStr = strNum.split('.')[1];
163
138
  return afterPonterStr ? afterPonterStr.length : 0;
164
139
  });
165
-
166
140
  var maxPointCount = dataPointCountList && dataPointCountList.length ? Math.max.apply(Math, dataPointCountList) : 0;
167
-
168
141
  var columnSumData = _data.reduce(function (acc, cur) {
169
142
  return acc += Number(cur[c.dataKey]);
170
143
  }, 0);
171
-
172
144
  if (isAvg) {
173
145
  var avgData = columnSumData / _data.length;
174
146
  return maxPointCount > 0 ? avgData.toFixed(maxPointCount) : avgData;
175
147
  }
176
-
177
148
  return maxPointCount > 0 ? columnSumData.toFixed(maxPointCount) : columnSumData;
178
149
  };
179
-
180
150
  export { checkNeedTotalOrEvg, getGroupItemWidth, getTotalOrEvgRowData, parseFixedColumns, parseLocalArray, setColumnsDefaultWidth, uuid };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { HiBaseHTMLProps } from '@hi-ui/core';
2
+ import { HiBaseHTMLProps, HiBaseSizeEnum } from '@hi-ui/core';
3
3
  import { TableExtra, TableColumnItem, TableOnRowReturn } from './types';
4
4
  import { UseTableProps } from './use-table';
5
5
  import { UseEmbedExpandProps } from './hooks/use-embed-expand';
@@ -30,7 +30,7 @@ export interface BaseTableProps extends Omit<HiBaseHTMLProps<'div'>, 'onDrop' |
30
30
  /**
31
31
  * 配置表格尺寸
32
32
  */
33
- size?: string;
33
+ size?: HiBaseSizeEnum;
34
34
  /**
35
35
  * 底部吸底
36
36
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/table",
3
- "version": "4.3.1",
3
+ "version": "4.3.2",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -43,46 +43,46 @@
43
43
  "url": "https://github.com/XiaoMi/hiui/issues"
44
44
  },
45
45
  "dependencies": {
46
- "@hi-ui/array-utils": "^4.0.1",
47
- "@hi-ui/button": "^4.0.6",
48
- "@hi-ui/checkbox": "^4.0.5",
49
- "@hi-ui/classname": "^4.0.1",
50
- "@hi-ui/dom-utils": "^4.0.4",
51
- "@hi-ui/drawer": "^4.0.7",
52
- "@hi-ui/empty-state": "^4.0.4",
53
- "@hi-ui/env": "^4.0.1",
54
- "@hi-ui/func-utils": "^4.0.1",
55
- "@hi-ui/icon-button": "^4.0.5",
56
- "@hi-ui/icons": "^4.0.14",
57
- "@hi-ui/loading": "^4.1.0",
58
- "@hi-ui/object-utils": "^4.0.1",
59
- "@hi-ui/pagination": "^4.0.11",
60
- "@hi-ui/popper": "^4.1.0",
61
- "@hi-ui/react-utils": "^4.0.1",
62
- "@hi-ui/select": "^4.2.2",
63
- "@hi-ui/spinner": "^4.0.4",
64
- "@hi-ui/times": "^4.0.1",
65
- "@hi-ui/tree-utils": "^4.1.1",
66
- "@hi-ui/type-assertion": "^4.0.1",
67
- "@hi-ui/use-cache": "^4.0.1",
68
- "@hi-ui/use-check": "^4.0.2",
69
- "@hi-ui/use-check-state": "^4.0.1",
70
- "@hi-ui/use-drag-sorter": "^4.0.1",
71
- "@hi-ui/use-latest": "^4.0.1",
72
- "@hi-ui/use-toggle": "^4.0.1",
73
- "@hi-ui/use-uncontrolled-state": "^4.0.1",
74
- "@hi-ui/use-update-effect": "^4.0.1",
46
+ "@hi-ui/array-utils": "^4.0.2",
47
+ "@hi-ui/button": "^4.0.7",
48
+ "@hi-ui/checkbox": "^4.0.6",
49
+ "@hi-ui/classname": "^4.0.2",
50
+ "@hi-ui/dom-utils": "^4.0.5",
51
+ "@hi-ui/drawer": "^4.1.1",
52
+ "@hi-ui/empty-state": "^4.0.5",
53
+ "@hi-ui/env": "^4.0.2",
54
+ "@hi-ui/func-utils": "^4.0.2",
55
+ "@hi-ui/icon-button": "^4.0.6",
56
+ "@hi-ui/icons": "^4.0.16",
57
+ "@hi-ui/loading": "^4.1.1",
58
+ "@hi-ui/object-utils": "^4.0.2",
59
+ "@hi-ui/pagination": "^4.0.12",
60
+ "@hi-ui/popper": "^4.1.1",
61
+ "@hi-ui/react-utils": "^4.0.2",
62
+ "@hi-ui/select": "^4.2.3",
63
+ "@hi-ui/spinner": "^4.0.6",
64
+ "@hi-ui/times": "^4.0.2",
65
+ "@hi-ui/tree-utils": "^4.1.2",
66
+ "@hi-ui/type-assertion": "^4.0.2",
67
+ "@hi-ui/use-cache": "^4.0.2",
68
+ "@hi-ui/use-check": "^4.0.3",
69
+ "@hi-ui/use-check-state": "^4.0.2",
70
+ "@hi-ui/use-drag-sorter": "^4.0.2",
71
+ "@hi-ui/use-latest": "^4.0.2",
72
+ "@hi-ui/use-toggle": "^4.0.2",
73
+ "@hi-ui/use-uncontrolled-state": "^4.0.2",
74
+ "@hi-ui/use-update-effect": "^4.0.2",
75
75
  "axios": "^1.5.0",
76
76
  "react-resizable": "^3.0.4"
77
77
  },
78
78
  "peerDependencies": {
79
- "@hi-ui/core": ">=4.0.0",
79
+ "@hi-ui/core": ">=4.0.6",
80
80
  "react": ">=16.8.6",
81
81
  "react-dom": ">=16.8.6"
82
82
  },
83
83
  "devDependencies": {
84
- "@hi-ui/core": "^4.0.4",
85
- "@hi-ui/core-css": "^4.1.2",
84
+ "@hi-ui/core": "^4.0.6",
85
+ "@hi-ui/core-css": "^4.1.3",
86
86
  "@types/react-resizable": "^1.7.4",
87
87
  "react": "^17.0.1",
88
88
  "react-dom": "^17.0.1"