@kdcloudjs/table 1.2.0-canary.16 → 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 +2047 -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 +0 -9
  35. package/es/table/base/table.js +95 -181
  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 +63 -142
  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 +0 -21
  143. package/lib/table/base/table.js +95 -214
  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 +63 -159
  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
@@ -1,56 +1,32 @@
1
1
  "use strict";
2
2
 
3
3
  var _flatMapInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/flat-map");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.rowDetail = rowDetail;
11
-
12
9
  var _toArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toArray"));
13
-
14
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
15
-
16
11
  var _extends4 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
17
-
18
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
19
-
20
13
  var _symbol = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/symbol"));
21
-
22
14
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
23
-
24
15
  var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
25
-
26
16
  var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
27
-
28
17
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
29
-
30
18
  var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
31
-
32
19
  var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
33
-
34
20
  var _classnames = _interopRequireDefault(require("classnames"));
35
-
36
21
  var _react = _interopRequireDefault(require("react"));
37
-
38
22
  var _commonViews = require("../../common-views");
39
-
40
23
  var _internals = require("../../internals");
41
-
42
24
  var _utils = require("../../utils");
43
-
44
25
  var _others = require("../../utils/others");
45
-
46
26
  var _console = _interopRequireDefault(require("../../utils/console"));
47
-
48
27
  var _renderTemplates = _interopRequireDefault(require("../../base/renderTemplates"));
49
-
50
28
  var _base = require("../../base");
51
-
52
29
  var rowDetailSymbol = (0, _symbol.default)('row-detail');
53
-
54
30
  var fallbackRenderDetail = function fallbackRenderDetail() {
55
31
  return /*#__PURE__*/_react.default.createElement("div", {
56
32
  style: {
@@ -62,14 +38,11 @@ var fallbackRenderDetail = function fallbackRenderDetail() {
62
38
  }
63
39
  }, "\u8BBE\u7F6E ", /*#__PURE__*/_react.default.createElement("code", null, "rowDetail.renderDetail"), " \u6765\u81EA\u5B9A\u4E49\u8BE6\u60C5\u5185\u5BB9"));
64
40
  };
