@zat-design/sisyphus-react 3.13.24-beta.1 → 3.14.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +8 -4
  2. package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +39 -28
  3. package/es/ProLayout/components/TabsManager/components/TabContextMenu.d.ts +7 -0
  4. package/es/ProLayout/components/TabsManager/components/TabContextMenu.js +96 -0
  5. package/es/ProLayout/components/TabsManager/components/TabItem.d.ts +26 -0
  6. package/es/ProLayout/components/TabsManager/components/TabItem.js +61 -0
  7. package/es/ProLayout/components/TabsManager/components/TabsContext.d.ts +6 -0
  8. package/es/ProLayout/components/TabsManager/components/TabsContext.js +5 -0
  9. package/es/ProLayout/components/TabsManager/hooks/useActiveTab.d.ts +6 -0
  10. package/es/ProLayout/components/TabsManager/hooks/useActiveTab.js +14 -0
  11. package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.d.ts +18 -0
  12. package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +26 -0
  13. package/es/ProLayout/components/TabsManager/hooks/useTabsCache.d.ts +31 -0
  14. package/es/ProLayout/components/TabsManager/hooks/useTabsCache.js +93 -0
  15. package/es/ProLayout/components/TabsManager/hooks/useTabsState.d.ts +5 -0
  16. package/es/ProLayout/components/TabsManager/hooks/useTabsState.js +357 -0
  17. package/es/ProLayout/components/TabsManager/index.d.ts +8 -0
  18. package/es/ProLayout/components/TabsManager/index.js +171 -0
  19. package/es/ProLayout/components/TabsManager/propTypes.d.ts +74 -0
  20. package/es/ProLayout/components/TabsManager/propTypes.js +16 -0
  21. package/es/ProLayout/components/TabsManager/style/index.less +179 -0
  22. package/es/ProLayout/components/TabsManager/utils/index.d.ts +38 -0
  23. package/es/ProLayout/components/TabsManager/utils/index.js +106 -0
  24. package/es/ProLayout/index.d.ts +10 -4
  25. package/es/ProLayout/index.js +82 -9
  26. package/es/ProLayout/propTypes.d.ts +139 -1
  27. package/es/ProLayout/propTypes.js +37 -1
  28. package/es/ProLayout/utils/index.js +8 -5
  29. package/es/index.d.ts +2 -1
  30. package/es/index.js +1 -1
  31. package/lib/ProLayout/components/Layout/Menu/FoldMenu/index.js +8 -4
  32. package/lib/ProLayout/components/Layout/Menu/OpenMenu/index.js +39 -28
  33. package/lib/ProLayout/components/TabsManager/components/TabContextMenu.d.ts +7 -0
  34. package/lib/ProLayout/components/TabsManager/components/TabContextMenu.js +103 -0
  35. package/lib/ProLayout/components/TabsManager/components/TabItem.d.ts +26 -0
  36. package/lib/ProLayout/components/TabsManager/components/TabItem.js +67 -0
  37. package/lib/ProLayout/components/TabsManager/components/TabsContext.d.ts +6 -0
  38. package/lib/ProLayout/components/TabsManager/components/TabsContext.js +11 -0
  39. package/lib/ProLayout/components/TabsManager/hooks/useActiveTab.d.ts +6 -0
  40. package/lib/ProLayout/components/TabsManager/hooks/useActiveTab.js +20 -0
  41. package/lib/ProLayout/components/TabsManager/hooks/useProLayoutTabs.d.ts +18 -0
  42. package/lib/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +31 -0
  43. package/lib/ProLayout/components/TabsManager/hooks/useTabsCache.d.ts +31 -0
  44. package/lib/ProLayout/components/TabsManager/hooks/useTabsCache.js +101 -0
  45. package/lib/ProLayout/components/TabsManager/hooks/useTabsState.d.ts +5 -0
  46. package/lib/ProLayout/components/TabsManager/hooks/useTabsState.js +364 -0
  47. package/lib/ProLayout/components/TabsManager/index.d.ts +8 -0
  48. package/lib/ProLayout/components/TabsManager/index.js +175 -0
  49. package/lib/ProLayout/components/TabsManager/propTypes.d.ts +74 -0
  50. package/lib/ProLayout/components/TabsManager/propTypes.js +22 -0
  51. package/lib/ProLayout/components/TabsManager/style/index.less +179 -0
  52. package/lib/ProLayout/components/TabsManager/utils/index.d.ts +38 -0
  53. package/lib/ProLayout/components/TabsManager/utils/index.js +119 -0
  54. package/lib/ProLayout/index.d.ts +10 -4
  55. package/lib/ProLayout/index.js +94 -8
  56. package/lib/ProLayout/propTypes.d.ts +139 -1
  57. package/lib/ProLayout/propTypes.js +40 -1
  58. package/lib/ProLayout/utils/index.js +8 -5
  59. package/lib/index.d.ts +2 -1
  60. package/lib/index.js +9 -2
  61. package/package.json +1 -1
