@kdcloudjs/table 1.0.0

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 (572) hide show
  1. package/LICENSE +568 -0
  2. package/README.md +111 -0
  3. package/dist/@kdcloudjs/table.css +422 -0
  4. package/dist/@kdcloudjs/table.css.map +1 -0
  5. package/dist/@kdcloudjs/table.js +38578 -0
  6. package/dist/@kdcloudjs/table.js.map +1 -0
  7. package/dist/@kdcloudjs/table.min.css +9 -0
  8. package/dist/@kdcloudjs/table.min.js +208 -0
  9. package/dist/@kdcloudjs/table.min.js.map +1 -0
  10. package/dist/default-theme.js +344 -0
  11. package/dist/kd-table.css +422 -0
  12. package/dist/kd-table.css.map +1 -0
  13. package/dist/kd-table.js +38578 -0
  14. package/dist/kd-table.js.map +1 -0
  15. package/dist/kd-table.min.css +9 -0
  16. package/dist/kd-table.min.js +208 -0
  17. package/dist/kd-table.min.js.map +1 -0
  18. package/dist/kd-ui-complete.less +779 -0
  19. package/dist/kd-ui.less +2 -0
  20. package/dist/theme.js +13 -0
  21. package/es/_utils/arrayUtil.d.ts +5 -0
  22. package/es/_utils/arrayUtil.js +17 -0
  23. package/es/_utils/devwarning.d.ts +1 -0
  24. package/es/_utils/devwarning.js +10 -0
  25. package/es/_utils/formatUtil.d.ts +46 -0
  26. package/es/_utils/formatUtil.js +346 -0
  27. package/es/_utils/hooks.d.ts +51 -0
  28. package/es/_utils/hooks.js +165 -0
  29. package/es/_utils/index.d.ts +8 -0
  30. package/es/_utils/index.js +15 -0
  31. package/es/_utils/numberUtil.d.ts +34 -0
  32. package/es/_utils/numberUtil.js +181 -0
  33. package/es/_utils/omit.d.ts +1 -0
  34. package/es/_utils/omit.js +11 -0
  35. package/es/_utils/react-children.d.ts +2 -0
  36. package/es/_utils/react-children.js +8 -0
  37. package/es/_utils/type.d.ts +12 -0
  38. package/es/_utils/type.js +15 -0
  39. package/es/_utils/usePopper.d.ts +29 -0
  40. package/es/_utils/usePopper.js +546 -0
  41. package/es/config-provider/ConfigContext.d.ts +22 -0
  42. package/es/config-provider/ConfigContext.js +7 -0
  43. package/es/config-provider/compDefaultProps.d.ts +8 -0
  44. package/es/config-provider/compDefaultProps.js +10 -0
  45. package/es/config-provider/configProvider.d.ts +11 -0
  46. package/es/config-provider/configProvider.js +40 -0
  47. package/es/config-provider/defaultConfig.d.ts +10 -0
  48. package/es/config-provider/defaultConfig.js +18 -0
  49. package/es/config-provider/index.d.ts +6 -0
  50. package/es/config-provider/index.js +6 -0
  51. package/es/index.d.ts +2 -0
  52. package/es/index.js +4 -0
  53. package/es/locale/index.d.ts +3 -0
  54. package/es/locale/index.js +3 -0
  55. package/es/locale/locale.d.ts +50 -0
  56. package/es/locale/locale.js +251 -0
  57. package/es/locale/zh-CN.d.ts +8 -0
  58. package/es/locale/zh-CN.js +8 -0
  59. package/es/style/color/colors.less +2 -0
  60. package/es/style/core/index.less +2 -0
  61. package/es/style/core/motion/other.less +28 -0
  62. package/es/style/core/motion/slide.less +53 -0
  63. package/es/style/core/motion.less +2 -0
  64. package/es/style/core/reset.less +186 -0
  65. package/es/style/css.js +1 -0
  66. package/es/style/index.css +410 -0
  67. package/es/style/index.d.ts +1 -0
  68. package/es/style/index.js +1 -0
  69. package/es/style/index.less +2 -0
  70. package/es/style/mixins/index.less +19 -0
  71. package/es/style/mixins/overlay.less +22 -0
  72. package/es/style/mixins/reset.less +13 -0
  73. package/es/style/themes/default.less +445 -0
  74. package/es/style/themes/index.less +1 -0
  75. package/es/table/base/calculations.d.ts +5 -0
  76. package/es/table/base/calculations.js +364 -0
  77. package/es/table/base/colgroup.d.ts +5 -0
  78. package/es/table/base/colgroup.js +22 -0
  79. package/es/table/base/empty.d.ts +9 -0
  80. package/es/table/base/empty.js +38 -0
  81. package/es/table/base/header.d.ts +5 -0
  82. package/es/table/base/header.js +324 -0
  83. package/es/table/base/helpers/SpanManager.d.ts +9 -0
  84. package/es/table/base/helpers/SpanManager.js +50 -0
  85. package/es/table/base/helpers/TableDOMUtils.d.ts +18 -0
  86. package/es/table/base/helpers/TableDOMUtils.js +104 -0
  87. package/es/table/base/helpers/__test__/SpanManager.test.d.ts +1 -0
  88. package/es/table/base/helpers/__test__/SpanManager.test.js +18 -0
  89. package/es/table/base/helpers/__test__/TableDOMUtils.test.d.ts +1 -0
  90. package/es/table/base/helpers/__test__/TableDOMUtils.test.js +34 -0
  91. package/es/table/base/helpers/__test__/rowHeightManager.test.d.ts +1 -0
  92. package/es/table/base/helpers/__test__/rowHeightManager.test.js +30 -0
  93. package/es/table/base/helpers/__test__/visible-part.test.d.ts +1 -0
  94. package/es/table/base/helpers/__test__/visible-part.test.js +28 -0
  95. package/es/table/base/helpers/rowHeightManager.d.ts +7 -0
  96. package/es/table/base/helpers/rowHeightManager.js +157 -0
  97. package/es/table/base/helpers/visible-part.d.ts +23 -0
  98. package/es/table/base/helpers/visible-part.js +58 -0
  99. package/es/table/base/html-table.d.ts +15 -0
  100. package/es/table/base/html-table.js +132 -0
  101. package/es/table/base/index.d.ts +3 -0
  102. package/es/table/base/index.js +2 -0
  103. package/es/table/base/interfaces.d.ts +54 -0
  104. package/es/table/base/interfaces.js +0 -0
  105. package/es/table/base/loading.d.ts +13 -0
  106. package/es/table/base/loading.js +60 -0
  107. package/es/table/base/styles.d.ts +132 -0
  108. package/es/table/base/styles.js +112 -0
  109. package/es/table/base/table.d.ts +150 -0
  110. package/es/table/base/table.js +733 -0
  111. package/es/table/base/utils.d.ts +36 -0
  112. package/es/table/base/utils.js +193 -0
  113. package/es/table/common-views.d.ts +24 -0
  114. package/es/table/common-views.js +70 -0
  115. package/es/table/index.d.ts +6 -0
  116. package/es/table/index.js +6 -0
  117. package/es/table/interfaces.d.ts +98 -0
  118. package/es/table/interfaces.js +0 -0
  119. package/es/table/internals.d.ts +14 -0
  120. package/es/table/internals.js +56 -0
  121. package/es/table/pipeline/features/__test__/multiSelect.test.d.ts +1 -0
  122. package/es/table/pipeline/features/__test__/multiSelect.test.js +152 -0
  123. package/es/table/pipeline/features/__test__/rowDetail.test.d.ts +1 -0
  124. package/es/table/pipeline/features/__test__/rowDetail.test.js +223 -0
  125. package/es/table/pipeline/features/__test__/rowGrouping.test.d.ts +1 -0
  126. package/es/table/pipeline/features/__test__/rowGrouping.test.js +120 -0
  127. package/es/table/pipeline/features/__test__/singleSelect.test.d.ts +1 -0
  128. package/es/table/pipeline/features/__test__/singleSelect.test.js +191 -0
  129. package/es/table/pipeline/features/__test__/sort.test.d.ts +1 -0
  130. package/es/table/pipeline/features/__test__/sort.test.js +213 -0
  131. package/es/table/pipeline/features/__test__/tips.test.d.ts +1 -0
  132. package/es/table/pipeline/features/__test__/tips.test.js +123 -0
  133. package/es/table/pipeline/features/__test__/treeMode.test.d.ts +1 -0
  134. package/es/table/pipeline/features/__test__/treeMode.test.js +202 -0
  135. package/es/table/pipeline/features/autoFill.d.ts +4 -0
  136. package/es/table/pipeline/features/autoFill.js +63 -0
  137. package/es/table/pipeline/features/autoRowSpan.d.ts +2 -0
  138. package/es/table/pipeline/features/autoRowSpan.js +72 -0
  139. package/es/table/pipeline/features/buildTree.d.ts +2 -0
  140. package/es/table/pipeline/features/buildTree.js +8 -0
  141. package/es/table/pipeline/features/columnDrag.d.ts +6 -0
  142. package/es/table/pipeline/features/columnDrag.js +265 -0
  143. package/es/table/pipeline/features/columnFilter.d.ts +20 -0
  144. package/es/table/pipeline/features/columnFilter.js +173 -0
  145. package/es/table/pipeline/features/columnHover.d.ts +12 -0
  146. package/es/table/pipeline/features/columnHover.js +51 -0
  147. package/es/table/pipeline/features/columnRangeHover.d.ts +15 -0
  148. package/es/table/pipeline/features/columnRangeHover.js +83 -0
  149. package/es/table/pipeline/features/columnResizeWidth.d.ts +21 -0
  150. package/es/table/pipeline/features/columnResizeWidth.js +173 -0
  151. package/es/table/pipeline/features/contextMenu.d.ts +14 -0
  152. package/es/table/pipeline/features/contextMenu.js +370 -0
  153. package/es/table/pipeline/features/filter/DefaultFilterContent.d.ts +4 -0
  154. package/es/table/pipeline/features/filter/DefaultFilterContent.js +91 -0
  155. package/es/table/pipeline/features/filter/Filter.d.ts +17 -0
  156. package/es/table/pipeline/features/filter/Filter.js +111 -0
  157. package/es/table/pipeline/features/filter/FilterPanel.d.ts +20 -0
  158. package/es/table/pipeline/features/filter/FilterPanel.js +81 -0
  159. package/es/table/pipeline/features/filter/__test__/Filter.test.d.ts +1 -0
  160. package/es/table/pipeline/features/filter/__test__/Filter.test.js +29 -0
  161. package/es/table/pipeline/features/filter/index.d.ts +4 -0
  162. package/es/table/pipeline/features/filter/index.js +4 -0
  163. package/es/table/pipeline/features/filter/util.d.ts +10 -0
  164. package/es/table/pipeline/features/filter/util.js +67 -0
  165. package/es/table/pipeline/features/index.d.ts +16 -0
  166. package/es/table/pipeline/features/index.js +16 -0
  167. package/es/table/pipeline/features/multiSelect.d.ts +27 -0
  168. package/es/table/pipeline/features/multiSelect.js +208 -0
  169. package/es/table/pipeline/features/rowDetail.d.ts +35 -0
  170. package/es/table/pipeline/features/rowDetail.js +254 -0
  171. package/es/table/pipeline/features/rowGrouping.d.ts +14 -0
  172. package/es/table/pipeline/features/rowGrouping.js +200 -0
  173. package/es/table/pipeline/features/singleSelect.d.ts +23 -0
  174. package/es/table/pipeline/features/singleSelect.js +122 -0
  175. package/es/table/pipeline/features/sort.d.ts +40 -0
  176. package/es/table/pipeline/features/sort.js +332 -0
  177. package/es/table/pipeline/features/tips.d.ts +2 -0
  178. package/es/table/pipeline/features/tips.js +57 -0
  179. package/es/table/pipeline/features/treeMode.d.ts +37 -0
  180. package/es/table/pipeline/features/treeMode.js +234 -0
  181. package/es/table/pipeline/features/treeSelect.d.ts +38 -0
  182. package/es/table/pipeline/features/treeSelect.js +154 -0
  183. package/es/table/pipeline/index.d.ts +3 -0
  184. package/es/table/pipeline/index.js +3 -0
  185. package/es/table/pipeline/pipeline.d.ts +85 -0
  186. package/es/table/pipeline/pipeline.js +272 -0
  187. package/es/table/pivot/cross-table/buildCrossTable.d.ts +14 -0
  188. package/es/table/pivot/cross-table/buildCrossTable.js +294 -0
  189. package/es/table/pivot/cross-table/constants.d.ts +1 -0
  190. package/es/table/pivot/cross-table/constants.js +1 -0
  191. package/es/table/pivot/cross-table/cross-table.d.ts +18 -0
  192. package/es/table/pivot/cross-table/cross-table.js +55 -0
  193. package/es/table/pivot/cross-table/index.d.ts +4 -0
  194. package/es/table/pivot/cross-table/index.js +3 -0
  195. package/es/table/pivot/cross-table/interfaces.d.ts +29 -0
  196. package/es/table/pivot/cross-table/interfaces.js +0 -0
  197. package/es/table/pivot/cross-table/internals.d.ts +13 -0
  198. package/es/table/pivot/cross-table/internals.js +0 -0
  199. package/es/table/pivot/cross-tree-table/buildCrossTreeTable.d.ts +14 -0
  200. package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +219 -0
  201. package/es/table/pivot/cross-tree-table/cross-tree-table.d.ts +38 -0
  202. package/es/table/pivot/cross-tree-table/cross-tree-table.js +127 -0
  203. package/es/table/pivot/cross-tree-table/index.d.ts +2 -0
  204. package/es/table/pivot/cross-tree-table/index.js +2 -0
  205. package/es/table/pivot/pivot-utils/buildDrillTree.d.ts +16 -0
  206. package/es/table/pivot/pivot-utils/buildDrillTree.js +93 -0
  207. package/es/table/pivot/pivot-utils/builders.d.ts +26 -0
  208. package/es/table/pivot/pivot-utils/builders.js +252 -0
  209. package/es/table/pivot/pivot-utils/convert-utils.d.ts +31 -0
  210. package/es/table/pivot/pivot-utils/convert-utils.js +180 -0
  211. package/es/table/pivot/pivot-utils/index.d.ts +5 -0
  212. package/es/table/pivot/pivot-utils/index.js +4 -0
  213. package/es/table/pivot/pivot-utils/interfaces.d.ts +12 -0
  214. package/es/table/pivot/pivot-utils/interfaces.js +0 -0
  215. package/es/table/pivot/pivot-utils/simpleEncode.d.ts +1 -0
  216. package/es/table/pivot/pivot-utils/simpleEncode.js +7 -0
  217. package/es/table/style/css.js +2 -0
  218. package/es/table/style/index.css +0 -0
  219. package/es/table/style/index.d.ts +2 -0
  220. package/es/table/style/index.js +2 -0
  221. package/es/table/style/index.less +1 -0
  222. package/es/table/transforms/autoRowSpan.d.ts +3 -0
  223. package/es/table/transforms/autoRowSpan.js +73 -0
  224. package/es/table/transforms/autoWidth.d.ts +25 -0
  225. package/es/table/transforms/autoWidth.js +160 -0
  226. package/es/table/transforms/buildTree.d.ts +3 -0
  227. package/es/table/transforms/buildTree.js +15 -0
  228. package/es/table/transforms/columnHover.d.ts +17 -0
  229. package/es/table/transforms/columnHover.js +59 -0
  230. package/es/table/transforms/columnRangeHover.d.ts +17 -0
  231. package/es/table/transforms/columnRangeHover.js +94 -0
  232. package/es/table/transforms/columnResize.d.ts +27 -0
  233. package/es/table/transforms/columnResize.js +152 -0
  234. package/es/table/transforms/flatten.d.ts +3 -0
  235. package/es/table/transforms/flatten.js +16 -0
  236. package/es/table/transforms/index.d.ts +12 -0
  237. package/es/table/transforms/index.js +12 -0
  238. package/es/table/transforms/orderField.d.ts +3 -0
  239. package/es/table/transforms/orderField.js +22 -0
  240. package/es/table/transforms/sort.d.ts +43 -0
  241. package/es/table/transforms/sort.js +338 -0
  242. package/es/table/transforms/tips.d.ts +8 -0
  243. package/es/table/transforms/tips.js +54 -0
  244. package/es/table/transforms/treeMode.d.ts +30 -0
  245. package/es/table/transforms/treeMode.js +252 -0
  246. package/es/table/transforms/visible.d.ts +5 -0
  247. package/es/table/transforms/visible.js +19 -0
  248. package/es/table/transforms/warnTransformsDeprecated.d.ts +1 -0
  249. package/es/table/transforms/warnTransformsDeprecated.js +8 -0
  250. package/es/table/use/useResizeObserver.d.ts +2 -0
  251. package/es/table/use/useResizeObserver.js +20 -0
  252. package/es/table/utils/applyTransforms.d.ts +6 -0
  253. package/es/table/utils/applyTransforms.js +15 -0
  254. package/es/table/utils/buildTree.d.ts +36 -0
  255. package/es/table/utils/buildTree.js +119 -0
  256. package/es/table/utils/collectNodes.d.ts +8 -0
  257. package/es/table/utils/collectNodes.js +59 -0
  258. package/es/table/utils/console.d.ts +11 -0
  259. package/es/table/utils/console.js +58 -0
  260. package/es/table/utils/copyToClipboard.d.ts +3 -0
  261. package/es/table/utils/copyToClipboard.js +30 -0
  262. package/es/table/utils/element.d.ts +42 -0
  263. package/es/table/utils/element.js +228 -0
  264. package/es/table/utils/exportTableAsExcel.d.ts +4 -0
  265. package/es/table/utils/exportTableAsExcel.js +188 -0
  266. package/es/table/utils/getTreeDepth.d.ts +3 -0
  267. package/es/table/utils/getTreeDepth.js +41 -0
  268. package/es/table/utils/groupBy.d.ts +1 -0
  269. package/es/table/utils/groupBy.js +37 -0
  270. package/es/table/utils/index.d.ts +18 -0
  271. package/es/table/utils/index.js +18 -0
  272. package/es/table/utils/isGroupColumn.d.ts +2 -0
  273. package/es/table/utils/isGroupColumn.js +7 -0
  274. package/es/table/utils/isLeafNode.d.ts +2 -0
  275. package/es/table/utils/isLeafNode.js +4 -0
  276. package/es/table/utils/layeredFilter.d.ts +2 -0
  277. package/es/table/utils/layeredFilter.js +25 -0
  278. package/es/table/utils/layeredSort.d.ts +5 -0
  279. package/es/table/utils/layeredSort.js +26 -0
  280. package/es/table/utils/makeRecursiveMapper.d.ts +9 -0
  281. package/es/table/utils/makeRecursiveMapper.js +76 -0
  282. package/es/table/utils/mergeCellProps.d.ts +8 -0
  283. package/es/table/utils/mergeCellProps.js +67 -0
  284. package/es/table/utils/others.d.ts +16 -0
  285. package/es/table/utils/others.js +80 -0
  286. package/es/table/utils/proto.d.ts +21 -0
  287. package/es/table/utils/proto.js +106 -0
  288. package/es/table/utils/smartCompare.d.ts +9 -0
  289. package/es/table/utils/smartCompare.js +51 -0
  290. package/es/table/utils/traverseColumn.d.ts +11 -0
  291. package/es/table/utils/traverseColumn.js +88 -0
  292. package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.d.ts +22 -0
  293. package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +138 -0
  294. package/es/table/utils/tree-data-helpers/TreeDataHelper.d.ts +26 -0
  295. package/es/table/utils/tree-data-helpers/TreeDataHelper.js +337 -0
  296. package/lib/_utils/arrayUtil.d.ts +5 -0
  297. package/lib/_utils/arrayUtil.js +26 -0
  298. package/lib/_utils/devwarning.d.ts +1 -0
  299. package/lib/_utils/devwarning.js +21 -0
  300. package/lib/_utils/formatUtil.d.ts +46 -0
  301. package/lib/_utils/formatUtil.js +358 -0
  302. package/lib/_utils/hooks.d.ts +51 -0
  303. package/lib/_utils/hooks.js +187 -0
  304. package/lib/_utils/index.d.ts +8 -0
  305. package/lib/_utils/index.js +28 -0
  306. package/lib/_utils/numberUtil.d.ts +34 -0
  307. package/lib/_utils/numberUtil.js +202 -0
  308. package/lib/_utils/omit.d.ts +1 -0
  309. package/lib/_utils/omit.js +21 -0
  310. package/lib/_utils/react-children.d.ts +2 -0
  311. package/lib/_utils/react-children.js +20 -0
  312. package/lib/_utils/type.d.ts +12 -0
  313. package/lib/_utils/type.js +27 -0
  314. package/lib/_utils/usePopper.d.ts +29 -0
  315. package/lib/_utils/usePopper.js +574 -0
  316. package/lib/config-provider/ConfigContext.d.ts +22 -0
  317. package/lib/config-provider/ConfigContext.js +19 -0
  318. package/lib/config-provider/compDefaultProps.d.ts +8 -0
  319. package/lib/config-provider/compDefaultProps.js +17 -0
  320. package/lib/config-provider/configProvider.d.ts +11 -0
  321. package/lib/config-provider/configProvider.js +56 -0
  322. package/lib/config-provider/defaultConfig.d.ts +10 -0
  323. package/lib/config-provider/defaultConfig.js +30 -0
  324. package/lib/config-provider/index.d.ts +6 -0
  325. package/lib/config-provider/index.js +37 -0
  326. package/lib/index.d.ts +2 -0
  327. package/lib/index.js +45 -0
  328. package/lib/locale/index.d.ts +3 -0
  329. package/lib/locale/index.js +25 -0
  330. package/lib/locale/locale.d.ts +50 -0
  331. package/lib/locale/locale.js +277 -0
  332. package/lib/locale/zh-CN.d.ts +8 -0
  333. package/lib/locale/zh-CN.js +15 -0
  334. package/lib/style/color/colors.less +2 -0
  335. package/lib/style/components.less +1 -0
  336. package/lib/style/core/index.less +2 -0
  337. package/lib/style/core/motion/other.less +28 -0
  338. package/lib/style/core/motion/slide.less +53 -0
  339. package/lib/style/core/motion.less +2 -0
  340. package/lib/style/core/reset.less +186 -0
  341. package/lib/style/css.js +3 -0
  342. package/lib/style/index.css +410 -0
  343. package/lib/style/index.d.ts +1 -0
  344. package/lib/style/index.js +3 -0
  345. package/lib/style/index.less +2 -0
  346. package/lib/style/mixins/index.less +19 -0
  347. package/lib/style/mixins/overlay.less +22 -0
  348. package/lib/style/mixins/reset.less +13 -0
  349. package/lib/style/themes/default.less +445 -0
  350. package/lib/style/themes/index.less +1 -0
  351. package/lib/table/base/calculations.d.ts +5 -0
  352. package/lib/table/base/calculations.js +385 -0
  353. package/lib/table/base/colgroup.d.ts +5 -0
  354. package/lib/table/base/colgroup.js +33 -0
  355. package/lib/table/base/empty.d.ts +9 -0
  356. package/lib/table/base/empty.js +54 -0
  357. package/lib/table/base/header.d.ts +5 -0
  358. package/lib/table/base/header.js +340 -0
  359. package/lib/table/base/helpers/SpanManager.d.ts +9 -0
  360. package/lib/table/base/helpers/SpanManager.js +59 -0
  361. package/lib/table/base/helpers/TableDOMUtils.d.ts +18 -0
  362. package/lib/table/base/helpers/TableDOMUtils.js +113 -0
  363. package/lib/table/base/helpers/__test__/SpanManager.test.d.ts +1 -0
  364. package/lib/table/base/helpers/__test__/SpanManager.test.js +23 -0
  365. package/lib/table/base/helpers/__test__/TableDOMUtils.test.d.ts +1 -0
  366. package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +41 -0
  367. package/lib/table/base/helpers/__test__/rowHeightManager.test.d.ts +1 -0
  368. package/lib/table/base/helpers/__test__/rowHeightManager.test.js +33 -0
  369. package/lib/table/base/helpers/__test__/visible-part.test.d.ts +1 -0
  370. package/lib/table/base/helpers/__test__/visible-part.test.js +31 -0
  371. package/lib/table/base/helpers/rowHeightManager.d.ts +7 -0
  372. package/lib/table/base/helpers/rowHeightManager.js +170 -0
  373. package/lib/table/base/helpers/visible-part.d.ts +23 -0
  374. package/lib/table/base/helpers/visible-part.js +72 -0
  375. package/lib/table/base/html-table.d.ts +15 -0
  376. package/lib/table/base/html-table.js +149 -0
  377. package/lib/table/base/index.d.ts +3 -0
  378. package/lib/table/base/index.js +21 -0
  379. package/lib/table/base/interfaces.d.ts +54 -0
  380. package/lib/table/base/interfaces.js +0 -0
  381. package/lib/table/base/loading.d.ts +13 -0
  382. package/lib/table/base/loading.js +71 -0
  383. package/lib/table/base/styles.d.ts +132 -0
  384. package/lib/table/base/styles.js +136 -0
  385. package/lib/table/base/table.d.ts +150 -0
  386. package/lib/table/base/table.js +773 -0
  387. package/lib/table/base/utils.d.ts +36 -0
  388. package/lib/table/base/utils.js +234 -0
  389. package/lib/table/common-views.d.ts +24 -0
  390. package/lib/table/common-views.js +90 -0
  391. package/lib/table/index.d.ts +6 -0
  392. package/lib/table/index.js +85 -0
  393. package/lib/table/interfaces.d.ts +98 -0
  394. package/lib/table/interfaces.js +0 -0
  395. package/lib/table/internals.d.ts +14 -0
  396. package/lib/table/internals.js +64 -0
  397. package/lib/table/pipeline/features/__test__/multiSelect.test.d.ts +1 -0
  398. package/lib/table/pipeline/features/__test__/multiSelect.test.js +163 -0
  399. package/lib/table/pipeline/features/__test__/rowDetail.test.d.ts +1 -0
  400. package/lib/table/pipeline/features/__test__/rowDetail.test.js +230 -0
  401. package/lib/table/pipeline/features/__test__/rowGrouping.test.d.ts +1 -0
  402. package/lib/table/pipeline/features/__test__/rowGrouping.test.js +129 -0
  403. package/lib/table/pipeline/features/__test__/singleSelect.test.d.ts +1 -0
  404. package/lib/table/pipeline/features/__test__/singleSelect.test.js +201 -0
  405. package/lib/table/pipeline/features/__test__/sort.test.d.ts +1 -0
  406. package/lib/table/pipeline/features/__test__/sort.test.js +218 -0
  407. package/lib/table/pipeline/features/__test__/tips.test.d.ts +1 -0
  408. package/lib/table/pipeline/features/__test__/tips.test.js +133 -0
  409. package/lib/table/pipeline/features/__test__/treeMode.test.d.ts +1 -0
  410. package/lib/table/pipeline/features/__test__/treeMode.test.js +206 -0
  411. package/lib/table/pipeline/features/autoFill.d.ts +4 -0
  412. package/lib/table/pipeline/features/autoFill.js +80 -0
  413. package/lib/table/pipeline/features/autoRowSpan.d.ts +2 -0
  414. package/lib/table/pipeline/features/autoRowSpan.js +84 -0
  415. package/lib/table/pipeline/features/buildTree.d.ts +2 -0
  416. package/lib/table/pipeline/features/buildTree.js +16 -0
  417. package/lib/table/pipeline/features/columnDrag.d.ts +6 -0
  418. package/lib/table/pipeline/features/columnDrag.js +278 -0
  419. package/lib/table/pipeline/features/columnFilter.d.ts +20 -0
  420. package/lib/table/pipeline/features/columnFilter.js +197 -0
  421. package/lib/table/pipeline/features/columnHover.d.ts +12 -0
  422. package/lib/table/pipeline/features/columnHover.js +62 -0
  423. package/lib/table/pipeline/features/columnRangeHover.d.ts +15 -0
  424. package/lib/table/pipeline/features/columnRangeHover.js +95 -0
  425. package/lib/table/pipeline/features/columnResizeWidth.d.ts +21 -0
  426. package/lib/table/pipeline/features/columnResizeWidth.js +192 -0
  427. package/lib/table/pipeline/features/contextMenu.d.ts +14 -0
  428. package/lib/table/pipeline/features/contextMenu.js +397 -0
  429. package/lib/table/pipeline/features/filter/DefaultFilterContent.d.ts +4 -0
  430. package/lib/table/pipeline/features/filter/DefaultFilterContent.js +112 -0
  431. package/lib/table/pipeline/features/filter/Filter.d.ts +17 -0
  432. package/lib/table/pipeline/features/filter/Filter.js +129 -0
  433. package/lib/table/pipeline/features/filter/FilterPanel.d.ts +20 -0
  434. package/lib/table/pipeline/features/filter/FilterPanel.js +98 -0
  435. package/lib/table/pipeline/features/filter/__test__/Filter.test.d.ts +1 -0
  436. package/lib/table/pipeline/features/filter/__test__/Filter.test.js +36 -0
  437. package/lib/table/pipeline/features/filter/index.d.ts +4 -0
  438. package/lib/table/pipeline/features/filter/index.js +39 -0
  439. package/lib/table/pipeline/features/filter/util.d.ts +10 -0
  440. package/lib/table/pipeline/features/filter/util.js +77 -0
  441. package/lib/table/pipeline/features/index.d.ts +16 -0
  442. package/lib/table/pipeline/features/index.js +141 -0
  443. package/lib/table/pipeline/features/multiSelect.d.ts +27 -0
  444. package/lib/table/pipeline/features/multiSelect.js +227 -0
  445. package/lib/table/pipeline/features/rowDetail.d.ts +35 -0
  446. package/lib/table/pipeline/features/rowDetail.js +283 -0
  447. package/lib/table/pipeline/features/rowGrouping.d.ts +14 -0
  448. package/lib/table/pipeline/features/rowGrouping.js +227 -0
  449. package/lib/table/pipeline/features/singleSelect.d.ts +23 -0
  450. package/lib/table/pipeline/features/singleSelect.js +138 -0
  451. package/lib/table/pipeline/features/sort.d.ts +40 -0
  452. package/lib/table/pipeline/features/sort.js +361 -0
  453. package/lib/table/pipeline/features/tips.d.ts +2 -0
  454. package/lib/table/pipeline/features/tips.js +73 -0
  455. package/lib/table/pipeline/features/treeMode.d.ts +37 -0
  456. package/lib/table/pipeline/features/treeMode.js +266 -0
  457. package/lib/table/pipeline/features/treeSelect.d.ts +38 -0
  458. package/lib/table/pipeline/features/treeSelect.js +169 -0
  459. package/lib/table/pipeline/index.d.ts +3 -0
  460. package/lib/table/pipeline/index.js +26 -0
  461. package/lib/table/pipeline/pipeline.d.ts +85 -0
  462. package/lib/table/pipeline/pipeline.js +291 -0
  463. package/lib/table/pivot/cross-table/buildCrossTable.d.ts +14 -0
  464. package/lib/table/pivot/cross-table/buildCrossTable.js +313 -0
  465. package/lib/table/pivot/cross-table/constants.d.ts +1 -0
  466. package/lib/table/pivot/cross-table/constants.js +8 -0
  467. package/lib/table/pivot/cross-table/cross-table.d.ts +18 -0
  468. package/lib/table/pivot/cross-table/cross-table.js +71 -0
  469. package/lib/table/pivot/cross-table/index.d.ts +4 -0
  470. package/lib/table/pivot/cross-table/index.js +31 -0
  471. package/lib/table/pivot/cross-table/interfaces.d.ts +29 -0
  472. package/lib/table/pivot/cross-table/interfaces.js +0 -0
  473. package/lib/table/pivot/cross-table/internals.d.ts +13 -0
  474. package/lib/table/pivot/cross-table/internals.js +0 -0
  475. package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.d.ts +14 -0
  476. package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +240 -0
  477. package/lib/table/pivot/cross-tree-table/cross-tree-table.d.ts +38 -0
  478. package/lib/table/pivot/cross-tree-table/cross-tree-table.js +144 -0
  479. package/lib/table/pivot/cross-tree-table/index.d.ts +2 -0
  480. package/lib/table/pivot/cross-tree-table/index.js +23 -0
  481. package/lib/table/pivot/pivot-utils/buildDrillTree.d.ts +16 -0
  482. package/lib/table/pivot/pivot-utils/buildDrillTree.js +106 -0
  483. package/lib/table/pivot/pivot-utils/builders.d.ts +26 -0
  484. package/lib/table/pivot/pivot-utils/builders.js +272 -0
  485. package/lib/table/pivot/pivot-utils/convert-utils.d.ts +31 -0
  486. package/lib/table/pivot/pivot-utils/convert-utils.js +204 -0
  487. package/lib/table/pivot/pivot-utils/index.d.ts +5 -0
  488. package/lib/table/pivot/pivot-utils/index.js +59 -0
  489. package/lib/table/pivot/pivot-utils/interfaces.d.ts +12 -0
  490. package/lib/table/pivot/pivot-utils/interfaces.js +0 -0
  491. package/lib/table/pivot/pivot-utils/simpleEncode.d.ts +1 -0
  492. package/lib/table/pivot/pivot-utils/simpleEncode.js +14 -0
  493. package/lib/table/style/css.js +5 -0
  494. package/lib/table/style/index.css +0 -0
  495. package/lib/table/style/index.d.ts +2 -0
  496. package/lib/table/style/index.js +5 -0
  497. package/lib/table/style/index.less +1 -0
  498. package/lib/table/transforms/autoRowSpan.d.ts +3 -0
  499. package/lib/table/transforms/autoRowSpan.js +86 -0
  500. package/lib/table/transforms/autoWidth.d.ts +25 -0
  501. package/lib/table/transforms/autoWidth.js +187 -0
  502. package/lib/table/transforms/buildTree.d.ts +3 -0
  503. package/lib/table/transforms/buildTree.js +23 -0
  504. package/lib/table/transforms/columnHover.d.ts +17 -0
  505. package/lib/table/transforms/columnHover.js +74 -0
  506. package/lib/table/transforms/columnRangeHover.d.ts +17 -0
  507. package/lib/table/transforms/columnRangeHover.js +110 -0
  508. package/lib/table/transforms/columnResize.d.ts +27 -0
  509. package/lib/table/transforms/columnResize.js +176 -0
  510. package/lib/table/transforms/flatten.d.ts +3 -0
  511. package/lib/table/transforms/flatten.js +24 -0
  512. package/lib/table/transforms/index.d.ts +12 -0
  513. package/lib/table/transforms/index.js +131 -0
  514. package/lib/table/transforms/orderField.d.ts +3 -0
  515. package/lib/table/transforms/orderField.js +33 -0
  516. package/lib/table/transforms/sort.d.ts +43 -0
  517. package/lib/table/transforms/sort.js +369 -0
  518. package/lib/table/transforms/tips.d.ts +8 -0
  519. package/lib/table/transforms/tips.js +71 -0
  520. package/lib/table/transforms/treeMode.d.ts +30 -0
  521. package/lib/table/transforms/treeMode.js +286 -0
  522. package/lib/table/transforms/visible.d.ts +5 -0
  523. package/lib/table/transforms/visible.js +31 -0
  524. package/lib/table/transforms/warnTransformsDeprecated.d.ts +1 -0
  525. package/lib/table/transforms/warnTransformsDeprecated.js +19 -0
  526. package/lib/table/use/useResizeObserver.d.ts +2 -0
  527. package/lib/table/use/useResizeObserver.js +32 -0
  528. package/lib/table/utils/applyTransforms.d.ts +6 -0
  529. package/lib/table/utils/applyTransforms.js +24 -0
  530. package/lib/table/utils/buildTree.d.ts +36 -0
  531. package/lib/table/utils/buildTree.js +140 -0
  532. package/lib/table/utils/collectNodes.d.ts +8 -0
  533. package/lib/table/utils/collectNodes.js +72 -0
  534. package/lib/table/utils/console.d.ts +11 -0
  535. package/lib/table/utils/console.js +68 -0
  536. package/lib/table/utils/copyToClipboard.d.ts +3 -0
  537. package/lib/table/utils/copyToClipboard.js +40 -0
  538. package/lib/table/utils/element.d.ts +42 -0
  539. package/lib/table/utils/element.js +243 -0
  540. package/lib/table/utils/exportTableAsExcel.d.ts +4 -0
  541. package/lib/table/utils/exportTableAsExcel.js +205 -0
  542. package/lib/table/utils/getTreeDepth.d.ts +3 -0
  543. package/lib/table/utils/getTreeDepth.js +54 -0
  544. package/lib/table/utils/groupBy.d.ts +1 -0
  545. package/lib/table/utils/groupBy.js +48 -0
  546. package/lib/table/utils/index.d.ts +18 -0
  547. package/lib/table/utils/index.js +187 -0
  548. package/lib/table/utils/isGroupColumn.d.ts +2 -0
  549. package/lib/table/utils/isGroupColumn.js +17 -0
  550. package/lib/table/utils/isLeafNode.d.ts +2 -0
  551. package/lib/table/utils/isLeafNode.js +11 -0
  552. package/lib/table/utils/layeredFilter.d.ts +2 -0
  553. package/lib/table/utils/layeredFilter.js +38 -0
  554. package/lib/table/utils/layeredSort.d.ts +5 -0
  555. package/lib/table/utils/layeredSort.js +37 -0
  556. package/lib/table/utils/makeRecursiveMapper.d.ts +9 -0
  557. package/lib/table/utils/makeRecursiveMapper.js +94 -0
  558. package/lib/table/utils/mergeCellProps.d.ts +8 -0
  559. package/lib/table/utils/mergeCellProps.js +78 -0
  560. package/lib/table/utils/others.d.ts +16 -0
  561. package/lib/table/utils/others.js +108 -0
  562. package/lib/table/utils/proto.d.ts +21 -0
  563. package/lib/table/utils/proto.js +117 -0
  564. package/lib/table/utils/smartCompare.d.ts +9 -0
  565. package/lib/table/utils/smartCompare.js +58 -0
  566. package/lib/table/utils/traverseColumn.d.ts +11 -0
  567. package/lib/table/utils/traverseColumn.js +103 -0
  568. package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.d.ts +22 -0
  569. package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +154 -0
  570. package/lib/table/utils/tree-data-helpers/TreeDataHelper.d.ts +26 -0
  571. package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +358 -0
  572. package/package.json +213 -0
