amis-ui 3.5.2 → 3.6.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 (714) hide show
  1. package/esm/components/404.js +1 -1
  2. package/esm/components/Alert.js +1 -1
  3. package/esm/components/Alert2.d.ts +11 -10
  4. package/esm/components/Alert2.js +3 -2
  5. package/esm/components/AnchorNav.js +1 -1
  6. package/esm/components/ArrayInput.js +1 -1
  7. package/esm/components/AsideNav.js +1 -1
  8. package/esm/components/AssociatedSelection.d.ts +40 -40
  9. package/esm/components/AssociatedSelection.js +7 -7
  10. package/esm/components/Avatar.js +1 -1
  11. package/esm/components/Badge.js +1 -1
  12. package/esm/components/BaiduMapPicker.d.ts +3 -1
  13. package/esm/components/BaiduMapPicker.js +37 -18
  14. package/esm/components/BarCode.js +1 -1
  15. package/esm/components/Breadcrumb.js +1 -1
  16. package/esm/components/Button.d.ts +10 -10
  17. package/esm/components/Button.js +1 -1
  18. package/esm/components/CalendarMobile.js +1 -1
  19. package/esm/components/Card.d.ts +10 -10
  20. package/esm/components/Card.js +1 -1
  21. package/esm/components/Cascader.js +1 -1
  22. package/esm/components/ChainedDropdownSelection.d.ts +40 -40
  23. package/esm/components/ChainedDropdownSelection.js +1 -1
  24. package/esm/components/ChainedSelection.d.ts +40 -40
  25. package/esm/components/ChainedSelection.js +6 -6
  26. package/esm/components/Checkbox.js +1 -1
  27. package/esm/components/CityArea.js +1 -1
  28. package/esm/components/CityDB.js +1 -1
  29. package/esm/components/CodeMirror.js +1 -1
  30. package/esm/components/Collapse.js +1 -1
  31. package/esm/components/CollapseGroup.js +1 -1
  32. package/esm/components/ColorPicker.js +1 -1
  33. package/esm/components/Combo.js +1 -1
  34. package/esm/components/ConfirmBox.js +1 -1
  35. package/esm/components/ContextMenu.js +1 -1
  36. package/esm/components/DatePicker.d.ts +52 -41
  37. package/esm/components/DatePicker.js +114 -27
  38. package/esm/components/DateRangePicker.d.ts +18 -10
  39. package/esm/components/DateRangePicker.js +39 -11
  40. package/esm/components/DndContainer.js +1 -1
  41. package/esm/components/Drawer.js +3 -2
  42. package/esm/components/DropDownSelection.d.ts +40 -40
  43. package/esm/components/DropDownSelection.js +1 -1
  44. package/esm/components/Editor.js +1 -1
  45. package/esm/components/Form.js +1 -1
  46. package/esm/components/FormField.js +1 -1
  47. package/esm/components/GaodeMapPicker.js +1 -1
  48. package/esm/components/GridNav.js +1 -1
  49. package/esm/components/GroupedSelection.d.ts +40 -40
  50. package/esm/components/GroupedSelection.js +1 -1
  51. package/esm/components/Html.js +1 -1
  52. package/esm/components/ImageGallery.js +1 -1
  53. package/esm/components/Input.js +1 -1
  54. package/esm/components/InputBox.d.ts +10 -10
  55. package/esm/components/InputBox.js +1 -1
  56. package/esm/components/InputBoxWithSuggestion.js +1 -1
  57. package/esm/components/InputTable.js +1 -1
  58. package/esm/components/Layout.js +1 -1
  59. package/esm/components/Link.js +1 -1
  60. package/esm/components/ListGroup.d.ts +10 -10
  61. package/esm/components/ListGroup.js +1 -1
  62. package/esm/components/ListMenu.js +1 -1
  63. package/esm/components/LocationPicker.d.ts +84 -40
  64. package/esm/components/LocationPicker.js +7 -6
  65. package/esm/components/Markdown.js +11 -1
  66. package/esm/components/Modal.d.ts +54 -0
  67. package/esm/components/Modal.js +93 -7
  68. package/esm/components/ModalManager.js +1 -1
  69. package/esm/components/MultilineText.js +1 -1
  70. package/esm/components/NumberInput.js +1 -1
  71. package/esm/components/Pagination.d.ts +40 -41
  72. package/esm/components/Pagination.js +9 -18
  73. package/esm/components/Picker.js +1 -1
  74. package/esm/components/PickerColumn.js +1 -1
  75. package/esm/components/PickerContainer.js +1 -1
  76. package/esm/components/PopOverContainer.js +1 -1
  77. package/esm/components/PopUp.js +1 -1
  78. package/esm/components/Progress.js +1 -1
  79. package/esm/components/PullRefresh.js +1 -1
  80. package/esm/components/Radios.js +1 -1
  81. package/esm/components/Range.js +9 -3
  82. package/esm/components/Rating.js +1 -1
  83. package/esm/components/ResultBox.d.ts +40 -40
  84. package/esm/components/ResultBox.js +1 -1
  85. package/esm/components/ResultList.js +1 -1
  86. package/esm/components/ResultTableList.d.ts +40 -40
  87. package/esm/components/ResultTableList.js +1 -1
  88. package/esm/components/ResultTreeList.d.ts +40 -40
  89. package/esm/components/ResultTreeList.js +1 -1
  90. package/esm/components/RichText.js +13 -4
  91. package/esm/components/SearchBox.js +1 -1
  92. package/esm/components/Select.d.ts +4 -0
  93. package/esm/components/Select.js +44 -40
  94. package/esm/components/SelectMobile.js +1 -1
  95. package/esm/components/Selection.d.ts +41 -40
  96. package/esm/components/Selection.js +1 -1
  97. package/esm/components/SparkLine.d.ts +44 -42
  98. package/esm/components/SparkLine.js +4 -4
  99. package/esm/components/Spinner.d.ts +13 -0
  100. package/esm/components/Spinner.js +8 -6
  101. package/esm/components/Steps.js +1 -1
  102. package/esm/components/Switch.d.ts +15 -10
  103. package/esm/components/Switch.js +13 -5
  104. package/esm/components/TableSelection.d.ts +40 -40
  105. package/esm/components/TableSelection.js +1 -1
  106. package/esm/components/Tabs.d.ts +1 -0
  107. package/esm/components/Tabs.js +2 -2
  108. package/esm/components/TabsTransfer.d.ts +40 -40
  109. package/esm/components/TabsTransfer.js +3 -3
  110. package/esm/components/TabsTransferPicker.js +1 -1
  111. package/esm/components/Tag.js +1 -1
  112. package/esm/components/Textarea.js +6 -2
  113. package/esm/components/Timeline.js +1 -1
  114. package/esm/components/TimelineItem.js +1 -1
  115. package/esm/components/Tinymce.d.ts +2 -1
  116. package/esm/components/Tinymce.js +30 -15
  117. package/esm/components/TitleBar.js +1 -1
  118. package/esm/components/Toast.js +1 -1
  119. package/esm/components/Tooltip.js +1 -1
  120. package/esm/components/TooltipWrapper.d.ts +11 -10
  121. package/esm/components/TooltipWrapper.js +1 -1
  122. package/esm/components/Transfer.d.ts +96 -40
  123. package/esm/components/Transfer.js +25 -11
  124. package/esm/components/TransferDropDown.d.ts +40 -40
  125. package/esm/components/TransferDropDown.js +1 -1
  126. package/esm/components/TransferPicker.js +1 -1
  127. package/esm/components/TransferSearch.js +1 -1
  128. package/esm/components/Tree.d.ts +51 -3
  129. package/esm/components/Tree.js +12 -11
  130. package/esm/components/TreeSelection.d.ts +40 -40
  131. package/esm/components/TreeSelection.js +11 -11
  132. package/esm/components/UserSelect.d.ts +42 -0
  133. package/esm/components/UserSelect.js +5 -4
  134. package/esm/components/UserTabSelect.js +1 -1
  135. package/esm/components/WithRemoteConfig.js +14 -2
  136. package/esm/components/WithStore.js +1 -1
  137. package/esm/components/calendar/Calendar.d.ts +9 -1
  138. package/esm/components/calendar/Calendar.js +27 -5
  139. package/esm/components/calendar/CalendarContainer.js +1 -1
  140. package/esm/components/calendar/DaysView.d.ts +11 -0
  141. package/esm/components/calendar/DaysView.js +44 -8
  142. package/esm/components/calendar/MonthsView.d.ts +5 -0
  143. package/esm/components/calendar/MonthsView.js +18 -3
  144. package/esm/components/calendar/QuartersView.js +1 -1
  145. package/esm/components/calendar/TimeView.js +1 -1
  146. package/esm/components/calendar/YearsView.js +1 -1
  147. package/esm/components/condition-builder/Expression.js +1 -1
  148. package/esm/components/condition-builder/Field.js +1 -1
  149. package/esm/components/condition-builder/Func.js +1 -1
  150. package/esm/components/condition-builder/Group.js +1 -1
  151. package/esm/components/condition-builder/GroupOrItem.js +1 -1
  152. package/esm/components/condition-builder/InputSwitch.js +1 -1
  153. package/esm/components/condition-builder/Item.js +6 -2
  154. package/esm/components/condition-builder/Value.js +1 -1
  155. package/esm/components/condition-builder/config.js +7 -1
  156. package/esm/components/condition-builder/index.js +1 -1
  157. package/esm/components/formula/Editor.js +1 -1
  158. package/esm/components/formula/FuncList.js +1 -1
  159. package/esm/components/formula/Input.js +2 -2
  160. package/esm/components/formula/Picker.js +1 -1
  161. package/esm/components/formula/VariableList.js +1 -1
  162. package/esm/components/formula/plugin.js +1 -1
  163. package/esm/components/icons.js +23 -6
  164. package/esm/components/json-schema/Array.js +1 -1
  165. package/esm/components/json-schema/Item.js +1 -1
  166. package/esm/components/json-schema/Object.js +1 -1
  167. package/esm/components/json-schema/index.js +1 -1
  168. package/esm/components/menu/MenuContext.js +1 -1
  169. package/esm/components/menu/MenuItem.js +1 -1
  170. package/esm/components/menu/SubMenu.js +1 -1
  171. package/esm/components/menu/index.d.ts +17 -17
  172. package/esm/components/menu/index.js +5 -4
  173. package/esm/components/schema-editor/Array.js +1 -1
  174. package/esm/components/schema-editor/Common.js +1 -1
  175. package/esm/components/schema-editor/Item.js +1 -1
  176. package/esm/components/schema-editor/Object.js +1 -1
  177. package/esm/components/schema-editor/SchemaVariableList.js +1 -1
  178. package/esm/components/schema-editor/SchemaVariableListPicker.js +1 -1
  179. package/esm/components/schema-editor/index.js +1 -1
  180. package/esm/components/table/Cell.d.ts +3 -455
  181. package/esm/components/table/Cell.js +6 -8
  182. package/esm/components/table/ColGroup.d.ts +8 -3
  183. package/esm/components/table/ColGroup.js +28 -22
  184. package/esm/components/table/Head.d.ts +42 -0
  185. package/esm/components/table/Head.js +142 -0
  186. package/esm/components/table/HeadCellDropDown.d.ts +1 -1
  187. package/esm/components/table/HeadCellDropDown.js +5 -3
  188. package/esm/components/table/HeadCellFilter.d.ts +41 -41
  189. package/esm/components/table/HeadCellFilter.js +2 -2
  190. package/esm/components/table/HeadCellSelect.d.ts +1 -1
  191. package/esm/components/table/HeadCellSelect.js +2 -2
  192. package/esm/components/table/HeadCellSort.d.ts +1 -1
  193. package/esm/components/table/HeadCellSort.js +2 -2
  194. package/esm/components/table/ItemActionsWrapper.d.ts +1 -1
  195. package/esm/components/table/ItemActionsWrapper.js +2 -2
  196. package/esm/components/table/Row.d.ts +60 -0
  197. package/esm/components/table/Row.js +183 -0
  198. package/esm/components/table/SummaryRow.d.ts +28 -0
  199. package/esm/components/table/SummaryRow.js +73 -0
  200. package/esm/components/table/index.d.ts +62 -67
  201. package/esm/components/table/index.js +347 -646
  202. package/esm/components/table/util.d.ts +54 -0
  203. package/esm/components/table/util.js +207 -0
  204. package/esm/components/virtual-list/AutoSizer.js +1 -1
  205. package/esm/components/virtual-list/SizeAndPositionManager.js +1 -1
  206. package/esm/components/virtual-list/constants.js +1 -1
  207. package/esm/components/virtual-list/index.js +1 -1
  208. package/esm/hooks/use-set-state.js +1 -1
  209. package/esm/hooks/use-sub-form.js +1 -1
  210. package/esm/hooks/use-touch.js +1 -1
  211. package/esm/hooks/use-update-effect.js +1 -1
  212. package/esm/hooks/use-validation-resolver.js +1 -1
  213. package/esm/icons/alert-danger.svg.js +1 -1
  214. package/esm/icons/alert-info.svg.js +1 -1
  215. package/esm/icons/alert-success.svg.js +1 -1
  216. package/esm/icons/alert-warning.svg.js +1 -1
  217. package/esm/icons/back.svg.js +1 -1
  218. package/esm/icons/calendar.svg.js +1 -1
  219. package/esm/icons/caret.svg.js +1 -1
  220. package/esm/icons/check.svg.js +1 -1
  221. package/esm/icons/clock.svg.js +1 -1
  222. package/esm/icons/close-small.svg.js +1 -1
  223. package/esm/icons/close.svg.js +1 -1
  224. package/esm/icons/cloud-upload.svg.js +1 -1
  225. package/esm/icons/column-filter.svg.js +1 -1
  226. package/esm/icons/columns.svg.js +1 -1
  227. package/esm/icons/compress-alt.svg.js +1 -1
  228. package/esm/icons/copy.svg.js +1 -1
  229. package/esm/icons/date.svg.js +1 -1
  230. package/esm/icons/department.svg.js +1 -1
  231. package/esm/icons/desk-empty.svg.js +1 -1
  232. package/esm/icons/dot.svg.js +1 -1
  233. package/esm/icons/down-arrow-bold.svg.js +1 -1
  234. package/esm/icons/down.svg.js +1 -1
  235. package/esm/icons/download.svg.js +1 -1
  236. package/esm/icons/drag-bar.svg.js +1 -1
  237. package/esm/icons/drag.svg.js +1 -1
  238. package/esm/icons/edit.svg.js +1 -1
  239. package/esm/icons/ellipsis-v.svg.js +1 -1
  240. package/esm/icons/enter.svg.js +1 -1
  241. package/esm/icons/exchange.svg.js +1 -1
  242. package/esm/icons/expand-alt.svg.js +1 -1
  243. package/esm/icons/fail.svg.js +1 -1
  244. package/esm/icons/file.svg.js +1 -1
  245. package/esm/icons/filter.svg.js +1 -1
  246. package/esm/icons/folder.svg.js +1 -1
  247. package/esm/icons/function.svg.js +1 -1
  248. package/esm/icons/home.svg.js +1 -1
  249. package/esm/icons/if.svg.js +1 -1
  250. package/esm/icons/image.svg.js +1 -1
  251. package/esm/icons/info-circle.svg.js +1 -1
  252. package/esm/icons/info.svg.js +1 -1
  253. package/esm/icons/input-clear.svg.js +1 -1
  254. package/esm/icons/invisible.svg.js +1 -1
  255. package/esm/icons/left-arrow.svg.js +1 -1
  256. package/esm/icons/loading-outline.svg.js +1 -1
  257. package/esm/icons/location.svg.js +1 -1
  258. package/esm/icons/menu.svg.js +1 -1
  259. package/esm/icons/minus.svg.js +1 -1
  260. package/esm/icons/move.svg.js +1 -1
  261. package/esm/icons/mute.svg.js +1 -1
  262. package/esm/icons/new-edit.svg.js +1 -1
  263. package/esm/icons/pause.svg.js +1 -1
  264. package/esm/icons/pencil.svg.js +1 -1
  265. package/esm/icons/play.svg.js +1 -1
  266. package/esm/icons/plus-cicle.svg.js +1 -1
  267. package/esm/icons/plus-fine.svg.js +1 -1
  268. package/esm/icons/plus.svg.js +1 -1
  269. package/esm/icons/post.svg.js +1 -1
  270. package/esm/icons/question-mark.svg.js +1 -1
  271. package/esm/icons/question.svg.js +1 -1
  272. package/esm/icons/redo.svg.js +1 -1
  273. package/esm/icons/refresh.svg.js +1 -1
  274. package/esm/icons/reload.svg.js +1 -1
  275. package/esm/icons/remove.svg.js +1 -1
  276. package/esm/icons/retry.svg.js +1 -1
  277. package/esm/icons/right-arrow-bold.svg.js +1 -1
  278. package/esm/icons/right-arrow.svg.js +1 -1
  279. package/esm/icons/right-double-arrow.svg.js +1 -1
  280. package/esm/icons/role.svg.js +1 -1
  281. package/esm/icons/rotate-left.svg.js +1 -1
  282. package/esm/icons/rotate-right.svg.js +1 -1
  283. package/esm/icons/scale-origin.svg.js +1 -1
  284. package/esm/icons/schedule.svg.js +1 -1
  285. package/esm/icons/search.svg.js +1 -1
  286. package/esm/icons/setting.svg.js +1 -1
  287. package/esm/icons/slider-handle-icon.svg.js +1 -1
  288. package/esm/icons/sort-asc.svg.js +1 -1
  289. package/esm/icons/sort-default.svg.js +1 -1
  290. package/esm/icons/sort-desc.svg.js +1 -1
  291. package/esm/icons/star.svg.js +1 -1
  292. package/esm/icons/status-close.svg.js +1 -1
  293. package/esm/icons/steps-finsh.svg.js +1 -1
  294. package/esm/icons/success.svg.js +1 -1
  295. package/esm/icons/transparent.svg.js +1 -1
  296. package/esm/icons/trash.svg.js +1 -1
  297. package/esm/icons/tree-down.svg.js +1 -1
  298. package/esm/icons/undo.svg.js +1 -1
  299. package/esm/icons/upload.svg.js +1 -1
  300. package/esm/icons/user-remove.svg.js +1 -1
  301. package/esm/icons/view.svg.js +1 -1
  302. package/esm/icons/volume.svg.js +1 -1
  303. package/esm/icons/warning-mark.svg.js +1 -1
  304. package/esm/icons/warning.svg.js +1 -1
  305. package/esm/icons/window-restore.svg.js +1 -1
  306. package/esm/icons/zoom-in.svg.js +1 -1
  307. package/esm/icons/zoom-out.svg.js +1 -1
  308. package/esm/index.js +1 -1
  309. package/esm/locale/de-DE.js +4 -1
  310. package/esm/locale/en-US.js +4 -1
  311. package/esm/locale/zh-CN.js +4 -1
  312. package/esm/themes/ang.js +1 -1
  313. package/esm/themes/antd.js +1 -1
  314. package/esm/themes/cxd.js +1 -1
  315. package/esm/themes/dark.js +1 -1
  316. package/lib/components/404.js +1 -1
  317. package/lib/components/Alert.d.ts +120 -120
  318. package/lib/components/Alert.js +1 -1
  319. package/lib/components/Alert2.d.ts +21 -20
  320. package/lib/components/Alert2.js +3 -2
  321. package/lib/components/AnchorNav.d.ts +20 -20
  322. package/lib/components/AnchorNav.js +1 -1
  323. package/lib/components/ArrayInput.d.ts +40 -40
  324. package/lib/components/ArrayInput.js +1 -1
  325. package/lib/components/AsideNav.js +1 -1
  326. package/lib/components/AssociatedSelection.d.ts +80 -80
  327. package/lib/components/AssociatedSelection.js +7 -7
  328. package/lib/components/Avatar.d.ts +90 -90
  329. package/lib/components/Avatar.js +1 -1
  330. package/lib/components/Badge.js +1 -1
  331. package/lib/components/BaiduMapPicker.d.ts +3 -1
  332. package/lib/components/BaiduMapPicker.js +37 -18
  333. package/lib/components/BarCode.js +1 -1
  334. package/lib/components/Breadcrumb.js +1 -1
  335. package/lib/components/Button.d.ts +20 -20
  336. package/lib/components/Button.js +1 -1
  337. package/lib/components/CalendarMobile.d.ts +40 -40
  338. package/lib/components/CalendarMobile.js +1 -1
  339. package/lib/components/Card.d.ts +100 -100
  340. package/lib/components/Card.js +1 -1
  341. package/lib/components/Cascader.js +1 -1
  342. package/lib/components/ChainedDropdownSelection.d.ts +80 -80
  343. package/lib/components/ChainedDropdownSelection.js +1 -1
  344. package/lib/components/ChainedSelection.d.ts +80 -80
  345. package/lib/components/ChainedSelection.js +6 -6
  346. package/lib/components/Checkbox.d.ts +10 -10
  347. package/lib/components/Checkbox.js +1 -1
  348. package/lib/components/CityArea.js +1 -1
  349. package/lib/components/CityDB.js +1 -1
  350. package/lib/components/CodeMirror.js +1 -1
  351. package/lib/components/Collapse.d.ts +120 -120
  352. package/lib/components/Collapse.js +1 -1
  353. package/lib/components/CollapseGroup.d.ts +20 -20
  354. package/lib/components/CollapseGroup.js +1 -1
  355. package/lib/components/ColorPicker.d.ts +40 -40
  356. package/lib/components/ColorPicker.js +1 -1
  357. package/lib/components/Combo.js +1 -1
  358. package/lib/components/ConfirmBox.d.ts +80 -80
  359. package/lib/components/ConfirmBox.js +1 -1
  360. package/lib/components/ContextMenu.js +1 -1
  361. package/lib/components/DatePicker.d.ts +132 -121
  362. package/lib/components/DatePicker.js +112 -25
  363. package/lib/components/DateRangePicker.d.ts +338 -330
  364. package/lib/components/DateRangePicker.js +39 -11
  365. package/lib/components/DndContainer.js +1 -1
  366. package/lib/components/Drawer.d.ts +30 -30
  367. package/lib/components/Drawer.js +3 -2
  368. package/lib/components/DropDownSelection.d.ts +80 -80
  369. package/lib/components/DropDownSelection.js +1 -1
  370. package/lib/components/Editor.d.ts +120 -120
  371. package/lib/components/Editor.js +1 -1
  372. package/lib/components/Form.js +1 -1
  373. package/lib/components/FormField.js +1 -1
  374. package/lib/components/GaodeMapPicker.js +1 -1
  375. package/lib/components/GridNav.js +1 -1
  376. package/lib/components/GroupedSelection.d.ts +80 -80
  377. package/lib/components/GroupedSelection.js +1 -1
  378. package/lib/components/Html.js +1 -1
  379. package/lib/components/ImageGallery.d.ts +40 -40
  380. package/lib/components/ImageGallery.js +1 -1
  381. package/lib/components/Input.js +1 -1
  382. package/lib/components/InputBox.d.ts +10 -10
  383. package/lib/components/InputBox.js +1 -1
  384. package/lib/components/InputBoxWithSuggestion.js +1 -1
  385. package/lib/components/InputTable.js +1 -1
  386. package/lib/components/Layout.d.ts +10 -10
  387. package/lib/components/Layout.js +1 -1
  388. package/lib/components/Link.js +1 -1
  389. package/lib/components/ListGroup.d.ts +10 -10
  390. package/lib/components/ListGroup.js +1 -1
  391. package/lib/components/ListMenu.d.ts +80 -80
  392. package/lib/components/ListMenu.js +1 -1
  393. package/lib/components/LocationPicker.d.ts +84 -40
  394. package/lib/components/LocationPicker.js +7 -6
  395. package/lib/components/Markdown.js +11 -1
  396. package/lib/components/Modal.d.ts +134 -80
  397. package/lib/components/Modal.js +93 -5
  398. package/lib/components/ModalManager.js +1 -1
  399. package/lib/components/MonthRangePicker.d.ts +160 -160
  400. package/lib/components/MultilineText.d.ts +40 -40
  401. package/lib/components/MultilineText.js +1 -1
  402. package/lib/components/NumberInput.d.ts +30 -30
  403. package/lib/components/NumberInput.js +1 -1
  404. package/lib/components/Pagination.d.ts +80 -81
  405. package/lib/components/Pagination.js +8 -17
  406. package/lib/components/Picker.js +1 -1
  407. package/lib/components/PickerColumn.js +1 -1
  408. package/lib/components/PickerContainer.js +1 -1
  409. package/lib/components/PopOverContainer.js +1 -1
  410. package/lib/components/PopUp.d.ts +80 -80
  411. package/lib/components/PopUp.js +1 -1
  412. package/lib/components/Progress.d.ts +60 -60
  413. package/lib/components/Progress.js +1 -1
  414. package/lib/components/PullRefresh.js +1 -1
  415. package/lib/components/Radios.d.ts +40 -40
  416. package/lib/components/Radios.js +1 -1
  417. package/lib/components/Range.js +9 -3
  418. package/lib/components/Rating.d.ts +20 -20
  419. package/lib/components/Rating.js +1 -1
  420. package/lib/components/ResultBox.d.ts +80 -80
  421. package/lib/components/ResultBox.js +1 -1
  422. package/lib/components/ResultList.d.ts +40 -40
  423. package/lib/components/ResultList.js +1 -1
  424. package/lib/components/ResultTableList.d.ts +80 -80
  425. package/lib/components/ResultTableList.js +1 -1
  426. package/lib/components/ResultTreeList.d.ts +40 -40
  427. package/lib/components/ResultTreeList.js +1 -1
  428. package/lib/components/RichText.js +13 -4
  429. package/lib/components/SearchBox.d.ts +120 -120
  430. package/lib/components/SearchBox.js +1 -1
  431. package/lib/components/Select.d.ts +1741 -1738
  432. package/lib/components/Select.js +44 -40
  433. package/lib/components/SelectMobile.js +1 -1
  434. package/lib/components/Selection.d.ts +81 -80
  435. package/lib/components/Selection.js +1 -1
  436. package/lib/components/SparkLine.d.ts +44 -42
  437. package/lib/components/SparkLine.js +3 -3
  438. package/lib/components/Spinner.d.ts +73 -60
  439. package/lib/components/Spinner.js +8 -6
  440. package/lib/components/Steps.js +1 -1
  441. package/lib/components/Switch.d.ts +15 -10
  442. package/lib/components/Switch.js +13 -5
  443. package/lib/components/TableSelection.d.ts +80 -80
  444. package/lib/components/TableSelection.js +1 -1
  445. package/lib/components/Tabs.d.ts +81 -80
  446. package/lib/components/Tabs.js +2 -2
  447. package/lib/components/TabsTransfer.d.ts +40 -40
  448. package/lib/components/TabsTransfer.js +3 -3
  449. package/lib/components/TabsTransferPicker.js +1 -1
  450. package/lib/components/Tag.d.ts +60 -60
  451. package/lib/components/Tag.js +1 -1
  452. package/lib/components/Textarea.d.ts +40 -40
  453. package/lib/components/Textarea.js +6 -2
  454. package/lib/components/Timeline.js +1 -1
  455. package/lib/components/TimelineItem.js +1 -1
  456. package/lib/components/Tinymce.d.ts +2 -1
  457. package/lib/components/Tinymce.js +29 -14
  458. package/lib/components/TitleBar.d.ts +10 -10
  459. package/lib/components/TitleBar.js +1 -1
  460. package/lib/components/Toast.d.ts +80 -80
  461. package/lib/components/Toast.js +1 -1
  462. package/lib/components/Tooltip.js +1 -1
  463. package/lib/components/TooltipWrapper.d.ts +31 -30
  464. package/lib/components/TooltipWrapper.js +1 -1
  465. package/lib/components/Transfer.d.ts +225 -169
  466. package/lib/components/Transfer.js +25 -11
  467. package/lib/components/TransferDropDown.d.ts +160 -160
  468. package/lib/components/TransferDropDown.js +1 -1
  469. package/lib/components/TransferPicker.js +1 -1
  470. package/lib/components/TransferSearch.js +1 -1
  471. package/lib/components/Tree.d.ts +291 -243
  472. package/lib/components/Tree.js +12 -11
  473. package/lib/components/TreeSelection.d.ts +120 -120
  474. package/lib/components/TreeSelection.js +11 -11
  475. package/lib/components/UserSelect.d.ts +82 -40
  476. package/lib/components/UserSelect.js +5 -4
  477. package/lib/components/UserTabSelect.d.ts +40 -40
  478. package/lib/components/UserTabSelect.js +1 -1
  479. package/lib/components/WithRemoteConfig.d.ts +0 -1
  480. package/lib/components/WithRemoteConfig.js +14 -2
  481. package/lib/components/WithStore.js +1 -1
  482. package/lib/components/calendar/Calendar.d.ts +9 -1
  483. package/lib/components/calendar/Calendar.js +27 -5
  484. package/lib/components/calendar/CalendarContainer.js +1 -1
  485. package/lib/components/calendar/DaysView.d.ts +11 -0
  486. package/lib/components/calendar/DaysView.js +44 -8
  487. package/lib/components/calendar/MonthsView.d.ts +5 -0
  488. package/lib/components/calendar/MonthsView.js +18 -3
  489. package/lib/components/calendar/QuartersView.js +1 -1
  490. package/lib/components/calendar/TimeView.js +1 -1
  491. package/lib/components/calendar/YearsView.js +1 -1
  492. package/lib/components/condition-builder/Expression.js +1 -1
  493. package/lib/components/condition-builder/Field.js +1 -1
  494. package/lib/components/condition-builder/Func.js +1 -1
  495. package/lib/components/condition-builder/Group.js +1 -1
  496. package/lib/components/condition-builder/GroupOrItem.js +1 -1
  497. package/lib/components/condition-builder/InputSwitch.js +1 -1
  498. package/lib/components/condition-builder/Item.js +6 -2
  499. package/lib/components/condition-builder/Value.js +1 -1
  500. package/lib/components/condition-builder/config.js +7 -1
  501. package/lib/components/condition-builder/index.d.ts +1 -1
  502. package/lib/components/condition-builder/index.js +1 -1
  503. package/lib/components/formula/Editor.d.ts +40 -40
  504. package/lib/components/formula/Editor.js +1 -1
  505. package/lib/components/formula/FuncList.js +1 -1
  506. package/lib/components/formula/Input.js +2 -2
  507. package/lib/components/formula/Picker.d.ts +40 -40
  508. package/lib/components/formula/Picker.js +1 -1
  509. package/lib/components/formula/VariableList.js +1 -1
  510. package/lib/components/formula/plugin.js +1 -1
  511. package/lib/components/icons.js +22 -5
  512. package/lib/components/json-schema/Array.js +1 -1
  513. package/lib/components/json-schema/Item.js +1 -1
  514. package/lib/components/json-schema/Object.js +1 -1
  515. package/lib/components/json-schema/index.js +1 -1
  516. package/lib/components/menu/MenuContext.js +1 -1
  517. package/lib/components/menu/MenuItem.js +1 -1
  518. package/lib/components/menu/SubMenu.js +1 -1
  519. package/lib/components/menu/index.d.ts +77 -77
  520. package/lib/components/menu/index.js +5 -5
  521. package/lib/components/schema-editor/Array.js +1 -1
  522. package/lib/components/schema-editor/Common.js +1 -1
  523. package/lib/components/schema-editor/Item.js +1 -1
  524. package/lib/components/schema-editor/Object.js +1 -1
  525. package/lib/components/schema-editor/SchemaVariableList.js +1 -1
  526. package/lib/components/schema-editor/SchemaVariableListPicker.js +1 -1
  527. package/lib/components/schema-editor/index.d.ts +40 -40
  528. package/lib/components/schema-editor/index.js +1 -1
  529. package/lib/components/table/Cell.d.ts +3 -455
  530. package/lib/components/table/Cell.js +6 -9
  531. package/lib/components/table/ColGroup.d.ts +8 -3
  532. package/lib/components/table/ColGroup.js +28 -23
  533. package/lib/components/table/Head.d.ts +42 -0
  534. package/lib/components/table/Head.js +149 -0
  535. package/lib/components/table/HeadCellDropDown.d.ts +1 -1
  536. package/lib/components/table/HeadCellDropDown.js +5 -3
  537. package/lib/components/table/HeadCellFilter.d.ts +81 -81
  538. package/lib/components/table/HeadCellFilter.js +2 -2
  539. package/lib/components/table/HeadCellSelect.d.ts +41 -41
  540. package/lib/components/table/HeadCellSelect.js +2 -2
  541. package/lib/components/table/HeadCellSort.d.ts +1 -1
  542. package/lib/components/table/HeadCellSort.js +2 -2
  543. package/lib/components/table/ItemActionsWrapper.d.ts +1 -1
  544. package/lib/components/table/ItemActionsWrapper.js +2 -2
  545. package/lib/components/table/Row.d.ts +60 -0
  546. package/lib/components/table/Row.js +190 -0
  547. package/lib/components/table/SummaryRow.d.ts +28 -0
  548. package/lib/components/table/SummaryRow.js +81 -0
  549. package/lib/components/table/index.d.ts +62 -67
  550. package/lib/components/table/index.js +344 -644
  551. package/lib/components/table/util.d.ts +54 -0
  552. package/lib/components/table/util.js +227 -0
  553. package/lib/components/virtual-list/AutoSizer.js +1 -1
  554. package/lib/components/virtual-list/SizeAndPositionManager.js +1 -1
  555. package/lib/components/virtual-list/constants.js +1 -1
  556. package/lib/components/virtual-list/index.js +1 -1
  557. package/lib/hooks/use-set-state.js +1 -1
  558. package/lib/hooks/use-sub-form.js +1 -1
  559. package/lib/hooks/use-touch.js +1 -1
  560. package/lib/hooks/use-update-effect.js +1 -1
  561. package/lib/hooks/use-validation-resolver.js +1 -1
  562. package/lib/icons/alert-danger.svg.js +1 -1
  563. package/lib/icons/alert-info.svg.js +1 -1
  564. package/lib/icons/alert-success.svg.js +1 -1
  565. package/lib/icons/alert-warning.svg.js +1 -1
  566. package/lib/icons/back.svg.js +1 -1
  567. package/lib/icons/calendar.svg.js +1 -1
  568. package/lib/icons/caret.svg.js +1 -1
  569. package/lib/icons/check.svg.js +1 -1
  570. package/lib/icons/clock.svg.js +1 -1
  571. package/lib/icons/close-small.svg.js +1 -1
  572. package/lib/icons/close.svg.js +1 -1
  573. package/lib/icons/cloud-upload.svg.js +1 -1
  574. package/lib/icons/column-filter.svg.js +1 -1
  575. package/lib/icons/columns.svg.js +1 -1
  576. package/lib/icons/compress-alt.svg.js +1 -1
  577. package/lib/icons/copy.svg.js +1 -1
  578. package/lib/icons/date.svg.js +1 -1
  579. package/lib/icons/department.svg.js +1 -1
  580. package/lib/icons/desk-empty.svg.js +1 -1
  581. package/lib/icons/dot.svg.js +1 -1
  582. package/lib/icons/down-arrow-bold.svg.js +1 -1
  583. package/lib/icons/down.svg.js +1 -1
  584. package/lib/icons/download.svg.js +1 -1
  585. package/lib/icons/drag-bar.svg.js +1 -1
  586. package/lib/icons/drag.svg.js +1 -1
  587. package/lib/icons/edit.svg.js +1 -1
  588. package/lib/icons/ellipsis-v.svg.js +1 -1
  589. package/lib/icons/enter.svg.js +1 -1
  590. package/lib/icons/exchange.svg.js +1 -1
  591. package/lib/icons/expand-alt.svg.js +1 -1
  592. package/lib/icons/fail.svg.js +1 -1
  593. package/lib/icons/file.svg.js +1 -1
  594. package/lib/icons/filter.svg.js +1 -1
  595. package/lib/icons/folder.svg.js +1 -1
  596. package/lib/icons/function.svg.js +1 -1
  597. package/lib/icons/home.svg.js +1 -1
  598. package/lib/icons/if.svg.js +1 -1
  599. package/lib/icons/image.svg.js +1 -1
  600. package/lib/icons/info-circle.svg.js +1 -1
  601. package/lib/icons/info.svg.js +1 -1
  602. package/lib/icons/input-clear.svg.js +1 -1
  603. package/lib/icons/invisible.svg.js +1 -1
  604. package/lib/icons/left-arrow.svg.js +1 -1
  605. package/lib/icons/loading-outline.svg.js +1 -1
  606. package/lib/icons/location.svg.js +1 -1
  607. package/lib/icons/menu.svg.js +1 -1
  608. package/lib/icons/minus.svg.js +1 -1
  609. package/lib/icons/move.svg.js +1 -1
  610. package/lib/icons/mute.svg.js +1 -1
  611. package/lib/icons/new-edit.svg.js +1 -1
  612. package/lib/icons/pause.svg.js +1 -1
  613. package/lib/icons/pencil.svg.js +1 -1
  614. package/lib/icons/play.svg.js +1 -1
  615. package/lib/icons/plus-cicle.svg.js +1 -1
  616. package/lib/icons/plus-fine.svg.js +1 -1
  617. package/lib/icons/plus.svg.js +1 -1
  618. package/lib/icons/post.svg.js +1 -1
  619. package/lib/icons/question-mark.svg.js +1 -1
  620. package/lib/icons/question.svg.js +1 -1
  621. package/lib/icons/redo.svg.js +1 -1
  622. package/lib/icons/refresh.svg.js +1 -1
  623. package/lib/icons/reload.svg.js +1 -1
  624. package/lib/icons/remove.svg.js +1 -1
  625. package/lib/icons/retry.svg.js +1 -1
  626. package/lib/icons/right-arrow-bold.svg.js +1 -1
  627. package/lib/icons/right-arrow.svg.js +1 -1
  628. package/lib/icons/right-double-arrow.svg.js +1 -1
  629. package/lib/icons/role.svg.js +1 -1
  630. package/lib/icons/rotate-left.svg.js +1 -1
  631. package/lib/icons/rotate-right.svg.js +1 -1
  632. package/lib/icons/scale-origin.svg.js +1 -1
  633. package/lib/icons/schedule.svg.js +1 -1
  634. package/lib/icons/search.svg.js +1 -1
  635. package/lib/icons/setting.svg.js +1 -1
  636. package/lib/icons/slider-handle-icon.svg.js +1 -1
  637. package/lib/icons/sort-asc.svg.js +1 -1
  638. package/lib/icons/sort-default.svg.js +1 -1
  639. package/lib/icons/sort-desc.svg.js +1 -1
  640. package/lib/icons/star.svg.js +1 -1
  641. package/lib/icons/status-close.svg.js +1 -1
  642. package/lib/icons/steps-finsh.svg.js +1 -1
  643. package/lib/icons/success.svg.js +1 -1
  644. package/lib/icons/transparent.svg.js +1 -1
  645. package/lib/icons/trash.svg.js +1 -1
  646. package/lib/icons/tree-down.svg.js +1 -1
  647. package/lib/icons/undo.svg.js +1 -1
  648. package/lib/icons/upload.svg.js +1 -1
  649. package/lib/icons/user-remove.svg.js +1 -1
  650. package/lib/icons/view.svg.js +1 -1
  651. package/lib/icons/volume.svg.js +1 -1
  652. package/lib/icons/warning-mark.svg.js +1 -1
  653. package/lib/icons/warning.svg.js +1 -1
  654. package/lib/icons/window-restore.svg.js +1 -1
  655. package/lib/icons/zoom-in.svg.js +1 -1
  656. package/lib/icons/zoom-out.svg.js +1 -1
  657. package/lib/index.js +1 -1
  658. package/lib/locale/de-DE.js +4 -1
  659. package/lib/locale/en-US.js +4 -1
  660. package/lib/locale/zh-CN.js +4 -1
  661. package/lib/scss/helper.scss.js +1 -1
  662. package/lib/scss/themes/ang.scss.js +1 -1
  663. package/lib/scss/themes/antd.scss.js +1 -1
  664. package/lib/scss/themes/cxd.scss.js +1 -1
  665. package/lib/scss/themes/dark.scss.js +1 -1
  666. package/lib/scss/themes/default.scss.js +1 -1
  667. package/lib/themes/ang.css +220 -69
  668. package/lib/themes/ang.js +1 -1
  669. package/lib/themes/antd.css +222 -71
  670. package/lib/themes/antd.js +1 -1
  671. package/lib/themes/cxd.css +220 -69
  672. package/lib/themes/cxd.js +1 -1
  673. package/lib/themes/dark.css +220 -69
  674. package/lib/themes/dark.js +1 -1
  675. package/lib/themes/default.css +220 -69
  676. package/package.json +5 -6
  677. package/scss/_components.scss +22 -14
  678. package/scss/_properties.scss +7 -11
  679. package/scss/base/_common.scss +8 -0
  680. package/scss/components/_alert.scss +4 -0
  681. package/scss/components/_audio.scss +1 -1
  682. package/scss/components/_card.scss +2 -1
  683. package/scss/components/_dropdown.scss +4 -2
  684. package/scss/components/_menu.scss +7 -2
  685. package/scss/components/_modal.scss +4 -0
  686. package/scss/components/_page.scss +6 -6
  687. package/scss/components/_pagination.scss +41 -44
  688. package/scss/components/_progress.scss +1 -1
  689. package/scss/components/_spinner.scss +12 -0
  690. package/scss/components/_steps.scss +7 -5
  691. package/scss/components/_table.scss +16 -2
  692. package/scss/components/_table2.scss +7 -0
  693. package/scss/components/_tabs.scss +21 -24
  694. package/scss/components/form/_combo.scss +6 -0
  695. package/scss/components/form/_date-range.scss +3 -6
  696. package/scss/components/form/_date.scss +3 -5
  697. package/scss/components/form/_excel.scss +2 -2
  698. package/scss/components/form/_fieldset.scss +1 -1
  699. package/scss/components/form/_form.scss +2 -0
  700. package/scss/components/form/_location.scss +19 -1
  701. package/scss/components/form/_nested-select.scss +20 -7
  702. package/scss/components/form/_picker.scss +3 -1
  703. package/scss/components/form/_range.scss +2 -2
  704. package/scss/components/form/_rating.scss +17 -3
  705. package/scss/components/form/_select.scss +0 -11
  706. package/scss/components/form/_selection.scss +2 -1
  707. package/scss/components/form/_switch.scss +38 -0
  708. package/scss/components/form/_text.scss +9 -8
  709. package/scss/components/form/_textarea.scss +4 -0
  710. package/scss/components/form/_transfer.scss +40 -0
  711. package/scss/themes/_ang-variables.scss +63 -61
  712. package/scss/themes/_antd-variables.scss +63 -61
  713. package/scss/themes/_cxd-variables.scss +64 -61
  714. package/scss/themes/_dark-variables.scss +63 -61
