@ant-design/pro-components 3.1.0-0 → 3.1.1-1

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/README.es-PR.md +1 -3
  2. package/README.md +8 -10
  3. package/README.zh-CN.md +11 -11
  4. package/dist/pro-components.min.js +1 -1
  5. package/es/card/ProCard.js +8 -10
  6. package/es/card/components/Actions/index.js +25 -25
  7. package/es/card/components/Actions/style.js +79 -71
  8. package/es/card/components/Card/index.js +157 -142
  9. package/es/card/components/Card/style.js +249 -192
  10. package/es/card/components/CheckCard/Group.js +94 -115
  11. package/es/card/components/CheckCard/index.js +85 -79
  12. package/es/card/components/CheckCard/style.js +184 -168
  13. package/es/card/components/Divider/index.js +19 -15
  14. package/es/card/components/Divider/style.js +32 -29
  15. package/es/card/components/Loading/index.js +19 -16
  16. package/es/card/components/Loading/style.js +34 -31
  17. package/es/card/components/Operation/index.js +16 -13
  18. package/es/card/components/Operation/style.js +19 -18
  19. package/es/card/components/Statistic/index.js +46 -41
  20. package/es/card/components/Statistic/style.js +89 -70
  21. package/es/card/components/StatisticCard/index.js +46 -41
  22. package/es/card/components/StatisticCard/style.js +37 -35
  23. package/es/descriptions/index.js +214 -225
  24. package/es/descriptions/useFetchData.js +53 -91
  25. package/es/field/AllProField.js +265 -216
  26. package/es/field/FieldHOC/index.js +9 -14
  27. package/es/field/PureProField.js +82 -80
  28. package/es/field/ValueTypeToComponent.js +517 -618
  29. package/es/field/components/Cascader/index.d.ts +3 -3
  30. package/es/field/components/Cascader/index.js +66 -84
  31. package/es/field/components/Checkbox/index.d.ts +2 -2
  32. package/es/field/components/Checkbox/index.js +75 -72
  33. package/es/field/components/Code/index.js +40 -39
  34. package/es/field/components/ColorPicker/index.d.ts +2 -2
  35. package/es/field/components/ColorPicker/index.js +38 -32
  36. package/es/field/components/DatePicker/index.d.ts +2 -2
  37. package/es/field/components/DatePicker/index.js +49 -53
  38. package/es/field/components/Digit/index.js +41 -42
  39. package/es/field/components/DigitRange/index.js +71 -77
  40. package/es/field/components/FromNow/index.js +27 -25
  41. package/es/field/components/Image/index.js +28 -24
  42. package/es/field/components/IndexColumn/index.js +22 -16
  43. package/es/field/components/Money/index.js +107 -116
  44. package/es/field/components/Options/index.js +34 -33
  45. package/es/field/components/Password/index.js +35 -38
  46. package/es/field/components/Percent/index.js +40 -44
  47. package/es/field/components/Percent/util.js +3 -5
  48. package/es/field/components/Progress/index.js +29 -27
  49. package/es/field/components/Radio/index.d.ts +1 -1
  50. package/es/field/components/Radio/index.js +61 -62
  51. package/es/field/components/RangePicker/index.d.ts +2 -2
  52. package/es/field/components/RangePicker/index.js +52 -63
  53. package/es/field/components/Rate/index.js +24 -21
  54. package/es/field/components/Second/index.js +36 -33
  55. package/es/field/components/Segmented/index.d.ts +1 -1
  56. package/es/field/components/Segmented/index.js +37 -46
  57. package/es/field/components/Select/LightSelect/index.d.ts +1 -1
  58. package/es/field/components/Select/LightSelect/index.js +102 -109
  59. package/es/field/components/Select/SearchSelect/index.js +129 -155
  60. package/es/field/components/Select/index.d.ts +2 -2
  61. package/es/field/components/Select/index.js +193 -219
  62. package/es/field/components/Slider/index.js +25 -22
  63. package/es/field/components/Status/index.js +67 -78
  64. package/es/field/components/Switch/index.d.ts +1 -1
  65. package/es/field/components/Switch/index.js +32 -30
  66. package/es/field/components/Text/index.js +34 -37
  67. package/es/field/components/TextArea/index.js +26 -21
  68. package/es/field/components/TextArea/readonly.js +24 -21
  69. package/es/field/components/TimePicker/index.js +96 -105
  70. package/es/field/components/TreeSelect/index.d.ts +3 -3
  71. package/es/field/components/TreeSelect/index.js +107 -125
  72. package/es/form/BaseForm/BaseForm.js +416 -502
  73. package/es/form/BaseForm/EditOrReadOnlyContext.js +1 -1
  74. package/es/form/BaseForm/LightWrapper/index.js +56 -65
  75. package/es/form/BaseForm/LightWrapper/style.js +17 -13
  76. package/es/form/BaseForm/Submitter/index.js +44 -43
  77. package/es/form/FieldContext.js +1 -1
  78. package/es/form/components/Captcha/index.js +74 -134
  79. package/es/form/components/Cascader/index.d.ts +1 -1
  80. package/es/form/components/Cascader/index.js +26 -28
  81. package/es/form/components/Checkbox/index.js +60 -61
  82. package/es/form/components/ColorPicker/index.d.ts +1 -1
  83. package/es/form/components/ColorPicker/index.js +24 -26
  84. package/es/form/components/DatePicker/BaseDatePicker.js +32 -30
  85. package/es/form/components/DatePicker/DatePicker.js +14 -13
  86. package/es/form/components/DatePicker/DateTimePicker.js +11 -12
  87. package/es/form/components/DatePicker/MonthPicker.js +14 -13
  88. package/es/form/components/DatePicker/QuarterPicker.js +14 -13
  89. package/es/form/components/DatePicker/TimePicker.js +26 -27
  90. package/es/form/components/DatePicker/WeekPicker.js +14 -13
  91. package/es/form/components/DatePicker/YearPicker.js +14 -13
  92. package/es/form/components/DatePicker/index.js +1 -1
  93. package/es/form/components/DateRangePicker/BaseDateRanger.js +34 -34
  94. package/es/form/components/DateRangePicker/DateMonthRangePicker.js +15 -16
  95. package/es/form/components/DateRangePicker/DateQuarterRangePicker.js +15 -16
  96. package/es/form/components/DateRangePicker/DateTimeRangePicker.js +15 -16
  97. package/es/form/components/DateRangePicker/DateWeekRangePicker.js +15 -16
  98. package/es/form/components/DateRangePicker/DateYearRangePicker.js +15 -16
  99. package/es/form/components/DateRangePicker/TimeRangePicker.js +26 -29
  100. package/es/form/components/DateRangePicker/index.js +15 -16
  101. package/es/form/components/Dependency/index.js +31 -34
  102. package/es/form/components/Digit/DigitRange.d.ts +2 -2
  103. package/es/form/components/Digit/DigitRange.js +23 -24
  104. package/es/form/components/Digit/index.d.ts +1 -1
  105. package/es/form/components/Digit/index.js +27 -29
  106. package/es/form/components/Field/index.js +55 -63
  107. package/es/form/components/FieldSet/index.js +68 -76
  108. package/es/form/components/FormItem/FormItemRender/index.js +58 -48
  109. package/es/form/components/FormItem/Group/index.js +95 -95
  110. package/es/form/components/FormItem/Group/style.js +46 -40
  111. package/es/form/components/FormItem/index.js +135 -141
  112. package/es/form/components/FormItem/warpField.js +165 -149
  113. package/es/form/components/List/ListContainer.js +98 -189
  114. package/es/form/components/List/ListItem.js +151 -198
  115. package/es/form/components/List/index.js +97 -107
  116. package/es/form/components/List/style.js +71 -47
  117. package/es/form/components/Money/index.d.ts +1 -1
  118. package/es/form/components/Money/index.js +28 -30
  119. package/es/form/components/Radio/index.d.ts +2 -2
  120. package/es/form/components/Radio/index.js +45 -49
  121. package/es/form/components/Rate/index.d.ts +1 -1
  122. package/es/form/components/Rate/index.js +17 -20
  123. package/es/form/components/SchemaForm/index.js +58 -72
  124. package/es/form/components/SchemaForm/layoutType/Embed.js +5 -6
  125. package/es/form/components/SchemaForm/layoutType/StepsForm.js +22 -26
  126. package/es/form/components/SchemaForm/valueType/dependency.js +11 -11
  127. package/es/form/components/SchemaForm/valueType/divider.js +4 -5
  128. package/es/form/components/SchemaForm/valueType/field.js +45 -44
  129. package/es/form/components/SchemaForm/valueType/formList.js +8 -7
  130. package/es/form/components/SchemaForm/valueType/formSet.js +8 -7
  131. package/es/form/components/SchemaForm/valueType/group.js +7 -8
  132. package/es/form/components/SchemaForm/valueType/ignore.js +2 -2
  133. package/es/form/components/SchemaForm/valueType/index.js +5 -5
  134. package/es/form/components/Segmented/index.js +20 -23
  135. package/es/form/components/Select/index.js +69 -73
  136. package/es/form/components/Slider/index.d.ts +1 -1
  137. package/es/form/components/Slider/index.js +33 -35
  138. package/es/form/components/Switch/index.js +24 -26
  139. package/es/form/components/Text/index.js +75 -86
  140. package/es/form/components/TextArea/index.d.ts +1 -1
  141. package/es/form/components/TextArea/index.js +17 -20
  142. package/es/form/components/TreeSelect/index.js +20 -23
  143. package/es/form/components/UploadButton/index.js +56 -103
  144. package/es/form/components/UploadDragger/index.js +37 -44
  145. package/es/form/helpers/grid.js +65 -67
  146. package/es/form/layouts/DrawerForm/index.js +150 -241
  147. package/es/form/layouts/DrawerForm/style.js +26 -25
  148. package/es/form/layouts/LightFilter/index.d.ts +12 -1
  149. package/es/form/layouts/LightFilter/index.js +158 -140
  150. package/es/form/layouts/LightFilter/style.js +52 -48
  151. package/es/form/layouts/LoginForm/index.js +44 -47
  152. package/es/form/layouts/LoginForm/style.js +71 -67
  153. package/es/form/layouts/LoginFormPage/index.js +45 -48
  154. package/es/form/layouts/LoginFormPage/style.js +136 -126
  155. package/es/form/layouts/ModalForm/index.js +119 -203
  156. package/es/form/layouts/ProForm/index.d.ts +2 -2
  157. package/es/form/layouts/ProForm/index.js +5 -5
  158. package/es/form/layouts/QueryFilter/Actions.js +23 -22
  159. package/es/form/layouts/QueryFilter/index.js +178 -203
  160. package/es/form/layouts/QueryFilter/style.js +45 -37
  161. package/es/form/layouts/StepsForm/StepForm.d.ts +2 -3
  162. package/es/form/layouts/StepsForm/StepForm.js +50 -71
  163. package/es/form/layouts/StepsForm/index.js +175 -217
  164. package/es/form/layouts/StepsForm/style.js +30 -28
  165. package/es/form/layouts/index.js +1 -1
  166. package/es/layout/ProLayout.js +281 -292
  167. package/es/layout/WrapContent.js +16 -12
  168. package/es/layout/assert/Logo.js +95 -97
  169. package/es/layout/components/AppsLogoComponents/AppsLogo.js +10 -12
  170. package/es/layout/components/AppsLogoComponents/DefaultContent.js +17 -16
  171. package/es/layout/components/AppsLogoComponents/SimpleContent.js +19 -18
  172. package/es/layout/components/AppsLogoComponents/index.js +33 -38
  173. package/es/layout/components/AppsLogoComponents/style/default.js +2 -2
  174. package/es/layout/components/AppsLogoComponents/style/index.js +52 -50
  175. package/es/layout/components/AppsLogoComponents/style/simple.js +1 -1
  176. package/es/layout/components/CollapsedIcon/index.js +18 -15
  177. package/es/layout/components/CollapsedIcon/style.js +40 -40
  178. package/es/layout/components/Footer.js +22 -21
  179. package/es/layout/components/FooterToolbar/index.js +58 -52
  180. package/es/layout/components/FooterToolbar/style/index.js +38 -37
  181. package/es/layout/components/FooterToolbar/style/stylish.js +11 -9
  182. package/es/layout/components/GlobalFooter/index.js +25 -25
  183. package/es/layout/components/GlobalFooter/style.js +31 -30
  184. package/es/layout/components/GlobalHeader/ActionsContent.js +62 -78
  185. package/es/layout/components/GlobalHeader/index.js +59 -47
  186. package/es/layout/components/GlobalHeader/rightContentStyle.js +49 -49
  187. package/es/layout/components/GlobalHeader/style.js +58 -54
  188. package/es/layout/components/GridContent/index.js +24 -19
  189. package/es/layout/components/GridContent/style.js +14 -13
  190. package/es/layout/components/Header/index.js +63 -57
  191. package/es/layout/components/Header/style/header.js +49 -47
  192. package/es/layout/components/Header/style/stylish.js +15 -11
  193. package/es/layout/components/Help/AsyncContentPanel.js +13 -18
  194. package/es/layout/components/Help/HelpProvide.js +1 -1
  195. package/es/layout/components/Help/ProHelpContentPanel.js +64 -83
  196. package/es/layout/components/Help/ProHelpDrawer.js +25 -31
  197. package/es/layout/components/Help/ProHelpModal.d.ts +1 -1
  198. package/es/layout/components/Help/ProHelpModal.js +24 -27
  199. package/es/layout/components/Help/ProHelpPanel.js +86 -94
  200. package/es/layout/components/Help/ProHelpPopover.js +18 -16
  201. package/es/layout/components/Help/RenderContentPanel.js +34 -24
  202. package/es/layout/components/Help/Search.js +52 -78
  203. package/es/layout/components/Help/index.js +9 -11
  204. package/es/layout/components/Help/style.js +82 -75
  205. package/es/layout/components/PageContainer/index.js +168 -149
  206. package/es/layout/components/PageContainer/style/index.js +95 -78
  207. package/es/layout/components/PageContainer/style/stylish.js +11 -9
  208. package/es/layout/components/PageHeader/index.js +96 -97
  209. package/es/layout/components/PageHeader/style/index.js +142 -122
  210. package/es/layout/components/PageLoading/index.js +17 -20
  211. package/es/layout/components/SettingDrawer/BlockCheckbox.js +29 -32
  212. package/es/layout/components/SettingDrawer/LayoutChange.js +22 -22
  213. package/es/layout/components/SettingDrawer/RegionalChange.js +14 -15
  214. package/es/layout/components/SettingDrawer/ThemeColor.js +32 -35
  215. package/es/layout/components/SettingDrawer/index.js +137 -168
  216. package/es/layout/components/SettingDrawer/style/index.js +141 -137
  217. package/es/layout/components/SiderMenu/BaseMenu.js +235 -221
  218. package/es/layout/components/SiderMenu/SiderMenu.js +125 -115
  219. package/es/layout/components/SiderMenu/index.js +47 -42
  220. package/es/layout/components/SiderMenu/style/index.js +179 -161
  221. package/es/layout/components/SiderMenu/style/menu.js +148 -110
  222. package/es/layout/components/SiderMenu/style/stylish.js +15 -11
  223. package/es/layout/components/TopNavHeader/index.js +71 -60
  224. package/es/layout/components/TopNavHeader/style.js +64 -63
  225. package/es/layout/context/RouteContext.js +1 -1
  226. package/es/layout/defaultSettings.js +1 -1
  227. package/es/layout/getPageTitle.js +23 -24
  228. package/es/layout/locales/en-US.js +3 -2
  229. package/es/layout/locales/index.js +5 -5
  230. package/es/layout/locales/it-IT.js +3 -2
  231. package/es/layout/locales/ko-KR.js +3 -2
  232. package/es/layout/locales/zh-CN.js +3 -2
  233. package/es/layout/locales/zh-TW.js +3 -2
  234. package/es/layout/style/index.js +48 -42
  235. package/es/layout/utils/getBreadcrumbProps.js +60 -60
  236. package/es/layout/utils/getMenuData.js +7 -11
  237. package/es/layout/utils/pathTools.js +2 -6
  238. package/es/layout/utils/useCurrentMenuLayoutProps.js +4 -9
  239. package/es/layout/utils/utils.js +15 -17
  240. package/es/list/Item.js +157 -137
  241. package/es/list/ListView.js +106 -115
  242. package/es/list/constants.js +2 -2
  243. package/es/list/index.js +72 -70
  244. package/es/list/style/index.js +281 -213
  245. package/es/provider/index.js +122 -115
  246. package/es/provider/intl.js +53 -55
  247. package/es/provider/typing/layoutToken.js +26 -23
  248. package/es/provider/useStyle/index.js +51 -59
  249. package/es/provider/utils/merge.js +10 -12
  250. package/es/skeleton/components/Descriptions/index.js +211 -229
  251. package/es/skeleton/components/List/index.js +208 -223
  252. package/es/skeleton/components/Result/index.js +45 -47
  253. package/es/skeleton/index.js +13 -10
  254. package/es/table/Store/Provide.d.ts +4 -4
  255. package/es/table/Store/Provide.js +102 -117
  256. package/es/table/Table.d.ts +5 -2
  257. package/es/table/Table.js +526 -691
  258. package/es/table/TableSearch.d.ts +24 -0
  259. package/es/table/TableSearch.js +54 -0
  260. package/es/table/TableToolbar.d.ts +22 -0
  261. package/es/table/TableToolbar.js +47 -0
  262. package/es/table/components/Alert/index.js +41 -40
  263. package/es/table/components/Alert/style.js +28 -27
  264. package/es/table/components/ColumnSetting/index.js +228 -223
  265. package/es/table/components/ColumnSetting/style.js +86 -71
  266. package/es/table/components/DragSortTable/index.js +65 -79
  267. package/es/table/components/DragSortTable/style.js +20 -19
  268. package/es/table/components/Dropdown/index.js +42 -47
  269. package/es/table/components/EditableTable/CellEditorTable.js +24 -32
  270. package/es/table/components/EditableTable/RowEditorTable.js +23 -28
  271. package/es/table/components/EditableTable/index.js +295 -329
  272. package/es/table/components/Form/FormRender.js +99 -103
  273. package/es/table/components/Form/index.d.ts +4 -19
  274. package/es/table/components/Form/index.js +112 -159
  275. package/es/table/components/ListToolBar/HeaderMenu.js +44 -52
  276. package/es/table/components/ListToolBar/index.js +122 -147
  277. package/es/table/components/ListToolBar/style.js +127 -117
  278. package/es/table/components/ToolBar/DensityIcon.js +10 -9
  279. package/es/table/components/ToolBar/FullscreenIcon.js +5 -9
  280. package/es/table/components/ToolBar/index.d.ts +2 -8
  281. package/es/table/components/ToolBar/index.js +155 -195
  282. package/es/table/style/index.js +144 -112
  283. package/es/table/typing.d.ts +4 -0
  284. package/es/table/useFetchData.js +199 -338
  285. package/es/table/utils/cellRenderToFromItem.js +105 -119
  286. package/es/table/utils/columnRender.js +63 -54
  287. package/es/table/utils/columnSort.js +22 -22
  288. package/es/table/utils/genProColumnToColumn.d.ts +13 -9
  289. package/es/table/utils/genProColumnToColumn.js +121 -98
  290. package/es/table/utils/index.d.ts +10 -0
  291. package/es/table/utils/index.js +112 -178
  292. package/es/table/utils/useDragSort.d.ts +1 -1
  293. package/es/table/utils/useDragSort.js +99 -92
  294. package/es/table/utils/usePageInfo.d.ts +6 -0
  295. package/es/table/utils/usePageInfo.js +55 -0
  296. package/es/utils/components/DropdownFooter/index.js +23 -21
  297. package/es/utils/components/DropdownFooter/style.js +16 -15
  298. package/es/utils/components/ErrorBoundary/index.js +27 -50
  299. package/es/utils/components/FieldLabel/index.js +70 -70
  300. package/es/utils/components/FieldLabel/style.js +104 -81
  301. package/es/utils/components/FilterDropdown/index.d.ts +11 -0
  302. package/es/utils/components/FilterDropdown/index.js +43 -32
  303. package/es/utils/components/FilterDropdown/style.js +19 -16
  304. package/es/utils/components/InlineErrorFormItem/index.js +78 -78
  305. package/es/utils/components/InlineErrorFormItem/style.js +56 -49
  306. package/es/utils/components/LabelIconTip/index.js +30 -31
  307. package/es/utils/components/LabelIconTip/style.js +36 -35
  308. package/es/utils/components/ProFormContext/index.js +1 -1
  309. package/es/utils/conversionMomentValue/index.js +19 -22
  310. package/es/utils/dateArrayFormatter/index.js +9 -14
  311. package/es/utils/genCopyable/index.js +74 -32
  312. package/es/utils/getFieldPropsOrFormItemProps/index.js +1 -1
  313. package/es/utils/hooks/useDebounceFn/index.js +18 -51
  314. package/es/utils/hooks/useDebounceValue/index.js +7 -16
  315. package/es/utils/hooks/useDeepCompareEffect/index.js +6 -18
  316. package/es/utils/hooks/useDocumentTitle/index.js +2 -2
  317. package/es/utils/hooks/useFetchData/index.js +36 -65
  318. package/es/utils/hooks/useForceRender/index.js +2 -9
  319. package/es/utils/hooks/useLatest/index.js +2 -2
  320. package/es/utils/hooks/usePrevious/index.js +3 -3
  321. package/es/utils/hooks/useReactiveRef/index.js +2 -2
  322. package/es/utils/hooks/useRefCallback/index.js +3 -3
  323. package/es/utils/hooks/useRefFunction/index.js +4 -9
  324. package/es/utils/index.d.ts +1 -2
  325. package/es/utils/index.js +1 -2
  326. package/es/utils/isBrowser/index.js +2 -2
  327. package/es/utils/isDeepEqualReact/index.js +9 -44
  328. package/es/utils/isDropdownValueType/index.js +2 -2
  329. package/es/utils/isNil/index.js +1 -3
  330. package/es/utils/isUrl/index.js +2 -2
  331. package/es/utils/merge/index.js +10 -12
  332. package/es/utils/nanoid/index.js +5 -6
  333. package/es/utils/omitBoolean/index.js +1 -1
  334. package/es/utils/omitUndefined/index.js +3 -3
  335. package/es/utils/omitUndefinedAndEmptyArr/index.js +4 -5
  336. package/es/utils/parseValueToMoment/index.js +3 -7
  337. package/es/utils/pickProFormItemProps/index.js +3 -3
  338. package/es/utils/pickProProps/index.js +6 -7
  339. package/es/utils/proFieldParsingText/index.js +85 -98
  340. package/es/utils/runFunction/index.js +2 -5
  341. package/es/utils/stringify/index.js +1 -1
  342. package/es/utils/transformKeySubmitValue/index.js +99 -116
  343. package/es/utils/useEditableArray/index.d.ts +6 -1
  344. package/es/utils/useEditableArray/index.js +579 -735
  345. package/es/utils/useEditableMap/index.d.ts +1 -1
  346. package/es/utils/useEditableMap/index.js +89 -135
  347. package/es/utils/useMediaQuery/index.d.ts +2 -2
  348. package/es/utils/useMediaQuery/index.js +37 -34
  349. package/es/utils/useMediaQuery/query.js +7 -17
  350. package/es/version.js +1 -1
  351. package/guidelines/Guidelines.md +33 -0
  352. package/guidelines/components/drawer-form.md +90 -0
  353. package/guidelines/components/editable-pro-table.md +150 -0
  354. package/guidelines/components/modal-form.md +88 -0
  355. package/guidelines/components/pro-card.md +90 -0
  356. package/guidelines/components/pro-form.md +96 -0
  357. package/guidelines/components/pro-layout.md +84 -0
  358. package/guidelines/components/pro-table.md +142 -0
  359. package/guidelines/components/steps-form.md +105 -0
  360. package/guidelines/design-tokens/colors.md +58 -0
  361. package/guidelines/design-tokens/layout.md +53 -0
  362. package/guidelines/design-tokens/typography.md +49 -0
  363. package/guidelines/overview-components.md +55 -0
  364. package/guidelines/overview-icons.md +23 -0
  365. package/lib/card/ProCard.js +8 -10
  366. package/lib/card/components/Actions/index.js +25 -25
  367. package/lib/card/components/Actions/style.js +79 -72
  368. package/lib/card/components/Card/index.js +154 -139
  369. package/lib/card/components/Card/style.js +249 -193
  370. package/lib/card/components/CheckCard/Group.js +97 -115
  371. package/lib/card/components/CheckCard/index.js +85 -78
  372. package/lib/card/components/CheckCard/style.js +184 -169
  373. package/lib/card/components/Divider/index.js +20 -16
  374. package/lib/card/components/Divider/style.js +32 -30
  375. package/lib/card/components/Loading/index.js +19 -16
  376. package/lib/card/components/Loading/style.js +34 -32
  377. package/lib/card/components/Operation/index.js +16 -14
  378. package/lib/card/components/Operation/style.js +19 -19
  379. package/lib/card/components/Statistic/index.js +46 -42
  380. package/lib/card/components/Statistic/style.js +89 -71
  381. package/lib/card/components/StatisticCard/index.js +46 -41
  382. package/lib/card/components/StatisticCard/style.js +37 -36
  383. package/lib/card/index.js +4 -4
  384. package/lib/descriptions/index.js +219 -225
  385. package/lib/descriptions/useFetchData.js +51 -90
  386. package/lib/field/AllProField.js +267 -217
  387. package/lib/field/FieldHOC/index.js +9 -15
  388. package/lib/field/PureProField.js +84 -82
  389. package/lib/field/ValueTypeToComponent.js +517 -618
  390. package/lib/field/components/Cascader/index.d.ts +2 -2
  391. package/lib/field/components/Cascader/index.js +66 -85
  392. package/lib/field/components/Checkbox/index.d.ts +1 -1
  393. package/lib/field/components/Checkbox/index.js +75 -73
  394. package/lib/field/components/Code/index.js +40 -39
  395. package/lib/field/components/ColorPicker/index.js +38 -33
  396. package/lib/field/components/DatePicker/index.d.ts +1 -1
  397. package/lib/field/components/DatePicker/index.js +49 -53
  398. package/lib/field/components/Digit/index.js +41 -43
  399. package/lib/field/components/DigitRange/index.js +69 -76
  400. package/lib/field/components/FromNow/index.js +27 -25
  401. package/lib/field/components/Image/index.js +28 -24
  402. package/lib/field/components/IndexColumn/index.js +22 -17
  403. package/lib/field/components/Money/index.js +106 -116
  404. package/lib/field/components/Options/index.js +34 -34
  405. package/lib/field/components/Password/index.js +35 -38
  406. package/lib/field/components/Percent/index.js +40 -45
  407. package/lib/field/components/Percent/util.js +3 -6
  408. package/lib/field/components/Progress/index.js +29 -28
  409. package/lib/field/components/Radio/index.d.ts +1 -1
  410. package/lib/field/components/Radio/index.js +61 -63
  411. package/lib/field/components/RangePicker/index.d.ts +1 -1
  412. package/lib/field/components/RangePicker/index.js +52 -63
  413. package/lib/field/components/Rate/index.js +24 -21
  414. package/lib/field/components/Second/index.js +36 -33
  415. package/lib/field/components/Segmented/index.d.ts +1 -1
  416. package/lib/field/components/Segmented/index.js +37 -48
  417. package/lib/field/components/Select/LightSelect/index.d.ts +1 -1
  418. package/lib/field/components/Select/LightSelect/index.js +103 -110
  419. package/lib/field/components/Select/SearchSelect/index.js +133 -156
  420. package/lib/field/components/Select/index.d.ts +1 -1
  421. package/lib/field/components/Select/index.js +194 -218
  422. package/lib/field/components/Slider/index.js +25 -22
  423. package/lib/field/components/Status/index.js +69 -79
  424. package/lib/field/components/Switch/index.d.ts +1 -1
  425. package/lib/field/components/Switch/index.js +32 -31
  426. package/lib/field/components/Text/index.js +34 -38
  427. package/lib/field/components/TextArea/index.js +26 -21
  428. package/lib/field/components/TextArea/readonly.js +24 -22
  429. package/lib/field/components/TimePicker/index.js +96 -105
  430. package/lib/field/components/TreeSelect/index.d.ts +2 -2
  431. package/lib/field/components/TreeSelect/index.js +105 -124
  432. package/lib/field/index.js +34 -34
  433. package/lib/form/BaseForm/BaseForm.js +413 -499
  434. package/lib/form/BaseForm/EditOrReadOnlyContext.js +1 -1
  435. package/lib/form/BaseForm/LightWrapper/index.js +57 -66
  436. package/lib/form/BaseForm/LightWrapper/style.js +17 -14
  437. package/lib/form/BaseForm/Submitter/index.js +44 -44
  438. package/lib/form/BaseForm/index.js +3 -3
  439. package/lib/form/FieldContext.js +1 -1
  440. package/lib/form/components/Captcha/index.js +74 -135
  441. package/lib/form/components/Cascader/index.js +26 -29
  442. package/lib/form/components/Checkbox/index.js +60 -61
  443. package/lib/form/components/ColorPicker/index.js +24 -26
  444. package/lib/form/components/DatePicker/BaseDatePicker.js +32 -30
  445. package/lib/form/components/DatePicker/DatePicker.js +14 -13
  446. package/lib/form/components/DatePicker/DateTimePicker.js +11 -12
  447. package/lib/form/components/DatePicker/MonthPicker.js +14 -13
  448. package/lib/form/components/DatePicker/QuarterPicker.js +14 -13
  449. package/lib/form/components/DatePicker/TimePicker.js +26 -27
  450. package/lib/form/components/DatePicker/WeekPicker.js +14 -13
  451. package/lib/form/components/DatePicker/YearPicker.js +14 -13
  452. package/lib/form/components/DatePicker/index.js +1 -1
  453. package/lib/form/components/DateRangePicker/BaseDateRanger.js +34 -34
  454. package/lib/form/components/DateRangePicker/DateMonthRangePicker.js +15 -16
  455. package/lib/form/components/DateRangePicker/DateQuarterRangePicker.js +15 -16
  456. package/lib/form/components/DateRangePicker/DateTimeRangePicker.js +15 -16
  457. package/lib/form/components/DateRangePicker/DateWeekRangePicker.js +15 -16
  458. package/lib/form/components/DateRangePicker/DateYearRangePicker.js +15 -16
  459. package/lib/form/components/DateRangePicker/TimeRangePicker.js +26 -29
  460. package/lib/form/components/DateRangePicker/index.js +15 -16
  461. package/lib/form/components/Dependency/index.js +31 -35
  462. package/lib/form/components/Digit/DigitRange.js +23 -24
  463. package/lib/form/components/Digit/index.js +27 -29
  464. package/lib/form/components/Field/index.js +55 -63
  465. package/lib/form/components/FieldSet/index.js +68 -76
  466. package/lib/form/components/FormItem/FormItemRender/index.js +58 -48
  467. package/lib/form/components/FormItem/Group/index.js +95 -95
  468. package/lib/form/components/FormItem/Group/style.js +46 -41
  469. package/lib/form/components/FormItem/index.js +135 -141
  470. package/lib/form/components/FormItem/warpField.js +165 -149
  471. package/lib/form/components/List/ListContainer.js +100 -191
  472. package/lib/form/components/List/ListItem.js +153 -200
  473. package/lib/form/components/List/index.js +97 -107
  474. package/lib/form/components/List/style.js +71 -48
  475. package/lib/form/components/Money/index.js +28 -30
  476. package/lib/form/components/Radio/index.js +45 -49
  477. package/lib/form/components/Rate/index.js +17 -21
  478. package/lib/form/components/SchemaForm/index.js +54 -68
  479. package/lib/form/components/SchemaForm/layoutType/Embed.js +5 -6
  480. package/lib/form/components/SchemaForm/layoutType/StepsForm.js +22 -26
  481. package/lib/form/components/SchemaForm/layoutType/index.js +2 -2
  482. package/lib/form/components/SchemaForm/valueType/dependency.js +13 -12
  483. package/lib/form/components/SchemaForm/valueType/divider.js +6 -7
  484. package/lib/form/components/SchemaForm/valueType/field.js +47 -45
  485. package/lib/form/components/SchemaForm/valueType/formList.js +10 -9
  486. package/lib/form/components/SchemaForm/valueType/formSet.js +10 -8
  487. package/lib/form/components/SchemaForm/valueType/group.js +9 -10
  488. package/lib/form/components/SchemaForm/valueType/ignore.js +4 -3
  489. package/lib/form/components/SchemaForm/valueType/index.js +7 -6
  490. package/lib/form/components/Segmented/index.js +20 -24
  491. package/lib/form/components/Select/index.js +69 -73
  492. package/lib/form/components/Slider/index.js +33 -35
  493. package/lib/form/components/Switch/index.js +24 -26
  494. package/lib/form/components/Text/index.js +73 -84
  495. package/lib/form/components/TextArea/index.js +17 -21
  496. package/lib/form/components/TreeSelect/index.js +20 -23
  497. package/lib/form/components/UploadButton/index.js +56 -103
  498. package/lib/form/components/UploadDragger/index.js +37 -44
  499. package/lib/form/components/index.js +42 -42
  500. package/lib/form/helpers/grid.js +68 -69
  501. package/lib/form/helpers/index.js +1 -1
  502. package/lib/form/index.js +8 -8
  503. package/lib/form/layouts/DrawerForm/index.js +149 -241
  504. package/lib/form/layouts/DrawerForm/style.js +26 -26
  505. package/lib/form/layouts/LightFilter/index.d.ts +12 -1
  506. package/lib/form/layouts/LightFilter/index.js +158 -141
  507. package/lib/form/layouts/LightFilter/style.js +52 -49
  508. package/lib/form/layouts/LoginForm/index.js +44 -48
  509. package/lib/form/layouts/LoginForm/style.js +71 -68
  510. package/lib/form/layouts/LoginFormPage/index.js +45 -49
  511. package/lib/form/layouts/LoginFormPage/style.js +136 -127
  512. package/lib/form/layouts/ModalForm/index.js +118 -203
  513. package/lib/form/layouts/ProForm/index.d.ts +1 -1
  514. package/lib/form/layouts/ProForm/index.js +5 -5
  515. package/lib/form/layouts/QueryFilter/Actions.js +23 -22
  516. package/lib/form/layouts/QueryFilter/index.js +177 -202
  517. package/lib/form/layouts/QueryFilter/style.js +45 -38
  518. package/lib/form/layouts/StepsForm/StepForm.d.ts +2 -3
  519. package/lib/form/layouts/StepsForm/StepForm.js +50 -72
  520. package/lib/form/layouts/StepsForm/index.js +174 -216
  521. package/lib/form/layouts/StepsForm/style.js +30 -29
  522. package/lib/form/layouts/index.js +9 -9
  523. package/lib/index.js +11 -11
  524. package/lib/layout/ProLayout.js +281 -292
  525. package/lib/layout/WrapContent.js +18 -14
  526. package/lib/layout/assert/Logo.js +96 -97
  527. package/lib/layout/components/AppsLogoComponents/AppsLogo.js +11 -12
  528. package/lib/layout/components/AppsLogoComponents/DefaultContent.js +19 -17
  529. package/lib/layout/components/AppsLogoComponents/SimpleContent.js +22 -19
  530. package/lib/layout/components/AppsLogoComponents/index.js +36 -40
  531. package/lib/layout/components/AppsLogoComponents/style/default.js +4 -3
  532. package/lib/layout/components/AppsLogoComponents/style/index.js +52 -51
  533. package/lib/layout/components/AppsLogoComponents/style/simple.js +3 -2
  534. package/lib/layout/components/CollapsedIcon/index.js +20 -17
  535. package/lib/layout/components/CollapsedIcon/style.js +40 -41
  536. package/lib/layout/components/Footer.js +23 -22
  537. package/lib/layout/components/FooterToolbar/index.js +59 -53
  538. package/lib/layout/components/FooterToolbar/style/index.js +38 -38
  539. package/lib/layout/components/FooterToolbar/style/stylish.js +11 -10
  540. package/lib/layout/components/GlobalFooter/index.js +27 -27
  541. package/lib/layout/components/GlobalFooter/style.js +31 -31
  542. package/lib/layout/components/GlobalHeader/ActionsContent.js +65 -81
  543. package/lib/layout/components/GlobalHeader/index.js +61 -49
  544. package/lib/layout/components/GlobalHeader/rightContentStyle.js +49 -50
  545. package/lib/layout/components/GlobalHeader/style.js +58 -55
  546. package/lib/layout/components/GridContent/index.js +26 -21
  547. package/lib/layout/components/GridContent/style.js +14 -14
  548. package/lib/layout/components/Header/index.js +65 -59
  549. package/lib/layout/components/Header/style/header.js +49 -48
  550. package/lib/layout/components/Header/style/stylish.js +15 -12
  551. package/lib/layout/components/Help/AsyncContentPanel.js +15 -20
  552. package/lib/layout/components/Help/HelpProvide.js +1 -1
  553. package/lib/layout/components/Help/ProHelpContentPanel.js +66 -85
  554. package/lib/layout/components/Help/ProHelpDrawer.js +27 -32
  555. package/lib/layout/components/Help/ProHelpModal.d.ts +1 -1
  556. package/lib/layout/components/Help/ProHelpModal.js +26 -28
  557. package/lib/layout/components/Help/ProHelpPanel.js +86 -94
  558. package/lib/layout/components/Help/ProHelpPopover.js +20 -18
  559. package/lib/layout/components/Help/RenderContentPanel.js +36 -26
  560. package/lib/layout/components/Help/Search.js +55 -80
  561. package/lib/layout/components/Help/index.js +19 -20
  562. package/lib/layout/components/Help/style.js +82 -76
  563. package/lib/layout/components/PageContainer/index.js +172 -151
  564. package/lib/layout/components/PageContainer/style/index.js +95 -79
  565. package/lib/layout/components/PageContainer/style/stylish.js +11 -10
  566. package/lib/layout/components/PageHeader/index.js +99 -99
  567. package/lib/layout/components/PageHeader/style/index.js +142 -123
  568. package/lib/layout/components/PageLoading/index.js +18 -20
  569. package/lib/layout/components/SettingDrawer/BlockCheckbox.js +31 -34
  570. package/lib/layout/components/SettingDrawer/LayoutChange.js +25 -23
  571. package/lib/layout/components/SettingDrawer/RegionalChange.js +16 -16
  572. package/lib/layout/components/SettingDrawer/ThemeColor.js +34 -36
  573. package/lib/layout/components/SettingDrawer/index.js +138 -168
  574. package/lib/layout/components/SettingDrawer/style/index.js +141 -138
  575. package/lib/layout/components/SiderMenu/BaseMenu.js +235 -221
  576. package/lib/layout/components/SiderMenu/SiderMenu.js +128 -117
  577. package/lib/layout/components/SiderMenu/index.js +49 -44
  578. package/lib/layout/components/SiderMenu/style/index.js +179 -162
  579. package/lib/layout/components/SiderMenu/style/menu.js +148 -111
  580. package/lib/layout/components/SiderMenu/style/stylish.js +15 -12
  581. package/lib/layout/components/TopNavHeader/index.js +73 -62
  582. package/lib/layout/components/TopNavHeader/style.js +64 -64
  583. package/lib/layout/context/RouteContext.js +1 -1
  584. package/lib/layout/defaultSettings.js +1 -1
  585. package/lib/layout/getPageTitle.js +27 -26
  586. package/lib/layout/index.js +16 -16
  587. package/lib/layout/locales/en-US.js +3 -2
  588. package/lib/layout/locales/index.js +8 -6
  589. package/lib/layout/locales/it-IT.js +3 -2
  590. package/lib/layout/locales/ko-KR.js +3 -2
  591. package/lib/layout/locales/zh-CN.js +3 -2
  592. package/lib/layout/locales/zh-TW.js +3 -2
  593. package/lib/layout/style/index.js +48 -43
  594. package/lib/layout/utils/getBreadcrumbProps.js +65 -62
  595. package/lib/layout/utils/getMenuData.js +9 -13
  596. package/lib/layout/utils/pathTools.js +2 -6
  597. package/lib/layout/utils/useCurrentMenuLayoutProps.js +6 -11
  598. package/lib/layout/utils/utils.js +16 -18
  599. package/lib/list/Item.js +155 -136
  600. package/lib/list/ListView.js +110 -119
  601. package/lib/list/constants.js +2 -2
  602. package/lib/list/index.js +72 -70
  603. package/lib/list/style/index.js +281 -214
  604. package/lib/provider/index.js +128 -118
  605. package/lib/provider/intl.js +56 -56
  606. package/lib/provider/typing/layoutToken.js +28 -25
  607. package/lib/provider/useStyle/index.js +55 -60
  608. package/lib/provider/utils/merge.js +12 -14
  609. package/lib/skeleton/components/Descriptions/index.js +213 -229
  610. package/lib/skeleton/components/List/index.js +211 -221
  611. package/lib/skeleton/components/Result/index.js +45 -47
  612. package/lib/skeleton/index.js +23 -19
  613. package/lib/table/Store/Provide.d.ts +4 -4
  614. package/lib/table/Store/Provide.js +103 -117
  615. package/lib/table/Table.d.ts +5 -2
  616. package/lib/table/Table.js +524 -689
  617. package/lib/table/TableSearch.d.ts +24 -0
  618. package/lib/table/TableSearch.js +61 -0
  619. package/lib/table/TableToolbar.d.ts +22 -0
  620. package/lib/table/TableToolbar.js +55 -0
  621. package/lib/table/components/Alert/index.js +41 -40
  622. package/lib/table/components/Alert/style.js +28 -28
  623. package/lib/table/components/ColumnSetting/index.js +228 -224
  624. package/lib/table/components/ColumnSetting/style.js +86 -72
  625. package/lib/table/components/DragSortTable/index.js +64 -78
  626. package/lib/table/components/DragSortTable/style.js +20 -20
  627. package/lib/table/components/Dropdown/index.js +42 -48
  628. package/lib/table/components/EditableTable/CellEditorTable.js +24 -32
  629. package/lib/table/components/EditableTable/RowEditorTable.js +23 -28
  630. package/lib/table/components/EditableTable/index.js +293 -327
  631. package/lib/table/components/Form/FormRender.js +99 -104
  632. package/lib/table/components/Form/index.d.ts +4 -19
  633. package/lib/table/components/Form/index.js +113 -159
  634. package/lib/table/components/ListToolBar/HeaderMenu.js +42 -51
  635. package/lib/table/components/ListToolBar/index.js +123 -148
  636. package/lib/table/components/ListToolBar/style.js +127 -118
  637. package/lib/table/components/ToolBar/DensityIcon.js +10 -9
  638. package/lib/table/components/ToolBar/FullscreenIcon.js +5 -10
  639. package/lib/table/components/ToolBar/index.d.ts +2 -8
  640. package/lib/table/components/ToolBar/index.js +154 -194
  641. package/lib/table/index.js +27 -27
  642. package/lib/table/style/index.js +144 -113
  643. package/lib/table/typing.d.ts +4 -0
  644. package/lib/table/useFetchData.js +197 -337
  645. package/lib/table/utils/cellRenderToFromItem.js +106 -120
  646. package/lib/table/utils/columnRender.js +65 -54
  647. package/lib/table/utils/columnSort.js +24 -23
  648. package/lib/table/utils/genProColumnToColumn.d.ts +13 -9
  649. package/lib/table/utils/genProColumnToColumn.js +121 -99
  650. package/lib/table/utils/index.d.ts +10 -0
  651. package/lib/table/utils/index.js +127 -181
  652. package/lib/table/utils/useDragSort.d.ts +1 -1
  653. package/lib/table/utils/useDragSort.js +99 -93
  654. package/lib/table/utils/usePageInfo.d.ts +6 -0
  655. package/lib/table/utils/usePageInfo.js +61 -0
  656. package/lib/utils/components/DropdownFooter/index.js +25 -23
  657. package/lib/utils/components/DropdownFooter/style.js +16 -16
  658. package/lib/utils/components/ErrorBoundary/index.js +28 -50
  659. package/lib/utils/components/FieldLabel/index.js +70 -71
  660. package/lib/utils/components/FieldLabel/style.js +104 -82
  661. package/lib/utils/components/FilterDropdown/index.d.ts +11 -0
  662. package/lib/utils/components/FilterDropdown/index.js +44 -33
  663. package/lib/utils/components/FilterDropdown/style.js +19 -17
  664. package/lib/utils/components/InlineErrorFormItem/index.js +80 -80
  665. package/lib/utils/components/InlineErrorFormItem/style.js +56 -50
  666. package/lib/utils/components/LabelIconTip/index.js +30 -32
  667. package/lib/utils/components/LabelIconTip/style.js +36 -36
  668. package/lib/utils/components/ProFormContext/index.js +1 -1
  669. package/lib/utils/conversionMomentValue/index.js +22 -23
  670. package/lib/utils/dateArrayFormatter/index.js +11 -15
  671. package/lib/utils/genCopyable/index.js +75 -33
  672. package/lib/utils/getFieldPropsOrFormItemProps/index.js +3 -2
  673. package/lib/utils/hooks/useDebounceFn/index.js +18 -52
  674. package/lib/utils/hooks/useDebounceValue/index.js +7 -17
  675. package/lib/utils/hooks/useDeepCompareEffect/index.js +7 -19
  676. package/lib/utils/hooks/useDocumentTitle/index.js +2 -2
  677. package/lib/utils/hooks/useFetchData/index.js +36 -65
  678. package/lib/utils/hooks/useForceRender/index.js +2 -10
  679. package/lib/utils/hooks/useLatest/index.js +4 -3
  680. package/lib/utils/hooks/usePrevious/index.js +5 -4
  681. package/lib/utils/hooks/useReactiveRef/index.js +2 -2
  682. package/lib/utils/hooks/useRefCallback/index.js +3 -3
  683. package/lib/utils/hooks/useRefFunction/index.js +6 -11
  684. package/lib/utils/index.d.ts +1 -2
  685. package/lib/utils/index.js +57 -65
  686. package/lib/utils/isBrowser/index.js +4 -3
  687. package/lib/utils/isDeepEqualReact/index.js +9 -45
  688. package/lib/utils/isDropdownValueType/index.js +4 -3
  689. package/lib/utils/isNil/index.js +2 -3
  690. package/lib/utils/isUrl/index.js +4 -3
  691. package/lib/utils/merge/index.js +12 -14
  692. package/lib/utils/nanoid/index.js +7 -7
  693. package/lib/utils/omitBoolean/index.js +3 -2
  694. package/lib/utils/omitUndefined/index.js +5 -4
  695. package/lib/utils/omitUndefinedAndEmptyArr/index.js +6 -6
  696. package/lib/utils/parseValueToMoment/index.js +5 -8
  697. package/lib/utils/pickProFormItemProps/index.js +3 -3
  698. package/lib/utils/pickProProps/index.js +6 -7
  699. package/lib/utils/proFieldParsingText/index.js +89 -99
  700. package/lib/utils/runFunction/index.js +2 -5
  701. package/lib/utils/stringify/index.js +2 -2
  702. package/lib/utils/transformKeySubmitValue/index.js +101 -117
  703. package/lib/utils/useEditableArray/index.d.ts +6 -1
  704. package/lib/utils/useEditableArray/index.js +582 -735
  705. package/lib/utils/useEditableMap/index.d.ts +1 -1
  706. package/lib/utils/useEditableMap/index.js +88 -135
  707. package/lib/utils/useMediaQuery/index.js +40 -35
  708. package/lib/utils/useMediaQuery/query.js +7 -18
  709. package/lib/version.js +1 -1
  710. package/package.json +20 -31
  711. package/es/utils/useMountMergeState/index.d.ts +0 -2
  712. package/es/utils/useMountMergeState/index.js +0 -2
  713. package/lib/utils/useMountMergeState/index.d.ts +0 -2
  714. package/lib/utils/useMountMergeState/index.js +0 -12