@@ -0,0 +1,38 @@
1
+ import { ArtColumn } from '../../interfaces';
2
+ import { TablePipeline } from '../pipeline';
3
+ export interface TreeSelectFeatureOptions {
4
+ /** 完整的树 */
5
+ tree: any[];
6
+ /** 虚拟的根节点值;该参数非空时,treeSelect 将会在 tree 参数之上再添加一个父节点 */
7
+ rootKey?: string;
8
+ /** 父子节点选中状态是否不再关联。设置为 true 之后,父节点和子节点的 value 独立管理,不再联动 */
9
+ checkStrictly?: boolean;
10
+ /**
11
+ * 定义选中时回填的方式,可选值:
12
+ * - 'all'(返回所有选中的节点)
13
+ * - 'parent'(父子节点都选中时只返回父节点)
14
+ * - 'child'(父子节点都选中时只返回子节点)
15
+ */
16
+ checkedStrategy?: 'all' | 'parent' | 'child';
17
+ /** 复选框所在列的位置 */
18
+ checkboxPlacement?: 'start' | 'end';
19
+ /** 复选框所在列的 column 配置,可指定 width,lock, title, align, features 等属性 */
20
+ checkboxColumn?: Partial<ArtColumn>;
21
+ /** 受控用法:当前选中的值 */
22
+ value?: string[];
23
+ /** 非受控用法:默认选中的值 */
24
+ defaultValue?: string[];
25
+ /** 受控用法:状态改变回调 */
26
+ onChange?(nextValue: string[]): void;
27
+ /** 点击事件的响应区域 */
28
+ clickArea?: 'checkbox' | 'cell' | 'row';
29
+ /** 是否对触发 onChange 的 click 事件调用 event.stopPropagation() */
30
+ stopClickEventPropagation?: boolean;
31
+ /** 被选中时是否高亮整行 */
32
+ highlightRowWhenSelected?: boolean;
33
+ /** 是否禁用该节点的交互 */
34
+ isDisabled?(row: any): boolean;
35
+ /** 是否让该节点对应的子树 与其父节点脱离联动 */
36
+ idDetached?(row: any): boolean;
37
+ }
38
+ export declare function treeSelect(opts: TreeSelectFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
@@ -0,0 +1,154 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
3
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
4
+ import React from 'react';
5
+ import { always } from '../../utils/others';
6
+ import StrictTreeDataHelper from '../../utils/tree-data-helpers/StrictTreeDataHelper';
7
+ import TreeDataHelper from '../../utils/tree-data-helpers/TreeDataHelper';
8
+ var STATE_KEY = 'treeSelect';
9
+ export function treeSelect(opts) {
10
+ return function treeSelectStep(pipeline) {
11
+ var _ref, _context;
12
+
13
+ var _a, _b, _c, _d, _e, _f, _g, _h;
14
+
15
+ var Checkbox = pipeline.ctx.components.Checkbox;
16
+
17
+ if (Checkbox == null) {
18
+ throw new Error('使用 treeSelect 之前需要通过 pipeline context 设置 components.Checkbox');
19
+ }
20
+
21
+ var primaryKey = pipeline.ensurePrimaryKey('treeSelect');
22
+
23
+ if (typeof primaryKey !== 'string') {
24
+ throw new Error('treeSelect 仅支持字符串作为 primaryKey');
25
+ }
26
+
27
+ var clickArea = (_a = opts.clickArea) !== null && _a !== void 0 ? _a : 'checkbox';
28
+ var isDisabled = (_b = opts.isDisabled) !== null && _b !== void 0 ? _b : always(false);
29
+ var isDetached = (_c = opts.idDetached) !== null && _c !== void 0 ? _c : always(false);
30
+ var value = (_f = (_e = (_d = opts.value) !== null && _d !== void 0 ? _d : pipeline.getStateAtKey(STATE_KEY)) !== null && _e !== void 0 ? _e : opts.defaultValue) !== null && _f !== void 0 ? _f : [];
31
+ var tree = opts.rootKey != null ? [(_ref = {}, _defineProperty(_ref, primaryKey, opts.rootKey), _defineProperty(_ref, "children", opts.tree), _ref)] : opts.tree;
32
+
33
+ var getNodeValue = function getNodeValue(node) {
34
+ return node[primaryKey];
35
+ };
36
+
37
+ var treeDataHelper = opts.checkStrictly ? new StrictTreeDataHelper({
38
+ value: value,
39
+ getNodeValue: getNodeValue,
40
+ tree: tree
41
+ }) : new TreeDataHelper({
42
+ value: value,
43
+ getNodeValue: getNodeValue,
44
+ isDetached: isDetached,
45
+ tree: tree,
46
+ checkedStrategy: (_g = opts.checkedStrategy) !== null && _g !== void 0 ? _g : 'parent'
47
+ });
48
+
49
+ var onToggleKey = function onToggleKey(key) {
50
+ var _a;
51
+
52
+ var nextValue = treeDataHelper.getValueAfterToggle(key);
53
+ pipeline.setStateAtKey(STATE_KEY, nextValue);
54
+ (_a = opts.onChange) === null || _a === void 0 ? void 0 : _a.call(opts, nextValue);
55
+ };
56
+
57
+ var makeCheckbox = function makeCheckbox(key, root, row) {
58
+ return /*#__PURE__*/React.createElement(Checkbox, {
59
+ checked: treeDataHelper.isChecked(key),
60
+ indeterminate: treeDataHelper.isIndeterminate(key),
61
+ disabled: !root && isDisabled(row),
62
+ onChange: clickArea === 'checkbox' || root ? function () {
63
+ return onToggleKey(key);
64
+ } : undefined
65
+ });
66
+ };
67
+
68
+ var checkboxColumn = _extends(_extends({
69
+ name: '',
70
+ width: 50,
71
+ align: 'center',
72
+ title: opts.rootKey != null ? makeCheckbox(opts.rootKey, true) : undefined
73
+ }, opts.checkboxColumn), {
74
+ render: function render(value, record) {
75
+ return makeCheckbox(record[primaryKey], false, record);
76
+ },
77
+ getCellProps: function getCellProps(value, row) {
78
+ var rowKey = row[primaryKey];
79
+
80
+ if (clickArea !== 'cell') {
81
+ return;
82
+ }
83
+
84
+ var disabled = isDisabled(row);
85
+
86
+ if (disabled) {
87
+ return {
88
+ style: {
89
+ cursor: 'not-allowed'
90
+ }
91
+ };
92
+ }
93
+
94
+ return {
95
+ style: {
96
+ cursor: 'pointer'
97
+ },
98
+ onClick: function onClick(e) {
99
+ if (opts.stopClickEventPropagation) {
100
+ e.stopPropagation();
101
+ }
102
+
103
+ onToggleKey(rowKey);
104
+ }
105
+ };
106
+ }
107
+ });
108
+
109
+ var nextColumns = _sliceInstanceProperty(_context = pipeline.getColumns()).call(_context);
110
+
111
+ var checkboxPlacement = (_h = opts.checkboxPlacement) !== null && _h !== void 0 ? _h : 'start';
112
+
113
+ if (checkboxPlacement === 'start') {
114
+ nextColumns.unshift(checkboxColumn);
115
+ } else {
116
+ nextColumns.push(checkboxColumn);
117
+ }
118
+
119
+ pipeline.columns(nextColumns);
120
+
121
+ if (clickArea === 'row') {
122
+ pipeline.appendRowPropsGetter(function (row) {
123
+ var disabled = isDisabled(row);
124
+
125
+ if (!disabled) {
126
+ return {
127
+ style: {
128
+ cursor: 'pointer'
129
+ },
130
+ onClick: function onClick(e) {
131
+ if (opts.stopClickEventPropagation) {
132
+ e.stopPropagation();
133
+ }
134
+
135
+ onToggleKey(row[primaryKey]);
136
+ }
137
+ };
138
+ }
139
+ });
140
+ }
141
+
142
+ if (opts.highlightRowWhenSelected) {
143
+ pipeline.appendRowPropsGetter(function (row) {
144
+ if (treeDataHelper.isChecked(row[primaryKey])) {
145
+ return {
146
+ className: 'highlight'
147
+ };
148
+ }
149
+ });
150
+ }
151
+
152
+ return pipeline;
153
+ };
154
+ }
@@ -0,0 +1,3 @@
1
+ import * as features from './features';
2
+ export { TablePipeline, useTablePipeline } from './pipeline';
3
+ export { features };
@@ -0,0 +1,3 @@
1
+ import * as features from './features';
2
+ export { TablePipeline, useTablePipeline } from './pipeline';
3
+ export { features };
@@ -0,0 +1,85 @@
1
+ /// <reference types="react" />
2
+ import { TableProps, PrimaryKey } from '../base';
3
+ import { ArtColumn, TableTransform, Transform } from '../interfaces';
4
+ declare type RowPropsGetter = TableProps['getRowProps'];
5
+ export interface TablePipelineIndentsConfig {
6
+ iconIndent: number;
7
+ iconWidth: 16;
8
+ iconGap: number;
9
+ indentSize: number;
10
+ }
11
+ export interface TablePipelineCtx {
12
+ primaryKey?: PrimaryKey;
13
+ components: {
14
+ [name: string]: any;
15
+ };
16
+ indents: TablePipelineIndentsConfig;
17
+ [key: string]: any;
18
+ }
19
+ /**
20
+ * 表格数据处理流水线。TablePipeline 提供了表格数据处理过程中的一些上下方与工具方法,包括……
21
+ *
22
+ * 1. ctx:上下文环境对象,step(流水线上的一步)可以对 ctx 中的字段进行读写。
23
+ * ctx 中部分字段名称有特定的含义(例如 primaryKey 表示行的主键),使用自定义的上下文信息时注意避开这些名称。
24
+ *
25
+ * 2. rowPropsGetters:getRowProps 回调队列,step 可以通过 pipeline.appendRowPropsGetter 向队列中追加回调函数,
26
+ * 在调用 pipeline.props() 队列中的所有函数会组合形成最终的 getRowProps
27
+ *
28
+ * 3. 当前流水线的状态,包括 dataSource, columns, rowPropsGetters 三个部分
29
+ *
30
+ * 4. snapshots,调用 pipeline.snapshot(name) 可以记录当前的状态,后续可以通过 name 来读取保存的状态
31
+ * */
32
+ export declare class TablePipeline {
33
+ ref?: React.MutableRefObject<any>;
34
+ private readonly _snapshots;
35
+ private readonly _rowPropsGetters;
36
+ private _tableProps;
37
+ private _dataSource;
38
+ private _columns;
39
+ static defaultIndents: TablePipelineIndentsConfig;
40
+ readonly ctx: TablePipelineCtx;
41
+ private readonly state;
42
+ private readonly setState;
43
+ constructor({ state, setState, ctx, ref }: {
44
+ state: any;
45
+ setState: TablePipeline['setState'];
46
+ ctx: Partial<TablePipelineCtx>;
47
+ ref?: React.MutableRefObject<any>;
48
+ });
49
+ guid(): string;
50
+ appendRowPropsGetter(getter: RowPropsGetter): this;
51
+ addTableProps(props: React.HTMLAttributes<HTMLTableElement>): void;
52
+ getDataSource(name?: string): any[];
53
+ getColumns(name?: string): any[];
54
+ getStateAtKey<T = any>(stateKey: string, defaultValue?: T): T;
55
+ /** 将 stateKey 对应的状态设置为 partialState */
56
+ setStateAtKey(stateKey: string, partialState: any, extraInfo?: any): void;
57
+ /** 确保 primaryKey 已被设置,并返回 primaryKey */
58
+ ensurePrimaryKey(hint?: string): PrimaryKey;
59
+ /** 设置流水线的输入数据 */
60
+ input(input: {
61
+ dataSource: any[];
62
+ columns: ArtColumn[];
63
+ }): this;
64
+ /** 设置 dataSource */
65
+ dataSource(rows: any[]): this;
66
+ /** 设置 columns */
67
+ columns(cols: ArtColumn[]): this;
68
+ /** 设置主键 */
69
+ primaryKey(key: PrimaryKey): this;
70
+ /** 保存快照 */
71
+ snapshot(name: string): this;
72
+ /** @deprecated
73
+ * 应用一个 kd-table Table transform */
74
+ useTransform(transform: TableTransform): this;
75
+ /** 使用 pipeline 功能拓展 */
76
+ use(step: (pipeline: this) => this): this;
77
+ /** 转换 dataSource */
78
+ mapDataSource(mapper: Transform<any[]>): this;
79
+ /** 转换 columns */
80
+ mapColumns(mapper: Transform<ArtColumn[]>): this;
81
+ /** 获取 BaseTable 的 props,结果中包含 dataSource/columns/primaryKey/getRowProps 四个字段 */
82
+ getProps(this: TablePipeline): TableProps;
83
+ }
84
+ export declare function useTablePipeline(ctx?: Partial<TablePipelineCtx>): TablePipeline;
85
+ export {};
@@ -0,0 +1,272 @@
1
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
2
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
3
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
4
+ import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
5
+ import _createClass from "@babel/runtime-corejs3/helpers/createClass";
6
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
7
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
8
+ import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
9
+ import { useState, useRef } from 'react';
10
+ import { mergeCellProps } from '../utils';
11
+ import { autoFillTableWidth, tableWidthKey } from './features/autoFill';
12
+ /**
13
+ * 表格数据处理流水线。TablePipeline 提供了表格数据处理过程中的一些上下方与工具方法,包括……
14
+ *
15
+ * 1. ctx:上下文环境对象,step(流水线上的一步)可以对 ctx 中的字段进行读写。
16
+ * ctx 中部分字段名称有特定的含义(例如 primaryKey 表示行的主键),使用自定义的上下文信息时注意避开这些名称。
17
+ *
18
+ * 2. rowPropsGetters:getRowProps 回调队列,step 可以通过 pipeline.appendRowPropsGetter 向队列中追加回调函数,
19
+ * 在调用 pipeline.props() 队列中的所有函数会组合形成最终的 getRowProps
20
+ *
21
+ * 3. 当前流水线的状态,包括 dataSource, columns, rowPropsGetters 三个部分
22
+ *
23
+ * 4. snapshots,调用 pipeline.snapshot(name) 可以记录当前的状态,后续可以通过 name 来读取保存的状态
24
+ * */
25
+
26
+ export var TablePipeline = /*#__PURE__*/function () {
27
+ function TablePipeline(_ref) {
28
+ var state = _ref.state,
29
+ setState = _ref.setState,
30
+ ctx = _ref.ctx,
31
+ ref = _ref.ref;
32
+
33
+ _classCallCheck(this, TablePipeline);
34
+
35
+ this._snapshots = {};
36
+ this._rowPropsGetters = [];
37
+ this._tableProps = {};
38
+ this.ctx = {
39
+ components: {},
40
+ indents: TablePipeline.defaultIndents
41
+ };
42
+ this.state = state;
43
+ this.setState = setState;
44
+ this.ref = ref;
45
+
46
+ _extends(this.ctx, ctx);
47
+ } // Generate a pseudo-GUID by concatenating random hexadecimal.
48
+
49
+
50
+ _createClass(TablePipeline, [{
51
+ key: "guid",
52
+ value: function guid() {
53
+ function S4() {
54
+ return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
55
+ }
56
+
57
+ return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
58
+ }
59
+ }, {
60
+ key: "appendRowPropsGetter",
61
+ value: function appendRowPropsGetter(getter) {
62
+ this._rowPropsGetters.push(getter);
63
+
64
+ return this;
65
+ }
66
+ }, {
67
+ key: "addTableProps",
68
+ value: function addTableProps(props) {
69
+ this._tableProps = _extends(_extends({}, this._tableProps), props);
70
+ }
71
+ }, {
72
+ key: "getDataSource",
73
+ value: function getDataSource(name) {
74
+ if (name == null) {
75
+ return this._dataSource;
76
+ } else {
77
+ return this._snapshots[name].dataSource;
78
+ }
79
+ }
80
+ }, {
81
+ key: "getColumns",
82
+ value: function getColumns(name) {
83
+ if (name == null) {
84
+ return this._columns;
85
+ } else {
86
+ return this._snapshots[name].columns;
87
+ }
88
+ }
89
+ }, {
90
+ key: "getStateAtKey",
91
+ value: function getStateAtKey(stateKey, defaultValue) {
92
+ var _a;
93
+
94
+ return (_a = this.state[stateKey]) !== null && _a !== void 0 ? _a : defaultValue;
95
+ }
96
+ /** 将 stateKey 对应的状态设置为 partialState */
97
+
98
+ }, {
99
+ key: "setStateAtKey",
100
+ value: function setStateAtKey(stateKey, partialState, extraInfo) {
101
+ this.setState(function (prev) {
102
+ return _extends(_extends({}, prev), _defineProperty({}, stateKey, partialState));
103
+ }, stateKey, partialState, extraInfo);
104
+ }
105
+ /** 确保 primaryKey 已被设置,并返回 primaryKey */
106
+
107
+ }, {
108
+ key: "ensurePrimaryKey",
109
+ value: function ensurePrimaryKey(hint) {
110
+ if (this.ctx.primaryKey == null) {
111
+ throw new Error(hint ? "\u4F7F\u7528 ".concat(hint, " \u4E4B\u524D\u5FC5\u987B\u5148\u8BBE\u7F6E primaryKey") : '必须先设置 primaryKey');
112
+ }
113
+
114
+ return this.ctx.primaryKey;
115
+ }
116
+ /** 设置流水线的输入数据 */
117
+
118
+ }, {
119
+ key: "input",
120
+ value: function input(_input) {
121
+ var _context,
122
+ _this = this;
123
+
124
+ if (this._dataSource != null || this._columns != null) {
125
+ throw new Error('input 不能调用两次');
126
+ }
127
+
128
+ this._dataSource = _input.dataSource;
129
+ this._columns = _mapInstanceProperty(_context = _input.columns).call(_context, function (col) {
130
+ return _extends(_extends({}, col), {
131
+ key: _this.guid()
132
+ });
133
+ });
134
+ this.snapshot('input');
135
+ return this;
136
+ }
137
+ /** 设置 dataSource */
138
+
139
+ }, {
140
+ key: "dataSource",
141
+ value: function dataSource(rows) {
142
+ this._dataSource = rows;
143
+ return this;
144
+ }
145
+ /** 设置 columns */
146
+
147
+ }, {
148
+ key: "columns",
149
+ value: function columns(cols) {
150
+ this._columns = cols;
151
+ return this;
152
+ }
153
+ /** 设置主键 */
154
+
155
+ }, {
156
+ key: "primaryKey",
157
+ value: function primaryKey(key) {
158
+ this.ctx.primaryKey = key;
159
+ return this;
160
+ }
161
+ /** 保存快照 */
162
+
163
+ }, {
164
+ key: "snapshot",
165
+ value: function snapshot(name) {
166
+ var _context2;
167
+
168
+ this._snapshots[name] = {
169
+ dataSource: this._dataSource,
170
+ columns: this._columns,
171
+ rowPropsGetters: _sliceInstanceProperty(_context2 = this._rowPropsGetters).call(_context2)
172
+ };
173
+ return this;
174
+ }
175
+ /** @deprecated
176
+ * 应用一个 kd-table Table transform */
177
+
178
+ }, {
179
+ key: "useTransform",
180
+ value: function useTransform(transform) {
181
+ var next = transform({
182
+ dataSource: this.getDataSource(),
183
+ columns: this.getColumns()
184
+ });
185
+ return this.dataSource(next.dataSource).columns(next.columns);
186
+ }
187
+ /** 使用 pipeline 功能拓展 */
188
+
189
+ }, {
190
+ key: "use",
191
+ value: function use(step) {
192
+ return step(this);
193
+ }
194
+ /** 转换 dataSource */
195
+
196
+ }, {
197
+ key: "mapDataSource",
198
+ value: function mapDataSource(mapper) {
199
+ return this.dataSource(mapper(this.getDataSource()));
200
+ }
201
+ /** 转换 columns */
202
+
203
+ }, {
204
+ key: "mapColumns",
205
+ value: function mapColumns(mapper) {
206
+ return this.columns(mapper(this.getColumns()));
207
+ }
208
+ /** 获取 BaseTable 的 props,结果中包含 dataSource/columns/primaryKey/getRowProps 四个字段 */
209
+
210
+ }, {
211
+ key: "getProps",
212
+ value: function getProps() {
213
+ var _this2 = this;
214
+
215
+ this.use(autoFillTableWidth());
216
+ var result = {
217
+ dataSource: this._dataSource,
218
+ columns: this._columns
219
+ };
220
+
221
+ if (this.ctx.primaryKey) {
222
+ result.primaryKey = this.ctx.primaryKey;
223
+ }
224
+
225
+ if (this._rowPropsGetters.length > 0) {
226
+ result.getRowProps = function (row, rowIndex) {
227
+ var _context3;
228
+
229
+ return _reduceInstanceProperty(_context3 = _this2._rowPropsGetters).call(_context3, function (res, get) {
230
+ return mergeCellProps(res, get(row, rowIndex));
231
+ }, {});
232
+ };
233
+ }
234
+
235
+ result.getTableProps = function () {
236
+ return _this2._tableProps;
237
+ };
238
+
239
+ result.setTableWidth = function (tableWidth) {
240
+ var preTableWidth = _this2.getStateAtKey(tableWidthKey);
241
+
242
+ if (preTableWidth !== tableWidth) {
243
+ _this2.setStateAtKey(tableWidthKey, tableWidth);
244
+ }
245
+ };
246
+
247
+ return result;
248
+ }
249
+ }]);
250
+
251
+ return TablePipeline;
252
+ }();
253
+ TablePipeline.defaultIndents = {
254
+ iconIndent: -8,
255
+ iconWidth: 16,
256
+ iconGap: 0,
257
+ indentSize: 16
258
+ };
259
+ export function useTablePipeline(ctx) {
260
+ var _useState = useState({}),
261
+ _useState2 = _slicedToArray(_useState, 2),
262
+ state = _useState2[0],
263
+ setState = _useState2[1];
264
+
265
+ var ref = useRef({});
266
+ return new TablePipeline({
267
+ state: state,
268
+ setState: setState,
269
+ ctx: ctx,
270
+ ref: ref
271
+ });
272
+ }
@@ -0,0 +1,14 @@
1
+ import { TableProps } from '../../base';
2
+ import { CrossTableProps } from './cross-table';
3
+ import { CrossTableLeftMetaColumn, LeftCrossTreeNode, TopCrossTreeNode } from './interfaces';
4
+ export interface BuildCrossTableOptions {
5
+ leftTree: LeftCrossTreeNode[];
6
+ topTree: TopCrossTreeNode[];
7
+ leftTotalNode?: LeftCrossTreeNode;
8
+ topTotalNode?: TopCrossTreeNode;
9
+ leftMetaColumns: CrossTableLeftMetaColumn[];
10
+ getValue: CrossTableProps['getValue'];
11
+ render?: CrossTableProps['render'];
12
+ getCellProps?: CrossTableProps['getCellProps'];
13
+ }
14
+ export default function buildCrossTable(options: BuildCrossTableOptions): Pick<TableProps, 'columns' | 'dataSource'>;