@@ -1,158 +1,50 @@
1
1
  /**
2
- * amis-ui v3.5.2
2
+ * amis-ui v3.6.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
- import { __extends, __spreadArray, __read, __awaiter, __generator, __assign, __decorate, __metadata, __rest } from 'tslib';
6
+ import { __extends, __spreadArray, __read, __awaiter, __generator, __assign, __decorate, __metadata } from 'tslib';
7
7
  import React__default from 'react';
8
8
  import { findDOMNode } from 'react-dom';
9
- import findLastIndex from 'lodash/findLastIndex';
10
9
  import find from 'lodash/find';
11
10
  import isEqual from 'lodash/isEqual';
12
- import filter from 'lodash/filter';
13
11
  import debounce from 'lodash/debounce';
14
12
  import intersection from 'lodash/intersection';
15
13
  import Sortable from 'sortablejs';
16
- import { resizeSensor, isObject, isBreakpoint, autobind, themeable, localeable, guid } from 'amis-core';
17
- import { Icon } from '../icons.js';
18
- import Checkbox from '../Checkbox.js';
14
+ import { resizeSensor, offset, getScrollParent, position, getStyleNumber, isObject, autobind, themeable, localeable } from 'amis-core';
19
15
  import Spinner from '../Spinner.js';
20
- import HeadCellSort from './HeadCellSort.js';
21
- import HeadCellFilter from './HeadCellFilter.js';
22
- import HeadCellSelect from './HeadCellSelect.js';
23
16
  import ItemActionsWrapper from './ItemActionsWrapper.js';
24
- import Cell from './Cell.js';
17
+ import BodyCell from './Cell.js';
25
18
  import ColGroup from './ColGroup.js';
19
+ import BodyRow from './Row.js';
20
+ import Head from './Head.js';
21
+ import SummaryRows from './SummaryRow.js';
22
+ import { getSelectedRows, levelsSplit, getDataChildrenKeys, checkChildrenRow, getBuildColumns } from './util.js';
26
23
 
27
24
  /**
28
25
  * @file Table
29
26
  * @author fex
30
27
  */
