@kdcloudjs/table 1.2.1-canary.6 → 1.2.2-canary.3

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 (288) 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 +5480 -6087
  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 +81 -144
  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 +11 -50
  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/globalStyleComponent.d.ts +4 -0
  39. package/es/table/base/globalStyleComponent.js +24 -0
  40. package/es/table/base/header.js +21 -76
  41. package/es/table/base/helpers/SpanManager.js +4 -11
  42. package/es/table/base/helpers/TableDOMUtils.js +9 -34
  43. package/es/table/base/helpers/__test__/SpanManager.test.js +2 -2
  44. package/es/table/base/helpers/__test__/TableDOMUtils.test.js +0 -1
  45. package/es/table/base/helpers/getRichVisibleRectsStream.js +13 -45
  46. package/es/table/base/helpers/rowHeightManager.js +0 -28
  47. package/es/table/base/html-table.js +17 -39
  48. package/es/table/base/loading.js +8 -10
  49. package/es/table/base/renderTemplates.js +42 -60
  50. package/es/table/base/styles.d.ts +10 -0
  51. package/es/table/base/styles.js +17 -16
  52. package/es/table/base/table.js +113 -201
  53. package/es/table/base/utils.js +17 -57
  54. package/es/table/common-views.js +0 -7
  55. package/es/table/interfaces.d.ts +38 -0
  56. package/es/table/internals.js +0 -13
  57. package/es/table/pipeline/const.d.ts +3 -0
  58. package/es/table/pipeline/const.js +3 -0
  59. package/es/table/pipeline/features/autoFill.js +11 -40
  60. package/es/table/pipeline/features/autoRowSpan.js +1 -14
  61. package/es/table/pipeline/features/colGroupExtendable.js +4 -19
  62. package/es/table/pipeline/features/columnDrag.js +41 -97
  63. package/es/table/pipeline/features/columnFilter.js +12 -51
  64. package/es/table/pipeline/features/columnHover.js +1 -7
  65. package/es/table/pipeline/features/columnRangeHover.js +1 -8
  66. package/es/table/pipeline/features/columnResizeWidth.js +13 -39
  67. package/es/table/pipeline/features/contextMenu.js +22 -95
  68. package/es/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
  69. package/es/table/pipeline/features/featureApi/RowDragApi.js +66 -0
  70. package/es/table/pipeline/features/featureApi/utils.d.ts +2 -0
  71. package/es/table/pipeline/features/featureApi/utils.js +10 -0
  72. package/es/table/pipeline/features/filter/DefaultFilterContent.js +14 -30
  73. package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
  74. package/es/table/pipeline/features/filter/Filter.js +27 -51
  75. package/es/table/pipeline/features/filter/FilterPanel.js +11 -25
  76. package/es/table/pipeline/features/filter/util.js +0 -4
  77. package/es/table/pipeline/features/footerDataSource.js +0 -3
  78. package/es/table/pipeline/features/mergeCellHover.js +0 -1
  79. package/es/table/pipeline/features/multiSelect.js +15 -57
  80. package/es/table/pipeline/features/rangeSelection.js +73 -152
  81. package/es/table/pipeline/features/rowDetail.js +4 -43
  82. package/es/table/pipeline/features/rowDrag.d.ts +10 -12
  83. package/es/table/pipeline/features/rowDrag.js +491 -236
  84. package/es/table/pipeline/features/rowGrouping.js +4 -37
  85. package/es/table/pipeline/features/singleSelect.js +0 -24
  86. package/es/table/pipeline/features/sort.js +38 -96
  87. package/es/table/pipeline/features/tips.js +4 -10
  88. package/es/table/pipeline/features/treeMode.d.ts +1 -0
  89. package/es/table/pipeline/features/treeMode.js +38 -57
  90. package/es/table/pipeline/features/treeSelect.js +2 -28
  91. package/es/table/pipeline/pipeline.d.ts +3 -0
  92. package/es/table/pipeline/pipeline.js +35 -54
  93. package/es/table/pivot/cross-table/buildCrossTable.js +21 -72
  94. package/es/table/pivot/cross-table/cross-table.js +23 -31
  95. package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -57
  96. package/es/table/pivot/cross-tree-table/cross-tree-table.js +36 -61
  97. package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
  98. package/es/table/pivot/pivot-utils/builders.js +34 -74
  99. package/es/table/pivot/pivot-utils/convert-utils.js +16 -42
  100. package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
  101. package/es/table/style/index.less +1 -1
  102. package/es/table/transforms/autoRowSpan.js +1 -15
  103. package/es/table/transforms/autoWidth.js +13 -35
  104. package/es/table/transforms/buildTree.js +1 -2
  105. package/es/table/transforms/columnHover.js +9 -15
  106. package/es/table/transforms/columnRangeHover.js +12 -19
  107. package/es/table/transforms/columnResize.js +18 -42
  108. package/es/table/transforms/flatten.js +0 -3
  109. package/es/table/transforms/orderField.js +0 -3
  110. package/es/table/transforms/sort.js +42 -101
  111. package/es/table/transforms/tips.js +5 -10
  112. package/es/table/transforms/treeMode.js +36 -77
  113. package/es/table/transforms/visible.js +0 -2
  114. package/es/table/use/useResizeObserver.js +1 -4
  115. package/es/table/utils/applyTransforms.js +0 -1
  116. package/es/table/utils/browserType.js +12 -19
  117. package/es/table/utils/buildTree.js +7 -22
  118. package/es/table/utils/collectNodes.js +4 -13
  119. package/es/table/utils/console.js +0 -14
  120. package/es/table/utils/copyToClipboard.js +0 -4
  121. package/es/table/utils/element.js +14 -41
  122. package/es/table/utils/exportTableAsExcel.js +7 -43
  123. package/es/table/utils/getTreeDepth.js +4 -12
  124. package/es/table/utils/groupBy.js +4 -13
  125. package/es/table/utils/layeredFilter.js +0 -4
  126. package/es/table/utils/layeredSort.js +0 -5
  127. package/es/table/utils/makeRecursiveMapper.js +4 -15
  128. package/es/table/utils/mergeCellProps.js +6 -14
  129. package/es/table/utils/others.js +6 -19
  130. package/es/table/utils/proto.js +2 -30
  131. package/es/table/utils/smartCompare.js +4 -12
  132. package/es/table/utils/traverseColumn.js +5 -18
  133. package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +8 -30
  134. package/es/table/utils/tree-data-helpers/TreeDataHelper.js +19 -74
  135. package/es/table/utils/uiDegrade.js +0 -5
  136. package/lib/_utils/arrayUtil.js +2 -8
  137. package/lib/_utils/devwarning.js +0 -5
  138. package/lib/_utils/formatUtil.js +36 -105
  139. package/lib/_utils/hooks.js +21 -56
  140. package/lib/_utils/index.js +2 -9
  141. package/lib/_utils/numberUtil.js +32 -63
  142. package/lib/_utils/omit.js +0 -5
  143. package/lib/_utils/react-children.js +0 -5
  144. package/lib/_utils/type.js +3 -11
  145. package/lib/_utils/usePopper.js +86 -173
  146. package/lib/config-provider/ConfigContext.js +2 -6
  147. package/lib/config-provider/compDefaultProps.js +1 -3
  148. package/lib/config-provider/configProvider.js +6 -22
  149. package/lib/config-provider/defaultConfig.js +1 -7
  150. package/lib/config-provider/index.js +1 -8
  151. package/lib/index.js +2 -8
  152. package/lib/locale/index.js +3 -11
  153. package/lib/locale/locale.js +15 -71
  154. package/lib/locale/zh-CN.js +1 -2
  155. package/lib/style/color/colors.less +1 -1
  156. package/lib/style/components.less +1 -1
  157. package/lib/style/core/index.less +1 -1
  158. package/lib/style/core/motion/other.less +27 -27
  159. package/lib/style/core/motion/slide.less +53 -53
  160. package/lib/style/core/motion.less +1 -1
  161. package/lib/style/core/reset.less +185 -185
  162. package/lib/style/index.less +1 -1
  163. package/lib/style/mixins/index.less +18 -18
  164. package/lib/style/mixins/overlay.less +21 -21
  165. package/lib/style/mixins/reset.less +12 -12
  166. package/lib/style/themes/default.less +445 -445
  167. package/lib/table/base/calculations.js +25 -86
  168. package/lib/table/base/colgroup.js +0 -5
  169. package/lib/table/base/empty.js +8 -20
  170. package/lib/table/base/globalStyleComponent.d.ts +4 -0
  171. package/lib/table/base/globalStyleComponent.js +35 -0
  172. package/lib/table/base/header.js +21 -86
  173. package/lib/table/base/helpers/SpanManager.js +6 -16
  174. package/lib/table/base/helpers/TableDOMUtils.js +9 -37
  175. package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
  176. package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
  177. package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
  178. package/lib/table/base/helpers/getRichVisibleRectsStream.js +15 -65
  179. package/lib/table/base/helpers/rowHeightManager.js +0 -33
  180. package/lib/table/base/html-table.js +17 -49
  181. package/lib/table/base/index.js +0 -2
  182. package/lib/table/base/loading.js +8 -14
  183. package/lib/table/base/renderTemplates.js +45 -76
  184. package/lib/table/base/styles.d.ts +10 -0
  185. package/lib/table/base/styles.js +24 -42
  186. package/lib/table/base/table.js +125 -245
  187. package/lib/table/base/utils.js +27 -109
  188. package/lib/table/common-views.js +4 -24
  189. package/lib/table/index.js +0 -13
  190. package/lib/table/interfaces.d.ts +38 -0
  191. package/lib/table/internals.js +2 -17
  192. package/lib/table/pipeline/const.d.ts +3 -0
  193. package/lib/table/pipeline/const.js +9 -0
  194. package/lib/table/pipeline/features/autoFill.js +14 -53
  195. package/lib/table/pipeline/features/autoRowSpan.js +1 -19
  196. package/lib/table/pipeline/features/buildTree.js +0 -2
  197. package/lib/table/pipeline/features/colGroupExtendable.js +6 -35
  198. package/lib/table/pipeline/features/columnDrag.js +41 -103
  199. package/lib/table/pipeline/features/columnFilter.js +12 -65
  200. package/lib/table/pipeline/features/columnHover.js +1 -11
  201. package/lib/table/pipeline/features/columnRangeHover.js +1 -13
  202. package/lib/table/pipeline/features/columnResizeWidth.js +18 -63
  203. package/lib/table/pipeline/features/contextMenu.js +24 -121
  204. package/lib/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
  205. package/lib/table/pipeline/features/featureApi/RowDragApi.js +72 -0
  206. package/lib/table/pipeline/features/featureApi/utils.d.ts +2 -0
  207. package/lib/table/pipeline/features/featureApi/utils.js +17 -0
  208. package/lib/table/pipeline/features/filter/DefaultFilterContent.js +17 -52
  209. package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
  210. package/lib/table/pipeline/features/filter/Filter.js +30 -77
  211. package/lib/table/pipeline/features/filter/FilterPanel.js +14 -44
  212. package/lib/table/pipeline/features/filter/index.js +0 -5
  213. package/lib/table/pipeline/features/filter/util.js +2 -10
  214. package/lib/table/pipeline/features/footerDataSource.js +1 -12
  215. package/lib/table/pipeline/features/index.js +0 -23
  216. package/lib/table/pipeline/features/mergeCellHover.js +0 -5
  217. package/lib/table/pipeline/features/multiSelect.js +15 -71
  218. package/lib/table/pipeline/features/rangeSelection.js +75 -173
  219. package/lib/table/pipeline/features/rowDetail.js +4 -67
  220. package/lib/table/pipeline/features/rowDrag.d.ts +10 -12
  221. package/lib/table/pipeline/features/rowDrag.js +494 -252
  222. package/lib/table/pipeline/features/rowGrouping.js +4 -57
  223. package/lib/table/pipeline/features/singleSelect.js +0 -34
  224. package/lib/table/pipeline/features/sort.js +37 -115
  225. package/lib/table/pipeline/features/tips.js +4 -19
  226. package/lib/table/pipeline/features/treeMode.d.ts +1 -0
  227. package/lib/table/pipeline/features/treeMode.js +40 -80
  228. package/lib/table/pipeline/features/treeSelect.js +2 -36
  229. package/lib/table/pipeline/index.js +2 -10
  230. package/lib/table/pipeline/pipeline.d.ts +3 -0
  231. package/lib/table/pipeline/pipeline.js +36 -65
  232. package/lib/table/pivot/cross-table/buildCrossTable.js +21 -83
  233. package/lib/table/pivot/cross-table/constants.js +1 -2
  234. package/lib/table/pivot/cross-table/cross-table.js +25 -42
  235. package/lib/table/pivot/cross-table/index.js +0 -4
  236. package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +22 -70
  237. package/lib/table/pivot/cross-tree-table/cross-tree-table.js +37 -73
  238. package/lib/table/pivot/cross-tree-table/index.js +0 -3
  239. package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
  240. package/lib/table/pivot/pivot-utils/builders.js +34 -85
  241. package/lib/table/pivot/pivot-utils/convert-utils.js +16 -60
  242. package/lib/table/pivot/pivot-utils/index.js +0 -7
  243. package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
  244. package/lib/table/style/css.js +0 -1
  245. package/lib/table/style/index.js +0 -1
  246. package/lib/table/style/index.less +1 -1
  247. package/lib/table/transforms/autoRowSpan.js +1 -21
  248. package/lib/table/transforms/autoWidth.js +15 -58
  249. package/lib/table/transforms/buildTree.js +1 -4
  250. package/lib/table/transforms/columnHover.js +9 -22
  251. package/lib/table/transforms/columnRangeHover.js +12 -27
  252. package/lib/table/transforms/columnResize.js +20 -63
  253. package/lib/table/transforms/flatten.js +0 -5
  254. package/lib/table/transforms/index.js +0 -12
  255. package/lib/table/transforms/orderField.js +0 -7
  256. package/lib/table/transforms/sort.js +44 -127
  257. package/lib/table/transforms/tips.js +5 -20
  258. package/lib/table/transforms/treeMode.js +38 -106
  259. package/lib/table/transforms/visible.js +0 -7
  260. package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
  261. package/lib/table/use/useResizeObserver.js +2 -10
  262. package/lib/table/utils/applyTransforms.js +0 -2
  263. package/lib/table/utils/browserType.js +14 -23
  264. package/lib/table/utils/buildTree.js +7 -33
  265. package/lib/table/utils/collectNodes.js +4 -18
  266. package/lib/table/utils/console.js +2 -19
  267. package/lib/table/utils/copyToClipboard.js +1 -8
  268. package/lib/table/utils/element.js +14 -46
  269. package/lib/table/utils/exportTableAsExcel.js +7 -52
  270. package/lib/table/utils/getTreeDepth.js +4 -17
  271. package/lib/table/utils/groupBy.js +4 -17
  272. package/lib/table/utils/index.js +0 -22
  273. package/lib/table/utils/isGroupColumn.js +0 -3
  274. package/lib/table/utils/isLeafNode.js +0 -1
  275. package/lib/table/utils/keyCode.js +1 -2
  276. package/lib/table/utils/layeredFilter.js +0 -10
  277. package/lib/table/utils/layeredSort.js +0 -10
  278. package/lib/table/utils/makeRecursiveMapper.js +4 -24
  279. package/lib/table/utils/mergeCellProps.js +6 -18
  280. package/lib/table/utils/others.js +7 -36
  281. package/lib/table/utils/proto.js +3 -35
  282. package/lib/table/utils/selectColumn.js +2 -5
  283. package/lib/table/utils/smartCompare.js +4 -13
  284. package/lib/table/utils/traverseColumn.js +5 -25
  285. package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +10 -41
  286. package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +21 -90
  287. package/lib/table/utils/uiDegrade.js +1 -8
  288. package/package.json +218 -218
