@zat-design/sisyphus-react 3.13.23 → 3.14.0-beta.1
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/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +8 -4
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +39 -28
- package/es/ProLayout/components/TabsManager/components/TabContextMenu.d.ts +7 -0
- package/es/ProLayout/components/TabsManager/components/TabContextMenu.js +96 -0
- package/es/ProLayout/components/TabsManager/components/TabItem.d.ts +26 -0
- package/es/ProLayout/components/TabsManager/components/TabItem.js +61 -0
- package/es/ProLayout/components/TabsManager/components/TabsContext.d.ts +6 -0
- package/es/ProLayout/components/TabsManager/components/TabsContext.js +5 -0
- package/es/ProLayout/components/TabsManager/hooks/useActiveTab.d.ts +6 -0
- package/es/ProLayout/components/TabsManager/hooks/useActiveTab.js +14 -0
- package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.d.ts +18 -0
- package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +26 -0
- package/es/ProLayout/components/TabsManager/hooks/useTabsCache.d.ts +31 -0
- package/es/ProLayout/components/TabsManager/hooks/useTabsCache.js +93 -0
- package/es/ProLayout/components/TabsManager/hooks/useTabsState.d.ts +5 -0
- package/es/ProLayout/components/TabsManager/hooks/useTabsState.js +357 -0
- package/es/ProLayout/components/TabsManager/index.d.ts +8 -0
- package/es/ProLayout/components/TabsManager/index.js +171 -0
- package/es/ProLayout/components/TabsManager/propTypes.d.ts +74 -0
- package/es/ProLayout/components/TabsManager/propTypes.js +16 -0
- package/es/ProLayout/components/TabsManager/style/index.less +179 -0
- package/es/ProLayout/components/TabsManager/utils/index.d.ts +38 -0
- package/es/ProLayout/components/TabsManager/utils/index.js +106 -0
- package/es/ProLayout/index.d.ts +10 -4
- package/es/ProLayout/index.js +82 -9
- package/es/ProLayout/propTypes.d.ts +139 -1
- package/es/ProLayout/propTypes.js +37 -1
- package/es/ProUpload/components/DragRender.d.ts +1 -0
- package/es/ProUpload/components/DragRender.js +5 -1
- package/es/ProUpload/index.js +4 -2
- package/es/ProUpload/propsType.d.ts +5 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +1 -1
- package/lib/ProLayout/components/Layout/Menu/FoldMenu/index.js +8 -4
- package/lib/ProLayout/components/Layout/Menu/OpenMenu/index.js +39 -28
- package/lib/ProLayout/components/TabsManager/components/TabContextMenu.d.ts +7 -0
- package/lib/ProLayout/components/TabsManager/components/TabContextMenu.js +103 -0
- package/lib/ProLayout/components/TabsManager/components/TabItem.d.ts +26 -0
- package/lib/ProLayout/components/TabsManager/components/TabItem.js +67 -0
- package/lib/ProLayout/components/TabsManager/components/TabsContext.d.ts +6 -0
- package/lib/ProLayout/components/TabsManager/components/TabsContext.js +11 -0
- package/lib/ProLayout/components/TabsManager/hooks/useActiveTab.d.ts +6 -0
- package/lib/ProLayout/components/TabsManager/hooks/useActiveTab.js +20 -0
- package/lib/ProLayout/components/TabsManager/hooks/useProLayoutTabs.d.ts +18 -0
- package/lib/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +31 -0
- package/lib/ProLayout/components/TabsManager/hooks/useTabsCache.d.ts +31 -0
- package/lib/ProLayout/components/TabsManager/hooks/useTabsCache.js +101 -0
- package/lib/ProLayout/components/TabsManager/hooks/useTabsState.d.ts +5 -0
- package/lib/ProLayout/components/TabsManager/hooks/useTabsState.js +364 -0
- package/lib/ProLayout/components/TabsManager/index.d.ts +8 -0
- package/lib/ProLayout/components/TabsManager/index.js +175 -0
- package/lib/ProLayout/components/TabsManager/propTypes.d.ts +74 -0
- package/lib/ProLayout/components/TabsManager/propTypes.js +22 -0
- package/lib/ProLayout/components/TabsManager/style/index.less +179 -0
- package/lib/ProLayout/components/TabsManager/utils/index.d.ts +38 -0
- package/lib/ProLayout/components/TabsManager/utils/index.js +119 -0
- package/lib/ProLayout/index.d.ts +10 -4
- package/lib/ProLayout/index.js +94 -8
- package/lib/ProLayout/propTypes.d.ts +139 -1
- package/lib/ProLayout/propTypes.js +40 -1
- package/lib/ProUpload/components/DragRender.d.ts +1 -0
- package/lib/ProUpload/components/DragRender.js +5 -1
- package/lib/ProUpload/index.js +4 -2
- package/lib/ProUpload/propsType.d.ts +5 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +9 -2
- package/package.json +1 -1
|
@@ -26,7 +26,8 @@ var DragRender = props => {
|
|
|
26
26
|
extExt = props.extExt,
|
|
27
27
|
maxCount = props.maxCount,
|
|
28
28
|
setFileList = props.setFileList,
|
|
29
|
-
onChange = props.onChange
|
|
29
|
+
onChange = props.onChange,
|
|
30
|
+
customTextRender = props.customTextRender;
|
|
30
31
|
var refReSelect = useRef();
|
|
31
32
|
|
|
32
33
|
// if (isView) return <>-</>;
|
|
@@ -145,6 +146,9 @@ var DragRender = props => {
|
|
|
145
146
|
}), /*#__PURE__*/_jsxs("p", {
|
|
146
147
|
className: "file-ext",
|
|
147
148
|
children: [locale === null || locale === void 0 || (_locale$ProUpload5 = locale.ProUpload) === null || _locale$ProUpload5 === void 0 ? void 0 : _locale$ProUpload5.draggerFileExt, "\uFF1A", extExt.length > 0 ? extExt.join('、') : `${locale === null || locale === void 0 || (_locale$ProUpload6 = locale.ProUpload) === null || _locale$ProUpload6 === void 0 ? void 0 : _locale$ProUpload6.draggerLimitless}`]
|
|
149
|
+
}), customTextRender && /*#__PURE__*/_jsx("p", {
|
|
150
|
+
className: "file-ext",
|
|
151
|
+
children: customTextRender
|
|
148
152
|
})]
|
|
149
153
|
}), /*#__PURE__*/_jsx("div", {
|
|
150
154
|
className: "dragger-file-show",
|
package/es/ProUpload/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import _message from "antd/es/message";
|
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
-
var _excluded = ["value", "size", "action", "maxCount", "headerRender", "footerRender", "centerRender", "disabled", "uploadType", "buttonProps", "accept", "extraTipText", "beforeUpload", "onChange", "onDownload", "onPreview", "onRemove", "filterOriginFileObj", "method", "className", "dataParams", "name", "showExampleContent", "showUploadList", "otherProps", "transformResponse", "exampleTitle", "exampleContent", "exampleModalProps", "buttonText", "afterRender", "fieldNames", "isConfirmDelete"];
|
|
6
|
+
var _excluded = ["value", "size", "action", "maxCount", "headerRender", "footerRender", "centerRender", "disabled", "uploadType", "buttonProps", "accept", "extraTipText", "beforeUpload", "onChange", "onDownload", "onPreview", "onRemove", "filterOriginFileObj", "method", "className", "dataParams", "name", "showExampleContent", "showUploadList", "otherProps", "transformResponse", "exampleTitle", "exampleContent", "exampleModalProps", "buttonText", "afterRender", "fieldNames", "isConfirmDelete", "customTextRender"];
|
|
7
7
|
import React, { useEffect, useState, useImperativeHandle } from 'react';
|
|
8
8
|
import { isFunction, omit } from 'lodash';
|
|
9
9
|
import { PointerSensor, useSensor } from '@dnd-kit/core';
|
|
@@ -65,6 +65,7 @@ var ProUpload = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
65
65
|
afterRender = props.afterRender,
|
|
66
66
|
fieldNames = props.fieldNames,
|
|
67
67
|
isConfirmDelete = props.isConfirmDelete,
|
|
68
|
+
customTextRender = props.customTextRender,
|
|
68
69
|
residueProps = _objectWithoutProperties(props, _excluded);
|
|
69
70
|
var isView = (props === null || props === void 0 ? void 0 : props.isView) || (otherProps === null || otherProps === void 0 ? void 0 : otherProps.isView);
|
|
70
71
|
var sensor = useSensor(PointerSensor, {
|
|
@@ -259,7 +260,8 @@ var ProUpload = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
259
260
|
buttonText,
|
|
260
261
|
extraTipText,
|
|
261
262
|
afterRender,
|
|
262
|
-
isConfirmDelete
|
|
263
|
+
isConfirmDelete,
|
|
264
|
+
customTextRender
|
|
263
265
|
};
|
|
264
266
|
useEffect(() => {
|
|
265
267
|
if (fieldNames && value.length > 0) {
|
|
@@ -72,6 +72,11 @@ export interface ProUploadType {
|
|
|
72
72
|
* @default -
|
|
73
73
|
*/
|
|
74
74
|
centerRender?: React.ReactNode | (() => React.ReactNode);
|
|
75
|
+
/**
|
|
76
|
+
* @description 自定义上传区域的文案
|
|
77
|
+
* @default -
|
|
78
|
+
*/
|
|
79
|
+
customTextRender?: React.ReactNode;
|
|
75
80
|
/**
|
|
76
81
|
* @description 是否显示示例弹窗
|
|
77
82
|
* @default false
|
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
|
|
38
|
-
|
|
39
|
-
|
|
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:
|
|
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
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
56
|
-
|
|
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)
|
|
114
|
-
|
|
115
|
-
selectedKeys: selectKeyIdPath
|
|
116
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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,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,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;
|