@zat-design/sisyphus-react 4.5.10-beta.1 → 4.5.10-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 (266) hide show
  1. package/es/FormsProvider/index.js +14 -21
  2. package/es/ProAction/components/CheckModalContent/index.js +12 -26
  3. package/es/ProAction/index.js +79 -83
  4. package/es/ProAction/propsType.js +0 -1
  5. package/es/ProConfigProvider/index.js +63 -110
  6. package/es/ProConfigProvider/propsType.js +0 -1
  7. package/es/ProDownload/index.js +55 -65
  8. package/es/ProDownload/propsType.js +0 -1
  9. package/es/ProDownload/utils.js +61 -95
  10. package/es/ProDrawerForm/components/ProDrawer/index.js +83 -113
  11. package/es/ProDrawerForm/components/ProModal/index.js +77 -108
  12. package/es/ProDrawerForm/components/index.js +6 -2
  13. package/es/ProDrawerForm/hooks/useConfirmClose.js +20 -39
  14. package/es/ProDrawerForm/index.js +29 -38
  15. package/es/ProDrawerForm/propsType.js +0 -1
  16. package/es/ProDrawerForm/utils/index.js +18 -36
  17. package/es/ProEditLabel/components/RenderProForm.js +45 -49
  18. package/es/ProEditLabel/index.js +126 -163
  19. package/es/ProEditLabel/propsType.js +0 -1
  20. package/es/ProEditLabel/utils/index.js +5 -8
  21. package/es/ProEditTable/components/ActionButton/index.js +111 -119
  22. package/es/ProEditTable/components/RcTable/BaseTable.js +38 -51
  23. package/es/ProEditTable/components/RcTable/DraggableTable.js +97 -129
  24. package/es/ProEditTable/components/RcTable/index.js +6 -4
  25. package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +77 -95
  26. package/es/ProEditTable/components/RenderField/index.js +490 -587
  27. package/es/ProEditTable/components/RenderField/propsType.js +0 -1
  28. package/es/ProEditTable/components/RenderField/tools.js +115 -112
  29. package/es/ProEditTable/components/RenderToolbar/index.js +47 -73
  30. package/es/ProEditTable/components/Summary/index.js +38 -64
  31. package/es/ProEditTable/components/Validator/index.js +46 -46
  32. package/es/ProEditTable/components/index.js +12 -5
  33. package/es/ProEditTable/index.js +456 -378
  34. package/es/ProEditTable/propsType.js +0 -1
  35. package/es/ProEditTable/utils/config.js +60 -122
  36. package/es/ProEditTable/utils/diffOriginal.js +45 -82
  37. package/es/ProEditTable/utils/getDefaultProps.js +19 -24
  38. package/es/ProEditTable/utils/index.js +150 -236
  39. package/es/ProEditTable/utils/tools.js +149 -286
  40. package/es/ProEditTable/utils/transform.js +25 -30
  41. package/es/ProEditTable/utils/useEditTableError.js +30 -43
  42. package/es/ProEditTable/utils/useShouldUpdateForTable.js +42 -72
  43. package/es/ProEditTable/utils/validateAll.js +87 -154
  44. package/es/ProEnum/components/Group.js +38 -30
  45. package/es/ProEnum/components/Tag.js +22 -26
  46. package/es/ProEnum/hooks/useEnum.js +48 -116
  47. package/es/ProEnum/hooks/useEnumRequest.js +128 -179
  48. package/es/ProEnum/hooks/useFrequentEnumRequest.js +40 -48
  49. package/es/ProEnum/index.js +162 -172
  50. package/es/ProEnum/propsType.js +0 -1
  51. package/es/ProEnum/utils/eventCenter.js +10 -12
  52. package/es/ProEnum/utils/frequentEnum.js +35 -92
  53. package/es/ProEnum/utils/getEnum.js +32 -90
  54. package/es/ProEnum/utils/getEnumLabel.js +44 -49
  55. package/es/ProEnum/utils/index.js +93 -207
  56. package/es/ProForm/components/Container.js +13 -28
  57. package/es/ProForm/components/FormFooter/index.js +36 -44
  58. package/es/ProForm/components/FormFooter/propsType.js +0 -1
  59. package/es/ProForm/components/base/Checkbox/index.js +32 -59
  60. package/es/ProForm/components/base/DatePicker/index.js +49 -71
  61. package/es/ProForm/components/base/Input/index.js +63 -97
  62. package/es/ProForm/components/base/Input/propsType.js +0 -1
  63. package/es/ProForm/components/base/InputNumber/index.js +118 -172
  64. package/es/ProForm/components/base/Radio/index.js +39 -52
  65. package/es/ProForm/components/base/RangePicker/index.js +109 -127
  66. package/es/ProForm/components/base/RangePicker/useDateRange.js +20 -17
  67. package/es/ProForm/components/base/Select/index.js +63 -89
  68. package/es/ProForm/components/base/Switch/index.js +27 -35
  69. package/es/ProForm/components/base/SwitchCheckbox/index.js +36 -54
  70. package/es/ProForm/components/base/TextArea/index.js +30 -41
  71. package/es/ProForm/components/base/TimePicker/index.js +27 -37
  72. package/es/ProForm/components/combination/Container/index.js +37 -47
  73. package/es/ProForm/components/combination/Container/propsType.js +0 -1
  74. package/es/ProForm/components/combination/FormList/components/ActionButton.js +165 -237
  75. package/es/ProForm/components/combination/FormList/components/BlockFields.js +98 -103
  76. package/es/ProForm/components/combination/FormList/components/Empty.js +27 -54
  77. package/es/ProForm/components/combination/FormList/components/LineFields.js +57 -54
  78. package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +61 -109
  79. package/es/ProForm/components/combination/FormList/index.js +151 -161
  80. package/es/ProForm/components/combination/FormList/propsType.js +0 -1
  81. package/es/ProForm/components/combination/FormList/utils.js +22 -38
  82. package/es/ProForm/components/combination/Group/component/AddonWrapper/index.js +12 -28
  83. package/es/ProForm/components/combination/Group/component/ComRender.js +50 -111
  84. package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +105 -206
  85. package/es/ProForm/components/combination/Group/hooks/index.js +68 -128
  86. package/es/ProForm/components/combination/Group/index.js +87 -126
  87. package/es/ProForm/components/combination/Group/propsType.js +0 -1
  88. package/es/ProForm/components/combination/Group/utils/index.js +124 -239
  89. package/es/ProForm/components/combination/ProCascader/index.js +156 -199
  90. package/es/ProForm/components/combination/ProCascader/propsType.js +0 -1
  91. package/es/ProForm/components/combination/ProCascader/utils/index.js +12 -21
  92. package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +63 -75
  93. package/es/ProForm/components/combination/ProModalSelect/index.js +290 -348
  94. package/es/ProForm/components/combination/ProModalSelect/propsType.js +0 -1
  95. package/es/ProForm/components/combination/ProModalSelect/utils/index.js +32 -39
  96. package/es/ProForm/components/combination/ProNumberRange/index.js +100 -156
  97. package/es/ProForm/components/combination/ProNumberRange/propsType.js +0 -1
  98. package/es/ProForm/components/combination/ProRangeLimit/index.js +104 -115
  99. package/es/ProForm/components/combination/ProRangeLimit/propsType.js +0 -1
  100. package/es/ProForm/components/combination/ProTimeLimit/hooks/useControlled.js +16 -16
  101. package/es/ProForm/components/combination/ProTimeLimit/index.js +75 -109
  102. package/es/ProForm/components/index.js +56 -34
  103. package/es/ProForm/components/render/ChangedWrapper.js +85 -94
  104. package/es/ProForm/components/render/ConfirmWrapper.js +27 -39
  105. package/es/ProForm/components/render/CustomComponentViewWrapper.js +65 -82
  106. package/es/ProForm/components/render/Render.js +223 -329
  107. package/es/ProForm/components/render/RenderFields.js +76 -113
  108. package/es/ProForm/components/render/propsType.js +0 -1
  109. package/es/ProForm/hooks/useControlled.js +8 -10
  110. package/es/ProForm/hooks/useDeepCompareMemo.js +11 -11
  111. package/es/ProForm/hooks/useFieldProps.js +8 -4
  112. package/es/ProForm/hooks/useForm.js +50 -110
  113. package/es/ProForm/hooks/useRules.js +17 -33
  114. package/es/ProForm/hooks/useShouldUpdate.js +77 -152
  115. package/es/ProForm/hooks/useWatch.js +58 -129
  116. package/es/ProForm/index.js +157 -194
  117. package/es/ProForm/propsType.js +15 -7
  118. package/es/ProForm/utils/buildFormItemProps.js +51 -58
  119. package/es/ProForm/utils/diffOriginal.js +43 -73
  120. package/es/ProForm/utils/getDefaultProps.js +18 -24
  121. package/es/ProForm/utils/index.js +159 -234
  122. package/es/ProForm/utils/processDependencies.js +21 -60
  123. package/es/ProForm/utils/reactiveValues.js +20 -34
  124. package/es/ProForm/utils/rulesCreator.js +42 -40
  125. package/es/ProForm/utils/transformNames.js +10 -13
  126. package/es/ProForm/utils/transformValue.js +16 -29
  127. package/es/ProForm/utils/valueType.js +96 -178
  128. package/es/ProIcon/config/index.js +340 -274
  129. package/es/ProIcon/index.js +135 -209
  130. package/es/ProIcon/propsTypes.js +0 -1
  131. package/es/ProIcon/utils/index.js +24 -39
  132. package/es/ProLayout/components/Layout/Header/index.js +108 -141
  133. package/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +134 -190
  134. package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +111 -137
  135. package/es/ProLayout/components/Layout/Menu/OpenMenu/propsType.js +0 -1
  136. package/es/ProLayout/components/Layout/Menu/SideMenu/index.js +23 -31
  137. package/es/ProLayout/components/Layout/Menu/index.js +92 -89
  138. package/es/ProLayout/components/Layout/Notice/index.js +13 -27
  139. package/es/ProLayout/components/Layout/index.js +8 -3
  140. package/es/ProLayout/components/ProCollapse/PropTypes.js +0 -1
  141. package/es/ProLayout/components/ProCollapse/index.js +89 -111
  142. package/es/ProLayout/components/ProFooter/PropTypes.js +0 -1
  143. package/es/ProLayout/components/ProFooter/index.js +27 -25
  144. package/es/ProLayout/components/ProHeader/PropTypes.js +0 -1
  145. package/es/ProLayout/components/ProHeader/components/Copy/index.js +23 -21
  146. package/es/ProLayout/components/ProHeader/components/Describe/index.js +67 -86
  147. package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.js +18 -21
  148. package/es/ProLayout/components/ProHeader/components/ProBackBtn/propsType.js +0 -1
  149. package/es/ProLayout/components/ProHeader/components/index.js +6 -2
  150. package/es/ProLayout/components/ProHeader/index.js +216 -356
  151. package/es/ProLayout/components/ProHeader/utils/index.js +19 -26
  152. package/es/ProLayout/components/TabsManager/components/TabContextMenu.js +92 -85
  153. package/es/ProLayout/components/TabsManager/components/TabItem.js +53 -64
  154. package/es/ProLayout/components/TabsManager/components/TabsContext.js +5 -5
  155. package/es/ProLayout/components/TabsManager/components/TabsHeader.js +42 -52
  156. package/es/ProLayout/components/TabsManager/hooks/useActiveTab.js +8 -9
  157. package/es/ProLayout/components/TabsManager/hooks/useIframeRoute.js +19 -32
  158. package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +6 -20
  159. package/es/ProLayout/components/TabsManager/hooks/useTabsCache.js +25 -42
  160. package/es/ProLayout/components/TabsManager/hooks/useTabsState.js +290 -408
  161. package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.js +132 -95
  162. package/es/ProLayout/components/TabsManager/index.js +406 -390
  163. package/es/ProLayout/components/TabsManager/propTypes.js +7 -15
  164. package/es/ProLayout/components/TabsManager/utils/historyObserver.js +26 -23
  165. package/es/ProLayout/components/TabsManager/utils/index.js +127 -184
  166. package/es/ProLayout/components/index.js +8 -3
  167. package/es/ProLayout/index.js +171 -229
  168. package/es/ProLayout/propTypes.js +12 -52
  169. package/es/ProLayout/utils/index.js +48 -128
  170. package/es/ProSelect/components/AdaptiveTooltip.js +26 -25
  171. package/es/ProSelect/index.js +184 -229
  172. package/es/ProSelect/propsType.js +0 -1
  173. package/es/ProSelect/utils/index.js +100 -146
  174. package/es/ProStep/components/Anchor/index.js +71 -82
  175. package/es/ProStep/components/Item/index.js +49 -56
  176. package/es/ProStep/components/LazyLoad/index.js +23 -29
  177. package/es/ProStep/components/Listener/index.js +20 -33
  178. package/es/ProStep/components/Step/index.js +31 -38
  179. package/es/ProStep/constants.js +4 -1
  180. package/es/ProStep/index.js +166 -153
  181. package/es/ProStep/propsType.js +0 -1
  182. package/es/ProStep/utils/index.js +29 -55
  183. package/es/ProStepTab/index.js +83 -138
  184. package/es/ProStepTab/propsType.js +0 -1
  185. package/es/ProTable/components/EditableCell/EditIcon.js +10 -14
  186. package/es/ProTable/components/EditableCell/index.js +37 -71
  187. package/es/ProTable/components/EditableCell/propsType.js +0 -1
  188. package/es/ProTable/components/FormatColumn/index.js +209 -340
  189. package/es/ProTable/components/FormatColumn/propsType.js +0 -1
  190. package/es/ProTable/components/RcTable/components/BaseTable/index.js +35 -39
  191. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +80 -107
  192. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index.js +54 -48
  193. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/propsType.js +0 -1
  194. package/es/ProTable/components/RcTable/components/DraggableTable/index.js +47 -54
  195. package/es/ProTable/components/RcTable/index.js +6 -4
  196. package/es/ProTable/components/RenderColumn/index.js +158 -186
  197. package/es/ProTable/components/RenderEmptyText/index.js +12 -21
  198. package/es/ProTable/components/RenderFooter/index.js +15 -15
  199. package/es/ProTable/components/RenderSummary/index.js +33 -50
  200. package/es/ProTable/components/RenderTableHeader/index.js +44 -46
  201. package/es/ProTable/components/RenderTabs/index.js +47 -51
  202. package/es/ProTable/components/TableResizable/index.js +56 -72
  203. package/es/ProTable/components/TooltipTitle/index.js +13 -21
  204. package/es/ProTable/components/index.js +16 -36
  205. package/es/ProTable/hooks/useAntdTable.js +185 -219
  206. package/es/ProTable/index.js +232 -249
  207. package/es/ProTable/propsType.js +0 -1
  208. package/es/ProTable/utils/columnStorage.js +63 -88
  209. package/es/ProTable/utils/index.js +57 -90
  210. package/es/ProTabs/components/Card/index.js +20 -48
  211. package/es/ProTabs/components/index.js +4 -1
  212. package/es/ProTabs/index.js +39 -56
  213. package/es/ProTabs/propType.js +0 -1
  214. package/es/ProThemeTools/component/ProTools/index.js +106 -158
  215. package/es/ProThemeTools/component/index.js +4 -1
  216. package/es/ProThemeTools/context/ThemeContext.js +67 -146
  217. package/es/ProThemeTools/index.js +103 -156
  218. package/es/ProThemeTools/propsType.js +0 -1
  219. package/es/ProThemeTools/utils/index.js +60 -109
  220. package/es/ProTooltip/index.js +132 -165
  221. package/es/ProTooltip/propsType.js +0 -1
  222. package/es/ProTree/components/AdaptiveTooltip.js +15 -17
  223. package/es/ProTree/components/CloseIcon.js +18 -26
  224. package/es/ProTree/components/List.js +28 -47
  225. package/es/ProTree/components/ProTree.js +152 -211
  226. package/es/ProTree/components/ProTreeSelect/index.js +254 -458
  227. package/es/ProTree/components/ProTreeSelect/propsType.js +0 -1
  228. package/es/ProTree/components/SearchTitle.js +23 -42
  229. package/es/ProTree/components/Tree.js +147 -195
  230. package/es/ProTree/components/index.js +10 -5
  231. package/es/ProTree/index.js +12 -16
  232. package/es/ProTree/propsType.js +0 -1
  233. package/es/ProTree/utils.js +46 -118
  234. package/es/ProTreeModal/components/Cascader.js +56 -64
  235. package/es/ProTreeModal/components/CloseIcon.js +18 -26
  236. package/es/ProTreeModal/components/List.js +114 -180
  237. package/es/ProTreeModal/components/SearchTitle.js +15 -18
  238. package/es/ProTreeModal/components/SortableItem.js +29 -58
  239. package/es/ProTreeModal/components/Tree.js +99 -113
  240. package/es/ProTreeModal/components/Trigger.js +87 -121
  241. package/es/ProTreeModal/components/index.js +14 -6
  242. package/es/ProTreeModal/index.js +397 -435
  243. package/es/ProTreeModal/propsType.js +0 -1
  244. package/es/ProTreeModal/utils.js +52 -95
  245. package/es/ProUpload/components/ButtonRender.js +44 -54
  246. package/es/ProUpload/components/DragRender.js +94 -134
  247. package/es/ProUpload/components/DraggableUploadListItem.js +12 -25
  248. package/es/ProUpload/components/Example.js +27 -31
  249. package/es/ProUpload/components/FileItem.js +69 -163
  250. package/es/ProUpload/components/ImageRender.js +134 -170
  251. package/es/ProUpload/index.js +68 -100
  252. package/es/ProUpload/propsType.js +0 -1
  253. package/es/ProUpload/uitls.js +8 -4
  254. package/es/ProUtils/utils/index.js +17 -13
  255. package/es/ProViewer/index.js +154 -175
  256. package/es/ProViewer/propsType.js +0 -5
  257. package/es/ProWaterMark/index.js +9 -16
  258. package/es/ProWaterMark/propsType.js +0 -1
  259. package/es/hooks/useDraggableRow.js +25 -53
  260. package/es/index.js +57 -77
  261. package/es/locale/en_US.js +153 -142
  262. package/es/locale/index.js +23 -36
  263. package/es/locale/zh_CN.js +145 -142
  264. package/es/tokens.js +84 -83
  265. package/es/utils/index.js +24 -51
  266. package/package.json +4 -3
