@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,254 @@
1
+ import _toArray from "@babel/runtime-corejs3/helpers/toArray";
2
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
3
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
4
+ import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
5
+ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
6
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
7
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
8
+ import _Set from "@babel/runtime-corejs3/core-js-stable/set";
9
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
10
+ import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
11
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
12
+ import cx from 'classnames';
13
+ import React from 'react';
14
+ import { ExpansionCell, icons, InlineFlexCell } from '../../common-views';
15
+ import { internals } from '../../internals';
16
+ import { collectNodes, mergeCellProps } from '../../utils';
17
+ import { always, flatMap } from '../../utils/others';
18
+ import console from '../../utils/console';
19
+
20
+ var rowDetailSymbol = _Symbol('row-detail');
21
+
22
+ var fallbackRenderDetail = function fallbackRenderDetail() {
23
+ return /*#__PURE__*/React.createElement("div", {
24
+ style: {
25
+ margin: '8px 24px'
26
+ }
27
+ }, /*#__PURE__*/React.createElement("b", {
28
+ style: {
29
+ color: 'indianred'
30
+ }
31
+ }, "\u8BBE\u7F6E ", /*#__PURE__*/React.createElement("code", null, "rowDetail.renderDetail"), " \u6765\u81EA\u5B9A\u4E49\u8BE6\u60C5\u5185\u5BB9"));
32
+ };
33
+
34
+ export function rowDetail() {
35
+ var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
36
+ return function rowDetailStep(pipeline) {
37
+ var _context, _context2;
38
+
39
+ var _a, _b, _c, _d, _e, _f, _g, _h;
40
+
41
+ var stateKey = 'rowDetail';
42
+ var primaryKey = pipeline.ensurePrimaryKey('rowDetail');
43
+
44
+ if (typeof primaryKey !== 'string') {
45
+ throw new Error('rowDetail 仅支持字符串作为 primaryKey');
46
+ }
47
+
48
+ var rowDetailMetaKey = (_a = opts.rowDetailMetaKey) !== null && _a !== void 0 ? _a : rowDetailSymbol;
49
+ var indents = pipeline.ctx.indents;
50
+ var textOffset = indents.iconIndent + indents.iconWidth + indents.iconGap;
51
+ var clickArea = (_b = opts.clickArea) !== null && _b !== void 0 ? _b : 'cell';
52
+ var getDetailKey = (_c = opts.getDetailKey) !== null && _c !== void 0 ? _c : function (row) {
53
+ return row[primaryKey] + '_detail';
54
+ };
55
+ var renderDetail = (_d = opts.renderDetail) !== null && _d !== void 0 ? _d : fallbackRenderDetail;
56
+ var hasDetail = (_e = opts.hasDetail) !== null && _e !== void 0 ? _e : always(true);
57
+ var openKeys = (_h = (_g = (_f = opts.openKeys) !== null && _f !== void 0 ? _f : pipeline.getStateAtKey(stateKey)) !== null && _g !== void 0 ? _g : opts.defaultOpenAll ? _mapInstanceProperty(_context = _filterInstanceProperty(_context2 = pipeline.getDataSource()).call(_context2, hasDetail)).call(_context, function (row) {
58
+ return row[primaryKey];
59
+ }) : opts.defaultOpenKeys) !== null && _h !== void 0 ? _h : [];
60
+
61
+ var onChangeOpenKeys = function onChangeOpenKeys(nextKeys, key, action) {
62
+ var _a;
63
+
64
+ (_a = opts.onChangeOpenKeys) === null || _a === void 0 ? void 0 : _a.call(opts, nextKeys, key, action);
65
+ pipeline.setStateAtKey(stateKey, nextKeys, {
66
+ key: key,
67
+ action: action
68
+ });
69
+ };
70
+
71
+ var openKeySet = new _Set(openKeys);
72
+
73
+ var toggle = function toggle(rowKey) {
74
+ var expanded = openKeySet.has(rowKey);
75
+
76
+ if (expanded) {
77
+ onChangeOpenKeys(_filterInstanceProperty(openKeys).call(openKeys, function (key) {
78
+ return key !== rowKey;
79
+ }), rowKey, 'collapse');
80
+ } else {
81
+ var _context3;
82
+
83
+ onChangeOpenKeys(_concatInstanceProperty(_context3 = []).call(_context3, _toConsumableArray(openKeys), [rowKey]), rowKey, 'expand');
84
+ }
85
+ };
86
+
87
+ return pipeline.dataSource(flatMap(pipeline.getDataSource(), function (row, rowIndex) {
88
+ if (openKeySet.has(row[primaryKey])) {
89
+ return [row, _extends(_extends(_defineProperty({}, rowDetailMetaKey, true), row), _defineProperty({}, primaryKey, getDetailKey(row, rowIndex)))];
90
+ } else {
91
+ return [row];
92
+ }
93
+ })).columns(processColumns(pipeline.getColumns())).appendRowPropsGetter(function (row) {
94
+ if (row[rowDetailMetaKey]) {
95
+ return {
96
+ className: 'no-hover'
97
+ };
98
+ }
99
+ });
100
+
101
+ function processColumns(columns) {
102
+ if (columns.length === 0) {
103
+ return columns;
104
+ }
105
+
106
+ var expandColumnIndex = 0;
107
+
108
+ if (opts.expandColumnCode) {
109
+ expandColumnIndex = _findIndexInstanceProperty(columns).call(columns, function (col) {
110
+ return col.code === opts.expandColumnCode;
111
+ });
112
+
113
+ if (expandColumnIndex < 0) {
114
+ console.warn('没找到可展开的列,请检查设置的展开列code');
115
+ return columns;
116
+ }
117
+ }
118
+
119
+ var expandCol = columns[expandColumnIndex];
120
+
121
+ var tableColumns = _toConsumableArray(columns);
122
+
123
+ var render = function render(value, row, rowIndex) {
124
+ if (row[rowDetailMetaKey]) {
125
+ return renderDetail(row, rowIndex);
126
+ }
127
+
128
+ var content = internals.safeRender(expandCol, row, rowIndex);
129
+
130
+ if (!hasDetail(row, rowIndex)) {
131
+ return /*#__PURE__*/React.createElement(InlineFlexCell, {
132
+ style: {
133
+ marginLeft: textOffset
134
+ }
135
+ }, content);
136
+ }
137
+
138
+ var rowKey = row[primaryKey];
139
+ var expanded = openKeySet.has(rowKey);
140
+
141
+ var onClick = function onClick(e) {
142
+ if (opts.stopClickEventPropagation) {
143
+ e.stopPropagation();
144
+ }
145
+
146
+ toggle(rowKey);
147
+ };
148
+
149
+ var expandCls = expanded ? 'expanded' : 'collapsed';
150
+ var ExpandIcon = opts.expandIcon;
151
+ return /*#__PURE__*/React.createElement(ExpansionCell, {
152
+ className: cx('expansion-cell', expandCls),
153
+ style: {
154
+ cursor: clickArea === 'content' ? 'pointer' : undefined
155
+ },
156
+ onClick: clickArea === 'content' ? onClick : undefined
157
+ }, opts.expandIcon ? /*#__PURE__*/React.createElement(ExpandIcon, {
158
+ expanded: expanded,
159
+ onClick: clickArea === 'icon' ? onClick : undefined
160
+ }) : /*#__PURE__*/React.createElement(icons.CaretRight, {
161
+ style: {
162
+ cursor: clickArea === 'icon' ? 'pointer' : undefined,
163
+ marginLeft: indents.iconIndent,
164
+ marginRight: indents.iconGap
165
+ },
166
+ className: cx('expansion-icon', expandCls),
167
+ onClick: clickArea === 'icon' ? onClick : undefined
168
+ }), content);
169
+ };
170
+
171
+ var getCellProps = function getCellProps(value, row, rowIndex) {
172
+ var _a;
173
+
174
+ if (row[rowDetailMetaKey]) {
175
+ return {
176
+ style: _extends({
177
+ '--cell-padding': '0',
178
+ overflow: 'hidden'
179
+ }, opts.detailCellStyle)
180
+ };
181
+ }
182
+
183
+ var prevProps = (_a = expandCol.getCellProps) === null || _a === void 0 ? void 0 : _a.call(expandCol, value, row, rowIndex);
184
+
185
+ if (!hasDetail(row, rowIndex)) {
186
+ return prevProps;
187
+ }
188
+
189
+ return mergeCellProps(prevProps, {
190
+ onClick: function onClick(e) {
191
+ if (opts.stopClickEventPropagation) {
192
+ e.stopPropagation();
193
+ }
194
+
195
+ toggle(row[primaryKey]);
196
+ },
197
+ style: {
198
+ cursor: 'pointer'
199
+ }
200
+ });
201
+ };
202
+
203
+ var _tableColumns = _toArray(tableColumns),
204
+ firstCol = _tableColumns[0],
205
+ others = _sliceInstanceProperty(_tableColumns).call(_tableColumns, 1);
206
+
207
+ var firstColRender = function firstColRender(value, row, rowIndex) {
208
+ if (row[rowDetailMetaKey]) {
209
+ return renderDetail(row, rowIndex);
210
+ }
211
+
212
+ var content = internals.safeRender(firstCol, row, rowIndex);
213
+ return content;
214
+ };
215
+
216
+ tableColumns[0] = _extends(_extends({}, firstCol), {
217
+ render: firstColRender,
218
+ getSpanRect: function getSpanRect(value, row, rowIndex) {
219
+ if (row[rowDetailMetaKey]) {
220
+ // detail 总是成一行
221
+ return {
222
+ top: rowIndex,
223
+ bottom: rowIndex + 1,
224
+ left: 0,
225
+ right: collectNodes(pipeline.getColumns(), 'leaf-only').length
226
+ };
227
+ }
228
+ }
229
+ });
230
+ tableColumns[expandColumnIndex] = _extends(_extends({}, expandCol), {
231
+ title: /*#__PURE__*/React.createElement("div", {
232
+ style: {
233
+ display: 'inline-block',
234
+ marginLeft: textOffset
235
+ }
236
+ }, internals.safeRenderHeader(expandCol)),
237
+ render: render,
238
+ getCellProps: clickArea === 'cell' ? getCellProps : expandCol.getCellProps,
239
+ getSpanRect: function getSpanRect(value, row, rowIndex) {
240
+ if (row[rowDetailMetaKey]) {
241
+ // detail 总是成一行
242
+ return {
243
+ top: rowIndex,
244
+ bottom: rowIndex + 1,
245
+ left: 0,
246
+ right: collectNodes(pipeline.getColumns(), 'leaf-only').length
247
+ };
248
+ }
249
+ }
250
+ });
251
+ return tableColumns;
252
+ }
253
+ };
254
+ }
@@ -0,0 +1,14 @@
1
+ import { TablePipeline } from '../pipeline';
2
+ export interface RowGroupingFeatureOptions {
3
+ /** 非受控用法:是否默认展开所有分组 */
4
+ defaultOpenAll?: boolean;
5
+ /** 非受控用法:默认展开的 keys */
6
+ defaultOpenKeys?: string[];
7
+ /** 受控用法:当前展开的 keys */
8
+ openKeys?: string[];
9
+ /** 受控用法:当前展开 keys 改变回调 */
10
+ onChangeOpenKeys?(nextKeys: string[], key: string, action: 'expand' | 'collapse'): void;
11
+ /** 是否对触发 onChangeOpenKeys 的 click 事件调用 event.stopPropagation() */
12
+ stopClickEventPropagation?: boolean;
13
+ }
14
+ export declare function rowGrouping(opts?: RowGroupingFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
@@ -0,0 +1,200 @@
1
+ import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
2
+ import _toArray from "@babel/runtime-corejs3/helpers/toArray";
3
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
4
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
5
+ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
6
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
7
+ import _Set from "@babel/runtime-corejs3/core-js-stable/set";
8
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
9
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
10
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
11
+ import cx from 'classnames';
12
+ import React from 'react';
13
+ import { ExpansionCell, icons, InlineFlexCell } from '../../common-views';
14
+ import { internals } from '../../internals';
15
+ import { collectNodes, isLeafNode, mergeCellProps } from '../../utils';
16
+ import { flatMap } from '../../utils/others';
17
+
18
+ var groupingMetaSymbol = _Symbol('row-grouping-meta');
19
+
20
+ function attachGroupingMeta(row) {
21
+ return _extends(_defineProperty({}, groupingMetaSymbol, {
22
+ expandable: !isLeafNode(row)
23
+ }), row);
24
+ }
25
+
26
+ function getGroupingMeta(row) {
27
+ if (row[groupingMetaSymbol] == null) {
28
+ return {
29
+ isGroupHeader: false,
30
+ expandable: false
31
+ };
32
+ }
33
+
34
+ return {
35
+ isGroupHeader: true,
36
+ expandable: row[groupingMetaSymbol].expandable
37
+ };
38
+ }
39
+
40
+ function rowGroupingRowPropsGetter(row) {
41
+ if (getGroupingMeta(row).isGroupHeader) {
42
+ return {
43
+ className: 'alternative'
44
+ };
45
+ }
46
+ }
47
+
48
+ export function rowGrouping() {
49
+ var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
50
+ return function (pipeline) {
51
+ var _context;
52
+
53
+ var _a, _b, _c;
54
+
55
+ var stateKey = 'rowGrouping';
56
+ var indents = pipeline.ctx.indents;
57
+ var textOffset = indents.iconIndent + indents.iconWidth + indents.iconGap;
58
+ var primaryKey = pipeline.ensurePrimaryKey('rowGrouping');
59
+
60
+ if (typeof primaryKey !== 'string') {
61
+ throw new Error('rowGrouping 仅支持字符串作为 primaryKey');
62
+ }
63
+
64
+ var openKeys = (_c = (_b = (_a = opts.openKeys) !== null && _a !== void 0 ? _a : pipeline.getStateAtKey(stateKey)) !== null && _b !== void 0 ? _b : opts.defaultOpenAll ? _mapInstanceProperty(_context = pipeline.getDataSource()).call(_context, function (row) {
65
+ return row[primaryKey];
66
+ }) : opts.defaultOpenKeys) !== null && _c !== void 0 ? _c : [];
67
+ var openKeySet = new _Set(openKeys);
68
+
69
+ var onChangeOpenKeys = function onChangeOpenKeys(nextKeys, key, action) {
70
+ var _a;
71
+
72
+ (_a = opts.onChangeOpenKeys) === null || _a === void 0 ? void 0 : _a.call(opts, nextKeys, key, action);
73
+ pipeline.setStateAtKey(stateKey, nextKeys, {
74
+ key: key,
75
+ action: action
76
+ });
77
+ };
78
+
79
+ return pipeline.mapDataSource(processDataSource).mapColumns(processColumns).appendRowPropsGetter(rowGroupingRowPropsGetter);
80
+
81
+ function processDataSource(input) {
82
+ return flatMap(input, function (row) {
83
+ var result = [attachGroupingMeta(row)];
84
+ var expanded = openKeySet.has(row[primaryKey]);
85
+
86
+ if (expanded) {
87
+ if (Array.isArray(row.children)) {
88
+ result = _concatInstanceProperty(result).call(result, row.children);
89
+ }
90
+ }
91
+
92
+ return result;
93
+ });
94
+ }
95
+
96
+ function processColumns(columns) {
97
+ var _context3;
98
+
99
+ if (columns.length === 0) {
100
+ return columns;
101
+ }
102
+
103
+ var columnFlatCount = collectNodes(columns, 'leaf-only').length;
104
+
105
+ var _columns = _toArray(columns),
106
+ firstCol = _columns[0],
107
+ others = _sliceInstanceProperty(_columns).call(_columns, 1);
108
+
109
+ var render = function render(value, row, rowIndex) {
110
+ var _a, _b;
111
+
112
+ var content = internals.safeRender(firstCol, row, rowIndex);
113
+ var meta = getGroupingMeta(row);
114
+
115
+ if (!meta.isGroupHeader || !meta.expandable) {
116
+ var marginLeft = textOffset + (meta.isGroupHeader ? 0 : indents.indentSize);
117
+ return /*#__PURE__*/React.createElement(InlineFlexCell, {
118
+ style: {
119
+ marginLeft: marginLeft
120
+ }
121
+ }, meta.isGroupHeader ? (_a = row.groupTitle) !== null && _a !== void 0 ? _a : content : content);
122
+ }
123
+
124
+ var expanded = openKeySet.has(row[primaryKey]);
125
+ var expandCls = expanded ? 'expanded' : 'collapsed';
126
+ return /*#__PURE__*/React.createElement(ExpansionCell, {
127
+ className: cx('expansion-cell', expandCls)
128
+ }, /*#__PURE__*/React.createElement(icons.CaretRight, {
129
+ className: cx('expansion-icon', expandCls),
130
+ style: {
131
+ marginLeft: indents.iconIndent,
132
+ marginRight: indents.iconGap
133
+ }
134
+ }), (_b = row.groupTitle) !== null && _b !== void 0 ? _b : content);
135
+ };
136
+
137
+ var getCellProps = function getCellProps(value, row, rowIndex) {
138
+ var _a;
139
+
140
+ var meta = getGroupingMeta(row);
141
+
142
+ if (!meta.isGroupHeader) {
143
+ return;
144
+ }
145
+
146
+ var expandable = meta.expandable;
147
+ var rowKey = row[primaryKey];
148
+ var expanded = openKeySet.has(rowKey);
149
+ var onClick;
150
+
151
+ if (expandable) {
152
+ onClick = function onClick(e) {
153
+ if (opts.stopClickEventPropagation) {
154
+ e.stopPropagation();
155
+ }
156
+
157
+ if (expanded) {
158
+ onChangeOpenKeys(_filterInstanceProperty(openKeys).call(openKeys, function (key) {
159
+ return key !== rowKey;
160
+ }), rowKey, 'collapse');
161
+ } else {
162
+ var _context2;
163
+
164
+ onChangeOpenKeys(_concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(openKeys), [rowKey]), rowKey, 'expand');
165
+ }
166
+ };
167
+ }
168
+
169
+ var prevProps = (_a = firstCol.getCellProps) === null || _a === void 0 ? void 0 : _a.call(firstCol, value, row, rowIndex);
170
+ return mergeCellProps(prevProps, {
171
+ onClick: onClick,
172
+ style: {
173
+ cursor: expandable ? 'pointer' : undefined
174
+ }
175
+ });
176
+ };
177
+
178
+ return _concatInstanceProperty(_context3 = [_extends(_extends({}, firstCol), {
179
+ title: /*#__PURE__*/React.createElement("div", {
180
+ style: {
181
+ display: 'inline-block',
182
+ marginLeft: textOffset
183
+ }
184
+ }, internals.safeRenderHeader(firstCol)),
185
+ render: render,
186
+ getCellProps: getCellProps,
187
+ getSpanRect: function getSpanRect(value, row, rowIndex) {
188
+ if (getGroupingMeta(row).isGroupHeader) {
189
+ return {
190
+ top: rowIndex,
191
+ bottom: rowIndex + 1,
192
+ left: 0,
193
+ right: columnFlatCount
194
+ };
195
+ }
196
+ }
197
+ })]).call(_context3, _toConsumableArray(others));
198
+ }
199
+ };
200
+ }
@@ -0,0 +1,23 @@
1
+ import { ArtColumn } from '../../interfaces';
2
+ import { TablePipeline } from '../pipeline';
3
+ export interface SingleSelectFeatureOptions {
4
+ /** 是否高亮被选中的行 */
5
+ highlightRowWhenSelected?: boolean;
6
+ /** 非受控用法:默认选中的值 */
7
+ defaultValue?: string;
8
+ /** 受控用法:当前选中的值 */
9
+ value?: string;
10
+ /** 受控用法:选中值改变回调 */
11
+ onChange?: (next: string) => void;
12
+ /** 判断一行是否禁用 */
13
+ isDisabled?(row: any, rowIndex: number): boolean;
14
+ /** 点击事件的响应区域 */
15
+ clickArea?: 'radio' | 'cell' | 'row';
16
+ /** 单选框所在列的 column 配置,可指定 width,lock 等属性 */
17
+ radioColumn?: Partial<ArtColumn>;
18
+ /** 单选框所在列的位置 */
19
+ radioPlacement?: 'start' | 'end';
20
+ /** 是否对触发 onChange 的 click 事件调用 event.stopPropagation() */
21
+ stopClickEventPropagation?: boolean;
22
+ }
23
+ export declare function singleSelect(opts?: SingleSelectFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
@@ -0,0 +1,122 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
3
+ import React from 'react';
4
+ import { internals } from '../../internals';
5
+ import { always } from '../../utils/others';
6
+ import { mergeCellProps } from '../../utils';
7
+ export function singleSelect() {
8
+ var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9
+ return function singleSelectStep(pipeline) {
10
+ var _context;
11
+
12
+ var _a, _b, _c, _d, _e;
13
+
14
+ var Radio = pipeline.ctx.components.Radio;
15
+
16
+ if (Radio == null) {
17
+ throw new Error('使用 singleSelect 之前需要通过 pipeline context 设置 components.Radio');
18
+ }
19
+
20
+ var stateKey = 'singleSelect';
21
+ var clickArea = (_a = opts.clickArea) !== null && _a !== void 0 ? _a : 'radio';
22
+ var isDisabled = (_b = opts.isDisabled) !== null && _b !== void 0 ? _b : always(false);
23
+ var primaryKey = pipeline.ensurePrimaryKey('singleSelect');
24
+ var value = (_d = (_c = opts.value) !== null && _c !== void 0 ? _c : pipeline.getStateAtKey(stateKey)) !== null && _d !== void 0 ? _d : opts.defaultValue;
25
+
26
+ var onChange = function onChange(rowKey) {
27
+ var _a;
28
+
29
+ (_a = opts.onChange) === null || _a === void 0 ? void 0 : _a.call(opts, rowKey);
30
+ pipeline.setStateAtKey(stateKey, rowKey);
31
+ };
32
+
33
+ var radioColumn = _extends(_extends({
34
+ name: '',
35
+ width: 50,
36
+ align: 'center'
37
+ }, opts.radioColumn), {
38
+ getCellProps: function getCellProps(value, row, rowIndex) {
39
+ var _a, _b;
40
+
41
+ if (clickArea === 'cell') {
42
+ var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
43
+ var disabled = isDisabled(row, rowIndex);
44
+ var preCellProps = (_b = (_a = opts.radioColumn) === null || _a === void 0 ? void 0 : _a.getCellProps) === null || _b === void 0 ? void 0 : _b.call(_a, value, row, rowIndex);
45
+ return mergeCellProps(preCellProps, {
46
+ style: {
47
+ cursor: disabled ? 'not-allowed' : 'pointer'
48
+ },
49
+ onClick: disabled ? undefined : function (e) {
50
+ if (opts.stopClickEventPropagation) {
51
+ e.stopPropagation();
52
+ }
53
+
54
+ onChange(rowKey);
55
+ }
56
+ });
57
+ }
58
+ },
59
+ render: function render(_, row, rowIndex) {
60
+ var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
61
+ return /*#__PURE__*/React.createElement(Radio, {
62
+ checked: value === rowKey,
63
+ disabled: isDisabled(row, rowIndex),
64
+ onChange: clickArea === 'radio' ? function (arg1, arg2) {
65
+ var _a;
66
+
67
+ var nativeEvent = (_a = arg2 === null || arg2 === void 0 ? void 0 : arg2.nativeEvent) !== null && _a !== void 0 ? _a : arg1 === null || arg1 === void 0 ? void 0 : arg1.nativeEvent;
68
+
69
+ if (nativeEvent && opts.stopClickEventPropagation) {
70
+ nativeEvent.stopPropagation();
71
+ }
72
+
73
+ onChange(rowKey);
74
+ } : undefined
75
+ });
76
+ }
77
+ });
78
+
79
+ var nextColumns = _sliceInstanceProperty(_context = pipeline.getColumns()).call(_context);
80
+
81
+ var radioPlacement = (_e = opts.radioPlacement) !== null && _e !== void 0 ? _e : 'start';
82
+
83
+ if (radioPlacement === 'start') {
84
+ nextColumns.unshift(radioColumn);
85
+ } else {
86
+ nextColumns.push(radioColumn);
87
+ }
88
+
89
+ pipeline.columns(nextColumns);
90
+ pipeline.appendRowPropsGetter(function (row, rowIndex) {
91
+ var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
92
+ var style = {};
93
+ var className;
94
+ var onClick;
95
+
96
+ if (opts.highlightRowWhenSelected) {
97
+ if (value === rowKey) {
98
+ className = 'highlight';
99
+ }
100
+ }
101
+
102
+ if (clickArea === 'row' && !isDisabled(row, rowIndex)) {
103
+ style.cursor = 'pointer';
104
+
105
+ onClick = function onClick(e) {
106
+ if (opts.stopClickEventPropagation) {
107
+ e.stopPropagation();
108
+ }
109
+
110
+ onChange(rowKey);
111
+ };
112
+ }
113
+
114
+ return {
115
+ className: className,
116
+ style: style,
117
+ onClick: onClick
118
+ };
119
+ });
120
+ return pipeline;
121
+ };
122
+ }
@@ -0,0 +1,40 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ArtColumn, SortItem, SortOrder } from '../../interfaces';
3
+ import { TablePipeline } from '../pipeline';
4
+ export interface SortHeaderCellProps {
5
+ /** 调用 makeSortTransform(...) 时的参数 */
6
+ sortOptions: Required<Omit<SortFeatureOptions, 'SortHeaderCell' | 'defaultSorts'>>;
7
+ /** 在添加排序相关的内容之前 表头原有的渲染内容 */
8
+ children: ReactNode;
9
+ /** 当前排序 */
10
+ sortOrder: SortOrder;
11
+ /** 多列排序下,sortIndex 指明了当前排序字段起作用的顺序. 当 sortOrder 为 none 时,sortIndex 固定为 -1 */
12
+ sortIndex: number;
13
+ /** 当前列的配置 */
14
+ column: ArtColumn;
15
+ /** 切换排序的回调 */
16
+ onToggle(e: React.MouseEvent): void;
17
+ }
18
+ export interface SortFeatureOptions {
19
+ /** (非受控用法) 默认的排序字段列表 */
20
+ defaultSorts?: SortItem[];
21
+ /** (受控用法) 排序字段列表 */
22
+ sorts?: SortItem[];
23
+ /** 更新排序字段列表的回调函数 */
24
+ onChangeSorts?(nextSorts: SortItem[], currentSort: SortItem): void;
25
+ /** 排序切换顺序 */
26
+ orders?: SortOrder[];
27
+ /** 排序模式。单选 single,多选 multiple,默认为多选 */
28
+ mode?: 'single' | 'multiple';
29
+ /** 自定义排序表头 */
30
+ SortHeaderCell?: React.ComponentType<SortHeaderCellProps>;
31
+ /** 是否保持 dataSource 不变 */
32
+ keepDataSource?: boolean;
33
+ /** 排序激活时 是否高亮这一列的单元格 */
34
+ highlightColumnWhenActive?: boolean;
35
+ /** 是否对触发 onChangeOpenKeys 的 click 事件调用 event.stopPropagation() */
36
+ stopClickEventPropagation?: boolean;
37
+ /** sort icon 是否 hover 之后显示 */
38
+ sortIconHoverShow?: boolean;
39
+ }
40
+ export declare function sort(opts?: SortFeatureOptions): (pipeline: TablePipeline) => TablePipeline;