@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,5 +1,15 @@
1
- import { useCallback, useMemo, forwardRef, useImperativeHandle, useState, useEffect, useLayoutEffect, useRef } from 'react';
2
- import { createPortal } from 'react-dom';
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ useCallback,
4
+ useMemo,
5
+ forwardRef,
6
+ useImperativeHandle,
7
+ useState,
8
+ useEffect,
9
+ useLayoutEffect,
10
+ useRef
11
+ } from "react";
12
+ import { createPortal } from "react-dom";
3
13
  import { useTabsState } from "./hooks/useTabsState";
4
14
  import { useTabsUrlSync } from "./hooks/useTabsUrlSync";
5
15
  import { useIframeRoute } from "./hooks/useIframeRoute";
@@ -7,406 +17,412 @@ import { flattenMenuData, resolveTabMenuItem, derivePinned } from "./utils";
7
17
  import { TabItemComponent } from "./components/TabItem";
8
18
  import { TabsHeader } from "./components/TabsHeader";
9
19
  import { TabsContext } from "./components/TabsContext";
10
-
11
- /**
12
- * 标签页管理器主组件
13
- */
14
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
- const TabsManager = /*#__PURE__*/forwardRef(({
16
- config,
17
- children,
18
- dataSource,
19
- originalOnMenuClick,
20
- tabsBarContainer,
21
- onTabsChange,
22
- onIframePureChange
23
- }, ref) => {
24
- // iframe 模式检测(在 useTabsState 之前,因为 cacheEnabled 依赖 pure)
25
- // addTab 由后续 useTabsState 提供,此处先用占位,后面用 ref 透传
26
- const iframeAddTabRef = useRef(undefined);
27
- const {
28
- pure: isIframePure
29
- } = useIframeRoute({
30
- config: config?.iframe,
31
- addTab: params => iframeAddTabRef.current?.(params)
32
- });
33
-
34
- // 通知父级(ProLayout)pure 状态变化
35
- useLayoutEffect(() => {
36
- onIframePureChange?.(isIframePure);
37
- }, [isIframePure, onIframePureChange]);
38
-
39
- // TabsManager 退出 tabs 模式或上报目标变更时,释放旧父级持有的 pure 状态。
40
- useLayoutEffect(() => () => {
41
- onIframePureChange?.(false);
42
- }, [onIframePureChange]);
43
- const {
44
- state,
45
- isInitialized,
46
- addTab,
47
- canAddTab,
48
- removeTab,
49
- updateTab,
50
- updateTabUrl,
51
- switchTab,
52
- rollbackTabActivation,
53
- closeOtherTabs,
54
- closeRightTabs,
55
- closeAllTabs,
56
- reorderTabs,
57
- pinTab,
58
- unpinTab
59
- } = useTabsState({
20
+ const TabsManager = forwardRef(
21
+ ({
60
22
  config,
23
+ children,
61
24
  dataSource,
62
- cacheEnabled: !isIframePure
63
- });
64
- const tabInteractionSequenceRef = useRef(0);
65
- const markTabInteraction = useCallback(() => {
66
- tabInteractionSequenceRef.current += 1;
67
- }, []);
68
- useTabsUrlSync({
69
- config,
70
- dataSource,
71
- state,
72
- isInitialized,
73
- addTab,
74
- switchTab,
75
- updateTabUrl,
76
- rollbackTabActivation,
77
- interactionSequence: tabInteractionSequenceRef.current
78
- });
79
-
80
- // 桥接 useIframeRoute 的 { code, name, extra } → addTab(menuItem)
81
- iframeAddTabRef.current = params => {
82
- const sourceMenus = Array.isArray(dataSource?.menus) ? flattenMenuData(dataSource.menus) : [];
83
- const matchedMenu = sourceMenus.find(item => item.code === params.code);
84
- const menuItem = matchedMenu ? {
85
- ...matchedMenu,
86
- name: params.name || matchedMenu.name,
87
- extra: params.extra ?? matchedMenu.extra
88
- } : {
89
- id: Date.now(),
90
- code: params.code,
91
- name: params.name,
92
- url: `/${params.code}`,
93
- extra: params.extra
94
- };
95
- addTab(menuItem);
96
- };
97
-
98
- // 记录已访问过的 Tab ID,用于懒加载
99
- const [visitedTabIds, setVisitedTabIds] = useState(new Set());
100
-
101
- // 监听 activeKey 变化,更新 visitedTabIds
102
- useEffect(() => {
103
- if (state.activeKey) {
104
- setVisitedTabIds(prev => {
105
- if (prev.has(state.activeKey)) return prev;
106
- const newSet = new Set(prev);
107
- newSet.add(state.activeKey);
108
- return newSet;
109
- });
110
- }
111
- }, [state.activeKey]);
112
-
113
- // tab 内子视图栈:按 tabId 隔离。栈底→栈顶顺序,入口页不在其中。
114
- // 只活在内存、不进缓存(详情/工作流是运行态 ReactNode,无法 JSON 序列化)。
115
- const [viewStacks, setViewStacks] = useState({});
116
-
117
- // 用 ref 持有 activeKey,供稳定的 pushView/back 读取当前激活 tab,避免因 activeKey 变化重建实例
118
- const activeKeyRef = useRef(state.activeKey);
119
- activeKeyRef.current = state.activeKey;
120
-
121
- // 同步持有最新 viewStacks,使 getViewStack 成为稳定引用且读取不受渲染时序影响
122
- const viewStacksRef = useRef(viewStacks);
123
- viewStacksRef.current = viewStacks;
124
-
125
- // 在当前激活 tab 内压入一层子视图(入口页/下层随之隐藏但不卸载)
126
- const pushView = useCallback(node => {
127
- const tabId = activeKeyRef.current;
128
- if (!tabId) return;
129
- setViewStacks(prev => ({
130
- ...prev,
131
- [tabId]: [...(prev[tabId] || []), node]
132
- }));
133
- }, []);
134
-
135
- // 返回:销毁当前激活 tab 的栈顶子视图(栈空时 no-op)
136
- const back = useCallback(() => {
137
- const tabId = activeKeyRef.current;
138
- if (!tabId) return;
139
- setViewStacks(prev => {
140
- const stack = prev[tabId];
141
- if (!stack || stack.length === 0) return prev;
142
- const nextStack = stack.slice(0, -1);
143
- const next = {
144
- ...prev
145
- };
146
- if (nextStack.length === 0) {
147
- delete next[tabId];
148
- } else {
149
- next[tabId] = nextStack;
25
+ originalOnMenuClick,
26
+ tabsBarContainer,
27
+ onTabsChange,
28
+ onIframePureChange
29
+ }, ref) => {
30
+ const iframeAddTabRef = useRef(void 0);
31
+ const { pure: isIframePure } = useIframeRoute({
32
+ config: config == null ? void 0 : config.iframe,
33
+ addTab: (params) => {
34
+ var _a;
35
+ return (_a = iframeAddTabRef.current) == null ? void 0 : _a.call(iframeAddTabRef, params);
150
36
  }
151
- return next;
152
37
  });
153
- }, []);
154
-
155
- // 获取当前激活 tab 的子视图栈(从 ref 读最新值,稳定引用)
156
- const getViewStack = useCallback(() => viewStacksRef.current[activeKeyRef.current] || [], []);
157
-
158
- // 子视图栈与 tabsList 对账:任何关闭路径(removeTab / closeOthers / closeRight /
159
- // closeAll)导致某 tab 消失后,清除其残留子视图栈,避免关闭后 node 仍驻留内存。
160
- useEffect(() => {
161
- setViewStacks(prev => {
162
- const keys = Object.keys(prev);
163
- if (keys.length === 0) return prev;
164
- const aliveIds = new Set(state.tabsList.map(tab => tab.id));
165
- const staleKeys = keys.filter(id => !aliveIds.has(id));
166
- if (staleKeys.length === 0) return prev;
167
- const next = {
168
- ...prev
169
- };
170
- staleKeys.forEach(id => delete next[id]);
171
- return next;
38
+ useLayoutEffect(() => {
39
+ onIframePureChange == null ? void 0 : onIframePureChange(isIframePure);
40
+ }, [isIframePure, onIframePureChange]);
41
+ useLayoutEffect(
42
+ () => () => {
43
+ onIframePureChange == null ? void 0 : onIframePureChange(false);
44
+ },
45
+ [onIframePureChange]
46
+ );
47
+ const {
48
+ state,
49
+ isInitialized,
50
+ addTab,
51
+ canAddTab,
52
+ removeTab,
53
+ updateTab,
54
+ updateTabUrl,
55
+ switchTab,
56
+ rollbackTabActivation,
57
+ closeOtherTabs,
58
+ closeRightTabs,
59
+ closeAllTabs,
60
+ reorderTabs,
61
+ pinTab,
62
+ unpinTab
63
+ } = useTabsState({ config, dataSource, cacheEnabled: !isIframePure });
64
+ const tabInteractionSequenceRef = useRef(0);
65
+ const markTabInteraction = useCallback(() => {
66
+ tabInteractionSequenceRef.current += 1;
67
+ }, []);
68
+ useTabsUrlSync({
69
+ config,
70
+ dataSource,
71
+ state,
72
+ isInitialized,
73
+ addTab,
74
+ switchTab,
75
+ updateTabUrl,
76
+ rollbackTabActivation,
77
+ interactionSequence: tabInteractionSequenceRef.current
172
78
  });
173
- }, [state.tabsList]);
174
-
175
- // 通知父级(ProLayout)当前是否有 Tab
176
- useLayoutEffect(() => {
177
- onTabsChange?.(state.tabsList.length > 0);
178
- }, [state.tabsList.length, onTabsChange]);
179
-
180
- // 卸载时显式复位,避免 ProLayout 在动态退出 tabs 模式后保留偏移状态。
181
- useLayoutEffect(() => () => {
182
- onTabsChange?.(false);
183
- }, [onTabsChange]);
184
-
185
- // 处理声明式固定标签页:config.fixed 中的 code 在初始化完成后自动添加,强制 closable=false
186
- // 用 ref 持有 addTab,避免 addTab 引用变化引起无限循环
187
- const addTabRef = useRef(addTab);
188
- addTabRef.current = addTab;
189
- useEffect(() => {
190
- // iframe pure 模式下不应用 fixed(嵌入页面只显示路由命中的单个 tab)
191
- if (isIframePure) return;
192
- if (!isInitialized || !config.fixed || config.fixed.length === 0) return;
193
- const sourceMenus = Array.isArray(dataSource?.menus) ? flattenMenuData(dataSource.menus) : [];
194
-
195
- // menus 为空说明异步数据尚未返回,等 dataSource 变化后重跑,避免用 code 创建占位 tab
196
- if (sourceMenus.length === 0) return;
197
- config.fixed.forEach(code => {
198
- // 已存在(如缓存恢复):仅校正 closable/pinned,不调 addTab 以保留缓存中的 activeKey
199
- const existing = state.tabsList.find(tab => tab.menuItem?.code === code || tab.code === code);
200
- if (existing) {
201
- if (existing.closable !== false || existing.pinned !== true) {
202
- updateTab(existing.id, {
203
- closable: false,
204
- pinned: true
205
- });
206
- }
207
- return;
208
- }
209
- const matchedMenu = sourceMenus.find(item => item.code === code);
210
- // pinned:true 使声明式固定标签与用户手动固定统一走 pinned 分区逻辑
79
+ iframeAddTabRef.current = (params) => {
80
+ const sourceMenus = Array.isArray(dataSource == null ? void 0 : dataSource.menus) ? flattenMenuData(dataSource.menus) : [];
81
+ const matchedMenu = sourceMenus.find((item) => item.code === params.code);
211
82
  const menuItem = matchedMenu ? {
212
83
  ...matchedMenu,
213
- closable: false,
214
- pinned: true
84
+ name: params.name || matchedMenu.name,
85
+ extra: params.extra ?? matchedMenu.extra
215
86
  } : {
216
87
  id: Date.now(),
217
- code,
218
- name: code,
219
- url: `/${code}`,
220
- closable: false,
221
- pinned: true
88
+ code: params.code,
89
+ name: params.name,
90
+ url: `/${params.code}`,
91
+ extra: params.extra
222
92
  };
223
- // silent: 已有 active(如 iframe 路由命中)时不抢 active;无 active 时仍激活以保留默认行为
224
- addTabRef.current(menuItem, {
225
- silent: true
93
+ addTab(menuItem);
94
+ };
95
+ const [visitedTabIds, setVisitedTabIds] = useState(/* @__PURE__ */ new Set());
96
+ useEffect(() => {
97
+ if (state.activeKey) {
98
+ setVisitedTabIds((prev) => {
99
+ if (prev.has(state.activeKey))
100
+ return prev;
101
+ const newSet = new Set(prev);
102
+ newSet.add(state.activeKey);
103
+ return newSet;
104
+ });
105
+ }
106
+ }, [state.activeKey]);
107
+ const [viewStacks, setViewStacks] = useState({});
108
+ const activeKeyRef = useRef(state.activeKey);
109
+ activeKeyRef.current = state.activeKey;
110
+ const viewStacksRef = useRef(viewStacks);
111
+ viewStacksRef.current = viewStacks;
112
+ const pushView = useCallback((node) => {
113
+ const tabId = activeKeyRef.current;
114
+ if (!tabId)
115
+ return;
116
+ setViewStacks((prev) => ({
117
+ ...prev,
118
+ [tabId]: [...prev[tabId] || [], node]
119
+ }));
120
+ }, []);
121
+ const back = useCallback(() => {
122
+ const tabId = activeKeyRef.current;
123
+ if (!tabId)
124
+ return;
125
+ setViewStacks((prev) => {
126
+ const stack = prev[tabId];
127
+ if (!stack || stack.length === 0)
128
+ return prev;
129
+ const nextStack = stack.slice(0, -1);
130
+ const next = { ...prev };
131
+ if (nextStack.length === 0) {
132
+ delete next[tabId];
133
+ } else {
134
+ next[tabId] = nextStack;
135
+ }
136
+ return next;
226
137
  });
227
- });
228
- }, [isInitialized, config.fixed, dataSource, state.tabsList, updateTab, isIframePure]);
229
-
230
- // 处理菜单点击 - 拦截原有的菜单点击逻辑
231
- const handleMenuClick = useCallback(params => {
232
- if (params.item) {
233
- markTabInteraction();
234
- addTab(params.item);
235
- }
236
- originalOnMenuClick?.(params);
237
- }, [addTab, markTabInteraction, originalOnMenuClick]);
238
-
239
- // 切换固定状态:已固定→取消固定,未固定→固定
240
- const handleTogglePin = useCallback(tabId => {
241
- const target = state.tabsList.find(tab => tab.id === tabId);
242
- if (!target) return;
243
- if (derivePinned(target)) {
244
- unpinTab(tabId);
245
- } else {
246
- pinTab(tabId);
247
- }
248
- }, [state.tabsList, pinTab, unpinTab]);
249
-
250
- // 创建标签页实例 API
251
- const tabsInstance = useMemo(() => ({
252
- addTab: (params, options) => {
253
- markTabInteraction();
254
- const sourceMenus = Array.isArray(dataSource?.menus) ? dataSource.menus : [];
255
- const menuItem = resolveTabMenuItem(params, sourceMenus);
256
- addTab(menuItem, options);
257
- },
258
- removeTab: tabId => {
259
- markTabInteraction();
260
- removeTab(tabId);
261
- },
262
- updateTab,
263
- getTabInfo: () => ({
264
- tabsList: state.tabsList,
265
- activeTabInfo: state.tabsList.find(tab => tab.id === state.activeKey),
266
- activeComponent: state.activeComponent
267
- }),
268
- pushView,
269
- back,
270
- getViewStack
271
- }), [addTab, markTabInteraction, removeTab, updateTab, state.tabsList, state.activeKey, state.activeComponent, dataSource, pushView, back, getViewStack]);
272
- const handleTabChange = useCallback(activeKey => {
273
- markTabInteraction();
274
- switchTab(activeKey);
275
- }, [markTabInteraction, switchTab]);
276
- const handleRemoveTab = useCallback(tabId => {
277
- markTabInteraction();
278
- removeTab(tabId);
279
- }, [markTabInteraction, removeTab]);
280
- const handleCloseOtherTabs = useCallback(tabId => {
281
- markTabInteraction();
282
- closeOtherTabs(tabId);
283
- }, [closeOtherTabs, markTabInteraction]);
284
- const handleCloseRightTabs = useCallback(tabId => {
285
- markTabInteraction();
286
- closeRightTabs(tabId);
287
- }, [closeRightTabs, markTabInteraction]);
288
- const handleCloseAllTabs = useCallback(() => {
289
- markTabInteraction();
290
- closeAllTabs();
291
- }, [closeAllTabs, markTabInteraction]);
292
- const handleTabEdit = useCallback((targetKey, action) => {
293
- if (action === 'remove') {
294
- handleRemoveTab(targetKey);
295
- }
296
- }, [handleRemoveTab]);
297
-
298
- // 构建 Tabs items
299
- const tabsItems = useMemo(() => {
300
- if (state.tabsList.length === 0) return [];
301
-
302
- // config.fixed 声明的 code 集合:这些标签是强制固定,不允许用户取消固定
303
- const forcedFixedCodes = new Set(config?.fixed ?? []);
304
- return state.tabsList.map(tab => {
305
- const pinned = derivePinned(tab);
306
- const pinDisabled = forcedFixedCodes.has(tab.menuItem?.code ?? tab.code);
307
- return {
308
- key: tab.id,
309
- label: /*#__PURE__*/_jsx(TabItemComponent, {
310
- tab: tab,
311
- active: tab.id === state.activeKey,
312
- onClick: () => handleTabChange(tab.id),
313
- onClose: () => handleRemoveTab(tab.id),
314
- onCloseOthers: () => handleCloseOtherTabs(tab.id),
315
- onCloseRight: () => handleCloseRightTabs(tab.id),
316
- onCloseAll: handleCloseAllTabs,
317
- pinned: pinned,
318
- pinDisabled: pinDisabled,
319
- onTogglePin: () => handleTogglePin(tab.id),
138
+ }, []);
139
+ const getViewStack = useCallback(
140
+ () => viewStacksRef.current[activeKeyRef.current] || [],
141
+ []
142
+ );
143
+ useEffect(() => {
144
+ setViewStacks((prev) => {
145
+ const keys = Object.keys(prev);
146
+ if (keys.length === 0)
147
+ return prev;
148
+ const aliveIds = new Set(state.tabsList.map((tab) => tab.id));
149
+ const staleKeys = keys.filter((id) => !aliveIds.has(id));
150
+ if (staleKeys.length === 0)
151
+ return prev;
152
+ const next = { ...prev };
153
+ staleKeys.forEach((id) => delete next[id]);
154
+ return next;
155
+ });
156
+ }, [state.tabsList]);
157
+ useLayoutEffect(() => {
158
+ onTabsChange == null ? void 0 : onTabsChange(state.tabsList.length > 0);
159
+ }, [state.tabsList.length, onTabsChange]);
160
+ useLayoutEffect(
161
+ () => () => {
162
+ onTabsChange == null ? void 0 : onTabsChange(false);
163
+ },
164
+ [onTabsChange]
165
+ );
166
+ const addTabRef = useRef(addTab);
167
+ addTabRef.current = addTab;
168
+ useEffect(() => {
169
+ if (isIframePure)
170
+ return;
171
+ if (!isInitialized || !config.fixed || config.fixed.length === 0)
172
+ return;
173
+ const sourceMenus = Array.isArray(dataSource == null ? void 0 : dataSource.menus) ? flattenMenuData(dataSource.menus) : [];
174
+ if (sourceMenus.length === 0)
175
+ return;
176
+ config.fixed.forEach((code) => {
177
+ const existing = state.tabsList.find(
178
+ (tab) => {
179
+ var _a;
180
+ return ((_a = tab.menuItem) == null ? void 0 : _a.code) === code || tab.code === code;
181
+ }
182
+ );
183
+ if (existing) {
184
+ if (existing.closable !== false || existing.pinned !== true) {
185
+ updateTab(existing.id, { closable: false, pinned: true });
186
+ }
187
+ return;
188
+ }
189
+ const matchedMenu = sourceMenus.find((item) => item.code === code);
190
+ const menuItem = matchedMenu ? { ...matchedMenu, closable: false, pinned: true } : {
191
+ id: Date.now(),
192
+ code,
193
+ name: code,
194
+ url: `/${code}`,
195
+ closable: false,
196
+ pinned: true
197
+ };
198
+ addTabRef.current(menuItem, { silent: true });
199
+ });
200
+ }, [isInitialized, config.fixed, dataSource, state.tabsList, updateTab, isIframePure]);
201
+ const handleMenuClick = useCallback(
202
+ (params) => {
203
+ if (params.item) {
204
+ markTabInteraction();
205
+ addTab(params.item);
206
+ }
207
+ originalOnMenuClick == null ? void 0 : originalOnMenuClick(params);
208
+ },
209
+ [addTab, markTabInteraction, originalOnMenuClick]
210
+ );
211
+ const handleTogglePin = useCallback(
212
+ (tabId) => {
213
+ const target = state.tabsList.find((tab) => tab.id === tabId);
214
+ if (!target)
215
+ return;
216
+ if (derivePinned(target)) {
217
+ unpinTab(tabId);
218
+ } else {
219
+ pinTab(tabId);
220
+ }
221
+ },
222
+ [state.tabsList, pinTab, unpinTab]
223
+ );
224
+ const tabsInstance = useMemo(
225
+ () => ({
226
+ addTab: (params, options) => {
227
+ markTabInteraction();
228
+ const sourceMenus = Array.isArray(dataSource == null ? void 0 : dataSource.menus) ? dataSource.menus : [];
229
+ const menuItem = resolveTabMenuItem(params, sourceMenus);
230
+ addTab(menuItem, options);
231
+ },
232
+ removeTab: (tabId) => {
233
+ markTabInteraction();
234
+ removeTab(tabId);
235
+ },
236
+ updateTab,
237
+ getTabInfo: () => ({
320
238
  tabsList: state.tabsList,
321
- menuItems: config?.menuItems,
322
- tabMenuClick: config?.tabMenuClick
239
+ activeTabInfo: state.tabsList.find((tab) => tab.id === state.activeKey),
240
+ activeComponent: state.activeComponent
323
241
  }),
324
- closable: false,
325
- // 关闭 antd 内置 ×,由 TabItemComponent 自定义按钮处理
326
- children: null
327
- };
328
- });
329
- }, [state.tabsList, state.activeKey, config?.menuItems, config?.tabMenuClick, config?.fixed, handleTabChange, handleRemoveTab, handleCloseOtherTabs, handleCloseRightTabs, handleCloseAllTabs, handleTogglePin]);
330
- const activeComponent = config?.activeComponent;
331
- const emptyComponent = config?.empty;
332
-
333
- // 渲染内容区域
334
- const renderContent = () => {
335
- return /*#__PURE__*/_jsxs("div", {
336
- className: "pro-layout-tabs-content",
337
- children: [state.tabsList.map(tab => {
338
- const isActive = tab.id === state.activeKey;
339
- const hasVisited = visitedTabIds.has(tab.id);
340
- if (!isActive && !hasVisited) {
341
- return /*#__PURE__*/_jsx("div", {
342
- className: "tab-pane hidden",
343
- "data-testid": `tab-pane-${tab.id}`
344
- }, tab.id);
242
+ pushView,
243
+ back,
244
+ getViewStack
245
+ }),
246
+ [
247
+ addTab,
248
+ markTabInteraction,
249
+ removeTab,
250
+ updateTab,
251
+ state.tabsList,
252
+ state.activeKey,
253
+ state.activeComponent,
254
+ dataSource,
255
+ pushView,
256
+ back,
257
+ getViewStack
258
+ ]
259
+ );
260
+ const handleTabChange = useCallback(
261
+ (activeKey) => {
262
+ markTabInteraction();
263
+ switchTab(activeKey);
264
+ },
265
+ [markTabInteraction, switchTab]
266
+ );
267
+ const handleRemoveTab = useCallback(
268
+ (tabId) => {
269
+ markTabInteraction();
270
+ removeTab(tabId);
271
+ },
272
+ [markTabInteraction, removeTab]
273
+ );
274
+ const handleCloseOtherTabs = useCallback(
275
+ (tabId) => {
276
+ markTabInteraction();
277
+ closeOtherTabs(tabId);
278
+ },
279
+ [closeOtherTabs, markTabInteraction]
280
+ );
281
+ const handleCloseRightTabs = useCallback(
282
+ (tabId) => {
283
+ markTabInteraction();
284
+ closeRightTabs(tabId);
285
+ },
286
+ [closeRightTabs, markTabInteraction]
287
+ );
288
+ const handleCloseAllTabs = useCallback(() => {
289
+ markTabInteraction();
290
+ closeAllTabs();
291
+ }, [closeAllTabs, markTabInteraction]);
292
+ const handleTabEdit = useCallback(
293
+ (targetKey, action) => {
294
+ if (action === "remove") {
295
+ handleRemoveTab(targetKey);
345
296
  }
346
- let content = children;
347
- if (activeComponent && tab.menuItem?.code) {
348
- const ResolvedComponent = activeComponent(tab.menuItem.code);
349
- if (ResolvedComponent) {
350
- content = /*#__PURE__*/_jsx(ResolvedComponent, {
351
- ...(tab.menuItem.extra || {})
352
- });
297
+ },
298
+ [handleRemoveTab]
299
+ );
300
+ const tabsItems = useMemo(() => {
301
+ if (state.tabsList.length === 0)
302
+ return [];
303
+ const forcedFixedCodes = new Set((config == null ? void 0 : config.fixed) ?? []);
304
+ return state.tabsList.map((tab) => {
305
+ var _a;
306
+ const pinned = derivePinned(tab);
307
+ const pinDisabled = forcedFixedCodes.has(((_a = tab.menuItem) == null ? void 0 : _a.code) ?? tab.code);
308
+ return {
309
+ key: tab.id,
310
+ label: /* @__PURE__ */ jsx(
311
+ TabItemComponent,
312
+ {
313
+ tab,
314
+ active: tab.id === state.activeKey,
315
+ onClick: () => handleTabChange(tab.id),
316
+ onClose: () => handleRemoveTab(tab.id),
317
+ onCloseOthers: () => handleCloseOtherTabs(tab.id),
318
+ onCloseRight: () => handleCloseRightTabs(tab.id),
319
+ onCloseAll: handleCloseAllTabs,
320
+ pinned,
321
+ pinDisabled,
322
+ onTogglePin: () => handleTogglePin(tab.id),
323
+ tabsList: state.tabsList,
324
+ menuItems: config == null ? void 0 : config.menuItems,
325
+ tabMenuClick: config == null ? void 0 : config.tabMenuClick
326
+ }
327
+ ),
328
+ closable: false,
329
+ // 关闭 antd 内置 ×,由 TabItemComponent 自定义按钮处理
330
+ children: null
331
+ };
332
+ });
333
+ }, [
334
+ state.tabsList,
335
+ state.activeKey,
336
+ config == null ? void 0 : config.menuItems,
337
+ config == null ? void 0 : config.tabMenuClick,
338
+ config == null ? void 0 : config.fixed,
339
+ handleTabChange,
340
+ handleRemoveTab,
341
+ handleCloseOtherTabs,
342
+ handleCloseRightTabs,
343
+ handleCloseAllTabs,
344
+ handleTogglePin
345
+ ]);
346
+ const activeComponent = config == null ? void 0 : config.activeComponent;
347
+ const emptyComponent = config == null ? void 0 : config.empty;
348
+ const renderContent = () => {
349
+ return /* @__PURE__ */ jsxs("div", { className: "pro-layout-tabs-content", children: [
350
+ state.tabsList.map((tab) => {
351
+ var _a;
352
+ const isActive = tab.id === state.activeKey;
353
+ const hasVisited = visitedTabIds.has(tab.id);
354
+ if (!isActive && !hasVisited) {
355
+ return /* @__PURE__ */ jsx("div", { className: "tab-pane hidden", "data-testid": `tab-pane-${tab.id}` }, tab.id);
353
356
  }
354
- }
355
-
356
- // 该 tab 的子视图栈:栈底→栈顶。只有「当前激活 tab 的栈顶层」可见,
357
- // 入口页与下层子视图 display:none 但保持挂载 → 返回秒回、状态不丢。
358
- const stack = viewStacks[tab.id] || [];
359
- // 入口页可见条件:该 tab 激活 且 无子视图
360
- const entryVisible = isActive && stack.length === 0;
361
- return /*#__PURE__*/_jsx("div", {
362
- className: `tab-pane ${entryVisible ? '' : 'hidden'}`,
363
- "data-testid": `tab-pane-${tab.id}`,
364
- children: content
365
- }, tab.id);
366
- }), state.tabsList.map(tab => {
367
- const isActive = tab.id === state.activeKey;
368
- const stack = viewStacks[tab.id] || [];
369
- if (stack.length === 0) return null;
370
- const topIndex = stack.length - 1;
371
- return stack.map((node, index) => {
372
- const layerVisible = isActive && index === topIndex;
373
- return /*#__PURE__*/_jsx("div", {
374
- className: `tab-pane ${layerVisible ? '' : 'hidden'}`,
375
- "data-testid": `tab-subview-${tab.id}-${index}`,
376
- children: node
377
- }, `${tab.id}-subview-${index}`);
378
- });
379
- }), state.tabsList.length === 0 && /*#__PURE__*/_jsx("div", {
380
- className: "tab-pane",
381
- "data-testid": "default-content",
382
- children: emptyComponent || children
383
- })]
384
- });
385
- };
386
-
387
- // TabsHeader 节点:有 tabsBarContainer 时用 Portal 渲染到外部,否则原位 fallback
388
- // iframe pure 模式下完全不渲染 tab bar
389
- const tabsHeaderNode = state.tabsList.length > 0 && !isIframePure ? /*#__PURE__*/_jsx(TabsHeader, {
390
- activeKey: state.activeKey || undefined,
391
- tabsItems: tabsItems,
392
- onTabChange: handleTabChange,
393
- onTabEdit: handleTabEdit,
394
- draggable: config?.draggable !== false,
395
- onReorder: reorderTabs
396
- }) : null;
397
- useImperativeHandle(ref, () => ({
398
- handleMenuClick,
399
- canAddTab,
400
- getTabInfo: tabsInstance.getTabInfo
401
- }), [handleMenuClick, canAddTab, tabsInstance]);
402
- return /*#__PURE__*/_jsxs(TabsContext.Provider, {
403
- value: tabsInstance,
404
- children: [tabsBarContainer ? /*#__PURE__*/createPortal(tabsHeaderNode, tabsBarContainer) : tabsHeaderNode, /*#__PURE__*/_jsx("div", {
405
- className: "pro-layout-tabs",
406
- "data-testid": "tabs-manager",
407
- children: renderContent()
408
- })]
409
- });
410
- });
411
- TabsManager.displayName = 'TabsManager';
412
- export default TabsManager;
357
+ let content = children;
358
+ if (activeComponent && ((_a = tab.menuItem) == null ? void 0 : _a.code)) {
359
+ const ResolvedComponent = activeComponent(tab.menuItem.code);
360
+ if (ResolvedComponent) {
361
+ content = /* @__PURE__ */ jsx(ResolvedComponent, { ...tab.menuItem.extra || {} });
362
+ }
363
+ }
364
+ const stack = viewStacks[tab.id] || [];
365
+ const entryVisible = isActive && stack.length === 0;
366
+ return /* @__PURE__ */ jsx(
367
+ "div",
368
+ {
369
+ className: `tab-pane ${entryVisible ? "" : "hidden"}`,
370
+ "data-testid": `tab-pane-${tab.id}`,
371
+ children: content
372
+ },
373
+ tab.id
374
+ );
375
+ }),
376
+ state.tabsList.map((tab) => {
377
+ const isActive = tab.id === state.activeKey;
378
+ const stack = viewStacks[tab.id] || [];
379
+ if (stack.length === 0)
380
+ return null;
381
+ const topIndex = stack.length - 1;
382
+ return stack.map((node, index) => {
383
+ const layerVisible = isActive && index === topIndex;
384
+ return /* @__PURE__ */ jsx(
385
+ "div",
386
+ {
387
+ className: `tab-pane ${layerVisible ? "" : "hidden"}`,
388
+ "data-testid": `tab-subview-${tab.id}-${index}`,
389
+ children: node
390
+ },
391
+ `${tab.id}-subview-${index}`
392
+ );
393
+ });
394
+ }),
395
+ state.tabsList.length === 0 && /* @__PURE__ */ jsx("div", { className: "tab-pane", "data-testid": "default-content", children: emptyComponent || children })
396
+ ] });
397
+ };
398
+ const tabsHeaderNode = state.tabsList.length > 0 && !isIframePure ? /* @__PURE__ */ jsx(
399
+ TabsHeader,
400
+ {
401
+ activeKey: state.activeKey || void 0,
402
+ tabsItems,
403
+ onTabChange: handleTabChange,
404
+ onTabEdit: handleTabEdit,
405
+ draggable: (config == null ? void 0 : config.draggable) !== false,
406
+ onReorder: reorderTabs
407
+ }
408
+ ) : null;
409
+ useImperativeHandle(
410
+ ref,
411
+ () => ({
412
+ handleMenuClick,
413
+ canAddTab,
414
+ getTabInfo: tabsInstance.getTabInfo
415
+ }),
416
+ [handleMenuClick, canAddTab, tabsInstance]
417
+ );
418
+ return /* @__PURE__ */ jsxs(TabsContext.Provider, { value: tabsInstance, children: [
419
+ tabsBarContainer ? createPortal(tabsHeaderNode, tabsBarContainer) : tabsHeaderNode,
420
+ /* @__PURE__ */ jsx("div", { className: "pro-layout-tabs", "data-testid": "tabs-manager", children: renderContent() })
421
+ ] });
422
+ }
423
+ );
424
+ TabsManager.displayName = "TabsManager";
425
+ var TabsManager_default = TabsManager;
426
+ export {
427
+ TabsManager_default as default
428
+ };