@zat-design/sisyphus-react 4.5.9 → 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 (280) hide show
  1. package/dist/index.esm.css +1 -1
  2. package/dist/less.esm.css +1 -1
  3. package/es/FormsProvider/index.js +14 -21
  4. package/es/ProAction/components/CheckModalContent/index.js +12 -26
  5. package/es/ProAction/index.js +79 -83
  6. package/es/ProAction/propsType.js +0 -1
  7. package/es/ProConfigProvider/index.js +63 -110
  8. package/es/ProConfigProvider/propsType.js +0 -1
  9. package/es/ProDownload/index.d.ts +2 -1
  10. package/es/ProDownload/index.js +74 -69
  11. package/es/ProDownload/propsType.js +0 -1
  12. package/es/ProDownload/utils.d.ts +10 -5
  13. package/es/ProDownload/utils.js +63 -95
  14. package/es/ProDrawerForm/components/ProDrawer/index.js +83 -113
  15. package/es/ProDrawerForm/components/ProModal/index.js +77 -108
  16. package/es/ProDrawerForm/components/index.js +6 -2
  17. package/es/ProDrawerForm/hooks/useConfirmClose.js +20 -39
  18. package/es/ProDrawerForm/index.js +29 -38
  19. package/es/ProDrawerForm/propsType.js +0 -1
  20. package/es/ProDrawerForm/utils/index.js +18 -36
  21. package/es/ProEditLabel/components/RenderProForm.js +45 -49
  22. package/es/ProEditLabel/index.js +126 -163
  23. package/es/ProEditLabel/propsType.js +0 -1
  24. package/es/ProEditLabel/utils/index.js +5 -8
  25. package/es/ProEditTable/components/ActionButton/index.js +111 -119
  26. package/es/ProEditTable/components/RcTable/BaseTable.js +38 -51
  27. package/es/ProEditTable/components/RcTable/DraggableTable.js +97 -129
  28. package/es/ProEditTable/components/RcTable/index.js +6 -4
  29. package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +77 -95
  30. package/es/ProEditTable/components/RenderField/index.js +490 -587
  31. package/es/ProEditTable/components/RenderField/propsType.js +0 -1
  32. package/es/ProEditTable/components/RenderField/tools.js +115 -112
  33. package/es/ProEditTable/components/RenderToolbar/index.js +47 -73
  34. package/es/ProEditTable/components/Summary/index.js +38 -64
  35. package/es/ProEditTable/components/Validator/index.js +46 -46
  36. package/es/ProEditTable/components/index.js +12 -5
  37. package/es/ProEditTable/index.js +456 -378
  38. package/es/ProEditTable/propsType.js +0 -1
  39. package/es/ProEditTable/utils/config.js +60 -122
  40. package/es/ProEditTable/utils/diffOriginal.js +45 -82
  41. package/es/ProEditTable/utils/getDefaultProps.js +19 -24
  42. package/es/ProEditTable/utils/index.js +154 -235
  43. package/es/ProEditTable/utils/tools.js +149 -286
  44. package/es/ProEditTable/utils/transform.js +25 -30
  45. package/es/ProEditTable/utils/useEditTableError.js +30 -43
  46. package/es/ProEditTable/utils/useShouldUpdateForTable.js +42 -72
  47. package/es/ProEditTable/utils/validateAll.js +87 -154
  48. package/es/ProEnum/components/Group.js +38 -30
  49. package/es/ProEnum/components/Tag.js +22 -26
  50. package/es/ProEnum/hooks/useEnum.js +48 -116
  51. package/es/ProEnum/hooks/useEnumRequest.js +182 -212
  52. package/es/ProEnum/hooks/useFrequentEnumRequest.js +40 -48
  53. package/es/ProEnum/index.js +162 -172
  54. package/es/ProEnum/propsType.js +0 -1
  55. package/es/ProEnum/utils/eventCenter.js +10 -12
  56. package/es/ProEnum/utils/frequentEnum.js +35 -92
  57. package/es/ProEnum/utils/getEnum.js +32 -90
  58. package/es/ProEnum/utils/getEnumLabel.js +44 -49
  59. package/es/ProEnum/utils/index.js +93 -207
  60. package/es/ProForm/components/Container.js +13 -28
  61. package/es/ProForm/components/FormFooter/index.js +36 -44
  62. package/es/ProForm/components/FormFooter/propsType.js +0 -1
  63. package/es/ProForm/components/base/Checkbox/index.js +32 -59
  64. package/es/ProForm/components/base/DatePicker/index.js +49 -71
  65. package/es/ProForm/components/base/Input/index.js +63 -97
  66. package/es/ProForm/components/base/Input/propsType.js +0 -1
  67. package/es/ProForm/components/base/InputNumber/index.js +118 -172
  68. package/es/ProForm/components/base/Radio/index.js +39 -52
  69. package/es/ProForm/components/base/RangePicker/index.js +109 -127
  70. package/es/ProForm/components/base/RangePicker/useDateRange.js +20 -17
  71. package/es/ProForm/components/base/Select/index.js +63 -89
  72. package/es/ProForm/components/base/Switch/index.js +27 -35
  73. package/es/ProForm/components/base/SwitchCheckbox/index.js +36 -54
  74. package/es/ProForm/components/base/TextArea/index.js +30 -41
  75. package/es/ProForm/components/base/TimePicker/index.js +27 -37
  76. package/es/ProForm/components/combination/Container/index.js +37 -47
  77. package/es/ProForm/components/combination/Container/propsType.js +0 -1
  78. package/es/ProForm/components/combination/FormList/components/ActionButton.js +165 -237
  79. package/es/ProForm/components/combination/FormList/components/BlockFields.js +98 -102
  80. package/es/ProForm/components/combination/FormList/components/Empty.js +28 -55
  81. package/es/ProForm/components/combination/FormList/components/LineFields.js +57 -54
  82. package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +61 -109
  83. package/es/ProForm/components/combination/FormList/index.js +151 -161
  84. package/es/ProForm/components/combination/FormList/propsType.js +0 -1
  85. package/es/ProForm/components/combination/FormList/style/index.less +6 -0
  86. package/es/ProForm/components/combination/FormList/utils.js +22 -38
  87. package/es/ProForm/components/combination/Group/component/AddonWrapper/index.js +12 -28
  88. package/es/ProForm/components/combination/Group/component/ComRender.js +50 -111
  89. package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +106 -213
  90. package/es/ProForm/components/combination/Group/hooks/index.js +69 -129
  91. package/es/ProForm/components/combination/Group/index.js +87 -126
  92. package/es/ProForm/components/combination/Group/propsType.js +0 -1
  93. package/es/ProForm/components/combination/Group/utils/index.js +124 -239
  94. package/es/ProForm/components/combination/ProCascader/index.js +156 -199
  95. package/es/ProForm/components/combination/ProCascader/propsType.js +0 -1
  96. package/es/ProForm/components/combination/ProCascader/utils/index.js +12 -21
  97. package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +72 -70
  98. package/es/ProForm/components/combination/ProModalSelect/index.js +309 -347
  99. package/es/ProForm/components/combination/ProModalSelect/propsType.js +0 -1
  100. package/es/ProForm/components/combination/ProModalSelect/utils/index.js +32 -39
  101. package/es/ProForm/components/combination/ProNumberRange/index.js +100 -156
  102. package/es/ProForm/components/combination/ProNumberRange/propsType.js +0 -1
  103. package/es/ProForm/components/combination/ProRangeLimit/index.js +104 -115
  104. package/es/ProForm/components/combination/ProRangeLimit/propsType.js +0 -1
  105. package/es/ProForm/components/combination/ProTimeLimit/hooks/useControlled.js +16 -16
  106. package/es/ProForm/components/combination/ProTimeLimit/index.js +75 -109
  107. package/es/ProForm/components/index.js +56 -34
  108. package/es/ProForm/components/render/ChangedWrapper.js +85 -94
  109. package/es/ProForm/components/render/ConfirmWrapper.js +27 -39
  110. package/es/ProForm/components/render/CustomComponentViewWrapper.js +65 -82
  111. package/es/ProForm/components/render/Render.js +223 -329
  112. package/es/ProForm/components/render/RenderFields.js +76 -113
  113. package/es/ProForm/components/render/propsType.js +0 -1
  114. package/es/ProForm/hooks/useControlled.js +8 -10
  115. package/es/ProForm/hooks/useDeepCompareMemo.js +11 -11
  116. package/es/ProForm/hooks/useFieldProps.js +8 -4
  117. package/es/ProForm/hooks/useForm.js +50 -110
  118. package/es/ProForm/hooks/useRules.js +17 -33
  119. package/es/ProForm/hooks/useShouldUpdate.js +77 -152
  120. package/es/ProForm/hooks/useWatch.js +62 -134
  121. package/es/ProForm/index.js +157 -194
  122. package/es/ProForm/propsType.js +15 -7
  123. package/es/ProForm/utils/buildFormItemProps.js +51 -58
  124. package/es/ProForm/utils/diffOriginal.js +43 -73
  125. package/es/ProForm/utils/getDefaultProps.js +18 -24
  126. package/es/ProForm/utils/index.js +160 -235
  127. package/es/ProForm/utils/processDependencies.js +21 -60
  128. package/es/ProForm/utils/reactiveValues.js +20 -34
  129. package/es/ProForm/utils/rulesCreator.js +42 -40
  130. package/es/ProForm/utils/transformNames.js +10 -13
  131. package/es/ProForm/utils/transformValue.js +16 -29
  132. package/es/ProForm/utils/valueType.js +96 -178
  133. package/es/ProIcon/config/index.js +340 -274
  134. package/es/ProIcon/index.js +135 -209
  135. package/es/ProIcon/propsTypes.js +0 -1
  136. package/es/ProIcon/utils/index.js +24 -39
  137. package/es/ProLayout/components/Layout/Header/index.js +108 -141
  138. package/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +134 -190
  139. package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +113 -139
  140. package/es/ProLayout/components/Layout/Menu/OpenMenu/propsType.js +0 -1
  141. package/es/ProLayout/components/Layout/Menu/SideMenu/index.js +23 -31
  142. package/es/ProLayout/components/Layout/Menu/index.js +92 -89
  143. package/es/ProLayout/components/Layout/Notice/index.js +13 -27
  144. package/es/ProLayout/components/Layout/index.js +8 -3
  145. package/es/ProLayout/components/ProCollapse/PropTypes.js +0 -1
  146. package/es/ProLayout/components/ProCollapse/index.js +89 -111
  147. package/es/ProLayout/components/ProFooter/PropTypes.js +0 -1
  148. package/es/ProLayout/components/ProFooter/index.js +27 -24
  149. package/es/ProLayout/components/ProHeader/PropTypes.js +0 -1
  150. package/es/ProLayout/components/ProHeader/components/Copy/index.js +23 -21
  151. package/es/ProLayout/components/ProHeader/components/Describe/index.js +67 -84
  152. package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.js +18 -21
  153. package/es/ProLayout/components/ProHeader/components/ProBackBtn/propsType.js +0 -1
  154. package/es/ProLayout/components/ProHeader/components/index.js +6 -2
  155. package/es/ProLayout/components/ProHeader/index.js +216 -356
  156. package/es/ProLayout/components/ProHeader/utils/index.js +19 -26
  157. package/es/ProLayout/components/TabsManager/components/TabContextMenu.js +92 -85
  158. package/es/ProLayout/components/TabsManager/components/TabItem.js +53 -63
  159. package/es/ProLayout/components/TabsManager/components/TabsContext.js +5 -5
  160. package/es/ProLayout/components/TabsManager/components/TabsHeader.js +42 -52
  161. package/es/ProLayout/components/TabsManager/hooks/useActiveTab.js +8 -9
  162. package/es/ProLayout/components/TabsManager/hooks/useIframeRoute.js +19 -32
  163. package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +6 -20
  164. package/es/ProLayout/components/TabsManager/hooks/useTabsCache.js +25 -42
  165. package/es/ProLayout/components/TabsManager/hooks/useTabsState.js +320 -350
  166. package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.d.ts +19 -0
  167. package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.js +332 -0
  168. package/es/ProLayout/components/TabsManager/index.js +407 -351
  169. package/es/ProLayout/components/TabsManager/propTypes.d.ts +4 -0
  170. package/es/ProLayout/components/TabsManager/propTypes.js +7 -15
  171. package/es/ProLayout/components/TabsManager/style/index.less +1 -1
  172. package/es/ProLayout/components/TabsManager/utils/historyObserver.d.ts +7 -0
  173. package/es/ProLayout/components/TabsManager/utils/historyObserver.js +65 -0
  174. package/es/ProLayout/components/TabsManager/utils/index.d.ts +15 -2
  175. package/es/ProLayout/components/TabsManager/utils/index.js +156 -159
  176. package/es/ProLayout/components/index.js +8 -3
  177. package/es/ProLayout/index.js +173 -228
  178. package/es/ProLayout/propTypes.d.ts +28 -1
  179. package/es/ProLayout/propTypes.js +12 -52
  180. package/es/ProLayout/utils/index.js +48 -128
  181. package/es/ProSelect/components/AdaptiveTooltip.js +26 -25
  182. package/es/ProSelect/index.js +187 -223
  183. package/es/ProSelect/propsType.js +0 -1
  184. package/es/ProSelect/style/index.less +13 -0
  185. package/es/ProSelect/utils/index.js +100 -146
  186. package/es/ProStep/components/Anchor/index.js +71 -82
  187. package/es/ProStep/components/Item/index.js +49 -56
  188. package/es/ProStep/components/LazyLoad/index.js +23 -29
  189. package/es/ProStep/components/Listener/index.js +20 -33
  190. package/es/ProStep/components/Step/index.js +31 -38
  191. package/es/ProStep/constants.js +4 -1
  192. package/es/ProStep/index.js +166 -153
  193. package/es/ProStep/propsType.js +0 -1
  194. package/es/ProStep/style/index.less +1 -1
  195. package/es/ProStep/utils/index.js +29 -55
  196. package/es/ProStepTab/index.js +83 -138
  197. package/es/ProStepTab/propsType.js +0 -1
  198. package/es/ProTable/components/EditableCell/EditIcon.js +10 -14
  199. package/es/ProTable/components/EditableCell/index.js +37 -71
  200. package/es/ProTable/components/EditableCell/propsType.js +0 -1
  201. package/es/ProTable/components/FormatColumn/index.js +209 -340
  202. package/es/ProTable/components/FormatColumn/propsType.js +0 -1
  203. package/es/ProTable/components/RcTable/components/BaseTable/index.js +35 -39
  204. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +80 -107
  205. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index.js +54 -48
  206. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/propsType.js +0 -1
  207. package/es/ProTable/components/RcTable/components/DraggableTable/index.js +47 -54
  208. package/es/ProTable/components/RcTable/index.js +6 -4
  209. package/es/ProTable/components/RenderColumn/index.js +158 -186
  210. package/es/ProTable/components/RenderEmptyText/index.js +12 -21
  211. package/es/ProTable/components/RenderFooter/index.js +15 -15
  212. package/es/ProTable/components/RenderSummary/index.js +33 -50
  213. package/es/ProTable/components/RenderTableHeader/index.js +44 -46
  214. package/es/ProTable/components/RenderTabs/index.js +47 -51
  215. package/es/ProTable/components/TableResizable/index.js +56 -72
  216. package/es/ProTable/components/TooltipTitle/index.js +13 -21
  217. package/es/ProTable/components/index.js +16 -36
  218. package/es/ProTable/hooks/useAntdTable.js +191 -224
  219. package/es/ProTable/index.js +232 -249
  220. package/es/ProTable/propsType.js +0 -1
  221. package/es/ProTable/utils/columnStorage.js +63 -88
  222. package/es/ProTable/utils/index.js +57 -90
  223. package/es/ProTabs/components/Card/index.js +20 -48
  224. package/es/ProTabs/components/index.js +4 -1
  225. package/es/ProTabs/index.js +41 -58
  226. package/es/ProTabs/propType.js +0 -1
  227. package/es/ProThemeTools/component/ProTools/index.js +106 -158
  228. package/es/ProThemeTools/component/index.js +4 -1
  229. package/es/ProThemeTools/context/ThemeContext.js +67 -146
  230. package/es/ProThemeTools/index.js +103 -156
  231. package/es/ProThemeTools/propsType.js +0 -1
  232. package/es/ProThemeTools/utils/index.js +60 -109
  233. package/es/ProTooltip/index.js +132 -168
  234. package/es/ProTooltip/propsType.js +0 -1
  235. package/es/ProTree/components/AdaptiveTooltip.js +15 -17
  236. package/es/ProTree/components/CloseIcon.js +18 -26
  237. package/es/ProTree/components/List.js +28 -47
  238. package/es/ProTree/components/ProTree.js +152 -211
  239. package/es/ProTree/components/ProTreeSelect/index.js +255 -459
  240. package/es/ProTree/components/ProTreeSelect/propsType.js +0 -1
  241. package/es/ProTree/components/SearchTitle.js +23 -42
  242. package/es/ProTree/components/Tree.js +147 -195
  243. package/es/ProTree/components/index.js +10 -5
  244. package/es/ProTree/index.js +12 -16
  245. package/es/ProTree/propsType.js +0 -1
  246. package/es/ProTree/utils.js +46 -118
  247. package/es/ProTreeModal/components/Cascader.js +56 -64
  248. package/es/ProTreeModal/components/CloseIcon.js +18 -26
  249. package/es/ProTreeModal/components/List.js +114 -180
  250. package/es/ProTreeModal/components/SearchTitle.js +15 -18
  251. package/es/ProTreeModal/components/SortableItem.js +29 -58
  252. package/es/ProTreeModal/components/Tree.js +99 -113
  253. package/es/ProTreeModal/components/Trigger.js +87 -121
  254. package/es/ProTreeModal/components/index.js +14 -6
  255. package/es/ProTreeModal/index.js +397 -438
  256. package/es/ProTreeModal/propsType.js +0 -1
  257. package/es/ProTreeModal/utils.js +52 -95
  258. package/es/ProUpload/components/ButtonRender.js +44 -54
  259. package/es/ProUpload/components/DragRender.js +94 -148
  260. package/es/ProUpload/components/DraggableUploadListItem.js +12 -25
  261. package/es/ProUpload/components/Example.js +27 -31
  262. package/es/ProUpload/components/FileItem.js +69 -163
  263. package/es/ProUpload/components/ImageRender.js +134 -170
  264. package/es/ProUpload/index.js +68 -100
  265. package/es/ProUpload/propsType.js +0 -1
  266. package/es/ProUpload/uitls.js +8 -4
  267. package/es/ProUtils/utils/index.js +17 -13
  268. package/es/ProViewer/index.js +154 -175
  269. package/es/ProViewer/propsType.js +0 -5
  270. package/es/ProWaterMark/index.js +9 -16
  271. package/es/ProWaterMark/propsType.js +0 -1
  272. package/es/hooks/useDraggableRow.js +25 -53
  273. package/es/index.js +57 -77
  274. package/es/locale/en_US.js +153 -142
  275. package/es/locale/index.js +23 -36
  276. package/es/locale/zh_CN.js +145 -142
  277. package/es/tokens.js +84 -83
  278. package/es/utils/index.js +24 -51
  279. package/package.json +4 -2
  280. package/es/ProConfigProvider/demo/locale.js +0 -58
