@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.
- package/dist/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/FormsProvider/index.js +14 -21
- package/es/ProAction/components/CheckModalContent/index.js +12 -26
- package/es/ProAction/index.js +79 -83
- package/es/ProAction/propsType.js +0 -1
- package/es/ProConfigProvider/index.js +63 -110
- package/es/ProConfigProvider/propsType.js +0 -1
- package/es/ProDownload/index.d.ts +2 -1
- package/es/ProDownload/index.js +74 -69
- package/es/ProDownload/propsType.js +0 -1
- package/es/ProDownload/utils.d.ts +10 -5
- package/es/ProDownload/utils.js +63 -95
- package/es/ProDrawerForm/components/ProDrawer/index.js +83 -113
- package/es/ProDrawerForm/components/ProModal/index.js +77 -108
- package/es/ProDrawerForm/components/index.js +6 -2
- package/es/ProDrawerForm/hooks/useConfirmClose.js +20 -39
- package/es/ProDrawerForm/index.js +29 -38
- package/es/ProDrawerForm/propsType.js +0 -1
- package/es/ProDrawerForm/utils/index.js +18 -36
- package/es/ProEditLabel/components/RenderProForm.js +45 -49
- package/es/ProEditLabel/index.js +126 -163
- package/es/ProEditLabel/propsType.js +0 -1
- package/es/ProEditLabel/utils/index.js +5 -8
- package/es/ProEditTable/components/ActionButton/index.js +111 -119
- package/es/ProEditTable/components/RcTable/BaseTable.js +38 -51
- package/es/ProEditTable/components/RcTable/DraggableTable.js +97 -129
- package/es/ProEditTable/components/RcTable/index.js +6 -4
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +77 -95
- package/es/ProEditTable/components/RenderField/index.js +490 -587
- package/es/ProEditTable/components/RenderField/propsType.js +0 -1
- package/es/ProEditTable/components/RenderField/tools.js +115 -112
- package/es/ProEditTable/components/RenderToolbar/index.js +47 -73
- package/es/ProEditTable/components/Summary/index.js +38 -64
- package/es/ProEditTable/components/Validator/index.js +46 -46
- package/es/ProEditTable/components/index.js +12 -5
- package/es/ProEditTable/index.js +456 -378
- package/es/ProEditTable/propsType.js +0 -1
- package/es/ProEditTable/utils/config.js +60 -122
- package/es/ProEditTable/utils/diffOriginal.js +45 -82
- package/es/ProEditTable/utils/getDefaultProps.js +19 -24
- package/es/ProEditTable/utils/index.js +154 -235
- package/es/ProEditTable/utils/tools.js +149 -286
- package/es/ProEditTable/utils/transform.js +25 -30
- package/es/ProEditTable/utils/useEditTableError.js +30 -43
- package/es/ProEditTable/utils/useShouldUpdateForTable.js +42 -72
- package/es/ProEditTable/utils/validateAll.js +87 -154
- package/es/ProEnum/components/Group.js +38 -30
- package/es/ProEnum/components/Tag.js +22 -26
- package/es/ProEnum/hooks/useEnum.js +48 -116
- package/es/ProEnum/hooks/useEnumRequest.js +182 -212
- package/es/ProEnum/hooks/useFrequentEnumRequest.js +40 -48
- package/es/ProEnum/index.js +162 -172
- package/es/ProEnum/propsType.js +0 -1
- package/es/ProEnum/utils/eventCenter.js +10 -12
- package/es/ProEnum/utils/frequentEnum.js +35 -92
- package/es/ProEnum/utils/getEnum.js +32 -90
- package/es/ProEnum/utils/getEnumLabel.js +44 -49
- package/es/ProEnum/utils/index.js +93 -207
- package/es/ProForm/components/Container.js +13 -28
- package/es/ProForm/components/FormFooter/index.js +36 -44
- package/es/ProForm/components/FormFooter/propsType.js +0 -1
- package/es/ProForm/components/base/Checkbox/index.js +32 -59
- package/es/ProForm/components/base/DatePicker/index.js +49 -71
- package/es/ProForm/components/base/Input/index.js +63 -97
- package/es/ProForm/components/base/Input/propsType.js +0 -1
- package/es/ProForm/components/base/InputNumber/index.js +118 -172
- package/es/ProForm/components/base/Radio/index.js +39 -52
- package/es/ProForm/components/base/RangePicker/index.js +109 -127
- package/es/ProForm/components/base/RangePicker/useDateRange.js +20 -17
- package/es/ProForm/components/base/Select/index.js +63 -89
- package/es/ProForm/components/base/Switch/index.js +27 -35
- package/es/ProForm/components/base/SwitchCheckbox/index.js +36 -54
- package/es/ProForm/components/base/TextArea/index.js +30 -41
- package/es/ProForm/components/base/TimePicker/index.js +27 -37
- package/es/ProForm/components/combination/Container/index.js +37 -47
- package/es/ProForm/components/combination/Container/propsType.js +0 -1
- package/es/ProForm/components/combination/FormList/components/ActionButton.js +165 -237
- package/es/ProForm/components/combination/FormList/components/BlockFields.js +98 -102
- package/es/ProForm/components/combination/FormList/components/Empty.js +28 -55
- package/es/ProForm/components/combination/FormList/components/LineFields.js +57 -54
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +61 -109
- package/es/ProForm/components/combination/FormList/index.js +151 -161
- package/es/ProForm/components/combination/FormList/propsType.js +0 -1
- package/es/ProForm/components/combination/FormList/style/index.less +6 -0
- package/es/ProForm/components/combination/FormList/utils.js +22 -38
- package/es/ProForm/components/combination/Group/component/AddonWrapper/index.js +12 -28
- package/es/ProForm/components/combination/Group/component/ComRender.js +50 -111
- package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +106 -213
- package/es/ProForm/components/combination/Group/hooks/index.js +69 -129
- package/es/ProForm/components/combination/Group/index.js +87 -126
- package/es/ProForm/components/combination/Group/propsType.js +0 -1
- package/es/ProForm/components/combination/Group/utils/index.js +124 -239
- package/es/ProForm/components/combination/ProCascader/index.js +156 -199
- package/es/ProForm/components/combination/ProCascader/propsType.js +0 -1
- package/es/ProForm/components/combination/ProCascader/utils/index.js +12 -21
- package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +72 -70
- package/es/ProForm/components/combination/ProModalSelect/index.js +309 -347
- package/es/ProForm/components/combination/ProModalSelect/propsType.js +0 -1
- package/es/ProForm/components/combination/ProModalSelect/utils/index.js +32 -39
- package/es/ProForm/components/combination/ProNumberRange/index.js +100 -156
- package/es/ProForm/components/combination/ProNumberRange/propsType.js +0 -1
- package/es/ProForm/components/combination/ProRangeLimit/index.js +104 -115
- package/es/ProForm/components/combination/ProRangeLimit/propsType.js +0 -1
- package/es/ProForm/components/combination/ProTimeLimit/hooks/useControlled.js +16 -16
- package/es/ProForm/components/combination/ProTimeLimit/index.js +75 -109
- package/es/ProForm/components/index.js +56 -34
- package/es/ProForm/components/render/ChangedWrapper.js +85 -94
- package/es/ProForm/components/render/ConfirmWrapper.js +27 -39
- package/es/ProForm/components/render/CustomComponentViewWrapper.js +65 -82
- package/es/ProForm/components/render/Render.js +223 -329
- package/es/ProForm/components/render/RenderFields.js +76 -113
- package/es/ProForm/components/render/propsType.js +0 -1
- package/es/ProForm/hooks/useControlled.js +8 -10
- package/es/ProForm/hooks/useDeepCompareMemo.js +11 -11
- package/es/ProForm/hooks/useFieldProps.js +8 -4
- package/es/ProForm/hooks/useForm.js +50 -110
- package/es/ProForm/hooks/useRules.js +17 -33
- package/es/ProForm/hooks/useShouldUpdate.js +77 -152
- package/es/ProForm/hooks/useWatch.js +62 -134
- package/es/ProForm/index.js +157 -194
- package/es/ProForm/propsType.js +15 -7
- package/es/ProForm/utils/buildFormItemProps.js +51 -58
- package/es/ProForm/utils/diffOriginal.js +43 -73
- package/es/ProForm/utils/getDefaultProps.js +18 -24
- package/es/ProForm/utils/index.js +160 -235
- package/es/ProForm/utils/processDependencies.js +21 -60
- package/es/ProForm/utils/reactiveValues.js +20 -34
- package/es/ProForm/utils/rulesCreator.js +42 -40
- package/es/ProForm/utils/transformNames.js +10 -13
- package/es/ProForm/utils/transformValue.js +16 -29
- package/es/ProForm/utils/valueType.js +96 -178
- package/es/ProIcon/config/index.js +340 -274
- package/es/ProIcon/index.js +135 -209
- package/es/ProIcon/propsTypes.js +0 -1
- package/es/ProIcon/utils/index.js +24 -39
- package/es/ProLayout/components/Layout/Header/index.js +108 -141
- package/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +134 -190
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +113 -139
- package/es/ProLayout/components/Layout/Menu/OpenMenu/propsType.js +0 -1
- package/es/ProLayout/components/Layout/Menu/SideMenu/index.js +23 -31
- package/es/ProLayout/components/Layout/Menu/index.js +92 -89
- package/es/ProLayout/components/Layout/Notice/index.js +13 -27
- package/es/ProLayout/components/Layout/index.js +8 -3
- package/es/ProLayout/components/ProCollapse/PropTypes.js +0 -1
- package/es/ProLayout/components/ProCollapse/index.js +89 -111
- package/es/ProLayout/components/ProFooter/PropTypes.js +0 -1
- package/es/ProLayout/components/ProFooter/index.js +27 -24
- package/es/ProLayout/components/ProHeader/PropTypes.js +0 -1
- package/es/ProLayout/components/ProHeader/components/Copy/index.js +23 -21
- package/es/ProLayout/components/ProHeader/components/Describe/index.js +67 -84
- package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.js +18 -21
- package/es/ProLayout/components/ProHeader/components/ProBackBtn/propsType.js +0 -1
- package/es/ProLayout/components/ProHeader/components/index.js +6 -2
- package/es/ProLayout/components/ProHeader/index.js +216 -356
- package/es/ProLayout/components/ProHeader/utils/index.js +19 -26
- package/es/ProLayout/components/TabsManager/components/TabContextMenu.js +92 -85
- package/es/ProLayout/components/TabsManager/components/TabItem.js +53 -63
- package/es/ProLayout/components/TabsManager/components/TabsContext.js +5 -5
- package/es/ProLayout/components/TabsManager/components/TabsHeader.js +42 -52
- package/es/ProLayout/components/TabsManager/hooks/useActiveTab.js +8 -9
- package/es/ProLayout/components/TabsManager/hooks/useIframeRoute.js +19 -32
- package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +6 -20
- package/es/ProLayout/components/TabsManager/hooks/useTabsCache.js +25 -42
- package/es/ProLayout/components/TabsManager/hooks/useTabsState.js +320 -350
- package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.d.ts +19 -0
- package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.js +332 -0
- package/es/ProLayout/components/TabsManager/index.js +407 -351
- package/es/ProLayout/components/TabsManager/propTypes.d.ts +4 -0
- package/es/ProLayout/components/TabsManager/propTypes.js +7 -15
- package/es/ProLayout/components/TabsManager/style/index.less +1 -1
- package/es/ProLayout/components/TabsManager/utils/historyObserver.d.ts +7 -0
- package/es/ProLayout/components/TabsManager/utils/historyObserver.js +65 -0
- package/es/ProLayout/components/TabsManager/utils/index.d.ts +15 -2
- package/es/ProLayout/components/TabsManager/utils/index.js +156 -159
- package/es/ProLayout/components/index.js +8 -3
- package/es/ProLayout/index.js +173 -228
- package/es/ProLayout/propTypes.d.ts +28 -1
- package/es/ProLayout/propTypes.js +12 -52
- package/es/ProLayout/utils/index.js +48 -128
- package/es/ProSelect/components/AdaptiveTooltip.js +26 -25
- package/es/ProSelect/index.js +187 -223
- package/es/ProSelect/propsType.js +0 -1
- package/es/ProSelect/style/index.less +13 -0
- package/es/ProSelect/utils/index.js +100 -146
- package/es/ProStep/components/Anchor/index.js +71 -82
- package/es/ProStep/components/Item/index.js +49 -56
- package/es/ProStep/components/LazyLoad/index.js +23 -29
- package/es/ProStep/components/Listener/index.js +20 -33
- package/es/ProStep/components/Step/index.js +31 -38
- package/es/ProStep/constants.js +4 -1
- package/es/ProStep/index.js +166 -153
- package/es/ProStep/propsType.js +0 -1
- package/es/ProStep/style/index.less +1 -1
- package/es/ProStep/utils/index.js +29 -55
- package/es/ProStepTab/index.js +83 -138
- package/es/ProStepTab/propsType.js +0 -1
- package/es/ProTable/components/EditableCell/EditIcon.js +10 -14
- package/es/ProTable/components/EditableCell/index.js +37 -71
- package/es/ProTable/components/EditableCell/propsType.js +0 -1
- package/es/ProTable/components/FormatColumn/index.js +209 -340
- package/es/ProTable/components/FormatColumn/propsType.js +0 -1
- package/es/ProTable/components/RcTable/components/BaseTable/index.js +35 -39
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +80 -107
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index.js +54 -48
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/propsType.js +0 -1
- package/es/ProTable/components/RcTable/components/DraggableTable/index.js +47 -54
- package/es/ProTable/components/RcTable/index.js +6 -4
- package/es/ProTable/components/RenderColumn/index.js +158 -186
- package/es/ProTable/components/RenderEmptyText/index.js +12 -21
- package/es/ProTable/components/RenderFooter/index.js +15 -15
- package/es/ProTable/components/RenderSummary/index.js +33 -50
- package/es/ProTable/components/RenderTableHeader/index.js +44 -46
- package/es/ProTable/components/RenderTabs/index.js +47 -51
- package/es/ProTable/components/TableResizable/index.js +56 -72
- package/es/ProTable/components/TooltipTitle/index.js +13 -21
- package/es/ProTable/components/index.js +16 -36
- package/es/ProTable/hooks/useAntdTable.js +191 -224
- package/es/ProTable/index.js +232 -249
- package/es/ProTable/propsType.js +0 -1
- package/es/ProTable/utils/columnStorage.js +63 -88
- package/es/ProTable/utils/index.js +57 -90
- package/es/ProTabs/components/Card/index.js +20 -48
- package/es/ProTabs/components/index.js +4 -1
- package/es/ProTabs/index.js +41 -58
- package/es/ProTabs/propType.js +0 -1
- package/es/ProThemeTools/component/ProTools/index.js +106 -158
- package/es/ProThemeTools/component/index.js +4 -1
- package/es/ProThemeTools/context/ThemeContext.js +67 -146
- package/es/ProThemeTools/index.js +103 -156
- package/es/ProThemeTools/propsType.js +0 -1
- package/es/ProThemeTools/utils/index.js +60 -109
- package/es/ProTooltip/index.js +132 -168
- package/es/ProTooltip/propsType.js +0 -1
- package/es/ProTree/components/AdaptiveTooltip.js +15 -17
- package/es/ProTree/components/CloseIcon.js +18 -26
- package/es/ProTree/components/List.js +28 -47
- package/es/ProTree/components/ProTree.js +152 -211
- package/es/ProTree/components/ProTreeSelect/index.js +255 -459
- package/es/ProTree/components/ProTreeSelect/propsType.js +0 -1
- package/es/ProTree/components/SearchTitle.js +23 -42
- package/es/ProTree/components/Tree.js +147 -195
- package/es/ProTree/components/index.js +10 -5
- package/es/ProTree/index.js +12 -16
- package/es/ProTree/propsType.js +0 -1
- package/es/ProTree/utils.js +46 -118
- package/es/ProTreeModal/components/Cascader.js +56 -64
- package/es/ProTreeModal/components/CloseIcon.js +18 -26
- package/es/ProTreeModal/components/List.js +114 -180
- package/es/ProTreeModal/components/SearchTitle.js +15 -18
- package/es/ProTreeModal/components/SortableItem.js +29 -58
- package/es/ProTreeModal/components/Tree.js +99 -113
- package/es/ProTreeModal/components/Trigger.js +87 -121
- package/es/ProTreeModal/components/index.js +14 -6
- package/es/ProTreeModal/index.js +397 -438
- package/es/ProTreeModal/propsType.js +0 -1
- package/es/ProTreeModal/utils.js +52 -95
- package/es/ProUpload/components/ButtonRender.js +44 -54
- package/es/ProUpload/components/DragRender.js +94 -148
- package/es/ProUpload/components/DraggableUploadListItem.js +12 -25
- package/es/ProUpload/components/Example.js +27 -31
- package/es/ProUpload/components/FileItem.js +69 -163
- package/es/ProUpload/components/ImageRender.js +134 -170
- package/es/ProUpload/index.js +68 -100
- package/es/ProUpload/propsType.js +0 -1
- package/es/ProUpload/uitls.js +8 -4
- package/es/ProUtils/utils/index.js +17 -13
- package/es/ProViewer/index.js +154 -175
- package/es/ProViewer/propsType.js +0 -5
- package/es/ProWaterMark/index.js +9 -16
- package/es/ProWaterMark/propsType.js +0 -1
- package/es/hooks/useDraggableRow.js +25 -53
- package/es/index.js +57 -77
- package/es/locale/en_US.js +153 -142
- package/es/locale/index.js +23 -36
- package/es/locale/zh_CN.js +145 -142
- package/es/tokens.js +84 -83
- package/es/utils/index.js +24 -51
- package/package.json +4 -2
- package/es/ProConfigProvider/demo/locale.js +0 -58
|
@@ -1,372 +1,428 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
196
|
-
|
|
84
|
+
name: params.name || matchedMenu.name,
|
|
85
|
+
extra: params.extra ?? matchedMenu.extra
|
|
197
86
|
} : {
|
|
198
87
|
id: Date.now(),
|
|
199
|
-
code,
|
|
200
|
-
name:
|
|
201
|
-
url: `/${code}`,
|
|
202
|
-
|
|
203
|
-
pinned: true
|
|
88
|
+
code: params.code,
|
|
89
|
+
name: params.name,
|
|
90
|
+
url: `/${params.code}`,
|
|
91
|
+
extra: params.extra
|
|
204
92
|
};
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
|
|
282
|
-
|
|
239
|
+
activeTabInfo: state.tabsList.find((tab) => tab.id === state.activeKey),
|
|
240
|
+
activeComponent: state.activeComponent
|
|
283
241
|
}),
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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
|
+
};
|