@kdcloudjs/table 1.2.0-canary.17 → 1.2.0-canary.17-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 (259) hide show
  1. package/LICENSE +568 -568
  2. package/README.md +111 -111
  3. package/dist/@kdcloudjs/table.css +1 -1
  4. package/dist/@kdcloudjs/table.js +4565 -5707
  5. package/dist/@kdcloudjs/table.js.map +1 -1
  6. package/dist/@kdcloudjs/table.min.css +1 -1
  7. package/dist/@kdcloudjs/table.min.js +18 -16
  8. package/dist/@kdcloudjs/table.min.js.map +1 -1
  9. package/dist/kd-ui-complete.less +777 -777
  10. package/es/_utils/arrayUtil.js +0 -3
  11. package/es/_utils/devwarning.js +0 -1
  12. package/es/_utils/formatUtil.js +36 -101
  13. package/es/_utils/hooks.js +21 -45
  14. package/es/_utils/index.js +0 -2
  15. package/es/_utils/numberUtil.js +32 -55
  16. package/es/_utils/omit.js +0 -2
  17. package/es/_utils/type.js +0 -2
  18. package/es/_utils/usePopper.js +74 -137
  19. package/es/config-provider/compDefaultProps.js +0 -1
  20. package/es/config-provider/configProvider.js +2 -7
  21. package/es/config-provider/defaultConfig.js +0 -1
  22. package/es/index.js +0 -2
  23. package/es/locale/locale.js +9 -48
  24. package/es/style/color/colors.less +1 -1
  25. package/es/style/core/index.less +1 -1
  26. package/es/style/core/motion/other.less +27 -27
  27. package/es/style/core/motion/slide.less +53 -53
  28. package/es/style/core/motion.less +1 -1
  29. package/es/style/core/reset.less +185 -185
  30. package/es/style/index.less +1 -1
  31. package/es/style/mixins/index.less +18 -18
  32. package/es/style/mixins/overlay.less +21 -21
  33. package/es/style/mixins/reset.less +12 -12
  34. package/es/style/themes/default.less +445 -445
  35. package/es/table/base/calculations.js +25 -75
  36. package/es/table/base/colgroup.js +0 -1
  37. package/es/table/base/empty.js +6 -6
  38. package/es/table/base/header.js +19 -74
  39. package/es/table/base/helpers/SpanManager.js +4 -11
  40. package/es/table/base/helpers/TableDOMUtils.js +5 -30
  41. package/es/table/base/helpers/__test__/SpanManager.test.js +2 -2
  42. package/es/table/base/helpers/__test__/TableDOMUtils.test.js +0 -1
  43. package/es/table/base/helpers/getRichVisibleRectsStream.js +11 -44
  44. package/es/table/base/helpers/rowHeightManager.js +0 -28
  45. package/es/table/base/html-table.js +17 -39
  46. package/es/table/base/loading.js +8 -10
  47. package/es/table/base/renderTemplates.js +41 -59
  48. package/es/table/base/styles.js +0 -9
  49. package/es/table/base/table.js +108 -197
  50. package/es/table/base/utils.js +17 -57
  51. package/es/table/common-views.js +0 -7
  52. package/es/table/internals.js +0 -13
  53. package/es/table/pipeline/features/autoFill.js +11 -40
  54. package/es/table/pipeline/features/autoRowSpan.js +1 -14
  55. package/es/table/pipeline/features/colGroupExtendable.js +4 -19
  56. package/es/table/pipeline/features/columnDrag.js +41 -97
  57. package/es/table/pipeline/features/columnFilter.js +12 -51
  58. package/es/table/pipeline/features/columnHover.js +1 -7
  59. package/es/table/pipeline/features/columnRangeHover.js +1 -8
  60. package/es/table/pipeline/features/columnResizeWidth.js +13 -39
  61. package/es/table/pipeline/features/contextMenu.js +18 -91
  62. package/es/table/pipeline/features/filter/DefaultFilterContent.js +14 -30
  63. package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
  64. package/es/table/pipeline/features/filter/Filter.js +26 -50
  65. package/es/table/pipeline/features/filter/FilterPanel.js +11 -25
  66. package/es/table/pipeline/features/filter/util.js +0 -4
  67. package/es/table/pipeline/features/footerDataSource.js +0 -3
  68. package/es/table/pipeline/features/mergeCellHover.js +0 -1
  69. package/es/table/pipeline/features/multiSelect.js +15 -57
  70. package/es/table/pipeline/features/rangeSelection.js +74 -154
  71. package/es/table/pipeline/features/rowDetail.js +4 -43
  72. package/es/table/pipeline/features/rowDrag.js +37 -75
  73. package/es/table/pipeline/features/rowGrouping.js +4 -37
  74. package/es/table/pipeline/features/singleSelect.js +0 -24
  75. package/es/table/pipeline/features/sort.js +37 -90
  76. package/es/table/pipeline/features/tips.js +4 -10
  77. package/es/table/pipeline/features/treeMode.js +14 -49
  78. package/es/table/pipeline/features/treeSelect.js +2 -28
  79. package/es/table/pipeline/pipeline.js +12 -53
  80. package/es/table/pivot/cross-table/buildCrossTable.js +21 -72
  81. package/es/table/pivot/cross-table/cross-table.js +23 -31
  82. package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -57
  83. package/es/table/pivot/cross-tree-table/cross-tree-table.js +35 -61
  84. package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
  85. package/es/table/pivot/pivot-utils/builders.js +34 -74
  86. package/es/table/pivot/pivot-utils/convert-utils.js +16 -42
  87. package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
  88. package/es/table/style/index.less +1 -1
  89. package/es/table/transforms/autoRowSpan.js +1 -15
  90. package/es/table/transforms/autoWidth.js +13 -35
  91. package/es/table/transforms/buildTree.js +1 -2
  92. package/es/table/transforms/columnHover.js +9 -15
  93. package/es/table/transforms/columnRangeHover.js +12 -19
  94. package/es/table/transforms/columnResize.js +18 -42
  95. package/es/table/transforms/flatten.js +0 -3
  96. package/es/table/transforms/orderField.js +0 -3
  97. package/es/table/transforms/sort.js +42 -96
  98. package/es/table/transforms/tips.js +5 -10
  99. package/es/table/transforms/treeMode.js +36 -77
  100. package/es/table/transforms/visible.js +0 -2
  101. package/es/table/use/useResizeObserver.js +1 -4
  102. package/es/table/utils/applyTransforms.js +0 -1
  103. package/es/table/utils/buildTree.js +7 -22
  104. package/es/table/utils/collectNodes.js +4 -13
  105. package/es/table/utils/console.js +0 -14
  106. package/es/table/utils/copyToClipboard.js +0 -4
  107. package/es/table/utils/element.js +14 -41
  108. package/es/table/utils/exportTableAsExcel.js +7 -43
  109. package/es/table/utils/getTreeDepth.js +4 -12
  110. package/es/table/utils/groupBy.js +4 -13
  111. package/es/table/utils/layeredFilter.js +0 -4
  112. package/es/table/utils/layeredSort.js +0 -5
  113. package/es/table/utils/makeRecursiveMapper.js +4 -15
  114. package/es/table/utils/mergeCellProps.js +6 -14
  115. package/es/table/utils/others.js +6 -19
  116. package/es/table/utils/proto.js +2 -30
  117. package/es/table/utils/smartCompare.js +4 -12
  118. package/es/table/utils/traverseColumn.js +5 -18
  119. package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +5 -27
  120. package/es/table/utils/tree-data-helpers/TreeDataHelper.js +19 -74
  121. package/lib/_utils/arrayUtil.js +2 -8
  122. package/lib/_utils/devwarning.js +0 -5
  123. package/lib/_utils/formatUtil.js +36 -105
  124. package/lib/_utils/hooks.js +21 -56
  125. package/lib/_utils/index.js +2 -9
  126. package/lib/_utils/numberUtil.js +32 -63
  127. package/lib/_utils/omit.js +0 -5
  128. package/lib/_utils/react-children.js +0 -5
  129. package/lib/_utils/type.js +3 -11
  130. package/lib/_utils/usePopper.js +79 -166
  131. package/lib/config-provider/ConfigContext.js +2 -6
  132. package/lib/config-provider/compDefaultProps.js +1 -3
  133. package/lib/config-provider/configProvider.js +6 -22
  134. package/lib/config-provider/defaultConfig.js +1 -7
  135. package/lib/config-provider/index.js +1 -8
  136. package/lib/index.js +2 -8
  137. package/lib/locale/index.js +3 -11
  138. package/lib/locale/locale.js +13 -69
  139. package/lib/locale/zh-CN.js +1 -2
  140. package/lib/style/color/colors.less +1 -1
  141. package/lib/style/components.less +1 -1
  142. package/lib/style/core/index.less +1 -1
  143. package/lib/style/core/motion/other.less +27 -27
  144. package/lib/style/core/motion/slide.less +53 -53
  145. package/lib/style/core/motion.less +1 -1
  146. package/lib/style/core/reset.less +185 -185
  147. package/lib/style/index.less +1 -1
  148. package/lib/style/mixins/index.less +18 -18
  149. package/lib/style/mixins/overlay.less +21 -21
  150. package/lib/style/mixins/reset.less +12 -12
  151. package/lib/style/themes/default.less +445 -445
  152. package/lib/table/base/calculations.js +25 -86
  153. package/lib/table/base/colgroup.js +0 -5
  154. package/lib/table/base/empty.js +8 -20
  155. package/lib/table/base/header.js +19 -84
  156. package/lib/table/base/helpers/SpanManager.js +6 -16
  157. package/lib/table/base/helpers/TableDOMUtils.js +5 -33
  158. package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
  159. package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
  160. package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
  161. package/lib/table/base/helpers/getRichVisibleRectsStream.js +13 -64
  162. package/lib/table/base/helpers/rowHeightManager.js +0 -33
  163. package/lib/table/base/html-table.js +17 -49
  164. package/lib/table/base/index.js +0 -2
  165. package/lib/table/base/loading.js +8 -14
  166. package/lib/table/base/renderTemplates.js +44 -75
  167. package/lib/table/base/styles.js +9 -37
  168. package/lib/table/base/table.js +120 -241
  169. package/lib/table/base/utils.js +27 -109
  170. package/lib/table/common-views.js +4 -24
  171. package/lib/table/index.js +0 -13
  172. package/lib/table/internals.js +2 -17
  173. package/lib/table/pipeline/features/autoFill.js +14 -53
  174. package/lib/table/pipeline/features/autoRowSpan.js +1 -19
  175. package/lib/table/pipeline/features/buildTree.js +0 -2
  176. package/lib/table/pipeline/features/colGroupExtendable.js +6 -35
  177. package/lib/table/pipeline/features/columnDrag.js +41 -103
  178. package/lib/table/pipeline/features/columnFilter.js +12 -65
  179. package/lib/table/pipeline/features/columnHover.js +1 -11
  180. package/lib/table/pipeline/features/columnRangeHover.js +1 -13
  181. package/lib/table/pipeline/features/columnResizeWidth.js +18 -63
  182. package/lib/table/pipeline/features/contextMenu.js +20 -117
  183. package/lib/table/pipeline/features/filter/DefaultFilterContent.js +17 -52
  184. package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
  185. package/lib/table/pipeline/features/filter/Filter.js +29 -76
  186. package/lib/table/pipeline/features/filter/FilterPanel.js +14 -44
  187. package/lib/table/pipeline/features/filter/index.js +0 -5
  188. package/lib/table/pipeline/features/filter/util.js +2 -10
  189. package/lib/table/pipeline/features/footerDataSource.js +1 -12
  190. package/lib/table/pipeline/features/index.js +0 -23
  191. package/lib/table/pipeline/features/mergeCellHover.js +0 -5
  192. package/lib/table/pipeline/features/multiSelect.js +15 -71
  193. package/lib/table/pipeline/features/rangeSelection.js +76 -175
  194. package/lib/table/pipeline/features/rowDetail.js +4 -67
  195. package/lib/table/pipeline/features/rowDrag.js +39 -89
  196. package/lib/table/pipeline/features/rowGrouping.js +4 -57
  197. package/lib/table/pipeline/features/singleSelect.js +0 -34
  198. package/lib/table/pipeline/features/sort.js +37 -110
  199. package/lib/table/pipeline/features/tips.js +4 -19
  200. package/lib/table/pipeline/features/treeMode.js +15 -72
  201. package/lib/table/pipeline/features/treeSelect.js +2 -36
  202. package/lib/table/pipeline/index.js +2 -10
  203. package/lib/table/pipeline/pipeline.js +13 -64
  204. package/lib/table/pivot/cross-table/buildCrossTable.js +21 -83
  205. package/lib/table/pivot/cross-table/constants.js +1 -2
  206. package/lib/table/pivot/cross-table/cross-table.js +25 -42
  207. package/lib/table/pivot/cross-table/index.js +0 -4
  208. package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -70
  209. package/lib/table/pivot/cross-tree-table/cross-tree-table.js +36 -73
  210. package/lib/table/pivot/cross-tree-table/index.js +0 -3
  211. package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
  212. package/lib/table/pivot/pivot-utils/builders.js +34 -85
  213. package/lib/table/pivot/pivot-utils/convert-utils.js +16 -60
  214. package/lib/table/pivot/pivot-utils/index.js +0 -7
  215. package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
  216. package/lib/table/style/css.js +0 -1
  217. package/lib/table/style/index.js +0 -1
  218. package/lib/table/style/index.less +1 -1
  219. package/lib/table/transforms/autoRowSpan.js +1 -21
  220. package/lib/table/transforms/autoWidth.js +15 -58
  221. package/lib/table/transforms/buildTree.js +1 -4
  222. package/lib/table/transforms/columnHover.js +9 -22
  223. package/lib/table/transforms/columnRangeHover.js +12 -27
  224. package/lib/table/transforms/columnResize.js +20 -63
  225. package/lib/table/transforms/flatten.js +0 -5
  226. package/lib/table/transforms/index.js +0 -12
  227. package/lib/table/transforms/orderField.js +0 -7
  228. package/lib/table/transforms/sort.js +44 -122
  229. package/lib/table/transforms/tips.js +5 -20
  230. package/lib/table/transforms/treeMode.js +38 -106
  231. package/lib/table/transforms/visible.js +0 -7
  232. package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
  233. package/lib/table/use/useResizeObserver.js +2 -10
  234. package/lib/table/utils/applyTransforms.js +0 -2
  235. package/lib/table/utils/browserType.js +2 -3
  236. package/lib/table/utils/buildTree.js +7 -33
  237. package/lib/table/utils/collectNodes.js +4 -18
  238. package/lib/table/utils/console.js +2 -19
  239. package/lib/table/utils/copyToClipboard.js +1 -8
  240. package/lib/table/utils/element.js +14 -46
  241. package/lib/table/utils/exportTableAsExcel.js +7 -52
  242. package/lib/table/utils/getTreeDepth.js +4 -17
  243. package/lib/table/utils/groupBy.js +4 -17
  244. package/lib/table/utils/index.js +0 -21
  245. package/lib/table/utils/isGroupColumn.js +0 -3
  246. package/lib/table/utils/isLeafNode.js +0 -1
  247. package/lib/table/utils/keyCode.js +1 -2
  248. package/lib/table/utils/layeredFilter.js +0 -10
  249. package/lib/table/utils/layeredSort.js +0 -10
  250. package/lib/table/utils/makeRecursiveMapper.js +4 -24
  251. package/lib/table/utils/mergeCellProps.js +6 -18
  252. package/lib/table/utils/others.js +7 -36
  253. package/lib/table/utils/proto.js +3 -35
  254. package/lib/table/utils/selectColumn.js +2 -5
  255. package/lib/table/utils/smartCompare.js +4 -13
  256. package/lib/table/utils/traverseColumn.js +5 -25
  257. package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +7 -38
  258. package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +21 -90
  259. package/package.json +219 -218
