@ant-design/pro-components 3.0.0-beta.1 → 3.0.0-beta.2

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 (786) hide show
  1. package/dist/pro-components.min.js +1 -1
  2. package/es/card/ProCard.d.ts +0 -1
  3. package/es/card/ProCard.js +11 -23
  4. package/es/card/components/Actions/index.js +33 -28
  5. package/es/card/components/Actions/style.js +72 -100
  6. package/es/card/components/Card/index.js +213 -258
  7. package/es/card/components/Card/style.js +192 -266
  8. package/es/card/components/CheckCard/Group.js +198 -208
  9. package/es/card/components/CheckCard/index.js +151 -160
  10. package/es/card/components/CheckCard/style.js +186 -212
  11. package/es/card/components/Divider/index.js +23 -18
  12. package/es/card/components/Divider/style.js +30 -54
  13. package/es/card/components/Loading/index.js +80 -13
  14. package/es/card/components/Loading/style.js +42 -63
  15. package/es/card/components/Operation/index.js +22 -17
  16. package/es/card/components/Operation/style.js +19 -43
  17. package/es/card/components/Statistic/index.js +79 -96
  18. package/es/card/components/Statistic/style.js +76 -115
  19. package/es/card/components/StatisticCard/index.d.ts +0 -2
  20. package/es/card/components/StatisticCard/index.js +59 -70
  21. package/es/card/components/StatisticCard/style.js +36 -55
  22. package/es/card/index.d.ts +2 -2
  23. package/es/card/index.js +2 -9
  24. package/es/card/typing.js +1 -0
  25. package/es/descriptions/index.js +364 -414
  26. package/es/descriptions/useFetchData.js +94 -73
  27. package/es/field/AllProField.js +438 -361
  28. package/es/field/FieldHOC/index.js +32 -28
  29. package/es/field/PureProField.js +129 -160
  30. package/es/field/ValueTypeToComponent.js +686 -396
  31. package/es/field/components/Cascader/index.d.ts +2 -2
  32. package/es/field/components/Cascader/index.js +124 -149
  33. package/es/field/components/Checkbox/index.d.ts +1 -1
  34. package/es/field/components/Checkbox/index.js +106 -128
  35. package/es/field/components/Code/index.js +67 -60
  36. package/es/field/components/ColorPicker/index.d.ts +2 -2
  37. package/es/field/components/ColorPicker/index.js +55 -78
  38. package/es/field/components/DatePicker/index.d.ts +2 -2
  39. package/es/field/components/DatePicker/index.js +100 -116
  40. package/es/field/components/Digit/index.js +84 -83
  41. package/es/field/components/DigitRange/index.js +102 -96
  42. package/es/field/components/FromNow/index.js +50 -62
  43. package/es/field/components/Image/index.js +46 -50
  44. package/es/field/components/IndexColumn/index.js +45 -43
  45. package/es/field/components/Money/index.js +245 -253
  46. package/es/field/components/Options/index.js +61 -71
  47. package/es/field/components/Password/index.js +62 -59
  48. package/es/field/components/Percent/index.js +74 -80
  49. package/es/field/components/Percent/util.js +23 -18
  50. package/es/field/components/Progress/index.js +53 -54
  51. package/es/field/components/Radio/index.d.ts +1 -1
  52. package/es/field/components/Radio/index.js +85 -107
  53. package/es/field/components/RangePicker/index.d.ts +2 -2
  54. package/es/field/components/RangePicker/index.js +122 -137
  55. package/es/field/components/Rate/index.js +39 -35
  56. package/es/field/components/Second/index.js +61 -59
  57. package/es/field/components/Segmented/index.d.ts +1 -1
  58. package/es/field/components/Segmented/index.js +68 -90
  59. package/es/field/components/Select/LightSelect/index.d.ts +1 -1
  60. package/es/field/components/Select/LightSelect/index.js +210 -256
  61. package/es/field/components/Select/SearchSelect/index.js +192 -225
  62. package/es/field/components/Select/index.d.ts +2 -2
  63. package/es/field/components/Select/index.js +299 -368
  64. package/es/field/components/Slider/index.js +39 -45
  65. package/es/field/components/Status/index.js +83 -23
  66. package/es/field/components/Switch/index.d.ts +1 -1
  67. package/es/field/components/Switch/index.js +60 -71
  68. package/es/field/components/Text/index.js +53 -48
  69. package/es/field/components/TextArea/index.js +39 -53
  70. package/es/field/components/TextArea/readonly.js +36 -50
  71. package/es/field/components/TimePicker/index.js +182 -190
  72. package/es/field/components/TreeSelect/index.d.ts +2 -2
  73. package/es/field/components/TreeSelect/index.js +178 -184
  74. package/es/field/index.js +3 -43
  75. package/es/form/BaseForm/BaseForm.js +582 -621
  76. package/es/form/BaseForm/EditOrReadOnlyContext.js +4 -8
  77. package/es/form/BaseForm/LightWrapper/index.js +104 -161
  78. package/es/form/BaseForm/LightWrapper/style.js +14 -41
  79. package/es/form/BaseForm/Submitter/index.js +69 -100
  80. package/es/form/BaseForm/index.js +1 -2
  81. package/es/form/FieldContext.js +4 -8
  82. package/es/form/components/Captcha/index.js +162 -169
  83. package/es/form/components/Cascader/index.js +46 -75
  84. package/es/form/components/Checkbox/index.js +73 -98
  85. package/es/form/components/ColorPicker/index.js +43 -64
  86. package/es/form/components/DatePicker/BaseDatePicker.js +45 -69
  87. package/es/form/components/DatePicker/DatePicker.js +26 -51
  88. package/es/form/components/DatePicker/DateTimePicker.js +26 -50
  89. package/es/form/components/DatePicker/MonthPicker.js +26 -51
  90. package/es/form/components/DatePicker/QuarterPicker.js +26 -51
  91. package/es/form/components/DatePicker/TimePicker.js +43 -72
  92. package/es/form/components/DatePicker/WeekPicker.js +26 -51
  93. package/es/form/components/DatePicker/YearPicker.js +26 -51
  94. package/es/form/components/DatePicker/index.js +4 -6
  95. package/es/form/components/DateRangePicker/BaseDateRanger.js +42 -70
  96. package/es/form/components/DateRangePicker/DateMonthRangePicker.js +29 -51
  97. package/es/form/components/DateRangePicker/DateQuarterRangePicker.js +29 -51
  98. package/es/form/components/DateRangePicker/DateTimeRangePicker.js +29 -51
  99. package/es/form/components/DateRangePicker/DateWeekRangePicker.js +29 -51
  100. package/es/form/components/DateRangePicker/DateYearRangePicker.js +29 -51
  101. package/es/form/components/DateRangePicker/TimeRangePicker.js +42 -67
  102. package/es/form/components/DateRangePicker/index.js +29 -51
  103. package/es/form/components/Dependency/index.js +56 -96
  104. package/es/form/components/Digit/DigitRange.js +42 -75
  105. package/es/form/components/Digit/index.js +47 -78
  106. package/es/form/components/Field/index.js +80 -124
  107. package/es/form/components/FieldSet/index.js +95 -123
  108. package/es/form/components/FormItem/FormItemRender/index.js +135 -92
  109. package/es/form/components/FormItem/Group/index.js +134 -169
  110. package/es/form/components/FormItem/Group/style.js +41 -62
  111. package/es/form/components/FormItem/index.js +252 -293
  112. package/es/form/components/FormItem/warpField.js +218 -285
  113. package/es/form/components/List/ListContainer.js +221 -181
  114. package/es/form/components/List/ListItem.js +259 -350
  115. package/es/form/components/List/index.d.ts +2 -2
  116. package/es/form/components/List/index.js +195 -252
  117. package/es/form/components/List/style.js +48 -95
  118. package/es/form/components/Money/index.js +50 -80
  119. package/es/form/components/Radio/index.js +52 -86
  120. package/es/form/components/Rate/index.js +37 -60
  121. package/es/form/components/SchemaForm/index.js +121 -167
  122. package/es/form/components/SchemaForm/layoutType/Embed.js +8 -5
  123. package/es/form/components/SchemaForm/layoutType/StepsForm.js +35 -68
  124. package/es/form/components/SchemaForm/layoutType/index.js +2 -7
  125. package/es/form/components/SchemaForm/typing.js +1 -0
  126. package/es/form/components/SchemaForm/valueType/dependency.js +19 -43
  127. package/es/form/components/SchemaForm/valueType/divider.js +11 -30
  128. package/es/form/components/SchemaForm/valueType/field.js +59 -100
  129. package/es/form/components/SchemaForm/valueType/formList.js +16 -42
  130. package/es/form/components/SchemaForm/valueType/formSet.js +16 -42
  131. package/es/form/components/SchemaForm/valueType/group.js +15 -37
  132. package/es/form/components/SchemaForm/valueType/ignore.js +4 -7
  133. package/es/form/components/SchemaForm/valueType/index.js +16 -17
  134. package/es/form/components/Segmented/index.js +43 -61
  135. package/es/form/components/Select/index.js +114 -151
  136. package/es/form/components/Slider/index.js +54 -91
  137. package/es/form/components/Switch/index.js +47 -71
  138. package/es/form/components/Text/index.js +132 -161
  139. package/es/form/components/TextArea/index.js +34 -57
  140. package/es/form/components/TreeSelect/index.js +42 -61
  141. package/es/form/components/UploadButton/index.js +125 -145
  142. package/es/form/components/UploadDragger/index.js +77 -92
  143. package/es/form/components/index.js +36 -88
  144. package/es/form/helpers/grid.js +77 -82
  145. package/es/form/helpers/index.js +1 -2
  146. package/es/form/index.js +6 -15
  147. package/es/form/layouts/DrawerForm/index.js +309 -315
  148. package/es/form/layouts/DrawerForm/style.js +26 -50
  149. package/es/form/layouts/LightFilter/index.js +208 -270
  150. package/es/form/layouts/LightFilter/style.js +49 -74
  151. package/es/form/layouts/LoginForm/index.js +85 -104
  152. package/es/form/layouts/LoginForm/style.js +68 -95
  153. package/es/form/layouts/LoginFormPage/index.js +141 -147
  154. package/es/form/layouts/LoginFormPage/style.js +129 -154
  155. package/es/form/layouts/ModalForm/index.js +247 -253
  156. package/es/form/layouts/ProForm/index.d.ts +1 -1
  157. package/es/form/layouts/ProForm/index.js +15 -32
  158. package/es/form/layouts/QueryFilter/Actions.js +52 -47
  159. package/es/form/layouts/QueryFilter/index.js +298 -358
  160. package/es/form/layouts/QueryFilter/style.js +38 -69
  161. package/es/form/layouts/StepsForm/StepForm.js +88 -119
  162. package/es/form/layouts/StepsForm/index.js +340 -353
  163. package/es/form/layouts/StepsForm/style.js +29 -50
  164. package/es/form/layouts/index.js +9 -20
  165. package/es/form/typing.js +1 -0
  166. package/es/index.js +1 -5
  167. package/es/layout/ProLayout.js +428 -497
  168. package/es/layout/WrapContent.js +26 -15
  169. package/es/layout/assert/Logo.js +107 -79
  170. package/es/layout/components/AppsLogoComponents/AppsLogo.js +13 -11
  171. package/es/layout/components/AppsLogoComponents/DefaultContent.js +50 -56
  172. package/es/layout/components/AppsLogoComponents/SimpleContent.js +73 -66
  173. package/es/layout/components/AppsLogoComponents/index.js +90 -73
  174. package/es/layout/components/AppsLogoComponents/style/default.js +31 -35
  175. package/es/layout/components/AppsLogoComponents/style/index.js +51 -77
  176. package/es/layout/components/AppsLogoComponents/style/simple.js +37 -40
  177. package/es/layout/components/CollapsedIcon/index.js +19 -55
  178. package/es/layout/components/CollapsedIcon/style.js +42 -66
  179. package/es/layout/components/Footer.js +27 -38
  180. package/es/layout/components/FooterToolbar/index.js +78 -102
  181. package/es/layout/components/FooterToolbar/style/index.js +38 -62
  182. package/es/layout/components/FooterToolbar/style/stylish.js +10 -38
  183. package/es/layout/components/GlobalFooter/index.js +37 -31
  184. package/es/layout/components/GlobalFooter/style.js +32 -53
  185. package/es/layout/components/GlobalHeader/ActionsContent.js +132 -181
  186. package/es/layout/components/GlobalHeader/index.d.ts +0 -5
  187. package/es/layout/components/GlobalHeader/index.js +76 -84
  188. package/es/layout/components/GlobalHeader/rightContentStyle.js +52 -76
  189. package/es/layout/components/GlobalHeader/style.js +57 -83
  190. package/es/layout/components/GridContent/index.js +35 -33
  191. package/es/layout/components/GridContent/style.js +14 -38
  192. package/es/layout/components/Header/index.js +95 -124
  193. package/es/layout/components/Header/style/header.js +48 -72
  194. package/es/layout/components/Header/style/stylish.js +12 -42
  195. package/es/layout/components/Help/AsyncContentPanel.js +53 -42
  196. package/es/layout/components/Help/HelpProvide.js +55 -6
  197. package/es/layout/components/Help/ProHelpContentPanel.js +128 -127
  198. package/es/layout/components/Help/ProHelpDrawer.js +48 -76
  199. package/es/layout/components/Help/ProHelpModal.js +47 -76
  200. package/es/layout/components/Help/ProHelpPanel.js +183 -224
  201. package/es/layout/components/Help/ProHelpPopover.js +37 -64
  202. package/es/layout/components/Help/RenderContentPanel.js +90 -103
  203. package/es/layout/components/Help/Search.js +124 -163
  204. package/es/layout/components/Help/index.js +19 -40
  205. package/es/layout/components/Help/style.js +90 -115
  206. package/es/layout/components/PageContainer/index.js +233 -280
  207. package/es/layout/components/PageContainer/style/index.js +78 -118
  208. package/es/layout/components/PageContainer/style/stylish.js +10 -38
  209. package/es/layout/components/PageHeader/index.js +144 -129
  210. package/es/layout/components/PageHeader/style/index.js +125 -172
  211. package/es/layout/components/PageLoading/index.js +23 -50
  212. package/es/layout/components/SettingDrawer/BlockCheckbox.js +42 -42
  213. package/es/layout/components/SettingDrawer/LayoutChange.js +108 -98
  214. package/es/layout/components/SettingDrawer/RegionalChange.js +31 -34
  215. package/es/layout/components/SettingDrawer/ThemeColor.js +50 -69
  216. package/es/layout/components/SettingDrawer/icon/group.js +109 -88
  217. package/es/layout/components/SettingDrawer/icon/sub.js +70 -116
  218. package/es/layout/components/SettingDrawer/index.js +406 -420
  219. package/es/layout/components/SettingDrawer/style/index.js +142 -146
  220. package/es/layout/components/SiderMenu/Arrow.js +12 -15
  221. package/es/layout/components/SiderMenu/BaseMenu.js +402 -451
  222. package/es/layout/components/SiderMenu/SiderMenu.js +246 -336
  223. package/es/layout/components/SiderMenu/index.js +72 -101
  224. package/es/layout/components/SiderMenu/style/index.js +171 -210
  225. package/es/layout/components/SiderMenu/style/menu.js +110 -173
  226. package/es/layout/components/SiderMenu/style/stylish.js +12 -42
  227. package/es/layout/components/TopNavHeader/index.js +106 -179
  228. package/es/layout/components/TopNavHeader/style.js +67 -95
  229. package/es/layout/context/RouteContext.js +2 -6
  230. package/es/layout/defaultSettings.js +6 -9
  231. package/es/layout/getPageTitle.js +46 -40
  232. package/es/layout/index.js +4 -27
  233. package/es/layout/locales/en-US/settingDrawer.js +43 -47
  234. package/es/layout/locales/en-US.js +2 -22
  235. package/es/layout/locales/index.js +13 -18
  236. package/es/layout/locales/it-IT/settingDrawer.js +34 -38
  237. package/es/layout/locales/it-IT.js +2 -22
  238. package/es/layout/locales/ko-KR/settingDrawer.js +39 -43
  239. package/es/layout/locales/ko-KR.js +2 -22
  240. package/es/layout/locales/zh-CN/settingDrawer.js +43 -47
  241. package/es/layout/locales/zh-CN.js +2 -22
  242. package/es/layout/locales/zh-TW/settingDrawer.js +35 -39
  243. package/es/layout/locales/zh-TW.js +2 -22
  244. package/es/layout/style/index.js +43 -73
  245. package/es/layout/typing.js +1 -0
  246. package/es/layout/utils/getBreadcrumbProps.js +111 -91
  247. package/es/layout/utils/getMenuData.js +18 -21
  248. package/es/layout/utils/pathTools.js +11 -12
  249. package/es/layout/utils/useCurrentMenuLayoutProps.js +21 -29
  250. package/es/layout/utils/utils.js +35 -51
  251. package/es/list/Item.js +222 -294
  252. package/es/list/ListView.js +188 -232
  253. package/es/list/constants.js +4 -17
  254. package/es/list/index.js +121 -178
  255. package/es/list/style/index.js +224 -287
  256. package/es/provider/index.js +228 -179
  257. package/es/provider/intl.js +100 -124
  258. package/es/provider/locale/ar_EG.js +47 -51
  259. package/es/provider/locale/ca_ES.js +45 -49
  260. package/es/provider/locale/cs_CZ.js +50 -54
  261. package/es/provider/locale/de_DE.js +47 -51
  262. package/es/provider/locale/en_GB.js +49 -53
  263. package/es/provider/locale/en_US.js +51 -55
  264. package/es/provider/locale/es_ES.js +47 -51
  265. package/es/provider/locale/fa_IR.js +47 -51
  266. package/es/provider/locale/fr_FR.js +47 -51
  267. package/es/provider/locale/he_IL.js +50 -54
  268. package/es/provider/locale/hr_HR.js +47 -51
  269. package/es/provider/locale/id_ID.js +47 -51
  270. package/es/provider/locale/it_IT.js +47 -51
  271. package/es/provider/locale/ja_JP.js +47 -51
  272. package/es/provider/locale/ko_KR.js +47 -51
  273. package/es/provider/locale/mn_MN.js +47 -51
  274. package/es/provider/locale/ms_MY.js +47 -51
  275. package/es/provider/locale/nl_NL.js +50 -54
  276. package/es/provider/locale/pl_PL.js +47 -51
  277. package/es/provider/locale/pt_BR.js +47 -51
  278. package/es/provider/locale/ro_RO.js +50 -54
  279. package/es/provider/locale/ru_RU.js +47 -51
  280. package/es/provider/locale/sk_SK.js +50 -54
  281. package/es/provider/locale/sr_RS.js +47 -51
  282. package/es/provider/locale/sv_SE.js +50 -54
  283. package/es/provider/locale/th_TH.js +50 -54
  284. package/es/provider/locale/tr_TR.js +47 -51
  285. package/es/provider/locale/uk_UA.js +50 -54
  286. package/es/provider/locale/uz_UZ.js +47 -51
  287. package/es/provider/locale/vi_VN.js +47 -51
  288. package/es/provider/locale/zh_CN.js +50 -54
  289. package/es/provider/locale/zh_HK.js +50 -54
  290. package/es/provider/locale/zh_TW.js +50 -54
  291. package/es/provider/typing/layoutToken.d.ts +0 -10
  292. package/es/provider/typing/layoutToken.js +19 -42
  293. package/es/provider/useStyle/index.d.ts +1 -1
  294. package/es/provider/useStyle/index.js +91 -78
  295. package/es/provider/utils/merge.js +13 -29
  296. package/es/skeleton/components/Descriptions/index.js +240 -252
  297. package/es/skeleton/components/List/index.js +217 -207
  298. package/es/skeleton/components/Result/index.js +57 -54
  299. package/es/skeleton/index.js +18 -62
  300. package/es/table/Store/Provide.d.ts +0 -1
  301. package/es/table/Store/Provide.js +141 -128
  302. package/es/table/Table.js +645 -698
  303. package/es/table/components/Alert/index.js +60 -37
  304. package/es/table/components/Alert/style.js +28 -52
  305. package/es/table/components/ColumnSetting/index.js +382 -387
  306. package/es/table/components/ColumnSetting/style.js +72 -108
  307. package/es/table/components/DragSortTable/index.js +101 -137
  308. package/es/table/components/DragSortTable/style.js +20 -44
  309. package/es/table/components/Dropdown/index.js +70 -83
  310. package/es/table/components/EditableTable/CellEditorTable.js +50 -65
  311. package/es/table/components/EditableTable/RowEditorTable.js +44 -62
  312. package/es/table/components/EditableTable/index.js +343 -347
  313. package/es/table/components/Form/FormRender.js +167 -173
  314. package/es/table/components/Form/index.js +123 -132
  315. package/es/table/components/ListToolBar/HeaderMenu.js +68 -102
  316. package/es/table/components/ListToolBar/index.js +254 -273
  317. package/es/table/components/ListToolBar/style.js +119 -134
  318. package/es/table/components/ToolBar/DensityIcon.js +36 -41
  319. package/es/table/components/ToolBar/FullscreenIcon.js +21 -14
  320. package/es/table/components/ToolBar/index.js +235 -267
  321. package/es/table/index.js +3 -50
  322. package/es/table/style/index.js +129 -175
  323. package/es/table/typing.d.ts +2 -2
  324. package/es/table/typing.js +1 -0
  325. package/es/table/useFetchData.js +432 -232
  326. package/es/table/utils/cellRenderToFromItem.js +186 -261
  327. package/es/table/utils/columnRender.js +116 -115
  328. package/es/table/utils/columnSort.js +23 -21
  329. package/es/table/utils/genProColumnToColumn.js +101 -129
  330. package/es/table/utils/index.js +197 -115
  331. package/es/table/utils/useDragSort.js +135 -174
  332. package/es/utils/components/DropdownFooter/index.js +48 -58
  333. package/es/utils/components/DropdownFooter/style.js +16 -40
  334. package/es/utils/components/ErrorBoundary/index.js +51 -25
  335. package/es/utils/components/FieldLabel/index.js +119 -146
  336. package/es/utils/components/FieldLabel/style.js +82 -128
  337. package/es/utils/components/FilterDropdown/index.js +54 -81
  338. package/es/utils/components/FilterDropdown/style.js +17 -38
  339. package/es/utils/components/InlineErrorFormItem/index.js +132 -167
  340. package/es/utils/components/InlineErrorFormItem/style.js +51 -79
  341. package/es/utils/components/LabelIconTip/index.js +58 -56
  342. package/es/utils/components/LabelIconTip/style.js +36 -57
  343. package/es/utils/components/ProFormContext/index.js +2 -6
  344. package/es/utils/conversionMomentValue/index.js +102 -83
  345. package/es/utils/dateArrayFormatter/index.js +31 -16
  346. package/es/utils/genCopyable/index.js +44 -38
  347. package/es/utils/getFieldPropsOrFormItemProps/index.js +10 -7
  348. package/es/utils/hooks/useDebounceFn/index.js +58 -48
  349. package/es/utils/hooks/useDebounceValue/index.js +29 -19
  350. package/es/utils/hooks/useDeepCompareEffect/index.js +29 -44
  351. package/es/utils/hooks/useDeepCompareMemo/index.js +12 -10
  352. package/es/utils/hooks/useDocumentTitle/index.js +5 -9
  353. package/es/utils/hooks/useFetchData/index.js +70 -63
  354. package/es/utils/hooks/useForceRender/index.js +12 -9
  355. package/es/utils/hooks/useLatest/index.js +8 -8
  356. package/es/utils/hooks/usePrevious/index.js +5 -9
  357. package/es/utils/hooks/useReactiveRef/index.js +4 -8
  358. package/es/utils/hooks/useRefCallback/index.js +6 -10
  359. package/es/utils/hooks/useRefFunction/index.js +11 -10
  360. package/es/utils/index.d.ts +1 -3
  361. package/es/utils/index.js +9 -84
  362. package/es/utils/isBrowser/index.js +14 -9
  363. package/es/utils/isDeepEqualReact/index.js +79 -53
  364. package/es/utils/isDropdownValueType/index.js +4 -8
  365. package/es/utils/isImg/index.js +3 -6
  366. package/es/utils/isNil/index.js +3 -5
  367. package/es/utils/isUrl/index.js +10 -10
  368. package/es/utils/merge/index.js +20 -27
  369. package/es/utils/nanoid/index.js +24 -18
  370. package/es/utils/omitBoolean/index.js +8 -7
  371. package/es/utils/omitUndefined/index.js +6 -10
  372. package/es/utils/omitUndefinedAndEmptyArr/index.js +7 -11
  373. package/es/utils/parseValueToMoment/index.js +16 -14
  374. package/es/utils/pickProFormItemProps/index.js +9 -42
  375. package/es/utils/pickProProps/index.js +9 -11
  376. package/es/utils/proFieldParsingText/index.js +141 -49
  377. package/es/utils/runFunction/index.js +8 -8
  378. package/es/utils/stringify/index.js +4 -9
  379. package/es/utils/transformKeySubmitValue/index.js +254 -130
  380. package/es/utils/typing.js +1 -0
  381. package/es/utils/useEditableArray/index.js +776 -611
  382. package/es/utils/useEditableMap/index.js +179 -161
  383. package/es/utils/useMediaQuery/index.js +47 -43
  384. package/es/utils/useMediaQuery/query.js +19 -15
  385. package/es/utils/useMountMergeState/index.d.ts +1 -1
  386. package/es/utils/useMountMergeState/index.js +2 -5
  387. package/es/version.js +3 -7
  388. package/lib/card/ProCard.d.ts +0 -1
  389. package/lib/card/ProCard.js +20 -52
  390. package/lib/card/components/Actions/index.js +39 -57
  391. package/lib/card/components/Actions/style.js +77 -115
  392. package/lib/card/components/Card/index.js +222 -287
  393. package/lib/card/components/Card/style.js +197 -281
  394. package/lib/card/components/CheckCard/Group.js +205 -230
  395. package/lib/card/components/CheckCard/index.js +160 -190
  396. package/lib/card/components/CheckCard/style.js +192 -227
  397. package/lib/card/components/Divider/index.js +30 -47
  398. package/lib/card/components/Divider/style.js +35 -69
  399. package/lib/card/components/Loading/index.js +85 -42
  400. package/lib/card/components/Loading/style.js +48 -78
  401. package/lib/card/components/Operation/index.js +29 -46
  402. package/lib/card/components/Operation/style.js +24 -58
  403. package/lib/card/components/Statistic/index.js +84 -117
  404. package/lib/card/components/Statistic/style.js +81 -130
  405. package/lib/card/components/StatisticCard/index.d.ts +0 -2
  406. package/lib/card/components/StatisticCard/index.js +72 -103
  407. package/lib/card/components/StatisticCard/style.js +41 -70
  408. package/lib/card/index.d.ts +2 -2
  409. package/lib/card/index.js +34 -41
  410. package/lib/card/typing.js +4 -16
  411. package/lib/descriptions/index.js +369 -436
  412. package/lib/descriptions/useFetchData.js +99 -100
  413. package/lib/field/AllProField.js +477 -415
  414. package/lib/field/FieldHOC/index.js +37 -56
  415. package/lib/field/PureProField.js +141 -187
  416. package/lib/field/ValueTypeToComponent.js +725 -454
  417. package/lib/field/components/Cascader/index.d.ts +2 -2
  418. package/lib/field/components/Cascader/index.js +132 -171
  419. package/lib/field/components/Checkbox/index.d.ts +1 -1
  420. package/lib/field/components/Checkbox/index.js +113 -155
  421. package/lib/field/components/Code/index.js +73 -86
  422. package/lib/field/components/ColorPicker/index.d.ts +2 -2
  423. package/lib/field/components/ColorPicker/index.js +61 -103
  424. package/lib/field/components/DatePicker/index.d.ts +2 -2
  425. package/lib/field/components/DatePicker/index.js +109 -145
  426. package/lib/field/components/Digit/index.js +92 -110
  427. package/lib/field/components/DigitRange/index.js +108 -122
  428. package/lib/field/components/FromNow/index.js +57 -90
  429. package/lib/field/components/Image/index.js +52 -76
  430. package/lib/field/components/IndexColumn/index.js +50 -72
  431. package/lib/field/components/Money/index.js +254 -281
  432. package/lib/field/components/Options/index.js +68 -98
  433. package/lib/field/components/Password/index.js +66 -85
  434. package/lib/field/components/Percent/index.js +80 -101
  435. package/lib/field/components/Percent/util.js +28 -33
  436. package/lib/field/components/Progress/index.js +61 -80
  437. package/lib/field/components/Radio/index.d.ts +1 -1
  438. package/lib/field/components/Radio/index.js +92 -134
  439. package/lib/field/components/RangePicker/index.d.ts +2 -2
  440. package/lib/field/components/RangePicker/index.js +129 -164
  441. package/lib/field/components/Rate/index.js +43 -60
  442. package/lib/field/components/Second/index.js +67 -84
  443. package/lib/field/components/Segmented/index.d.ts +1 -1
  444. package/lib/field/components/Segmented/index.js +74 -117
  445. package/lib/field/components/Select/LightSelect/index.d.ts +1 -1
  446. package/lib/field/components/Select/LightSelect/index.js +216 -282
  447. package/lib/field/components/Select/SearchSelect/index.js +195 -245
  448. package/lib/field/components/Select/index.d.ts +2 -2
  449. package/lib/field/components/Select/index.js +307 -379
  450. package/lib/field/components/Slider/index.js +43 -70
  451. package/lib/field/components/Status/index.js +89 -52
  452. package/lib/field/components/Switch/index.d.ts +1 -1
  453. package/lib/field/components/Switch/index.js +67 -98
  454. package/lib/field/components/Text/index.js +58 -74
  455. package/lib/field/components/TextArea/index.js +44 -80
  456. package/lib/field/components/TextArea/readonly.js +43 -76
  457. package/lib/field/components/TimePicker/index.js +188 -217
  458. package/lib/field/components/TreeSelect/index.d.ts +2 -2
  459. package/lib/field/components/TreeSelect/index.js +185 -206
  460. package/lib/field/index.js +240 -96
  461. package/lib/form/BaseForm/BaseForm.js +595 -634
  462. package/lib/form/BaseForm/EditOrReadOnlyContext.js +9 -36
  463. package/lib/form/BaseForm/LightWrapper/index.js +111 -182
  464. package/lib/form/BaseForm/LightWrapper/style.js +19 -56
  465. package/lib/form/BaseForm/Submitter/index.js +75 -126
  466. package/lib/form/BaseForm/index.js +37 -20
  467. package/lib/form/FieldContext.js +8 -36
  468. package/lib/form/components/Captcha/index.js +169 -196
  469. package/lib/form/components/Cascader/index.js +56 -104
  470. package/lib/form/components/Checkbox/index.js +83 -128
  471. package/lib/form/components/ColorPicker/index.js +51 -92
  472. package/lib/form/components/DatePicker/BaseDatePicker.js +54 -98
  473. package/lib/form/components/DatePicker/DatePicker.js +32 -77
  474. package/lib/form/components/DatePicker/DateTimePicker.js +32 -76
  475. package/lib/form/components/DatePicker/MonthPicker.js +32 -77
  476. package/lib/form/components/DatePicker/QuarterPicker.js +32 -77
  477. package/lib/form/components/DatePicker/TimePicker.js +55 -103
  478. package/lib/form/components/DatePicker/WeekPicker.js +32 -77
  479. package/lib/form/components/DatePicker/YearPicker.js +32 -77
  480. package/lib/form/components/DatePicker/index.js +19 -44
  481. package/lib/form/components/DateRangePicker/BaseDateRanger.js +53 -100
  482. package/lib/form/components/DateRangePicker/DateMonthRangePicker.js +36 -78
  483. package/lib/form/components/DateRangePicker/DateQuarterRangePicker.js +36 -78
  484. package/lib/form/components/DateRangePicker/DateTimeRangePicker.js +36 -78
  485. package/lib/form/components/DateRangePicker/DateWeekRangePicker.js +36 -78
  486. package/lib/form/components/DateRangePicker/DateYearRangePicker.js +36 -78
  487. package/lib/form/components/DateRangePicker/TimeRangePicker.js +53 -97
  488. package/lib/form/components/DateRangePicker/index.js +36 -78
  489. package/lib/form/components/Dependency/index.js +68 -127
  490. package/lib/form/components/Digit/DigitRange.js +50 -103
  491. package/lib/form/components/Digit/index.js +55 -106
  492. package/lib/form/components/Field/index.js +89 -153
  493. package/lib/form/components/FieldSet/index.js +107 -153
  494. package/lib/form/components/FormItem/FormItemRender/index.js +142 -114
  495. package/lib/form/components/FormItem/Group/index.js +143 -198
  496. package/lib/form/components/FormItem/Group/style.js +46 -77
  497. package/lib/form/components/FormItem/index.js +257 -316
  498. package/lib/form/components/FormItem/warpField.js +229 -308
  499. package/lib/form/components/List/ListContainer.js +227 -211
  500. package/lib/form/components/List/ListItem.js +268 -374
  501. package/lib/form/components/List/index.d.ts +2 -2
  502. package/lib/form/components/List/index.js +211 -277
  503. package/lib/form/components/List/style.js +53 -110
  504. package/lib/form/components/Money/index.js +58 -108
  505. package/lib/form/components/Radio/index.js +60 -114
  506. package/lib/form/components/Rate/index.js +45 -88
  507. package/lib/form/components/SchemaForm/index.js +154 -193
  508. package/lib/form/components/SchemaForm/layoutType/Embed.js +12 -24
  509. package/lib/form/components/SchemaForm/layoutType/StepsForm.js +43 -96
  510. package/lib/form/components/SchemaForm/layoutType/index.js +18 -35
  511. package/lib/form/components/SchemaForm/typing.js +4 -16
  512. package/lib/form/components/SchemaForm/valueType/dependency.js +25 -69
  513. package/lib/form/components/SchemaForm/valueType/divider.js +16 -45
  514. package/lib/form/components/SchemaForm/valueType/field.js +67 -128
  515. package/lib/form/components/SchemaForm/valueType/formList.js +22 -58
  516. package/lib/form/components/SchemaForm/valueType/formSet.js +22 -68
  517. package/lib/form/components/SchemaForm/valueType/group.js +21 -53
  518. package/lib/form/components/SchemaForm/valueType/ignore.js +8 -25
  519. package/lib/form/components/SchemaForm/valueType/index.js +27 -43
  520. package/lib/form/components/Segmented/index.js +50 -89
  521. package/lib/form/components/Select/index.js +125 -181
  522. package/lib/form/components/Slider/index.js +62 -119
  523. package/lib/form/components/Switch/index.js +55 -99
  524. package/lib/form/components/Text/index.js +141 -190
  525. package/lib/form/components/TextArea/index.js +42 -85
  526. package/lib/form/components/TreeSelect/index.js +50 -89
  527. package/lib/form/components/UploadButton/index.js +131 -172
  528. package/lib/form/components/UploadDragger/index.js +84 -119
  529. package/lib/form/components/index.js +294 -110
  530. package/lib/form/helpers/grid.js +82 -97
  531. package/lib/form/helpers/index.js +15 -18
  532. package/lib/form/index.js +78 -38
  533. package/lib/form/layouts/DrawerForm/index.js +318 -338
  534. package/lib/form/layouts/DrawerForm/style.js +31 -65
  535. package/lib/form/layouts/LightFilter/index.js +217 -293
  536. package/lib/form/layouts/LightFilter/style.js +54 -89
  537. package/lib/form/layouts/LoginForm/index.js +93 -133
  538. package/lib/form/layouts/LoginForm/style.js +73 -110
  539. package/lib/form/layouts/LoginFormPage/index.js +148 -174
  540. package/lib/form/layouts/LoginFormPage/style.js +133 -165
  541. package/lib/form/layouts/ModalForm/index.js +253 -273
  542. package/lib/form/layouts/ProForm/index.d.ts +1 -1
  543. package/lib/form/layouts/ProForm/index.js +28 -68
  544. package/lib/form/layouts/QueryFilter/Actions.js +57 -77
  545. package/lib/form/layouts/QueryFilter/index.js +308 -390
  546. package/lib/form/layouts/QueryFilter/style.js +43 -84
  547. package/lib/form/layouts/StepsForm/StepForm.js +95 -146
  548. package/lib/form/layouts/StepsForm/index.js +352 -378
  549. package/lib/form/layouts/StepsForm/style.js +34 -65
  550. package/lib/form/layouts/index.js +62 -40
  551. package/lib/form/typing.js +4 -16
  552. package/lib/index.js +133 -34
  553. package/lib/layout/ProLayout.js +449 -528
  554. package/lib/layout/WrapContent.js +34 -46
  555. package/lib/layout/assert/Logo.js +110 -97
  556. package/lib/layout/components/AppsLogoComponents/AppsLogo.js +17 -29
  557. package/lib/layout/components/AppsLogoComponents/DefaultContent.js +55 -85
  558. package/lib/layout/components/AppsLogoComponents/SimpleContent.js +78 -95
  559. package/lib/layout/components/AppsLogoComponents/index.js +98 -105
  560. package/lib/layout/components/AppsLogoComponents/style/default.js +36 -55
  561. package/lib/layout/components/AppsLogoComponents/style/index.js +58 -94
  562. package/lib/layout/components/AppsLogoComponents/style/simple.js +41 -59
  563. package/lib/layout/components/CollapsedIcon/index.js +26 -82
  564. package/lib/layout/components/CollapsedIcon/style.js +47 -81
  565. package/lib/layout/components/Footer.js +33 -65
  566. package/lib/layout/components/FooterToolbar/index.js +87 -132
  567. package/lib/layout/components/FooterToolbar/style/index.js +43 -77
  568. package/lib/layout/components/FooterToolbar/style/stylish.js +16 -54
  569. package/lib/layout/components/GlobalFooter/index.js +43 -61
  570. package/lib/layout/components/GlobalFooter/style.js +37 -68
  571. package/lib/layout/components/GlobalHeader/ActionsContent.js +138 -208
  572. package/lib/layout/components/GlobalHeader/index.d.ts +0 -5
  573. package/lib/layout/components/GlobalHeader/index.js +86 -116
  574. package/lib/layout/components/GlobalHeader/rightContentStyle.js +57 -91
  575. package/lib/layout/components/GlobalHeader/style.js +62 -98
  576. package/lib/layout/components/GridContent/index.js +43 -64
  577. package/lib/layout/components/GridContent/style.js +19 -53
  578. package/lib/layout/components/Header/index.js +105 -156
  579. package/lib/layout/components/Header/style/header.js +53 -87
  580. package/lib/layout/components/Header/style/stylish.js +18 -58
  581. package/lib/layout/components/Help/AsyncContentPanel.js +59 -62
  582. package/lib/layout/components/Help/HelpProvide.js +59 -34
  583. package/lib/layout/components/Help/ProHelpContentPanel.js +139 -157
  584. package/lib/layout/components/Help/ProHelpDrawer.js +54 -102
  585. package/lib/layout/components/Help/ProHelpModal.js +53 -102
  586. package/lib/layout/components/Help/ProHelpPanel.js +192 -254
  587. package/lib/layout/components/Help/ProHelpPopover.js +46 -92
  588. package/lib/layout/components/Help/RenderContentPanel.js +97 -130
  589. package/lib/layout/components/Help/Search.js +130 -191
  590. package/lib/layout/components/Help/index.js +113 -74
  591. package/lib/layout/components/Help/style.js +96 -130
  592. package/lib/layout/components/PageContainer/index.js +245 -308
  593. package/lib/layout/components/PageContainer/style/index.js +83 -133
  594. package/lib/layout/components/PageContainer/style/stylish.js +16 -54
  595. package/lib/layout/components/PageHeader/index.js +149 -156
  596. package/lib/layout/components/PageHeader/style/index.js +129 -182
  597. package/lib/layout/components/PageLoading/index.js +28 -76
  598. package/lib/layout/components/SettingDrawer/BlockCheckbox.js +46 -71
  599. package/lib/layout/components/SettingDrawer/LayoutChange.js +114 -129
  600. package/lib/layout/components/SettingDrawer/RegionalChange.js +38 -65
  601. package/lib/layout/components/SettingDrawer/ThemeColor.js +55 -95
  602. package/lib/layout/components/SettingDrawer/icon/group.js +111 -105
  603. package/lib/layout/components/SettingDrawer/icon/sub.js +72 -133
  604. package/lib/layout/components/SettingDrawer/index.js +425 -447
  605. package/lib/layout/components/SettingDrawer/style/index.js +147 -161
  606. package/lib/layout/components/SiderMenu/Arrow.js +16 -34
  607. package/lib/layout/components/SiderMenu/BaseMenu.js +416 -487
  608. package/lib/layout/components/SiderMenu/SiderMenu.js +254 -367
  609. package/lib/layout/components/SiderMenu/index.js +81 -130
  610. package/lib/layout/components/SiderMenu/style/index.js +178 -226
  611. package/lib/layout/components/SiderMenu/style/menu.js +115 -188
  612. package/lib/layout/components/SiderMenu/style/stylish.js +18 -58
  613. package/lib/layout/components/TopNavHeader/index.js +117 -211
  614. package/lib/layout/components/TopNavHeader/style.js +72 -110
  615. package/lib/layout/context/RouteContext.js +6 -24
  616. package/lib/layout/defaultSettings.js +11 -29
  617. package/lib/layout/getPageTitle.js +53 -60
  618. package/lib/layout/index.js +145 -55
  619. package/lib/layout/locales/en-US/settingDrawer.js +47 -65
  620. package/lib/layout/locales/en-US.js +8 -48
  621. package/lib/layout/locales/index.js +24 -52
  622. package/lib/layout/locales/it-IT/settingDrawer.js +38 -56
  623. package/lib/layout/locales/it-IT.js +8 -48
  624. package/lib/layout/locales/ko-KR/settingDrawer.js +43 -61
  625. package/lib/layout/locales/ko-KR.js +8 -48
  626. package/lib/layout/locales/zh-CN/settingDrawer.js +47 -65
  627. package/lib/layout/locales/zh-CN.js +8 -48
  628. package/lib/layout/locales/zh-TW/settingDrawer.js +39 -57
  629. package/lib/layout/locales/zh-TW.js +8 -48
  630. package/lib/layout/style/index.js +48 -88
  631. package/lib/layout/typing.js +4 -16
  632. package/lib/layout/utils/getBreadcrumbProps.js +117 -107
  633. package/lib/layout/utils/getMenuData.js +23 -40
  634. package/lib/layout/utils/pathTools.js +14 -29
  635. package/lib/layout/utils/useCurrentMenuLayoutProps.js +27 -49
  636. package/lib/layout/utils/utils.js +40 -64
  637. package/lib/list/Item.js +229 -321
  638. package/lib/list/ListView.js +197 -260
  639. package/lib/list/constants.js +7 -35
  640. package/lib/list/index.js +132 -207
  641. package/lib/list/style/index.js +230 -302
  642. package/lib/provider/index.js +270 -215
  643. package/lib/provider/intl.js +140 -188
  644. package/lib/provider/locale/ar_EG.js +51 -69
  645. package/lib/provider/locale/ca_ES.js +49 -67
  646. package/lib/provider/locale/cs_CZ.js +54 -72
  647. package/lib/provider/locale/de_DE.js +51 -69
  648. package/lib/provider/locale/en_GB.js +53 -71
  649. package/lib/provider/locale/en_US.js +55 -73
  650. package/lib/provider/locale/es_ES.js +51 -69
  651. package/lib/provider/locale/fa_IR.js +51 -69
  652. package/lib/provider/locale/fr_FR.js +51 -69
  653. package/lib/provider/locale/he_IL.js +54 -72
  654. package/lib/provider/locale/hr_HR.js +51 -69
  655. package/lib/provider/locale/id_ID.js +51 -69
  656. package/lib/provider/locale/it_IT.js +51 -69
  657. package/lib/provider/locale/ja_JP.js +51 -69
  658. package/lib/provider/locale/ko_KR.js +51 -69
  659. package/lib/provider/locale/mn_MN.js +51 -69
  660. package/lib/provider/locale/ms_MY.js +51 -69
  661. package/lib/provider/locale/nl_NL.js +54 -72
  662. package/lib/provider/locale/pl_PL.js +51 -69
  663. package/lib/provider/locale/pt_BR.js +51 -69
  664. package/lib/provider/locale/ro_RO.js +54 -72
  665. package/lib/provider/locale/ru_RU.js +51 -69
  666. package/lib/provider/locale/sk_SK.js +54 -72
  667. package/lib/provider/locale/sr_RS.js +51 -69
  668. package/lib/provider/locale/sv_SE.js +54 -72
  669. package/lib/provider/locale/th_TH.js +54 -72
  670. package/lib/provider/locale/tr_TR.js +51 -69
  671. package/lib/provider/locale/uk_UA.js +54 -72
  672. package/lib/provider/locale/uz_UZ.js +51 -69
  673. package/lib/provider/locale/vi_VN.js +51 -69
  674. package/lib/provider/locale/zh_CN.js +54 -72
  675. package/lib/provider/locale/zh_HK.js +54 -72
  676. package/lib/provider/locale/zh_TW.js +54 -72
  677. package/lib/provider/typing/layoutToken.d.ts +0 -10
  678. package/lib/provider/typing/layoutToken.js +36 -69
  679. package/lib/provider/useStyle/index.d.ts +1 -1
  680. package/lib/provider/useStyle/index.js +98 -94
  681. package/lib/provider/utils/merge.js +18 -44
  682. package/lib/skeleton/components/Descriptions/index.js +246 -282
  683. package/lib/skeleton/components/List/index.js +221 -236
  684. package/lib/skeleton/components/Result/index.js +63 -84
  685. package/lib/skeleton/index.js +73 -79
  686. package/lib/table/Store/Provide.d.ts +0 -1
  687. package/lib/table/Store/Provide.js +147 -151
  688. package/lib/table/Table.js +664 -712
  689. package/lib/table/components/Alert/index.js +66 -67
  690. package/lib/table/components/Alert/style.js +33 -67
  691. package/lib/table/components/ColumnSetting/index.js +391 -404
  692. package/lib/table/components/ColumnSetting/style.js +77 -123
  693. package/lib/table/components/DragSortTable/index.js +110 -165
  694. package/lib/table/components/DragSortTable/style.js +25 -59
  695. package/lib/table/components/Dropdown/index.js +75 -108
  696. package/lib/table/components/EditableTable/CellEditorTable.js +55 -90
  697. package/lib/table/components/EditableTable/RowEditorTable.js +49 -87
  698. package/lib/table/components/EditableTable/index.js +351 -365
  699. package/lib/table/components/Form/FormRender.js +176 -201
  700. package/lib/table/components/Form/index.js +132 -161
  701. package/lib/table/components/ListToolBar/HeaderMenu.js +74 -128
  702. package/lib/table/components/ListToolBar/index.js +263 -302
  703. package/lib/table/components/ListToolBar/style.js +124 -149
  704. package/lib/table/components/ToolBar/DensityIcon.js +43 -71
  705. package/lib/table/components/ToolBar/FullscreenIcon.js +30 -45
  706. package/lib/table/components/ToolBar/index.js +247 -299
  707. package/lib/table/index.js +179 -71
  708. package/lib/table/style/index.js +135 -190
  709. package/lib/table/typing.d.ts +2 -2
  710. package/lib/table/typing.js +4 -16
  711. package/lib/table/useFetchData.js +437 -241
  712. package/lib/table/utils/cellRenderToFromItem.js +192 -277
  713. package/lib/table/utils/columnRender.js +126 -144
  714. package/lib/table/utils/columnSort.js +27 -39
  715. package/lib/table/utils/genProColumnToColumn.js +111 -141
  716. package/lib/table/utils/index.js +204 -128
  717. package/lib/table/utils/useDragSort.js +141 -188
  718. package/lib/utils/components/DropdownFooter/index.js +56 -89
  719. package/lib/utils/components/DropdownFooter/style.js +21 -55
  720. package/lib/utils/components/ErrorBoundary/index.js +55 -53
  721. package/lib/utils/components/FieldLabel/index.js +126 -176
  722. package/lib/utils/components/FieldLabel/style.js +87 -143
  723. package/lib/utils/components/FilterDropdown/index.js +61 -109
  724. package/lib/utils/components/FilterDropdown/style.js +22 -53
  725. package/lib/utils/components/InlineErrorFormItem/index.js +137 -193
  726. package/lib/utils/components/InlineErrorFormItem/style.js +56 -94
  727. package/lib/utils/components/LabelIconTip/index.js +62 -82
  728. package/lib/utils/components/LabelIconTip/style.js +41 -72
  729. package/lib/utils/components/ProFormContext/index.js +7 -34
  730. package/lib/utils/conversionMomentValue/index.js +112 -115
  731. package/lib/utils/dateArrayFormatter/index.js +38 -46
  732. package/lib/utils/genCopyable/index.js +49 -66
  733. package/lib/utils/getFieldPropsOrFormItemProps/index.js +15 -27
  734. package/lib/utils/hooks/useDebounceFn/index.js +63 -65
  735. package/lib/utils/hooks/useDebounceValue/index.js +35 -38
  736. package/lib/utils/hooks/useDeepCompareEffect/index.js +37 -61
  737. package/lib/utils/hooks/useDeepCompareMemo/index.js +17 -39
  738. package/lib/utils/hooks/useDocumentTitle/index.js +10 -28
  739. package/lib/utils/hooks/useFetchData/index.js +74 -89
  740. package/lib/utils/hooks/useForceRender/index.js +16 -26
  741. package/lib/utils/hooks/useLatest/index.js +11 -26
  742. package/lib/utils/hooks/usePrevious/index.js +9 -27
  743. package/lib/utils/hooks/useReactiveRef/index.js +10 -37
  744. package/lib/utils/hooks/useRefCallback/index.js +9 -27
  745. package/lib/utils/hooks/useRefFunction/index.js +16 -29
  746. package/lib/utils/index.d.ts +1 -3
  747. package/lib/utils/index.js +455 -138
  748. package/lib/utils/isBrowser/index.js +18 -27
  749. package/lib/utils/isDeepEqualReact/index.js +83 -70
  750. package/lib/utils/isDropdownValueType/index.js +8 -26
  751. package/lib/utils/isImg/index.js +6 -23
  752. package/lib/utils/isNil/index.js +7 -23
  753. package/lib/utils/isUrl/index.js +14 -28
  754. package/lib/utils/merge/index.js +26 -44
  755. package/lib/utils/nanoid/index.js +28 -36
  756. package/lib/utils/omitBoolean/index.js +12 -25
  757. package/lib/utils/omitUndefined/index.js +10 -28
  758. package/lib/utils/omitUndefinedAndEmptyArr/index.js +11 -29
  759. package/lib/utils/parseValueToMoment/index.js +26 -47
  760. package/lib/utils/pickProFormItemProps/index.js +12 -59
  761. package/lib/utils/pickProProps/index.js +13 -29
  762. package/lib/utils/proFieldParsingText/index.js +146 -77
  763. package/lib/utils/runFunction/index.js +12 -26
  764. package/lib/utils/stringify/index.js +14 -28
  765. package/lib/utils/transformKeySubmitValue/index.js +262 -160
  766. package/lib/utils/typing.js +4 -16
  767. package/lib/utils/useEditableArray/index.js +790 -630
  768. package/lib/utils/useEditableMap/index.js +188 -179
  769. package/lib/utils/useMediaQuery/index.js +53 -73
  770. package/lib/utils/useMediaQuery/query.js +23 -32
  771. package/lib/utils/useMountMergeState/index.d.ts +1 -1
  772. package/lib/utils/useMountMergeState/index.js +10 -33
  773. package/lib/version.js +7 -25
  774. package/package.json +2 -1
  775. package/es/card/components/TabPane/index.d.ts +0 -26
  776. package/es/card/components/TabPane/index.js +0 -84
  777. package/es/utils/compareVersions/coverToNewToken.d.ts +0 -2
  778. package/es/utils/compareVersions/coverToNewToken.js +0 -56
  779. package/es/utils/compareVersions/index.d.ts +0 -8
  780. package/es/utils/compareVersions/index.js +0 -48
  781. package/lib/card/components/TabPane/index.d.ts +0 -26
  782. package/lib/card/components/TabPane/index.js +0 -111
  783. package/lib/utils/compareVersions/coverToNewToken.d.ts +0 -2
  784. package/lib/utils/compareVersions/coverToNewToken.js +0 -73
  785. package/lib/utils/compareVersions/index.d.ts +0 -8
  786. package/lib/utils/compareVersions/index.js +0 -68
