@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,33 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.TablePipeline = void 0;
9
8
  exports.useTablePipeline = useTablePipeline;
10
-
11
9
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
12
-
13
10
  var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
14
-
15
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
16
-
17
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
18
-
19
13
  var _extends3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
20
-
21
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
22
-
23
15
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
24
-
25
16
  var _react = require("react");
26
-
27
17
  var _utils = require("../utils");
28
-
29
18
  var _autoFill = require("./features/autoFill");
30
-
31
19
  /**
32
20
  * 表格数据处理流水线。TablePipeline 提供了表格数据处理过程中的一些上下方与工具方法,包括……
33
21
  *
@@ -44,9 +32,9 @@ var _autoFill = require("./features/autoFill");
44
32
  var TablePipeline = /*#__PURE__*/function () {
45
33
  function TablePipeline(_ref) {
46
34
  var state = _ref.state,
47
- setState = _ref.setState,
48
- ctx = _ref.ctx,
49
- ref = _ref.ref;
35
+ setState = _ref.setState,
36
+ ctx = _ref.ctx,
37
+ ref = _ref.ref;
50
38
  (0, _classCallCheck2.default)(this, TablePipeline);
51
39
  this._snapshots = {};
52
40
  this._rowPropsGetters = [];
@@ -59,23 +47,20 @@ var TablePipeline = /*#__PURE__*/function () {
59
47
  this.setState = setState;
60
48
  this.ref = ref;
61
49
  (0, _extends3.default)(this.ctx, ctx);
62
- } // Generate a pseudo-GUID by concatenating random hexadecimal.
63
-
64
-
50
+ }
51
+ // Generate a pseudo-GUID by concatenating random hexadecimal.
65
52
  (0, _createClass2.default)(TablePipeline, [{
66
53
  key: "guid",
67
54
  value: function guid() {
68
55
  function S4() {
69
56
  return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
70
57
  }
71
-
72
58
  return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
73
59
  }
74
60
  }, {
75
61
  key: "appendRowPropsGetter",
76
62
  value: function appendRowPropsGetter(getter) {
77
63
  this._rowPropsGetters.push(getter);
78
-
79
64
  return this;
80
65
  }
81
66
  }, {
@@ -115,11 +100,9 @@ var TablePipeline = /*#__PURE__*/function () {
115
100
  key: "getStateAtKey",
116
101
  value: function getStateAtKey(stateKey, defaultValue) {
117
102
  var _a;
118
-
119
103
  return (_a = this.state[stateKey]) !== null && _a !== void 0 ? _a : defaultValue;
120
104
  }
121
105
  /** 将 stateKey 对应的状态设置为 partialState */
122
-
123
106
  }, {
124
107
  key: "setStateAtKey",
125
108
  value: function setStateAtKey(stateKey, partialState, extraInfo) {
@@ -128,29 +111,24 @@ var TablePipeline = /*#__PURE__*/function () {
128
111
  }, stateKey, partialState, extraInfo);
129
112
  }
130
113
  /** 确保 primaryKey 已被设置,并返回 primaryKey */
131
-
132
114
  }, {
133
115
  key: "ensurePrimaryKey",
134
116
  value: function ensurePrimaryKey(hint) {
135
117
  if (this.ctx.primaryKey == null) {
136
118
  throw new Error(hint ? "\u4F7F\u7528 ".concat(hint, " \u4E4B\u524D\u5FC5\u987B\u5148\u8BBE\u7F6E primaryKey") : '必须先设置 primaryKey');
137
119
  }
138
-
139
120
  return this.ctx.primaryKey;
140
121
  }
141
122
  /** 设置流水线的输入数据 */
142
-
143
123
  }, {
144
124
  key: "input",
145
125
  value: function input(_input) {
146
126
  var _context,
147
- _this = this;
148
-
127
+ _this = this;
149
128
  if (this._dataSource != null || this._columns != null) {
150
129
  throw new Error('input 不能调用两次');
151
- } // 在 pipeline 中识别本次更新是否有数据变化
152
-
153
-
130
+ }
131
+ // 在 pipeline 中识别本次更新是否有数据变化
154
132
  this._isSameInputDataSource = _input.dataSource === this.ref.current._lastInputDataSource;
155
133
  this._dataSource = _input.dataSource;
156
134
  this.ref.current._lastInputDataSource = _input.dataSource;
@@ -163,7 +141,6 @@ var TablePipeline = /*#__PURE__*/function () {
163
141
  return this;
164
142
  }
165
143
  /** 设置 dataSource */
166
-
167
144
  }, {
168
145
  key: "dataSource",
169
146
  value: function dataSource(rows) {
@@ -171,7 +148,6 @@ var TablePipeline = /*#__PURE__*/function () {
171
148
  return this;
172
149
  }
173
150
  /** 设置 columns */
174
-
175
151
  }, {
176
152
  key: "columns",
177
153
  value: function columns(cols) {
@@ -179,7 +155,6 @@ var TablePipeline = /*#__PURE__*/function () {
179
155
  return this;
180
156
  }
181
157
  /** 设置主键 */
182
-
183
158
  }, {
184
159
  key: "primaryKey",
185
160
  value: function primaryKey(key) {
@@ -187,7 +162,6 @@ var TablePipeline = /*#__PURE__*/function () {
187
162
  return this;
188
163
  }
189
164
  /** 设置页脚数据 */
190
-
191
165
  }, {
192
166
  key: "footerDataSource",
193
167
  value: function footerDataSource(rows) {
@@ -195,12 +169,10 @@ var TablePipeline = /*#__PURE__*/function () {
195
169
  return this;
196
170
  }
197
171
  /** 保存快照 */
198
-
199
172
  }, {
200
173
  key: "snapshot",
201
174
  value: function snapshot(name) {
202
175
  var _context2;
203
-
204
176
  this._snapshots[name] = {
205
177
  dataSource: this._dataSource,
206
178
  columns: this._columns,
@@ -210,7 +182,6 @@ var TablePipeline = /*#__PURE__*/function () {
210
182
  }
211
183
  /** @deprecated
212
184
  * 应用一个 kd-table Table transform */
213
-
214
185
  }, {
215
186
  key: "useTransform",
216
187
  value: function useTransform(transform) {
@@ -221,63 +192,52 @@ var TablePipeline = /*#__PURE__*/function () {
221
192
  return this.dataSource(next.dataSource).columns(next.columns);
222
193
  }
223
194
  /** 使用 pipeline 功能拓展 */
224
-
225
195
  }, {
226
196
  key: "use",
227
197
  value: function use(step) {
228
198
  return step(this);
229
199
  }
230
200
  /** 转换 dataSource */
231
-
232
201
  }, {
233
202
  key: "mapDataSource",
234
203
  value: function mapDataSource(mapper) {
235
204
  return this.dataSource(mapper(this.getDataSource()));
236
205
  }
237
206
  /** 转换 columns */
238
-
239
207
  }, {
240
208
  key: "mapColumns",
241
209
  value: function mapColumns(mapper) {
242
210
  return this.columns(mapper(this.getColumns()));
243
211
  }
244
212
  /** 获取featureOptions 内容 */
245
-
246
213
  }, {
247
214
  key: "getFeatureOptions",
248
215
  value: function getFeatureOptions(optionKey) {
249
216
  var _a;
250
-
251
217
  return (_a = this.ref.current.featureOptions) === null || _a === void 0 ? void 0 : _a[optionKey];
252
218
  }
253
219
  /** 设置pipelineOptions 内容 */
254
-
255
220
  }, {
256
221
  key: "setFeatureOptions",
257
222
  value: function setFeatureOptions(optionKey, value) {
258
223
  this.ref.current.featureOptions[optionKey] = value;
259
224
  }
260
225
  /** 获取 BaseTable 的 props,结果中包含 dataSource/columns/primaryKey/getRowProps 四个字段 */
261
-
262
226
  }, {
263
227
  key: "getProps",
264
228
  value: function getProps() {
265
229
  var _this2 = this;
266
-
267
230
  this.use((0, _autoFill.autoFillTableWidth)());
268
231
  var result = {
269
232
  dataSource: this._dataSource,
270
233
  columns: this._columns
271
234
  };
272
-
273
235
  if (this.ctx.primaryKey) {
274
236
  result.primaryKey = this.ctx.primaryKey;
275
237
  }
276
-
277
238
  if (this._footerDataSource) {
278
239
  result.footerDataSource = this._footerDataSource;
279
240
  }
280
-
281
241
  if (this._rowPropsGetters.length > 0) {
282
242
  result.getRowProps = function (row, rowIndex) {
283
243
  return _this2._rowPropsGetters.reduce(function (res, get) {
@@ -285,33 +245,26 @@ var TablePipeline = /*#__PURE__*/function () {
285
245
  }, {});
286
246
  };
287
247
  }
288
-
289
248
  result.getTableProps = function () {
290
249
  return _this2._tableProps;
291
250
  };
292
-
293
251
  result.setTableWidth = function (tableWidth) {
294
252
  var preTableWidth = _this2.getStateAtKey(_autoFill.tableWidthKey);
295
-
296
253
  if (preTableWidth !== tableWidth) {
297
254
  tableWidth && _this2.setStateAtKey(_autoFill.tableWidthKey, tableWidth);
298
255
  }
299
256
  };
300
-
301
257
  result.setTableDomHelper = function (domHelper) {
302
258
  _this2.ref.current.domHelper = domHelper;
303
259
  };
304
-
305
260
  result.setRowHeightManager = function (rowHeightManager) {
306
261
  _this2.ref.current.rowHeightManager = rowHeightManager;
307
262
  };
308
-
309
263
  return result;
310
264
  }
311
265
  }]);
312
266
  return TablePipeline;
313
267
  }();
314
-
315
268
  exports.TablePipeline = TablePipeline;
316
269
  TablePipeline.defaultIndents = {
317
270
  iconIndent: -8,
@@ -319,13 +272,11 @@ TablePipeline.defaultIndents = {
319
272
  iconGap: 0,
320
273
  indentSize: 16
321
274
  };
322
-
323
275
  function useTablePipeline(ctx) {
324
276
  var _useState = (0, _react.useState)({}),
325
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
326
- state = _useState2[0],
327
- setState = _useState2[1];
328
-
277
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
278
+ state = _useState2[0],
279
+ setState = _useState2[1];
329
280
  var ref = (0, _react.useRef)({
330
281
  featureOptions: {}
331
282
  });
@@ -1,61 +1,41 @@
1
1
  "use strict";
2
2
 
3
3
  var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
4
-
5
4
  var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
6
-
7
5
  var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
8
-
9
6
  var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
10
-
11
7
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
12
-
13
8
  Object.defineProperty(exports, "__esModule", {
14
9
  value: true
15
10
  });
16
11
  exports.default = buildCrossTable;
17
-
18
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
19
-
20
13
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
21
-
22
14
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
23
-
24
15
  var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
25
-
26
16
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
27
-
28
17
  var _utils = require("../../utils");
29
-
30
18
  var _constants = require("./constants");
31
-
32
19
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
33
-
34
20
  function _unsupportedIterableToArray(o, minLen) { var _context4; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context4 = Object.prototype.toString.call(o)).call(_context4, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
35
-
36
21
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
37
-
38
22
  var __rest = void 0 && (void 0).__rest || function (s, e) {
39
23
  var t = {};
40
-
41
24
  for (var p in s) {
42
25
  if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
43
26
  }
44
-
45
27
  if (s != null && typeof _getOwnPropertySymbols.default === "function") for (var i = 0, p = (0, _getOwnPropertySymbols.default)(s); i < p.length; i++) {
46
28
  if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
47
29
  }
48
30
  return t;
49
31
  };
50
-
51
32
  function buildCrossTable(options) {
52
33
  var _a, _b, _c;
53
-
54
34
  var leftTotalNode = options.leftTotalNode,
55
- topTotalNode = options.topTotalNode; // 有的时候 leftTree/topTree 是通过 node.children 传入的
35
+ topTotalNode = options.topTotalNode;
36
+ // 有的时候 leftTree/topTree 是通过 node.children 传入的
56
37
  // 此时 leftTree/topTree 等于 null 和等于空数组是等价的
57
38
  // 故在这里兼容 leftTree/topTree 为空的情况
58
-
59
39
  var leftTree = (_a = options.leftTree) !== null && _a !== void 0 ? _a : [];
60
40
  var topTree = (_b = options.topTree) !== null && _b !== void 0 ? _b : [];
61
41
  var leftMetaColumns = (_c = options.leftMetaColumns) !== null && _c !== void 0 ? _c : [];
@@ -65,24 +45,17 @@ function buildCrossTable(options) {
65
45
  dataSource: getDataSource()
66
46
  };
67
47
  /** 获取表格的列配置 */
68
-
69
48
  function getColumns() {
70
49
  var _context;
71
-
72
50
  return (0, _concat.default)(_context = []).call(_context, (0, _toConsumableArray2.default)(getLeftPartColumns()), (0, _toConsumableArray2.default)(getDataPartColumns()));
73
-
74
51
  function getLeftPartColumns() {
75
52
  var _a;
76
-
77
53
  var leftPartColumns = [];
78
-
79
54
  for (var index = 0; index < leftHeaderWidth; index++) {
80
55
  var metaCol = (_a = leftMetaColumns[index]) !== null && _a !== void 0 ? _a : {};
81
-
82
56
  var getCellProps = metaCol.getCellProps,
83
- render = metaCol.render,
84
- staticMetaColConfig = __rest(metaCol, ["getCellProps", "render"]);
85
-
57
+ render = metaCol.render,
58
+ staticMetaColConfig = __rest(metaCol, ["getCellProps", "render"]);
86
59
  leftPartColumns.push((0, _extends2.default)((0, _extends2.default)({
87
60
  columnType: 'left',
88
61
  lock: true
@@ -93,48 +66,37 @@ function buildCrossTable(options) {
93
66
  render: leftHeaderRenderFactory(metaCol, index)
94
67
  }));
95
68
  }
96
-
97
69
  return leftPartColumns;
98
-
99
70
  function leftHeaderGetCellPropsFactory(metaCol, colIndex) {
100
71
  return function (_value, row, rowIndex) {
101
72
  var _a;
102
-
103
73
  var node = row.nodes[colIndex];
104
74
  return (_a = metaCol.getCellProps) === null || _a === void 0 ? void 0 : _a.call(metaCol, node, colIndex);
105
75
  };
106
76
  }
107
-
108
77
  function leftHeaderGetSpanRectFactory(metaCol, colIndex) {
109
78
  return function (_value, row) {
110
79
  return row.rects[colIndex];
111
80
  };
112
81
  }
113
-
114
82
  function leftHeaderGetValueFactory(metaCol, colIndex) {
115
83
  return function (row, rowIndex) {
116
84
  var node = row.nodes[colIndex];
117
85
  return node.value;
118
86
  };
119
87
  }
120
-
121
88
  function leftHeaderRenderFactory(metaCol, colIndex) {
122
89
  return function (v, row, rowIndex) {
123
90
  var _a;
124
-
125
91
  var node = row.nodes[colIndex];
126
-
127
92
  if (metaCol.render) {
128
93
  return metaCol.render(node, colIndex);
129
94
  }
130
-
131
95
  return (_a = node.title) !== null && _a !== void 0 ? _a : node.value;
132
96
  };
133
97
  }
134
98
  }
135
99
  /** 获取表格数据部分的列配置 */
136
-
137
-
138
100
  function getDataPartColumns() {
139
101
  if (topTree.length > 0) {
140
102
  return dfs(topTree, {
@@ -149,29 +111,25 @@ function buildCrossTable(options) {
149
111
  } else {
150
112
  return [];
151
113
  }
152
-
153
114
  function dfs(nodes, ctx) {
154
115
  var result = [];
155
-
156
116
  var _iterator = _createForOfIteratorHelper(nodes),
157
- _step;
158
-
117
+ _step;
159
118
  try {
160
119
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
161
120
  var node = _step.value;
162
121
  ctx.valuePath.push(node.value);
163
-
164
122
  if ((0, _utils.isLeafNode)(node)) {
165
123
  // 叶子节点
166
124
  result.push(getDataColumn(node, ctx.depth));
167
125
  } else {
168
126
  var key = node.key,
169
- value = node.value,
170
- children = node.children,
171
- others = __rest(node // 强制展开的节点
172
- , ["key", "value", "children"]); // 强制展开的节点
173
-
174
-
127
+ value = node.value,
128
+ children = node.children,
129
+ others = __rest(node
130
+ // 强制展开的节点
131
+ , ["key", "value", "children"]);
132
+ // 强制展开的节点
175
133
  result.push((0, _extends2.default)((0, _extends2.default)({
176
134
  columnType: 'data-parent'
177
135
  }, others), {
@@ -182,7 +140,6 @@ function buildCrossTable(options) {
182
140
  })
183
141
  }));
184
142
  }
185
-
186
143
  ctx.valuePath.pop();
187
144
  }
188
145
  } catch (err) {
@@ -190,23 +147,19 @@ function buildCrossTable(options) {
190
147
  } finally {
191
148
  _iterator.f();
192
149
  }
193
-
194
150
  return result;
195
151
  }
196
152
  }
197
-
198
153
  function getDataColumn(topNode, topDepth) {
199
154
  var columnGetValue = function columnGetValue(row) {
200
155
  var leftDepth = row.nodes.length - 1;
201
156
  var leftNode = row.nodes[leftDepth];
202
157
  return options.getValue(leftNode, topNode, leftDepth, topDepth);
203
158
  };
204
-
205
159
  var key = topNode.key,
206
- value = topNode.value,
207
- children = topNode.children,
208
- others = __rest(topNode, ["key", "value", "children"]);
209
-
160
+ value = topNode.value,
161
+ children = topNode.children,
162
+ others = __rest(topNode, ["key", "value", "children"]);
210
163
  return (0, _extends2.default)((0, _extends2.default)({
211
164
  columnType: 'data'
212
165
  }, others), {
@@ -219,7 +172,6 @@ function buildCrossTable(options) {
219
172
  var leftNode = row.nodes[leftDepth];
220
173
  return options.render(value, leftNode, topNode, leftDepth, topDepth);
221
174
  }
222
-
223
175
  return value;
224
176
  },
225
177
  getCellProps: function getCellProps(value, row) {
@@ -232,7 +184,6 @@ function buildCrossTable(options) {
232
184
  });
233
185
  }
234
186
  }
235
-
236
187
  function getDataSource() {
237
188
  var flatRows = [];
238
189
  var ctx = {
@@ -241,33 +192,24 @@ function buildCrossTable(options) {
241
192
  rects: [],
242
193
  rowIndex: 0
243
194
  };
244
-
245
195
  if (leftTree.length > 0) {
246
196
  dfs(leftTree, ctx);
247
197
  } else if (leftTotalNode) {
248
198
  dfs([leftTotalNode], ctx);
249
199
  } // else 表格没有行,展示空表格
250
-
251
-
252
200
  return flatRows;
253
-
254
201
  function dfs(nodes, ctx) {
255
202
  var count = 0;
256
-
257
203
  var _iterator2 = _createForOfIteratorHelper(nodes),
258
- _step2;
259
-
204
+ _step2;
260
205
  try {
261
206
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
262
207
  var _context2, _context3, _row;
263
-
264
208
  var node = _step2.value;
265
-
266
209
  if (node.hidden) {
267
210
  // 跳过被隐藏的节点
268
211
  continue;
269
212
  }
270
-
271
213
  var rect = {
272
214
  top: ctx.rowIndex + count,
273
215
  bottom: -1,
@@ -275,7 +217,6 @@ function buildCrossTable(options) {
275
217
  right: -1
276
218
  };
277
219
  var row = (_row = {}, (0, _defineProperty2.default)(_row, _constants.ROW_KEY, node.key), (0, _defineProperty2.default)(_row, "rects", (0, _concat.default)(_context2 = []).call(_context2, (0, _toConsumableArray2.default)(ctx.rects), [rect])), (0, _defineProperty2.default)(_row, "nodes", (0, _concat.default)(_context3 = []).call(_context3, (0, _toConsumableArray2.default)(ctx.nodes), [node])), _row);
278
-
279
220
  if ((0, _utils.isLeafNode)(node)) {
280
221
  rect.right = leftHeaderWidth;
281
222
  rect.bottom = rect.top + 1;
@@ -302,7 +243,6 @@ function buildCrossTable(options) {
302
243
  } finally {
303
244
  _iterator2.f();
304
245
  }
305
-
306
246
  return {
307
247
  count: count
308
248
  };
@@ -1,64 +1,51 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
11
-
12
9
  var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
13
-
14
10
  var _react = _interopRequireDefault(require("react"));
15
-
16
11
  var _base = require("../../base");
17
-
18
12
  var _buildCrossTable2 = _interopRequireDefault(require("./buildCrossTable"));
19
-
20
13
  var _constants = require("./constants");
21
-
22
14
  var __rest = void 0 && (void 0).__rest || function (s, e) {
23
15
  var t = {};
24
-
25
16
  for (var p in s) {
26
17
  if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
27
18
  }
28
-
29
19
  if (s != null && typeof _getOwnPropertySymbols.default === "function") for (var i = 0, p = (0, _getOwnPropertySymbols.default)(s); i < p.length; i++) {
30
20
  if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
31
21
  }
32
22
  return t;
33
23
  };
34
-
35
24
  var CrossTable = function CrossTable(_a) {
36
25
  var _a$BaseTableComponent = _a.BaseTableComponent,
37
- BaseTableComponent = _a$BaseTableComponent === void 0 ? _base.Table : _a$BaseTableComponent,
38
- leftTree = _a.leftTree,
39
- leftTotalNode = _a.leftTotalNode,
40
- topTree = _a.topTree,
41
- topTotalNode = _a.topTotalNode,
42
- getValue = _a.getValue,
43
- getCellProps = _a.getCellProps,
44
- leftMetaColumns = _a.leftMetaColumns,
45
- render = _a.render,
46
- baseTableRef = _a.baseTableRef,
47
- others = __rest(_a, ["BaseTableComponent", "leftTree", "leftTotalNode", "topTree", "topTotalNode", "getValue", "getCellProps", "leftMetaColumns", "render", "baseTableRef"]);
48
-
26
+ BaseTableComponent = _a$BaseTableComponent === void 0 ? _base.Table : _a$BaseTableComponent,
27
+ leftTree = _a.leftTree,
28
+ leftTotalNode = _a.leftTotalNode,
29
+ topTree = _a.topTree,
30
+ topTotalNode = _a.topTotalNode,
31
+ getValue = _a.getValue,
32
+ getCellProps = _a.getCellProps,
33
+ leftMetaColumns = _a.leftMetaColumns,
34
+ render = _a.render,
35
+ baseTableRef = _a.baseTableRef,
36
+ others = __rest(_a, ["BaseTableComponent", "leftTree", "leftTotalNode", "topTree", "topTotalNode", "getValue", "getCellProps", "leftMetaColumns", "render", "baseTableRef"]);
49
37
  var _buildCrossTable = (0, _buildCrossTable2.default)({
50
- leftTree: leftTree,
51
- topTree: topTree,
52
- leftTotalNode: leftTotalNode,
53
- topTotalNode: topTotalNode,
54
- getValue: getValue,
55
- getCellProps: getCellProps,
56
- render: render,
57
- leftMetaColumns: leftMetaColumns
58
- }),
59
- dataSource = _buildCrossTable.dataSource,
60
- columns = _buildCrossTable.columns;
61
-
38
+ leftTree: leftTree,
39
+ topTree: topTree,
40
+ leftTotalNode: leftTotalNode,
41
+ topTotalNode: topTotalNode,
42
+ getValue: getValue,
43
+ getCellProps: getCellProps,
44
+ render: render,
45
+ leftMetaColumns: leftMetaColumns
46
+ }),
47
+ dataSource = _buildCrossTable.dataSource,
48
+ columns = _buildCrossTable.columns;
62
49
  return /*#__PURE__*/_react.default.createElement(BaseTableComponent, (0, _extends2.default)({
63
50
  ref: baseTableRef
64
51
  }, others, {
@@ -67,5 +54,4 @@ var CrossTable = function CrossTable(_a) {
67
54
  columns: columns
68
55
  }));
69
56
  };
70
-
71
57
  exports.default = CrossTable;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -23,9 +22,6 @@ Object.defineProperty(exports, "buildCrossTable", {
23
22
  return _buildCrossTable.default;
24
23
  }
25
24
  });
26
-
27
25
  var _crossTable = _interopRequireDefault(require("./cross-table"));
28
-
29
26
  var _buildCrossTable = _interopRequireDefault(require("./buildCrossTable"));
30
-
31
27
  var _constants = require("./constants");