@kdcloudjs/table 1.2.0-canary.15 → 1.2.0-canary.16-hotfix

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 (233) hide show
  1. package/dist/@kdcloudjs/table.css +1 -1
  2. package/dist/@kdcloudjs/table.js +2051 -3489
  3. package/dist/@kdcloudjs/table.js.map +1 -1
  4. package/dist/@kdcloudjs/table.min.css +1 -1
  5. package/dist/@kdcloudjs/table.min.js +16 -16
  6. package/dist/@kdcloudjs/table.min.js.map +1 -1
  7. package/es/_utils/arrayUtil.js +0 -3
  8. package/es/_utils/devwarning.js +0 -1
  9. package/es/_utils/formatUtil.js +35 -96
  10. package/es/_utils/hooks.js +18 -42
  11. package/es/_utils/index.js +0 -2
  12. package/es/_utils/numberUtil.js +32 -55
  13. package/es/_utils/omit.js +0 -2
  14. package/es/_utils/type.js +0 -2
  15. package/es/_utils/usePopper.js +74 -137
  16. package/es/config-provider/compDefaultProps.js +0 -1
  17. package/es/config-provider/configProvider.js +2 -7
  18. package/es/config-provider/defaultConfig.js +0 -1
  19. package/es/index.js +0 -2
  20. package/es/locale/locale.js +5 -43
  21. package/es/table/base/calculations.js +22 -72
  22. package/es/table/base/colgroup.js +0 -1
  23. package/es/table/base/empty.js +4 -4
  24. package/es/table/base/header.js +14 -67
  25. package/es/table/base/helpers/SpanManager.js +3 -9
  26. package/es/table/base/helpers/TableDOMUtils.js +4 -27
  27. package/es/table/base/helpers/__test__/SpanManager.test.js +2 -2
  28. package/es/table/base/helpers/__test__/TableDOMUtils.test.js +0 -1
  29. package/es/table/base/helpers/getRichVisibleRectsStream.js +11 -44
  30. package/es/table/base/helpers/rowHeightManager.js +0 -28
  31. package/es/table/base/html-table.js +14 -35
  32. package/es/table/base/loading.js +6 -8
  33. package/es/table/base/renderTemplates.js +26 -44
  34. package/es/table/base/styles.js +1 -10
  35. package/es/table/base/table.js +96 -179
  36. package/es/table/base/utils.js +14 -54
  37. package/es/table/common-views.js +0 -7
  38. package/es/table/internals.js +0 -13
  39. package/es/table/pipeline/features/autoFill.js +11 -40
  40. package/es/table/pipeline/features/autoRowSpan.js +1 -14
  41. package/es/table/pipeline/features/colGroupExtendable.js +4 -19
  42. package/es/table/pipeline/features/columnDrag.d.ts +1 -0
  43. package/es/table/pipeline/features/columnDrag.js +236 -303
  44. package/es/table/pipeline/features/columnFilter.js +11 -48
  45. package/es/table/pipeline/features/columnHover.js +1 -7
  46. package/es/table/pipeline/features/columnRangeHover.js +1 -8
  47. package/es/table/pipeline/features/columnResizeWidth.js +51 -42
  48. package/es/table/pipeline/features/contextMenu.js +18 -89
  49. package/es/table/pipeline/features/filter/DefaultFilterContent.js +10 -25
  50. package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
  51. package/es/table/pipeline/features/filter/Filter.js +25 -48
  52. package/es/table/pipeline/features/filter/FilterPanel.js +11 -25
  53. package/es/table/pipeline/features/filter/util.js +0 -4
  54. package/es/table/pipeline/features/footerDataSource.js +0 -3
  55. package/es/table/pipeline/features/mergeCellHover.js +0 -1
  56. package/es/table/pipeline/features/multiSelect.js +15 -57
  57. package/es/table/pipeline/features/rangeSelection.js +65 -143
  58. package/es/table/pipeline/features/rowDetail.js +2 -41
  59. package/es/table/pipeline/features/rowDrag.js +36 -71
  60. package/es/table/pipeline/features/rowGrouping.js +2 -35
  61. package/es/table/pipeline/features/singleSelect.js +0 -24
  62. package/es/table/pipeline/features/sort.js +31 -83
  63. package/es/table/pipeline/features/tips.js +0 -6
  64. package/es/table/pipeline/features/treeMode.js +9 -44
  65. package/es/table/pipeline/features/treeSelect.js +0 -26
  66. package/es/table/pipeline/features/utils/touchEventUtils.d.ts +15 -0
  67. package/es/table/pipeline/features/utils/touchEventUtils.js +65 -0
  68. package/es/table/pipeline/pipeline.js +11 -51
  69. package/es/table/pivot/cross-table/buildCrossTable.js +15 -64
  70. package/es/table/pivot/cross-table/cross-table.js +22 -28
  71. package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +14 -47
  72. package/es/table/pivot/cross-tree-table/cross-tree-table.js +28 -50
  73. package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
  74. package/es/table/pivot/pivot-utils/builders.js +31 -71
  75. package/es/table/pivot/pivot-utils/convert-utils.js +13 -39
  76. package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
  77. package/es/table/transforms/autoRowSpan.js +1 -15
  78. package/es/table/transforms/autoWidth.js +10 -32
  79. package/es/table/transforms/buildTree.js +1 -2
  80. package/es/table/transforms/columnHover.js +9 -15
  81. package/es/table/transforms/columnRangeHover.js +12 -19
  82. package/es/table/transforms/columnResize.js +15 -37
  83. package/es/table/transforms/flatten.js +0 -3
  84. package/es/table/transforms/orderField.js +0 -3
  85. package/es/table/transforms/sort.js +36 -88
  86. package/es/table/transforms/tips.js +1 -6
  87. package/es/table/transforms/treeMode.js +30 -69
  88. package/es/table/transforms/visible.js +0 -2
  89. package/es/table/use/useResizeObserver.js +1 -4
  90. package/es/table/utils/applyTransforms.js +0 -1
  91. package/es/table/utils/buildTree.js +4 -19
  92. package/es/table/utils/collectNodes.js +1 -10
  93. package/es/table/utils/console.js +0 -14
  94. package/es/table/utils/copyToClipboard.js +0 -4
  95. package/es/table/utils/element.js +14 -41
  96. package/es/table/utils/exportTableAsExcel.js +4 -40
  97. package/es/table/utils/getTreeDepth.js +1 -9
  98. package/es/table/utils/groupBy.js +1 -10
  99. package/es/table/utils/layeredFilter.js +0 -4
  100. package/es/table/utils/layeredSort.js +0 -5
  101. package/es/table/utils/makeRecursiveMapper.js +1 -12
  102. package/es/table/utils/mergeCellProps.js +6 -13
  103. package/es/table/utils/others.js +3 -16
  104. package/es/table/utils/proto.js +2 -30
  105. package/es/table/utils/smartCompare.js +4 -12
  106. package/es/table/utils/traverseColumn.js +2 -15
  107. package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +1 -22
  108. package/es/table/utils/tree-data-helpers/TreeDataHelper.js +15 -69
  109. package/lib/_utils/arrayUtil.js +0 -5
  110. package/lib/_utils/devwarning.js +0 -5
  111. package/lib/_utils/formatUtil.js +35 -100
  112. package/lib/_utils/hooks.js +18 -53
  113. package/lib/_utils/index.js +0 -6
  114. package/lib/_utils/numberUtil.js +32 -63
  115. package/lib/_utils/omit.js +0 -5
  116. package/lib/_utils/react-children.js +0 -5
  117. package/lib/_utils/type.js +0 -6
  118. package/lib/_utils/usePopper.js +74 -158
  119. package/lib/config-provider/ConfigContext.js +1 -4
  120. package/lib/config-provider/compDefaultProps.js +0 -1
  121. package/lib/config-provider/configProvider.js +3 -18
  122. package/lib/config-provider/defaultConfig.js +0 -5
  123. package/lib/config-provider/index.js +0 -6
  124. package/lib/index.js +2 -8
  125. package/lib/locale/index.js +0 -7
  126. package/lib/locale/locale.js +5 -57
  127. package/lib/table/base/calculations.js +22 -83
  128. package/lib/table/base/colgroup.js +0 -5
  129. package/lib/table/base/empty.js +4 -16
  130. package/lib/table/base/header.js +14 -77
  131. package/lib/table/base/helpers/SpanManager.js +3 -11
  132. package/lib/table/base/helpers/TableDOMUtils.js +2 -27
  133. package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
  134. package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
  135. package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
  136. package/lib/table/base/helpers/getRichVisibleRectsStream.js +11 -62
  137. package/lib/table/base/helpers/rowHeightManager.js +0 -33
  138. package/lib/table/base/html-table.js +14 -45
  139. package/lib/table/base/index.js +0 -2
  140. package/lib/table/base/loading.js +6 -12
  141. package/lib/table/base/renderTemplates.js +27 -58
  142. package/lib/table/base/styles.js +1 -22
  143. package/lib/table/base/table.js +96 -212
  144. package/lib/table/base/utils.js +14 -89
  145. package/lib/table/common-views.js +0 -16
  146. package/lib/table/index.js +0 -13
  147. package/lib/table/internals.js +0 -14
  148. package/lib/table/pipeline/features/autoFill.js +11 -47
  149. package/lib/table/pipeline/features/autoRowSpan.js +1 -19
  150. package/lib/table/pipeline/features/buildTree.js +0 -2
  151. package/lib/table/pipeline/features/colGroupExtendable.js +4 -32
  152. package/lib/table/pipeline/features/columnDrag.d.ts +1 -0
  153. package/lib/table/pipeline/features/columnDrag.js +236 -309
  154. package/lib/table/pipeline/features/columnFilter.js +11 -62
  155. package/lib/table/pipeline/features/columnHover.js +1 -11
  156. package/lib/table/pipeline/features/columnRangeHover.js +1 -13
  157. package/lib/table/pipeline/features/columnResizeWidth.js +51 -58
  158. package/lib/table/pipeline/features/contextMenu.js +18 -113
  159. package/lib/table/pipeline/features/filter/DefaultFilterContent.js +10 -43
  160. package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
  161. package/lib/table/pipeline/features/filter/Filter.js +25 -70
  162. package/lib/table/pipeline/features/filter/FilterPanel.js +11 -40
  163. package/lib/table/pipeline/features/filter/index.js +0 -5
  164. package/lib/table/pipeline/features/filter/util.js +0 -7
  165. package/lib/table/pipeline/features/footerDataSource.js +0 -10
  166. package/lib/table/pipeline/features/index.js +0 -23
  167. package/lib/table/pipeline/features/mergeCellHover.js +0 -5
  168. package/lib/table/pipeline/features/multiSelect.js +15 -71
  169. package/lib/table/pipeline/features/rangeSelection.js +65 -160
  170. package/lib/table/pipeline/features/rowDetail.js +2 -65
  171. package/lib/table/pipeline/features/rowDrag.js +36 -81
  172. package/lib/table/pipeline/features/rowGrouping.js +2 -55
  173. package/lib/table/pipeline/features/singleSelect.js +0 -34
  174. package/lib/table/pipeline/features/sort.js +31 -103
  175. package/lib/table/pipeline/features/tips.js +0 -15
  176. package/lib/table/pipeline/features/treeMode.js +9 -65
  177. package/lib/table/pipeline/features/treeSelect.js +0 -34
  178. package/lib/table/pipeline/features/utils/touchEventUtils.d.ts +15 -0
  179. package/lib/table/pipeline/features/utils/touchEventUtils.js +76 -0
  180. package/lib/table/pipeline/index.js +0 -8
  181. package/lib/table/pipeline/pipeline.js +11 -60
  182. package/lib/table/pivot/cross-table/buildCrossTable.js +15 -75
  183. package/lib/table/pivot/cross-table/cross-table.js +22 -36
  184. package/lib/table/pivot/cross-table/index.js +0 -4
  185. package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +14 -60
  186. package/lib/table/pivot/cross-tree-table/cross-tree-table.js +28 -60
  187. package/lib/table/pivot/cross-tree-table/index.js +0 -3
  188. package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
  189. package/lib/table/pivot/pivot-utils/builders.js +31 -82
  190. package/lib/table/pivot/pivot-utils/convert-utils.js +13 -57
  191. package/lib/table/pivot/pivot-utils/index.js +0 -7
  192. package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
  193. package/lib/table/style/css.js +0 -1
  194. package/lib/table/style/index.js +0 -1
  195. package/lib/table/transforms/autoRowSpan.js +1 -21
  196. package/lib/table/transforms/autoWidth.js +10 -53
  197. package/lib/table/transforms/buildTree.js +1 -4
  198. package/lib/table/transforms/columnHover.js +9 -22
  199. package/lib/table/transforms/columnRangeHover.js +12 -27
  200. package/lib/table/transforms/columnResize.js +15 -56
  201. package/lib/table/transforms/flatten.js +0 -5
  202. package/lib/table/transforms/index.js +0 -12
  203. package/lib/table/transforms/orderField.js +0 -7
  204. package/lib/table/transforms/sort.js +36 -112
  205. package/lib/table/transforms/tips.js +1 -16
  206. package/lib/table/transforms/treeMode.js +30 -96
  207. package/lib/table/transforms/visible.js +0 -7
  208. package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
  209. package/lib/table/use/useResizeObserver.js +1 -8
  210. package/lib/table/utils/applyTransforms.js +0 -2
  211. package/lib/table/utils/buildTree.js +4 -30
  212. package/lib/table/utils/collectNodes.js +1 -15
  213. package/lib/table/utils/console.js +0 -16
  214. package/lib/table/utils/copyToClipboard.js +0 -6
  215. package/lib/table/utils/element.js +14 -46
  216. package/lib/table/utils/exportTableAsExcel.js +4 -49
  217. package/lib/table/utils/getTreeDepth.js +1 -14
  218. package/lib/table/utils/groupBy.js +1 -14
  219. package/lib/table/utils/index.js +0 -21
  220. package/lib/table/utils/isGroupColumn.js +0 -3
  221. package/lib/table/utils/isLeafNode.js +0 -1
  222. package/lib/table/utils/layeredFilter.js +0 -10
  223. package/lib/table/utils/layeredSort.js +0 -10
  224. package/lib/table/utils/makeRecursiveMapper.js +1 -21
  225. package/lib/table/utils/mergeCellProps.js +6 -17
  226. package/lib/table/utils/others.js +3 -31
  227. package/lib/table/utils/proto.js +2 -33
  228. package/lib/table/utils/selectColumn.js +0 -1
  229. package/lib/table/utils/smartCompare.js +4 -13
  230. package/lib/table/utils/traverseColumn.js +2 -22
  231. package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +1 -30
  232. package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +15 -82
  233. package/package.json +2 -1
