@kdcloudjs/table 1.2.1-canary.6 → 1.2.1-canary.7-hotfix.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.
Files changed (251) hide show
  1. package/dist/@kdcloudjs/table.css +1 -1
  2. package/dist/@kdcloudjs/table.css.map +0 -0
  3. package/dist/@kdcloudjs/table.js +1755 -3334
  4. package/dist/@kdcloudjs/table.js.map +1 -1
  5. package/dist/@kdcloudjs/table.min.css +1 -1
  6. package/dist/@kdcloudjs/table.min.js +16 -16
  7. package/dist/@kdcloudjs/table.min.js.map +1 -1
  8. package/dist/default-theme.js +0 -0
  9. package/dist/kd-ui-complete.less +0 -0
  10. package/dist/kd-ui.less +0 -0
  11. package/dist/theme.js +0 -0
  12. package/es/_utils/arrayUtil.js +0 -3
  13. package/es/_utils/devwarning.js +0 -1
  14. package/es/_utils/formatUtil.js +35 -96
  15. package/es/_utils/hooks.js +18 -42
  16. package/es/_utils/index.js +0 -2
  17. package/es/_utils/numberUtil.js +32 -55
  18. package/es/_utils/omit.js +0 -2
  19. package/es/_utils/type.js +0 -2
  20. package/es/_utils/usePopper.js +74 -137
  21. package/es/config-provider/compDefaultProps.js +0 -1
  22. package/es/config-provider/configProvider.js +2 -7
  23. package/es/config-provider/defaultConfig.js +0 -1
  24. package/es/index.js +0 -2
  25. package/es/locale/locale.js +5 -43
  26. package/es/table/base/calculations.js +22 -72
  27. package/es/table/base/colgroup.js +0 -1
  28. package/es/table/base/empty.js +4 -4
  29. package/es/table/base/header.js +16 -69
  30. package/es/table/base/helpers/SpanManager.js +3 -9
  31. package/es/table/base/helpers/TableDOMUtils.js +4 -28
  32. package/es/table/base/helpers/__test__/SpanManager.test.js +2 -2
  33. package/es/table/base/helpers/__test__/TableDOMUtils.test.js +0 -1
  34. package/es/table/base/helpers/getRichVisibleRectsStream.js +13 -45
  35. package/es/table/base/helpers/rowHeightManager.js +0 -28
  36. package/es/table/base/html-table.js +14 -35
  37. package/es/table/base/loading.js +6 -8
  38. package/es/table/base/renderTemplates.js +26 -44
  39. package/es/table/base/styles.js +0 -9
  40. package/es/table/base/table.js +95 -181
  41. package/es/table/base/utils.js +14 -54
  42. package/es/table/common-views.js +0 -7
  43. package/es/table/internals.js +0 -13
  44. package/es/table/pipeline/features/autoFill.js +11 -40
  45. package/es/table/pipeline/features/autoRowSpan.js +1 -14
  46. package/es/table/pipeline/features/colGroupExtendable.js +4 -19
  47. package/es/table/pipeline/features/columnDrag.js +41 -96
  48. package/es/table/pipeline/features/columnFilter.js +11 -48
  49. package/es/table/pipeline/features/columnHover.js +1 -7
  50. package/es/table/pipeline/features/columnRangeHover.js +1 -8
  51. package/es/table/pipeline/features/columnResizeWidth.js +11 -37
  52. package/es/table/pipeline/features/contextMenu.js +18 -89
  53. package/es/table/pipeline/features/filter/DefaultFilterContent.js +10 -25
  54. package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
  55. package/es/table/pipeline/features/filter/Filter.js +25 -48
  56. package/es/table/pipeline/features/filter/FilterPanel.js +11 -25
  57. package/es/table/pipeline/features/filter/util.js +0 -4
  58. package/es/table/pipeline/features/footerDataSource.js +0 -3
  59. package/es/table/pipeline/features/mergeCellHover.js +0 -1
  60. package/es/table/pipeline/features/multiSelect.js +15 -57
  61. package/es/table/pipeline/features/rangeSelection.js +63 -142
  62. package/es/table/pipeline/features/rowDetail.js +2 -41
  63. package/es/table/pipeline/features/rowDrag.js +38 -76
  64. package/es/table/pipeline/features/rowGrouping.js +2 -35
  65. package/es/table/pipeline/features/singleSelect.js +0 -24
  66. package/es/table/pipeline/features/sort.js +32 -89
  67. package/es/table/pipeline/features/tips.js +0 -6
  68. package/es/table/pipeline/features/treeMode.js +14 -46
  69. package/es/table/pipeline/features/treeSelect.js +0 -26
  70. package/es/table/pipeline/pipeline.js +11 -51
  71. package/es/table/pivot/cross-table/buildCrossTable.js +15 -64
  72. package/es/table/pivot/cross-table/cross-table.js +22 -28
  73. package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +14 -47
  74. package/es/table/pivot/cross-tree-table/cross-tree-table.js +28 -50
  75. package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
  76. package/es/table/pivot/pivot-utils/builders.js +31 -71
  77. package/es/table/pivot/pivot-utils/convert-utils.js +13 -39
  78. package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
  79. package/es/table/transforms/autoRowSpan.js +1 -15
  80. package/es/table/transforms/autoWidth.js +10 -32
  81. package/es/table/transforms/buildTree.js +1 -2
  82. package/es/table/transforms/columnHover.js +9 -15
  83. package/es/table/transforms/columnRangeHover.js +12 -19
  84. package/es/table/transforms/columnResize.js +15 -37
  85. package/es/table/transforms/flatten.js +0 -3
  86. package/es/table/transforms/orderField.js +0 -3
  87. package/es/table/transforms/sort.js +36 -93
  88. package/es/table/transforms/tips.js +1 -6
  89. package/es/table/transforms/treeMode.js +30 -69
  90. package/es/table/transforms/visible.js +0 -2
  91. package/es/table/use/useResizeObserver.js +1 -4
  92. package/es/table/utils/applyTransforms.js +0 -1
  93. package/es/table/utils/browserType.js +12 -19
  94. package/es/table/utils/buildTree.js +4 -19
  95. package/es/table/utils/collectNodes.js +1 -10
  96. package/es/table/utils/console.js +0 -14
  97. package/es/table/utils/copyToClipboard.js +0 -4
  98. package/es/table/utils/element.js +14 -41
  99. package/es/table/utils/exportTableAsExcel.js +4 -40
  100. package/es/table/utils/getTreeDepth.js +1 -9
  101. package/es/table/utils/groupBy.js +1 -10
  102. package/es/table/utils/layeredFilter.js +0 -4
  103. package/es/table/utils/layeredSort.js +0 -5
  104. package/es/table/utils/makeRecursiveMapper.js +1 -12
  105. package/es/table/utils/mergeCellProps.js +6 -13
  106. package/es/table/utils/others.js +3 -16
  107. package/es/table/utils/proto.js +2 -30
  108. package/es/table/utils/smartCompare.js +4 -12
  109. package/es/table/utils/traverseColumn.js +2 -15
  110. package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +1 -22
  111. package/es/table/utils/tree-data-helpers/TreeDataHelper.js +15 -69
  112. package/es/table/utils/uiDegrade.js +0 -5
  113. package/lib/_utils/arrayUtil.js +0 -5
  114. package/lib/_utils/devwarning.js +0 -5
  115. package/lib/_utils/formatUtil.js +35 -100
  116. package/lib/_utils/hooks.js +18 -53
  117. package/lib/_utils/index.js +0 -6
  118. package/lib/_utils/numberUtil.js +32 -63
  119. package/lib/_utils/omit.js +0 -5
  120. package/lib/_utils/react-children.js +0 -5
  121. package/lib/_utils/type.js +0 -6
  122. package/lib/_utils/usePopper.js +74 -158
  123. package/lib/config-provider/ConfigContext.js +1 -4
  124. package/lib/config-provider/compDefaultProps.js +0 -1
  125. package/lib/config-provider/configProvider.js +3 -18
  126. package/lib/config-provider/defaultConfig.js +0 -5
  127. package/lib/config-provider/index.js +0 -6
  128. package/lib/index.js +2 -8
  129. package/lib/locale/index.js +0 -7
  130. package/lib/locale/locale.js +5 -57
  131. package/lib/table/base/calculations.js +22 -83
  132. package/lib/table/base/colgroup.js +0 -5
  133. package/lib/table/base/empty.js +4 -16
  134. package/lib/table/base/header.js +16 -79
  135. package/lib/table/base/helpers/SpanManager.js +3 -11
  136. package/lib/table/base/helpers/TableDOMUtils.js +2 -28
  137. package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
  138. package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
  139. package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
  140. package/lib/table/base/helpers/getRichVisibleRectsStream.js +13 -63
  141. package/lib/table/base/helpers/rowHeightManager.js +0 -33
  142. package/lib/table/base/html-table.js +14 -45
  143. package/lib/table/base/index.js +0 -2
  144. package/lib/table/base/loading.js +6 -12
  145. package/lib/table/base/renderTemplates.js +27 -58
  146. package/lib/table/base/styles.js +0 -21
  147. package/lib/table/base/table.js +95 -214
  148. package/lib/table/base/utils.js +14 -89
  149. package/lib/table/common-views.js +0 -16
  150. package/lib/table/index.js +0 -13
  151. package/lib/table/internals.js +0 -14
  152. package/lib/table/pipeline/features/autoFill.js +11 -47
  153. package/lib/table/pipeline/features/autoRowSpan.js +1 -19
  154. package/lib/table/pipeline/features/buildTree.js +0 -2
  155. package/lib/table/pipeline/features/colGroupExtendable.js +4 -32
  156. package/lib/table/pipeline/features/columnDrag.js +41 -102
  157. package/lib/table/pipeline/features/columnFilter.js +11 -62
  158. package/lib/table/pipeline/features/columnHover.js +1 -11
  159. package/lib/table/pipeline/features/columnRangeHover.js +1 -13
  160. package/lib/table/pipeline/features/columnResizeWidth.js +11 -53
  161. package/lib/table/pipeline/features/contextMenu.js +18 -113
  162. package/lib/table/pipeline/features/filter/DefaultFilterContent.js +10 -43
  163. package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
  164. package/lib/table/pipeline/features/filter/Filter.js +25 -70
  165. package/lib/table/pipeline/features/filter/FilterPanel.js +11 -40
  166. package/lib/table/pipeline/features/filter/index.js +0 -5
  167. package/lib/table/pipeline/features/filter/util.js +0 -7
  168. package/lib/table/pipeline/features/footerDataSource.js +0 -10
  169. package/lib/table/pipeline/features/index.js +0 -23
  170. package/lib/table/pipeline/features/mergeCellHover.js +0 -5
  171. package/lib/table/pipeline/features/multiSelect.js +15 -71
  172. package/lib/table/pipeline/features/rangeSelection.js +63 -159
  173. package/lib/table/pipeline/features/rowDetail.js +2 -65
  174. package/lib/table/pipeline/features/rowDrag.js +38 -87
  175. package/lib/table/pipeline/features/rowGrouping.js +2 -55
  176. package/lib/table/pipeline/features/singleSelect.js +0 -34
  177. package/lib/table/pipeline/features/sort.js +31 -108
  178. package/lib/table/pipeline/features/tips.js +0 -15
  179. package/lib/table/pipeline/features/treeMode.js +14 -67
  180. package/lib/table/pipeline/features/treeSelect.js +0 -34
  181. package/lib/table/pipeline/index.js +0 -8
  182. package/lib/table/pipeline/pipeline.js +11 -60
  183. package/lib/table/pivot/cross-table/buildCrossTable.js +15 -75
  184. package/lib/table/pivot/cross-table/cross-table.js +22 -36
  185. package/lib/table/pivot/cross-table/index.js +0 -4
  186. package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +14 -60
  187. package/lib/table/pivot/cross-tree-table/cross-tree-table.js +28 -60
  188. package/lib/table/pivot/cross-tree-table/index.js +0 -3
  189. package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
  190. package/lib/table/pivot/pivot-utils/builders.js +31 -82
  191. package/lib/table/pivot/pivot-utils/convert-utils.js +13 -57
  192. package/lib/table/pivot/pivot-utils/index.js +0 -7
  193. package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
  194. package/lib/table/style/css.js +0 -1
  195. package/lib/table/style/index.js +0 -1
  196. package/lib/table/transforms/autoRowSpan.js +1 -21
  197. package/lib/table/transforms/autoWidth.js +10 -53
  198. package/lib/table/transforms/buildTree.js +1 -4
  199. package/lib/table/transforms/columnHover.js +9 -22
  200. package/lib/table/transforms/columnRangeHover.js +12 -27
  201. package/lib/table/transforms/columnResize.js +15 -56
  202. package/lib/table/transforms/flatten.js +0 -5
  203. package/lib/table/transforms/index.js +0 -12
  204. package/lib/table/transforms/orderField.js +0 -7
  205. package/lib/table/transforms/sort.js +36 -117
  206. package/lib/table/transforms/tips.js +1 -16
  207. package/lib/table/transforms/treeMode.js +30 -96
  208. package/lib/table/transforms/visible.js +0 -7
  209. package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
  210. package/lib/table/use/useResizeObserver.js +1 -8
  211. package/lib/table/utils/applyTransforms.js +0 -2
  212. package/lib/table/utils/browserType.js +12 -19
  213. package/lib/table/utils/buildTree.js +4 -30
  214. package/lib/table/utils/collectNodes.js +1 -15
  215. package/lib/table/utils/console.js +0 -16
  216. package/lib/table/utils/copyToClipboard.js +0 -6
  217. package/lib/table/utils/element.js +14 -46
  218. package/lib/table/utils/exportTableAsExcel.js +4 -49
  219. package/lib/table/utils/getTreeDepth.js +1 -14
  220. package/lib/table/utils/groupBy.js +1 -14
  221. package/lib/table/utils/index.js +0 -22
  222. package/lib/table/utils/isGroupColumn.js +0 -3
  223. package/lib/table/utils/isLeafNode.js +0 -1
  224. package/lib/table/utils/layeredFilter.js +0 -10
  225. package/lib/table/utils/layeredSort.js +0 -10
  226. package/lib/table/utils/makeRecursiveMapper.js +1 -21
  227. package/lib/table/utils/mergeCellProps.js +6 -17
  228. package/lib/table/utils/others.js +3 -31
  229. package/lib/table/utils/proto.js +2 -33
  230. package/lib/table/utils/selectColumn.js +0 -1
  231. package/lib/table/utils/smartCompare.js +4 -13
  232. package/lib/table/utils/traverseColumn.js +2 -22
  233. package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +1 -30
  234. package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +15 -82
  235. package/lib/table/utils/uiDegrade.js +1 -8
  236. package/package.json +2 -1
  237. package/lib/style/color/colors.less +0 -2
  238. package/lib/style/core/index.less +0 -2
  239. package/lib/style/core/motion/other.less +0 -28
  240. package/lib/style/core/motion/slide.less +0 -53
  241. package/lib/style/core/motion.less +0 -2
  242. package/lib/style/core/reset.less +0 -186
  243. package/lib/style/index.css +0 -410
  244. package/lib/style/index.less +0 -2
  245. package/lib/style/mixins/index.less +0 -19
  246. package/lib/style/mixins/overlay.less +0 -22
  247. package/lib/style/mixins/reset.less +0 -13
  248. package/lib/style/themes/default.less +0 -445
  249. package/lib/style/themes/index.less +0 -1
  250. package/lib/table/style/index.css +0 -0
  251. package/lib/table/style/index.less +0 -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, isValid) {
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 (isValid) {
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 isValidDrag = false;
@@ -118,12 +105,12 @@ export function rowDrag(opt) {
118
105
  });
119
106
  handleDragStrat(dragStartEvent);
120
107
  var tableWidth = tableBody.clientWidth;
121
- var startRowRects = startRowInfo.cell.getBoundingClientRect(); // 光标位置距离初始拖拽行的偏移量
122
-
108
+ var startRowRects = startRowInfo.cell.getBoundingClientRect();
109
+ // 光标位置距离初始拖拽行的偏移量
123
110
  var mouseDownClientY = mouseDownEvent.clientY;
124
111
  var startOffset = mouseDownEvent.clientY - startRowRects.top;
125
- var dragElement = createDragElement(startRowRects, tableWidth, rowHeight); // 可拖拽的范围
126
-
112
+ var dragElement = createDragElement(startRowRects, tableWidth, rowHeight);
113
+ // 可拖拽的范围
127
114
  var dragRange = getDragRange(tableBody, {
128
115
  startOffset: startOffset,
129
116
  rowHeight: rowHeight
@@ -134,7 +121,6 @@ export function rowDrag(opt) {
134
121
  };
135
122
  var mousemove$ = fromEvent(window, 'mousemove');
136
123
  var mouseup$ = fromEvent(window, 'mouseup');
137
-
138
124
  var scrollCallback = function scrollCallback(event) {
139
125
  // 在当前表格内滚动不处理
140
126
  if (event.target === tableBody) return;
@@ -145,27 +131,23 @@ export function rowDrag(opt) {
145
131
  var isOutOfRange = isOutOfDragRange(mousePosition, dragRange);
146
132
  updateCurSorStyle(isOutOfRange);
147
133
  };
148
-
149
134
  document.addEventListener('scroll', scrollCallback, true);
150
135
  var rowDrag$ = mousemove$.pipe(filter(function (mouseMoveEvent) {
151
- var mouseMoveClientY = mouseMoveEvent.clientY; // 上下移动偏移量大于5才是有效的拖拽
152
-
136
+ var mouseMoveClientY = mouseMoveEvent.clientY;
137
+ // 上下移动偏移量大于5才是有效的拖拽
153
138
  if (Math.abs(mouseMoveClientY - mouseDownClientY) > 5) {
154
139
  isValidDrag = true;
155
140
  }
156
-
157
141
  return isValidDrag;
158
142
  }), map(function (mouseMoveEvent) {
159
143
  var clientX = mouseMoveEvent.clientX,
160
- clientY = mouseMoveEvent.clientY;
144
+ clientY = mouseMoveEvent.clientY;
161
145
  var tagretRow = getTargetRowInfo(mouseMoveEvent.target, tableBody, dataSource);
162
-
163
146
  if (tagretRow) {
164
147
  endRowInfo = tagretRow;
165
148
  }
166
-
167
- var targetRowRects = endRowInfo.cell.getBoundingClientRect(); // 判断拖拽插入的位置,拖拽框上边框位于目标行之上则向上插入,否则向下插入
168
-
149
+ var targetRowRects = endRowInfo.cell.getBoundingClientRect();
150
+ // 判断拖拽插入的位置,拖拽框上边框位于目标行之上则向上插入,否则向下插入
169
151
  var isMoveToTop = clientY - startOffset < targetRowRects.top;
170
152
  dragPosition = isMoveToTop ? 'top' : 'bottom';
171
153
  isOutOfRange = isOutOfDragRange({
@@ -177,7 +159,6 @@ export function rowDrag(opt) {
177
159
  y: clientY
178
160
  };
179
161
  updateScrollPosition(mouseMoveEvent); // 拖拽到底时让滚动条可以滚动
180
-
181
162
  updateDragElementPosition(dragElement, dragRange, {
182
163
  x: clientX,
183
164
  y: clientY,
@@ -193,8 +174,8 @@ export function rowDrag(opt) {
193
174
  rowDrag$.subscribe({
194
175
  next: function next(_ref2) {
195
176
  var startRowInfo = _ref2.startRowInfo,
196
- endRowInfo = _ref2.endRowInfo,
197
- dragPosition = _ref2.dragPosition;
177
+ endRowInfo = _ref2.endRowInfo,
178
+ dragPosition = _ref2.dragPosition;
198
179
  var dragMoveEvent = getDragEvent(startRowInfo, endRowInfo, {
199
180
  isFinished: false,
200
181
  dragPosition: dragPosition
@@ -214,12 +195,9 @@ export function rowDrag(opt) {
214
195
  }
215
196
  });
216
197
  };
217
-
218
198
  var rowDragColumn = (opt === null || opt === void 0 ? void 0 : opt.rowDragColumn) || defaultRowDragColumn;
219
199
  pipeline.setFeatureOptions('rowDragColumnKey', rowDragColumn.code);
220
-
221
200
  var nextColumns = _sliceInstanceProperty(_context = pipeline.getColumns()).call(_context);
222
-
223
201
  nextColumns.unshift(rowDragColumn);
224
202
  pipeline.columns(nextColumns);
225
203
  pipeline.addTableProps({
@@ -227,12 +205,11 @@ export function rowDrag(opt) {
227
205
  });
228
206
  pipeline.appendRowPropsGetter(function (row, rowIndex) {
229
207
  var _cx;
230
-
231
208
  var rowDragEvent = pipeline.getStateAtKey(rowDragKey) || {};
232
209
  var startRowIndex = rowDragEvent.startRowIndex,
233
- endRowIndex = rowDragEvent.endRowIndex,
234
- isFinished = rowDragEvent.isFinished,
235
- dragPosition = rowDragEvent.dragPosition;
210
+ endRowIndex = rowDragEvent.endRowIndex,
211
+ isFinished = rowDragEvent.isFinished,
212
+ dragPosition = rowDragEvent.dragPosition;
236
213
  var isFooterCell = row[pipeline.getFeatureOptions('footerRowMetaKey')];
237
214
  if (isFooterCell || isFinished || rowIndex !== startRowIndex && rowIndex !== endRowIndex) return;
238
215
  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));
@@ -243,7 +220,6 @@ export function rowDrag(opt) {
243
220
  return pipeline;
244
221
  };
245
222
  }
246
-
247
223
  function getTargetRowInfo(target, tableBody, record) {
248
224
  while (target && tableBody.contains(target)) {
249
225
  if (target.getAttribute('data-role') === 'table-cell') {
@@ -259,41 +235,33 @@ function getTargetRowInfo(target, tableBody, record) {
259
235
  cell: target
260
236
  };
261
237
  }
262
-
263
238
  target = target.parentElement;
264
239
  }
265
-
266
240
  return null;
267
241
  }
268
-
269
242
  function isEleInFooter(target) {
270
243
  while (target && !target.classList.contains(Classes.artTable)) {
271
244
  if (target.classList.contains(Classes.tableFooter)) {
272
245
  return true;
273
246
  }
274
-
275
247
  target = target.parentElement;
276
248
  }
277
-
278
249
  return false;
279
250
  }
280
-
281
251
  function createDragElement(rects, tableWidth, rowHeight) {
282
252
  var _context2, _context3, _context4;
283
-
284
253
  var x = rects.x,
285
- y = rects.y;
254
+ y = rects.y;
286
255
  var dragMoveElement = document.createElement('div');
287
256
  dragMoveElement.className = cx(Classes.rowDragElement);
288
257
  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;");
289
258
  document.body.appendChild(dragMoveElement);
290
259
  return dragMoveElement;
291
260
  }
292
-
293
261
  function updateDragElementPosition(element, dragRange, _ref3) {
294
262
  var x = _ref3.x,
295
- y = _ref3.y,
296
- startOffset = _ref3.startOffset;
263
+ y = _ref3.y,
264
+ startOffset = _ref3.startOffset;
297
265
  var validPosition = getValidPosition({
298
266
  x: x,
299
267
  y: y
@@ -301,11 +269,9 @@ function updateDragElementPosition(element, dragRange, _ref3) {
301
269
  element.style.top = validPosition.y - startOffset + 'px';
302
270
  return element;
303
271
  }
304
-
305
272
  function removeDragElement(element) {
306
273
  document.body.removeChild(element);
307
274
  }
308
-
309
275
  function updateCurSorStyle(isOutOfRange) {
310
276
  if (isOutOfRange) {
311
277
  document.body.style.cursor = 'no-drop';
@@ -313,19 +279,17 @@ function updateCurSorStyle(isOutOfRange) {
313
279
  document.body.style.cursor = 'move';
314
280
  }
315
281
  }
316
-
317
282
  function removeCurSorStyle() {
318
283
  document.body.style.cursor = 'default';
319
284
  }
320
-
321
285
  function getDragRange(tableBody, _ref4) {
322
286
  var startOffset = _ref4.startOffset,
323
- rowHeight = _ref4.rowHeight;
287
+ rowHeight = _ref4.rowHeight;
324
288
  var tableBodyClientRect = tableBody.getBoundingClientRect();
325
289
  var height = tableBodyClientRect.height,
326
- width = tableBodyClientRect.width,
327
- top = tableBodyClientRect.top,
328
- left = tableBodyClientRect.left;
290
+ width = tableBodyClientRect.width,
291
+ top = tableBodyClientRect.top,
292
+ left = tableBodyClientRect.left;
329
293
  return {
330
294
  minX: left,
331
295
  maxX: left + width,
@@ -333,14 +297,13 @@ function getDragRange(tableBody, _ref4) {
333
297
  maxY: top + height + startOffset
334
298
  };
335
299
  }
336
-
337
300
  function getValidPosition(position, dragRange) {
338
301
  var x = position.x,
339
- y = position.y;
302
+ y = position.y;
340
303
  var minX = dragRange.minX,
341
- maxX = dragRange.maxX,
342
- minY = dragRange.minY,
343
- maxY = dragRange.maxY;
304
+ maxX = dragRange.maxX,
305
+ minY = dragRange.minY,
306
+ maxY = dragRange.maxY;
344
307
  var newX = x < minX ? minX : x > maxX ? maxX : x;
345
308
  var newY = y < minY ? minY : y > maxY ? maxY : y;
346
309
  return {
@@ -348,13 +311,12 @@ function getValidPosition(position, dragRange) {
348
311
  y: newY
349
312
  };
350
313
  }
351
-
352
314
  function isOutOfDragRange(position, dragRange) {
353
315
  var x = position.x,
354
- y = position.y;
316
+ y = position.y;
355
317
  var minX = dragRange.minX,
356
- maxX = dragRange.maxX,
357
- minY = dragRange.minY,
358
- maxY = dragRange.maxY;
318
+ maxX = dragRange.maxX,
319
+ minY = dragRange.minY,
320
+ maxY = dragRange.maxY;
359
321
  return x > maxX || x < minX || y > maxY || y < minY;
360
322
  }
@@ -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,