@@ -47,8 +47,9 @@ export var transformMenu = (menuData, pathPrefix) => {
47
47
  if (!Array.isArray(menuDeepItem) || !menuDeepItem.length) {
48
48
  return [];
49
49
  }
50
- menuDeepItem.forEach((item, index) => {
50
+ var _loop = function _loop() {
51
51
  var _item$keyUrlPath, _item$keyIdPath, _item$children;
52
+ var item = menuDeepItem[i];
52
53
  item.code = item.code || item.id;
53
54
  item.url = `${pathPrefix}${item.url}`;
54
55
  item.redirectUrl = item !== null && item !== void 0 && item.redirectUrl ? `${pathPrefix}${item.redirectUrl}` : '';
@@ -68,9 +69,8 @@ export var transformMenu = (menuData, pathPrefix) => {
68
69
  item.keyIdPath = [item.id];
69
70
  }
70
71
  if (!['PAGE', 'MENU'].includes(item.type)) {
71
- menuDeepItem.splice(index, 1);
72
- }
73
- if (Array.isArray(item === null || item === void 0 ? void 0 : item.children) && item !== null && item !== void 0 && (_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) {
72
+ menuDeepItem.splice(i, 1);
73
+ } else if (Array.isArray(item === null || item === void 0 ? void 0 : item.children) && item !== null && item !== void 0 && (_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) {
74
74
  // 给children注入keyUrlPath,keyIdPath
75
75
  item.children.forEach(childrenItem => {
76
76
  childrenItem.keyUrlPath = [...item.keyUrlPath];
@@ -78,7 +78,10 @@ export var transformMenu = (menuData, pathPrefix) => {
78
78
  });
79
79
  menuDeep(item.children);
80
80
  }
81
- });
81
+ };
82
+ for (var i = menuDeepItem.length - 1; i >= 0; i -= 1) {
83
+ _loop();
84
+ }
82
85
  };
83
86
  menuDeep(data);
84
87
  return data;
package/es/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="typings" />
2
- export { default as ProLayout } from './ProLayout';
2
+ export { default as ProLayout, useProLayoutTabs } from './ProLayout';
3
3
  export { default as ProStep } from './ProStep';
4
4
  export { default as ProTabs } from './ProTabs';
5
5
  export { default as ProTable } from './ProTable';
@@ -33,6 +33,7 @@ export type { ProTableType, ProTableColumnType, ProTableSummaryType, ProTableUse
33
33
  export type { ProUploadType, ProUploadProps } from './ProUpload/propsType';
34
34
  export type { ProTabsType, ProTabsItemType, ProTabsProps, ProTabsItemsProps } from './ProTabs/propType';
35
35
  export type { BreadcrumbColumnType, SubDescribeColumnType, DescribeColumnType, ProHeaderType, ProHeaderProps, BreadcrumbColumnsProps, SubDescribeColumnsProps, DescribeColumnsProps } from './ProLayout/components/ProHeader/PropTypes';
36
+ export type { ProLayoutTabsInstance, AddTabParams, AddTabOptions } from './ProLayout/propTypes';
36
37
  export type { ProTooltipType, ProTooltipProps } from './ProTooltip/propsType';
37
38
  export type { ProIconType, ProIconProps } from './ProIcon/propsTypes';
38
39
  export type { ProTreeType, ProTreeSelectType, ProTreeProps, PropTreeSelectProps } from './ProTree/propsType';
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference path="../typings.d.ts" />;
2
2
 
3
3
  // 布局
4
- export { default as ProLayout } from "./ProLayout";
4
+ export { default as ProLayout, useProLayoutTabs } from "./ProLayout";
5
5
  export { default as ProStep } from "./ProStep";
6
6
  export { default as ProTabs } from "./ProTabs";
7
7
 
@@ -34,9 +34,12 @@ var FoldMenu = props => {
34
34
  'pro-layout-menu-tooltip-has-notice': notice,
35
35
  'pro-layout-menu-tooltip-nav-open': collapsed
36
36
  });
37
- var _useContext = (0, _react.useContext)(_index2.LayoutContext),
38
- selectedPath = _useContext.selectedPath,
39
- onSelected = _useContext.onSelected;
37
+ var _ref = (0, _react.useContext)(_index2.LayoutContext) || {
38
+ selectedPath: '',
39
+ onSelected: () => {}
40
+ },
41
+ selectedPath = _ref.selectedPath,
42
+ onSelected = _ref.onSelected;
40
43
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
41
44
  className: "pro-layout-menu-fold",
42
45
  style: (0, _objectSpread2.default)({}, style),
@@ -60,11 +63,12 @@ var FoldMenu = props => {
60
63
  return null;
61
64
  }
62
65
  var selectedMenu = (0, _utils.getUrlParams)('activeMenu');
66
+ var pathToMatch = selectedPath || selectedMenu || window.location.pathname;
63
67
 
64
68
  // 取第一级
65
69
  var currentKeyIdPath = (0, _utils.getPathNameKey)({
66
70
  menus,
67
- pathName: selectedMenu || selectedPath || window.location.pathname // 优先匹配URL中定位菜单
71
+ pathName: pathToMatch // 优先匹配上下文路径
68
72
  }) || [];
69
73
  var cls = (0, _classnames.default)({
70
74
  active: currentKeyIdPath.includes(id)
@@ -16,6 +16,7 @@ var _reactRouterDom = require("react-router-dom");
16
16
  var _lodash = require("lodash");
17
17
  var _index = require("../../../../index");
18
18
  var _utils = require("../../../../utils");
19
+ var _utils2 = require("../../../TabsManager/utils");
19
20
  var _index2 = require("../../index");
20
21
  var _jsxRuntime = require("react/jsx-runtime");
21
22
  var Link = _reactRouterDom.Link;
@@ -44,16 +45,19 @@ var OpenMenu = props => {
44
45
  router = _useSetState2$.router,
45
46
  setState = _useSetState2[1];
46
47
  var query = new URLSearchParams(window.location.search);
47
- var _useContext = (0, _react.useContext)(_index.LayoutContext),
48
- onSelected = _useContext.onSelected,
49
- target = _useContext.target;
48
+ var layoutContext = (0, _react.useContext)(_index.LayoutContext);
49
+ var layoutSelectedPath = layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.selectedPath;
50
+ var layoutOnSelected = layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.onSelected;
51
+ var layoutTarget = layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.target;
50
52
  var cls = (0, _classnames.default)({
51
53
  'pro-layout-open-menu': true,
52
54
  [`${className}`]: className
53
55
  });
54
56
 
55
- // 默认激活菜单优先取activeMenu中,默认取pathName进行匹配
56
- var selectKeyIdPath = ((_getIdsByPathName = (0, _utils.getIdsByPathName)(menus, query.get('activeMenu'))) === null || _getIdsByPathName === void 0 ? void 0 : _getIdsByPathName.map(item => String(item))) || [];
57
+ // 默认激活菜单优先取selectedPath或activeMenu,默认取pathName进行匹配
58
+ // 特殊处理:如果layoutSelectedPath是'##EMPTY##',表示有意清空选中状态
59
+ var preferredPath = query.get('activeMenu') || (layoutSelectedPath === '##EMPTY##' ? null : layoutSelectedPath) || window.location.pathname;
60
+ var selectKeyIdPath = preferredPath ? ((_getIdsByPathName = (0, _utils.getIdsByPathName)(menus, preferredPath)) === null || _getIdsByPathName === void 0 ? void 0 : _getIdsByPathName.map(item => String(item))) || [] : [];
57
61
  var itemsTransform = (0, _react.useMemo)(() => {
58
62
  var result = (0, _lodash.cloneDeep)(menus);
59
63
  if (!Array.isArray(result) || !result.length) {
@@ -110,11 +114,14 @@ var OpenMenu = props => {
110
114
  return result;
111
115
  }, [dataSource]);
112
116
  (0, _ahooks.useDeepCompareEffect)(() => {
113
- if (Array.isArray(selectKeyIdPath) && selectKeyIdPath.length) {
114
- setState({
115
- selectedKeys: selectKeyIdPath,
116
- openKeys: selectKeyIdPath.slice(0, 2)
117
- });
117
+ if (Array.isArray(selectKeyIdPath)) {
118
+ var newState = {
119
+ selectedKeys: selectKeyIdPath
120
+ };
121
+ if (selectKeyIdPath.length) {
122
+ newState.openKeys = selectKeyIdPath.slice(0, 2);
123
+ }
124
+ setState(newState);
118
125
  }
119
126
  }, [menus, selectKeyIdPath]);
120
127
 
@@ -146,7 +153,6 @@ var OpenMenu = props => {
146
153
  });
147
154
  },
148
155
  onClick: _ref2 => {
149
- var _item$props, _item$props2;
150
156
  var item = _ref2.item,
151
157
  keyPath = _ref2.keyPath,
152
158
  key = _ref2.key,
@@ -168,23 +174,28 @@ var OpenMenu = props => {
168
174
  keyPath: menuKeyPath
169
175
  });
170
176
  }
171
- setState({
172
- selectedKeys: keyPath,
173
- router: item === null || item === void 0 || (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.router
174
- });
175
- onSelected({
176
- selectedPath: item === null || item === void 0 || (_item$props2 = item.props) === null || _item$props2 === void 0 ? void 0 : _item$props2.router
177
- });
178
- if (target) {
179
- var _item$props3;
180
- window.open(item === null || item === void 0 || (_item$props3 = item.props) === null || _item$props3 === void 0 ? void 0 : _item$props3.router, target);
181
- } else {
182
- setTimeout(() => {
183
- // 路由变更,且不再demo文档中
184
- if (!window.location.href.includes('~demos/prolayout')) {
185
- linkRef.current.click();
186
- }
187
- }, 100);
177
+
178
+ // 只有最后一级菜单(叶子节点)才设置选中状态和路径
179
+ if (menuItem && (0, _utils2.isLeafMenuItem)(menuItem)) {
180
+ var _item$props, _item$props2;
181
+ setState({
182
+ selectedKeys: keyPath,
183
+ router: item === null || item === void 0 || (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.router
184
+ });
185
+ layoutOnSelected === null || layoutOnSelected === void 0 || layoutOnSelected({
186
+ selectedPath: item === null || item === void 0 || (_item$props2 = item.props) === null || _item$props2 === void 0 ? void 0 : _item$props2.router
187
+ });
188
+ if (layoutTarget) {
189
+ var _item$props3;
190
+ window.open(item === null || item === void 0 || (_item$props3 = item.props) === null || _item$props3 === void 0 ? void 0 : _item$props3.router, layoutTarget);
191
+ } else {
192
+ setTimeout(() => {
193
+ // 路由变更,且不再demo文档中
194
+ if (!window.location.href.includes('~demos/prolayout')) {
195
+ linkRef.current.click();
196
+ }
197
+ }, 100);
198
+ }
188
199
  }
189
200
  },
190
201
  style: {
@@ -0,0 +1,7 @@
1
+ import { TabContextMenuProps } from '../propTypes';
2
+ /**
3
+ * 右键菜单组件 - 兼容Antd 4.x和5.x
4
+ */
5
+ declare function TabContextMenu({ tabId, children, closable, onClose, onCloseOthers, onCloseRight, onCloseAll, menuItems: customMenuItems, tabMenuClick, tab, tabs, }: TabContextMenuProps): import("react/jsx-runtime").JSX.Element;
6
+ export default TabContextMenu;
7
+ export { TabContextMenu };
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.TabContextMenu = TabContextMenu;
8
+ exports.default = void 0;
9
+ require("antd/es/dropdown/style");
10
+ var _dropdown = _interopRequireDefault(require("antd/es/dropdown"));
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+ var _react = require("react");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ /**
15
+ * 右键菜单组件 - 兼容Antd 4.x和5.x
16
+ */
17
+ function TabContextMenu(_ref) {
18
+ var tabId = _ref.tabId,
19
+ children = _ref.children,
20
+ _ref$closable = _ref.closable,
21
+ closable = _ref$closable === void 0 ? true : _ref$closable,
22
+ onClose = _ref.onClose,
23
+ onCloseOthers = _ref.onCloseOthers,
24
+ onCloseRight = _ref.onCloseRight,
25
+ onCloseAll = _ref.onCloseAll,
26
+ customMenuItems = _ref.menuItems,
27
+ tabMenuClick = _ref.tabMenuClick,
28
+ tab = _ref.tab,
29
+ _ref$tabs = _ref.tabs,
30
+ tabs = _ref$tabs === void 0 ? [] : _ref$tabs;
31
+ var _useState = (0, _react.useState)(false),
32
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
33
+ visible = _useState2[0],
34
+ setVisible = _useState2[1];
35
+ var handleMenuClick = (0, _react.useCallback)(key => {
36
+ setVisible(false);
37
+
38
+ // 优先调用自定义回调
39
+ if (tabMenuClick && tab) {
40
+ tabMenuClick({
41
+ key,
42
+ tab,
43
+ tabs
44
+ });
45
+ }
46
+
47
+ // 处理默认菜单项
48
+ switch (key) {
49
+ case 'close':
50
+ if (!closable) {
51
+ return;
52
+ }
53
+ onClose(tabId);
54
+ break;
55
+ case 'closeOthers':
56
+ onCloseOthers(tabId);
57
+ break;
58
+ case 'closeRight':
59
+ onCloseRight(tabId);
60
+ break;
61
+ case 'closeAll':
62
+ onCloseAll();
63
+ break;
64
+ }
65
+ }, [tabId, closable, onClose, onCloseOthers, onCloseRight, onCloseAll, tabMenuClick, tab, tabs]);
66
+
67
+ // 默认右键菜单配置 - 统一使用items方式(antd 4.20+都支持)
68
+ var defaultMenuItems = [{
69
+ key: 'close',
70
+ label: '关闭',
71
+ disabled: !closable
72
+ }, {
73
+ key: 'closeOthers',
74
+ label: '关闭其他'
75
+ }, {
76
+ key: 'closeRight',
77
+ label: '关闭右侧标签页'
78
+ }, {
79
+ key: 'closeAll',
80
+ label: '关闭全部'
81
+ }];
82
+
83
+ // 合并自定义菜单项和默认菜单项
84
+ // 如果提供了自定义菜单项,则追加到默认菜单项后面;否则使用默认菜单项
85
+ var menuItems = customMenuItems && customMenuItems.length > 0 ? [...defaultMenuItems, {
86
+ type: 'divider'
87
+ }, ...customMenuItems] : defaultMenuItems;
88
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_dropdown.default, {
89
+ menu: {
90
+ items: menuItems,
91
+ onClick: _ref2 => {
92
+ var key = _ref2.key;
93
+ return handleMenuClick(key);
94
+ }
95
+ },
96
+ trigger: ['contextMenu'],
97
+ open: visible,
98
+ onOpenChange: setVisible,
99
+ placement: "bottomLeft",
100
+ children: children
101
+ });
102
+ }
103
+ var _default = exports.default = TabContextMenu;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { TabItem } from '../../../propTypes';
3
+ interface TabItemComponentProps {
4
+ tab: TabItem;
5
+ active: boolean;
6
+ onClick: () => void;
7
+ onClose: () => void;
8
+ onCloseOthers: () => void;
9
+ onCloseRight: () => void;
10
+ onCloseAll: () => void;
11
+ /** 所有标签页列表 */
12
+ tabsList?: TabItem[];
13
+ /** 自定义菜单项 */
14
+ menuItems?: import('antd').MenuProps['items'];
15
+ /** 自定义菜单项点击回调 */
16
+ tabMenuClick?: (params: {
17
+ key: string;
18
+ tab: TabItem;
19
+ tabs: TabItem[];
20
+ }) => void;
21
+ }
22
+ /**
23
+ * 单个标签页组件
24
+ */
25
+ declare const TabItemComponent: React.FC<TabItemComponentProps>;
26
+ export { TabItemComponent };
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.TabItemComponent = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _icons = require("@ant-design/icons");
10
+ var _TabContextMenu = require("./TabContextMenu");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ /**
13
+ * 单个标签页组件
14
+ */
15
+ var TabItemComponent = _ref => {
16
+ var tab = _ref.tab,
17
+ active = _ref.active,
18
+ onClick = _ref.onClick,
19
+ _onClose = _ref.onClose,
20
+ _onCloseOthers = _ref.onCloseOthers,
21
+ _onCloseRight = _ref.onCloseRight,
22
+ onCloseAll = _ref.onCloseAll,
23
+ _ref$tabsList = _ref.tabsList,
24
+ tabsList = _ref$tabsList === void 0 ? [] : _ref$tabsList,
25
+ menuItems = _ref.menuItems,
26
+ tabMenuClick = _ref.tabMenuClick;
27
+ var handleCloseClick = e => {
28
+ e.stopPropagation();
29
+ _onClose();
30
+ };
31
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TabContextMenu.TabContextMenu, {
32
+ tabId: tab.id,
33
+ closable: tab.closable,
34
+ onClose: () => _onClose(),
35
+ onCloseOthers: () => _onCloseOthers(),
36
+ onCloseRight: () => _onCloseRight(),
37
+ onCloseAll: onCloseAll,
38
+ tab: tab,
39
+ tabs: tabsList,
40
+ menuItems: menuItems,
41
+ tabMenuClick: tabMenuClick,
42
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
43
+ className: `pro-layout-tab-item ${active ? 'active' : ''} ${tab.closable ? 'closable' : ''}`,
44
+ onClick: onClick,
45
+ "data-testid": `tab-${tab.id}`,
46
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
47
+ className: "pro-layout-tab-content",
48
+ children: [tab.icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
49
+ className: "pro-layout-tab-icon",
50
+ children: typeof tab.icon === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
51
+ className: `iconfont ${tab.icon}`
52
+ }) : tab.icon
53
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
54
+ className: "pro-layout-tab-title",
55
+ title: tab.title,
56
+ children: tab.title
57
+ }), tab.closable && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
58
+ className: "pro-layout-tab-close",
59
+ onClick: handleCloseClick,
60
+ "data-testid": `tab-close-${tab.id}`,
61
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CloseOutlined, {})
62
+ })]
63
+ })
64
+ })
65
+ });
66
+ };
67
+ exports.TabItemComponent = TabItemComponent;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { ProLayoutTabsInstance } from '../../../propTypes';
3
+ /**
4
+ * 标签页实例 Context,用于在 ProLayout children 中访问标签页 API
5
+ */
6
+ export declare const TabsContext: import("react").Context<ProLayoutTabsInstance>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TabsContext = void 0;
7
+ var _react = require("react");
8
+ /**
9
+ * 标签页实例 Context,用于在 ProLayout children 中访问标签页 API
10
+ */
11
+ var TabsContext = exports.TabsContext = /*#__PURE__*/(0, _react.createContext)(null);
@@ -0,0 +1,6 @@
1
+ import { TabItem } from '../../../propTypes';
2
+ /**
3
+ * 获取当前激活的 Tab 信息 Hook
4
+ * @returns 当前激活的 Tab 对象,如果没有激活则返回 undefined
5
+ */
6
+ export declare const useActiveTab: () => TabItem | undefined;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useActiveTab = void 0;
7
+ var _react = require("react");
8
+ var _TabsContext = require("../components/TabsContext");
9
+ /**
10
+ * 获取当前激活的 Tab 信息 Hook
11
+ * @returns 当前激活的 Tab 对象,如果没有激活则返回 undefined
12
+ */
13
+ var useActiveTab = () => {
14
+ var tabsInstance = (0, _react.useContext)(_TabsContext.TabsContext);
15
+ return (0, _react.useMemo)(() => {
16
+ if (!tabsInstance) return undefined;
17
+ return tabsInstance.getTabInfo().activeTabInfo;
18
+ }, [tabsInstance]);
19
+ };
20
+ exports.useActiveTab = useActiveTab;
@@ -0,0 +1,18 @@
1
+ import type { ProLayoutTabsInstance } from '../../../propTypes';
2
+ /**
3
+ * @description 获取 ProLayout 标签页实例的 Hook(类似 Form.useForm)
4
+ * @returns [ProLayoutTabsInstance] 标签页实例
5
+ * @example
6
+ * ```tsx
7
+ * // 在 ProLayout children 中使用
8
+ * const [layoutTabs] = useProLayoutTabs();
9
+ *
10
+ * // 使用实例方法
11
+ * layoutTabs.addTab({
12
+ * code: 'PolicyInput',
13
+ * name: '投保单录入',
14
+ * extra: { customData: '自定义数据' }
15
+ * });
16
+ * ```
17
+ */
18
+ export declare function useProLayoutTabs(): [ProLayoutTabsInstance];
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useProLayoutTabs = useProLayoutTabs;
7
+ var _react = require("react");
8
+ var _TabsContext = require("../components/TabsContext");
9
+ /**
10
+ * @description 获取 ProLayout 标签页实例的 Hook(类似 Form.useForm)
11
+ * @returns [ProLayoutTabsInstance] 标签页实例
12
+ * @example
13
+ * ```tsx
14
+ * // 在 ProLayout children 中使用
15
+ * const [layoutTabs] = useProLayoutTabs();
16
+ *
17
+ * // 使用实例方法
18
+ * layoutTabs.addTab({
19
+ * code: 'PolicyInput',
20
+ * name: '投保单录入',
21
+ * extra: { customData: '自定义数据' }
22
+ * });
23
+ * ```
24
+ */
25
+ function useProLayoutTabs() {
26
+ var context = (0, _react.useContext)(_TabsContext.TabsContext);
27
+ if (!context) {
28
+ throw new Error('useProLayoutTabs must be used within ProLayout with mode="tabs"');
29
+ }
30
+ return [context];
31
+ }
@@ -0,0 +1,31 @@
1
+ import { TabsState } from '../../../propTypes';
2
+ import { TabsCacheManager } from '../propTypes';
3
+ /**
4
+ * 简化的标签页缓存管理器
5
+ */
6
+ declare class SimpleTabsCache implements TabsCacheManager {
7
+ private cacheKey;
8
+ private storage;
9
+ constructor(keyPrefix: string, strategy: 'localStorage' | 'sessionStorage');
10
+ /** 保存标签页状态 */
11
+ save(state: TabsState): void;
12
+ /** 恢复标签页状态 */
13
+ restore(): TabsState | null;
14
+ /** 清空缓存 */
15
+ clear(): void;
16
+ }
17
+ interface UseTabsCacheOptions {
18
+ cacheKey: string;
19
+ storage: 'localStorage' | 'sessionStorage';
20
+ enabled?: boolean;
21
+ }
22
+ /**
23
+ * 标签页缓存管理Hook
24
+ */
25
+ export declare const useTabsCache: (options: UseTabsCacheOptions) => {
26
+ saveToCache: (state: TabsState) => void;
27
+ restoreFromCache: () => TabsState | null;
28
+ clearCache: () => void;
29
+ cacheManager: SimpleTabsCache;
30
+ };
31
+ export {};
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useTabsCache = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _react = require("react");
11
+ /**
12
+ * 简化的标签页缓存管理器
13
+ */
14
+ class SimpleTabsCache {
15
+ constructor(keyPrefix, strategy) {
16
+ (0, _defineProperty2.default)(this, "cacheKey", void 0);
17
+ (0, _defineProperty2.default)(this, "storage", void 0);
18
+ this.cacheKey = `${keyPrefix}_tabs_cache`;
19
+ this.storage = strategy === 'localStorage' ? localStorage : sessionStorage;
20
+ }
21
+
22
+ /** 保存标签页状态 */
23
+ save(state) {
24
+ try {
25
+ var cacheData = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
26
+ timestamp: Date.now()
27
+ });
28
+ this.storage.setItem(this.cacheKey, JSON.stringify(cacheData));
29
+ } catch (error) {
30
+ console.warn('标签页缓存保存失败:', error);
31
+ }
32
+ }
33
+
34
+ /** 恢复标签页状态 */
35
+ restore() {
36
+ try {
37
+ var cached = this.storage.getItem(this.cacheKey);
38
+ if (!cached) return null;
39
+ var cacheData = JSON.parse(cached);
40
+ // 移除时间戳字段
41
+ delete cacheData.timestamp;
42
+ return cacheData;
43
+ } catch (error) {
44
+ console.warn('标签页缓存恢复失败:', error);
45
+ return null;
46
+ }
47
+ }
48
+
49
+ /** 清空缓存 */
50
+ clear() {
51
+ try {
52
+ this.storage.removeItem(this.cacheKey);
53
+ } catch (error) {
54
+ console.warn('标签页缓存清空失败:', error);
55
+ }
56
+ }
57
+ }
58
+ /**
59
+ * 标签页缓存管理Hook
60
+ */
61
+ var useTabsCache = options => {
62
+ var cacheKey = options.cacheKey,
63
+ storage = options.storage,
64
+ _options$enabled = options.enabled,
65
+ enabled = _options$enabled === void 0 ? true : _options$enabled;
66
+
67
+ // 创建缓存管理器实例
68
+ var cacheManager = (0, _react.useMemo)(() => {
69
+ if (!enabled) return null;
70
+ return new SimpleTabsCache(cacheKey, storage);
71
+ }, [cacheKey, storage, enabled]);
72
+
73
+ // 保存状态到缓存
74
+ var saveToCache = (0, _react.useCallback)(state => {
75
+ if (cacheManager) {
76
+ cacheManager.save(state);
77
+ }
78
+ }, [cacheManager]);
79
+
80
+ // 从缓存恢复状态
81
+ var restoreFromCache = (0, _react.useCallback)(() => {
82
+ if (cacheManager) {
83
+ return cacheManager.restore();
84
+ }
85
+ return null;
86
+ }, [cacheManager]);
87
+
88
+ // 清空缓存
89
+ var clearCache = (0, _react.useCallback)(() => {
90
+ if (cacheManager) {
91
+ cacheManager.clear();
92
+ }
93
+ }, [cacheManager]);
94
+ return {
95
+ saveToCache,
96
+ restoreFromCache,
97
+ clearCache,
98
+ cacheManager
99
+ };
100
+ };
101
+ exports.useTabsCache = useTabsCache;
@@ -0,0 +1,5 @@
1
+ import { UseTabsStateOptions, UseTabsStateReturn } from '../propTypes';
2
+ /**
3
+ * 标签页状态管理Hook
4
+ */
5
+ export declare const useTabsState: (options: UseTabsStateOptions) => UseTabsStateReturn;