@@ -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
  *
@@ -41,12 +29,12 @@ var _autoFill = require("./features/autoFill");
41
29
  *
42
30
  * 4. snapshots,调用 pipeline.snapshot(name) 可以记录当前的状态,后续可以通过 name 来读取保存的状态
43
31
  * */
44
- var TablePipeline = /*#__PURE__*/function () {
32
+ var TablePipeline = exports.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
-
65
- (0, _createClass2.default)(TablePipeline, [{
50
+ }
51
+ // Generate a pseudo-GUID by concatenating random hexadecimal.
52
+ return (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,47 +245,36 @@ 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
- return TablePipeline;
313
266
  }();
314
-
315
- exports.TablePipeline = TablePipeline;
316
267
  TablePipeline.defaultIndents = {
317
268
  iconIndent: -8,
318
269
  iconWidth: 16,
319
270
  iconGap: 0,
320
271
  indentSize: 16
321
272
  };
322
-
323
273
  function useTablePipeline(ctx) {
324
274
  var _useState = (0, _react.useState)({}),
325
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
326
- state = _useState2[0],
327
- setState = _useState2[1];
328
-
275
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
276
+ state = _useState2[0],
277
+ setState = _useState2[1];
329
278
  var ref = (0, _react.useRef)({
330
279
  featureOptions: {}
331
280
  });
@@ -1,61 +1,39 @@
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
- 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
- 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
- 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
-
19
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && _getIteratorMethod(r) || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
20
+ function _unsupportedIterableToArray(r, a) { if (r) { var _context4; if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = _sliceInstanceProperty(_context4 = {}.toString.call(r)).call(_context4, 8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
21
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
38
22
  var __rest = void 0 && (void 0).__rest || function (s, e) {
39
23
  var t = {};
40
-
41
- for (var p in s) {
42
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
43
- }
44
-
24
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
45
25
  if (s != null && typeof _getOwnPropertySymbols.default === "function") for (var i = 0, p = (0, _getOwnPropertySymbols.default)(s); i < p.length; i++) {
46
26
  if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
47
27
  }
48
28
  return t;
49
29
  };
50
-
51
30
  function buildCrossTable(options) {
52
31
  var _a, _b, _c;
53
-
54
32
  var leftTotalNode = options.leftTotalNode,
55
- topTotalNode = options.topTotalNode; // 有的时候 leftTree/topTree 是通过 node.children 传入的
33
+ topTotalNode = options.topTotalNode;
34
+ // 有的时候 leftTree/topTree 是通过 node.children 传入的
56
35
  // 此时 leftTree/topTree 等于 null 和等于空数组是等价的
57
36
  // 故在这里兼容 leftTree/topTree 为空的情况
58
-
59
37
  var leftTree = (_a = options.leftTree) !== null && _a !== void 0 ? _a : [];
60
38
  var topTree = (_b = options.topTree) !== null && _b !== void 0 ? _b : [];
61
39
  var leftMetaColumns = (_c = options.leftMetaColumns) !== null && _c !== void 0 ? _c : [];
@@ -65,24 +43,17 @@ function buildCrossTable(options) {
65
43
  dataSource: getDataSource()
66
44
  };
67
45
  /** 获取表格的列配置 */
68
-
69
46
  function getColumns() {
70
47
  var _context;
71
-
72
48
  return (0, _concat.default)(_context = []).call(_context, (0, _toConsumableArray2.default)(getLeftPartColumns()), (0, _toConsumableArray2.default)(getDataPartColumns()));
73
-
74
49
  function getLeftPartColumns() {
75
50
  var _a;
76
-
77
51
  var leftPartColumns = [];
78
-
79
52
  for (var index = 0; index < leftHeaderWidth; index++) {
80
53
  var metaCol = (_a = leftMetaColumns[index]) !== null && _a !== void 0 ? _a : {};
81
-
82
54
  var getCellProps = metaCol.getCellProps,
83
- render = metaCol.render,
84
- staticMetaColConfig = __rest(metaCol, ["getCellProps", "render"]);
85
-
55
+ render = metaCol.render,
56
+ staticMetaColConfig = __rest(metaCol, ["getCellProps", "render"]);
86
57
  leftPartColumns.push((0, _extends2.default)((0, _extends2.default)({
87
58
  columnType: 'left',
88
59
  lock: true
@@ -93,48 +64,37 @@ function buildCrossTable(options) {
93
64
  render: leftHeaderRenderFactory(metaCol, index)
94
65
  }));
95
66
  }
96
-
97
67
  return leftPartColumns;
98
-
99
68
  function leftHeaderGetCellPropsFactory(metaCol, colIndex) {
100
69
  return function (_value, row, rowIndex) {
101
70
  var _a;
102
-
103
71
  var node = row.nodes[colIndex];
104
72
  return (_a = metaCol.getCellProps) === null || _a === void 0 ? void 0 : _a.call(metaCol, node, colIndex);
105
73
  };
106
74
  }
107
-
108
75
  function leftHeaderGetSpanRectFactory(metaCol, colIndex) {
109
76
  return function (_value, row) {
110
77
  return row.rects[colIndex];
111
78
  };
112
79
  }
113
-
114
80
  function leftHeaderGetValueFactory(metaCol, colIndex) {
115
81
  return function (row, rowIndex) {
116
82
  var node = row.nodes[colIndex];
117
83
  return node.value;
118
84
  };
119
85
  }
120
-
121
86
  function leftHeaderRenderFactory(metaCol, colIndex) {
122
87
  return function (v, row, rowIndex) {
123
88
  var _a;
124
-
125
89
  var node = row.nodes[colIndex];
126
-
127
90
  if (metaCol.render) {
128
91
  return metaCol.render(node, colIndex);
129
92
  }
130
-
131
93
  return (_a = node.title) !== null && _a !== void 0 ? _a : node.value;
132
94
  };
133
95
  }
134
96
  }
135
97
  /** 获取表格数据部分的列配置 */
136
-
137
-
138
98
  function getDataPartColumns() {
139
99
  if (topTree.length > 0) {
140
100
  return dfs(topTree, {
@@ -149,29 +109,25 @@ function buildCrossTable(options) {
149
109
  } else {
150
110
  return [];
151
111
  }
152
-
153
112
  function dfs(nodes, ctx) {
154
113
  var result = [];
155
-
156
114
  var _iterator = _createForOfIteratorHelper(nodes),
157
- _step;
158
-
115
+ _step;
159
116
  try {
160
117
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
161
118
  var node = _step.value;
162
119
  ctx.valuePath.push(node.value);
163
-
164
120
  if ((0, _utils.isLeafNode)(node)) {
165
121
  // 叶子节点
166
122
  result.push(getDataColumn(node, ctx.depth));
167
123
  } else {
168
124
  var key = node.key,
169
- value = node.value,
170
- children = node.children,
171
- others = __rest(node // 强制展开的节点
172
- , ["key", "value", "children"]); // 强制展开的节点
173
-
174
-
125
+ value = node.value,
126
+ children = node.children,
127
+ others = __rest(node
128
+ // 强制展开的节点
129
+ , ["key", "value", "children"]);
130
+ // 强制展开的节点
175
131
  result.push((0, _extends2.default)((0, _extends2.default)({
176
132
  columnType: 'data-parent'
177
133
  }, others), {
@@ -182,7 +138,6 @@ function buildCrossTable(options) {
182
138
  })
183
139
  }));
184
140
  }
185
-
186
141
  ctx.valuePath.pop();
187
142
  }
188
143
  } catch (err) {
@@ -190,23 +145,19 @@ function buildCrossTable(options) {
190
145
  } finally {
191
146
  _iterator.f();
192
147
  }
193
-
194
148
  return result;
195
149
  }
196
150
  }
197
-
198
151
  function getDataColumn(topNode, topDepth) {
199
152
  var columnGetValue = function columnGetValue(row) {
200
153
  var leftDepth = row.nodes.length - 1;
201
154
  var leftNode = row.nodes[leftDepth];
202
155
  return options.getValue(leftNode, topNode, leftDepth, topDepth);
203
156
  };
204
-
205
157
  var key = topNode.key,
206
- value = topNode.value,
207
- children = topNode.children,
208
- others = __rest(topNode, ["key", "value", "children"]);
209
-
158
+ value = topNode.value,
159
+ children = topNode.children,
160
+ others = __rest(topNode, ["key", "value", "children"]);
210
161
  return (0, _extends2.default)((0, _extends2.default)({
211
162
  columnType: 'data'
212
163
  }, others), {
@@ -219,7 +170,6 @@ function buildCrossTable(options) {
219
170
  var leftNode = row.nodes[leftDepth];
220
171
  return options.render(value, leftNode, topNode, leftDepth, topDepth);
221
172
  }
222
-
223
173
  return value;
224
174
  },
225
175
  getCellProps: function getCellProps(value, row) {
@@ -232,7 +182,6 @@ function buildCrossTable(options) {
232
182
  });
233
183
  }
234
184
  }
235
-
236
185
  function getDataSource() {
237
186
  var flatRows = [];
238
187
  var ctx = {
@@ -241,41 +190,31 @@ function buildCrossTable(options) {
241
190
  rects: [],
242
191
  rowIndex: 0
243
192
  };
244
-
245
193
  if (leftTree.length > 0) {
246
194
  dfs(leftTree, ctx);
247
195
  } else if (leftTotalNode) {
248
196
  dfs([leftTotalNode], ctx);
249
197
  } // else 表格没有行,展示空表格
250
-
251
-
252
198
  return flatRows;
253
-
254
199
  function dfs(nodes, ctx) {
255
200
  var count = 0;
256
-
257
201
  var _iterator2 = _createForOfIteratorHelper(nodes),
258
- _step2;
259
-
202
+ _step2;
260
203
  try {
261
204
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
262
- var _context2, _context3, _row;
263
-
205
+ var _context2, _context3;
264
206
  var node = _step2.value;
265
-
266
207
  if (node.hidden) {
267
208
  // 跳过被隐藏的节点
268
209
  continue;
269
210
  }
270
-
271
211
  var rect = {
272
212
  top: ctx.rowIndex + count,
273
213
  bottom: -1,
274
214
  left: ctx.depth,
275
215
  right: -1
276
216
  };
277
- 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
-
217
+ var row = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.ROW_KEY, node.key), "rects", (0, _concat.default)(_context2 = []).call(_context2, (0, _toConsumableArray2.default)(ctx.rects), [rect])), "nodes", (0, _concat.default)(_context3 = []).call(_context3, (0, _toConsumableArray2.default)(ctx.nodes), [node]));
279
218
  if ((0, _utils.isLeafNode)(node)) {
280
219
  rect.right = leftHeaderWidth;
281
220
  rect.bottom = rect.top + 1;
@@ -302,7 +241,6 @@ function buildCrossTable(options) {
302
241
  } finally {
303
242
  _iterator2.f();
304
243
  }
305
-
306
244
  return {
307
245
  count: count
308
246
  };
@@ -4,5 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ROW_KEY = void 0;
7
- var ROW_KEY = 'rowKey';
8
- exports.ROW_KEY = ROW_KEY;
7
+ var ROW_KEY = exports.ROW_KEY = 'rowKey';
@@ -1,64 +1,49 @@
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
- for (var p in s) {
26
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
27
- }
28
-
16
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
29
17
  if (s != null && typeof _getOwnPropertySymbols.default === "function") for (var i = 0, p = (0, _getOwnPropertySymbols.default)(s); i < p.length; i++) {
30
18
  if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
31
19
  }
32
20
  return t;
33
21
  };
34
-
35
- var CrossTable = function CrossTable(_a) {
22
+ var CrossTable = exports.default = function CrossTable(_a) {
36
23
  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
-
24
+ BaseTableComponent = _a$BaseTableComponent === void 0 ? _base.Table : _a$BaseTableComponent,
25
+ leftTree = _a.leftTree,
26
+ leftTotalNode = _a.leftTotalNode,
27
+ topTree = _a.topTree,
28
+ topTotalNode = _a.topTotalNode,
29
+ getValue = _a.getValue,
30
+ getCellProps = _a.getCellProps,
31
+ leftMetaColumns = _a.leftMetaColumns,
32
+ render = _a.render,
33
+ baseTableRef = _a.baseTableRef,
34
+ others = __rest(_a, ["BaseTableComponent", "leftTree", "leftTotalNode", "topTree", "topTotalNode", "getValue", "getCellProps", "leftMetaColumns", "render", "baseTableRef"]);
49
35
  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
-
36
+ leftTree: leftTree,
37
+ topTree: topTree,
38
+ leftTotalNode: leftTotalNode,
39
+ topTotalNode: topTotalNode,
40
+ getValue: getValue,
41
+ getCellProps: getCellProps,
42
+ render: render,
43
+ leftMetaColumns: leftMetaColumns
44
+ }),
45
+ dataSource = _buildCrossTable.dataSource,
46
+ columns = _buildCrossTable.columns;
62
47
  return /*#__PURE__*/_react.default.createElement(BaseTableComponent, (0, _extends2.default)({
63
48
  ref: baseTableRef
64
49
  }, others, {
@@ -66,6 +51,4 @@ var CrossTable = function CrossTable(_a) {
66
51
  dataSource: dataSource,
67
52
  columns: columns
68
53
  }));
69
- };
70
-
71
- exports.default = CrossTable;
54
+ };