@@ -38,43 +38,35 @@ var defaultRowDragColumn = {
38
38
  export function rowDrag(opt) {
39
39
  return function rowDragStep(pipeline) {
40
40
  var _context;
41
-
42
41
  var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
43
42
  var artTable = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.artTable;
44
43
  if (!tableBody) return pipeline;
45
44
  var dataSource = pipeline.getDataSource();
46
45
  var rowHeight = (opt === null || opt === void 0 ? void 0 : opt.rowHeight) || 48;
47
-
48
46
  var handleDragStrat = function handleDragStrat(event) {
49
- var _a; // 开始拖拽
50
-
51
-
47
+ var _a;
48
+ // 开始拖拽
52
49
  artTable.classList.add(cx(Classes.rowDragging));
53
50
  (_a = opt === null || opt === void 0 ? void 0 : opt.onDragStart) === null || _a === void 0 ? void 0 : _a.call(opt, event);
54
51
  };
55
-
56
52
  var handleDragMove = function handleDragMove(event) {
57
53
  var _a;
58
-
59
54
  (_a = opt === null || opt === void 0 ? void 0 : opt.onDragMove) === null || _a === void 0 ? void 0 : _a.call(opt, event);
60
55
  pipeline.setStateAtKey(rowDragKey, event);
61
56
  };
62
-
63
57
  var handleDragEnd = function handleDragEnd(event, isOutOfRange) {
64
58
  var _a;
65
-
66
59
  artTable.classList.remove(cx(Classes.rowDragging));
67
- pipeline.setStateAtKey(rowDragKey, event); // 超出拖拽范围不触发dragend事件
68
-
60
+ pipeline.setStateAtKey(rowDragKey, event);
61
+ // 超出拖拽范围不触发dragend事件
69
62
  if (!isOutOfRange) {
70
63
  (_a = opt === null || opt === void 0 ? void 0 : opt.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(opt, event);
71
64
  }
72
65
  };
73
-
74
66
  var getDragEvent = function getDragEvent(startRowInfo, endRowInfo, _ref) {
75
67
  var isFinished = _ref.isFinished,
76
- _ref$dragPosition = _ref.dragPosition,
77
- dragPosition = _ref$dragPosition === void 0 ? 'bottom' : _ref$dragPosition;
68
+ _ref$dragPosition = _ref.dragPosition,
69
+ dragPosition = _ref$dragPosition === void 0 ? 'bottom' : _ref$dragPosition;
78
70
  return {
79
71
  startRowIndex: startRowInfo.rowIndex,
80
72
  startRow: startRowInfo.row,
@@ -84,31 +76,26 @@ export function rowDrag(opt) {
84
76
  isFinished: isFinished
85
77
  };
86
78
  };
87
-
88
79
  var updateScrollPosition = function updateScrollPosition(mouseMoveEvent) {
89
80
  if (opt === null || opt === void 0 ? void 0 : opt.suppressScrollMove) return;
90
81
  var clientY = mouseMoveEvent.clientY;
91
82
  var tableBodyClientRect = tableBody.getBoundingClientRect();
92
83
  var top = tableBodyClientRect.top,
93
- height = tableBodyClientRect.height;
94
-
84
+ height = tableBodyClientRect.height;
95
85
  if (clientY + SCROLL_OFFSET >= top + height) {
96
86
  pipeline.ref.current.domHelper.tableBody.scrollTop += SCROLL_OFFSET;
97
87
  }
98
-
99
88
  if (clientY + SCROLL_OFFSET <= top) {
100
89
  pipeline.ref.current.domHelper.tableBody.scrollTop -= SCROLL_OFFSET;
101
90
  }
102
91
  };
103
-
104
92
  var onMouseDown = function onMouseDown(mouseDownEvent) {
105
93
  var _a;
106
-
107
94
  var startRowInfo = getTargetRowInfo(mouseDownEvent.target, tableBody, dataSource);
108
95
  var endRowInfo = startRowInfo;
109
96
  if (!startRowInfo || startRowInfo.code !== rowDragColumn.code) return;
110
- if ((_a = opt === null || opt === void 0 ? void 0 : opt.isDisabled) === null || _a === void 0 ? void 0 : _a.call(opt, startRowInfo.row, startRowInfo.rowIndex)) return; // 默认拖拽插入的位置是向下
111
-
97
+ if ((_a = opt === null || opt === void 0 ? void 0 : opt.isDisabled) === null || _a === void 0 ? void 0 : _a.call(opt, startRowInfo.row, startRowInfo.rowIndex)) return;
98
+ // 默认拖拽插入的位置是向下
112
99
  var dragPosition = 'bottom';
113
100
  var isOutOfRange = false;
114
101
  var dragStartEvent = getDragEvent(startRowInfo, endRowInfo, {
@@ -117,11 +104,11 @@ export function rowDrag(opt) {
117
104
  });
118
105
  handleDragStrat(dragStartEvent);
119
106
  var tableWidth = tableBody.clientWidth;
120
- var startRowRects = startRowInfo.cell.getBoundingClientRect(); // 光标位置距离初始拖拽行的偏移量
121
-
107
+ var startRowRects = startRowInfo.cell.getBoundingClientRect();
108
+ // 光标位置距离初始拖拽行的偏移量
122
109
  var startOffset = mouseDownEvent.clientY - startRowRects.y;
123
- var dragElement = createDragElement(startRowRects, tableWidth, rowHeight); // 可拖拽的范围
124
-
110
+ var dragElement = createDragElement(startRowRects, tableWidth, rowHeight);
111
+ // 可拖拽的范围
125
112
  var dragRange = getDragRange(tableBody, {
126
113
  startOffset: startOffset,
127
114
  rowHeight: startRowRects.height
@@ -130,15 +117,13 @@ export function rowDrag(opt) {
130
117
  var mouseup$ = fromEvent(window, 'mouseup');
131
118
  var rowDrag$ = mousemove$.pipe(map(function (mouseMoveEvent) {
132
119
  var clientX = mouseMoveEvent.clientX,
133
- clientY = mouseMoveEvent.clientY;
120
+ clientY = mouseMoveEvent.clientY;
134
121
  var tagretRow = getTargetRowInfo(mouseMoveEvent.target, tableBody, dataSource);
135
-
136
122
  if (tagretRow) {
137
123
  endRowInfo = tagretRow;
138
124
  }
139
-
140
- var targetRowRects = endRowInfo.cell.getBoundingClientRect(); // 判断拖拽插入的位置,拖拽框上边框位于目标行之上则向上插入,否则向下插入
141
-
125
+ var targetRowRects = endRowInfo.cell.getBoundingClientRect();
126
+ // 判断拖拽插入的位置,拖拽框上边框位于目标行之上则向上插入,否则向下插入
142
127
  var isMoveToTop = clientY - startOffset < targetRowRects.y;
143
128
  dragPosition = isMoveToTop ? 'top' : 'bottom';
144
129
  isOutOfRange = isOutOfDragRange({
@@ -146,7 +131,6 @@ export function rowDrag(opt) {
146
131
  y: clientY
147
132
  }, dragRange);
148
133
  updateScrollPosition(mouseMoveEvent); // 拖拽到底时让滚动条可以滚动
149
-
150
134
  updateDragElementPosition(dragElement, dragRange, {
151
135
  x: clientX,
152
136
  y: clientY,
@@ -162,8 +146,8 @@ export function rowDrag(opt) {
162
146
  rowDrag$.subscribe({
163
147
  next: function next(_ref2) {
164
148
  var startRowInfo = _ref2.startRowInfo,
165
- endRowInfo = _ref2.endRowInfo,
166
- dragPosition = _ref2.dragPosition;
149
+ endRowInfo = _ref2.endRowInfo,
150
+ dragPosition = _ref2.dragPosition;
167
151
  var dragMoveEvent = getDragEvent(startRowInfo, endRowInfo, {
168
152
  isFinished: false,
169
153
  dragPosition: dragPosition
@@ -181,12 +165,9 @@ export function rowDrag(opt) {
181
165
  }
182
166
  });
183
167
  };
184
-
185
168
  var rowDragColumn = (opt === null || opt === void 0 ? void 0 : opt.rowDragColumn) || defaultRowDragColumn;
186
169
  pipeline.setFeatureOptions('rowDragColumnKey', rowDragColumn.code);
187
-
188
170
  var nextColumns = _sliceInstanceProperty(_context = pipeline.getColumns()).call(_context);
189
-
190
171
  nextColumns.unshift(rowDragColumn);
191
172
  pipeline.columns(nextColumns);
192
173
  pipeline.addTableProps({
@@ -194,12 +175,11 @@ export function rowDrag(opt) {
194
175
  });
195
176
  pipeline.appendRowPropsGetter(function (row, rowIndex) {
196
177
  var _cx;
197
-
198
178
  var rowDragEvent = pipeline.getStateAtKey(rowDragKey) || {};
199
179
  var startRowIndex = rowDragEvent.startRowIndex,
200
- endRowIndex = rowDragEvent.endRowIndex,
201
- isFinished = rowDragEvent.isFinished,
202
- dragPosition = rowDragEvent.dragPosition;
180
+ endRowIndex = rowDragEvent.endRowIndex,
181
+ isFinished = rowDragEvent.isFinished,
182
+ dragPosition = rowDragEvent.dragPosition;
203
183
  var isFooterCell = row[pipeline.getFeatureOptions('footerRowMetaKey')];
204
184
  if (isFooterCell || isFinished || rowIndex !== startRowIndex && rowIndex !== endRowIndex) return;
205
185
  var className = cx((_cx = {}, _defineProperty(_cx, Classes.rowDragStart, rowIndex === startRowIndex), _defineProperty(_cx, Classes.rowDragEnd, rowIndex === endRowIndex), _defineProperty(_cx, Classes.rowDragEndToTop, rowIndex === endRowIndex && dragPosition === 'top'), _defineProperty(_cx, Classes.rowDragEndToBottom, rowIndex === endRowIndex && dragPosition === 'bottom'), _cx));
@@ -210,7 +190,6 @@ export function rowDrag(opt) {
210
190
  return pipeline;
211
191
  };
212
192
  }
213
-
214
193
  function getTargetRowInfo(target, tableBody, record) {
215
194
  while (target && tableBody.contains(target)) {
216
195
  if (target.getAttribute('data-role') === 'table-cell') {
@@ -226,41 +205,33 @@ function getTargetRowInfo(target, tableBody, record) {
226
205
  cell: target
227
206
  };
228
207
  }
229
-
230
208
  target = target.parentElement;
231
209
  }
232
-
233
210
  return null;
234
211
  }
235
-
236
212
  function isEleInFooter(target) {
237
213
  while (target && !target.classList.contains(Classes.artTable)) {
238
214
  if (target.classList.contains(Classes.tableFooter)) {
239
215
  return true;
240
216
  }
241
-
242
217
  target = target.parentElement;
243
218
  }
244
-
245
219
  return false;
246
220
  }
247
-
248
221
  function createDragElement(rects, tableWidth, rowHeight) {
249
222
  var _context2, _context3, _context4;
250
-
251
223
  var x = rects.x,
252
- y = rects.y;
224
+ y = rects.y;
253
225
  var dragMoveElement = document.createElement('div');
254
226
  dragMoveElement.className = cx(Classes.rowDragElement);
255
227
  dragMoveElement.style.cssText = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "position:fixed;z-index:9999;left:".concat(x, "px;top:")).call(_context4, y, "px;pointer-events:none;width:")).call(_context3, tableWidth, "px;height:")).call(_context2, rowHeight, "px;background:var(--primary-color);opacity: 0.1;");
256
228
  document.body.appendChild(dragMoveElement);
257
229
  return dragMoveElement;
258
230
  }
259
-
260
231
  function updateDragElementPosition(element, dragRange, _ref3) {
261
232
  var x = _ref3.x,
262
- y = _ref3.y,
263
- startOffset = _ref3.startOffset;
233
+ y = _ref3.y,
234
+ startOffset = _ref3.startOffset;
264
235
  var validPosition = getValidPosition({
265
236
  x: x,
266
237
  y: y
@@ -268,11 +239,9 @@ function updateDragElementPosition(element, dragRange, _ref3) {
268
239
  element.style.top = validPosition.y - startOffset + 'px';
269
240
  return element;
270
241
  }
271
-
272
242
  function removeDragElement(element) {
273
243
  document.body.removeChild(element);
274
244
  }
275
-
276
245
  function updateCurSorStyle(isOutOfRange) {
277
246
  if (isOutOfRange) {
278
247
  document.body.style.cursor = 'no-drop';
@@ -280,19 +249,17 @@ function updateCurSorStyle(isOutOfRange) {
280
249
  document.body.style.cursor = 'move';
281
250
  }
282
251
  }
283
-
284
252
  function removeCurSorStyle() {
285
253
  document.body.style.cursor = 'default';
286
254
  }
287
-
288
255
  function getDragRange(tableBody, _ref4) {
289
256
  var startOffset = _ref4.startOffset,
290
- rowHeight = _ref4.rowHeight;
257
+ rowHeight = _ref4.rowHeight;
291
258
  var tableBodyClientRect = tableBody.getBoundingClientRect();
292
259
  var height = tableBodyClientRect.height,
293
- width = tableBodyClientRect.width,
294
- x = tableBodyClientRect.x,
295
- y = tableBodyClientRect.y;
260
+ width = tableBodyClientRect.width,
261
+ x = tableBodyClientRect.x,
262
+ y = tableBodyClientRect.y;
296
263
  return {
297
264
  minX: x,
298
265
  maxX: x + width,
@@ -300,14 +267,13 @@ function getDragRange(tableBody, _ref4) {
300
267
  maxY: y + height + startOffset
301
268
  };
302
269
  }
303
-
304
270
  function getValidPosition(position, dragRange) {
305
271
  var x = position.x,
306
- y = position.y;
272
+ y = position.y;
307
273
  var minX = dragRange.minX,
308
- maxX = dragRange.maxX,
309
- minY = dragRange.minY,
310
- maxY = dragRange.maxY;
274
+ maxX = dragRange.maxX,
275
+ minY = dragRange.minY,
276
+ maxY = dragRange.maxY;
311
277
  var newX = x < minX ? minX : x > maxX ? maxX : x;
312
278
  var newY = y < minY ? minY : y > maxY ? maxY : y;
313
279
  return {
@@ -315,13 +281,12 @@ function getValidPosition(position, dragRange) {
315
281
  y: newY
316
282
  };
317
283
  }
318
-
319
284
  function isOutOfDragRange(position, dragRange) {
320
285
  var x = position.x,
321
- y = position.y;
286
+ y = position.y;
322
287
  var minX = dragRange.minX,
323
- maxX = dragRange.maxX,
324
- minY = dragRange.minY,
325
- maxY = dragRange.maxY;
288
+ maxX = dragRange.maxX,
289
+ minY = dragRange.minY,
290
+ maxY = dragRange.maxY;
326
291
  return x > maxX || x < minX || y > maxY || y < minY;
327
292
  }
@@ -15,15 +15,12 @@ import { internals } from '../../internals';
15
15
  import { collectNodes, isLeafNode, mergeCellProps } from '../../utils';
16
16
  import { flatMap } from '../../utils/others';
17
17
  import { Classes } from '../../base';
18
-
19
18
  var groupingMetaSymbol = _Symbol('row-grouping-meta');
20
-
21
19
  function attachGroupingMeta(row) {
22
20
  return _extends(_defineProperty({}, groupingMetaSymbol, {
23
21
  expandable: !isLeafNode(row)
24
22
  }), row);
25
23
  }
26
-
27
24
  function getGroupingMeta(row) {
28
25
  if (row[groupingMetaSymbol] == null) {
29
26
  return {
@@ -31,13 +28,11 @@ function getGroupingMeta(row) {
31
28
  expandable: false
32
29
  };
33
30
  }
34
-
35
31
  return {
36
32
  isGroupHeader: true,
37
33
  expandable: row[groupingMetaSymbol].expandable
38
34
  };
39
35
  }
40
-
41
36
  function rowGroupingRowPropsGetter(row) {
42
37
  if (getGroupingMeta(row).isGroupHeader) {
43
38
  return {
@@ -45,74 +40,56 @@ function rowGroupingRowPropsGetter(row) {
45
40
  };
46
41
  }
47
42
  }
48
-
49
43
  export function rowGrouping() {
50
44
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
51
45
  return function (pipeline) {
52
46
  var _context;
53
-
54
47
  var _a, _b, _c;
55
-
56
48
  var stateKey = 'rowGrouping';
57
49
  var indents = pipeline.ctx.indents;
58
50
  var textOffset = indents.iconIndent + indents.iconWidth + indents.iconGap;
59
51
  var primaryKey = pipeline.ensurePrimaryKey('rowGrouping');
60
-
61
52
  if (typeof primaryKey !== 'string') {
62
53
  throw new Error('rowGrouping 仅支持字符串作为 primaryKey');
63
54
  }
64
-
65
55
  var openKeys = (_c = (_b = (_a = opts.openKeys) !== null && _a !== void 0 ? _a : pipeline.getStateAtKey(stateKey)) !== null && _b !== void 0 ? _b : opts.defaultOpenAll ? _mapInstanceProperty(_context = pipeline.getDataSource()).call(_context, function (row) {
66
56
  return row[primaryKey];
67
57
  }) : opts.defaultOpenKeys) !== null && _c !== void 0 ? _c : [];
68
58
  var openKeySet = new _Set(openKeys);
69
-
70
59
  var onChangeOpenKeys = function onChangeOpenKeys(nextKeys, key, action) {
71
60
  var _a;
72
-
73
61
  (_a = opts.onChangeOpenKeys) === null || _a === void 0 ? void 0 : _a.call(opts, nextKeys, key, action);
74
62
  pipeline.setStateAtKey(stateKey, nextKeys, {
75
63
  key: key,
76
64
  action: action
77
65
  });
78
66
  };
79
-
80
67
  return pipeline.mapDataSource(processDataSource).mapColumns(processColumns).appendRowPropsGetter(rowGroupingRowPropsGetter);
81
-
82
68
  function processDataSource(input) {
83
69
  return flatMap(input, function (row) {
84
70
  var result = [attachGroupingMeta(row)];
85
71
  var expanded = openKeySet.has(row[primaryKey]);
86
-
87
72
  if (expanded) {
88
73
  if (Array.isArray(row.children)) {
89
74
  result = _concatInstanceProperty(result).call(result, row.children);
90
75
  }
91
76
  }
92
-
93
77
  return result;
94
78
  });
95
79
  }
96
-
97
80
  function processColumns(columns) {
98
81
  var _context3;
99
-
100
82
  if (columns.length === 0) {
101
83
  return columns;
102
84
  }
103
-
104
85
  var columnFlatCount = collectNodes(columns, 'leaf-only').length;
105
-
106
86
  var _columns = _toArray(columns),
107
- firstCol = _columns[0],
108
- others = _sliceInstanceProperty(_columns).call(_columns, 1);
109
-
87
+ firstCol = _columns[0],
88
+ others = _sliceInstanceProperty(_columns).call(_columns, 1);
110
89
  var render = function render(value, row, rowIndex) {
111
90
  var _a, _b;
112
-
113
91
  var content = internals.safeRender(firstCol, row, rowIndex);
114
92
  var meta = getGroupingMeta(row);
115
-
116
93
  if (!meta.isGroupHeader || !meta.expandable) {
117
94
  var marginLeft = textOffset + (meta.isGroupHeader ? 0 : indents.indentSize);
118
95
  return /*#__PURE__*/React.createElement(InlineFlexCell, {
@@ -121,7 +98,6 @@ export function rowGrouping() {
121
98
  }
122
99
  }, meta.isGroupHeader ? (_a = row.groupTitle) !== null && _a !== void 0 ? _a : content : content);
123
100
  }
124
-
125
101
  var expanded = openKeySet.has(row[primaryKey]);
126
102
  var expandCls = expanded ? Classes.expanded : Classes.collapsed;
127
103
  return /*#__PURE__*/React.createElement(ExpansionCell, {
@@ -134,39 +110,31 @@ export function rowGrouping() {
134
110
  }
135
111
  }), (_b = row.groupTitle) !== null && _b !== void 0 ? _b : content);
136
112
  };
137
-
138
113
  var getCellProps = function getCellProps(value, row, rowIndex) {
139
114
  var _a;
140
-
141
115
  var meta = getGroupingMeta(row);
142
-
143
116
  if (!meta.isGroupHeader) {
144
117
  return;
145
118
  }
146
-
147
119
  var expandable = meta.expandable;
148
120
  var rowKey = row[primaryKey];
149
121
  var expanded = openKeySet.has(rowKey);
150
122
  var onClick;
151
-
152
123
  if (expandable) {
153
124
  onClick = function onClick(e) {
154
125
  if (opts.stopClickEventPropagation) {
155
126
  e.stopPropagation();
156
127
  }
157
-
158
128
  if (expanded) {
159
129
  onChangeOpenKeys(_filterInstanceProperty(openKeys).call(openKeys, function (key) {
160
130
  return key !== rowKey;
161
131
  }), rowKey, 'collapse');
162
132
  } else {
163
133
  var _context2;
164
-
165
134
  onChangeOpenKeys(_concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(openKeys), [rowKey]), rowKey, 'expand');
166
135
  }
167
136
  };
168
137
  }
169
-
170
138
  var prevProps = (_a = firstCol.getCellProps) === null || _a === void 0 ? void 0 : _a.call(firstCol, value, row, rowIndex);
171
139
  return mergeCellProps(prevProps, {
172
140
  onClick: onClick,
@@ -175,7 +143,6 @@ export function rowGrouping() {
175
143
  }
176
144
  });
177
145
  };
178
-
179
146
  return _concatInstanceProperty(_context3 = [_extends(_extends({}, firstCol), {
180
147
  title: /*#__PURE__*/React.createElement("div", {
181
148
  style: {
@@ -9,28 +9,21 @@ export function singleSelect() {
9
9
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10
10
  return function singleSelectStep(pipeline) {
11
11
  var _context;
12
-
13
12
  var _a, _b, _c, _d, _e, _f;
14
-
15
13
  var Radio = pipeline.ctx.components.Radio;
16
-
17
14
  if (Radio == null) {
18
15
  throw new Error('使用 singleSelect 之前需要通过 pipeline context 设置 components.Radio');
19
16
  }
20
-
21
17
  var stateKey = 'singleSelect';
22
18
  var clickArea = (_a = opts.clickArea) !== null && _a !== void 0 ? _a : 'radio';
23
19
  var isDisabled = (_b = opts.isDisabled) !== null && _b !== void 0 ? _b : always(false);
24
20
  var primaryKey = pipeline.ensurePrimaryKey('singleSelect');
25
21
  var value = (_d = (_c = opts.value) !== null && _c !== void 0 ? _c : pipeline.getStateAtKey(stateKey)) !== null && _d !== void 0 ? _d : opts.defaultValue;
26
-
27
22
  var onChange = function onChange(rowKey) {
28
23
  var _a;
29
-
30
24
  (_a = opts.onChange) === null || _a === void 0 ? void 0 : _a.call(opts, rowKey);
31
25
  pipeline.setStateAtKey(stateKey, rowKey);
32
26
  };
33
-
34
27
  var radioColumn = _extends(_extends({
35
28
  name: '',
36
29
  width: 50,
@@ -38,9 +31,7 @@ export function singleSelect() {
38
31
  }, opts.radioColumn), {
39
32
  getCellProps: function getCellProps(value, row, rowIndex) {
40
33
  var _a, _b;
41
-
42
34
  var preCellProps = (_b = (_a = opts.radioColumn) === null || _a === void 0 ? void 0 : _a.getCellProps) === null || _b === void 0 ? void 0 : _b.call(_a, value, row, rowIndex);
43
-
44
35
  if (clickArea === 'cell') {
45
36
  var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
46
37
  var disabled = isDisabled(row, rowIndex);
@@ -52,74 +43,59 @@ export function singleSelect() {
52
43
  if (opts.stopClickEventPropagation) {
53
44
  e.stopPropagation();
54
45
  }
55
-
56
46
  onChange(rowKey);
57
47
  }
58
48
  });
59
49
  }
60
-
61
50
  return preCellProps;
62
51
  },
63
52
  render: function render(_, row, rowIndex) {
64
53
  if (row[pipeline.getFeatureOptions('footerRowMetaKey')]) {
65
54
  return null;
66
55
  }
67
-
68
56
  var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
69
57
  return /*#__PURE__*/React.createElement(Radio, {
70
58
  checked: value === rowKey,
71
59
  disabled: isDisabled(row, rowIndex),
72
60
  onChange: clickArea === 'radio' ? function (arg1, arg2) {
73
61
  var _a;
74
-
75
62
  var nativeEvent = (_a = arg2 === null || arg2 === void 0 ? void 0 : arg2.nativeEvent) !== null && _a !== void 0 ? _a : arg1 === null || arg1 === void 0 ? void 0 : arg1.nativeEvent;
76
-
77
63
  if (nativeEvent && opts.stopClickEventPropagation) {
78
64
  nativeEvent.stopPropagation();
79
65
  }
80
-
81
66
  onChange(rowKey);
82
67
  } : undefined
83
68
  });
84
69
  },
85
70
  features: _extends(_extends({}, (_e = opts.radioColumn) === null || _e === void 0 ? void 0 : _e.features), _defineProperty({}, SINGLE_SELECT_MARK_PROPNAME, true))
86
71
  });
87
-
88
72
  var nextColumns = _sliceInstanceProperty(_context = pipeline.getColumns()).call(_context);
89
-
90
73
  var radioPlacement = (_f = opts.radioPlacement) !== null && _f !== void 0 ? _f : 'start';
91
-
92
74
  if (radioPlacement === 'start') {
93
75
  nextColumns.unshift(radioColumn);
94
76
  } else {
95
77
  nextColumns.push(radioColumn);
96
78
  }
97
-
98
79
  pipeline.columns(nextColumns);
99
80
  pipeline.appendRowPropsGetter(function (row, rowIndex) {
100
81
  var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
101
82
  var style = {};
102
83
  var className;
103
84
  var onClick;
104
-
105
85
  if (opts.highlightRowWhenSelected) {
106
86
  if (value === rowKey) {
107
87
  className = 'highlight';
108
88
  }
109
89
  }
110
-
111
90
  if (clickArea === 'row' && !isDisabled(row, rowIndex)) {
112
91
  style.cursor = 'pointer';
113
-
114
92
  onClick = function onClick(e) {
115
93
  if (opts.stopClickEventPropagation) {
116
94
  e.stopPropagation();
117
95
  }
118
-
119
96
  onChange(rowKey);
120
97
  };
121
98
  }
122
-
123
99
  return {
124
100
  className: className,
125
101
  style: style,