@kdcloudjs/table 1.0.1 → 1.0.4

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 (207) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +34 -33
  3. package/dist/@kdcloudjs/table.css +1 -1
  4. package/dist/@kdcloudjs/table.css.map +1 -1
  5. package/dist/@kdcloudjs/table.js +6555 -3388
  6. package/dist/@kdcloudjs/table.js.map +1 -1
  7. package/dist/@kdcloudjs/table.min.css +1 -1
  8. package/dist/@kdcloudjs/table.min.js +32 -24
  9. package/dist/@kdcloudjs/table.min.js.map +1 -1
  10. package/es/_utils/hooks.js +1 -2
  11. package/es/_utils/numberUtil.js +3 -4
  12. package/es/locale/locale.js +1 -2
  13. package/es/table/base/calculations.js +3 -4
  14. package/es/table/base/empty.js +2 -2
  15. package/es/table/base/header.d.ts +6 -2
  16. package/es/table/base/header.js +41 -22
  17. package/es/table/base/helpers/SpanManager.js +1 -1
  18. package/es/table/base/helpers/TableDOMUtils.d.ts +3 -0
  19. package/es/table/base/helpers/TableDOMUtils.js +23 -5
  20. package/es/table/base/helpers/getRichVisibleRectsStream.d.ts +23 -0
  21. package/es/table/base/helpers/getRichVisibleRectsStream.js +216 -0
  22. package/es/table/base/html-table.d.ts +3 -1
  23. package/es/table/base/html-table.js +43 -26
  24. package/es/table/base/interfaces.d.ts +1 -0
  25. package/es/table/base/renderTemplates.d.ts +1 -0
  26. package/es/table/base/renderTemplates.js +344 -0
  27. package/es/table/base/styles.d.ts +24 -0
  28. package/es/table/base/styles.js +31 -9
  29. package/es/table/base/table.d.ts +12 -4
  30. package/es/table/base/table.js +183 -136
  31. package/es/table/base/utils.d.ts +6 -3
  32. package/es/table/base/utils.js +27 -6
  33. package/es/table/common-views.js +3 -3
  34. package/es/table/pipeline/features/autoFill.js +7 -1
  35. package/es/table/pipeline/features/columnDrag.js +168 -59
  36. package/es/table/pipeline/features/columnFilter.js +7 -9
  37. package/es/table/pipeline/features/columnResizeWidth.d.ts +3 -0
  38. package/es/table/pipeline/features/columnResizeWidth.js +11 -4
  39. package/es/table/pipeline/features/contextMenu.js +78 -31
  40. package/es/table/pipeline/features/filter/Filter.js +74 -37
  41. package/es/table/pipeline/features/index.d.ts +1 -0
  42. package/es/table/pipeline/features/index.js +2 -1
  43. package/es/table/pipeline/features/multiSelect.js +85 -79
  44. package/es/table/pipeline/features/rangeSelection.d.ts +10 -0
  45. package/es/table/pipeline/features/rangeSelection.js +231 -0
  46. package/es/table/pipeline/features/rowDetail.js +39 -16
  47. package/es/table/pipeline/features/rowGrouping.js +2 -1
  48. package/es/table/pipeline/features/singleSelect.js +4 -1
  49. package/es/table/pipeline/features/sort.js +2 -3
  50. package/es/table/pipeline/features/treeMode.js +4 -4
  51. package/es/table/pipeline/pipeline.d.ts +8 -0
  52. package/es/table/pipeline/pipeline.js +49 -5
  53. package/es/table/pivot/cross-table/buildCrossTable.js +1 -2
  54. package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +1 -2
  55. package/es/table/pivot/pivot-utils/builders.js +1 -2
  56. package/es/table/pivot/pivot-utils/convert-utils.js +5 -4
  57. package/es/table/transforms/autoWidth.js +1 -2
  58. package/es/table/transforms/sort.js +1 -2
  59. package/es/table/transforms/treeMode.js +1 -2
  60. package/es/table/utils/applyTransforms.js +1 -3
  61. package/es/table/utils/browserType.d.ts +6 -0
  62. package/es/table/utils/browserType.js +6 -0
  63. package/es/table/utils/buildTree.js +4 -5
  64. package/es/table/utils/collectNodes.js +1 -2
  65. package/es/table/utils/exportTableAsExcel.js +1 -2
  66. package/es/table/utils/getTreeDepth.js +1 -2
  67. package/es/table/utils/groupBy.js +1 -2
  68. package/es/table/utils/index.d.ts +1 -0
  69. package/es/table/utils/index.js +2 -1
  70. package/es/table/utils/layeredSort.js +5 -2
  71. package/es/table/utils/makeRecursiveMapper.js +4 -5
  72. package/es/table/utils/others.d.ts +1 -1
  73. package/es/table/utils/others.js +20 -14
  74. package/es/table/utils/traverseColumn.js +1 -2
  75. package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +4 -5
  76. package/es/table/utils/tree-data-helpers/TreeDataHelper.js +4 -5
  77. package/lib/_utils/formatUtil.js +1 -1
  78. package/lib/_utils/hooks.js +2 -4
  79. package/lib/_utils/numberUtil.js +7 -9
  80. package/lib/_utils/usePopper.js +9 -1
  81. package/lib/config-provider/configProvider.js +9 -1
  82. package/lib/config-provider/index.js +5 -5
  83. package/lib/locale/index.js +14 -6
  84. package/lib/locale/locale.js +2 -4
  85. package/lib/table/base/calculations.js +4 -6
  86. package/lib/table/base/empty.js +11 -3
  87. package/lib/table/base/header.d.ts +6 -2
  88. package/lib/table/base/header.js +39 -19
  89. package/lib/table/base/helpers/SpanManager.js +1 -1
  90. package/lib/table/base/helpers/TableDOMUtils.d.ts +3 -0
  91. package/lib/table/base/helpers/TableDOMUtils.js +21 -5
  92. package/lib/table/base/helpers/getRichVisibleRectsStream.d.ts +23 -0
  93. package/lib/table/base/helpers/getRichVisibleRectsStream.js +246 -0
  94. package/lib/table/base/html-table.d.ts +3 -1
  95. package/lib/table/base/html-table.js +44 -26
  96. package/lib/table/base/index.js +4 -4
  97. package/lib/table/base/interfaces.d.ts +1 -0
  98. package/lib/table/base/renderTemplates.d.ts +1 -0
  99. package/lib/table/base/renderTemplates.js +370 -0
  100. package/lib/table/base/styles.d.ts +24 -0
  101. package/lib/table/base/styles.js +42 -13
  102. package/lib/table/base/table.d.ts +12 -4
  103. package/lib/table/base/table.js +191 -137
  104. package/lib/table/base/utils.d.ts +6 -3
  105. package/lib/table/base/utils.js +47 -10
  106. package/lib/table/common-views.js +3 -3
  107. package/lib/table/pipeline/features/autoFill.js +9 -2
  108. package/lib/table/pipeline/features/columnDrag.js +168 -59
  109. package/lib/table/pipeline/features/columnFilter.js +6 -9
  110. package/lib/table/pipeline/features/columnResizeWidth.d.ts +3 -0
  111. package/lib/table/pipeline/features/columnResizeWidth.js +21 -5
  112. package/lib/table/pipeline/features/contextMenu.js +89 -32
  113. package/lib/table/pipeline/features/filter/DefaultFilterContent.js +10 -2
  114. package/lib/table/pipeline/features/filter/Filter.js +88 -37
  115. package/lib/table/pipeline/features/filter/FilterPanel.js +10 -2
  116. package/lib/table/pipeline/features/filter/index.js +4 -4
  117. package/lib/table/pipeline/features/index.d.ts +1 -0
  118. package/lib/table/pipeline/features/index.js +37 -27
  119. package/lib/table/pipeline/features/multiSelect.js +81 -75
  120. package/lib/table/pipeline/features/rangeSelection.d.ts +10 -0
  121. package/lib/table/pipeline/features/rangeSelection.js +256 -0
  122. package/lib/table/pipeline/features/rowDetail.js +42 -16
  123. package/lib/table/pipeline/features/rowGrouping.js +3 -1
  124. package/lib/table/pipeline/features/singleSelect.js +4 -1
  125. package/lib/table/pipeline/features/sort.js +2 -4
  126. package/lib/table/pipeline/features/treeMode.js +6 -6
  127. package/lib/table/pipeline/index.js +11 -3
  128. package/lib/table/pipeline/pipeline.d.ts +8 -0
  129. package/lib/table/pipeline/pipeline.js +50 -7
  130. package/lib/table/pivot/cross-table/buildCrossTable.js +1 -3
  131. package/lib/table/pivot/cross-table/index.js +4 -4
  132. package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +1 -3
  133. package/lib/table/pivot/pivot-utils/builders.js +2 -4
  134. package/lib/table/pivot/pivot-utils/convert-utils.js +7 -5
  135. package/lib/table/pivot/pivot-utils/index.js +4 -4
  136. package/lib/table/transforms/autoWidth.js +10 -4
  137. package/lib/table/transforms/columnResize.js +10 -2
  138. package/lib/table/transforms/index.js +32 -32
  139. package/lib/table/transforms/sort.js +10 -4
  140. package/lib/table/transforms/treeMode.js +9 -3
  141. package/lib/table/utils/applyTransforms.js +1 -5
  142. package/lib/table/utils/browserType.d.ts +6 -0
  143. package/lib/table/utils/browserType.js +13 -0
  144. package/lib/table/utils/buildTree.js +1 -3
  145. package/lib/table/utils/collectNodes.js +1 -3
  146. package/lib/table/utils/copyToClipboard.js +1 -1
  147. package/lib/table/utils/element.js +3 -3
  148. package/lib/table/utils/exportTableAsExcel.js +1 -3
  149. package/lib/table/utils/getTreeDepth.js +1 -3
  150. package/lib/table/utils/groupBy.js +1 -3
  151. package/lib/table/utils/index.d.ts +1 -0
  152. package/lib/table/utils/index.js +57 -49
  153. package/lib/table/utils/layeredSort.js +6 -2
  154. package/lib/table/utils/makeRecursiveMapper.js +1 -3
  155. package/lib/table/utils/others.d.ts +1 -1
  156. package/lib/table/utils/others.js +23 -18
  157. package/lib/table/utils/traverseColumn.js +1 -3
  158. package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +5 -7
  159. package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +5 -7
  160. package/package.json +6 -2
  161. package/dist/kd-table.css +0 -422
  162. package/dist/kd-table.css.map +0 -1
  163. package/dist/kd-table.js +0 -38578
  164. package/dist/kd-table.js.map +0 -1
  165. package/dist/kd-table.min.css +0 -9
  166. package/dist/kd-table.min.js +0 -208
  167. package/dist/kd-table.min.js.map +0 -1
  168. package/es/table/base/helpers/__test__/visible-part.test.d.ts +0 -1
  169. package/es/table/base/helpers/__test__/visible-part.test.js +0 -28
  170. package/es/table/base/helpers/visible-part.d.ts +0 -23
  171. package/es/table/base/helpers/visible-part.js +0 -58
  172. package/es/table/pipeline/features/__test__/multiSelect.test.d.ts +0 -1
  173. package/es/table/pipeline/features/__test__/multiSelect.test.js +0 -152
  174. package/es/table/pipeline/features/__test__/rowDetail.test.d.ts +0 -1
  175. package/es/table/pipeline/features/__test__/rowDetail.test.js +0 -223
  176. package/es/table/pipeline/features/__test__/rowGrouping.test.d.ts +0 -1
  177. package/es/table/pipeline/features/__test__/rowGrouping.test.js +0 -120
  178. package/es/table/pipeline/features/__test__/singleSelect.test.d.ts +0 -1
  179. package/es/table/pipeline/features/__test__/singleSelect.test.js +0 -191
  180. package/es/table/pipeline/features/__test__/sort.test.d.ts +0 -1
  181. package/es/table/pipeline/features/__test__/sort.test.js +0 -213
  182. package/es/table/pipeline/features/__test__/tips.test.d.ts +0 -1
  183. package/es/table/pipeline/features/__test__/tips.test.js +0 -123
  184. package/es/table/pipeline/features/__test__/treeMode.test.d.ts +0 -1
  185. package/es/table/pipeline/features/__test__/treeMode.test.js +0 -202
  186. package/es/table/pipeline/features/filter/__test__/Filter.test.d.ts +0 -1
  187. package/es/table/pipeline/features/filter/__test__/Filter.test.js +0 -29
  188. package/lib/table/base/helpers/__test__/visible-part.test.d.ts +0 -1
  189. package/lib/table/base/helpers/__test__/visible-part.test.js +0 -31
  190. package/lib/table/base/helpers/visible-part.d.ts +0 -23
  191. package/lib/table/base/helpers/visible-part.js +0 -72
  192. package/lib/table/pipeline/features/__test__/multiSelect.test.d.ts +0 -1
  193. package/lib/table/pipeline/features/__test__/multiSelect.test.js +0 -163
  194. package/lib/table/pipeline/features/__test__/rowDetail.test.d.ts +0 -1
  195. package/lib/table/pipeline/features/__test__/rowDetail.test.js +0 -230
  196. package/lib/table/pipeline/features/__test__/rowGrouping.test.d.ts +0 -1
  197. package/lib/table/pipeline/features/__test__/rowGrouping.test.js +0 -129
  198. package/lib/table/pipeline/features/__test__/singleSelect.test.d.ts +0 -1
  199. package/lib/table/pipeline/features/__test__/singleSelect.test.js +0 -201
  200. package/lib/table/pipeline/features/__test__/sort.test.d.ts +0 -1
  201. package/lib/table/pipeline/features/__test__/sort.test.js +0 -218
  202. package/lib/table/pipeline/features/__test__/tips.test.d.ts +0 -1
  203. package/lib/table/pipeline/features/__test__/tips.test.js +0 -133
  204. package/lib/table/pipeline/features/__test__/treeMode.test.d.ts +0 -1
  205. package/lib/table/pipeline/features/__test__/treeMode.test.js +0 -206
  206. package/lib/table/pipeline/features/filter/__test__/Filter.test.d.ts +0 -1
  207. package/lib/table/pipeline/features/filter/__test__/Filter.test.js +0 -36