@@ -1,33 +1,22 @@
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
-
19
+ var _utils2 = require("./features/featureApi/utils");
31
20
  /**
32
21
  * 表格数据处理流水线。TablePipeline 提供了表格数据处理过程中的一些上下方与工具方法,包括……
33
22
  *
@@ -41,12 +30,12 @@ var _autoFill = require("./features/autoFill");
41
30
  *
42
31
  * 4. snapshots,调用 pipeline.snapshot(name) 可以记录当前的状态,后续可以通过 name 来读取保存的状态
43
32
  * */
44
- var TablePipeline = /*#__PURE__*/function () {
33
+ var TablePipeline = exports.TablePipeline = /*#__PURE__*/function () {
45
34
  function TablePipeline(_ref) {
46
35
  var state = _ref.state,
47
- setState = _ref.setState,
48
- ctx = _ref.ctx,
49
- ref = _ref.ref;
36
+ setState = _ref.setState,
37
+ ctx = _ref.ctx,
38
+ ref = _ref.ref;
50
39
  (0, _classCallCheck2.default)(this, TablePipeline);
51
40
  this._snapshots = {};
52
41
  this._rowPropsGetters = [];
@@ -59,23 +48,20 @@ var TablePipeline = /*#__PURE__*/function () {
59
48
  this.setState = setState;
60
49
  this.ref = ref;
61
50
  (0, _extends3.default)(this.ctx, ctx);
62
- } // Generate a pseudo-GUID by concatenating random hexadecimal.
63
-
64
-
65
- (0, _createClass2.default)(TablePipeline, [{
51
+ }
52
+ // Generate a pseudo-GUID by concatenating random hexadecimal.
53
+ return (0, _createClass2.default)(TablePipeline, [{
66
54
  key: "guid",
67
55
  value: function guid() {
68
56
  function S4() {
69
57
  return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
70
58
  }
71
-
72
59
  return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
73
60
  }
74
61
  }, {
75
62
  key: "appendRowPropsGetter",
76
63
  value: function appendRowPropsGetter(getter) {
77
64
  this._rowPropsGetters.push(getter);
78
-
79
65
  return this;
80
66
  }
81
67
  }, {
@@ -115,11 +101,9 @@ var TablePipeline = /*#__PURE__*/function () {
115
101
  key: "getStateAtKey",
116
102
  value: function getStateAtKey(stateKey, defaultValue) {
117
103
  var _a;
118
-
119
104
  return (_a = this.state[stateKey]) !== null && _a !== void 0 ? _a : defaultValue;
120
105
  }
121
106
  /** 将 stateKey 对应的状态设置为 partialState */
122
-
123
107
  }, {
124
108
  key: "setStateAtKey",
125
109
  value: function setStateAtKey(stateKey, partialState, extraInfo) {
@@ -128,32 +112,28 @@ var TablePipeline = /*#__PURE__*/function () {
128
112
  }, stateKey, partialState, extraInfo);
129
113
  }
130
114
  /** 确保 primaryKey 已被设置,并返回 primaryKey */
131
-
132
115
  }, {
133
116
  key: "ensurePrimaryKey",
134
117
  value: function ensurePrimaryKey(hint) {
135
118
  if (this.ctx.primaryKey == null) {
136
119
  throw new Error(hint ? "\u4F7F\u7528 ".concat(hint, " \u4E4B\u524D\u5FC5\u987B\u5148\u8BBE\u7F6E primaryKey") : '必须先设置 primaryKey');
137
120
  }
138
-
139
121
  return this.ctx.primaryKey;
140
122
  }
141
123
  /** 设置流水线的输入数据 */
142
-
143
124
  }, {
144
125
  key: "input",
145
126
  value: function input(_input) {
146
127
  var _context,
147
- _this = this;
148
-
128
+ _this = this;
149
129
  if (this._dataSource != null || this._columns != null) {
150
130
  throw new Error('input 不能调用两次');
151
- } // 在 pipeline 中识别本次更新是否有数据变化
152
-
153
-
131
+ }
132
+ // 在 pipeline 中识别本次更新是否有数据变化
154
133
  this._isSameInputDataSource = _input.dataSource === this.ref.current._lastInputDataSource;
155
134
  this._dataSource = _input.dataSource;
156
135
  this.ref.current._lastInputDataSource = _input.dataSource;
136
+ this.ref.current.lastPipeline = this;
157
137
  this._columns = (0, _map.default)(_context = _input.columns).call(_context, function (col) {
158
138
  return (0, _extends3.default)((0, _extends3.default)({}, col), {
159
139
  key: _this.guid()
@@ -163,7 +143,6 @@ var TablePipeline = /*#__PURE__*/function () {
163
143
  return this;
164
144
  }
165
145
  /** 设置 dataSource */
166
-
167
146
  }, {
168
147
  key: "dataSource",
169
148
  value: function dataSource(rows) {
@@ -171,7 +150,6 @@ var TablePipeline = /*#__PURE__*/function () {
171
150
  return this;
172
151
  }
173
152
  /** 设置 columns */
174
-
175
153
  }, {
176
154
  key: "columns",
177
155
  value: function columns(cols) {
@@ -179,7 +157,6 @@ var TablePipeline = /*#__PURE__*/function () {
179
157
  return this;
180
158
  }
181
159
  /** 设置主键 */
182
-
183
160
  }, {
184
161
  key: "primaryKey",
185
162
  value: function primaryKey(key) {
@@ -187,7 +164,6 @@ var TablePipeline = /*#__PURE__*/function () {
187
164
  return this;
188
165
  }
189
166
  /** 设置页脚数据 */
190
-
191
167
  }, {
192
168
  key: "footerDataSource",
193
169
  value: function footerDataSource(rows) {
@@ -195,12 +171,10 @@ var TablePipeline = /*#__PURE__*/function () {
195
171
  return this;
196
172
  }
197
173
  /** 保存快照 */
198
-
199
174
  }, {
200
175
  key: "snapshot",
201
176
  value: function snapshot(name) {
202
177
  var _context2;
203
-
204
178
  this._snapshots[name] = {
205
179
  dataSource: this._dataSource,
206
180
  columns: this._columns,
@@ -210,7 +184,6 @@ var TablePipeline = /*#__PURE__*/function () {
210
184
  }
211
185
  /** @deprecated
212
186
  * 应用一个 kd-table Table transform */
213
-
214
187
  }, {
215
188
  key: "useTransform",
216
189
  value: function useTransform(transform) {
@@ -221,63 +194,52 @@ var TablePipeline = /*#__PURE__*/function () {
221
194
  return this.dataSource(next.dataSource).columns(next.columns);
222
195
  }
223
196
  /** 使用 pipeline 功能拓展 */
224
-
225
197
  }, {
226
198
  key: "use",
227
199
  value: function use(step) {
228
200
  return step(this);
229
201
  }
230
202
  /** 转换 dataSource */
231
-
232
203
  }, {
233
204
  key: "mapDataSource",
234
205
  value: function mapDataSource(mapper) {
235
206
  return this.dataSource(mapper(this.getDataSource()));
236
207
  }
237
208
  /** 转换 columns */
238
-
239
209
  }, {
240
210
  key: "mapColumns",
241
211
  value: function mapColumns(mapper) {
242
212
  return this.columns(mapper(this.getColumns()));
243
213
  }
244
214
  /** 获取featureOptions 内容 */
245
-
246
215
  }, {
247
216
  key: "getFeatureOptions",
248
217
  value: function getFeatureOptions(optionKey) {
249
218
  var _a;
250
-
251
219
  return (_a = this.ref.current.featureOptions) === null || _a === void 0 ? void 0 : _a[optionKey];
252
220
  }
253
221
  /** 设置pipelineOptions 内容 */
254
-
255
222
  }, {
256
223
  key: "setFeatureOptions",
257
224
  value: function setFeatureOptions(optionKey, value) {
258
225
  this.ref.current.featureOptions[optionKey] = value;
259
226
  }
260
227
  /** 获取 BaseTable 的 props,结果中包含 dataSource/columns/primaryKey/getRowProps 四个字段 */
261
-
262
228
  }, {
263
229
  key: "getProps",
264
230
  value: function getProps() {
265
231
  var _this2 = this;
266
-
267
232
  this.use((0, _autoFill.autoFillTableWidth)());
268
233
  var result = {
269
234
  dataSource: this._dataSource,
270
235
  columns: this._columns
271
236
  };
272
-
273
237
  if (this.ctx.primaryKey) {
274
238
  result.primaryKey = this.ctx.primaryKey;
275
239
  }
276
-
277
240
  if (this._footerDataSource) {
278
241
  result.footerDataSource = this._footerDataSource;
279
242
  }
280
-
281
243
  if (this._rowPropsGetters.length > 0) {
282
244
  result.getRowProps = function (row, rowIndex) {
283
245
  return _this2._rowPropsGetters.reduce(function (res, get) {
@@ -285,49 +247,58 @@ var TablePipeline = /*#__PURE__*/function () {
285
247
  }, {});
286
248
  };
287
249
  }
288
-
289
250
  result.getTableProps = function () {
290
251
  return _this2._tableProps;
291
252
  };
292
-
293
253
  result.setTableWidth = function (tableWidth) {
294
254
  var preTableWidth = _this2.getStateAtKey(_autoFill.tableWidthKey);
295
-
296
255
  if (preTableWidth !== tableWidth) {
297
256
  tableWidth && _this2.setStateAtKey(_autoFill.tableWidthKey, tableWidth);
298
257
  }
299
258
  };
300
-
301
259
  result.setTableDomHelper = function (domHelper) {
302
260
  _this2.ref.current.domHelper = domHelper;
303
261
  };
304
-
305
262
  result.setRowHeightManager = function (rowHeightManager) {
306
263
  _this2.ref.current.rowHeightManager = rowHeightManager;
307
264
  };
308
-
309
265
  return result;
310
266
  }
267
+ }, {
268
+ key: "getFeatureApi",
269
+ value: function getFeatureApi(featureName) {
270
+ var _a;
271
+ return (_a = this.ref.current.featureApi) === null || _a === void 0 ? void 0 : _a[featureName];
272
+ }
273
+ }, {
274
+ key: "addFeatureApi",
275
+ value: function addFeatureApi(featureName) {
276
+ if (!this.getFeatureApi(featureName)) {
277
+ this.ref.current.featureApi[featureName] = (0, _utils2.createFeatureApi)(featureName, this);
278
+ }
279
+ return this.ref.current.featureApi[featureName];
280
+ }
281
+ }, {
282
+ key: "getLastPipeline",
283
+ value: function getLastPipeline() {
284
+ return this.ref.current.lastPipeline;
285
+ }
311
286
  }]);
312
- return TablePipeline;
313
287
  }();
314
-
315
- exports.TablePipeline = TablePipeline;
316
288
  TablePipeline.defaultIndents = {
317
289
  iconIndent: -8,
318
290
  iconWidth: 16,
319
291
  iconGap: 0,
320
292
  indentSize: 16
321
293
  };
322
-
323
294
  function useTablePipeline(ctx) {
324
295
  var _useState = (0, _react.useState)({}),
325
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
326
- state = _useState2[0],
327
- setState = _useState2[1];
328
-
296
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
297
+ state = _useState2[0],
298
+ setState = _useState2[1];
329
299
  var ref = (0, _react.useRef)({
330
- featureOptions: {}
300
+ featureOptions: {},
301
+ featureApi: {}
331
302
  });
332
303
  return new TablePipeline({
333
304
  state: state,
@@ -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';