@@ -1,372 +1,428 @@
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";
14
+ import { useTabsUrlSync } from "./hooks/useTabsUrlSync";
4
15
  import { useIframeRoute } from "./hooks/useIframeRoute";
5
16
  import { flattenMenuData, resolveTabMenuItem, derivePinned } from "./utils";
6
17
  import { TabItemComponent } from "./components/TabItem";
7
18
  import { TabsHeader } from "./components/TabsHeader";
8
19
  import { TabsContext } from "./components/TabsContext";
9
-
10
- /**
11
- * 标签页管理器主组件
12
- */
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- const TabsManager = /*#__PURE__*/forwardRef(({
15
- config,
16
- children,
17
- dataSource,
18
- originalOnMenuClick,
19
- tabsBarContainer,
20
- onTabsChange,
21
- onIframePureChange
22
- }, ref) => {
23
- // iframe 模式检测(在 useTabsState 之前,因为 cacheEnabled 依赖 pure)
24
- // addTab 由后续 useTabsState 提供,此处先用占位,后面用 ref 透传
25
- const iframeAddTabRef = useRef(() => {});
26
- const {
27
- pure: isIframePure
28
- } = useIframeRoute({
29
- config: config?.iframe,
30
- addTab: params => iframeAddTabRef.current(params)
31
- });
32
-
33
- // 通知父级(ProLayout)pure 状态变化
34
- useLayoutEffect(() => {
35
- onIframePureChange?.(isIframePure);
36
- }, [isIframePure, onIframePureChange]);
37
-
38
- // TabsManager 退出 tabs 模式或上报目标变更时,释放旧父级持有的 pure 状态。
39
- useLayoutEffect(() => () => {
40
- onIframePureChange?.(false);
41
- }, [onIframePureChange]);
42
- const {
43
- state,
44
- isInitialized,
45
- addTab,
46
- canAddTab,
47
- removeTab,
48
- updateTab,
49
- switchTab,
50
- closeOtherTabs,
51
- closeRightTabs,
52
- closeAllTabs,
53
- reorderTabs,
54
- pinTab,
55
- unpinTab
56
- } = useTabsState({
20
+ const TabsManager = forwardRef(
21
+ ({
57
22
  config,
23
+ children,
58
24
  dataSource,
59
- cacheEnabled: !isIframePure
60
- });
61
-
62
- // 桥接 useIframeRoute 的 { code, name, extra } → addTab(menuItem)
63
- iframeAddTabRef.current = params => {
64
- const sourceMenus = Array.isArray(dataSource?.menus) ? flattenMenuData(dataSource.menus) : [];
65
- const matchedMenu = sourceMenus.find(item => item.code === params.code);
66
- const menuItem = matchedMenu ? {
67
- ...matchedMenu,
68
- name: params.name || matchedMenu.name,
69
- extra: params.extra ?? matchedMenu.extra
70
- } : {
71
- id: Date.now(),
72
- code: params.code,
73
- name: params.name,
74
- url: `/${params.code}`,
75
- extra: params.extra
76
- };
77
- addTab(menuItem);
78
- };
79
-
80
- // 记录已访问过的 Tab ID,用于懒加载
81
- const [visitedTabIds, setVisitedTabIds] = useState(new Set());
82
-
83
- // 监听 activeKey 变化,更新 visitedTabIds
84
- useEffect(() => {
85
- if (state.activeKey) {
86
- setVisitedTabIds(prev => {
87
- if (prev.has(state.activeKey)) return prev;
88
- const newSet = new Set(prev);
89
- newSet.add(state.activeKey);
90
- return newSet;
91
- });
92
- }
93
- }, [state.activeKey]);
94
-
95
- // tab 内子视图栈:按 tabId 隔离。栈底→栈顶顺序,入口页不在其中。
96
- // 只活在内存、不进缓存(详情/工作流是运行态 ReactNode,无法 JSON 序列化)。
97
- const [viewStacks, setViewStacks] = useState({});
98
-
99
- // 用 ref 持有 activeKey,供稳定的 pushView/back 读取当前激活 tab,避免因 activeKey 变化重建实例
100
- const activeKeyRef = useRef(state.activeKey);
101
- activeKeyRef.current = state.activeKey;
102
-
103
- // 同步持有最新 viewStacks,使 getViewStack 成为稳定引用且读取不受渲染时序影响
104
- const viewStacksRef = useRef(viewStacks);
105
- viewStacksRef.current = viewStacks;
106
-
107
- // 在当前激活 tab 内压入一层子视图(入口页/下层随之隐藏但不卸载)
108
- const pushView = useCallback(node => {
109
- const tabId = activeKeyRef.current;
110
- if (!tabId) return;
111
- setViewStacks(prev => ({
112
- ...prev,
113
- [tabId]: [...(prev[tabId] || []), node]
114
- }));
115
- }, []);
116
-
117
- // 返回:销毁当前激活 tab 的栈顶子视图(栈空时 no-op)
118
- const back = useCallback(() => {
119
- const tabId = activeKeyRef.current;
120
- if (!tabId) return;
121
- setViewStacks(prev => {
122
- const stack = prev[tabId];
123
- if (!stack || stack.length === 0) return prev;
124
- const nextStack = stack.slice(0, -1);
125
- const next = {
126
- ...prev
127
- };
128
- if (nextStack.length === 0) {
129
- delete next[tabId];
130
- } else {
131
- 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);
132
36
  }
133
- return next;
134
37
  });
135
- }, []);
136
-
137
- // 获取当前激活 tab 的子视图栈(从 ref 读最新值,稳定引用)
138
- const getViewStack = useCallback(() => viewStacksRef.current[activeKeyRef.current] || [], []);
139
-
140
- // 子视图栈与 tabsList 对账:任何关闭路径(removeTab / closeOthers / closeRight /
141
- // closeAll)导致某 tab 消失后,清除其残留子视图栈,避免关闭后 node 仍驻留内存。
142
- useEffect(() => {
143
- setViewStacks(prev => {
144
- const keys = Object.keys(prev);
145
- if (keys.length === 0) return prev;
146
- const aliveIds = new Set(state.tabsList.map(tab => tab.id));
147
- const staleKeys = keys.filter(id => !aliveIds.has(id));
148
- if (staleKeys.length === 0) return prev;
149
- const next = {
150
- ...prev
151
- };
152
- staleKeys.forEach(id => delete next[id]);
153
- 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
154
78
  });
155
- }, [state.tabsList]);
156
-
157
- // 通知父级(ProLayout)当前是否有 Tab
158
- useLayoutEffect(() => {
159
- onTabsChange?.(state.tabsList.length > 0);
160
- }, [state.tabsList.length, onTabsChange]);
161
-
162
- // 卸载时显式复位,避免 ProLayout 在动态退出 tabs 模式后保留偏移状态。
163
- useLayoutEffect(() => () => {
164
- onTabsChange?.(false);
165
- }, [onTabsChange]);
166
-
167
- // 处理声明式固定标签页:config.fixed 中的 code 在初始化完成后自动添加,强制 closable=false
168
- // 用 ref 持有 addTab,避免 addTab 引用变化引起无限循环
169
- const addTabRef = useRef(addTab);
170
- addTabRef.current = addTab;
171
- useEffect(() => {
172
- // iframe pure 模式下不应用 fixed(嵌入页面只显示路由命中的单个 tab)
173
- if (isIframePure) return;
174
- if (!isInitialized || !config.fixed || config.fixed.length === 0) return;
175
- const sourceMenus = Array.isArray(dataSource?.menus) ? flattenMenuData(dataSource.menus) : [];
176
-
177
- // menus 为空说明异步数据尚未返回,等 dataSource 变化后重跑,避免用 code 创建占位 tab
178
- if (sourceMenus.length === 0) return;
179
- config.fixed.forEach(code => {
180
- // 已存在(如缓存恢复):仅校正 closable/pinned,不调 addTab 以保留缓存中的 activeKey
181
- const existing = state.tabsList.find(tab => tab.menuItem?.code === code || tab.code === code);
182
- if (existing) {
183
- if (existing.closable !== false || existing.pinned !== true) {
184
- updateTab(existing.id, {
185
- closable: false,
186
- pinned: true
187
- });
188
- }
189
- return;
190
- }
191
- const matchedMenu = sourceMenus.find(item => item.code === code);
192
- // 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);
193
82
  const menuItem = matchedMenu ? {
194
83
  ...matchedMenu,
195
- closable: false,
196
- pinned: true
84
+ name: params.name || matchedMenu.name,
85
+ extra: params.extra ?? matchedMenu.extra
197
86
  } : {
198
87
  id: Date.now(),
199
- code,
200
- name: code,
201
- url: `/${code}`,
202
- closable: false,
203
- pinned: true
88
+ code: params.code,
89
+ name: params.name,
90
+ url: `/${params.code}`,
91
+ extra: params.extra
204
92
  };
205
- // silent: 已有 active(如 iframe 路由命中)时不抢 active;无 active 时仍激活以保留默认行为
206
- addTabRef.current(menuItem, {
207
- 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;
208
137
  });
209
- });
210
- }, [isInitialized, config.fixed, dataSource, state.tabsList, updateTab, isIframePure]);
211
-
212
- // 处理菜单点击 - 拦截原有的菜单点击逻辑
213
- const handleMenuClick = useCallback(params => {
214
- if (params.item) {
215
- addTab(params.item);
216
- }
217
- originalOnMenuClick?.(params);
218
- }, [addTab, originalOnMenuClick]);
219
-
220
- // 切换固定状态:已固定→取消固定,未固定→固定
221
- const handleTogglePin = useCallback(tabId => {
222
- const target = state.tabsList.find(tab => tab.id === tabId);
223
- if (!target) return;
224
- if (derivePinned(target)) {
225
- unpinTab(tabId);
226
- } else {
227
- pinTab(tabId);
228
- }
229
- }, [state.tabsList, pinTab, unpinTab]);
230
-
231
- // 创建标签页实例 API
232
- const tabsInstance = useMemo(() => ({
233
- addTab: (params, options) => {
234
- const sourceMenus = Array.isArray(dataSource?.menus) ? dataSource.menus : [];
235
- const menuItem = resolveTabMenuItem(params, sourceMenus);
236
- addTab(menuItem, options);
237
- },
238
- removeTab,
239
- updateTab,
240
- getTabInfo: () => ({
241
- tabsList: state.tabsList,
242
- activeTabInfo: state.tabsList.find(tab => tab.id === state.activeKey),
243
- activeComponent: state.activeComponent
244
- }),
245
- pushView,
246
- back,
247
- getViewStack
248
- }), [addTab, removeTab, updateTab, state.tabsList, state.activeKey, state.activeComponent, dataSource, pushView, back, getViewStack]);
249
- const handleTabChange = useCallback(activeKey => {
250
- switchTab(activeKey);
251
- }, [switchTab]);
252
- const handleTabEdit = useCallback((targetKey, action) => {
253
- if (action === 'remove') {
254
- removeTab(targetKey);
255
- }
256
- }, [removeTab]);
257
-
258
- // 构建 Tabs items
259
- const tabsItems = useMemo(() => {
260
- if (state.tabsList.length === 0) return [];
261
-
262
- // config.fixed 声明的 code 集合:这些标签是强制固定,不允许用户取消固定
263
- const forcedFixedCodes = new Set(config?.fixed ?? []);
264
- return state.tabsList.map(tab => {
265
- const pinned = derivePinned(tab);
266
- const pinDisabled = forcedFixedCodes.has(tab.menuItem?.code ?? tab.code);
267
- return {
268
- key: tab.id,
269
- label: /*#__PURE__*/_jsx(TabItemComponent, {
270
- tab: tab,
271
- active: tab.id === state.activeKey,
272
- onClick: () => switchTab(tab.id),
273
- onClose: () => removeTab(tab.id),
274
- onCloseOthers: () => closeOtherTabs(tab.id),
275
- onCloseRight: () => closeRightTabs(tab.id),
276
- onCloseAll: closeAllTabs,
277
- pinned: pinned,
278
- pinDisabled: pinDisabled,
279
- 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: () => ({
280
238
  tabsList: state.tabsList,
281
- menuItems: config?.menuItems,
282
- tabMenuClick: config?.tabMenuClick
239
+ activeTabInfo: state.tabsList.find((tab) => tab.id === state.activeKey),
240
+ activeComponent: state.activeComponent
283
241
  }),
284
- closable: false,
285
- // 关闭 antd 内置 ×,由 TabItemComponent 自定义按钮处理
286
- children: null
287
- };
288
- });
289
- }, [state.tabsList, state.activeKey, config?.menuItems, config?.tabMenuClick, config?.fixed, switchTab, removeTab, closeOtherTabs, closeRightTabs, closeAllTabs, handleTogglePin]);
290
- const activeComponent = config?.activeComponent;
291
- const emptyComponent = config?.empty;
292
-
293
- // 渲染内容区域
294
- const renderContent = () => {
295
- return /*#__PURE__*/_jsxs("div", {
296
- className: "pro-layout-tabs-content",
297
- children: [state.tabsList.map(tab => {
298
- const isActive = tab.id === state.activeKey;
299
- const hasVisited = visitedTabIds.has(tab.id);
300
- if (!isActive && !hasVisited) {
301
- return /*#__PURE__*/_jsx("div", {
302
- className: "tab-pane hidden",
303
- "data-testid": `tab-pane-${tab.id}`
304
- }, 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);
305
296
  }
306
- let content = children;
307
- if (activeComponent && tab.menuItem?.code) {
308
- const ResolvedComponent = activeComponent(tab.menuItem.code);
309
- if (ResolvedComponent) {
310
- content = /*#__PURE__*/_jsx(ResolvedComponent, {
311
- ...(tab.menuItem.extra || {})
312
- });
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);
313
356
  }
314
- }
315
-
316
- // tab 的子视图栈:栈底→栈顶。只有「当前激活 tab 的栈顶层」可见,
317
- // 入口页与下层子视图 display:none 但保持挂载 → 返回秒回、状态不丢。
318
- const stack = viewStacks[tab.id] || [];
319
- // 入口页可见条件:该 tab 激活 且 无子视图
320
- const entryVisible = isActive && stack.length === 0;
321
- return /*#__PURE__*/_jsx("div", {
322
- className: `tab-pane ${entryVisible ? '' : 'hidden'}`,
323
- "data-testid": `tab-pane-${tab.id}`,
324
- children: content
325
- }, tab.id);
326
- }), state.tabsList.map(tab => {
327
- const isActive = tab.id === state.activeKey;
328
- const stack = viewStacks[tab.id] || [];
329
- if (stack.length === 0) return null;
330
- const topIndex = stack.length - 1;
331
- return stack.map((node, index) => {
332
- const layerVisible = isActive && index === topIndex;
333
- return /*#__PURE__*/_jsx("div", {
334
- className: `tab-pane ${layerVisible ? '' : 'hidden'}`,
335
- "data-testid": `tab-subview-${tab.id}-${index}`,
336
- children: node
337
- }, `${tab.id}-subview-${index}`);
338
- });
339
- }), state.tabsList.length === 0 && /*#__PURE__*/_jsx("div", {
340
- className: "tab-pane",
341
- "data-testid": "default-content",
342
- children: emptyComponent || children
343
- })]
344
- });
345
- };
346
-
347
- // TabsHeader 节点:有 tabsBarContainer 时用 Portal 渲染到外部,否则原位 fallback
348
- // iframe pure 模式下完全不渲染 tab bar
349
- const tabsHeaderNode = state.tabsList.length > 0 && !isIframePure ? /*#__PURE__*/_jsx(TabsHeader, {
350
- activeKey: state.activeKey || undefined,
351
- tabsItems: tabsItems,
352
- onTabChange: handleTabChange,
353
- onTabEdit: handleTabEdit,
354
- draggable: config?.draggable !== false,
355
- onReorder: reorderTabs
356
- }) : null;
357
- useImperativeHandle(ref, () => ({
358
- handleMenuClick,
359
- canAddTab,
360
- getTabInfo: tabsInstance.getTabInfo
361
- }), [handleMenuClick, canAddTab, tabsInstance]);
362
- return /*#__PURE__*/_jsxs(TabsContext.Provider, {
363
- value: tabsInstance,
364
- children: [tabsBarContainer ? /*#__PURE__*/createPortal(tabsHeaderNode, tabsBarContainer) : tabsHeaderNode, /*#__PURE__*/_jsx("div", {
365
- className: "pro-layout-tabs",
366
- "data-testid": "tabs-manager",
367
- children: renderContent()
368
- })]
369
- });
370
- });
371
- TabsManager.displayName = 'TabsManager';
372
- 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
+ };