@@ -1,16 +1,7 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- import _typeof from "@babel/runtime/helpers/esm/typeof";
4
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
6
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
8
- var _excluded = ["record", "position", "creatorButtonText", "newRecordType", "parentKey", "style"],
9
- _excluded2 = ["onTableChange", "maxLength", "formItemProps", "recordCreatorProps", "rowKey", "controlled", "defaultValue", "onChange", "editableFormRef"];
10
1
  import { PlusOutlined } from '@ant-design/icons';
11
- import { get, set, useMergedState } from '@rc-component/util';
2
+ import { get, set, useControlledState } from '@rc-component/util';
12
3
  import { Button, Form } from 'antd';
13
- import React, { useContext, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
4
+ import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
14
5
  import ProForm, { ProFormDependency } from "../../../form";
15
6
  import { useIntl } from "../../../provider";
16
7
  import { isDeepEqualReact, runFunction, useDeepCompareEffect, useRefFunction } from "../../../utils";
@@ -19,71 +10,51 @@ import ProTable from "../../Table";
19
10
  import { jsx as _jsx } from "react/jsx-runtime";
20
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
21
12
  import { Fragment as _Fragment } from "react/jsx-runtime";
22
- var EditableTableActionContext = /*#__PURE__*/React.createContext(undefined);
13
+ const EditableTableActionContext = /*#__PURE__*/React.createContext(undefined);
23
14
 
24
15
  /** 可编辑表格的按钮 */
25
16
  function RecordCreator(props) {
26
- var children = props.children,
27
- record = props.record,
28
- position = props.position,
29
- newRecordType = props.newRecordType,
30
- parentKey = props.parentKey;
31
- var actionRef = useContext(EditableTableActionContext);
32
- return /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), {}, {
33
- onClick: function () {
34
- var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
35
- var _children$props$onCli, _children$props;
36
- var isOk;
37
- return _regeneratorRuntime().wrap(function _callee$(_context) {
38
- while (1) switch (_context.prev = _context.next) {
39
- case 0:
40
- _context.next = 2;
41
- return (_children$props$onCli = (_children$props = children.props).onClick) === null || _children$props$onCli === void 0 ? void 0 : _children$props$onCli.call(_children$props, e);
42
- case 2:
43
- isOk = _context.sent;
44
- if (!(isOk === false)) {
45
- _context.next = 5;
46
- break;
47
- }
48
- return _context.abrupt("return");
49
- case 5:
50
- if (actionRef !== null && actionRef !== void 0 && actionRef.current) {
51
- actionRef.current.addEditRecord(record, {
52
- position: position,
53
- newRecordType: newRecordType,
54
- parentKey: parentKey
55
- });
56
- }
57
- case 6:
58
- case "end":
59
- return _context.stop();
60
- }
61
- }, _callee);
62
- }));
63
- function onClick(_x) {
64
- return _onClick.apply(this, arguments);
17
+ const {
18
+ children,
19
+ record,
20
+ position,
21
+ newRecordType,
22
+ parentKey
23
+ } = props;
24
+ const actionRef = useContext(EditableTableActionContext);
25
+ return /*#__PURE__*/React.cloneElement(children, {
26
+ ...children.props,
27
+ onClick: async e => {
28
+ // 如果返回了false,接触掉默认行为
29
+ const isOk = await children.props.onClick?.(e);
30
+ if (isOk === false) return;
31
+ if (actionRef?.current) {
32
+ actionRef.current.addEditRecord(record, {
33
+ position,
34
+ newRecordType,
35
+ parentKey: parentKey
36
+ });
65
37
  }
66
- return onClick;
67
- }()
68
- }));
38
+ }
39
+ });
69
40
  }