65
-
66
41
  function rowDetail() {
67
42
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
68
43
  return function rowDetailStep(pipeline) {
69
44
  var _context, _context2;
70
-
71
45
  var _a, _b, _c, _d, _e, _f, _g, _h;
72
-
73
46
  var stateKey = 'rowDetail';
74
47
  var rowDetailMetaKey = (_a = opts.rowDetailMetaKey) !== null && _a !== void 0 ? _a : rowDetailSymbol;
75
48
  var primaryKey = pipeline.ensurePrimaryKey('rowDetail');
@@ -84,33 +57,26 @@ function rowDetail() {
84
57
  var openKeys = (_h = (_g = (_f = opts.openKeys) !== null && _f !== void 0 ? _f : pipeline.getStateAtKey(stateKey)) !== null && _g !== void 0 ? _g : opts.defaultOpenAll ? (0, _map.default)(_context = (0, _filter.default)(_context2 = pipeline.getDataSource()).call(_context2, hasDetail)).call(_context, function (row, rowIndex) {
85
58
  return _internals.internals.safeGetRowKey(primaryKey, row, rowIndex);
86
59
  }) : opts.defaultOpenKeys) !== null && _h !== void 0 ? _h : [];
87
-
88
60
  var onChangeOpenKeys = function onChangeOpenKeys(nextKeys, key, action) {
89
61
  var _a;
90
-
91
62
  (_a = opts.onChangeOpenKeys) === null || _a === void 0 ? void 0 : _a.call(opts, nextKeys, key, action);
92
63
  pipeline.setStateAtKey(stateKey, nextKeys, {
93
64
  key: key,
94
65
  action: action
95
66
  });
96
67
  };
97
-
98
68
  var openKeySet = new _set.default(openKeys);
99
-
100
69
  var toggle = function toggle(rowKey) {
101
70
  var expanded = openKeySet.has(rowKey);
102
-
103
71
  if (expanded) {
104
72
  onChangeOpenKeys((0, _filter.default)(openKeys).call(openKeys, function (key) {
105
73
  return key !== rowKey;
106
74
  }), rowKey, 'collapse');
107
75
  } else {
108
76
  var _context3;
109
-
110
77
  onChangeOpenKeys((0, _concat.default)(_context3 = []).call(_context3, (0, _toConsumableArray2.default)(openKeys), [rowKey]), rowKey, 'expand');
111
78
  }
112
79
  };
113
-
114
80
  var detailPrimaryKey = typeof primaryKey === 'string' ? primaryKey : rowDetailMetaKey.toString() + 'PrimaryKey';
115
81
  return pipeline.dataSource((0, _flatMapInstanceProperty(_others))(pipeline.getDataSource(), function (row, rowIndex) {
116
82
  if (openKeySet.has(_internals.internals.safeGetRowKey(primaryKey, row, rowIndex))) {
@@ -126,35 +92,27 @@ function rowDetail() {
126
92
  };
127
93
  }
128
94
  });
129
-
130
95
  function processColumns(columns) {
131
96
  if (columns.length === 0) {
132
97
  return columns;
133
98
  }
134
-
135
99
  var expandColumnIndex = 0;
136
-
137
100
  if (opts.expandColumnCode) {
138
101
  expandColumnIndex = (0, _findIndex.default)(columns).call(columns, function (col) {
139
102
  return col.code === opts.expandColumnCode;
140
103
  });
141
-
142
104
  if (expandColumnIndex < 0) {
143
105
  _console.default.warn('没找到可展开的列,请检查设置的展开列code');
144
-
145
106
  return columns;
146
107
  }
147
108
  }
148
-
149
109
  var expandCol = columns[expandColumnIndex];
150
110
  var tableColumns = (0, _toConsumableArray2.default)(columns);
151
-
152
111
  var render = function render(value, row, rowIndex) {
153
112
  if (row[rowDetailMetaKey]) {
154
113
  // 第一列内容已经渲染
155
114
  if (expandColumnIndex !== 0) return;
156
115
  var renderRowDetail = (0, _renderTemplates.default)('rowDetail');
157
-
158
116
  if (typeof renderRowDetail === 'function') {
159
117
  return renderRowDetail({
160
118
  row: row,
@@ -163,12 +121,9 @@ function rowDetail() {
163
121
  renderDetail: renderDetail
164
122
  });
165
123
  }
166
-
167
124
  return renderDetail(row, rowIndex);
168
125
  }
169
-
170
126
  var content = _internals.internals.safeRender(expandCol, row, rowIndex);
171
-
172
127
  if (!hasDetail(row, rowIndex)) {
173
128
  return /*#__PURE__*/_react.default.createElement(_commonViews.InlineFlexCell, {
174
129
  style: {
@@ -176,19 +131,14 @@ function rowDetail() {
176
131
  }
177
132
  }, content);
178
133
  }
179
-
180
134
  var rowKey = _internals.internals.safeGetRowKey(primaryKey, row, rowIndex);
181
-
182
135
  var expanded = openKeySet.has(rowKey);
183
-
184
136
  var onClick = function onClick(e) {
185
137
  if (opts.stopClickEventPropagation) {
186
138
  e.stopPropagation();
187
139
  }
188
-
189
140
  toggle(rowKey);
190
141
  };
191
-
192
142
  var expandCls = expanded ? _base.Classes.expanded : _base.Classes.collapsed;
193
143
  var ExpandIcon = opts.expandIcon;
194
144
  return /*#__PURE__*/_react.default.createElement(_commonViews.ExpansionCell, {
@@ -210,10 +160,8 @@ function rowDetail() {
210
160
  onClick: clickArea === 'icon' ? onClick : undefined
211
161
  }), content);
212
162
  };
213
-
214
163
  var getCellProps = function getCellProps(value, row, rowIndex) {
215
164
  var _a;
216
-
217
165
  if (row[rowDetailMetaKey]) {
218
166
  return {
219
167
  style: (0, _extends4.default)({
@@ -222,19 +170,15 @@ function rowDetail() {
222
170
  }, opts.detailCellStyle)
223
171
  };
224
172
  }
225
-
226
173
  var prevProps = (_a = expandCol.getCellProps) === null || _a === void 0 ? void 0 : _a.call(expandCol, value, row, rowIndex);
227
-
228
174
  if (!hasDetail(row, rowIndex)) {
229
175
  return prevProps;
230
176
  }
231
-
232
177
  return (0, _utils.mergeCellProps)(prevProps, {
233
178
  onClick: function onClick(e) {
234
179
  if (opts.stopClickEventPropagation) {
235
180
  e.stopPropagation();
236
181
  }
237
-
238
182
  toggle(_internals.internals.safeGetRowKey(primaryKey, row, rowIndex));
239
183
  },
240
184
  style: {
@@ -242,15 +186,12 @@ function rowDetail() {
242
186
  }
243
187
  });
244
188
  };
245
-
246
189
  var _tableColumns = (0, _toArray2.default)(tableColumns),
247
- firstCol = _tableColumns[0],
248
- others = (0, _slice.default)(_tableColumns).call(_tableColumns, 1);
249
-
190
+ firstCol = _tableColumns[0],
191
+ others = (0, _slice.default)(_tableColumns).call(_tableColumns, 1);
250
192
  var firstColRender = function firstColRender(value, row, rowIndex) {
251
193
  if (row[rowDetailMetaKey]) {
252
194
  var renderRowDetail = (0, _renderTemplates.default)('rowDetail');
253
-
254
195
  if (typeof renderRowDetail === 'function') {
255
196
  return renderRowDetail({
256
197
  row: row,
@@ -259,15 +200,11 @@ function rowDetail() {
259
200
  renderDetail: renderDetail
260
201
  });
261
202
  }
262
-
263
203
  return renderDetail(row, rowIndex);
264
204
  }
265
-
266
205
  var content = _internals.internals.safeRender(firstCol, row, rowIndex);
267
-
268
206
  return content;
269
207
  };
270
-
271
208
  tableColumns[0] = (0, _extends4.default)((0, _extends4.default)({}, firstCol), {
272
209
  render: firstColRender,
273
210
  getSpanRect: function getSpanRect(value, row, rowIndex) {
@@ -1,32 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _mapInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/map");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.ROW_DRAG_COLUMN_CODE = void 0;
11
9
  exports.rowDrag = rowDrag;
12
10
  exports.rowDragKey = void 0;
13
-
14
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
15
-
16
12
  var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
17
-
18
13
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
19
-
20
14
  var _react = _interopRequireDefault(require("react"));
21
-
22
15
  var _rxjs = require("rxjs");
23
-
24
16
  var _operators = require("rxjs/operators");
25
-
26
17
  var _classnames = _interopRequireDefault(require("classnames"));
27
-
28
18
  var _styles = require("../../base/styles");
29
-
30
19
  var ROW_DRAG_COLUMN_CODE = '$_row_drag_column_&';
31
20
  exports.ROW_DRAG_COLUMN_CODE = ROW_DRAG_COLUMN_CODE;
32
21
  var rowDragKey = 'rowDragKey';
@@ -58,47 +47,38 @@ var defaultRowDragColumn = {
58
47
  }));
59
48
  }
60
49
  };
61
-
62
50
  function rowDrag(opt) {
63
51
  return function rowDragStep(pipeline) {
64
52
  var _context;
65
-
66
53
  var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
67
54
  var artTable = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.artTable;
68
55
  if (!tableBody) return pipeline;
69
56
  var dataSource = pipeline.getDataSource();
70
57
  var rowHeight = (opt === null || opt === void 0 ? void 0 : opt.rowHeight) || 48;
71
-
72
58
  var handleDragStrat = function handleDragStrat(event) {
73
- var _a; // 开始拖拽
74
-
75
-
59
+ var _a;
60
+ // 开始拖拽
76
61
  artTable.classList.add((0, _classnames.default)(_styles.Classes.rowDragging));
77
62
  (_a = opt === null || opt === void 0 ? void 0 : opt.onDragStart) === null || _a === void 0 ? void 0 : _a.call(opt, event);
78
63
  };
79
-
80
64
  var handleDragMove = function handleDragMove(event) {
81
65
  var _a;
82
-
83
66
  (_a = opt === null || opt === void 0 ? void 0 : opt.onDragMove) === null || _a === void 0 ? void 0 : _a.call(opt, event);
84
67
  pipeline.setStateAtKey(rowDragKey, event);
85
68
  };
86
-
87
69
  var handleDragEnd = function handleDragEnd(event, isOutOfRange) {
88
70
  var _a;
89
-
90
71
  artTable.classList.remove((0, _classnames.default)(_styles.Classes.rowDragging));
91
- pipeline.setStateAtKey(rowDragKey, event); // 超出拖拽范围不触发dragend事件
92
-
72
+ pipeline.setStateAtKey(rowDragKey, event);
73
+ // 超出拖拽范围不触发dragend事件
93
74
  if (!isOutOfRange) {
94
75
  (_a = opt === null || opt === void 0 ? void 0 : opt.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(opt, event);
95
76
  }
96
77
  };
97
-
98
78
  var getDragEvent = function getDragEvent(startRowInfo, endRowInfo, _ref) {
99
79
  var isFinished = _ref.isFinished,
100
- _ref$dragPosition = _ref.dragPosition,
101
- dragPosition = _ref$dragPosition === void 0 ? 'bottom' : _ref$dragPosition;
80
+ _ref$dragPosition = _ref.dragPosition,
81
+ dragPosition = _ref$dragPosition === void 0 ? 'bottom' : _ref$dragPosition;
102
82
  return {
103
83
  startRowIndex: startRowInfo.rowIndex,
104
84
  startRow: startRowInfo.row,
@@ -108,31 +88,26 @@ function rowDrag(opt) {
108
88
  isFinished: isFinished
109
89
  };
110
90
  };
111
-
112
91
  var updateScrollPosition = function updateScrollPosition(mouseMoveEvent) {
113
92
  if (opt === null || opt === void 0 ? void 0 : opt.suppressScrollMove) return;
114
93
  var clientY = mouseMoveEvent.clientY;
115
94
  var tableBodyClientRect = tableBody.getBoundingClientRect();
116
95
  var top = tableBodyClientRect.top,
117
- height = tableBodyClientRect.height;
118
-
96
+ height = tableBodyClientRect.height;
119
97
  if (clientY + SCROLL_OFFSET >= top + height) {
120
98
  pipeline.ref.current.domHelper.tableBody.scrollTop += SCROLL_OFFSET;
121
99
  }
122
-
123
100
  if (clientY + SCROLL_OFFSET <= top) {
124
101
  pipeline.ref.current.domHelper.tableBody.scrollTop -= SCROLL_OFFSET;
125
102
  }
126
103
  };
127
-
128
104
  var onMouseDown = function onMouseDown(mouseDownEvent) {
129
105
  var _a;
130
-
131
106
  var startRowInfo = getTargetRowInfo(mouseDownEvent.target, tableBody, dataSource);
132
107
  var endRowInfo = startRowInfo;
133
108
  if (!startRowInfo || startRowInfo.code !== rowDragColumn.code) return;
134
- 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; // 默认拖拽插入的位置是向下
135
-
109
+ 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;
110
+ // 默认拖拽插入的位置是向下
136
111
  var dragPosition = 'bottom';
137
112
  var isOutOfRange = false;
138
113
  var dragStartEvent = getDragEvent(startRowInfo, endRowInfo, {
@@ -141,11 +116,11 @@ function rowDrag(opt) {
141
116
  });
142
117
  handleDragStrat(dragStartEvent);
143
118
  var tableWidth = tableBody.clientWidth;
144
- var startRowRects = startRowInfo.cell.getBoundingClientRect(); // 光标位置距离初始拖拽行的偏移量
145
-
119
+ var startRowRects = startRowInfo.cell.getBoundingClientRect();
120
+ // 光标位置距离初始拖拽行的偏移量
146
121
  var startOffset = mouseDownEvent.clientY - startRowRects.y;
147
- var dragElement = createDragElement(startRowRects, tableWidth, rowHeight); // 可拖拽的范围
148
-
122
+ var dragElement = createDragElement(startRowRects, tableWidth, rowHeight);
123
+ // 可拖拽的范围
149
124
  var dragRange = getDragRange(tableBody, {
150
125
  startOffset: startOffset,
151
126
  rowHeight: startRowRects.height
@@ -154,15 +129,13 @@ function rowDrag(opt) {
154
129
  var mouseup$ = (0, _rxjs.fromEvent)(window, 'mouseup');
155
130
  var rowDrag$ = mousemove$.pipe((0, _mapInstanceProperty(_operators))(function (mouseMoveEvent) {
156
131
  var clientX = mouseMoveEvent.clientX,
157
- clientY = mouseMoveEvent.clientY;
132
+ clientY = mouseMoveEvent.clientY;
158
133
  var tagretRow = getTargetRowInfo(mouseMoveEvent.target, tableBody, dataSource);
159
-
160
134
  if (tagretRow) {
161
135
  endRowInfo = tagretRow;
162
136
  }
163
-
164
- var targetRowRects = endRowInfo.cell.getBoundingClientRect(); // 判断拖拽插入的位置,拖拽框上边框位于目标行之上则向上插入,否则向下插入
165
-
137
+ var targetRowRects = endRowInfo.cell.getBoundingClientRect();
138
+ // 判断拖拽插入的位置,拖拽框上边框位于目标行之上则向上插入,否则向下插入
166
139
  var isMoveToTop = clientY - startOffset < targetRowRects.y;
167
140
  dragPosition = isMoveToTop ? 'top' : 'bottom';
168
141
  isOutOfRange = isOutOfDragRange({
@@ -170,7 +143,6 @@ function rowDrag(opt) {
170
143
  y: clientY
171
144
  }, dragRange);
172
145
  updateScrollPosition(mouseMoveEvent); // 拖拽到底时让滚动条可以滚动
173
-
174
146
  updateDragElementPosition(dragElement, dragRange, {
175
147
  x: clientX,
176
148
  y: clientY,
@@ -186,8 +158,8 @@ function rowDrag(opt) {
186
158
  rowDrag$.subscribe({
187
159
  next: function next(_ref2) {
188
160
  var startRowInfo = _ref2.startRowInfo,
189
- endRowInfo = _ref2.endRowInfo,
190
- dragPosition = _ref2.dragPosition;
161
+ endRowInfo = _ref2.endRowInfo,
162
+ dragPosition = _ref2.dragPosition;
191
163
  var dragMoveEvent = getDragEvent(startRowInfo, endRowInfo, {
192
164
  isFinished: false,
193
165
  dragPosition: dragPosition
@@ -205,7 +177,6 @@ function rowDrag(opt) {
205
177
  }
206
178
  });
207
179
  };
208
-
209
180
  var rowDragColumn = (opt === null || opt === void 0 ? void 0 : opt.rowDragColumn) || defaultRowDragColumn;
210
181
  pipeline.setFeatureOptions('rowDragColumnKey', rowDragColumn.code);
211
182
  var nextColumns = (0, _slice.default)(_context = pipeline.getColumns()).call(_context);
@@ -216,12 +187,11 @@ function rowDrag(opt) {
216
187
  });
217
188
  pipeline.appendRowPropsGetter(function (row, rowIndex) {
218
189
  var _cx;
219
-
220
190
  var rowDragEvent = pipeline.getStateAtKey(rowDragKey) || {};
221
191
  var startRowIndex = rowDragEvent.startRowIndex,
222
- endRowIndex = rowDragEvent.endRowIndex,
223
- isFinished = rowDragEvent.isFinished,
224
- dragPosition = rowDragEvent.dragPosition;
192
+ endRowIndex = rowDragEvent.endRowIndex,
193
+ isFinished = rowDragEvent.isFinished,
194
+ dragPosition = rowDragEvent.dragPosition;
225
195
  var isFooterCell = row[pipeline.getFeatureOptions('footerRowMetaKey')];
226
196
  if (isFooterCell || isFinished || rowIndex !== startRowIndex && rowIndex !== endRowIndex) return;
227
197
  var className = (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, _styles.Classes.rowDragStart, rowIndex === startRowIndex), (0, _defineProperty2.default)(_cx, _styles.Classes.rowDragEnd, rowIndex === endRowIndex), (0, _defineProperty2.default)(_cx, _styles.Classes.rowDragEndToTop, rowIndex === endRowIndex && dragPosition === 'top'), (0, _defineProperty2.default)(_cx, _styles.Classes.rowDragEndToBottom, rowIndex === endRowIndex && dragPosition === 'bottom'), _cx));
@@ -232,7 +202,6 @@ function rowDrag(opt) {
232
202
  return pipeline;
233
203
  };
234
204
  }
235
-
236
205
  function getTargetRowInfo(target, tableBody, record) {
237
206
  while (target && tableBody.contains(target)) {
238
207
  if (target.getAttribute('data-role') === 'table-cell') {
@@ -248,41 +217,33 @@ function getTargetRowInfo(target, tableBody, record) {
248
217
  cell: target
249
218
  };
250
219
  }
251
-
252
220
  target = target.parentElement;
253
221
  }
254
-
255
222
  return null;
256
223
  }
257
-
258
224
  function isEleInFooter(target) {
259
225
  while (target && !target.classList.contains(_styles.Classes.artTable)) {
260
226
  if (target.classList.contains(_styles.Classes.tableFooter)) {
261
227
  return true;
262
228
  }
263
-
264
229
  target = target.parentElement;
265
230
  }
266
-
267
231
  return false;
268
232
  }
269
-
270
233
  function createDragElement(rects, tableWidth, rowHeight) {
271
234
  var _context2, _context3, _context4;
272
-
273
235
  var x = rects.x,
274
- y = rects.y;
236
+ y = rects.y;
275
237
  var dragMoveElement = document.createElement('div');
276
238
  dragMoveElement.className = (0, _classnames.default)(_styles.Classes.rowDragElement);
277
239
  dragMoveElement.style.cssText = (0, _concat.default)(_context2 = (0, _concat.default)(_context3 = (0, _concat.default)(_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;");
278
240
  document.body.appendChild(dragMoveElement);
279
241
  return dragMoveElement;
280
242
  }
281
-
282
243
  function updateDragElementPosition(element, dragRange, _ref3) {
283
244
  var x = _ref3.x,
284
- y = _ref3.y,
285
- startOffset = _ref3.startOffset;
245
+ y = _ref3.y,
246
+ startOffset = _ref3.startOffset;
286
247
  var validPosition = getValidPosition({
287
248
  x: x,
288
249
  y: y
@@ -290,11 +251,9 @@ function updateDragElementPosition(element, dragRange, _ref3) {
290
251
  element.style.top = validPosition.y - startOffset + 'px';
291
252
  return element;
292
253
  }
293
-
294
254
  function removeDragElement(element) {
295
255
  document.body.removeChild(element);
296
256
  }
297
-
298
257
  function updateCurSorStyle(isOutOfRange) {
299
258
  if (isOutOfRange) {
300
259
  document.body.style.cursor = 'no-drop';
@@ -302,19 +261,17 @@ function updateCurSorStyle(isOutOfRange) {
302
261
  document.body.style.cursor = 'move';
303
262
  }
304
263
  }
305
-
306
264
  function removeCurSorStyle() {
307
265
  document.body.style.cursor = 'default';
308
266
  }
309
-
310
267
  function getDragRange(tableBody, _ref4) {
311
268
  var startOffset = _ref4.startOffset,
312
- rowHeight = _ref4.rowHeight;
269
+ rowHeight = _ref4.rowHeight;
313
270
  var tableBodyClientRect = tableBody.getBoundingClientRect();
314
271
  var height = tableBodyClientRect.height,
315
- width = tableBodyClientRect.width,
316
- x = tableBodyClientRect.x,
317
- y = tableBodyClientRect.y;
272
+ width = tableBodyClientRect.width,
273
+ x = tableBodyClientRect.x,
274
+ y = tableBodyClientRect.y;
318
275
  return {
319
276
  minX: x,
320
277
  maxX: x + width,
@@ -322,14 +279,13 @@ function getDragRange(tableBody, _ref4) {
322
279
  maxY: y + height + startOffset
323
280
  };
324
281
  }
325
-
326
282
  function getValidPosition(position, dragRange) {
327
283
  var x = position.x,
328
- y = position.y;
284
+ y = position.y;
329
285
  var minX = dragRange.minX,
330
- maxX = dragRange.maxX,
331
- minY = dragRange.minY,
332
- maxY = dragRange.maxY;
286
+ maxX = dragRange.maxX,
287
+ minY = dragRange.minY,
288
+ maxY = dragRange.maxY;
333
289
  var newX = x < minX ? minX : x > maxX ? maxX : x;
334
290
  var newY = y < minY ? minY : y > maxY ? maxY : y;
335
291
  return {
@@ -337,13 +293,12 @@ function getValidPosition(position, dragRange) {
337
293
  y: newY
338
294
  };
339
295
  }
340
-
341
296
  function isOutOfDragRange(position, dragRange) {
342
297
  var x = position.x,
343
- y = position.y;
298
+ y = position.y;
344
299
  var minX = dragRange.minX,
345
- maxX = dragRange.maxX,
346
- minY = dragRange.minY,
347
- maxY = dragRange.maxY;
300
+ maxX = dragRange.maxX,
301
+ minY = dragRange.minY,
302
+ maxY = dragRange.maxY;
348
303
  return x > maxX || x < minX || y > maxY || y < minY;
349
304
  }