31
- function getMaxLevelThRowSpan(columns) {
32
- var maxLevel = 0;
33
- Array.isArray(columns) &&
34
- columns.forEach(function (c) {
35
- var level = getThRowSpan(c);
36
- if (maxLevel < level) {
37
- maxLevel = level;
38
- }
39
- });
40
- return maxLevel;
41
- }
42
- function getThRowSpan(column) {
43
- if (!column.children || (column.children && !column.children.length)) {
44
- return 1;
45
- }
46
- return 1 + getMaxLevelThRowSpan(column.children);
47
- }
48
- function getThColSpan(column) {
49
- if (!column.children || (column.children && !column.children.length)) {
50
- return 1;
51
- }
52
- var childrenLength = 0;
53
- column.children.forEach(function (item) { return (childrenLength += getThColSpan(item)); });
54
- return childrenLength;
55
- }
56
- function buildColumns(columns, thColumns, tdColumns, maxLevel, depth, id, fixed) {
57
- if (columns === void 0) { columns = []; }
58
- if (tdColumns === void 0) { tdColumns = []; }
59
- if (depth === void 0) { depth = 0; }
60
- // 在处理表头时,如果父级column设置了fixed属性,那么所有children保持一致
61
- Array.isArray(columns) &&
62
- columns.forEach(function (column) {
63
- var groupId = id || guid();
64
- var childMaxLevel = 0;
65
- if (column.children) {
66
- childMaxLevel = getMaxLevelThRowSpan(column.children);
67
- }
68
- var newColumn = __assign(__assign({}, column), { rowSpan: childMaxLevel ? 1 : maxLevel - depth, colSpan: getThColSpan(column), groupId: groupId, depth: depth });
69
- var tdColumn = __assign(__assign({}, column), { groupId: groupId });
70
- if (fixed) {
71
- newColumn.fixed = fixed;
72
- tdColumn.fixed = fixed;
73
- }
74
- if (!thColumns[depth]) {
75
- thColumns[depth] = [];
76
- }
77
- thColumns[depth].push(newColumn);
78
- if (column.children && column.children.length > 0) {
79
- buildColumns(column.children, thColumns, tdColumns, maxLevel, depth + 1, groupId, column.fixed);
80
- }
81
- else {
82
- tdColumn.children; var rest = __rest(tdColumn, ["children"]);
83
- tdColumns.push(rest);
84
- }
85
- });
86
- }
87
- function isFixedLeftColumn(fixed) {
88
- return fixed === true || fixed === 'left';
89
- }
90
- function isFixedRightColumn(fixed) {
91
- return fixed === 'right';
92
- }
93
- function getPreviousLeftWidth(doms, index, columns) {
94
- var width = 0;
95
- for (var i = 0; i < index; i++) {
96
- if (columns && columns[i] && isFixedLeftColumn(columns[i].fixed)) {
97
- var dom = doms[i];
98
- width += dom.offsetWidth;
99
- }
100
- }
101
- return width;
102
- }
103
- function getAfterRightWidth(doms, index, columns) {
104
- var width = 0;
105
- for (var i = doms.length - 0; i > index; i--) {
106
- if (columns && columns[i] && isFixedRightColumn(columns[i].fixed)) {
107
- var dom = doms[i];
108
- width += dom.offsetWidth;
109
- }
110
- }
111
- return width;
112
- }
113
- function hasFixedColumn(columns) {
114
- return find(columns, function (column) { return column.fixed; });
115
- }
116
- function getSummaryColumns(summary) {
117
- if (!summary) {
118
- return [];
119
- }
120
- var last = [];
121
- var first = [];
122
- summary.forEach(function (item) {
123
- if (isObject(item)) {
124
- first.push(item);
125
- }
126
- else if (Array.isArray(item)) {
127
- last.push(item);
128
- }
129
- });
130
- return __spreadArray([first], __read(last), false);
131
- }
132
28
  var DefaultCellWidth = 40;