70
41
 
71
42
  /**
72
43
  * 处理嵌套行的新增
73
44
  */
74
45
  function handleNestedRowInsert(baseData, defaultValue, newLineOptions, getRowKey, childrenColumnName) {
75
- var _recordKeyToString;
76
46
  if (!newLineOptions.recordKey) {
77
47
  return baseData;
78
48
  }
79
- var actionProps = {
49
+ const actionProps = {
80
50
  data: baseData,
81
- getRowKey: getRowKey,
82
- row: _objectSpread(_objectSpread({}, defaultValue), {}, {
83
- map_row_parentKey: (_recordKeyToString = recordKeyToString(newLineOptions.parentKey)) === null || _recordKeyToString === void 0 ? void 0 : _recordKeyToString.toString()
84
- }),
51
+ getRowKey,
52
+ row: {
53
+ ...defaultValue,
54
+ map_row_parentKey: recordKeyToString(newLineOptions.parentKey)?.toString()
55
+ },
85
56
  key: newLineOptions.recordKey,
86
- childrenColumnName: childrenColumnName
57
+ childrenColumnName
87
58
  };
88
59
  return editableRowByKey(actionProps, newLineOptions.position === 'top' ? 'top' : 'update');
89
60
  }
@@ -93,39 +64,42 @@ function handleNestedRowInsert(baseData, defaultValue, newLineOptions, getRowKey
93
64
  */
94
65
  function handlePaginationInsert(baseData, defaultValue, pageConfig) {
95
66
  if (pageConfig.pageSize > baseData.length) {
96
- return [].concat(_toConsumableArray(baseData), [defaultValue]);
67
+ return [...baseData, defaultValue];
97
68
  }
98
- var insertIndex = pageConfig.current * pageConfig.pageSize - 1;
99
- var result = _toConsumableArray(baseData);
69
+ const insertIndex = pageConfig.current * pageConfig.pageSize - 1;
70
+ const result = [...baseData];
100
71
  result.splice(insertIndex, 0, defaultValue);
101
72
  return result;
102
73
  }
103
- function useEditableDataSource(_ref) {
104
- var actionDataSource = _ref.actionDataSource,
105
- editableUtils = _ref.editableUtils,
106
- pagination = _ref.pagination,
107
- getRowKey = _ref.getRowKey,
108
- childrenColumnName = _ref.childrenColumnName;
109
- return useMemo(function () {
110
- var newLineConfig = editableUtils === null || editableUtils === void 0 ? void 0 : editableUtils.newLineRecord;
111
- var baseData = Array.isArray(actionDataSource) ? _toConsumableArray(actionDataSource) : [];
112
- if (!(newLineConfig !== null && newLineConfig !== void 0 && newLineConfig.defaultValue)) {
74
+ function useEditableDataSource({
75
+ actionDataSource,
76
+ editableUtils,
77
+ pagination,
78
+ getRowKey,
79
+ childrenColumnName
80
+ }) {
81
+ return useMemo(() => {
82
+ const newLineConfig = editableUtils?.newLineRecord;
83
+ const baseData = Array.isArray(actionDataSource) ? [...actionDataSource] : [];
84
+ if (!newLineConfig?.defaultValue) {
113
85
  return baseData;
114
86
  }
115
- var newLineOptions = newLineConfig.options,
116
- defaultValue = newLineConfig.defaultValue;
117
- if (newLineOptions !== null && newLineOptions !== void 0 && newLineOptions.parentKey) {
87
+ const {
88
+ options: newLineOptions,
89
+ defaultValue
90
+ } = newLineConfig;
91
+ if (newLineOptions?.parentKey) {
118
92
  return handleNestedRowInsert(baseData, defaultValue, newLineOptions, getRowKey, childrenColumnName || 'children');
119
93
  }
120
- if ((newLineOptions === null || newLineOptions === void 0 ? void 0 : newLineOptions.position) === 'top') {
121
- return [defaultValue].concat(_toConsumableArray(baseData));
94
+ if (newLineOptions?.position === 'top') {
95
+ return [defaultValue, ...baseData];
122
96
  }
123
- var pageConfig = pagination && _typeof(pagination) === 'object' ? pagination : undefined;
124
- if (pageConfig !== null && pageConfig !== void 0 && pageConfig.current && pageConfig !== null && pageConfig !== void 0 && pageConfig.pageSize) {
97
+ const pageConfig = pagination && typeof pagination === 'object' ? pagination : undefined;
98
+ if (pageConfig?.current && pageConfig?.pageSize) {
125
99
  return handlePaginationInsert(baseData, defaultValue, pageConfig);
126
100
  }
127
- return [].concat(_toConsumableArray(baseData), [defaultValue]);
128
- }, [actionDataSource, childrenColumnName, editableUtils === null || editableUtils === void 0 ? void 0 : editableUtils.newLineRecord, getRowKey, pagination]);
101
+ return [...baseData, defaultValue];
102
+ }, [actionDataSource, childrenColumnName, editableUtils?.newLineRecord, getRowKey, pagination]);
129
103
  }
130
104
 
131
105
  /**
@@ -142,29 +116,32 @@ function shouldShowCreatorButton(maxLength, valueLength, recordCreatorProps) {
142
116
  * 创建按钮 DOM
143
117
  */
144
118
  function createButtonDom(recordCreatorProps, value, intl) {
145
- var record = recordCreatorProps.record,
146
- position = recordCreatorProps.position,
147
- creatorButtonText = recordCreatorProps.creatorButtonText,
148
- newRecordType = recordCreatorProps.newRecordType,
149
- parentKey = recordCreatorProps.parentKey,
150
- style = recordCreatorProps.style,
151
- restButtonProps = _objectWithoutProperties(recordCreatorProps, _excluded);
119
+ const {
120
+ record,
121
+ position,
122
+ creatorButtonText,
123
+ newRecordType,
124
+ parentKey,
125
+ style,
126
+ ...restButtonProps
127
+ } = recordCreatorProps;
152
128
  return /*#__PURE__*/_jsx(RecordCreator, {
153
- record: runFunction(record, value === null || value === void 0 ? void 0 : value.length, value) || {},
129
+ record: runFunction(record, value?.length, value) || {},
154
130
  position: position,
155
- parentKey: runFunction(parentKey, value === null || value === void 0 ? void 0 : value.length, value),
131
+ parentKey: runFunction(parentKey, value?.length, value),
156
132
  newRecordType: newRecordType,
157
- children: /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
133
+ children: /*#__PURE__*/_jsx(Button, {
158
134
  type: "dashed",
159
- style: _objectSpread({
135
+ style: {
160
136
  display: 'block',
161
137
  margin: '10px 0',
162
- width: '100%'
163
- }, style),
164
- icon: /*#__PURE__*/_jsx(PlusOutlined, {})
165
- }, restButtonProps), {}, {
138
+ width: '100%',
139
+ ...style
140
+ },
141
+ icon: /*#__PURE__*/_jsx(PlusOutlined, {}),
142
+ ...restButtonProps,
166
143
  children: creatorButtonText || intl.getMessage('editableTable.action.add', '添加一行数据')
167
- }))
144
+ })
168
145
  });
169
146
  }
170
147
 
@@ -175,33 +152,32 @@ function createTopButtonProps(creatorButtonDom, columnsLength) {
175
152
  return {
176
153
  components: {
177
154
  header: {
178
- wrapper: function wrapper(_ref2) {
179
- var className = _ref2.className,
180
- children = _ref2.children;
181
- return /*#__PURE__*/_jsxs("thead", {
182
- className: className,
183
- children: [children, /*#__PURE__*/_jsxs("tr", {
155
+ wrapper: ({
156
+ className,
157
+ children
158
+ }) => /*#__PURE__*/_jsxs("thead", {
159
+ className: className,
160
+ children: [children, /*#__PURE__*/_jsxs("tr", {
161
+ style: {
162
+ position: 'relative'
163
+ },
164
+ children: [/*#__PURE__*/_jsx("td", {
165
+ colSpan: 0,
166
+ style: {
167
+ visibility: 'hidden'
168
+ },
169
+ children: creatorButtonDom
170
+ }), /*#__PURE__*/_jsx("td", {
184
171
  style: {
185
- position: 'relative'
172
+ position: 'absolute',
173
+ left: 0,
174
+ width: '100%'
186
175
  },
187
- children: [/*#__PURE__*/_jsx("td", {
188
- colSpan: 0,
189
- style: {
190
- visibility: 'hidden'
191
- },
192
- children: creatorButtonDom
193
- }), /*#__PURE__*/_jsx("td", {
194
- style: {
195
- position: 'absolute',
196
- left: 0,
197
- width: '100%'
198
- },
199
- colSpan: columnsLength,
200
- children: creatorButtonDom
201
- })]
176
+ colSpan: columnsLength,
177
+ children: creatorButtonDom
202
178
  })]
203
- });
204
- }
179
+ })]
180
+ })
205
181
  }
206
182
  }
207
183
  };
@@ -210,26 +186,24 @@ function createTopButtonProps(creatorButtonDom, columnsLength) {
210
186
  /**
211
187
  * 创建底部按钮的渲染属性
212
188
  */
213
- function createBottomButtonProps(creatorButtonDom, _tableViewRender) {
189
+ function createBottomButtonProps(creatorButtonDom, tableViewRender) {
214
190
  return {
215
- tableViewRender: function tableViewRender(_, dom) {
216
- var _tableViewRender2;
217
- return /*#__PURE__*/_jsxs(_Fragment, {
218
- children: [(_tableViewRender2 = _tableViewRender === null || _tableViewRender === void 0 ? void 0 : _tableViewRender(_, dom)) !== null && _tableViewRender2 !== void 0 ? _tableViewRender2 : dom, creatorButtonDom]
219
- });
220
- }
191
+ tableViewRender: (_, dom) => /*#__PURE__*/_jsxs(_Fragment, {
192
+ children: [tableViewRender?.(_, dom) ?? dom, creatorButtonDom]
193
+ })
221
194
  };
222
195
  }
223
- function useCreatorButton(_ref3) {
224
- var recordCreatorProps = _ref3.recordCreatorProps,
225
- maxLength = _ref3.maxLength,
226
- value = _ref3.value,
227
- intl = _ref3.intl,
228
- isTop = _ref3.isTop,
229
- columnsLength = _ref3.columnsLength,
230
- tableViewRender = _ref3.tableViewRender;
231
- var creatorButtonDom = useMemo(function () {
232
- if (!shouldShowCreatorButton(maxLength, (value === null || value === void 0 ? void 0 : value.length) || 0, recordCreatorProps)) {
196
+ function useCreatorButton({
197
+ recordCreatorProps,
198
+ maxLength,
199
+ value,
200
+ intl,
201
+ isTop,
202
+ columnsLength,
203
+ tableViewRender
204
+ }) {
205
+ const creatorButtonDom = useMemo(() => {
206
+ if (!shouldShowCreatorButton(maxLength, value?.length || 0, recordCreatorProps)) {
233
207
  return false;
234
208
  }
235
209
  if (!recordCreatorProps) {
@@ -237,16 +211,16 @@ function useCreatorButton(_ref3) {
237
211
  }
238
212
  return createButtonDom(recordCreatorProps, value, intl);
239
213
  // eslint-disable-next-line react-hooks/exhaustive-deps
240
- }, [maxLength, recordCreatorProps, value === null || value === void 0 ? void 0 : value.length, intl]);
241
- var buttonRenderProps = useMemo(function () {
214
+ }, [maxLength, recordCreatorProps, value?.length, intl]);
215
+ const buttonRenderProps = useMemo(() => {
242
216
  if (!creatorButtonDom) {
243
217
  return {};
244
218
  }
245
219
  return isTop ? createTopButtonProps(creatorButtonDom, columnsLength) : createBottomButtonProps(creatorButtonDom, tableViewRender);
246
220
  }, [columnsLength, creatorButtonDom, isTop, tableViewRender]);
247
221
  return {
248
- creatorButtonDom: creatorButtonDom,
249
- buttonRenderProps: buttonRenderProps
222
+ creatorButtonDom,
223
+ buttonRenderProps
250
224
  };
251
225
  }
252
226
 
@@ -256,30 +230,31 @@ function useCreatorButton(_ref3) {
256
230
  * @param props
257
231
  */
258
232
  function EditableTable(props) {
259
- var _props$editable2, _rest$columns;
260
- var intl = useIntl();
261
- var onTableChange = props.onTableChange,
262
- maxLength = props.maxLength,
263
- formItemProps = props.formItemProps,
264
- recordCreatorProps = props.recordCreatorProps,
265
- rowKey = props.rowKey,
266
- controlled = props.controlled,
267
- defaultValue = props.defaultValue,
268
- onChange = props.onChange,
269
- editableFormRef = props.editableFormRef,
270
- rest = _objectWithoutProperties(props, _excluded2);
271
- var preData = useRef(undefined);
272
- var actionRef = useRef();
273
- var formRef = useRef();
274
- var form = Form.useFormInstance();
233
+ const intl = useIntl();
234
+ const {
235
+ onTableChange,
236
+ maxLength,
237
+ formItemProps,
238
+ recordCreatorProps,
239
+ rowKey,
240
+ controlled,
241
+ defaultValue,
242
+ onChange,
243
+ editableFormRef,
244
+ // @ts-ignore
245
+ autoFocus,
246
+ ...rest
247
+ } = props;
248
+ const preData = useRef(undefined);
249
+ const actionRef = useRef();
250
+ const formRef = useRef();
251
+ const form = Form.useFormInstance();
275
252
 
276
253
  // 设置 ref
277
- useImperativeHandle(rest.actionRef, function () {
278
- return actionRef.current;
279
- }, [actionRef.current]);
254
+ useImperativeHandle(rest.actionRef, () => actionRef.current, [actionRef.current]);
280
255
 
281
256
  // 在 name 模式下,如果没有传递 value prop,尝试从表单值中获取初始值
282
- var getInitialValue = function getInitialValue() {
257
+ const getInitialValue = () => {
283
258
  if (props.value) {
284
259
  return props.value;
285
260
  }
@@ -288,62 +263,59 @@ function EditableTable(props) {
288
263
  }
289
264
  // 如果使用了 name 且没有 value,尝试从表单获取初始值
290
265
  if (props.name && form) {
291
- var namePath = [props.name].flat(1).filter(Boolean);
292
- var formValue = form.getFieldValue(namePath);
266
+ const namePath = [props.name].flat(1).filter(Boolean);
267
+ const formValue = form.getFieldValue(namePath);
293
268
  if (Array.isArray(formValue)) {
294
269
  return formValue;
295
270
  }
296
271
  }
297
272
  return [];
298
273
  };
299
- var _useMergedState = useMergedState(getInitialValue, {
300
- value: props.value,
274
+ const [value, setValueInner] = useControlledState(getInitialValue, props.value);
275
+ const onChangeFn = props.controlled ? props.onChange : undefined;
276
+ const setValue = useCallback(updater => {
277
+ setValueInner(prev => {
278
+ const next = typeof updater === 'function' ? updater(prev) : updater;
301
279
  // 在非受控模式下,onChange 应该在 onDataSourceChange 中触发
302
- // 这样可以确保数据已经正确更新
303
- onChange: props.controlled ? props.onChange : undefined
304
- }),
305
- _useMergedState2 = _slicedToArray(_useMergedState, 2),
306
- value = _useMergedState2[0],
307
- setValue = _useMergedState2[1];
308
- var getRowKey = React.useMemo(function () {
280
+ onChangeFn?.(next);
281
+ return next;
282
+ });
283
+ }, [onChangeFn]);
284
+ const getRowKey = React.useMemo(() => {
309
285
  if (typeof rowKey === 'function') {
310
286
  return rowKey;
311
287
  }
312
- return function (record, index) {
313
- return record[rowKey] || index;
314
- };
288
+ return (record, index) => record[rowKey] || index;
315
289
  }, [rowKey]);
316
290
 
317
291
  /**
318
292
  * 创建编辑 keys 的 Set,用于快速查找
319
293
  */
320
- var createEditingKeysSet = useRefFunction(function (editingKeys) {
321
- return new Set((editingKeys || []).map(function (key) {
322
- return String(key);
323
- }));
294
+ const createEditingKeysSet = useRefFunction(editingKeys => {
295
+ return new Set((editingKeys || []).map(key => String(key)));
324
296
  });
325
297
 
326
298
  /**
327
299
  * 同步表单值,排除正在编辑的行
328
300
  */
329
- var syncFormValuesExcludingEditing = useRefFunction(function (dataSource, editingKeysSet, namePath) {
301
+ const syncFormValuesExcludingEditing = useRefFunction((dataSource, editingKeysSet, namePath) => {
330
302
  if (!formRef.current) return;
331
303
  try {
332
304
  if (namePath && namePath.length > 0) {
333
305
  // name 模式:需要保留正在编辑的行
334
- var currentFormValues = formRef.current.getFieldsValue() || {};
335
- var currentList = get(currentFormValues, namePath);
306
+ const currentFormValues = formRef.current.getFieldsValue() || {};
307
+ const currentList = get(currentFormValues, namePath);
336
308
  if (currentList && Array.isArray(currentList)) {
337
309
  // 构建新的表单值,保留正在编辑的行
338
310
  // 使用 Map 优化查找性能,将 O(n²) 降低到 O(n)
339
- var currentListMap = new Map();
340
- currentList.forEach(function (item, idx) {
341
- var key = getRowKey(item, idx);
311
+ const currentListMap = new Map();
312
+ currentList.forEach((item, idx) => {
313
+ const key = getRowKey(item, idx);
342
314
  currentListMap.set(String(key), item);
343
315
  });
344
- var newList = dataSource.map(function (item, index) {
345
- var key = getRowKey(item, index);
346
- var keyStr = String(key);
316
+ const newList = dataSource.map((item, index) => {
317
+ const key = getRowKey(item, index);
318
+ const keyStr = String(key);
347
319
 
348
320
  // 如果该行正在编辑,保留表单中的值
349
321
  if (editingKeysSet.has(keyStr)) {
@@ -351,18 +323,18 @@ function EditableTable(props) {
351
323
  }
352
324
  return item;
353
325
  });
354
- var newValue = set({}, namePath, newList);
326
+ const newValue = set({}, namePath, newList);
355
327
  formRef.current.setFieldsValue(newValue);
356
328
  } else {
357
- var _newValue = set({}, namePath, dataSource);
358
- formRef.current.setFieldsValue(_newValue);
329
+ const newValue = set({}, namePath, dataSource);
330
+ formRef.current.setFieldsValue(newValue);
359
331
  }
360
332
  } else {
361
333
  // 非 name 模式:直接设置值
362
- var formValues = {};
363
- dataSource.forEach(function (current, index) {
364
- var key = getRowKey(current, index);
365
- var keyStr = String(key);
334
+ const formValues = {};
335
+ dataSource.forEach((current, index) => {
336
+ const key = getRowKey(current, index);
337
+ const keyStr = String(key);
366
338
  if (!editingKeysSet.has(keyStr)) {
367
339
  formValues[keyStr] = current;
368
340
  }
@@ -379,26 +351,23 @@ function EditableTable(props) {
379
351
  /**
380
352
  * 将数字索引转换为实际的 rowKey(非 name 模式)
381
353
  */
382
- var convertIndexToRowKey = useRefFunction(function (index) {
383
- var _value$length;
384
- var dataLength = (_value$length = value === null || value === void 0 ? void 0 : value.length) !== null && _value$length !== void 0 ? _value$length : 0;
354
+ const convertIndexToRowKey = useRefFunction(index => {
355
+ const dataLength = value?.length ?? 0;
385
356
  if (index >= dataLength) return index;
386
- var rowData = value === null || value === void 0 ? void 0 : value[index];
387
- return getRowKey === null || getRowKey === void 0 ? void 0 : getRowKey(rowData, index);
357
+ const rowData = value?.[index];
358
+ return getRowKey?.(rowData, index);
388
359
  });
389
360
 
390
361
  /**
391
362
  * 将 rowKey 转换为数字索引(name 模式)
392
363
  */
393
- var convertRowKeyToIndex = useRefFunction(function (rowKey) {
394
- var _value$length2;
395
- var dataLength = (_value$length2 = value === null || value === void 0 ? void 0 : value.length) !== null && _value$length2 !== void 0 ? _value$length2 : 0;
364
+ const convertRowKeyToIndex = useRefFunction(rowKey => {
365
+ const dataLength = value?.length ?? 0;
396
366
  if (typeof rowKey === 'string' || rowKey >= dataLength) {
397
- var _rowIndex = value.findIndex(function (item, index) {
398
- var _getRowKey;
399
- return (getRowKey === null || getRowKey === void 0 || (_getRowKey = getRowKey(item, index)) === null || _getRowKey === void 0 ? void 0 : _getRowKey.toString()) === (rowKey === null || rowKey === void 0 ? void 0 : rowKey.toString());
367
+ const rowIndex = value.findIndex((item, index) => {
368
+ return getRowKey?.(item, index)?.toString() === rowKey?.toString();
400
369
  });
401
- if (_rowIndex !== -1) return _rowIndex;
370
+ if (rowIndex !== -1) return rowIndex;
402
371
  }
403
372
  return rowKey;
404
373
  });
@@ -406,7 +375,7 @@ function EditableTable(props) {
406
375
  /**
407
376
  * 根据不同的情况返回不同的 rowKey
408
377
  */
409
- var coverRowKey = useRefFunction(function (finlayRowKey) {
378
+ const coverRowKey = useRefFunction(finlayRowKey => {
410
379
  if (typeof finlayRowKey === 'number' && !props.name) {
411
380
  return convertIndexToRowKey(finlayRowKey);
412
381
  }
@@ -419,76 +388,71 @@ function EditableTable(props) {
419
388
  /**
420
389
  * 构建表单字段路径
421
390
  */
422
- var buildFormFieldPath = useRefFunction(function (rowKey) {
423
- var _rowKey$toString;
424
- return [props.name, (_rowKey$toString = rowKey === null || rowKey === void 0 ? void 0 : rowKey.toString()) !== null && _rowKey$toString !== void 0 ? _rowKey$toString : ''].flat(1).filter(Boolean);
391
+ const buildFormFieldPath = useRefFunction(rowKey => {
392
+ return [props.name, rowKey?.toString() ?? ''].flat(1).filter(Boolean);
425
393
  });
426
394
 
427
395
  /**
428
396
  * 获取一行数据
429
397
  */
430
- var getRowData = useRefFunction(function (rowIndex) {
431
- var _formRef$current;
398
+ const getRowData = useRefFunction(rowIndex => {
432
399
  if (rowIndex == null) {
433
400
  throw new Error('rowIndex is required');
434
401
  }
435
- var finlayRowKey = coverRowKey(rowIndex);
436
- var rowKeyName = buildFormFieldPath(finlayRowKey);
437
- return (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldValue(rowKeyName);
402
+ const finlayRowKey = coverRowKey(rowIndex);
403
+ const rowKeyName = buildFormFieldPath(finlayRowKey);
404
+ return formRef.current?.getFieldValue(rowKeyName);
438
405
  });
439
406
 
440
407
  /**
441
408
  * 获取整个表格的数据
442
409
  */
443
- var getRowsData = useRefFunction(function () {
444
- var _formRef$current3;
445
- var rowKeyName = [props.name].flat(1).filter(Boolean);
410
+ const getRowsData = useRefFunction(() => {
411
+ const rowKeyName = [props.name].flat(1).filter(Boolean);
446
412
  if (Array.isArray(rowKeyName) && rowKeyName.length === 0) {
447
- var _formRef$current2;
448
- var rowData = (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldsValue();
413
+ const rowData = formRef.current?.getFieldsValue();
449
414
  if (Array.isArray(rowData)) return rowData;
450
- return Object.keys(rowData).map(function (key) {
451
- return rowData[key];
452
- });
415
+ return Object.keys(rowData).map(key => rowData[key]);
453
416
  }
454
- return (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.getFieldValue(rowKeyName);
417
+ return formRef.current?.getFieldValue(rowKeyName);
455
418
  });
456
419
 
457
420
  /**
458
421
  * 设置一行数据
459
422
  */
460
- var setRowData = useRefFunction(function (rowIndex, data) {
423
+ const setRowData = useRefFunction((rowIndex, data) => {
461
424
  if (rowIndex == null) {
462
425
  throw new Error('rowIndex is required');
463
426
  }
464
- var finlayRowKey = coverRowKey(rowIndex);
465
- var rowKeyName = buildFormFieldPath(finlayRowKey);
466
- var currentRowData = getRowData(rowIndex);
467
- var newRowData = _objectSpread(_objectSpread({}, currentRowData), data || {});
427
+ const finlayRowKey = coverRowKey(rowIndex);
428
+ const rowKeyName = buildFormFieldPath(finlayRowKey);
429
+ const currentRowData = getRowData(rowIndex);
430
+ const newRowData = {
431
+ ...currentRowData,
432
+ ...(data || {})
433
+ };
468
434
 
469
435
  // 在 name 模式下,需要更新整个数组
470
436
  if (props.name) {
471
- var _formRef$current4;
472
- var tableName = [props.name].flat(1).filter(Boolean);
437
+ const tableName = [props.name].flat(1).filter(Boolean);
473
438
  // 优先从 value prop 获取数据(受控模式),否则从表单值获取
474
- var currentTableData = props.value || ((_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : _formRef$current4.getFieldValue(tableName));
439
+ let currentTableData = props.value || formRef.current?.getFieldValue(tableName);
475
440
  if (Array.isArray(currentTableData)) {
476
441
  // 找到要更新的行的索引
477
- var rowIndexToUpdate = typeof finlayRowKey === 'number' ? finlayRowKey : currentTableData.findIndex(function (row, index) {
478
- var rowKey = getRowKey === null || getRowKey === void 0 ? void 0 : getRowKey(row, index);
479
- return rowKey === finlayRowKey || (rowKey === null || rowKey === void 0 ? void 0 : rowKey.toString()) === (finlayRowKey === null || finlayRowKey === void 0 ? void 0 : finlayRowKey.toString());
442
+ const rowIndexToUpdate = typeof finlayRowKey === 'number' ? finlayRowKey : currentTableData.findIndex((row, index) => {
443
+ const rowKey = getRowKey?.(row, index);
444
+ return rowKey === finlayRowKey || rowKey?.toString() === finlayRowKey?.toString();
480
445
  });
481
446
  if (rowIndexToUpdate >= 0 && rowIndexToUpdate < currentTableData.length) {
482
- var _formRef$current5;
483
447
  // 更新数组中的对应行
484
- var updatedTableData = _toConsumableArray(currentTableData);
448
+ const updatedTableData = [...currentTableData];
485
449
  updatedTableData[rowIndexToUpdate] = newRowData;
486
450
 
487
451
  // 设置整个数组,使用 set 来构建正确的路径
488
452
  // 使用与 syncFormValuesExcludingEditing 相同的路径格式(数组路径)
489
453
  // 这样可以确保 getFieldValue 能正确获取值
490
- var updateValues = set({}, tableName, updatedTableData);
491
- (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 || _formRef$current5.setFieldsValue(updateValues);
454
+ const updateValues = set({}, tableName, updatedTableData);
455
+ formRef.current?.setFieldsValue(updateValues);
492
456
 
493
457
  // 在受控模式下,触发 onChange
494
458
  if (props.controlled && props.onChange) {
@@ -496,27 +460,26 @@ function EditableTable(props) {
496
460
  }
497
461
  }
498
462
  } else {
499
- var _formRef$current6;
500
463
  // 如果当前没有数据,直接设置单个字段
501
- var _updateValues = set({}, rowKeyName, newRowData);
502
- (_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 || _formRef$current6.setFieldsValue(_updateValues);
464
+ const updateValues = set({}, rowKeyName, newRowData);
465
+ formRef.current?.setFieldsValue(updateValues);
503
466
  }
504
467
  } else {
505
- var _formRef$current7;
506
468
  // 非 name 模式下,直接设置单个字段
507
- var _updateValues2 = set({}, rowKeyName, newRowData);
508
- (_formRef$current7 = formRef.current) === null || _formRef$current7 === void 0 || _formRef$current7.setFieldsValue(_updateValues2);
469
+ const updateValues = set({}, rowKeyName, newRowData);
470
+ formRef.current?.setFieldsValue(updateValues);
509
471
  }
510
472
  return true;
511
473
  });
512
474
 
513
475
  // 设置 editableFormRef
514
- useImperativeHandle(editableFormRef, function () {
515
- return _objectSpread(_objectSpread({}, formRef.current), {}, {
516
- getRowData: getRowData,
517
- getRowsData: getRowsData,
518
- setRowData: setRowData
519
- });
476
+ useImperativeHandle(editableFormRef, () => {
477
+ return {
478
+ ...formRef.current,
479
+ getRowData,
480
+ getRowsData,
481
+ setRowData
482
+ };
520
483
  }, [coverRowKey, props.name, getRowData, getRowsData, setRowData]);
521
484
 
522
485
  /**
@@ -525,7 +488,7 @@ function EditableTable(props) {
525
488
  * 使用深度比较优化性能,避免频繁的序列化操作
526
489
  * 注意:只有当 value 明确传递时才同步,避免覆盖表单中的初始值
527
490
  */
528
- useDeepCompareEffect(function () {
491
+ useDeepCompareEffect(() => {
529
492
  if (!props.controlled || !formRef.current) return;
530
493
 
531
494
  // 在受控模式下,只有当 value 明确传递时才同步
@@ -537,15 +500,15 @@ function EditableTable(props) {
537
500
  try {
538
501
  if (props.name) {
539
502
  // name 模式:直接设置整个数组
540
- var namePath = [props.name].flat(1);
541
- var newValue = set({}, namePath, value);
503
+ const namePath = [props.name].flat(1);
504
+ const newValue = set({}, namePath, value);
542
505
  formRef.current.setFieldsValue(newValue);
543
506
  } else {
544
507
  // 非 name 模式:直接设置值
545
- var formValues = {};
546
- value.forEach(function (item, index) {
547
- var key = getRowKey(item, index);
548
- var keyStr = String(key);
508
+ const formValues = {};
509
+ value.forEach((item, index) => {
510
+ const key = getRowKey(item, index);
511
+ const keyStr = String(key);
549
512
  formValues[keyStr] = item;
550
513
  });
551
514
  if (Object.keys(formValues).length > 0) {
@@ -561,40 +524,40 @@ function EditableTable(props) {
561
524
  * 同步表单实例引用
562
525
  * 只在 name 模式下且 form 存在时更新
563
526
  */
564
- useEffect(function () {
565
- var _props$editable;
566
- if (props.name && props !== null && props !== void 0 && (_props$editable = props.editable) !== null && _props$editable !== void 0 && _props$editable.form) {
527
+ useEffect(() => {
528
+ if (props.name && props?.editable?.form) {
567
529
  formRef.current = props.editable.form;
568
530
  }
569
- }, [(_props$editable2 = props.editable) === null || _props$editable2 === void 0 ? void 0 : _props$editable2.form, props.name]);
570
- var _ref4 = recordCreatorProps || {},
571
- position = _ref4.position;
572
- var isTop = position === 'top';
573
- var _useCreatorButton = useCreatorButton({
574
- recordCreatorProps: recordCreatorProps,
575
- maxLength: maxLength,
576
- value: value,
577
- intl: intl,
578
- isTop: isTop,
579
- columnsLength: (_rest$columns = rest.columns) === null || _rest$columns === void 0 ? void 0 : _rest$columns.length,
580
- tableViewRender: props.tableViewRender
581
- }),
582
- creatorButtonDom = _useCreatorButton.creatorButtonDom,
583
- buttonRenderProps = _useCreatorButton.buttonRenderProps;
531
+ }, [props.editable?.form, props.name]);
532
+ const {
533
+ position
534
+ } = recordCreatorProps || {};
535
+ const isTop = position === 'top';
536
+ const {
537
+ creatorButtonDom,
538
+ buttonRenderProps
539
+ } = useCreatorButton({
540
+ recordCreatorProps,
541
+ maxLength,
542
+ value,
543
+ intl,
544
+ isTop,
545
+ columnsLength: rest.columns?.length,
546
+ tableViewRender: props.tableViewRender
547
+ });
584
548
 
585
549
  /**
586
550
  * 处理值变化回调
587
551
  * 注意:受控模式下不调用 onChange,避免循环更新
588
552
  * onChange 应该由外部控制,而不是在内部触发
589
553
  */
590
- var handleValuesChange = useRefFunction(function (r, dataSource) {
591
- var _props$editable3, _props$editable3$onVa, _props$onValuesChange;
592
- (_props$editable3 = props.editable) === null || _props$editable3 === void 0 || (_props$editable3$onVa = _props$editable3.onValuesChange) === null || _props$editable3$onVa === void 0 || _props$editable3$onVa.call(_props$editable3, r, dataSource);
593
- (_props$onValuesChange = props.onValuesChange) === null || _props$onValuesChange === void 0 || _props$onValuesChange.call(props, dataSource, r);
554
+ const handleValuesChange = useRefFunction((r, dataSource) => {
555
+ props.editable?.onValuesChange?.(r, dataSource);
556
+ props.onValuesChange?.(dataSource, r);
594
557
 
595
558
  // 在受控模式下,当表单值变化时也应该触发 onChange
596
559
  // 这样外部可以同步更新 value,实现真正的受控
597
- if (props.controlled && props !== null && props !== void 0 && props.onChange) {
560
+ if (props.controlled && props?.onChange) {
598
561
  props.onChange(dataSource);
599
562
  }
600
563
  // 非受控模式下,onChange 应该在 onDataSourceChange 中触发
@@ -605,10 +568,11 @@ function EditableTable(props) {
605
568
  * 构建可编辑属性
606
569
  * 使用 useMemo 优化性能,避免不必要的重新创建
607
570
  */
608
- var editableProps = useMemo(function () {
609
- var _props$editable4;
610
- var baseProps = _objectSpread({}, props.editable);
611
- var hasOnValuesChange = Boolean(props === null || props === void 0 ? void 0 : props.onValuesChange) || Boolean((_props$editable4 = props.editable) === null || _props$editable4 === void 0 ? void 0 : _props$editable4.onValuesChange) || Boolean(props.controlled && (props === null || props === void 0 ? void 0 : props.onChange));
571
+ const editableProps = useMemo(() => {
572
+ const baseProps = {
573
+ ...props.editable
574
+ };
575
+ const hasOnValuesChange = Boolean(props?.onValuesChange) || Boolean(props.editable?.onValuesChange) || Boolean(props.controlled && props?.onChange);
612
576
  if (hasOnValuesChange) {
613
577
  baseProps.onValuesChange = handleValuesChange;
614
578
  }
@@ -617,23 +581,26 @@ function EditableTable(props) {
617
581
  return /*#__PURE__*/_jsxs(_Fragment, {
618
582
  children: [/*#__PURE__*/_jsx(EditableTableActionContext.Provider, {
619
583
  value: actionRef,
620
- children: /*#__PURE__*/_jsx(ProTable, _objectSpread(_objectSpread(_objectSpread({
584
+ children: /*#__PURE__*/_jsx(ProTable, {
621
585
  search: false,
622
586
  options: false,
623
587
  pagination: false,
624
588
  rowKey: rowKey,
625
- revalidateOnFocus: false
626
- }, rest), buttonRenderProps), {}, {
589
+ revalidateOnFocus: false,
590
+ ...rest,
591
+ ...buttonRenderProps,
627
592
  tableLayout: "fixed",
628
593
  actionRef: actionRef,
629
594
  onChange: onTableChange,
630
- editable: _objectSpread(_objectSpread({}, editableProps), {}, {
631
- formProps: _objectSpread({
632
- formRef: formRef
633
- }, editableProps.formProps)
634
- }),
595
+ editable: {
596
+ ...editableProps,
597
+ formProps: {
598
+ formRef,
599
+ ...editableProps.formProps
600
+ }
601
+ },
635
602
  dataSource: value,
636
- onDataSourceChange: function onDataSourceChange(dataSource) {
603
+ onDataSourceChange: dataSource => {
637
604
  // setValue 会触发 onChange,但我们需要确保数据已经正确更新
638
605
  // 所以先设置数据,然后手动触发 onChange
639
606
  setValue(dataSource);
@@ -644,10 +611,9 @@ function EditableTable(props) {
644
611
  * 注意:不会覆盖正在编辑的行
645
612
  */
646
613
  if (props.name && formRef.current) {
647
- var _props$editable5;
648
- var editingKeys = (_props$editable5 = props.editable) === null || _props$editable5 === void 0 ? void 0 : _props$editable5.editableKeys;
649
- var editingKeysSet = createEditingKeysSet(editingKeys);
650
- var namePath = [props.name].flat(1).filter(Boolean);
614
+ const editingKeys = props.editable?.editableKeys;
615
+ const editingKeysSet = createEditingKeysSet(editingKeys);
616
+ const namePath = [props.name].flat(1).filter(Boolean);
651
617
  syncFormValuesExcludingEditing(dataSource, editingKeysSet, namePath);
652
618
  }
653
619
 
@@ -657,17 +623,17 @@ function EditableTable(props) {
657
623
  props.onChange(dataSource);
658
624
  }
659
625
  }
660
- }))
626
+ })
661
627
  }), props.name ? /*#__PURE__*/_jsx(ProFormDependency, {
662
628
  name: [props.name],
663
- children: function children(changeValue) {
629
+ children: changeValue => {
664
630
  // 初始化 preData
665
631
  if (!preData.current) {
666
632
  preData.current = value;
667
633
  return null;
668
634
  }
669
- var namePath = [props.name].flat(1);
670
- var list = get(changeValue, namePath);
635
+ const namePath = [props.name].flat(1);
636
+ const list = get(changeValue, namePath);
671
637
 
672
638
  // 添加空值检查,避免后续操作出错
673
639
  if (!list || !Array.isArray(list)) {
@@ -677,20 +643,18 @@ function EditableTable(props) {
677
643
 
678
644
  // 在更新 preData 之前找到变化的项
679
645
  // 使用 findIndex 可以同时获取变化的项和索引
680
- var changeIndex = list.findIndex(function (item, index) {
681
- var _preData$current;
682
- return !isDeepEqualReact(item, (_preData$current = preData.current) === null || _preData$current === void 0 ? void 0 : _preData$current[index]);
646
+ const changeIndex = list.findIndex((item, index) => {
647
+ return !isDeepEqualReact(item, preData.current?.[index]);
683
648
  });
684
649
 
685
650
  // 只有在找到变化项时才触发回调
686
651
  if (changeIndex !== -1) {
687
- var _props$editable6, _props$editable6$onVa;
688
- var changeItem = list[changeIndex];
689
- props === null || props === void 0 || (_props$editable6 = props.editable) === null || _props$editable6 === void 0 || (_props$editable6$onVa = _props$editable6.onValuesChange) === null || _props$editable6$onVa === void 0 || _props$editable6$onVa.call(_props$editable6, changeItem, list);
652
+ const changeItem = list[changeIndex];
653
+ props?.editable?.onValuesChange?.(changeItem, list);
690
654
  }
691
655
 
692
656
  // 在找到 changeItem 之后再更新 preData,确保后续比较正确
693
- preData.current = value;
657
+ preData.current = list;
694
658
  return null;
695
659
  }
696
660
  }) : null]
@@ -703,38 +667,40 @@ function EditableTable(props) {
703
667
  * @param props
704
668
  */
705
669
  function FieldEditableTable(props) {
706
- var form = ProForm.useFormInstance();
707
- if (!props.name) return /*#__PURE__*/_jsx(EditableTable, _objectSpread({
670
+ const form = ProForm.useFormInstance();
671
+ if (!props.name) return /*#__PURE__*/_jsx(EditableTable, {
708
672
  tableLayout: "fixed",
709
673
  scroll: {
710
674
  x: 'max-content'
711
- }
712
- }, props));
713
- return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({
675
+ },
676
+ ...props
677
+ });
678
+ return /*#__PURE__*/_jsx(Form.Item, {
714
679
  style: {
715
680
  maxWidth: '100%'
716
681
  },
717
- shouldUpdate: function shouldUpdate(prev, next) {
718
- var name = [props.name].flat(1);
682
+ shouldUpdate: (prev, next) => {
683
+ const name = [props.name].flat(1);
719
684
  try {
720
685
  return JSON.stringify(get(prev, name)) !== JSON.stringify(get(next, name));
721
686
  } catch (error) {
722
687
  return true;
723
688
  }
724
- }
725
- }, props === null || props === void 0 ? void 0 : props.formItemProps), {}, {
689
+ },
690
+ ...props?.formItemProps,
726
691
  name: props.name,
727
- children: /*#__PURE__*/_jsx(EditableTable, _objectSpread(_objectSpread({
692
+ children: /*#__PURE__*/_jsx(EditableTable, {
728
693
  tableLayout: "fixed",
729
694
  scroll: {
730
695
  x: 'max-content'
731
- }
732
- }, props), {}, {
733
- editable: _objectSpread(_objectSpread({}, props.editable), {}, {
696
+ },
697
+ ...props,
698
+ editable: {
699
+ ...props.editable,
734
700
  form: form
735
- })
736
- }))
737
- }));
701
+ }
702
+ })
703
+ });
738
704
  }
739
705
  FieldEditableTable.RecordCreator = RecordCreator;
740
706
  export default FieldEditableTable;