@@ -1,38 +1,50 @@
1
1
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
2
2
  import _extends from "@babel/runtime-corejs3/helpers/extends";
3
+ import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
3
4
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
- import { makeRecursiveMapper, mergeCellProps, collectNodes } from '../../utils';
5
+ import { makeRecursiveMapper, mergeCellProps, collectNodes, isLeafNode } from '../../utils';
5
6
  import { FILL_COLUMN_CODE } from './autoFill';
6
7
  var stateKey = 'columnDrag';
8
+ var SCROLL_SIZE = 30;
7
9
 
8
- function sortColumns(cloumns, sort) {
9
- var res = new Array(cloumns.length);
10
+ function sortColumns(columns, sort) {
11
+ var res = new Array(columns.length);
10
12
 
11
- while (cloumns.length) {
12
- var cloumn = cloumns.pop();
13
+ var lastColumns = _toConsumableArray(columns);
14
+
15
+ while (columns.length) {
16
+ var cloumn = columns.pop();
13
17
  res[sort[cloumn.code]] = cloumn;
14
18
  }
15
19
 
20
+ if (_filterInstanceProperty(res).call(res, Boolean).length !== lastColumns.length) {
21
+ return lastColumns;
22
+ }
23
+
16
24
  return res;
17
25
  }
18
26
 
27
+ function stopClickPropagation(e) {
28
+ e.stopPropagation();
29
+ }
30
+
19
31
  export function columnDrag() {
20
32
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21
33
  return function (pipeline) {
22
34
  var _pipeline$getStateAtK = pipeline.getStateAtKey(stateKey, {}),
23
- cloumnsSortData = _pipeline$getStateAtK.cloumnsSortData,
24
35
  cloumnsTranslateData = _pipeline$getStateAtK.cloumnsTranslateData;
25
36
 
26
37
  var columns = pipeline.getColumns();
27
-
28
- if (cloumnsSortData) {
29
- columns = sortColumns(columns, cloumnsSortData);
30
- }
38
+ var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody; // if (cloumnsSortData) {
39
+ // columns = sortColumns(columns, cloumnsSortData)
40
+ // }
31
41
 
32
42
  pipeline.columns(_filterInstanceProperty(columns).call(columns, function (column) {
33
43
  return column;
34
44
  }));
35
- return pipeline.mapColumns(makeRecursiveMapper(function (col) {
45
+ return pipeline.mapColumns(makeRecursiveMapper(function (col, recursiveFlatMapInfo) {
46
+ var path = recursiveFlatMapInfo.path,
47
+ isLeaf = recursiveFlatMapInfo.isLeaf;
36
48
  var style = cloumnsTranslateData ? {
37
49
  transition: '.3s',
38
50
  transform: "translate3d(".concat(cloumnsTranslateData[col.code], "px, 0px, 0px)")
@@ -48,7 +60,7 @@ export function columnDrag() {
48
60
  });
49
61
  },
50
62
  headerCellProps: mergeCellProps(col.headerCellProps, {
51
- onMouseDown: function onMouseDown(e) {
63
+ onMouseDown: !isLeaf || path.length > 1 ? undefined : function (e) {
52
64
  if (e.button !== 0) {
53
65
  return;
54
66
  } // const cx = e.clientX
@@ -65,46 +77,60 @@ export function columnDrag() {
65
77
  var columns = pipeline.getColumns();
66
78
 
67
79
  var _pipeline$getStateAtK2 = pipeline.getStateAtKey(stateKey, {}),
68
- cloumnsSortData = _pipeline$getStateAtK2.cloumnsSortData,
69
80
  cloumnsTranslateData = _pipeline$getStateAtK2.cloumnsTranslateData;
70
81
 
71
- if (cloumnsSortData) {
72
- columns = sortColumns(columns, cloumnsSortData);
73
- } else {
74
- cloumnsSortData = {};
75
- columns.forEach(function (item, index) {
76
- cloumnsSortData[item.code] = index;
77
- });
78
- }
79
-
82
+ var cloumnsSortData = {};
83
+ columns.forEach(function (item, index) {
84
+ cloumnsSortData[item.code] = index;
85
+ });
80
86
  var currentTarget = e.currentTarget;
81
87
  var rect = e.currentTarget.parentElement.getClientRects()[0];
82
88
  var startX = rect.left;
83
89
  var moveData = [];
90
+ var allColumns = collectNodes(columns);
91
+ var tableBodyClientRect = tableBody.getBoundingClientRect();
92
+ var startScrollLeft = pipeline.ref.current.domHelper.virtual.scrollLeft;
93
+
94
+ var updateScrollPosition = function updateScrollPosition(client) {
95
+ var clientX = client.clientX;
96
+ var left = tableBodyClientRect.left,
97
+ width = tableBodyClientRect.width;
98
+
99
+ if (clientX + SCROLL_SIZE >= left + width) {
100
+ pipeline.ref.current.domHelper.virtual.scrollLeft += SCROLL_SIZE;
101
+ }
102
+
103
+ if (clientX - SCROLL_SIZE <= left) {
104
+ pipeline.ref.current.domHelper.virtual.scrollLeft -= SCROLL_SIZE;
105
+ }
106
+ };
107
+
108
+ var stopClickPropagationFlag = false;
84
109
 
85
110
  function handleMouseMove(e) {
86
- if (e.clientX - startX < 20) {
111
+ var client = {
112
+ clientX: e.clientX,
113
+ clientY: e.clientY
114
+ };
115
+ var scrollDistance = pipeline.ref.current.domHelper.virtual.scrollLeft - startScrollLeft;
116
+ var leftPosition = startX - scrollDistance; // 表头最左边起点
117
+
118
+ updateScrollPosition(client);
119
+
120
+ if (e.clientX - leftPosition < 20) {
87
121
  return;
88
122
  } else {
123
+ // 阻止列头点击事件,防止拖动后触发列头过滤事件
124
+ if (stopClickPropagationFlag === false) {
125
+ stopClickPropagationFlag = true;
126
+ currentTarget.addEventListener('click', stopClickPropagation);
127
+ }
128
+
89
129
  e.stopPropagation();
90
130
  }
91
131
 
92
132
  document.body.style.userSelect = 'none';
93
- currentTarget.style.cursor = 'move'; // 计算平移位置
94
-
95
- var replaceIndex = 0;
96
- var totalWitdth = columns[replaceIndex].width;
97
-
98
- while (totalWitdth < e.clientX - startX && replaceIndex < columns.length - 1) {
99
- replaceIndex++;
100
- totalWitdth += columns[replaceIndex].width;
101
- } // 重置位置信息
102
-
103
-
104
- cloumnsTranslateData = {};
105
- columns.forEach(function (item) {
106
- cloumnsTranslateData[item.code] = 0;
107
- }); // 循环计算每一个的位置
133
+ currentTarget.style.cursor = 'move'; // 循环计算每一个的位置
108
134
  // if (startIndex !== replaceIndex) {
109
135
  // const optionColumn = columns[startIndex]
110
136
  // const move = startIndex > replaceIndex ? 1 : -1
@@ -126,11 +152,24 @@ export function columnDrag() {
126
152
  // }
127
153
  // index++
128
154
  // }
129
- // 需要取最新startIndex, 不能直接用makeRecursiveMapper提供的startIndex(因为map时还没添加选择列、充满列等后面use添加的列)
155
+ // 重置位置信息
156
+
157
+ cloumnsTranslateData = {};
158
+ allColumns.forEach(function (item) {
159
+ cloumnsTranslateData[item.code] = 0;
160
+ }); // 计算平移位置
161
+
162
+ var replaceIndex = 0;
163
+ var totalWitdth = getColumnWidth(columns[replaceIndex]);
164
+
165
+ while (totalWitdth < e.clientX - leftPosition && replaceIndex < columns.length - 1) {
166
+ replaceIndex++;
167
+ totalWitdth += getColumnWidth(columns[replaceIndex]);
168
+ } // 需要取最新startIndex, 不能直接用makeRecursiveMapper提供的startIndex(因为map时还没添加选择列、充满列等后面use添加的列)
169
+
130
170
 
131
171
  var startIndex;
132
- var leafColumns = collectNodes(collectNodes(columns, 'leaf-only'));
133
- leafColumns.forEach(function (column, index) {
172
+ columns.forEach(function (column, index) {
134
173
  if (column.code === col.code) {
135
174
  startIndex = index;
136
175
  }
@@ -141,11 +180,25 @@ export function columnDrag() {
141
180
  if (startIndex > replaceIndex) {
142
181
  // 左移
143
182
  while (index < startIndex) {
144
- var code = columns[index].code;
145
-
146
- if (code && code !== FILL_COLUMN_CODE && !columns[index].lock) {
183
+ var _columns$index = columns[index],
184
+ code = _columns$index.code,
185
+ lock = _columns$index.lock,
186
+ width = _columns$index.width,
187
+ children = _columns$index.children;
188
+
189
+ if (enableMove({
190
+ code: code,
191
+ lock: lock
192
+ })) {
147
193
  cloumnsTranslateData[code] += optionColumn.width;
148
- cloumnsTranslateData[optionColumn.code] -= columns[index].width;
194
+
195
+ if (isLeafNode(columns[index])) {
196
+ cloumnsTranslateData[optionColumn.code] -= width;
197
+ } else {
198
+ cloumnsTranslateData[optionColumn.code] -= getColumnWidth(columns[index]);
199
+ moveAllChildren(children, cloumnsTranslateData, optionColumn.width);
200
+ }
201
+
149
202
  columnMoved = true;
150
203
  }
151
204
 
@@ -154,22 +207,34 @@ export function columnDrag() {
154
207
  } else if (startIndex < replaceIndex) {
155
208
  // 右移
156
209
  while (startIndex < index) {
157
- var _code = columns[index].code;
158
-
159
- if (_code && _code !== FILL_COLUMN_CODE && !columns[index].lock) {
210
+ var _columns$index2 = columns[index],
211
+ _code = _columns$index2.code,
212
+ _lock = _columns$index2.lock,
213
+ _width = _columns$index2.width,
214
+ _children = _columns$index2.children;
215
+
216
+ if (enableMove({
217
+ code: _code,
218
+ lock: _lock
219
+ })) {
160
220
  cloumnsTranslateData[_code] -= optionColumn.width;
161
- cloumnsTranslateData[optionColumn.code] += columns[index].width;
221
+
222
+ if (isLeafNode(columns[index])) {
223
+ cloumnsTranslateData[optionColumn.code] += _width;
224
+ } else {
225
+ cloumnsTranslateData[optionColumn.code] += getColumnWidth(columns[index]);
226
+ moveAllChildren(_children, cloumnsTranslateData, optionColumn.width, true);
227
+ }
228
+
162
229
  columnMoved = true;
163
230
  }
164
231
 
165
232
  index--;
166
233
  }
167
- } else {// 不动或者移动回原位
168
234
  }
169
235
 
170
236
  window.requestAnimationFrame(function () {
171
237
  pipeline.setStateAtKey(stateKey, {
172
- cloumnsSortData: cloumnsSortData,
173
238
  cloumnsTranslateData: cloumnsTranslateData
174
239
  });
175
240
  moveData = [startIndex, replaceIndex];
@@ -181,6 +246,11 @@ export function columnDrag() {
181
246
  document.body.removeEventListener('mousemove', handleMouseMove);
182
247
  document.body.removeEventListener('mouseup', handleMouseUp);
183
248
  window.requestAnimationFrame(function () {
249
+ // 取消阻止列头点击事件
250
+ currentTarget.removeEventListener('click', stopClickPropagation);
251
+ stopClickPropagationFlag = false;
252
+ currentTarget = null;
253
+
184
254
  var _moveData = moveData,
185
255
  _moveData2 = _slicedToArray(_moveData, 2),
186
256
  startIndex = _moveData2[0],
@@ -200,9 +270,14 @@ export function columnDrag() {
200
270
  if (startIndex > replaceIndex) {
201
271
  // 左移
202
272
  while (index < startIndex) {
203
- var code = columns[index].code;
204
-
205
- if (code && code !== FILL_COLUMN_CODE && !columns[index].lock) {
273
+ var _columns$index3 = columns[index],
274
+ code = _columns$index3.code,
275
+ lock = _columns$index3.lock;
276
+
277
+ if (enableMove({
278
+ code: code,
279
+ lock: lock
280
+ })) {
206
281
  cloumnsSortData[code] += 1;
207
282
  cloumnsSortData[optionColumn.code] -= 1;
208
283
  columnMoved = true;
@@ -213,9 +288,14 @@ export function columnDrag() {
213
288
  } else if (startIndex < replaceIndex) {
214
289
  // 右移
215
290
  while (index > startIndex) {
216
- var _code2 = columns[index].code;
217
-
218
- if (_code2 && _code2 !== FILL_COLUMN_CODE && !columns[index].lock) {
291
+ var _columns$index4 = columns[index],
292
+ _code2 = _columns$index4.code,
293
+ _lock2 = _columns$index4.lock;
294
+
295
+ if (enableMove({
296
+ code: _code2,
297
+ lock: _lock2
298
+ })) {
219
299
  cloumnsSortData[_code2] -= 1;
220
300
  cloumnsSortData[optionColumn.code] += 1;
221
301
  columnMoved = true;
@@ -240,14 +320,12 @@ export function columnDrag() {
240
320
  }
241
321
 
242
322
  pipeline.setStateAtKey(stateKey, {
243
- cloumnsSortData: cloumnsSortData,
244
323
  cloumnsTranslateData: null
245
324
  });
246
325
  });
247
326
  document.body.style.userSelect = '';
248
327
  currentTarget.style.opacity = '';
249
328
  currentTarget.style.cursor = '';
250
- currentTarget = null;
251
329
  }
252
330
 
253
331
  document.body.addEventListener('mousemove', handleMouseMove);
@@ -262,4 +340,35 @@ export function columnDrag() {
262
340
  });
263
341
  }));
264
342
  };
343
+ }
344
+
345
+ function enableMove(_ref2) {
346
+ var lock = _ref2.lock,
347
+ code = _ref2.code;
348
+ return code && code !== FILL_COLUMN_CODE && !lock;
349
+ }
350
+
351
+ function getColumnWidth(col) {
352
+ if (col.children) {
353
+ return col.children.reduce(function (acc, col) {
354
+ return acc + getColumnWidth(col);
355
+ }, 0);
356
+ }
357
+
358
+ return col.width;
359
+ }
360
+
361
+ function moveAllChildren(cols, cloumnsTranslateData, width, isMinus) {
362
+ cols.forEach(function (col) {
363
+ var _a;
364
+
365
+ var code = col.code,
366
+ children = col.children;
367
+ var movedWidth = (_a = cloumnsTranslateData[code]) !== null && _a !== void 0 ? _a : 0;
368
+ cloumnsTranslateData[code] = movedWidth + (isMinus ? -width : width);
369
+
370
+ if (!isLeafNode(col)) {
371
+ moveAllChildren(children, cloumnsTranslateData, width);
372
+ }
373
+ });
265
374
  }
@@ -8,11 +8,10 @@ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
8
8
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
9
9
  import _valuesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/values";
10
10
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
11
- import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
12
11
  import React from 'react';
13
12
  import cx from 'classnames';
14
13
  import { internals } from '../../internals';
15
- import { isLeafNode, mergeCellProps, collectNodes } from '../../utils';
14
+ import { isLeafNode, collectNodes } from '../../utils';
16
15
  import { Filter, DEFAULT_FILTER_OPTIONS } from './filter';
17
16
  import { Classes } from '../../base/styles';
18
17
  var stateKey = 'filter';
@@ -94,12 +93,11 @@ export function filter() {
94
93
  isFilterActive: filterActive,
95
94
  className: cx((_cx = {}, _defineProperty(_cx, Classes.tableFilterTrigger, true), _defineProperty(_cx, "active", filterActive), _cx)),
96
95
  stopClickEventPropagation: stopClickEventPropagation
97
- })]);
98
- result.headerCellProps = mergeCellProps(col.headerCellProps, {
99
- style: {
100
- paddingRight: '18px'
101
- }
102
- });
96
+ })]); // result.headerCellProps = mergeCellProps(col.headerCellProps, {
97
+ // style: {
98
+ // paddingRight: '18px'
99
+ // }
100
+ // })
103
101
  }
104
102
 
105
103
  if (!isLeafNode(col)) {
@@ -157,7 +155,7 @@ export function filter() {
157
155
  });
158
156
  }
159
157
 
160
- return _reduceInstanceProperty(dataSource).call(dataSource, function (pre, record) {
158
+ return dataSource.reduce(function (pre, record) {
161
159
  if (isMatchedFilterCondition(record)) {
162
160
  return _concatInstanceProperty(pre).call(pre, [record]);
163
161
  }
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+ import { ArtColumn } from '../../interfaces';
1
3
  import { TablePipeline } from '../pipeline';
2
4
  interface ColumnSize {
3
5
  [key: string]: number;
@@ -14,6 +16,7 @@ export interface ColumnResizeOptions {
14
16
  fallbackSize?: number;
15
17
  /** 列的最大宽度,默认为 1000 */
16
18
  maxSize?: number;
19
+ doubleClickCallback?(e: React.MouseEvent<HTMLSpanElement>, col: ArtColumn): void;
17
20
  onChangeSize?(nextSize: ColumnSize): void;
18
21
  afterChangeSize?(nextSize: ColumnSize, changedColumnSize: ChangedColumnSize[]): void;
19
22
  }
@@ -3,7 +3,6 @@ import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplat
3
3
 
4
4
  var _templateObject, _templateObject2;
5
5
 
6
- import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
7
6
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
8
7
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
9
8
  import React from 'react';
@@ -74,6 +73,10 @@ export function columnResize() {
74
73
  });
75
74
  };
76
75
 
76
+ var handleDoubleClick = function handleDoubleClick(e, col) {
77
+ opts === null || opts === void 0 ? void 0 : opts.doubleClickCallback(e, col);
78
+ };
79
+
77
80
  var handleMouseDown = function handleMouseDown(e, col) {
78
81
  window.addEventListener('selectstart', disableSelect);
79
82
  var changedColumnSize = {};
@@ -92,12 +95,10 @@ export function columnResize() {
92
95
 
93
96
  if ((children === null || children === void 0 ? void 0 : children.length) > 0) {
94
97
  var leafChildColumns = collectNodes(children, 'leaf-only');
95
-
96
- var childrenWidthSum = _reduceInstanceProperty(leafChildColumns).call(leafChildColumns, function (sum, _ref2) {
98
+ var childrenWidthSum = leafChildColumns.reduce(function (sum, _ref2) {
97
99
  var code = _ref2.code;
98
100
  return sum + columnSize[code];
99
101
  }, 0);
100
-
101
102
  leafChildColumns.forEach(function (_ref3, index) {
102
103
  var code = _ref3.code;
103
104
  var startSize = columnSize[code];
@@ -155,11 +156,17 @@ export function columnResize() {
155
156
  width: (_a = columnSize[code]) !== null && _a !== void 0 ? _a : width,
156
157
  title: /*#__PURE__*/React.createElement(React.Fragment, null, prevTitle, (features === null || features === void 0 ? void 0 : features.resizeable) !== false && (isGroup ? /*#__PURE__*/React.createElement(TableHeaderGroupCellResize, {
157
158
  className: Classes.tableHeaderCellResize,
159
+ onDoubleClick: function onDoubleClick(e) {
160
+ return handleDoubleClick(e, col);
161
+ },
158
162
  onMouseDown: function onMouseDown(e) {
159
163
  return handleMouseDown(e, col);
160
164
  }
161
165
  }) : /*#__PURE__*/React.createElement(TableHeaderCellResize, {
162
166
  className: Classes.tableHeaderCellResize,
167
+ onDoubleClick: function onDoubleClick(e) {
168
+ return handleDoubleClick(e, col);
169
+ },
163
170
  onMouseDown: function onMouseDown(e) {
164
171
  return handleMouseDown(e, col);
165
172
  }
@@ -1,13 +1,16 @@
1
+ import _createClass from "@babel/runtime-corejs3/helpers/createClass";
1
2
  import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
3
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
4
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
3
5
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
4
6
  import React, { useRef, useEffect } from 'react';
5
7
  import ReactDOM from 'react-dom';
8
+ import cx from 'classnames';
6
9
  import { ContextMenuStyleWrap } from '../../common-views';
7
10
  import { copyDataToClipboard, executeOnTempElement, console, getEventPath, isElementInEventPath, getTargetEleInEventPath } from '../../utils';
8
11
  import { findByTree } from '../../utils/others';
9
12
  import { internals } from '../../internals';
10
- import { MenuClasses } from '../../base/styles';
13
+ import { Classes, MenuClasses } from '../../base/styles';
11
14
  var stateKey = 'contextMenu';
12
15
  export function contextMenu() {
13
16
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -45,6 +48,10 @@ export function contextMenu() {
45
48
  };
46
49
 
47
50
  var onContextMenu = function onContextMenu(e) {
51
+ if (suppressShowContextMenu(e)) {
52
+ return;
53
+ }
54
+
48
55
  e.preventDefault();
49
56
  showContextMenu(e);
50
57
  };
@@ -53,7 +60,7 @@ export function contextMenu() {
53
60
  onContextMenu: onContextMenu
54
61
  });
55
62
 
56
- var getContextMenuOptions = function getContextMenuOptions(record, column, value) {
63
+ var getContextMenuOptions = function getContextMenuOptions(record, column, value, event) {
57
64
  var defaultMenuOptions = [];
58
65
 
59
66
  if (column) {
@@ -64,7 +71,8 @@ export function contextMenu() {
64
71
  var params = {
65
72
  record: record,
66
73
  column: column,
67
- value: value
74
+ value: value,
75
+ event: event
68
76
  };
69
77
  return opts.getContextMenuItems(params);
70
78
  }
@@ -81,24 +89,29 @@ export function contextMenu() {
81
89
  };
82
90
 
83
91
  var showContextMenu = function showContextMenu(e) {
84
- var dataSource = pipeline.getDataSource();
85
- var cellEle = getCellEleForEvent(e);
92
+ var path = getEventPath(e);
93
+ var cellEle = getCellEleInEventPath(path);
86
94
  var code;
87
95
  var rowIndex;
96
+ var isInFooter;
88
97
 
89
98
  if (cellEle) {
90
- code = cellEle.getAttribute('data-code'), rowIndex = cellEle.getAttribute('data-rowindex');
99
+ code = cellEle.getAttribute('data-code');
100
+ rowIndex = cellEle.getAttribute('data-rowindex');
101
+ isInFooter = isElementInsideTheFooter(cellEle);
91
102
  } else {
92
- var rowEle = getRowEleForEvent(e, dataSource);
103
+ var rowEle = getRowEleInEventPath(path);
93
104
  rowIndex = rowEle === null || rowEle === void 0 ? void 0 : rowEle.getAttribute('data-rowindex');
105
+ isInFooter = isElementInsideTheFooter(rowEle);
94
106
  }
95
107
 
108
+ var dataSource = isInFooter ? pipeline.getFooterDataSource() || [] : pipeline.getDataSource();
96
109
  var record = dataSource[rowIndex];
97
- var column = code !== undefined && findByTree(pipeline.getColumns(), function (item, index) {
98
- return item.code === code ? index : -1;
110
+ var column = code !== undefined && findByTree(pipeline.getColumns(), function (item) {
111
+ return item.code === code;
99
112
  });
100
113
  var value = column && record && internals.safeGetValue(column, record, rowIndex);
101
- var options = getContextMenuOptions(record, column, value);
114
+ var options = getContextMenuOptions(record, column, value, e);
102
115
 
103
116
  if (options.length === 0) {
104
117
  console.warn('context menu options is empty');
@@ -180,6 +193,7 @@ function Menu(props) {
180
193
  }),
181
194
  name: item.name,
182
195
  action: item.action,
196
+ disabled: item.disabled,
183
197
  hideContextMenu: hideContextMenu
184
198
  });
185
199
  })));
@@ -193,6 +207,10 @@ function MenuItem(props) {
193
207
  var itemRef = useRef();
194
208
 
195
209
  var handleClick = function handleClick() {
210
+ if (disabled) {
211
+ return;
212
+ }
213
+
196
214
  hideContextMenu();
197
215
  typeof action === 'function' && action();
198
216
  };
@@ -224,7 +242,7 @@ function MenuItem(props) {
224
242
  };
225
243
 
226
244
  return /*#__PURE__*/React.createElement("div", {
227
- className: MenuClasses.menuOption,
245
+ className: cx(MenuClasses.menuOption, _defineProperty({}, MenuClasses.menuOptionDisable, disabled)),
228
246
  ref: itemRef,
229
247
  onClick: handleClick,
230
248
  onMouseEnter: handleMouseEnter,
@@ -234,7 +252,7 @@ function MenuItem(props) {
234
252
  }, name));
235
253
  }
236
254
 
237
- var MenuHelper = function MenuHelper() {
255
+ var MenuHelper = /*#__PURE__*/_createClass(function MenuHelper() {
238
256
  var _this = this;
239
257
 
240
258
  _classCallCheck(this, MenuHelper);
@@ -247,7 +265,7 @@ var MenuHelper = function MenuHelper() {
247
265
  _this.hidePopup && _this.hidePopup();
248
266
  _this.hidePopup = null;
249
267
  };
250
- };
268
+ });
251
269
  /** 是否点击是外部 start */
252
270
 
253
271
 
@@ -262,18 +280,6 @@ function isEventFromCurrentPopup(event, ele) {
262
280
 
263
281
  return false;
264
282
  }
265
-
266
- function getCellEleInEventPath(path) {
267
- return getTargetEleInEventPath(path, function (ele) {
268
- return ele && ele.getAttribute('data-role') === 'table-cell';
269
- });
270
- }
271
-
272
- function getRowEleInEventPath(path) {
273
- return getTargetEleInEventPath(path, function (ele) {
274
- return ele && ele.getAttribute('data-role') === 'table-row';
275
- });
276
- }
277
283
  /** 是否点击是外部 end */
278
284
 
279
285
  /** 计算位置 start */
@@ -331,13 +337,13 @@ function keepWithinBounds(popupParent, ePopup, x, y) {
331
337
  var minWidth = Math.min(ePopupRect.width, 120);
332
338
  ePopup.style.minWidth = minWidth + 'px';
333
339
  var maxX = parentWidth - minWidth;
334
- x = Math.min(Math.max(x, 0), Math.abs(maxX)); //目前位置,最大支持的位置
340
+ x = Math.min(Math.max(x, 0), Math.abs(maxX)); // 目前位置,最大支持的位置
335
341
  }
336
342
 
337
343
  if (y) {
338
344
  var minHeight = Math.min(ePopupRect.height, 180);
339
345
  var maxY = parentHeight - minHeight;
340
- y = Math.min(Math.max(y, 0), Math.abs(maxY)); //目前位置,最大支持的位置
346
+ y = Math.min(Math.max(y, 0), Math.abs(maxY)); // 目前位置,最大支持的位置
341
347
  }
342
348
 
343
349
  return {
@@ -350,16 +356,57 @@ function keepWithinBounds(popupParent, ePopup, x, y) {
350
356
  /** 获得点击的元素 start */
351
357
 
352
358
 
353
- function getCellEleForEvent(event) {
354
- return getCellEleInEventPath(getEventPath(event));
359
+ function getCellEleInEventPath(path) {
360
+ return getTargetEleInEventPath(path, function (ele) {
361
+ return ele && ele.getAttribute('data-role') === 'table-cell';
362
+ });
355
363
  }
356
364
 
357
- function getRowEleForEvent(event, dataSource) {
358
- return getRowEleInEventPath(getEventPath(event));
365
+ function getRowEleInEventPath(path) {
366
+ return getTargetEleInEventPath(path, function (ele) {
367
+ return ele && ele.getAttribute('data-role') === 'table-row';
368
+ });
359
369
  }
360
370
  /** 获得点击的元素 end */
361
371
 
362
372
 
373
+ function isElementInsideTheFooter(ele) {
374
+ var pointer = ele;
375
+
376
+ while (pointer) {
377
+ if (pointer.tagName === 'TFOOT') {
378
+ return true;
379
+ }
380
+
381
+ if (pointer.tagName === 'TABLE' || pointer.tagName === 'TBODY') {
382
+ return false;
383
+ }
384
+
385
+ pointer = pointer.parentElement;
386
+ }
387
+
388
+ return false;
389
+ } // 禁止弹出右键菜单
390
+
391
+
392
+ function suppressShowContextMenu(e) {
393
+ var path = getEventPath(e.nativeEvent);
394
+ var pointIndex = 0;
395
+
396
+ while (pointIndex < path.length) {
397
+ var ele = path[pointIndex];
398
+
399
+ if (ele.classList.contains(Classes.tableBody) || ele.classList.contains(Classes.tableFooter)) {
400
+ return false;
401
+ }
402
+
403
+ pointIndex++;
404
+ }
405
+
406
+ return true;
407
+ } // 默认选项
408
+
409
+
363
410
  function getCopyItem(v) {
364
411
  return {
365
412
  name: '复制',