133
29
  var Table = /** @class */ (function (_super) {
134
30
  __extends(Table, _super);
135
31
  function Table(props) {
136
- var _this = this;
137
- var _a;
138
- _this = _super.call(this, props) || this;
32
+ var _this = _super.call(this, props) || this;
139
33
  _this.tableDom = React__default.createRef();
140
- _this.theadDom = React__default.createRef();
141
34
  _this.tbodyDom = React__default.createRef();
142
35
  _this.contentDom = React__default.createRef();
143
36
  _this.headerDom = React__default.createRef();
144
- _this.tfootDom = React__default.createRef();
145
37
  _this.footDom = React__default.createRef();
38
+ _this.containerDom = React__default.createRef();
146
39
  _this.toDispose = [];
147
40
  _this.updateTableInfoLazy = debounce(_this.updateTableInfo.bind(_this), 250, {
148
41
  trailing: true,
149
42
  leading: false
150
43
  });
151
- if (props.rowSelection) {
152
- var selectedResult = _this.getSelectedRows(props.dataSource, (_a = props.rowSelection) === null || _a === void 0 ? void 0 : _a.selectedRowKeys);
153
- _this.selectedRows = selectedResult.selectedRows;
154
- _this.unSelectedRows = selectedResult.unSelectedRows;
155
- }
44
+ _this.updateAutoFillHeightLazy = debounce(_this.updateAutoFillHeight.bind(_this), 250, {
45
+ trailing: true,
46
+ leading: false
47
+ });
156
48
  _this.state = {
157
49
  selectedRowKeys: props.rowSelection
158
50
  ? props.rowSelection.selectedRowKeys.map(function (key) { return key; }) || []
@@ -169,46 +61,6 @@ var Table = /** @class */ (function (_super) {
169
61
  Table.prototype.getPopOverContainer = function () {
170
62
  return findDOMNode(this);
171
63
  };
172
- Table.prototype.getSelectedRows = function (dataSource, selectedRowKeys) {
173
- var _this = this;
174
- var selectedRows = [];
175
- var unSelectedRows = [];
176
- dataSource.forEach(function (data) {
177
- if (find(selectedRowKeys, function (key) { return key === data[_this.getRowSelectionKeyField()]; })) {
178
- selectedRows.push(data);
179
- }
180
- else {
181
- unSelectedRows.push(data);
182
- }
183
- });
184
- return { selectedRows: selectedRows, unSelectedRows: unSelectedRows };
185
- };
186
- Table.prototype.updateTableBodyFixed = function () {
187
- var tbodyDom = this.tbodyDom && this.tbodyDom.current;
188
- var tdColumns = __spreadArray([], __read(this.tdColumns), false);
189
- if (!tbodyDom) {
190
- return;
191
- }
192
- this.updateTbodyFixedRow(tbodyDom, tdColumns);
193
- this.updateHeadSummaryFixedRow(tbodyDom);
194
- };
195
- Table.prototype.updateTableFixedRows = function () {
196
- if (hasFixedColumn(this.props.columns)) {
197
- var headerDom = this.headerDom && this.headerDom.current;
198
- if (headerDom) {
199
- var headerBody = headerDom.getElementsByTagName('tbody');
200
- headerBody &&
201
- headerBody[0] &&
202
- this.updateHeadSummaryFixedRow(headerBody[0]);
203
- }
204
- var tfootDom = this.tfootDom && this.tfootDom.current;
205
- tfootDom && this.updateFootSummaryFixedRow(tfootDom);
206
- var theadDom = this.theadDom && this.theadDom.current;
207
- var thColumns = this.thColumns;
208
- this.updateTheadFixedRow(theadDom, thColumns);
209
- this.updateTableBodyFixed();
210
- }
211
- };
212
64
  Table.prototype.componentDidMount = function () {
213
65
  var _this = this;
214
66
  var _a, _b, _c, _d, _e;
@@ -216,9 +68,7 @@ var Table = /** @class */ (function (_super) {
216
68
  if (this.props.loading) {
217
69
  return;
218
70
  }
219
- this.updateTableFixedRows();
220
- var current = (_c = this.contentDom) === null || _c === void 0 ? void 0 : _c.current;
221
- if ((_d = this.headerDom) === null || _d === void 0 ? void 0 : _d.current) {
71
+ if ((_c = this.headerDom) === null || _c === void 0 ? void 0 : _c.current) {
222
72
  // overflow设置为hidden的情况
223
73
  var hiddenDomRefs = [this.headerDom, this.footDom];
224
74
  hiddenDomRefs.forEach(function (ref) {
@@ -227,40 +77,43 @@ var Table = /** @class */ (function (_super) {
227
77
  ref.current.addEventListener('wheel', _this.onWheel.bind(_this));
228
78
  });
229
79
  }
80
+ var current = (_d = this.contentDom) === null || _d === void 0 ? void 0 : _d.current;
230
81
  current && this.updateTableDom(current);
231
82
  if (this.props.draggable && ((_e = this.tbodyDom) === null || _e === void 0 ? void 0 : _e.current)) {
232
83
  this.initDragging();
233
84
  }
234
85
  this.updateStickyHeader();
235
86
  var currentNode = findDOMNode(this);
87
+ if (this.props.autoFillHeight) {
88
+ this.toDispose.push(resizeSensor(currentNode.parentElement, this.updateAutoFillHeightLazy, false, 'height'));
89
+ this.updateAutoFillHeight();
90
+ }
236
91
  this.toDispose.push(resizeSensor(currentNode, this.updateTableInfoLazy, false, 'width'));
237
92
  };
238
93
  Table.prototype.componentDidUpdate = function (prevProps, prevState) {
239
94
  var _this = this;
240
95
  var _a, _b, _c, _d;
241
- // 数据源发生了变化
242
- // 异步加载数据需求再更新一次
243
- // 翻页
244
96
  if (!isEqual(prevProps.dataSource, this.props.dataSource)) {
245
97
  this.setState({
246
98
  dataSource: __spreadArray([], __read(this.props.dataSource), false)
247
- }, function () {
248
- _this.updateTableFixedRows();
249
99
  });
250
100
  }
101
+ if (prevProps.autoFillHeight !== this.props.autoFillHeight ||
102
+ ((!isEqual(prevState.dataSource, this.state.dataSource) ||
103
+ prevProps.loading !== this.props.loading) &&
104
+ this.props.autoFillHeight)) {
105
+ this.updateAutoFillHeight();
106
+ }
251
107
  // 选择项发生了变化触发
252
108
  if (!isEqual(prevState.selectedRowKeys, this.state.selectedRowKeys)) {
109
+ var rowSelectionKeyField = this.getRowSelectionKeyField();
110
+ var childrenColumnName = this.getChildrenColumnName();
253
111
  // 更新保存的已选择行数据
254
- var selectedResult = this.getSelectedRows(this.state.dataSource, this.state.selectedRowKeys);
255
- this.selectedRows = selectedResult.selectedRows;
256
- this.unSelectedRows = selectedResult.unSelectedRows;
112
+ var selectedResult = getSelectedRows(this.state.dataSource, this.state.selectedRowKeys, rowSelectionKeyField, childrenColumnName);
257
113
  var rowSelection = this.props.rowSelection;
258
114
  rowSelection &&
259
115
  rowSelection.onChange &&
260
- rowSelection.onChange(this.state.selectedRowKeys, this.selectedRows);
261
- this.setState({
262
- selectedRowKeys: this.state.selectedRowKeys.filter(function (key, i, a) { return a.indexOf(key) === i; })
263
- });
116
+ rowSelection.onChange(this.state.selectedRowKeys, selectedResult.selectedRows);
264
117
  }
265
118
  // 外部传入的选择项发生了变化
266
119
  if (!isEqual((_a = prevProps.rowSelection) === null || _a === void 0 ? void 0 : _a.selectedRowKeys, (_b = this.props.rowSelection) === null || _b === void 0 ? void 0 : _b.selectedRowKeys)) {
@@ -268,9 +121,6 @@ var Table = /** @class */ (function (_super) {
268
121
  this.setState({
269
122
  selectedRowKeys: this.props.rowSelection.selectedRowKeys
270
123
  });
271
- var selectedResult = this.getSelectedRows(this.state.dataSource, this.state.selectedRowKeys);
272
- this.selectedRows = selectedResult.selectedRows;
273
- this.unSelectedRows = selectedResult.unSelectedRows;
274
124
  }
275
125
  }
276
126
  // 外部传入的展开项发生了变化
@@ -299,7 +149,7 @@ var Table = /** @class */ (function (_super) {
299
149
  this.updateStickyHeader();
300
150
  }
301
151
  if (prevProps.columns !== this.props.columns) {
302
- this.updateTableFixedRows();
152
+ this.syncTableWidth();
303
153
  }
304
154
  };
305
155
  Table.prototype.componentWillUnmount = function () {
@@ -314,6 +164,69 @@ var Table = /** @class */ (function (_super) {
314
164
  this.toDispose.forEach(function (fn) { return fn(); });
315
165
  this.toDispose = [];
316
166
  this.updateTableInfoLazy.cancel();
167
+ this.updateAutoFillHeightLazy.cancel();
168
+ };
169
+ /**
170
+ * 自动设置表格高度占满界面剩余区域
171
+ * 用 css 实现有点麻烦,要改很多结构,所以先用 dom hack 了,避免对之前的功能有影响
172
+ */
173
+ Table.prototype.updateAutoFillHeight = function () {
174
+ var tableContent = this.containerDom.current;
175
+ if (!tableContent) {
176
+ return;
177
+ }
178
+ tableContent.removeAttribute('style');
179
+ var autoFillHeight = this.props.autoFillHeight;
180
+ if (!autoFillHeight) {
181
+ return;
182
+ }
183
+ // 计算 table-content 在 dom 中的位置
184
+ var viewportHeight = window.innerHeight;
185
+ var tableContentTop = offset(tableContent).top;
186
+ var parent = getScrollParent(tableContent.parentElement);
187
+ if (parent && parent !== document.body) {
188
+ viewportHeight = parent.clientHeight - 1;
189
+ tableContentTop = position(tableContent, parent).top;
190
+ }
191
+ var tableContentBottom = 0;
192
+ var selfNode = tableContent;
193
+ var parentNode = selfNode.parentElement;
194
+ while (parentNode) {
195
+ var paddingBottom = getStyleNumber(parentNode, 'padding-bottom');
196
+ var borderBottom = getStyleNumber(parentNode, 'border-bottom-width');
197
+ var nextSiblingHeight = 0;
198
+ var nextSibling = selfNode.nextElementSibling;
199
+ while (nextSibling) {
200
+ var positon = getComputedStyle(nextSibling).position;
201
+ if (positon !== 'absolute' && positon !== 'fixed') {
202
+ nextSiblingHeight +=
203
+ nextSibling.offsetHeight +
204
+ getStyleNumber(nextSibling, 'margin-bottom');
205
+ }
206
+ nextSibling = nextSibling.nextElementSibling;
207
+ }
208
+ var marginBottom = getStyleNumber(selfNode, 'margin-bottom');
209
+ tableContentBottom +=
210
+ paddingBottom + borderBottom + marginBottom + nextSiblingHeight;
211
+ selfNode = parentNode;
212
+ parentNode = selfNode.parentElement;
213
+ if (parent && parent !== document.body && parent === selfNode) {
214
+ break;
215
+ }
216
+ }
217
+ var heightField = autoFillHeight && autoFillHeight.maxHeight
218
+ ? 'maxHeight'
219
+ : 'height';
220
+ var heightValue = isObject(autoFillHeight)
221
+ ? autoFillHeight[heightField]
222
+ : 0;
223
+ var tableContentHeight = heightValue
224
+ ? heightValue
225
+ : Math.round(viewportHeight - tableContentTop - tableContentBottom);
226
+ if (tableContentHeight > 0) {
227
+ tableContent.style[heightField] = "".concat(tableContentHeight, "px");
228
+ tableContent.style['overflow'] = 'auto';
229
+ }
317
230
  };
318
231
  Table.prototype.initDragging = function () {
319
232
  var _this = this;
@@ -341,15 +254,24 @@ var Table = /** @class */ (function (_super) {
341
254
  return true;
342
255
  },
343
256
  onEnd: function (e) { return __awaiter(_this, void 0, void 0, function () {
344
- var rowLevels;
257
+ var oldIndex, newIndex, rowLevels, i;
345
258
  return __generator(this, function (_a) {
346
259
  // 没有移动
347
260
  if (e.newIndex === e.oldIndex) {
348
261
  return [2 /*return*/];
349
262
  }
350
- rowLevels = e.item.getAttribute('row-levels');
351
- onDrag &&
352
- onDrag(e.oldIndex, e.newIndex, rowLevels ? rowLevels.split(',') : []);
263
+ oldIndex = e.oldIndex;
264
+ newIndex = e.newIndex;
265
+ rowLevels = levelsSplit(e.item.getAttribute('row-levels'));
266
+ if (rowLevels.length) {
267
+ i = 0;
268
+ while (i < rowLevels.length) {
269
+ oldIndex = oldIndex - rowLevels[i] - 1;
270
+ newIndex = newIndex - rowLevels[i] - 1;
271
+ i++;
272
+ }
273
+ }
274
+ onDrag && onDrag(oldIndex, newIndex, rowLevels);
353
275
  return [2 /*return*/];
354
276
  });
355
277
  }); }
@@ -384,109 +306,10 @@ var Table = /** @class */ (function (_super) {
384
306
  });
385
307
  }
386
308
  };
387
- // 更新一个tr下的td的left和class
388
- Table.prototype.updateFixedRow = function (row, columns) {
389
- var _a, _b, _c;
390
- var cx = this.props.classnames;
391
- var children = row.children;
392
- for (var i = 0; i < children.length; i++) {
393
- var dom = children[i];
394
- dom.style.removeProperty('left');
395
- var fixed = columns[i] ? columns[i].fixed || '' : '';
396
- if (isFixedLeftColumn(fixed)) {
397
- dom.style.left =
398
- i > 0 ? getPreviousLeftWidth(children, i, columns) + 'px' : '0';
399
- }
400
- else if (isFixedRightColumn(fixed)) {
401
- dom.style.right =
402
- i < children.length - 1
403
- ? getAfterRightWidth(children, i, columns) + 'px'
404
- : '0';
405
- }
406
- dom.classList.remove(cx('Table-cell-fix-left-last'));
407
- dom.classList.remove(cx('Table-cell-fix-right-first'));
408
- dom.classList.remove(cx('Table-cell-fix-right-first-prev'));
409
- }
410
- // 最后一个左fixed的添加样式
411
- var leftIndex = findLastIndex(columns, function (column) {
412
- return isFixedLeftColumn(column.fixed);
413
- });
414
- if (leftIndex > -1) {
415
- (_a = children[leftIndex]) === null || _a === void 0 ? void 0 : _a.classList.add(cx('Table-cell-fix-left-last'));
416
- }
417
- // 第一个右fixed的添加样式
418
- var rightIndex = columns.findIndex(function (column) {
419
- return isFixedRightColumn(column.fixed);
420
- });
421
- if (rightIndex > -1) {
422
- (_b = children[rightIndex]) === null || _b === void 0 ? void 0 : _b.classList.add(cx('Table-cell-fix-right-first'));
423
- if (rightIndex > 0) {
424
- (_c = children[rightIndex - 1]) === null || _c === void 0 ? void 0 : _c.classList.add(cx('Table-cell-fix-right-first-prev'));
425
- }
426
- }
427
- };
428
- // 在可选、可展开、可拖拽的情况下,补充column,方便fix处理
429
- Table.prototype.prependColumns = function (columns) {
430
- var _a = this.props, rowSelection = _a.rowSelection, expandable = _a.expandable, draggable = _a.draggable;
431
- if (draggable) {
432
- columns.unshift({});
433
- }
434
- else {
435
- if (expandable) {
436
- columns.unshift(expandable);
437
- }
438
- if (rowSelection) {
439
- columns.unshift(rowSelection);
440
- }
441
- }
442
- };
443
- Table.prototype.updateTheadFixedRow = function (thead, columns) {
444
- var children = thead.children;
445
- for (var i = 0; i < children.length; i++) {
446
- var cols = __spreadArray([], __read(columns[i]), false);
447
- if (i === 0) {
448
- this.prependColumns(cols);
449
- }
450
- this.updateFixedRow(children[i], cols);
451
- }
452
- };
453
- Table.prototype.updateTbodyFixedRow = function (tbody, columns) {
454
- var cx = this.props.classnames;
455
- var children = filter(tbody.children, function (child) {
456
- return !child.classList.contains(cx('Table-summary-row')) &&
457
- !child.classList.contains(cx('Table-empty-row'));
458
- });
459
- this.prependColumns(columns);
460
- for (var i = 0; i < children.length; i++) {
461
- this.updateFixedRow(children[i], columns);
462
- }
463
- };
464
- Table.prototype.updateSummaryFixedRow = function (children, columns) {
465
- for (var i = 0; i < children.length; i++) {
466
- this.updateFixedRow(children[i], columns[i]);
467
- }
468
- };
469
- Table.prototype.updateFootSummaryFixedRow = function (tfoot) {
470
- var footSummary = this.props.footSummary;
471
- if (Array.isArray(footSummary)) {
472
- var columns = getSummaryColumns(footSummary);
473
- this.updateSummaryFixedRow(tfoot.children, columns);
474
- }
475
- };
476
- Table.prototype.updateHeadSummaryFixedRow = function (tbody) {
477
- var _a = this.props, headSummary = _a.headSummary, cx = _a.classnames;
478
- if (Array.isArray(headSummary)) {
479
- var columns = getSummaryColumns(headSummary);
480
- var children = filter(tbody.children, function (child) {
481
- return child.classList.contains(cx('Table-summary-row'));
482
- });
483
- this.updateSummaryFixedRow(children, columns);
484
- }
485
- };
486
309
  Table.prototype.renderColGroup = function (showReal) {
487
- var _a = this.props, scroll = _a.scroll, tableLayout = _a.tableLayout;
310
+ var _a = this.props, scroll = _a.scroll, tableLayout = _a.tableLayout, columns = _a.columns, rowSelection = _a.rowSelection, expandable = _a.expandable, draggable = _a.draggable;
488
311
  var isFixed = !!((scroll && scroll.x) || tableLayout === 'fixed');
489
- return (React__default.createElement(ColGroup, { columns: this.tdColumns, colWidths: this.state.colWidths, isFixed: isFixed, syncTableWidth: this.syncTableWidth, initTableWidth: this.initTableWidth, showReal: showReal }));
312
+ return (React__default.createElement(ColGroup, { columns: columns, colWidths: this.state.colWidths, isFixed: isFixed, syncTableWidth: this.syncTableWidth, initTableWidth: this.initTableWidth, selectable: !!rowSelection, expandable: !!expandable, draggable: !!draggable, rowSelectionColumnWidth: (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.columnWidth) || DefaultCellWidth, expandableColumnWidth: (expandable === null || expandable === void 0 ? void 0 : expandable.columnWidth) || DefaultCellWidth, isRightExpandable: this.isRightExpandable(), isLeftExpandable: this.isLeftExpandable(), showReal: showReal }));
490
313
  };
491
314
  Table.prototype.onResizeMouseDown = function (event, index) {
492
315
  // 点击记录起始坐标
@@ -494,7 +317,8 @@ var Table = /** @class */ (function (_super) {
494
317
  this.resizeTarget = event.currentTarget;
495
318
  var column = this.tdColumns[index];
496
319
  this.resizeIndex = index;
497
- this.resizeWidth = this.state.colWidths[column.name].width;
320
+ var colWidth = this.state.colWidths[column.name];
321
+ this.resizeWidth = colWidth.width || colWidth.realWidth;
498
322
  this.resizeTarget.classList.add('is-resizing');
499
323
  document.addEventListener('mousemove', this.onResizeMouseMove);
500
324
  document.addEventListener('mouseup', this.onResizeMouseUp);
@@ -528,147 +352,60 @@ var Table = /** @class */ (function (_super) {
528
352
  this.resizeWidth = 0;
529
353
  delete this.resizeTarget;
530
354
  };
531
- Table.prototype.renderTHead = function () {
355
+ Table.prototype.renderHead = function () {
532
356
  var _this = this;
533
- var _a = this.props, rowSelection = _a.rowSelection, dataSource = _a.dataSource, cx = _a.classnames, onSort = _a.onSort, expandable = _a.expandable, draggable = _a.draggable, resizable = _a.resizable, onSelectAll = _a.onSelectAll, onFilter = _a.onFilter;
534
- var thColumns = this.thColumns;
535
- var tdColumns = this.tdColumns;
536
- // 获取一行最多th个数
537
- var maxCount = 0;
538
- thColumns.forEach(function (columns) {
539
- if (columns.length > maxCount) {
540
- maxCount = columns.length;
541
- }
542
- });
543
- var keyField = this.getRowSelectionKeyField();
357
+ var _a;
358
+ var _b = this.props, columns = _b.columns, cx = _b.classnames, classPrefix = _b.classPrefix, expandable = _b.expandable, rowSelection = _b.rowSelection, draggable = _b.draggable, resizable = _b.resizable, dataSource = _b.dataSource, onSort = _b.onSort, onSelectAll = _b.onSelectAll, onFilter = _b.onFilter;
359
+ var rowSelectionKeyField = this.getRowSelectionKeyField();
544
360
  var dataList = rowSelection && rowSelection.getCheckboxProps
545
361
  ? this.state.dataSource.filter(function (data, index) {
546
362
  var props = rowSelection.getCheckboxProps(data, index);
547
363
  return !props.disabled;
548
364
  })
549
365
  : this.state.dataSource;
550
- var isExpandable = this.isExpandableTable();
551
- var isLeftExpandable = this.isLeftExpandable();
552
- var isRightExpandable = this.isRightExpandable();
553
- var expandableCell = !draggable && isExpandable ? (React__default.createElement(Cell, { wrapperComponent: "th", rowSpan: thColumns.length, fixed: expandable && expandable.fixed ? 'left' : '', className: cx('Table-row-expand-icon-cell'), style: { width: ((expandable === null || expandable === void 0 ? void 0 : expandable.columnWidth) || DefaultCellWidth) + 'px' } })) : null;
554
- var allRowKeys = [];
555
- var allRows = [];
556
- dataList.forEach(function (data) {
557
- allRowKeys.push(data[keyField]);
558
- allRows.push(data);
559
- if (!expandable && _this.hasChildrenRow(data)) {
560
- allRowKeys = __spreadArray(__spreadArray([], __read(allRowKeys), false), __read(_this.getDataChildrenKeys(data)), false);
561
- data[_this.getChildrenColumnName()].forEach(function (item) {
562
- return allRows.push(item);
366
+ return (React__default.createElement(Head, { key: "thead", columns: columns, draggable: !!draggable, selectable: !!rowSelection, rowSelectionFixed: !!(rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.fixed), rowSelectionType: rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type, selections: rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selections, rowSelectionKeyField: rowSelectionKeyField, maxSelectedLength: rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.maxSelectedLength, isExpandable: this.isExpandableTable(), isRightExpandable: this.isRightExpandable(), isLeftExpandable: this.isLeftExpandable(), selectedRowKeys: this.state.selectedRowKeys, dataSource: dataList, resizable: resizable, expandable: !!expandable, expandableFixed: expandable === null || expandable === void 0 ? void 0 : expandable.fixed, childrenColumnName: this.getChildrenColumnName(), orderBy: (_a = this.state.sort) === null || _a === void 0 ? void 0 : _a.orderBy, popOverContainer: this.getPopOverContainer, classnames: cx, classPrefix: classPrefix, onSort: function (payload, column) {
367
+ _this.setState({
368
+ sort: payload
563
369
  });
564
- }
565
- });
566
- // 从renderers的table传来的数据 可能不在当前页 因此需要过滤一下
567
- var selectedRowKeys = this.state.selectedRowKeys.filter(function (key) {
568
- return allRowKeys.includes(key);
569
- });
570
- var restSelectedRowKeys = this.state.selectedRowKeys.filter(function (key) { return !allRowKeys.includes(key); });
571
- var maxSelectedLength = rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.maxSelectedLength;
572
- if (maxSelectedLength && Number.isInteger(maxSelectedLength)) {
573
- if (restSelectedRowKeys.length + allRowKeys.length > maxSelectedLength) {
574
- var count = maxSelectedLength - restSelectedRowKeys.length;
575
- allRowKeys = allRowKeys.slice(0, count);
576
- allRows = allRows.slice(0, count);
577
- }
578
- }
579
- return (React__default.createElement("thead", { ref: this.theadDom, className: cx('Table-thead') }, thColumns.map(function (data, index) {
580
- return (React__default.createElement("tr", { key: 'th-cell-' + index },
581
- draggable && index === 0 ? (React__default.createElement(Cell, { wrapperComponent: "th", rowSpan: thColumns.length, className: cx('Table-dragCell'), style: { width: DefaultCellWidth + 'px' }, col: "drag" })) : null,
582
- !draggable && rowSelection && index === 0 ? (React__default.createElement(Cell, { wrapperComponent: "th", rowSpan: thColumns.length, fixed: rowSelection.fixed ? 'left' : '', className: cx('Table-checkCell'), style: {
583
- width: (rowSelection.columnWidth || DefaultCellWidth) + 'px'
584
- }, col: "select" }, rowSelection.type !== 'radio'
585
- ? [
586
- React__default.createElement(Checkbox, { key: "checkAll", partial: selectedRowKeys.length > 0 &&
587
- selectedRowKeys.length < allRowKeys.length, checked: selectedRowKeys.length > 0, onChange: function (value) { return __awaiter(_this, void 0, void 0, function () {
588
- var selectedRows, selectedRowKeys, prevented;
589
- return __generator(this, function (_a) {
590
- switch (_a.label) {
591
- case 0:
592
- selectedRows = value ? allRows : [];
593
- selectedRowKeys = value ? allRowKeys : [];
594
- if (!onSelectAll) return [3 /*break*/, 2];
595
- return [4 /*yield*/, onSelectAll(selectedRows, value ? selectedRowKeys : [], value ? [] : selectedRows)];
596
- case 1:
597
- prevented = _a.sent();
598
- if (prevented) {
599
- return [2 /*return*/];
600
- }
601
- _a.label = 2;
602
- case 2:
603
- this.setState({
604
- selectedRowKeys: __spreadArray(__spreadArray([], __read(selectedRowKeys), false), __read(restSelectedRowKeys // 更新数据要把非当前页的数据也加上
605
- ), false)
606
- });
607
- return [2 /*return*/];
608
- }
609
- });
610
- }); } }),
611
- rowSelection.selections &&
612
- rowSelection.selections.length > 0 ? (React__default.createElement(HeadCellSelect, { key: "checkSelection", keys: allRowKeys, selections: rowSelection.selections, popOverContainer: _this.getPopOverContainer })) : null
613
- ]
614
- : null)) : null,
615
- isLeftExpandable && index === 0 ? expandableCell : null,
616
- data.map(function (item, i) {
617
- var _a, _b, _c;
618
- var sort = null;
619
- if (item.sorter) {
620
- sort = (React__default.createElement(HeadCellSort, { column: item, active: !!((_a = _this.state.sort) === null || _a === void 0 ? void 0 : _a.orderBy) &&
621
- _this.state.sort.orderBy === (item === null || item === void 0 ? void 0 : item.name), onSort: function (payload) {
622
- _this.setState({
623
- sort: payload
624
- });
625
- if (onSort) {
626
- onSort(payload);
627
- }
628
- else {
629
- if (typeof item.sorter === 'function') {
630
- if (payload.orderBy) {
631
- var sortList = __spreadArray([], __read(_this.state.dataSource), false);
632
- _this.setState({
633
- dataSource: sortList.sort(item.sorter)
634
- });
635
- }
636
- else {
637
- _this.setState({ dataSource: __spreadArray([], __read(dataSource), false) });
638
- }
639
- }
640
- }
641
- } }));
642
- }
643
- var filter = null;
644
- if (item.filterDropdown) {
645
- filter = item.filterDropdown;
646
- }
647
- else if (item.filters && item.filters.length > 0) {
648
- filter = (React__default.createElement(HeadCellFilter, { column: item, popOverContainer: _this.getPopOverContainer, onFilter: onFilter }));
370
+ if (onSort) {
371
+ onSort(payload);
372
+ }
373
+ else {
374
+ if (typeof column.sorter === 'function') {
375
+ if (payload.orderBy) {
376
+ var sortList = __spreadArray([], __read(_this.state.dataSource), false);
377
+ _this.setState({
378
+ dataSource: sortList.sort(column.sorter)
379
+ });
380
+ }
381
+ else {
382
+ _this.setState({ dataSource: __spreadArray([], __read(dataSource), false) });
383
+ }
649
384
  }
650
- // th的最后一行才可调整列宽
651
- // 分组情况下 最后一行才和列配置个数对应
652
- // 就可以根据index找到col 不依赖name
653
- var noChildren = !((_b = item.children) === null || _b === void 0 ? void 0 : _b.length);
654
- var cIndex = -1;
655
- if (noChildren) {
656
- // 根据name去tdColumns匹配出index
657
- // 没设置name的 那一定不是要绑定数据的列 一般都是分组的上层 也不会出现调整列宽
658
- cIndex = tdColumns.findIndex(function (c) { return c.name === item.name; });
385
+ }
386
+ }, onSelectAll: function (value, selectedRowKeys, selectedRows, restSelectedKeys) { return __awaiter(_this, void 0, void 0, function () {
387
+ var prevented, keys;
388
+ return __generator(this, function (_a) {
389
+ switch (_a.label) {
390
+ case 0:
391
+ if (!onSelectAll) return [3 /*break*/, 2];
392
+ return [4 /*yield*/, onSelectAll(selectedRows, value ? selectedRowKeys : [], value ? [] : selectedRows)];
393
+ case 1:
394
+ prevented = _a.sent();
395
+ if (prevented) {
396
+ return [2 /*return*/];
397
+ }
398
+ _a.label = 2;
399
+ case 2:
400
+ keys = __spreadArray(__spreadArray([], __read(selectedRowKeys), false), __read(restSelectedKeys // 更新数据要把非当前页的数据也加上
401
+ ), false);
402
+ if (!isEqual(keys, this.state.selectedRowKeys)) {
403
+ this.setState({ selectedRowKeys: keys });
404
+ }
405
+ return [2 /*return*/];
659
406
  }
660
- var children = !((_c = item.children) === null || _c === void 0 ? void 0 : _c.length) ? (React__default.createElement(React__default.Fragment, null,
661
- sort,
662
- filter,
663
- resizable ? (React__default.createElement("i", { className: cx('Table-thead-resizable'), onMouseDown: function (e) { return _this.onResizeMouseDown(e, cIndex); } })) : null)) : null;
664
- return (React__default.createElement(Cell, { wrapperComponent: "th", rowSpan: item.rowSpan, colSpan: item.colSpan, key: "cell-".concat(i), fixed: item.fixed === true ? 'left' : item.fixed, className: cx({
665
- 'Table-cell-last': i === maxCount - 1 && i === data.length - 1
666
- }), groupId: item.groupId, depth: item.depth, col: cIndex > -1 ? cIndex.toString() : undefined }, typeof item.title === 'function'
667
- ? item.title(children)
668
- : item.title));
669
- }),
670
- isRightExpandable && index === 0 ? expandableCell : null));
671
- })));
407
+ });
408
+ }); }, onFilter: onFilter, onResizeMouseDown: this.onResizeMouseDown.bind(this) }));
672
409
  };
673
410
  Table.prototype.onRowClick = function (event, record, rowIndex) {
674
411
  return __awaiter(this, void 0, void 0, function () {
@@ -696,6 +433,26 @@ var Table = /** @class */ (function (_super) {
696
433
  });
697
434
  });
698
435
  };
436
+ Table.prototype.onRowDbClick = function (event, record, rowIndex) {
437
+ return __awaiter(this, void 0, void 0, function () {
438
+ var onRow, prevented;
439
+ return __generator(this, function (_a) {
440
+ switch (_a.label) {
441
+ case 0:
442
+ onRow = this.props.onRow;
443
+ if (!(onRow && onRow.onRowDbClick)) return [3 /*break*/, 2];
444
+ return [4 /*yield*/, onRow.onRowDbClick(event, record, rowIndex)];
445
+ case 1:
446
+ prevented = _a.sent();
447
+ if (prevented === false) {
448
+ return [2 /*return*/];
449
+ }
450
+ _a.label = 2;
451
+ case 2: return [2 /*return*/];
452
+ }
453
+ });
454
+ });
455
+ };
699
456
  Table.prototype.onRowMouseEnter = function (event, record, rowIndex) {
700
457
  return __awaiter(this, void 0, void 0, function () {
701
458
  var _a, onRow, itemActions, prevented, target;
@@ -771,204 +528,118 @@ var Table = /** @class */ (function (_super) {
771
528
  var _a = this.props, expandable = _a.expandable, keyField = _a.keyField;
772
529
  return (expandable === null || expandable === void 0 ? void 0 : expandable.keyField) || keyField || 'key';
773
530
  };
774
- Table.prototype.hasChildrenRow = function (data) {
775
- var key = this.getChildrenColumnName();
776
- return data[key] && Array.isArray(data[key]) && data[key].length > 0;
777
- };
778
- // 展开和嵌套不能共存
779
- Table.prototype.isExpandableRow = function (data, rowIndex) {
780
- var expandable = this.props.expandable;
781
- return (expandable &&
782
- (!expandable.rowExpandable ||
783
- (expandable.rowExpandable && expandable.rowExpandable(data, rowIndex))));
784
- };
785
- // 获取当前行数据所有子行的key值
786
- Table.prototype.getDataChildrenKeys = function (data) {
787
- var _this = this;
788
- var keys = [];
789
- if (this.hasChildrenRow(data)) {
790
- var key = this.getChildrenColumnName();
791
- data[key].forEach(function (item) {
792
- return (keys = __spreadArray(__spreadArray(__spreadArray([], __read(keys), false), __read(_this.getDataChildrenKeys(item)), false), [
793
- item[_this.getRowSelectionKeyField()]
794
- ], false));
795
- });
796
- }
797
- return keys;
798
- };
799
- Table.prototype.hasCheckedRows = function (data) {
800
- var selectedRowKeys = this.state.selectedRowKeys;
801
- var childrenKeys = this.getDataChildrenKeys(data);
802
- return (intersection(selectedRowKeys, __spreadArray(__spreadArray([], __read(childrenKeys), false), [
803
- data[this.getRowSelectionKeyField()]
804
- ], false)).length > 0);
805
- };
806
531
  Table.prototype.hasCheckedChildrenRows = function (data) {
807
532
  var selectedRowKeys = this.state.selectedRowKeys;
808
- var childrenKeys = this.getDataChildrenKeys(data);
533
+ var childrenColumnName = this.getChildrenColumnName();
534
+ var rowSelectionKeyField = this.getRowSelectionKeyField();
535
+ var childrenKeys = getDataChildrenKeys(data, childrenColumnName, rowSelectionKeyField);
809
536
  var length = intersection(selectedRowKeys, childrenKeys).length;
810
537
  return length > 0;
811
538
  };
812
- Table.prototype.isExpanded = function (record) {
813
- var _this = this;
814
- return !!find(this.state.expandedRowKeys, function (key) { return key == record[_this.getExpandableKeyField()]; }); // == 匹配 否则'3'、3匹配不上
815
- };
816
- Table.prototype.getExpandedIcons = function (record) {
817
- var cx = this.props.classnames;
818
- return this.isExpanded(record) ? (React__default.createElement("i", { className: cx('Table-expandBtn', 'is-active'), onClick: this.onCollapseRows.bind(this, [record]) },
819
- React__default.createElement(Icon, { icon: "right-arrow-bold", className: "icon" }))) : (React__default.createElement("i", { className: cx('Table-expandBtn'), onClick: this.onExpandRows.bind(this, [record]) },
820
- React__default.createElement(Icon, { icon: "right-arrow-bold", className: "icon" })));
539
+ Table.prototype.getSelectedRowKeys = function (isSelected, data) {
540
+ var rowSelection = this.props.rowSelection;
541
+ var rowSelectionKeyField = this.getRowSelectionKeyField();
542
+ var childrenColumnName = this.getChildrenColumnName();
543
+ var isRadio = rowSelection && rowSelection.type === 'radio';
544
+ var selected = [];
545
+ if (isSelected) {
546
+ if (isRadio) {
547
+ selected = [data[rowSelectionKeyField]];
548
+ }
549
+ else {
550
+ selected = __spreadArray(__spreadArray(__spreadArray([], __read(this.state.selectedRowKeys), false), [
551
+ data[rowSelectionKeyField]
552
+ ], false), __read(getDataChildrenKeys(data, childrenColumnName, rowSelectionKeyField)), false).filter(function (key, i, a) { return a.indexOf(key) === i; });
553
+ }
554
+ }
555
+ else {
556
+ if (!isRadio) {
557
+ selected = this.state.selectedRowKeys.filter(function (key) {
558
+ return !__spreadArray([
559
+ data[rowSelectionKeyField]
560
+ ], __read(getDataChildrenKeys(data, childrenColumnName, rowSelectionKeyField)), false).includes(key);
561
+ });
562
+ }
563
+ }
564
+ return selected;
821
565
  };
822
566
  Table.prototype.selectedSingleRow = function (value, data) {
823
567
  return __awaiter(this, void 0, void 0, function () {
824
- var _a, rowSelection, onSelect, defaultKey, isRadio, selectedRowKeys, selectedResult, prevented;
825
- var _this = this;
826
- return __generator(this, function (_b) {
827
- switch (_b.label) {
568
+ var onSelect, selectedRowKeys, rowSelectionKeyField, childrenColumnName, selectedResult, prevented;
569
+ return __generator(this, function (_a) {
570
+ switch (_a.label) {
828
571
  case 0:
829
- _a = this.props, rowSelection = _a.rowSelection, onSelect = _a.onSelect;
830
- defaultKey = this.getRowSelectionKeyField();
831
- isRadio = rowSelection && rowSelection.type === 'radio';
832
- selectedRowKeys = [];
833
- if (value) {
834
- if (isRadio) {
835
- selectedRowKeys = [data[defaultKey]];
836
- }
837
- else {
838
- selectedRowKeys = __spreadArray(__spreadArray(__spreadArray([], __read(this.state.selectedRowKeys), false), [
839
- data[defaultKey]
840
- ], false), __read(this.getDataChildrenKeys(data)), false).filter(function (key, i, a) { return a.indexOf(key) === i; });
841
- }
842
- }
843
- else {
844
- if (!isRadio) {
845
- selectedRowKeys = this.state.selectedRowKeys.filter(function (key) {
846
- return !__spreadArray([data[defaultKey]], __read(_this.getDataChildrenKeys(data)), false).includes(key);
847
- });
848
- }
849
- }
572
+ onSelect = this.props.onSelect;
573
+ selectedRowKeys = this.getSelectedRowKeys(value, data);
850
574
  if (!onSelect) return [3 /*break*/, 2];
851
- selectedResult = this.getSelectedRows(this.state.dataSource, selectedRowKeys);
575
+ rowSelectionKeyField = this.getRowSelectionKeyField();
576
+ childrenColumnName = this.getChildrenColumnName();
577
+ selectedResult = getSelectedRows(this.state.dataSource, selectedRowKeys, rowSelectionKeyField, childrenColumnName);
852
578
  return [4 /*yield*/, onSelect(selectedResult.selectedRows, selectedRowKeys, selectedResult.unSelectedRows)];
853
579
  case 1:
854
- prevented = _b.sent();
580
+ prevented = _a.sent();
855
581
  if (prevented) {
856
582
  return [2 /*return*/];
857
583
  }
858
- _b.label = 2;
584
+ _a.label = 2;
859
585
  case 2:
860
- this.setState({ selectedRowKeys: selectedRowKeys });
586
+ if (!isEqual(this.state.selectedRowKeys, selectedRowKeys)) {
587
+ this.setState({ selectedRowKeys: selectedRowKeys });
588
+ }
861
589
  return [2 /*return*/];
862
590
  }
863
591
  });
864
592
  });
865
593
  };
594
+ // 展开和嵌套不能共存
595
+ Table.prototype.isExpandableRow = function (data, rowIndex) {
596
+ var expandable = this.props.expandable;
597
+ return (expandable &&
598
+ (!expandable.rowExpandable ||
599
+ (expandable.rowExpandable && expandable.rowExpandable(data, rowIndex))));
600
+ };
601
+ Table.prototype.isExpanded = function (record) {
602
+ var expandableKeyField = this.getExpandableKeyField();
603
+ return !!find(this.state.expandedRowKeys, function (key) { return key == record[expandableKeyField]; }); // == 匹配 否则'3'、3匹配不上
604
+ };
866
605
  Table.prototype.renderRow = function (data, rowIndex, levels) {
867
606
  var _this = this;
868
- var _a = this.props, cx = _a.classnames, rowSelection = _a.rowSelection, expandable = _a.expandable, draggable = _a.draggable, indentSize = _a.indentSize, rowClassName = _a.rowClassName, keyField = _a.keyField, lineHeight = _a.lineHeight // 是否设置了固定行高
869
- ;
870
- var tdColumns = this.tdColumns;
871
- var isExpandable = this.isExpandableTable();
872
- var defaultKey = this.getRowSelectionKeyField();
873
- var colCount = this.getExtraColumnCount();
874
- var isLeftExpandable = this.isLeftExpandable();
875
- var isRightExpandable = this.isRightExpandable();
607
+ var _a = this.props, rowSelection = _a.rowSelection, expandable = _a.expandable, indentSize = _a.indentSize, lineHeight = _a.lineHeight, draggable = _a.draggable, rowClassName = _a.rowClassName, keyField = _a.keyField, columns = _a.columns, classPrefix = _a.classPrefix, cx = _a.classnames;
608
+ var rowSelectionKeyField = this.getRowSelectionKeyField();
609
+ var isChecked = !!find(this.state.selectedRowKeys, function (key) { return key === data[rowSelectionKeyField]; });
610
+ var childrenColumnName = this.getChildrenColumnName();
876
611
  // 当前行是否可展开
877
612
  var isExpandableRow = this.isExpandableRow(data, rowIndex);
878
- // 当前行是否有children
879
- var hasChildrenRow = this.hasChildrenRow(data);
880
- var isExpanded = this.isExpanded(data);
881
- // 设置缩进效果
882
- var indentDom = levels.length > 0 ? (React__default.createElement("span", { className: cx('Table-row-indent', "indent-level-".concat(levels.length)), style: levels.length > 0 ? { width: indentSize * levels.length + 'px' } : {} })) : null;
883
- var cells = tdColumns.map(function (item, i) {
884
- var _a, _b;
885
- // 为了支持灵活合并单元格,renderers层的Table2传递的render方法,返回{children: <ReactElement>, props: {rowSpan, colSpan}}
886
- // 但直接使用amis-ui的table,render方法一般直接返回ReactElement
887
- var render = item.render && typeof item.render === 'function'
888
- ? item.render(data[item.name], data, rowIndex, i, levels)
889
- : null;
890
- var props = { rowSpan: 1, colSpan: 1 };
891
- var children = render;
892
- if (render && !React__default.isValidElement(render) && isObject(render)) {
893
- if (render.props) {
894
- props = render.props;
895
- }
896
- children = render.children;
897
- // 如果合并行 且有展开行,那么合并行不生效
898
- if (props.rowSpan > 1 && isExpandableRow && hasChildrenRow) {
899
- props.rowSpan === 1;
900
- }
901
- }
902
- var className = typeof item.className === 'function'
903
- ? item.className(data, rowIndex)
904
- : '';
905
- return props.rowSpan === 0 || props.colSpan === 0 ? null : (React__default.createElement(Cell, __assign({ key: i }, props, { fixed: item.fixed === true ? 'left' : item.fixed, column: item, groupId: item.groupId, className: cx((_a = {},
906
- _a["".concat(className)] = !!className,
907
- _a)), col: i > -1 ? i.toString() : undefined }),
908
- React__default.createElement("div", { className: cx('Table-cell-wrapper', (_b = {},
909
- _b[cx('Table-cell-wrapper-prefix')] = i === 0 &&
910
- (!!indentDom || (levels.length === 0 && hasChildrenRow)),
911
- _b[cx("Table-cell-height-".concat(lineHeight))] = !!lineHeight,
912
- _b)) },
913
- i === 0 && levels.length > 0 ? indentDom : null,
914
- i === 0 && hasChildrenRow ? _this.getExpandedIcons(data) : null,
915
- render ? children : data[item.name])));
916
- });
917
- var rowClassNameClass = rowClassName && typeof rowClassName === 'function'
918
- ? rowClassName(data, rowIndex)
919
- : '';
920
- // 可展开和嵌套不能同时支持
921
- // 设置了expandable 数据源里有children也就不生效了
922
- // 拖拽排序 可选、可展开都先不支持了,可以支持嵌套展示
923
- var checkboxProps = rowSelection && rowSelection.getCheckboxProps
924
- ? rowSelection.getCheckboxProps(data, rowIndex)
925
- : {};
613
+ var hasChildrenRow = checkChildrenRow(data, childrenColumnName);
614
+ var hasChildrenChecked = !!rowSelection && hasChildrenRow && this.hasCheckedChildrenRows(data);
926
615
  var expandedRowClassName = expandable &&
927
616
  expandable.expandedRowClassName &&
928
617
  typeof expandable.expandedRowClassName === 'function'
929
618
  ? expandable.expandedRowClassName(data, rowIndex)
930
619
  : '';
931
- var dataKey = this.getChildrenColumnName();
932
- var children = !draggable && isExpandableRow && isExpanded ? (React__default.createElement("tr", { key: "expanded", className: cx('Table-expanded-row', expandedRowClassName) },
933
- React__default.createElement(Cell, { colSpan: tdColumns.length + colCount }, expandable &&
934
- expandable.expandedRowRender &&
935
- typeof expandable.expandedRowRender === 'function'
936
- ? expandable.expandedRowRender(data, rowIndex)
937
- : null))) : this.hasChildrenRow(data) && isExpanded ? (data[dataKey].map(function (item, index) {
938
- return _this.renderRow(item, index, __spreadArray(__spreadArray([], __read(levels), false), [rowIndex], false));
939
- })) : null;
940
- var isChecked = !!find(this.state.selectedRowKeys, function (key) { return key === data[defaultKey]; });
941
- var hasChildrenChecked = this.hasCheckedChildrenRows(data);
942
- var isRadio = rowSelection && rowSelection.type === 'radio';
943
- var expandableCell = !draggable && isExpandable ? (React__default.createElement(Cell, { fixed: expandable && expandable.fixed
944
- ? isRightExpandable
945
- ? 'right'
946
- : 'left'
947
- : '', className: cx('Table-cell-expand-icon-cell') }, isExpandableRow || hasChildrenRow
948
- ? this.getExpandedIcons(data)
949
- : null)) : null;
620
+ var isExpanded = this.isExpanded(data);
621
+ var checkboxProps = rowSelection && rowSelection.getCheckboxProps
622
+ ? rowSelection.getCheckboxProps(data, rowIndex)
623
+ : {};
624
+ var children = !expandable && childrenColumnName && hasChildrenRow && isExpanded
625
+ ? data[childrenColumnName].map(function (item, index) {
626
+ return _this.renderRow(item, index, __spreadArray(__spreadArray([], __read(levels), false), [rowIndex], false));
627
+ })
628
+ : null;
950
629
  return [
951
- React__default.createElement("tr", { key: "".concat(data[keyField || 'key'] || rowIndex), "row-index": rowIndex, "row-levels": levels.join(','), className: cx('Table-row', "Table-row-level-".concat(levels.length), rowClassNameClass, {
952
- 'Table-row-disabled': !!checkboxProps.disabled
953
- }), onMouseEnter: function (e) { return _this.onRowMouseEnter(e, data, rowIndex); }, onMouseLeave: function (e) { return _this.onRowMouseLeave(e, data, rowIndex); }, onClick: function (e) { return _this.onRowClick(e, data, rowIndex); } },
954
- draggable ? (React__default.createElement(Cell, { className: cx('Table-dragCell') },
955
- React__default.createElement(Icon, { icon: "drag-bar", className: "icon" }))) : null,
956
- !draggable && rowSelection ? (React__default.createElement(Cell, { fixed: rowSelection.fixed ? 'left' : '', className: cx('Table-checkCell') },
957
- React__default.createElement(Checkbox, __assign({ name: 'Table-checkbox', type: rowSelection.type || 'checkbox', partial: !isRadio && hasChildrenChecked && !isChecked, checked: isRadio ? isChecked : hasChildrenChecked || isChecked, onChange: function (value) {
958
- if (!(rowSelection && rowSelection.rowClick)) {
959
- _this.selectedSingleRow(value, data);
960
- }
961
- event && event.stopPropagation();
962
- } }, checkboxProps)))) : null,
963
- isLeftExpandable ? expandableCell : null,
964
- cells,
965
- isRightExpandable ? expandableCell : null),
630
+ React__default.createElement(BodyRow, __assign({ key: "row-".concat(rowIndex), data: data, rowIndex: rowIndex, levels: levels.join(','), columns: columns, selectable: !!rowSelection, rowSelectionFixed: !!(rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.fixed), rowSelectionType: (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) || 'checkbox', expandable: !!expandable, expandableFixed: expandable === null || expandable === void 0 ? void 0 : expandable.fixed, expandedRowClassName: expandedRowClassName, expandedRowRender: expandable === null || expandable === void 0 ? void 0 : expandable.expandedRowRender, isExpanded: isExpanded, hasChildrenRow: hasChildrenRow, hasChildrenChecked: hasChildrenChecked, indentSize: indentSize, lineHeight: lineHeight, draggable: !!draggable, isExpandable: this.isExpandableTable(), isExpandableRow: isExpandableRow, colCount: this.getExtraColumnCount(), isRightExpandable: this.isRightExpandable(), isLeftExpandable: this.isLeftExpandable(), isChecked: isChecked, rowClassName: rowClassName, onExpand: this.onExpandRows, onCollapse: this.onCollapseRows, onMouseEnter: this.onRowMouseEnter, onMouseLeave: this.onRowMouseLeave, onClick: this.onRowClick, onDoubleClick: this.onRowDbClick, onChange: this.onRowChange, childrenColumnName: this.getChildrenColumnName(), keyField: keyField, classnames: cx, classPrefix: classPrefix }, checkboxProps)),
966
631
  children
967
632
  ];
968
633
  };
969
- Table.prototype.renderTBody = function () {
634
+ Table.prototype.onRowChange = function (value, record) {
635
+ var rowSelection = this.props.rowSelection;
636
+ if (!(rowSelection && rowSelection.rowClick)) {
637
+ this.selectedSingleRow(value, record);
638
+ }
639
+ };
640
+ Table.prototype.renderBody = function () {
970
641
  var _this = this;
971
- var _a = this.props, cx = _a.classnames, headSummary = _a.headSummary, scroll = _a.scroll, placeholder = _a.placeholder, sticky = _a.sticky, loading = _a.loading, loadingConfig = _a.loadingConfig;
642
+ var _a = this.props, cx = _a.classnames, headSummary = _a.headSummary, scroll = _a.scroll, placeholder = _a.placeholder, sticky = _a.sticky, loading = _a.loading, loadingConfig = _a.loadingConfig, classPrefix = _a.classPrefix;
972
643
  var tdColumns = this.tdColumns;
973
644
  var hasScrollY = scroll && scroll.y;
974
645
  var colCount = this.getExtraColumnCount();
@@ -977,9 +648,9 @@ var Table = /** @class */ (function (_super) {
977
648
  ? this.renderSummaryRow(headSummary)
978
649
  : null,
979
650
  !!loading ? (React__default.createElement("tr", { className: cx('Table-row', 'Table-loading-row') },
980
- React__default.createElement(Cell, { colSpan: tdColumns.length + colCount },
651
+ React__default.createElement(BodyCell, { classnames: cx, classPrefix: classPrefix, colSpan: tdColumns.length + colCount },
981
652
  React__default.createElement("div", { className: cx('Table-loading') }, typeof loading === 'boolean' ? (React__default.createElement(Spinner, { overlay: true, show: loading, loadingConfig: loadingConfig })) : React__default.isValidElement(loading) ? (loading) : null)))) : !this.state.dataSource.length ? (React__default.createElement("tr", { className: cx('Table-row', 'Table-empty-row') },
982
- React__default.createElement(Cell, { colSpan: tdColumns.length + colCount },
653
+ React__default.createElement(BodyCell, { classnames: cx, classPrefix: classPrefix, colSpan: tdColumns.length + colCount },
983
654
  React__default.createElement("div", { className: cx('Table-empty') }, typeof placeholder === 'function'
984
655
  ? placeholder()
985
656
  : placeholder)))) : (this.state.dataSource.map(function (data, index) {
@@ -997,16 +668,11 @@ var Table = /** @class */ (function (_super) {
997
668
  var expandable = this.props.expandable;
998
669
  return expandable && expandable.position === 'right';
999
670
  };
1000
- // 展开列放到左侧
671
+ // 展开列放到左侧 还有一种情况是position为none 无展开按钮
1001
672
  Table.prototype.isLeftExpandable = function () {
1002
673
  var expandable = this.props.expandable;
1003
674
  return (expandable && (!expandable.position || expandable.position === 'left'));
1004
675
  };
1005
- Table.prototype.isNestedTable = function () {
1006
- var _this = this;
1007
- var dataSource = this.props.dataSource;
1008
- return !!find(dataSource, function (item) { return _this.hasChildrenRow(item); });
1009
- };
1010
676
  // 计算自动增加的列数
1011
677
  // 选择、拖拽、展开
1012
678
  Table.prototype.getExtraColumnCount = function () {
@@ -1026,46 +692,18 @@ var Table = /** @class */ (function (_super) {
1026
692
  return count;
1027
693
  };
1028
694
  Table.prototype.renderSummaryRow = function (summary) {
1029
- var _this = this;
1030
- var _a = this.props, cx = _a.classnames, dataSource = _a.dataSource;
1031
- var cells = [];
1032
- var trs = [];
1033
- var colCount = this.getExtraColumnCount();
1034
- var isRightExpandable = this.isRightExpandable() ? 1 : 0;
1035
- Array.isArray(summary)
1036
- ? summary.forEach(function (s, index) {
1037
- Array.isArray(s)
1038
- ? trs.push(React__default.createElement("tr", { onMouseEnter: function (e) { return _this.onRowMouseEnter(e); }, onMouseLeave: function (e) { return _this.onRowMouseLeave(e); }, key: 'summary-tr-' + index, className: cx('Table-summary-row') }, s.map(function (d, i) {
1039
- // 将操作列自动添加到第一列,用户的colSpan只需要关心实际的列数
1040
- var colSpan = i === 0
1041
- ? (d.colSpan || 1) + colCount - isRightExpandable
1042
- : i === s.length - 1
1043
- ? (d.colSpan || 1) + isRightExpandable
1044
- : d.colSpan;
1045
- return (React__default.createElement(Cell, { key: 'summary-tr-cell-' + i, fixed: d.fixed, colSpan: colSpan }, typeof d.render === 'function'
1046
- ? d.render(dataSource)
1047
- : d.render));
1048
- })))
1049
- : cells.push(React__default.createElement(Cell, { key: 'summary-cell-' + index, fixed: s.fixed, colSpan: cells.length === 0
1050
- ? (s.colSpan || 1) + colCount - isRightExpandable
1051
- : index === summary.length - 1
1052
- ? (s.colSpan || 1) + isRightExpandable
1053
- : s.colSpan }, typeof s.render === 'function'
1054
- ? s.render(dataSource)
1055
- : s.render));
1056
- })
1057
- : null;
1058
- return summary
1059
- ? typeof summary === 'function'
1060
- ? summary(dataSource)
1061
- : __spreadArray([
1062
- cells.length > 0 ? (React__default.createElement("tr", { onMouseEnter: function (e) { return _this.onRowMouseEnter(e); }, onMouseLeave: function (e) { return _this.onRowMouseLeave(e); }, key: "summary-row", className: cx('Table-summary-row') }, cells)) : null
1063
- ], __read(trs), false)
1064
- : null;
695
+ var _a = this.props, cx = _a.classnames, classPrefix = _a.classPrefix;
696
+ if (typeof summary === 'function') {
697
+ return summary(this.state.dataSource);
698
+ }
699
+ if (React__default.isValidElement(summary)) {
700
+ return summary;
701
+ }
702
+ return (React__default.createElement(SummaryRows, { summary: summary, colCount: this.getExtraColumnCount(), isRightExpandable: this.isRightExpandable(), classnames: cx, classPrefix: classPrefix, dataSource: this.state.dataSource, onMouseEnter: this.onRowMouseEnter, onMouseLeave: this.onRowMouseLeave }));
1065
703
  };
1066
- Table.prototype.renderTFoot = function () {
704
+ Table.prototype.renderFoot = function () {
1067
705
  var _a = this.props, cx = _a.classnames, footSummary = _a.footSummary;
1068
- return (React__default.createElement("tfoot", { ref: this.tfootDom, className: cx('Table-summary') }, this.renderSummaryRow(footSummary)));
706
+ return (React__default.createElement("tfoot", { className: cx('Table-summary') }, this.renderSummaryRow(footSummary)));
1069
707
  };
1070
708
  Table.prototype.updateTableDom = function (dom) {
1071
709
  var cx = this.props.classnames;
@@ -1117,15 +755,15 @@ var Table = /** @class */ (function (_super) {
1117
755
  var tableStyle = hasScrollX
1118
756
  ? { width: scroll.x + 'px', tableLayout: 'fixed' }
1119
757
  : {};
1120
- return (React__default.createElement("div", { ref: this.contentDom, className: cx('Table-content'), style: hasScrollX ? { overflow: 'auto hidden' } : {}, onMouseLeave: this.onMouseLeave.bind(this), onScroll: this.onTableContentScroll.bind(this) },
758
+ return (React__default.createElement("div", { ref: this.contentDom, className: cx('Table-content'), style: hasScrollX ? { overflow: 'auto hidden' } : {}, onMouseLeave: this.onMouseLeave, onScroll: this.onTableContentScroll.bind(this) },
1121
759
  itemActions && hoverRow ? (React__default.createElement(ItemActionsWrapper, { dom: hoverRow.target, classnames: cx }, typeof itemActions === 'function'
1122
760
  ? itemActions(hoverRow.record, hoverRow.rowIndex)
1123
761
  : null)) : null,
1124
762
  React__default.createElement("table", { style: __assign(__assign({}, tableStyle), { tableLayout: tableLayout === 'fixed' ? 'fixed' : 'auto' }), className: cx('Table-table') },
1125
763
  this.renderColGroup(),
1126
- showHeader ? this.renderTHead() : null,
1127
- this.renderTBody(),
1128
- footSummary ? this.renderTFoot() : null)));
764
+ showHeader ? this.renderHead() : null,
765
+ this.renderBody(),
766
+ footSummary ? this.renderFoot() : null)));
1129
767
  };
1130
768
  Table.prototype.renderScrollTableHeader = function () {
1131
769
  var _a;
@@ -1145,7 +783,7 @@ var Table = /** @class */ (function (_super) {
1145
783
  _a)), style: style },
1146
784
  React__default.createElement("table", { className: cx('Table-table'), style: __assign(__assign({}, tableStyle), { tableLayout: 'fixed' }) },
1147
785
  this.renderColGroup(true),
1148
- showHeader ? this.renderTHead() : null,
786
+ showHeader ? this.renderHead() : null,
1149
787
  headSummary ? (React__default.createElement("tbody", null, this.renderSummaryRow(headSummary))) : null)));
1150
788
  };
1151
789
  Table.prototype.renderScrollTableBody = function () {
@@ -1162,22 +800,22 @@ var Table = /** @class */ (function (_super) {
1162
800
  });
1163
801
  }
1164
802
  var hoverRow = this.state.hoverRow;
1165
- return (React__default.createElement("div", { ref: this.contentDom, className: cx('Table-body'), style: style, onMouseLeave: this.onMouseLeave.bind(this), onScroll: this.onTableScroll.bind(this) },
803
+ return (React__default.createElement("div", { ref: this.contentDom, className: cx('Table-body'), style: style, onMouseLeave: this.onMouseLeave, onScroll: this.onTableScroll },
1166
804
  itemActions && hoverRow ? (React__default.createElement(ItemActionsWrapper, { dom: hoverRow.target, classnames: cx }, typeof itemActions === 'function'
1167
805
  ? itemActions(hoverRow.record, hoverRow.rowIndex)
1168
806
  : null)) : null,
1169
807
  React__default.createElement("table", { className: cx('Table-table'), style: __assign(__assign({}, tableStyle), { tableLayout: 'fixed' }) },
1170
808
  this.renderColGroup(),
1171
- this.renderTBody())));
809
+ this.renderBody())));
1172
810
  };
1173
811
  Table.prototype.renderScrollTableFoot = function () {
1174
812
  var _a = this.props, scroll = _a.scroll, cx = _a.classnames;
1175
813
  return (React__default.createElement("div", { ref: this.footDom, className: cx('Table-summary'), style: { overflow: 'hidden' } },
1176
- React__default.createElement("table", { className: cx('Table-table'), style: { width: (scroll === null || scroll === void 0 ? void 0 : scroll.x) + 'px' || '100%', tableLayout: 'fixed' } }, this.renderTFoot())));
814
+ React__default.createElement("table", { className: cx('Table-table'), style: { width: (scroll === null || scroll === void 0 ? void 0 : scroll.x) + 'px' || '100%', tableLayout: 'fixed' } }, this.renderFoot())));
1177
815
  };
1178
816
  Table.prototype.renderScrollTable = function () {
1179
817
  var _a = this.props, footSummary = _a.footSummary, cx = _a.classnames;
1180
- return (React__default.createElement("div", { className: cx('Table-container') },
818
+ return (React__default.createElement("div", { className: cx('Table-container'), ref: this.containerDom },
1181
819
  this.renderScrollTableHeader(),
1182
820
  this.renderScrollTableBody(),
1183
821
  footSummary ? this.renderScrollTableFoot() : null));
@@ -1209,15 +847,19 @@ var Table = /** @class */ (function (_super) {
1209
847
  };
1210
848
  Table.prototype.initTableWidth = function () {
1211
849
  var _this = this;
1212
- var _a;
1213
850
  var tableWrapperDom = this.contentDom.current;
1214
851
  if (!tableWrapperDom) {
1215
852
  return;
1216
853
  }
1217
- var _b = this.props, scroll = _b.scroll, tableLayout = _b.tableLayout;
854
+ var _a = this.props, scroll = _a.scroll, tableLayout = _a.tableLayout;
1218
855
  var table = tableWrapperDom.querySelector('table');
856
+ var thead = tableWrapperDom.querySelector('thead');
857
+ if (!thead) {
858
+ if (this.headerDom.current) {
859
+ thead = this.headerDom.current.querySelector('thead');
860
+ }
861
+ }
1219
862
  var tableWidth = scroll && scroll.x ? scroll.x : tableWrapperDom.offsetWidth;
1220
- var thead = (_a = this.theadDom) === null || _a === void 0 ? void 0 : _a.current;
1221
863
  var tbody = null;
1222
864
  var htmls = [];
1223
865
  var isFixed = tableLayout === 'fixed' || (scroll && scroll.x);
@@ -1295,16 +937,15 @@ var Table = /** @class */ (function (_super) {
1295
937
  if (this.resizeTarget) {
1296
938
  return;
1297
939
  }
940
+ this.syncTableWidth();
1298
941
  this.initTableWidth();
1299
942
  };
1300
943
  Table.prototype.render = function () {
1301
944
  var _a;
1302
945
  var _b = this.props, title = _b.title, footer = _b.footer, className = _b.className, scroll = _b.scroll, size = _b.size, bordered = _b.bordered, resizable = _b.resizable, columns = _b.columns, sticky = _b.sticky, cx = _b.classnames;
1303
- // 过滤掉设置了breakpoint属性的列
1304
- var filterColumns = columns.filter(function (item) { return !item.breakpoint || !isBreakpoint(item.breakpoint); });
1305
- this.thColumns = [];
1306
- this.tdColumns = [];
1307
- buildColumns(filterColumns, this.thColumns, this.tdColumns, getMaxLevelThRowSpan(filterColumns));
946
+ var _c = getBuildColumns(columns), thColumns = _c.thColumns, tdColumns = _c.tdColumns;
947
+ this.thColumns = thColumns;
948
+ this.tdColumns = tdColumns;
1308
949
  // 是否设置了纵向滚动
1309
950
  var hasScrollY = scroll && scroll.y;
1310
951
  // 是否设置了横向滚动
@@ -1316,7 +957,7 @@ var Table = /** @class */ (function (_super) {
1316
957
  _a[cx('Table-resizable')] = resizable,
1317
958
  _a)) },
1318
959
  title ? (React__default.createElement("div", { className: cx('Table-title') }, typeof title === 'function' ? title() : title)) : null,
1319
- hasScrollY || sticky ? (this.renderScrollTable()) : (React__default.createElement("div", { className: cx('Table-container') }, this.renderTable())),
960
+ hasScrollY || sticky ? (this.renderScrollTable()) : (React__default.createElement("div", { className: cx('Table-container'), ref: this.containerDom }, this.renderTable())),
1320
961
  footer ? (React__default.createElement("div", { className: cx('Table-footer') }, typeof footer === 'function' ? footer() : footer)) : null));
1321
962
  };
1322
963
  Table.defaultProps = {
@@ -1335,6 +976,12 @@ var Table = /** @class */ (function (_super) {
1335
976
  __metadata("design:paramtypes", []),
1336
977
  __metadata("design:returntype", void 0)
1337
978
  ], Table.prototype, "getPopOverContainer", null);
979
+ __decorate([
980
+ autobind,
981
+ __metadata("design:type", Function),
982
+ __metadata("design:paramtypes", []),
983
+ __metadata("design:returntype", void 0)
984
+ ], Table.prototype, "updateAutoFillHeight", null);
1338
985
  __decorate([
1339
986
  autobind,
1340
987
  __metadata("design:type", Function),
@@ -1347,6 +994,60 @@ var Table = /** @class */ (function (_super) {
1347
994
  __metadata("design:paramtypes", [MouseEvent]),
1348
995
  __metadata("design:returntype", void 0)
1349
996
  ], Table.prototype, "onResizeMouseUp", null);
997
+ __decorate([
998
+ autobind,
999
+ __metadata("design:type", Function),
1000
+ __metadata("design:paramtypes", [Object, Object, Number]),
1001
+ __metadata("design:returntype", Promise)
1002
+ ], Table.prototype, "onRowClick", null);
1003
+ __decorate([
1004
+ autobind,
1005
+ __metadata("design:type", Function),
1006
+ __metadata("design:paramtypes", [Object, Object, Number]),
1007
+ __metadata("design:returntype", Promise)
1008
+ ], Table.prototype, "onRowDbClick", null);
1009
+ __decorate([
1010
+ autobind,
1011
+ __metadata("design:type", Function),
1012
+ __metadata("design:paramtypes", [Object, Object, Number]),
1013
+ __metadata("design:returntype", Promise)
1014
+ ], Table.prototype, "onRowMouseEnter", null);
1015
+ __decorate([
1016
+ autobind,
1017
+ __metadata("design:type", Function),
1018
+ __metadata("design:paramtypes", [Object, Object, Number]),
1019
+ __metadata("design:returntype", Promise)
1020
+ ], Table.prototype, "onRowMouseLeave", null);
1021
+ __decorate([
1022
+ autobind,
1023
+ __metadata("design:type", Function),
1024
+ __metadata("design:paramtypes", []),
1025
+ __metadata("design:returntype", void 0)
1026
+ ], Table.prototype, "onMouseLeave", null);
1027
+ __decorate([
1028
+ autobind,
1029
+ __metadata("design:type", Function),
1030
+ __metadata("design:paramtypes", [Array]),
1031
+ __metadata("design:returntype", void 0)
1032
+ ], Table.prototype, "onExpandRows", null);
1033
+ __decorate([
1034
+ autobind,
1035
+ __metadata("design:type", Function),
1036
+ __metadata("design:paramtypes", [Array]),
1037
+ __metadata("design:returntype", void 0)
1038
+ ], Table.prototype, "onCollapseRows", null);
1039
+ __decorate([
1040
+ autobind,
1041
+ __metadata("design:type", Function),
1042
+ __metadata("design:paramtypes", [Boolean, Object]),
1043
+ __metadata("design:returntype", void 0)
1044
+ ], Table.prototype, "onRowChange", null);
1045
+ __decorate([
1046
+ autobind,
1047
+ __metadata("design:type", Function),
1048
+ __metadata("design:paramtypes", [Object]),
1049
+ __metadata("design:returntype", void 0)
1050
+ ], Table.prototype, "onTableScroll", null);
1350
1051
  __decorate([
1351
1052
  autobind,
1352
1053
  __metadata("design:type", Function),
@@ -1369,4 +1070,4 @@ var Table = /** @class */ (function (_super) {
1369
1070
  }(React__default.PureComponent));
1370
1071
  var index = themeable(localeable(Table));
1371
1072
 
1372
- export { Table, index as default };
1073
+ export { DefaultCellWidth, Table, index as default };