@@ -1,91 +1,65 @@
1
- import _pick from "lodash/pick";
2
- import scrollIntoView from 'scroll-into-view-if-needed';
3
- const toCssLength = value => typeof value === 'number' ? `${value}px` : value;
4
-
5
- /**
6
- * 滚动到错误位置, 延迟200ms解决ProForm错误还未生成
7
- */
8
- export const handleScrollError = (dom, root = document) => {
1
+ import pick from "lodash/pick";
2
+ import scrollIntoView from "scroll-into-view-if-needed";
3
+ const toCssLength = (value) => typeof value === "number" ? `${value}px` : value;
4
+ const handleScrollError = (dom, root = document) => {
9
5
  setTimeout(() => {
10
6
  const errorDom = dom || root.querySelector('[class*="form-item-has-error"]');
11
7
  if (errorDom) {
12
8
  scrollIntoView(errorDom, {
13
- behavior: 'smooth',
14
- block: 'center',
15
- scrollMode: 'if-needed'
9
+ behavior: "smooth",
10
+ block: "center",
11
+ scrollMode: "if-needed"
16
12
  });
17
13
  }
18
14
  }, 200);
19
15
  };
20
-
21
- /**
22
- * 处理滚动到指定元素位置, 如发现有错误, 则优先滚动到错误位置
23
- * @param id 目标元素的ID
24
- * @param options 滚动选项
25
- */
26
- export const handleScroll = (id, options) => {
27
- const {
28
- targetOffset,
29
- scrollToError,
30
- root = document,
31
- target
32
- } = options || {};
33
- const dom = target || Array.from(root.querySelectorAll('.pro-step-item')).find(item => item.id === id);
16
+ const handleScroll = (id, options) => {
17
+ const { targetOffset, scrollToError, root = document, target } = options || {};
18
+ const dom = target || Array.from(root.querySelectorAll(".pro-step-item")).find((item) => item.id === id);
34
19
  if (dom) {
35
- // 查找指定id下的错误表单项
36
20
  const errorDom = dom.querySelector('[class*="form-item-has-error"]');
37
21
  if (errorDom && scrollToError) {
38
- // 如果发现错误表单项,执行handleScrollError函数
39
22
  handleScrollError(errorDom);
40
23
  } else {
41
- // 目录点击必须重新对齐到 sticky 区域下方,不能因“当前可见”而跳过。
42
24
  const previousScrollMarginTop = dom.style.scrollMarginTop;
43
- if (targetOffset !== undefined && targetOffset !== null) {
25
+ if (targetOffset !== void 0 && targetOffset !== null) {
44
26
  dom.style.scrollMarginTop = toCssLength(targetOffset);
45
27
  }
46
28
  try {
47
29
  scrollIntoView(dom, {
48
30
  // compute-scroll-into-view 已计算 scroll-margin;custom behavior 避免外层库再次扣减。
49
- behavior: actions => {
50
- actions.forEach(({
51
- el,
52
- top,
53
- left
54
- }) => {
55
- el.scroll({
56
- top,
57
- left,
58
- behavior: 'smooth'
59
- });
31
+ behavior: (actions) => {
32
+ actions.forEach(({ el, top, left }) => {
33
+ el.scroll({ top, left, behavior: "smooth" });
60
34
  });
61
35
  },
62
- block: 'start',
63
- scrollMode: 'always'
36
+ block: "start",
37
+ scrollMode: "always"
64
38
  });
65
39
  } finally {
66
- if (targetOffset !== undefined && targetOffset !== null) {
40
+ if (targetOffset !== void 0 && targetOffset !== null) {
67
41
  dom.style.scrollMarginTop = previousScrollMarginTop;
68
42
  }
69
43
  }
70
44
  }
71
45
  }
72
46
  };
73
-
74
- /**
75
- * 获取加载模块数据信息
76
- * @param registerMap 注册映射对象
77
- * @returns 模块加载状态列表
78
- */
79
- export const getLoadedMap = registerMap => {
80
- if (!registerMap?.current) {
47
+ const getLoadedMap = (registerMap) => {
48
+ if (!(registerMap == null ? void 0 : registerMap.current)) {
81
49
  return [];
82
50
  }
83
- const stepList = Object.values(registerMap?.current).map(item => {
51
+ const stepList = Object.values(registerMap == null ? void 0 : registerMap.current).map((item) => {
84
52
  return {
85
- ..._pick(item, ['id', 'order', 'title']),
86
- loaded: !document.querySelector(`.${item?.id}-placeholder`)
53
+ ...pick(item, ["id", "order", "title"]),
54
+ loaded: !document.querySelector(`.${item == null ? void 0 : item.id}-placeholder`)
87
55
  };
88
56
  });
89
57
  return stepList;
90
58
  };
91
- export default handleScroll;
59
+ var utils_default = handleScroll;
60
+ export {
61
+ utils_default as default,
62
+ getLoadedMap,
63
+ handleScroll,
64
+ handleScrollError
65
+ };
@@ -1,19 +1,11 @@
1
- import _isNaN from "lodash/isNaN";
2
- import React, { useState, useCallback, useEffect, createContext, useContext } from 'react';
3
- // 存储当前的 StepTab 实例
4
- const StepTabInstanceContext = /*#__PURE__*/createContext(null);
5
-
6
- /**
7
- * 使用原生 JS 获取 URL 搜索参数
8
- * @returns 当前 URL 的搜索参数和路径
9
- */
1
+ import React, { useState, useCallback, useEffect, createContext, useContext } from "react";
2
+ import isNaN from "lodash/isNaN";
3
+ const StepTabInstanceContext = createContext(null);
10
4
  const useNativeLocation = () => {
11
5
  const [location, setLocation] = useState({
12
6
  search: window.location.search,
13
7
  pathname: window.location.pathname
14
8
  });
15
-
16
- // 监听 popstate 事件,更新 location 状态
17
9
  useEffect(() => {
18
10
  const handleLocationChange = () => {
19
11
  setLocation({
@@ -21,24 +13,17 @@ const useNativeLocation = () => {
21
13
  pathname: window.location.pathname
22
14
  });
23
15
  };
24
- window.addEventListener('popstate', handleLocationChange);
16
+ window.addEventListener("popstate", handleLocationChange);
25
17
  return () => {
26
- window.removeEventListener('popstate', handleLocationChange);
18
+ window.removeEventListener("popstate", handleLocationChange);
27
19
  };
28
20
  }, []);
29
21
  return location;
30
22
  };
31
-
32
- /**
33
- * 步骤化Tab管理钩子,用于管理多步骤表单或流程的切换和验证
34
- *
35
- * @param {ProStepTabType} props 配置参数
36
- * @returns {ProStepTabResultType} 返回步骤Tab相关方法和状态
37
- */
38
- export function useStepTab(props = {}) {
23
+ function useStepTab(props = {}) {
39
24
  const {
40
25
  routerKeep = false,
41
- routerSearchKey = 'tab',
26
+ routerSearchKey = "tab",
42
27
  validate = true,
43
28
  onBeforeChange,
44
29
  onAfterChange,
@@ -47,12 +32,8 @@ export function useStepTab(props = {}) {
47
32
  queueSteps,
48
33
  autoNext = false
49
34
  } = props;
50
-
51
- // 内部状态,避免全局污染
52
35
  const [handlesState, setHandlesState] = useState({});
53
36
  const location = useNativeLocation();
54
-
55
- // 获取初始激活的tab key
56
37
  const getInitialActiveKey = useCallback(() => {
57
38
  if (routerKeep) {
58
39
  const urlSearchParams = new URLSearchParams(location.search);
@@ -61,40 +42,30 @@ export function useStepTab(props = {}) {
61
42
  return tabValue;
62
43
  }
63
44
  }
64
- return defaultActiveKey || '1';
45
+ return defaultActiveKey || "1";
65
46
  }, [routerKeep, routerSearchKey, location.search, defaultActiveKey]);
66
-
67
- // 获取初始激活的步骤
68
47
  const getInitialStep = useCallback(() => {
69
48
  if (routerKeep) {
70
49
  const urlSearchParams = new URLSearchParams(location.search);
71
50
  const stepValue = urlSearchParams.get(routerSearchKey);
72
- // 如果stepValue是数字,则返回数字
73
- if (stepValue && !_isNaN(Number(stepValue))) {
51
+ if (stepValue && !isNaN(Number(stepValue))) {
74
52
  return Number(stepValue);
75
53
  }
76
54
  }
77
55
  return defaultStep;
78
56
  }, [routerKeep, routerSearchKey, location.search, defaultStep]);
79
57
  const [activeKey, setActiveKeyState] = useState(getInitialActiveKey());
80
- const [step, setStepState] = useState(getInitialStep()); // 当前已激活步骤
58
+ const [step, setStepState] = useState(getInitialStep());
81
59
  const [loading, setLoading] = useState(false);
82
-
83
- // 同步URL参数
84
60
  useEffect(() => {
85
61
  if (routerKeep && activeKey) {
86
- // 更新URL参数
87
62
  const urlSearchParams = new URLSearchParams(location.search);
88
63
  urlSearchParams.set(routerSearchKey, activeKey);
89
-
90
- // 使用原生 history API 更新 URL
91
64
  const newUrl = `${location.pathname}?${urlSearchParams.toString()}`;
92
- window.history.replaceState(null, '', newUrl);
65
+ window.history.replaceState(null, "", newUrl);
93
66
  }
94
67
  }, [activeKey, routerKeep, routerSearchKey, location]);
95
-
96
- // 创建一个包装函数,自动处理loading状态
97
- const wrapHandleWithLoading = useCallback(fn => {
68
+ const wrapHandleWithLoading = useCallback((fn) => {
98
69
  return async () => {
99
70
  setLoading(true);
100
71
  try {
@@ -107,82 +78,72 @@ export function useStepTab(props = {}) {
107
78
  }
108
79
  };
109
80
  }, []);
110
-
111
- // 注册步骤处理函数
112
- const registerHandle = useCallback((key, handler) => {
113
- // 使用wrapHandleWithLoading包装处理函数
114
- setHandlesState(prev => ({
115
- ...prev,
116
- [key]: wrapHandleWithLoading(handler)
117
- }));
118
- }, [wrapHandleWithLoading]);
119
-
120
- // 获取步骤处理函数
121
- const getHandle = useCallback(key => {
122
- return handlesState[key];
123
- }, [handlesState]);
124
-
125
- // 处理表单验证和切换(内部使用)
126
- const validateAndChange = useCallback(async targetKey => {
127
- if (targetKey === activeKey) return true;
128
- try {
129
- // 执行当前步骤的保存处理, 如果validate为true,则执行验证
130
- const currentHandler = handlesState[activeKey];
131
- if (currentHandler && validate) {
132
- const handleResult = await currentHandler();
133
- if (!handleResult) {
134
- return false;
81
+ const registerHandle = useCallback(
82
+ (key, handler) => {
83
+ setHandlesState((prev) => ({
84
+ ...prev,
85
+ [key]: wrapHandleWithLoading(handler)
86
+ }));
87
+ },
88
+ [wrapHandleWithLoading]
89
+ );
90
+ const getHandle = useCallback(
91
+ (key) => {
92
+ return handlesState[key];
93
+ },
94
+ [handlesState]
95
+ );
96
+ const validateAndChange = useCallback(
97
+ async (targetKey) => {
98
+ if (targetKey === activeKey)
99
+ return true;
100
+ try {
101
+ const currentHandler = handlesState[activeKey];
102
+ if (currentHandler && validate) {
103
+ const handleResult = await currentHandler();
104
+ if (!handleResult) {
105
+ return false;
106
+ }
135
107
  }
136
- }
137
-
138
- // 执行切换前回调
139
- if (onBeforeChange) {
140
- const beforeResult = await onBeforeChange(activeKey, targetKey);
141
- if (beforeResult === false) {
142
- return false;
108
+ if (onBeforeChange) {
109
+ const beforeResult = await onBeforeChange(activeKey, targetKey);
110
+ if (beforeResult === false) {
111
+ return false;
112
+ }
113
+ }
114
+ setActiveKeyState(targetKey);
115
+ if (onAfterChange) {
116
+ onAfterChange(targetKey);
143
117
  }
118
+ return true;
119
+ } catch (error) {
120
+ console.error("Tab切换验证失败:", error);
121
+ return false;
144
122
  }
145
-
146
- // 更新激活的key
147
- setActiveKeyState(targetKey);
148
-
149
- // 执行切换后回调
150
- if (onAfterChange) {
151
- onAfterChange(targetKey);
123
+ },
124
+ [activeKey, validate, onBeforeChange, onAfterChange, handlesState]
125
+ );
126
+ const setCheckActiveKey = useCallback(
127
+ async (targetKey, validate2) => {
128
+ if (validate2 === false) {
129
+ setActiveKeyState(targetKey);
130
+ return true;
152
131
  }
153
- return true;
154
- } catch (error) {
155
- // 验证失败
156
- console.error('Tab切换验证失败:', error);
157
- return false;
158
- }
159
- }, [activeKey, validate, onBeforeChange, onAfterChange, handlesState]);
160
-
161
- // 设置激活的key
162
- const setCheckActiveKey = useCallback(async (targetKey, validate) => {
163
- if (validate === false) {
164
- setActiveKeyState(targetKey);
165
- return true;
166
- }
167
- // 执行表单验证和切换
168
- return validateAndChange(targetKey);
169
- }, [validateAndChange]);
170
-
171
- // 执行当前步骤处理函数
132
+ return validateAndChange(targetKey);
133
+ },
134
+ [validateAndChange]
135
+ );
172
136
  const saveHandle = useCallback(async () => {
173
137
  const handler = handlesState[activeKey];
174
138
  if (handler) {
175
139
  const result = await handler();
176
- // 添加autoNext功能
177
140
  if (result && autoNext) {
178
- // 只有当activeKey能转换为数字时才执行自动跳转
179
141
  const currentKeyNum = Number(activeKey);
180
- if (!_isNaN(currentKeyNum)) {
142
+ if (!isNaN(currentKeyNum)) {
181
143
  let nextKey = String(currentKeyNum + 1);
182
144
  if (Number(nextKey) > queueSteps) {
183
145
  nextKey = String(queueSteps);
184
146
  }
185
- // 自动跳转到下一个tab
186
147
  await setCheckActiveKey(nextKey, false);
187
148
  }
188
149
  }
@@ -193,16 +154,15 @@ export function useStepTab(props = {}) {
193
154
  }
194
155
  return Promise.resolve(true);
195
156
  }, [activeKey, handlesState, autoNext, queueSteps, setCheckActiveKey]);
196
-
197
- // 拦截setStep, 最大值是queueSteps
198
- const setStep = useCallback(step => {
199
- if (step > queueSteps) {
200
- return;
201
- }
202
- setStepState(step);
203
- }, [queueSteps]);
204
-
205
- // 重置handles,用于清空或组件卸载时调用
157
+ const setStep = useCallback(
158
+ (step2) => {
159
+ if (step2 > queueSteps) {
160
+ return;
161
+ }
162
+ setStepState(step2);
163
+ },
164
+ [queueSteps]
165
+ );
206
166
  const resetHandles = useCallback(() => {
207
167
  setHandlesState({});
208
168
  }, []);
@@ -221,36 +181,21 @@ export function useStepTab(props = {}) {
221
181
  };
222
182
  return stepTabInstance;
223
183
  }
224
-
225
- /**
226
- * 在子组件中获取父级 StepTab 实例的钩子
227
- * @returns {ProStepTabResultType} 步骤Tab实例
228
- */
229
- export function useStepTabInstance() {
184
+ function useStepTabInstance() {
230
185
  const context = useContext(StepTabInstanceContext);
231
186
  if (context === null) {
232
- throw new Error('useStepTabInstance must be used inside a ProStepTab component');
187
+ throw new Error("useStepTabInstance must be used inside a ProStepTab component");
233
188
  }
234
189
  return context;
235
190
  }
236
-
237
- // 扩展FC类型,添加静态方法
238
-
239
- /**
240
- * ProStepTab 组件
241
- */
242
- const ProStepTab = ({
243
- children,
244
- ...rest
245
- }) => {
191
+ const ProStepTab = ({ children, ...rest }) => {
246
192
  const stepTabInstance = useStepTab(rest);
247
- return /*#__PURE__*/React.createElement(StepTabInstanceContext.Provider, {
248
- value: stepTabInstance
249
- }, children);
193
+ return React.createElement(StepTabInstanceContext.Provider, { value: stepTabInstance }, children);
250
194
  };
251
-
252
- // 将 useStepTabInstance 挂载到 ProStepTab 上作为静态方法
253
195
  ProStepTab.useStepTabInstance = useStepTabInstance;
254
-
255
- // 导出默认组件
256
- export default ProStepTab;
196
+ var ProStepTab_default = ProStepTab;
197
+ export {
198
+ ProStepTab_default as default,
199
+ useStepTab,
200
+ useStepTabInstance
201
+ };
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +1,11 @@
1
- import { EditOutlined } from '@ant-design/icons';
2
- import classNames from 'classnames';
3
- import React from 'react';
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const EditIcon = ({
6
- onClick
7
- }) => {
8
- const cls = classNames('pro-table-editable-cell-edit-icon');
9
- return /*#__PURE__*/_jsx("span", {
10
- className: cls,
11
- onClick: onClick,
12
- children: /*#__PURE__*/_jsx(EditOutlined, {})
13
- });
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { EditOutlined } from "@ant-design/icons";
3
+ import classNames from "classnames";
4
+ const EditIcon = ({ onClick }) => {
5
+ const cls = classNames("pro-table-editable-cell-edit-icon");
6
+ return /* @__PURE__ */ jsx("span", { className: cls, onClick, children: /* @__PURE__ */ jsx(EditOutlined, {}) });
7
+ };
8
+ var EditIcon_default = EditIcon;
9
+ export {
10
+ EditIcon_default as default
14
11
  };
15
- export default EditIcon;
@@ -1,10 +1,10 @@
1
- import _isEqual from "lodash/isEqual";
2
- import React, { useState, useRef } from 'react';
3
- import { Form } from 'antd';
4
- import classNames from 'classnames';
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState, useRef } from "react";
3
+ import { Form } from "antd";
4
+ import classNames from "classnames";
5
+ import isEqual from "lodash/isEqual";
5
6
  import * as componentMap from "../../../ProForm/components";
6
7
  import EditIcon from "./EditIcon";
7
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
8
  const InternalCell = ({
9
9
  value,
10
10
  record,
@@ -17,19 +17,10 @@ const InternalCell = ({
17
17
  }) => {
18
18
  const [editing, setEditing] = useState(false);
19
19
  const snapshotRef = useRef(value);
20
- const {
21
- type = 'Input',
22
- fieldProps = {},
23
- rules,
24
- required,
25
- valueType
26
- } = editConfig;
27
- const {
28
- onBlur: onBlurCallback,
29
- ...restFieldProps
30
- } = fieldProps;
20
+ const { type = "Input", fieldProps = {}, rules, required, valueType } = editConfig;
21
+ const { onBlur: onBlurCallback, ...restFieldProps } = fieldProps;
31
22
  const Component = componentMap[type] ?? componentMap.Input;
32
- const wrapperClassName = classNames('pro-table-editable-cell-wrapper');
23
+ const wrapperClassName = classNames("pro-table-editable-cell-wrapper");
33
24
  const handleEditIconClick = () => {
34
25
  snapshotRef.current = value;
35
26
  form.setFieldValue(fieldName, value);
@@ -39,7 +30,7 @@ const InternalCell = ({
39
30
  try {
40
31
  await form.validateFields([fieldName]);
41
32
  const newValue = form.getFieldValue(fieldName);
42
- if (_isEqual(newValue, snapshotRef.current)) {
33
+ if (isEqual(newValue, snapshotRef.current)) {
43
34
  setEditing(false);
44
35
  return;
45
36
  }
@@ -53,69 +44,44 @@ const InternalCell = ({
53
44
  }
54
45
  setEditing(false);
55
46
  } catch {
56
- // Validation failed - stay in edit mode
57
47
  }
58
48
  };
59
49
  if (!editing) {
60
- return /*#__PURE__*/_jsxs("span", {
61
- className: wrapperClassName,
62
- children: [/*#__PURE__*/_jsx("span", {
63
- children: displayContent ?? '-'
64
- }), /*#__PURE__*/_jsx(EditIcon, {
65
- onClick: handleEditIconClick
66
- })]
67
- });
50
+ return /* @__PURE__ */ jsxs("span", { className: wrapperClassName, children: [
51
+ /* @__PURE__ */ jsx("span", { children: displayContent ?? "-" }),
52
+ /* @__PURE__ */ jsx(EditIcon, { onClick: handleEditIconClick })
53
+ ] });
68
54
  }
69
- const formItem = /*#__PURE__*/_jsx(Form.Item, {
70
- name: fieldName,
71
- rules: rules,
72
- required: required,
73
- noStyle: true,
74
- children: /*#__PURE__*/_jsx(Component, {
75
- ...restFieldProps,
76
- valueType: valueType,
77
- autoFocus: true,
78
- onBlur: handleBlur
79
- })
80
- });
55
+ const formItem = /* @__PURE__ */ jsx(Form.Item, { name: fieldName, rules, required, noStyle: true, children: /* @__PURE__ */ jsx(Component, { ...restFieldProps, valueType, autoFocus: true, onBlur: handleBlur }) });
81
56
  if (!wrapInForm) {
82
57
  return formItem;
83
58
  }
84
- return /*#__PURE__*/_jsx(Form, {
85
- form: form,
86
- component: false,
87
- children: formItem
88
- });
59
+ return /* @__PURE__ */ jsx(Form, { form, component: false, children: formItem });
89
60
  };
90
- const PerCellEditableCell = props => {
61
+ const PerCellEditableCell = (props) => {
91
62
  const [form] = Form.useForm();
92
- const fieldName = Array.isArray(props.dataIndex) ? props.dataIndex.join('_') : props.dataIndex;
93
- return /*#__PURE__*/_jsx(InternalCell, {
94
- ...props,
95
- form: form,
96
- fieldName: fieldName,
97
- wrapInForm: true
98
- });
63
+ const fieldName = Array.isArray(props.dataIndex) ? props.dataIndex.join("_") : props.dataIndex;
64
+ return /* @__PURE__ */ jsx(InternalCell, { ...props, form, fieldName, wrapInForm: true });
99
65
  };
100
- const SharedFormEditableCell = props => {
101
- const fieldName = props.sharedFieldName ?? (Array.isArray(props.dataIndex) ? props.dataIndex.join('_') : props.dataIndex);
102
- return /*#__PURE__*/_jsx(InternalCell, {
103
- ...props,
104
- form: props.sharedForm,
105
- fieldName: fieldName,
106
- wrapInForm: false
107
- });
66
+ const SharedFormEditableCell = (props) => {
67
+ const fieldName = props.sharedFieldName ?? (Array.isArray(props.dataIndex) ? props.dataIndex.join("_") : props.dataIndex);
68
+ return /* @__PURE__ */ jsx(
69
+ InternalCell,
70
+ {
71
+ ...props,
72
+ form: props.sharedForm,
73
+ fieldName,
74
+ wrapInForm: false
75
+ }
76
+ );
108
77
  };
109
- const EditableCell = props => {
110
- // editMode 默认 'per-cell-form',与重构前完全一致
111
- // 'shared-form':外层 ProTable 提供共享 Form,跳过内部 useForm
112
- if (props.editMode === 'shared-form' && props.sharedForm) {
113
- return /*#__PURE__*/_jsx(SharedFormEditableCell, {
114
- ...props
115
- });
78
+ const EditableCell = (props) => {
79
+ if (props.editMode === "shared-form" && props.sharedForm) {
80
+ return /* @__PURE__ */ jsx(SharedFormEditableCell, { ...props });
116
81
  }
117
- return /*#__PURE__*/_jsx(PerCellEditableCell, {
118
- ...props
119
- });
82
+ return /* @__PURE__ */ jsx(PerCellEditableCell, { ...props });
83
+ };
84
+ var EditableCell_default = EditableCell;
85
+ export {
86
+ EditableCell_default as default
120
87
  };
121
- export default EditableCell;
@@ -1 +0,0 @@
1
- export {};