@@ -1,161 +1,106 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
-
53
- // src/form/BaseForm/BaseForm.tsx
54
- import { useUrlSearchParams } from "@umijs/use-params";
55
- import { ConfigProvider, Form, Spin } from "antd";
56
- import classNames from "classnames";
57
- import omit from "rc-util/lib/omit";
58
- import get from "rc-util/lib/utils/get";
59
- import { default as namePathSet, default as set } from "rc-util/lib/utils/set";
60
- import { noteOnce } from "rc-util/lib/warning";
61
- import React, {
62
- useContext,
63
- useEffect,
64
- useImperativeHandle,
65
- useMemo,
66
- useRef,
67
- useState
68
- } from "react";
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
5
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
6
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
7
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
8
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
9
+ var _excluded = ["children", "contentRender", "submitter", "fieldProps", "formItemProps", "groupProps", "transformKey", "formRef", "onInit", "form", "loading", "formComponentType", "extraUrlParams", "syncToUrl", "onUrlSearchChange", "onReset", "omitNil", "isKeyPressSubmit", "autoFocusFirstInput", "grid", "rowProps", "colProps"],
10
+ _excluded2 = ["extraUrlParams", "syncToUrl", "isKeyPressSubmit", "syncToUrlAsImportant", "syncToInitialValues", "children", "contentRender", "submitter", "fieldProps", "proFieldProps", "formItemProps", "groupProps", "dateFormatter", "formRef", "onInit", "form", "formComponentType", "onReset", "grid", "rowProps", "colProps", "omitNil", "request", "params", "initialValues", "formKey", "readonly", "onLoadingChange", "loading"];
11
+ /* eslint-disable react-hooks/exhaustive-deps */import { useUrlSearchParams } from '@umijs/use-params';
12
+ import { ConfigProvider, Form, Spin } from 'antd';
13
+ import classNames from 'classnames';
14
+ import { get, set as namePathSet, set, warning } from 'rc-util';
15
+ import omit from 'rc-util/lib/omit';
16
+ import React, { useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
69
17
  import { ProConfigProvider } from "../../provider";
70
- import {
71
- ProFormContext,
72
- conversionMomentValue,
73
- isDeepEqualReact,
74
- nanoid,
75
- runFunction,
76
- transformKeySubmitValue,
77
- useFetchData,
78
- useMountMergeState,
79
- usePrevious,
80
- useRefFunction,
81
- useStyle
82
- } from "../../utils";
18
+ import { ProFormContext, conversionMomentValue, isDeepEqualReact, nanoid, runFunction, transformKeySubmitValue, useFetchData, useMountMergeState, usePrevious, useRefFunction, useStyle } from "../../utils";
83
19
  import { FormListContext } from "../components/List";
84
20
  import FieldContext from "../FieldContext";
85
21
  import { GridContext, useGridHelpers } from "../helpers";
86
22
  import { EditOrReadOnlyContext } from "./EditOrReadOnlyContext";
87
23
  import Submitter from "./Submitter";
88
- var genParams = (syncUrl, params, type) => {
24
+ import { jsx as _jsx } from "react/jsx-runtime";
25
+ import { jsxs as _jsxs } from "react/jsx-runtime";
26
+ var noteOnce = warning.noteOnce;
27
+
28
+ // Define ProFormInstance and ProFormRef
29
+
30
+ var genParams = function genParams(syncUrl, params, type) {
89
31
  if (syncUrl === true) {
90
32
  return params;
91
33
  }
92
34
  return runFunction(syncUrl, params, type);
93
35
  };
94
- var covertFormName = (name) => {
95
- if (!name)
96
- return name;
97
- if (Array.isArray(name))
98
- return name;
36
+
37
+ /**
38
+ * It takes a name path and converts it to an array.
39
+ * @param {NamePath} name - The name of the form.
40
+ * @returns string[]
41
+ *
42
+ * a-> [a]
43
+ * [a] -> [a]
44
+ */
45
+ var covertFormName = function covertFormName(name) {
46
+ if (!name) return name;
47
+ if (Array.isArray(name)) return name;
99
48
  return [name];
100
49
  };
101
50
  function BaseFormComponents(props) {
102
- var _b, _c;
103
- const _a = props, {
104
- children,
105
- contentRender,
106
- submitter,
107
- fieldProps,
108
- formItemProps,
109
- groupProps,
110
- transformKey,
111
- formRef: propsFormRef,
112
- onInit,
113
- form,
114
- loading,
115
- formComponentType,
116
- extraUrlParams = {},
117
- syncToUrl,
118
- onUrlSearchChange,
119
- onReset,
120
- omitNil = true,
121
- isKeyPressSubmit,
122
- autoFocusFirstInput = true,
123
- grid,
124
- rowProps,
125
- colProps
126
- } = _a, rest = __objRest(_a, [
127
- "children",
128
- "contentRender",
129
- "submitter",
130
- "fieldProps",
131
- "formItemProps",
132
- "groupProps",
133
- "transformKey",
134
- "formRef",
135
- "onInit",
136
- "form",
137
- "loading",
138
- "formComponentType",
139
- "extraUrlParams",
140
- "syncToUrl",
141
- "onUrlSearchChange",
142
- "onReset",
143
- "omitNil",
144
- "isKeyPressSubmit",
145
- "autoFocusFirstInput",
146
- "grid",
147
- "rowProps",
148
- "colProps"
149
- ]);
150
- const formInstance = Form.useFormInstance();
151
- const { componentSize } = ((_c = (_b = ConfigProvider) == null ? void 0 : _b.useConfig) == null ? void 0 : _c.call(_b)) || {
152
- componentSize: "middle"
153
- };
154
- const formRef = useRef(form || formInstance);
155
- const { RowWrapper } = useGridHelpers({ grid, rowProps });
156
- const getFormInstance = useRefFunction(() => formInstance);
157
- const formatValues = useMemo(
158
- () => ({
51
+ var _ConfigProvider$useCo;
52
+ var children = props.children,
53
+ contentRender = props.contentRender,
54
+ submitter = props.submitter,
55
+ fieldProps = props.fieldProps,
56
+ formItemProps = props.formItemProps,
57
+ groupProps = props.groupProps,
58
+ transformKey = props.transformKey,
59
+ propsFormRef = props.formRef,
60
+ onInit = props.onInit,
61
+ form = props.form,
62
+ loading = props.loading,
63
+ formComponentType = props.formComponentType,
64
+ _props$extraUrlParams = props.extraUrlParams,
65
+ extraUrlParams = _props$extraUrlParams === void 0 ? {} : _props$extraUrlParams,
66
+ syncToUrl = props.syncToUrl,
67
+ onUrlSearchChange = props.onUrlSearchChange,
68
+ _onReset = props.onReset,
69
+ _props$omitNil = props.omitNil,
70
+ omitNil = _props$omitNil === void 0 ? true : _props$omitNil,
71
+ isKeyPressSubmit = props.isKeyPressSubmit,
72
+ _props$autoFocusFirst = props.autoFocusFirstInput,
73
+ autoFocusFirstInput = _props$autoFocusFirst === void 0 ? true : _props$autoFocusFirst,
74
+ grid = props.grid,
75
+ rowProps = props.rowProps,
76
+ colProps = props.colProps,
77
+ rest = _objectWithoutProperties(props, _excluded);
78
+
79
+ /**
80
+ * 获取 form 实例
81
+ */
82
+ var formInstance = Form.useFormInstance();
83
+ var _ref = (ConfigProvider === null || ConfigProvider === void 0 || (_ConfigProvider$useCo = ConfigProvider.useConfig) === null || _ConfigProvider$useCo === void 0 ? void 0 : _ConfigProvider$useCo.call(ConfigProvider)) || {
84
+ componentSize: 'middle'
85
+ },
86
+ componentSize = _ref.componentSize;
87
+
88
+ /** 同步 url 上的参数 */
89
+ var formRef = useRef(form || formInstance);
90
+
91
+ /**
92
+ * 获取布局
93
+ */
94
+ var _useGridHelpers = useGridHelpers({
95
+ grid: grid,
96
+ rowProps: rowProps
97
+ }),
98
+ RowWrapper = _useGridHelpers.RowWrapper;
99
+ var getFormInstance = useRefFunction(function () {
100
+ return formInstance;
101
+ });
102
+ var formatValues = useMemo(function () {
103
+ return {
159
104
  /**
160
105
  * 获取被 ProForm 格式化后的所有数据
161
106
  * @param allData boolean
@@ -164,16 +109,13 @@ function BaseFormComponents(props) {
164
109
  *
165
110
  * @example getFieldsFormatValue(true) ->返回所有数据,即使没有被 form 托管的
166
111
  */
167
- getFieldsFormatValue: (allData, omitNilParam) => {
168
- const formInstance2 = getFormInstance();
169
- if (!formInstance2) {
112
+ getFieldsFormatValue: function getFieldsFormatValue(allData, omitNilParam) {
113
+ var formInstance = getFormInstance();
114
+ if (!formInstance) {
170
115
  return {};
171
116
  }
172
- const values = formInstance2.getFieldsValue(allData);
173
- return transformKey(
174
- values,
175
- omitNilParam !== void 0 ? omitNilParam : omitNil
176
- );
117
+ var values = formInstance.getFieldsValue(allData);
118
+ return transformKey(values, omitNilParam !== undefined ? omitNilParam : omitNil);
177
119
  },
178
120
  /**
179
121
  * 获取被 ProForm 格式化后的单个数据
@@ -184,26 +126,26 @@ function BaseFormComponents(props) {
184
126
  * @example {a:{b:value}} -> getFieldFormatValue(['a', 'b']) -> value
185
127
  */
186
128
  /** 获取格式化之后的单个数据 */
187
- getFieldFormatValue: (paramsNameList = [], omitNilParam) => {
188
- const formInstance2 = getFormInstance();
189
- if (!formInstance2) {
190
- return void 0;
129
+ getFieldFormatValue: function getFieldFormatValue() {
130
+ var paramsNameList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
131
+ var omitNilParam = arguments.length > 1 ? arguments[1] : undefined;
132
+ var formInstance = getFormInstance();
133
+ if (!formInstance) {
134
+ return undefined;
191
135
  }
192
- const nameList = covertFormName(paramsNameList);
193
- if (!nameList)
194
- throw new Error("nameList is require");
195
- const value = formInstance2.getFieldValue(nameList);
196
- const obj = nameList ? set({}, nameList, value) : value;
197
- const newNameList = [...nameList];
136
+ var nameList = covertFormName(paramsNameList);
137
+ if (!nameList) throw new Error('nameList is require');
138
+ var value = formInstance.getFieldValue(nameList);
139
+ var obj = nameList ? set({}, nameList, value) : value;
140
+ //transformKey会将keys重新和nameList拼接,所以这里要将nameList的首个元素弹出
141
+ var newNameList = _toConsumableArray(nameList);
198
142
  newNameList.shift();
199
- const transformed = transformKey(
200
- obj,
201
- omitNilParam !== void 0 ? omitNilParam : omitNil,
202
- newNameList
203
- );
204
- const result = get(transformed, nameList);
205
- if (result && typeof result === "object" && !Array.isArray(result)) {
206
- const objValue = Object.values(result)[0];
143
+ var transformed = transformKey(obj, omitNilParam !== undefined ? omitNilParam : omitNil, newNameList);
144
+ var result = get(transformed, nameList);
145
+ // 如果结果是对象,返回对象的值
146
+ if (result && _typeof(result) === 'object' && !Array.isArray(result)) {
147
+ var objValue = Object.values(result)[0];
148
+ // 如果对象的值是数组,返回数组
207
149
  if (Array.isArray(objValue)) {
208
150
  return objValue;
209
151
  }
@@ -220,19 +162,15 @@ function BaseFormComponents(props) {
220
162
  * @example {a:{b:value}} -> getFieldFormatValueObject(['a', 'b']) -> {a:{b:value}}
221
163
  */
222
164
  /** 获取格式化之后的单个数据 */
223
- getFieldFormatValueObject: (paramsNameList, omitNilParam) => {
224
- const formInstance2 = getFormInstance();
225
- if (!formInstance2) {
165
+ getFieldFormatValueObject: function getFieldFormatValueObject(paramsNameList, omitNilParam) {
166
+ var formInstance = getFormInstance();
167
+ if (!formInstance) {
226
168
  return {};
227
169
  }
228
- const nameList = covertFormName(paramsNameList);
229
- const value = formInstance2.getFieldValue(nameList);
230
- const obj = nameList ? set({}, nameList, value) : value;
231
- return transformKey(
232
- obj,
233
- omitNilParam !== void 0 ? omitNilParam : omitNil,
234
- nameList
235
- );
170
+ var nameList = covertFormName(paramsNameList);
171
+ var value = formInstance.getFieldValue(nameList);
172
+ var obj = nameList ? set({}, nameList, value) : value;
173
+ return transformKey(obj, omitNilParam !== undefined ? omitNilParam : omitNil, nameList);
236
174
  },
237
175
  /**
238
176
  /**
@@ -243,134 +181,137 @@ function BaseFormComponents(props) {
243
181
  *
244
182
  * @example validateFieldsReturnFormatValue -> {a:{b:value}}
245
183
  */
246
- validateFieldsReturnFormatValue: (nameList, omitNilParam) => __async(this, null, function* () {
247
- const formInstance2 = getFormInstance();
248
- if (!formInstance2) {
249
- return {};
184
+ validateFieldsReturnFormatValue: function () {
185
+ var _validateFieldsReturnFormatValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(nameList, omitNilParam) {
186
+ var formInstance, values, transformedKey;
187
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
188
+ while (1) switch (_context.prev = _context.next) {
189
+ case 0:
190
+ formInstance = getFormInstance();
191
+ if (formInstance) {
192
+ _context.next = 3;
193
+ break;
194
+ }
195
+ return _context.abrupt("return", {});
196
+ case 3:
197
+ if (!(!Array.isArray(nameList) && nameList)) {
198
+ _context.next = 5;
199
+ break;
200
+ }
201
+ throw new Error('nameList must be array');
202
+ case 5:
203
+ _context.next = 7;
204
+ return formInstance.validateFields(nameList);
205
+ case 7:
206
+ values = _context.sent;
207
+ transformedKey = transformKey(values, omitNilParam !== undefined ? omitNilParam : omitNil);
208
+ return _context.abrupt("return", transformedKey ? transformedKey : {});
209
+ case 10:
210
+ case "end":
211
+ return _context.stop();
212
+ }
213
+ }, _callee);
214
+ }));
215
+ function validateFieldsReturnFormatValue(_x, _x2) {
216
+ return _validateFieldsReturnFormatValue.apply(this, arguments);
250
217
  }
251
- if (!Array.isArray(nameList) && nameList)
252
- throw new Error("nameList must be array");
253
- const values = yield formInstance2.validateFields(nameList);
254
- const transformedKey = transformKey(
255
- values,
256
- omitNilParam !== void 0 ? omitNilParam : omitNil
257
- );
258
- return transformedKey ? transformedKey : {};
259
- })
260
- }),
261
- [omitNil, transformKey, getFormInstance]
262
- );
263
- const items = useMemo(() => {
264
- return React.Children.toArray(children).map((item, index) => {
265
- if (index === 0 && React.isValidElement(item) && autoFocusFirstInput) {
266
- return React.cloneElement(item, __spreadProps(__spreadValues({}, item.props), {
218
+ return validateFieldsReturnFormatValue;
219
+ }()
220
+ };
221
+ }, [omitNil, transformKey, getFormInstance]);
222
+ var items = useMemo(function () {
223
+ return React.Children.toArray(children).map(function (item, index) {
224
+ if (index === 0 && /*#__PURE__*/React.isValidElement(item) && autoFocusFirstInput) {
225
+ return /*#__PURE__*/React.cloneElement(item, _objectSpread(_objectSpread({}, item.props), {}, {
267
226
  autoFocus: autoFocusFirstInput
268
227
  }));
269
228
  }
270
229
  return item;
271
230
  });
272
231
  }, [autoFocusFirstInput, children]);
273
- const submitterProps = useMemo(
274
- () => typeof submitter === "boolean" || !submitter ? {} : submitter,
275
- [submitter]
276
- );
277
- const submitterNode = useMemo(() => {
278
- if (submitter === false)
279
- return void 0;
280
- return /* @__PURE__ */ React.createElement(
281
- Submitter,
282
- __spreadProps(__spreadValues({
283
- key: "submitter"
284
- }, submitterProps), {
285
- onReset: () => {
286
- var _a2, _b2, _c2;
287
- const finalValues = transformKey(
288
- (_a2 = formRef.current) == null ? void 0 : _a2.getFieldsValue(),
289
- omitNil
290
- );
291
- (_b2 = submitterProps == null ? void 0 : submitterProps.onReset) == null ? void 0 : _b2.call(submitterProps, finalValues);
292
- onReset == null ? void 0 : onReset(finalValues);
293
- if (syncToUrl) {
294
- const params = Object.keys(
295
- transformKey((_c2 = formRef.current) == null ? void 0 : _c2.getFieldsValue(), false)
296
- ).reduce((pre, next) => {
297
- return __spreadProps(__spreadValues({}, pre), {
298
- [next]: finalValues[next] || void 0
299
- });
300
- }, extraUrlParams);
301
- onUrlSearchChange(genParams(syncToUrl, params || {}, "set"));
302
- }
303
- },
304
- submitButtonProps: __spreadValues({
305
- loading
306
- }, submitterProps.submitButtonProps)
307
- })
308
- );
309
- }, [
310
- submitter,
311
- submitterProps,
312
- loading,
313
- transformKey,
314
- omitNil,
315
- onReset,
316
- syncToUrl,
317
- extraUrlParams,
318
- onUrlSearchChange
319
- ]);
320
- const content = useMemo(() => {
321
- const wrapItems = grid ? /* @__PURE__ */ React.createElement(RowWrapper, null, items) : items;
232
+
233
+ /** 计算 props 的对象 */
234
+ var submitterProps = useMemo(function () {
235
+ return typeof submitter === 'boolean' || !submitter ? {} : submitter;
236
+ }, [submitter]);
237
+
238
+ /** 渲染提交按钮与重置按钮 */
239
+ var submitterNode = useMemo(function () {
240
+ if (submitter === false) return undefined;
241
+ return /*#__PURE__*/_jsx(Submitter, _objectSpread(_objectSpread({}, submitterProps), {}, {
242
+ onReset: function onReset() {
243
+ var _formRef$current, _submitterProps$onRes;
244
+ var finalValues = transformKey((_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue(), omitNil);
245
+ submitterProps === null || submitterProps === void 0 || (_submitterProps$onRes = submitterProps.onReset) === null || _submitterProps$onRes === void 0 || _submitterProps$onRes.call(submitterProps, finalValues);
246
+ _onReset === null || _onReset === void 0 || _onReset(finalValues);
247
+ // 如果 syncToUrl,清空一下数据
248
+ if (syncToUrl) {
249
+ var _formRef$current2;
250
+ // 把没有的值设置为未定义可以删掉 url 的参数
251
+ var params = Object.keys(transformKey((_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldsValue(), false)).reduce(function (pre, next) {
252
+ return _objectSpread(_objectSpread({}, pre), {}, _defineProperty({}, next, finalValues[next] || undefined));
253
+ }, extraUrlParams);
254
+
255
+ /** 在同步到 url 上时对参数进行转化 */
256
+ onUrlSearchChange(genParams(syncToUrl, params || {}, 'set'));
257
+ }
258
+ },
259
+ submitButtonProps: _objectSpread({
260
+ loading: loading
261
+ }, submitterProps.submitButtonProps)
262
+ }), "submitter");
263
+ }, [submitter, submitterProps, loading, transformKey, omitNil, _onReset, syncToUrl, extraUrlParams, onUrlSearchChange]);
264
+ var content = useMemo(function () {
265
+ var wrapItems = grid ? /*#__PURE__*/_jsx(RowWrapper, {
266
+ children: items
267
+ }) : items;
322
268
  if (contentRender) {
323
269
  return contentRender(wrapItems, submitterNode, formRef.current);
324
270
  }
325
271
  return wrapItems;
326
272
  }, [grid, RowWrapper, items, contentRender, submitterNode]);
327
- const preInitialValues = usePrevious(props.initialValues);
328
- useEffect(() => {
329
- if (syncToUrl || !props.initialValues || !preInitialValues || rest.request)
330
- return;
331
- const isEqual = isDeepEqualReact(props.initialValues, preInitialValues);
332
- noteOnce(
333
- isEqual,
334
- `initialValues 只在 form 初始化时生效,如果你需要异步加载推荐使用 request,或者 initialValues ? <Form/> : null `
335
- );
336
- noteOnce(
337
- isEqual,
338
- `The initialValues only take effect when the form is initialized, if you need to load asynchronously recommended request, or the initialValues ? <Form/> : null `
339
- );
273
+ var preInitialValues = usePrevious(props.initialValues);
274
+
275
+ // 提示一个 initialValues ,问的人实在是太多了
276
+ useEffect(function () {
277
+ if (syncToUrl || !props.initialValues || !preInitialValues || rest.request) return;
278
+ var isEqual = isDeepEqualReact(props.initialValues, preInitialValues);
279
+ noteOnce(isEqual, "initialValues \u53EA\u5728 form \u521D\u59CB\u5316\u65F6\u751F\u6548\uFF0C\u5982\u679C\u4F60\u9700\u8981\u5F02\u6B65\u52A0\u8F7D\u63A8\u8350\u4F7F\u7528 request\uFF0C\u6216\u8005 initialValues ? <Form/> : null ");
280
+ noteOnce(isEqual, "The initialValues only take effect when the form is initialized, if you need to load asynchronously recommended request, or the initialValues ? <Form/> : null ");
281
+ // eslint-disable-next-line react-hooks/exhaustive-deps
340
282
  }, [props.initialValues]);
341
- useImperativeHandle(propsFormRef, () => {
342
- return __spreadProps(__spreadValues({}, formRef.current), {
343
- getFieldsFormatValue: (allData, omitNilParam) => {
344
- const formInstance2 = formRef.current;
345
- if (!formInstance2) {
283
+
284
+ // 初始化给一个默认的 form
285
+ useImperativeHandle(propsFormRef, function () {
286
+ return _objectSpread(_objectSpread({}, formRef.current), {}, {
287
+ getFieldsFormatValue: function getFieldsFormatValue(allData, omitNilParam) {
288
+ var formInstance = formRef.current;
289
+ if (!formInstance) {
346
290
  return {};
347
291
  }
348
- const values = formInstance2.getFieldsValue(allData);
349
- return transformKey(
350
- values,
351
- omitNilParam !== void 0 ? omitNilParam : omitNil
352
- );
292
+ var values = formInstance.getFieldsValue(allData);
293
+ return transformKey(values, omitNilParam !== undefined ? omitNilParam : omitNil);
353
294
  },
354
- getFieldFormatValue: (paramsNameList = [], omitNilParam) => {
355
- const formInstance2 = formRef.current;
356
- if (!formInstance2) {
357
- return void 0;
295
+ getFieldFormatValue: function getFieldFormatValue() {
296
+ var paramsNameList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
297
+ var omitNilParam = arguments.length > 1 ? arguments[1] : undefined;
298
+ var formInstance = formRef.current;
299
+ if (!formInstance) {
300
+ return undefined;
358
301
  }
359
- const nameList = covertFormName(paramsNameList);
360
- if (!nameList)
361
- throw new Error("nameList is require");
362
- const value = formInstance2.getFieldValue(nameList);
363
- const obj = nameList ? set({}, nameList, value) : value;
364
- const newNameList = [...nameList];
302
+ var nameList = covertFormName(paramsNameList);
303
+ if (!nameList) throw new Error('nameList is require');
304
+ var value = formInstance.getFieldValue(nameList);
305
+ var obj = nameList ? set({}, nameList, value) : value;
306
+ //transformKey会将keys重新和nameList拼接,所以这里要将nameList的首个元素弹出
307
+ var newNameList = _toConsumableArray(nameList);
365
308
  newNameList.shift();
366
- const transformed = transformKey(
367
- obj,
368
- omitNilParam !== void 0 ? omitNilParam : omitNil,
369
- newNameList
370
- );
371
- const result = get(transformed, nameList);
372
- if (result && typeof result === "object" && !Array.isArray(result)) {
373
- const objValue = Object.values(result)[0];
309
+ var transformed = transformKey(obj, omitNilParam !== undefined ? omitNilParam : omitNil, newNameList);
310
+ var result = get(transformed, nameList);
311
+ // 如果结果是对象,返回对象的值
312
+ if (result && _typeof(result) === 'object' && !Array.isArray(result)) {
313
+ var objValue = Object.values(result)[0];
314
+ // 如果对象的值是数组,返回数组
374
315
  if (Array.isArray(objValue)) {
375
316
  return objValue;
376
317
  }
@@ -378,375 +319,395 @@ function BaseFormComponents(props) {
378
319
  }
379
320
  return result;
380
321
  },
381
- getFieldFormatValueObject: (paramsNameList, omitNilParam) => {
382
- const formInstance2 = formRef.current;
383
- if (!formInstance2) {
322
+ getFieldFormatValueObject: function getFieldFormatValueObject(paramsNameList, omitNilParam) {
323
+ var formInstance = formRef.current;
324
+ if (!formInstance) {
384
325
  return {};
385
326
  }
386
- const nameList = covertFormName(paramsNameList);
387
- const value = formInstance2.getFieldValue(nameList);
388
- const obj = nameList ? set({}, nameList, value) : value;
389
- return transformKey(
390
- obj,
391
- omitNilParam !== void 0 ? omitNilParam : omitNil,
392
- nameList
393
- );
327
+ var nameList = covertFormName(paramsNameList);
328
+ var value = formInstance.getFieldValue(nameList);
329
+ var obj = nameList ? set({}, nameList, value) : value;
330
+ return transformKey(obj, omitNilParam !== undefined ? omitNilParam : omitNil, nameList);
394
331
  },
395
- validateFieldsReturnFormatValue: (nameList, omitNilParam) => __async(this, null, function* () {
396
- const formInstance2 = formRef.current;
397
- if (!formInstance2) {
398
- return {};
332
+ validateFieldsReturnFormatValue: function () {
333
+ var _validateFieldsReturnFormatValue2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(nameList, omitNilParam) {
334
+ var formInstance, values, transformedKey;
335
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
336
+ while (1) switch (_context2.prev = _context2.next) {
337
+ case 0:
338
+ formInstance = formRef.current;
339
+ if (formInstance) {
340
+ _context2.next = 3;
341
+ break;
342
+ }
343
+ return _context2.abrupt("return", {});
344
+ case 3:
345
+ if (!(!Array.isArray(nameList) && nameList)) {
346
+ _context2.next = 5;
347
+ break;
348
+ }
349
+ throw new Error('nameList must be array');
350
+ case 5:
351
+ _context2.next = 7;
352
+ return formInstance.validateFields(nameList);
353
+ case 7:
354
+ values = _context2.sent;
355
+ transformedKey = transformKey(values, omitNilParam !== undefined ? omitNilParam : omitNil);
356
+ return _context2.abrupt("return", transformedKey ? transformedKey : {});
357
+ case 10:
358
+ case "end":
359
+ return _context2.stop();
360
+ }
361
+ }, _callee2);
362
+ }));
363
+ function validateFieldsReturnFormatValue(_x3, _x4) {
364
+ return _validateFieldsReturnFormatValue2.apply(this, arguments);
399
365
  }
400
- if (!Array.isArray(nameList) && nameList)
401
- throw new Error("nameList must be array");
402
- const values = yield formInstance2.validateFields(nameList);
403
- const transformedKey = transformKey(
404
- values,
405
- omitNilParam !== void 0 ? omitNilParam : omitNil
406
- );
407
- return transformedKey ? transformedKey : {};
408
- })
366
+ return validateFieldsReturnFormatValue;
367
+ }()
409
368
  });
410
369
  }, [omitNil, transformKey, formRef.current]);
411
- useEffect(() => {
412
- var _a2, _b2;
413
- const finalValues = transformKey(
414
- (_b2 = (_a2 = formRef.current) == null ? void 0 : _a2.getFieldsValue) == null ? void 0 : _b2.call(_a2, true),
415
- omitNil
416
- );
417
- onInit == null ? void 0 : onInit(finalValues, __spreadValues(__spreadValues({}, formRef.current), formatValues));
370
+ useEffect(function () {
371
+ var _formRef$current3, _formRef$current3$get;
372
+ var finalValues = transformKey((_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 || (_formRef$current3$get = _formRef$current3.getFieldsValue) === null || _formRef$current3$get === void 0 ? void 0 : _formRef$current3$get.call(_formRef$current3, true), omitNil);
373
+ onInit === null || onInit === void 0 || onInit(finalValues, _objectSpread(_objectSpread({}, formRef.current), formatValues));
418
374
  }, []);
419
- return /* @__PURE__ */ React.createElement(
420
- ProFormContext.Provider,
421
- {
422
- value: __spreadProps(__spreadValues({}, formatValues), {
423
- formRef
375
+ return /*#__PURE__*/_jsx(ProFormContext.Provider, {
376
+ value: _objectSpread(_objectSpread({}, formatValues), {}, {
377
+ formRef: formRef
378
+ }),
379
+ children: /*#__PURE__*/_jsx(ConfigProvider, {
380
+ componentSize: rest.size || componentSize,
381
+ children: /*#__PURE__*/_jsxs(GridContext.Provider, {
382
+ value: {
383
+ grid: grid,
384
+ colProps: colProps
385
+ },
386
+ children: [rest.component !== false && /*#__PURE__*/_jsx("input", {
387
+ type: "text",
388
+ style: {
389
+ display: 'none'
390
+ }
391
+ }), content]
424
392
  })
425
- },
426
- /* @__PURE__ */ React.createElement(ConfigProvider, { componentSize: rest.size || componentSize }, /* @__PURE__ */ React.createElement(GridContext.Provider, { value: { grid, colProps } }, rest.component !== false && /* @__PURE__ */ React.createElement(
427
- "input",
428
- {
429
- type: "text",
430
- style: {
431
- display: "none"
432
- }
433
- }
434
- ), content))
435
- );
393
+ })
394
+ });
436
395
  }
396
+
397
+ /** 自动的formKey 防止重复 */
437
398
  var requestFormCacheId = 0;
438
- function BaseForm(props) {
439
- const _a = props, {
440
- extraUrlParams = {},
441
- syncToUrl,
442
- isKeyPressSubmit,
443
- syncToUrlAsImportant = false,
444
- syncToInitialValues = true,
445
- children,
446
- contentRender,
447
- submitter,
448
- fieldProps,
449
- proFieldProps,
450
- formItemProps,
451
- groupProps,
452
- dateFormatter = "string",
453
- formRef: propsFormRef,
454
- onInit,
455
- form,
456
- formComponentType,
457
- onReset,
458
- grid,
459
- rowProps,
460
- colProps,
461
- omitNil = true,
462
- request,
463
- params,
464
- initialValues,
465
- formKey = requestFormCacheId,
466
- readonly,
467
- onLoadingChange,
468
- loading: propsLoading
469
- } = _a, propRest = __objRest(_a, [
470
- "extraUrlParams",
471
- "syncToUrl",
472
- "isKeyPressSubmit",
473
- "syncToUrlAsImportant",
474
- "syncToInitialValues",
475
- "children",
476
- "contentRender",
477
- "submitter",
478
- "fieldProps",
479
- "proFieldProps",
480
- "formItemProps",
481
- "groupProps",
482
- "dateFormatter",
483
- "formRef",
484
- "onInit",
485
- "form",
486
- "formComponentType",
487
- "onReset",
488
- "grid",
489
- "rowProps",
490
- "colProps",
491
- "omitNil",
492
- "request",
493
- "params",
494
- "initialValues",
495
- "formKey",
496
- "readonly",
497
- "onLoadingChange",
498
- "loading"
499
- ]);
500
- const formRef = useRef({});
501
- const [loading, setLoading] = useMountMergeState(false, {
502
- onChange: onLoadingChange,
503
- value: propsLoading
504
- });
505
- const [urlSearch, setUrlSearch] = useUrlSearchParams(
506
- {},
507
- { disabled: !syncToUrl }
508
- );
509
- const curFormKey = useRef(nanoid());
510
- useEffect(() => {
399
+ export function BaseForm(props) {
400
+ var _props$extraUrlParams2 = props.extraUrlParams,
401
+ extraUrlParams = _props$extraUrlParams2 === void 0 ? {} : _props$extraUrlParams2,
402
+ syncToUrl = props.syncToUrl,
403
+ isKeyPressSubmit = props.isKeyPressSubmit,
404
+ _props$syncToUrlAsImp = props.syncToUrlAsImportant,
405
+ syncToUrlAsImportant = _props$syncToUrlAsImp === void 0 ? false : _props$syncToUrlAsImp,
406
+ _props$syncToInitialV = props.syncToInitialValues,
407
+ syncToInitialValues = _props$syncToInitialV === void 0 ? true : _props$syncToInitialV,
408
+ children = props.children,
409
+ contentRender = props.contentRender,
410
+ submitter = props.submitter,
411
+ fieldProps = props.fieldProps,
412
+ proFieldProps = props.proFieldProps,
413
+ formItemProps = props.formItemProps,
414
+ groupProps = props.groupProps,
415
+ _props$dateFormatter = props.dateFormatter,
416
+ dateFormatter = _props$dateFormatter === void 0 ? 'string' : _props$dateFormatter,
417
+ propsFormRef = props.formRef,
418
+ onInit = props.onInit,
419
+ form = props.form,
420
+ formComponentType = props.formComponentType,
421
+ onReset = props.onReset,
422
+ grid = props.grid,
423
+ rowProps = props.rowProps,
424
+ colProps = props.colProps,
425
+ _props$omitNil2 = props.omitNil,
426
+ omitNil = _props$omitNil2 === void 0 ? true : _props$omitNil2,
427
+ request = props.request,
428
+ params = props.params,
429
+ initialValues = props.initialValues,
430
+ _props$formKey = props.formKey,
431
+ formKey = _props$formKey === void 0 ? requestFormCacheId : _props$formKey,
432
+ readonly = props.readonly,
433
+ onLoadingChange = props.onLoadingChange,
434
+ propsLoading = props.loading,
435
+ propRest = _objectWithoutProperties(props, _excluded2);
436
+ var formRef = useRef({});
437
+ var _useMountMergeState = useMountMergeState(false, {
438
+ onChange: onLoadingChange,
439
+ value: propsLoading
440
+ }),
441
+ _useMountMergeState2 = _slicedToArray(_useMountMergeState, 2),
442
+ loading = _useMountMergeState2[0],
443
+ setLoading = _useMountMergeState2[1];
444
+ var _useUrlSearchParams = useUrlSearchParams({}, {
445
+ disabled: !syncToUrl
446
+ }),
447
+ _useUrlSearchParams2 = _slicedToArray(_useUrlSearchParams, 2),
448
+ urlSearch = _useUrlSearchParams2[0],
449
+ setUrlSearch = _useUrlSearchParams2[1];
450
+ var curFormKey = useRef(nanoid());
451
+ useEffect(function () {
511
452
  requestFormCacheId += 0;
512
453
  }, []);
513
- const [initialData, initialDataLoading] = useFetchData({
514
- request,
515
- params,
516
- proFieldKey: formKey
517
- });
518
- const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
519
- const prefixCls = getPrefixCls("pro-form");
520
- const { wrapSSR, hashId } = useStyle("ProForm", (token) => {
521
- return {
522
- [`.${prefixCls}`]: {
523
- [`> div:not(${token.proComponentsCls}-form-light-filter)`]: {
524
- ".pro-field": {
525
- maxWidth: "100%",
526
- "@media screen and (max-width: 575px)": {
527
- // 减少了 form 的 padding
528
- maxWidth: "calc(93vw - 48px)"
529
- },
530
- // 适用于短数字,短文本或者选项
531
- "&-xs": {
532
- width: 104
533
- },
534
- "&-s": {
535
- width: 216
536
- },
537
- // 适用于较短字段录入、如姓名、电话、ID 等。
538
- "&-sm": {
539
- width: 216
540
- },
541
- "&-m": {
542
- width: 328
543
- },
544
- // 标准宽度,适用于大部分字段长度
545
- "&-md": {
546
- width: 328
547
- },
548
- "&-l": {
549
- width: 440
550
- },
551
- // 适用于较长字段录入,如长网址、标签组、文件路径等。
552
- "&-lg": {
553
- width: 440
554
- },
555
- // 适用于长文本录入,如长链接、描述、备注等,通常搭配自适应多行输入框或定高文本域使用。
556
- "&-xl": {
557
- width: 552
558
- }
454
+ var _useFetchData = useFetchData({
455
+ request: request,
456
+ params: params,
457
+ proFieldKey: formKey
458
+ }),
459
+ _useFetchData2 = _slicedToArray(_useFetchData, 2),
460
+ initialData = _useFetchData2[0],
461
+ initialDataLoading = _useFetchData2[1];
462
+ var _useContext = useContext(ConfigProvider.ConfigContext),
463
+ getPrefixCls = _useContext.getPrefixCls;
464
+ var prefixCls = getPrefixCls('pro-form');
465
+ // css
466
+ var _useStyle = useStyle('ProForm', function (token) {
467
+ return _defineProperty({}, ".".concat(prefixCls), _defineProperty({}, "> div:not(".concat(token.proComponentsCls, "-form-light-filter)"), {
468
+ '.pro-field': {
469
+ maxWidth: '100%',
470
+ '@media screen and (max-width: 575px)': {
471
+ // 减少了 form 的 padding
472
+ maxWidth: 'calc(93vw - 48px)'
473
+ },
474
+ // 适用于短数字,短文本或者选项
475
+ '&-xs': {
476
+ width: 104
477
+ },
478
+ '&-s': {
479
+ width: 216
480
+ },
481
+ // 适用于较短字段录入、如姓名、电话、ID 等。
482
+ '&-sm': {
483
+ width: 216
484
+ },
485
+ '&-m': {
486
+ width: 328
487
+ },
488
+ // 标准宽度,适用于大部分字段长度
489
+ '&-md': {
490
+ width: 328
491
+ },
492
+ '&-l': {
493
+ width: 440
494
+ },
495
+ // 适用于较长字段录入,如长网址、标签组、文件路径等。
496
+ '&-lg': {
497
+ width: 440
498
+ },
499
+ // 适用于长文本录入,如长链接、描述、备注等,通常搭配自适应多行输入框或定高文本域使用。
500
+ '&-xl': {
501
+ width: 552
559
502
  }
560
503
  }
504
+ }));
505
+ }),
506
+ wrapSSR = _useStyle.wrapSSR,
507
+ hashId = _useStyle.hashId;
508
+
509
+ // 如果为 false,不需要触发设置进去
510
+ var _useState = useState(function () {
511
+ if (!syncToUrl) {
512
+ return {};
561
513
  }
562
- };
563
- });
564
- const [urlParamsMergeInitialValues, setUrlParamsMergeInitialValues] = useState(() => {
565
- if (!syncToUrl) {
566
- return {};
514
+ return genParams(syncToUrl, urlSearch, 'get');
515
+ }),
516
+ _useState2 = _slicedToArray(_useState, 2),
517
+ urlParamsMergeInitialValues = _useState2[0],
518
+ setUrlParamsMergeInitialValues = _useState2[1];
519
+
520
+ /** 保存 transformKeyRef,用于对表单key transform */
521
+ var transformKeyRef = useRef({});
522
+ var fieldsValueType = useRef({});
523
+
524
+ /** 使用 callback 的类型 */
525
+ var transformKey = useRefFunction(function (values, paramsOmitNil, parentKey) {
526
+ if (!values || _typeof(values) !== 'object') {
527
+ return values;
567
528
  }
568
- return genParams(syncToUrl, urlSearch, "get");
529
+ return transformKeySubmitValue(conversionMomentValue(values, dateFormatter, fieldsValueType.current, paramsOmitNil, parentKey), transformKeyRef.current);
569
530
  });
570
- const transformKeyRef = useRef({});
571
- const fieldsValueType = useRef({});
572
- const transformKey = useRefFunction(
573
- (values, paramsOmitNil, parentKey) => {
574
- if (!values || typeof values !== "object") {
575
- return values;
576
- }
577
- return transformKeySubmitValue(
578
- conversionMomentValue(
579
- values,
580
- dateFormatter,
581
- fieldsValueType.current,
582
- paramsOmitNil,
583
- parentKey
584
- ),
585
- transformKeyRef.current
586
- );
587
- }
588
- );
589
- useEffect(() => {
590
- if (syncToInitialValues)
591
- return;
531
+ useEffect(function () {
532
+ if (syncToInitialValues) return;
592
533
  setUrlParamsMergeInitialValues({});
593
534
  }, [syncToInitialValues]);
594
- const getGenParams = useRefFunction(() => {
595
- return __spreadValues(__spreadValues({}, urlSearch), extraUrlParams);
535
+ var getGenParams = useRefFunction(function () {
536
+ return _objectSpread(_objectSpread({}, urlSearch), extraUrlParams);
596
537
  });
597
- useEffect(() => {
598
- if (!syncToUrl)
599
- return;
600
- setUrlSearch(genParams(syncToUrl, getGenParams(), "set"));
538
+ useEffect(function () {
539
+ if (!syncToUrl) return;
540
+ setUrlSearch(genParams(syncToUrl, getGenParams(), 'set'));
541
+ // eslint-disable-next-line react-hooks/exhaustive-deps
601
542
  }, [extraUrlParams, getGenParams, syncToUrl]);
602
- const getPopupContainer = useMemo(() => {
603
- if (typeof window === "undefined")
604
- return void 0;
605
- if (formComponentType && ["DrawerForm"].includes(formComponentType)) {
606
- return (e) => e.parentNode || document.body;
543
+ var getPopupContainer = useMemo(function () {
544
+ if (typeof window === 'undefined') return undefined;
545
+ // 如果在 drawerForm 和 modalForm 里就渲染dom到父节点里
546
+ // modalForm 可能高度太小不适合
547
+ if (formComponentType && ['DrawerForm'].includes(formComponentType)) {
548
+ return function (e) {
549
+ return e.parentNode || document.body;
550
+ };
607
551
  }
608
- return void 0;
552
+ return undefined;
609
553
  }, [formComponentType]);
610
- const onFinish = useRefFunction(() => __async(this, null, function* () {
611
- var _a2, _b, _c, _d;
612
- if (!propRest.onFinish)
613
- return;
614
- if (loading)
615
- return;
616
- try {
617
- setLoading(true);
618
- const finalValues = ((_b = (_a2 = formRef == null ? void 0 : formRef.current) == null ? void 0 : _a2.getFieldsFormatValue) == null ? void 0 : _b.call(_a2)) || {};
619
- const response = propRest.onFinish(finalValues);
620
- if (response && typeof response === "object" && typeof response.then === "function") {
621
- try {
622
- yield response;
623
- } catch (error) {
554
+ var onFinish = useRefFunction( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
555
+ var _formRef$current4, _formRef$current4$get, finalValues, response, _formRef$current5, _formRef$current5$get, syncToUrlParams;
556
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
557
+ while (1) switch (_context3.prev = _context3.next) {
558
+ case 0:
559
+ if (propRest.onFinish) {
560
+ _context3.next = 2;
561
+ break;
562
+ }
563
+ return _context3.abrupt("return");
564
+ case 2:
565
+ if (!loading) {
566
+ _context3.next = 4;
567
+ break;
568
+ }
569
+ return _context3.abrupt("return");
570
+ case 4:
571
+ _context3.prev = 4;
572
+ setLoading(true);
573
+ finalValues = (formRef === null || formRef === void 0 || (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 || (_formRef$current4$get = _formRef$current4.getFieldsFormatValue) === null || _formRef$current4$get === void 0 ? void 0 : _formRef$current4$get.call(_formRef$current4)) || {};
574
+ response = propRest.onFinish(finalValues);
575
+ if (!(response && _typeof(response) === 'object' && typeof response.then === 'function')) {
576
+ _context3.next = 21;
577
+ break;
578
+ }
579
+ _context3.prev = 9;
580
+ _context3.next = 12;
581
+ return response;
582
+ case 12:
583
+ _context3.next = 18;
584
+ break;
585
+ case 14:
586
+ _context3.prev = 14;
587
+ _context3.t0 = _context3["catch"](9);
588
+ // 确保在 Promise 被拒绝时也重置 loading 状态
624
589
  setLoading(false);
625
- throw error;
626
- }
627
- setLoading(false);
628
- } else {
629
- setLoading(false);
630
- }
631
- if (syncToUrl) {
632
- const syncToUrlParams = Object.keys(
633
- ((_d = (_c = formRef == null ? void 0 : formRef.current) == null ? void 0 : _c.getFieldsFormatValue) == null ? void 0 : _d.call(_c, true, false)) || {}
634
- ).reduce((pre, next) => {
635
- var _a3;
636
- return __spreadProps(__spreadValues({}, pre), {
637
- [next]: (_a3 = finalValues[next]) != null ? _a3 : void 0
638
- });
639
- }, extraUrlParams);
640
- Object.keys(urlSearch).forEach((key) => {
641
- if (syncToUrlParams[key] !== false && syncToUrlParams[key] !== 0 && !syncToUrlParams[key]) {
642
- syncToUrlParams[key] = void 0;
590
+ throw _context3.t0;
591
+ case 18:
592
+ // 只有在 Promise 成功完成时才重置 loading 状态
593
+ setLoading(false);
594
+ _context3.next = 22;
595
+ break;
596
+ case 21:
597
+ setLoading(false);
598
+ case 22:
599
+ if (syncToUrl) {
600
+ // 把没有的值设置为未定义可以删掉 url 的参数
601
+ syncToUrlParams = Object.keys((formRef === null || formRef === void 0 || (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 || (_formRef$current5$get = _formRef$current5.getFieldsFormatValue) === null || _formRef$current5$get === void 0 ? void 0 : _formRef$current5$get.call(_formRef$current5, true, false)) || {}).reduce(function (pre, next) {
602
+ var _finalValues$next;
603
+ return _objectSpread(_objectSpread({}, pre), {}, _defineProperty({}, next, (_finalValues$next = finalValues[next]) !== null && _finalValues$next !== void 0 ? _finalValues$next : undefined));
604
+ }, extraUrlParams); // fix #3547: 当原先在url中存在的字段被删除时,应该将 params 中的该字段设置为 undefined,以便触发url同步删除
605
+ Object.keys(urlSearch).forEach(function (key) {
606
+ if (syncToUrlParams[key] !== false && syncToUrlParams[key] !== 0 && !syncToUrlParams[key]) {
607
+ syncToUrlParams[key] = undefined;
608
+ }
609
+ });
610
+ /** 在同步到 url 上时对参数进行转化 */
611
+ setUrlSearch(genParams(syncToUrl, syncToUrlParams, 'set'));
643
612
  }
644
- });
645
- setUrlSearch(genParams(syncToUrl, syncToUrlParams, "set"));
613
+ _context3.next = 28;
614
+ break;
615
+ case 25:
616
+ _context3.prev = 25;
617
+ _context3.t1 = _context3["catch"](4);
618
+ setLoading(false);
619
+ case 28:
620
+ case "end":
621
+ return _context3.stop();
646
622
  }
647
- } catch (error) {
648
- setLoading(false);
649
- }
650
- }));
651
- useImperativeHandle(propsFormRef, () => {
623
+ }, _callee3, null, [[4, 25], [9, 14]]);
624
+ })));
625
+
626
+ // 初始化给一个默认的 form
627
+ useImperativeHandle(propsFormRef, function () {
652
628
  return formRef.current;
653
629
  }, [!initialData]);
654
630
  if (request && initialDataLoading) {
655
- return /* @__PURE__ */ React.createElement("div", { style: { paddingTop: 50, paddingBottom: 50, textAlign: "center" } }, /* @__PURE__ */ React.createElement(Spin, null));
631
+ return /*#__PURE__*/_jsx("div", {
632
+ style: {
633
+ paddingTop: 50,
634
+ paddingBottom: 50,
635
+ textAlign: 'center'
636
+ },
637
+ children: /*#__PURE__*/_jsx(Spin, {})
638
+ });
656
639
  }
657
- return wrapSSR(
658
- /* @__PURE__ */ React.createElement(
659
- EditOrReadOnlyContext.Provider,
660
- {
640
+ return wrapSSR( /*#__PURE__*/_jsx(EditOrReadOnlyContext.Provider, {
641
+ value: {
642
+ mode: props.readonly ? 'read' : 'edit'
643
+ },
644
+ children: /*#__PURE__*/_jsx(ProConfigProvider, {
645
+ needDeps: true,
646
+ children: /*#__PURE__*/_jsx(FieldContext.Provider, {
661
647
  value: {
662
- mode: props.readonly ? "read" : "edit"
663
- }
664
- },
665
- /* @__PURE__ */ React.createElement(ProConfigProvider, { needDeps: true }, /* @__PURE__ */ React.createElement(
666
- FieldContext.Provider,
667
- {
668
- value: {
669
- formRef,
670
- fieldProps,
671
- proFieldProps,
672
- formItemProps,
673
- groupProps,
674
- formComponentType,
675
- getPopupContainer,
676
- formKey: curFormKey.current,
677
- setFieldValueType: (name, { valueType = "text", dateFormat, transform }) => {
678
- if (!Array.isArray(name))
679
- return;
680
- if (transform) {
681
- transformKeyRef.current = namePathSet(
682
- transformKeyRef.current,
683
- name,
684
- transform
685
- );
686
- }
687
- fieldsValueType.current = namePathSet(
688
- fieldsValueType.current,
689
- name,
690
- {
691
- valueType,
692
- dateFormat
693
- }
694
- );
648
+ formRef: formRef,
649
+ fieldProps: fieldProps,
650
+ proFieldProps: proFieldProps,
651
+ formItemProps: formItemProps,
652
+ groupProps: groupProps,
653
+ formComponentType: formComponentType,
654
+ getPopupContainer: getPopupContainer,
655
+ formKey: curFormKey.current,
656
+ setFieldValueType: function setFieldValueType(name, _ref4) {
657
+ var _ref4$valueType = _ref4.valueType,
658
+ valueType = _ref4$valueType === void 0 ? 'text' : _ref4$valueType,
659
+ dateFormat = _ref4.dateFormat,
660
+ transform = _ref4.transform;
661
+ if (!Array.isArray(name)) return;
662
+
663
+ // Store transform function in the correct nested structure
664
+ if (transform) {
665
+ transformKeyRef.current = namePathSet(transformKeyRef.current, name, transform);
695
666
  }
667
+ fieldsValueType.current = namePathSet(fieldsValueType.current, name, {
668
+ valueType: valueType,
669
+ dateFormat: dateFormat
670
+ });
696
671
  }
697
672
  },
698
- /* @__PURE__ */ React.createElement(FormListContext.Provider, { value: {} }, /* @__PURE__ */ React.createElement(
699
- Form,
700
- __spreadProps(__spreadValues({
701
- onKeyPress: (event) => {
702
- var _a2;
703
- if (!isKeyPressSubmit)
704
- return;
705
- if (event.key === "Enter") {
706
- (_a2 = formRef.current) == null ? void 0 : _a2.submit();
673
+ children: /*#__PURE__*/_jsx(FormListContext.Provider, {
674
+ value: {},
675
+ children: /*#__PURE__*/_jsx(Form, _objectSpread(_objectSpread({
676
+ onKeyPress: function onKeyPress(event) {
677
+ if (!isKeyPressSubmit) return;
678
+ if (event.key === 'Enter') {
679
+ var _formRef$current6;
680
+ (_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 || _formRef$current6.submit();
707
681
  }
708
682
  },
709
683
  autoComplete: "off",
710
- form
711
- }, omit(propRest, [
712
- "ref",
713
- "labelWidth",
714
- "autoFocusFirstInput"
715
- ])), {
716
- ref: (instance) => {
717
- if (!formRef.current)
718
- return;
719
- formRef.current.nativeElement = instance == null ? void 0 : instance.nativeElement;
720
- },
721
- initialValues: syncToUrlAsImportant ? __spreadValues(__spreadValues(__spreadValues({}, initialValues), initialData), urlParamsMergeInitialValues) : __spreadValues(__spreadValues(__spreadValues({}, urlParamsMergeInitialValues), initialValues), initialData),
722
- onValuesChange: (changedValues, values) => {
723
- var _a2;
724
- (_a2 = propRest == null ? void 0 : propRest.onValuesChange) == null ? void 0 : _a2.call(
725
- propRest,
726
- transformKey(changedValues, !!omitNil),
727
- transformKey(values, !!omitNil)
728
- );
684
+ form: form
685
+ }, omit(propRest, ['ref', 'labelWidth', 'autoFocusFirstInput'])), {}, {
686
+ ref: function ref(instance) {
687
+ if (!formRef.current) return;
688
+ formRef.current.nativeElement = instance === null || instance === void 0 ? void 0 : instance.nativeElement;
689
+ }
690
+ // 组合 urlSearch 和 initialValues
691
+ ,
692
+ initialValues: syncToUrlAsImportant ? _objectSpread(_objectSpread(_objectSpread({}, initialValues), initialData), urlParamsMergeInitialValues) : _objectSpread(_objectSpread(_objectSpread({}, urlParamsMergeInitialValues), initialValues), initialData),
693
+ onValuesChange: function onValuesChange(changedValues, values) {
694
+ var _propRest$onValuesCha;
695
+ propRest === null || propRest === void 0 || (_propRest$onValuesCha = propRest.onValuesChange) === null || _propRest$onValuesCha === void 0 || _propRest$onValuesCha.call(propRest, transformKey(changedValues, !!omitNil), transformKey(values, !!omitNil));
729
696
  },
730
697
  className: classNames(props.className, prefixCls, hashId),
731
- onFinish
732
- }),
733
- /* @__PURE__ */ React.createElement(
734
- BaseFormComponents,
735
- __spreadProps(__spreadValues({
736
- transformKey,
698
+ onFinish: onFinish,
699
+ children: /*#__PURE__*/_jsx(BaseFormComponents, _objectSpread(_objectSpread({
700
+ transformKey: transformKey,
737
701
  autoComplete: "off",
738
702
  loading: loading || !!(request && !initialData && initialDataLoading),
739
703
  onUrlSearchChange: setUrlSearch
740
- }, props), {
741
- formRef,
742
- initialValues: __spreadValues(__spreadValues({}, initialValues), initialData)
743
- })
744
- )
745
- ))
746
- ))
747
- )
748
- );
749
- }
750
- export {
751
- BaseForm
752
- };
704
+ }, props), {}, {
705
+ formRef: formRef,
706
+ initialValues: _objectSpread(_objectSpread({}, initialValues), initialData)
707
+ }))
708
+ }))
709
+ })
710
+ })
711
+ })
712
+ }));
713
+ }