@ccs-ui/rc-pro 2.2.2 → 2.2.3
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/config.js +6 -21
- package/es/context/index.d.ts +3 -1
- package/es/dialog/button.d.ts +1 -1
- package/es/dialog/hook.d.ts +1 -0
- package/es/dialog/hook.js +7 -20
- package/es/hooks/use-page.d.ts +2 -0
- package/es/layout-keep-alive/page.js +6 -1
- package/es/layout-single-page/page.js +6 -1
- package/package.json +1 -1
package/es/config.js
CHANGED
|
@@ -15,27 +15,12 @@ import { theme as antTheme, App, ConfigProvider, message, Modal, notification }
|
|
|
15
15
|
import zhCN from 'antd/locale/zh_CN';
|
|
16
16
|
import React, { useState } from 'react';
|
|
17
17
|
import { AppConfigContext } from "./context";
|
|
18
|
-
import
|
|
18
|
+
import { DialogElementsHolder } from "./dialog/hook";
|
|
19
19
|
import ThemeDialog from "./theme-dialog";
|
|
20
20
|
import WaterMarkRelative from "./water-mark/relative";
|
|
21
21
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
22
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
|
|
25
|
-
var _usePatchElement = usePatchElement(),
|
|
26
|
-
_usePatchElement2 = _slicedToArray(_usePatchElement, 2),
|
|
27
|
-
elements = _usePatchElement2[0],
|
|
28
|
-
patchElement = _usePatchElement2[1];
|
|
29
|
-
React.useImperativeHandle(ref, function () {
|
|
30
|
-
return {
|
|
31
|
-
patchElement: patchElement
|
|
32
|
-
};
|
|
33
|
-
}, []);
|
|
34
|
-
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
35
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
36
|
-
children: elements
|
|
37
|
-
});
|
|
38
|
-
}));
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
39
24
|
function AppDialog() {
|
|
40
25
|
var _message$useMessage = message.useMessage(),
|
|
41
26
|
_message$useMessage2 = _slicedToArray(_message$useMessage, 2),
|
|
@@ -69,7 +54,7 @@ function AppConfig(_ref) {
|
|
|
69
54
|
watermark = _ref.watermark,
|
|
70
55
|
themeConfig = _ref.themeConfig,
|
|
71
56
|
fieldNames = _ref.fieldNames;
|
|
72
|
-
var
|
|
57
|
+
var dialogHolderRef = React.useRef(null);
|
|
73
58
|
// 主题
|
|
74
59
|
var appTheme = theme === 'dark' ? darkTheme : defaultTheme;
|
|
75
60
|
var algorithm = function algorithm() {
|
|
@@ -96,11 +81,11 @@ function AppConfig(_ref) {
|
|
|
96
81
|
value: {
|
|
97
82
|
theme: theme,
|
|
98
83
|
themeConfig: themeConfig,
|
|
99
|
-
|
|
84
|
+
dialogHolderRef: dialogHolderRef,
|
|
100
85
|
fieldNames: fieldNames
|
|
101
86
|
},
|
|
102
|
-
children: [children, /*#__PURE__*/_jsx(AppDialog, {}), /*#__PURE__*/_jsx(
|
|
103
|
-
ref:
|
|
87
|
+
children: [children, /*#__PURE__*/_jsx(AppDialog, {}), /*#__PURE__*/_jsx(DialogElementsHolder, {
|
|
88
|
+
ref: dialogHolderRef
|
|
104
89
|
}, "modal-drawer-holder"), (watermark === null || watermark === void 0 ? void 0 : watermark.content) && /*#__PURE__*/_jsx(WaterMarkRelative, {
|
|
105
90
|
content: watermark.content,
|
|
106
91
|
fontColor: "rgba(0,0,0,.15)",
|
package/es/context/index.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ type PageContextType = {
|
|
|
38
38
|
location: Location;
|
|
39
39
|
/** 当前页面是否选中 */
|
|
40
40
|
isActive: boolean;
|
|
41
|
+
/** dialog holder */
|
|
42
|
+
dialogHolderRef: React.RefObject<ElementsHolderRef>;
|
|
41
43
|
/** 销毁页面 */
|
|
42
44
|
onDestroy: (path: string) => void;
|
|
43
45
|
/** 获取按钮权限 */
|
|
@@ -70,7 +72,7 @@ type CssAppConfigType = {
|
|
|
70
72
|
/** 全局水印 */
|
|
71
73
|
watermark?: WaterMarkProps;
|
|
72
74
|
/** modal or drawer holder */
|
|
73
|
-
|
|
75
|
+
dialogHolderRef?: React.RefObject<ElementsHolderRef>;
|
|
74
76
|
/** 接口字段指定 */
|
|
75
77
|
fieldNames?: {
|
|
76
78
|
/** CcsProTable 组件字段全局指定 */
|
package/es/dialog/button.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
|
|
|
16
16
|
export type DialogButtonRef = {
|
|
17
17
|
onSetButtons: (e: React.ReactElement) => void;
|
|
18
18
|
};
|
|
19
|
-
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "
|
|
19
|
+
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "onOk" | "onClose" | "auth" | "extraBtn" | "request" | "requestFieldNames" | "preventRequestHandle"> & {
|
|
20
20
|
formRef: React.RefObject<DialogFormRef<TParams>>;
|
|
21
21
|
formInitialValues: FormProps['initialValues'];
|
|
22
22
|
buttonRef: RefObject<DialogButtonRef>;
|
package/es/dialog/hook.d.ts
CHANGED
|
@@ -66,5 +66,6 @@ export type CcsDialogType = {
|
|
|
66
66
|
export type ElementsHolderRef = {
|
|
67
67
|
patchElement: ReturnType<typeof usePatchElement>[1];
|
|
68
68
|
};
|
|
69
|
+
export declare const DialogElementsHolder: React.MemoExoticComponent<React.ForwardRefExoticComponent<React.RefAttributes<ElementsHolderRef>>>;
|
|
69
70
|
export default function useCcsDialog(): CcsDialogType;
|
|
70
71
|
export {};
|
package/es/dialog/hook.js
CHANGED
|
@@ -14,7 +14,6 @@ import _debounce from 'lodash.debounce';
|
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import { createRoot } from 'react-dom/client';
|
|
16
16
|
import { useCcsPage } from '..';
|
|
17
|
-
import { PageContext } from "../context";
|
|
18
17
|
import useAppConfig from "../hooks/use-app";
|
|
19
18
|
import HookDrawer from "./HookDrawer";
|
|
20
19
|
import HookModal from "./HookModal";
|
|
@@ -30,7 +29,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
30
29
|
// update: (configUpdate: ModalFuncProps) => void;
|
|
31
30
|
// };
|
|
32
31
|
|
|
33
|
-
var
|
|
32
|
+
export var DialogElementsHolder = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (_props, ref) {
|
|
34
33
|
var _usePatchElement = usePatchElement(),
|
|
35
34
|
_usePatchElement2 = _slicedToArray(_usePatchElement, 2),
|
|
36
35
|
elements = _usePatchElement2[0],
|
|
@@ -56,6 +55,7 @@ export default function useCcsDialog() {
|
|
|
56
55
|
setActionQueue = _React$useState2[1];
|
|
57
56
|
var appConfig = useAppConfig() || {};
|
|
58
57
|
var CcsPageContext = useCcsPage();
|
|
58
|
+
var dialogHolderRef = CcsPageContext.dialogHolderRef || appConfig.dialogHolderRef;
|
|
59
59
|
React.useEffect(function () {
|
|
60
60
|
if (actionQueue.length) {
|
|
61
61
|
var cloneQueue = _toConsumableArray(actionQueue);
|
|
@@ -80,16 +80,9 @@ export default function useCcsDialog() {
|
|
|
80
80
|
},
|
|
81
81
|
dialogRef: modalRef
|
|
82
82
|
}, "modal-".concat(modalUuid));
|
|
83
|
-
|
|
84
|
-
// if (CcsPageContext && CcsPageContext.id) {
|
|
85
|
-
// dialog = (
|
|
86
|
-
// <PageContext.Provider value={CcsPageContext}>
|
|
87
|
-
// {dialog}
|
|
88
|
-
// </PageContext.Provider>
|
|
89
|
-
// );
|
|
90
|
-
// }
|
|
83
|
+
|
|
91
84
|
// 优先使用自定义contextHolder、其次使用全局contextHolder
|
|
92
|
-
var $holderRef = holderRef.current ? holderRef :
|
|
85
|
+
var $holderRef = holderRef.current ? holderRef : dialogHolderRef;
|
|
93
86
|
if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
|
|
94
87
|
// 加载了contextHolder
|
|
95
88
|
closeFunc = $holderRef.current.patchElement(dialog);
|
|
@@ -154,14 +147,8 @@ export default function useCcsDialog() {
|
|
|
154
147
|
dialogRef: dialogRef
|
|
155
148
|
}, "drawer-".concat(drawerUuid));
|
|
156
149
|
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
dialog = /*#__PURE__*/_jsx(PageContext.Provider, {
|
|
160
|
-
value: CcsPageContext,
|
|
161
|
-
children: dialog
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
|
|
150
|
+
// 优先使用自定义contextHolder、其次使用全局contextHolder
|
|
151
|
+
var $holderRef = holderRef.current ? holderRef : dialogHolderRef;
|
|
165
152
|
if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
|
|
166
153
|
var _$holderRef$current;
|
|
167
154
|
// 加载了contextHolder
|
|
@@ -240,7 +227,7 @@ export default function useCcsDialog() {
|
|
|
240
227
|
return {
|
|
241
228
|
openDrawer: fns.openDrawer,
|
|
242
229
|
openModal: fns.openModal,
|
|
243
|
-
contextHolder: /*#__PURE__*/_jsx(
|
|
230
|
+
contextHolder: /*#__PURE__*/_jsx(DialogElementsHolder, {
|
|
244
231
|
ref: holderRef
|
|
245
232
|
}, "modal-holder")
|
|
246
233
|
};
|
package/es/hooks/use-page.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
declare const usePage: () => {
|
|
2
3
|
id: string;
|
|
3
4
|
location: import("react-router").Location<any>;
|
|
4
5
|
isActive: boolean;
|
|
6
|
+
dialogHolderRef: import("react").RefObject<import("../dialog/hook").ElementsHolderRef>;
|
|
5
7
|
onDestroy: (path: string) => void;
|
|
6
8
|
onAuth: (code: string) => boolean;
|
|
7
9
|
};
|
|
@@ -3,6 +3,7 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { memo, useRef } from 'react';
|
|
4
4
|
import Scrollbars from 'react-custom-scrollbars';
|
|
5
5
|
import { PageContext } from "../context";
|
|
6
|
+
import { DialogElementsHolder } from "../dialog/hook";
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
9
|
export default /*#__PURE__*/memo(function (props) {
|
|
@@ -13,9 +14,11 @@ export default /*#__PURE__*/memo(function (props) {
|
|
|
13
14
|
onDestroy = props.onDestroy,
|
|
14
15
|
breadcrumb = props.breadcrumb;
|
|
15
16
|
var id = "_tab_content_".concat(locationRef.current.key);
|
|
17
|
+
var dialogHolderRef = useRef(null);
|
|
16
18
|
return /*#__PURE__*/_jsx(PageContext.Provider, {
|
|
17
19
|
value: {
|
|
18
20
|
id: id,
|
|
21
|
+
dialogHolderRef: dialogHolderRef,
|
|
19
22
|
isActive: active,
|
|
20
23
|
location: locationRef.current,
|
|
21
24
|
onDestroy: onDestroy,
|
|
@@ -38,7 +41,9 @@ export default /*#__PURE__*/memo(function (props) {
|
|
|
38
41
|
children: [/*#__PURE__*/_jsx(Breadcrumb, {
|
|
39
42
|
items: breadcrumb,
|
|
40
43
|
className: "ccs-breadcrumb"
|
|
41
|
-
}), children
|
|
44
|
+
}), children, /*#__PURE__*/_jsx(DialogElementsHolder, {
|
|
45
|
+
ref: dialogHolderRef
|
|
46
|
+
}, "modal-drawer-holder")]
|
|
42
47
|
})
|
|
43
48
|
})
|
|
44
49
|
});
|
|
@@ -2,6 +2,7 @@ import { Breadcrumb } from 'antd';
|
|
|
2
2
|
import { memo, useRef } from 'react';
|
|
3
3
|
import Scrollbars from 'react-custom-scrollbars';
|
|
4
4
|
import { PageContext } from "../context";
|
|
5
|
+
import { DialogElementsHolder } from "../dialog/hook";
|
|
5
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
7
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
8
|
export default /*#__PURE__*/memo(function (props) {
|
|
@@ -11,10 +12,12 @@ export default /*#__PURE__*/memo(function (props) {
|
|
|
11
12
|
urlAuthList = _props$urlAuthList === void 0 ? [] : _props$urlAuthList,
|
|
12
13
|
_props$breadcrumb = props.breadcrumb,
|
|
13
14
|
breadcrumb = _props$breadcrumb === void 0 ? [] : _props$breadcrumb;
|
|
15
|
+
var dialogHolderRef = useRef(null);
|
|
14
16
|
return /*#__PURE__*/_jsx(PageContext.Provider, {
|
|
15
17
|
value: {
|
|
16
18
|
id: '',
|
|
17
19
|
isActive: true,
|
|
20
|
+
dialogHolderRef: dialogHolderRef,
|
|
18
21
|
location: locationRef.current,
|
|
19
22
|
onDestroy: function onDestroy() {
|
|
20
23
|
console.error('单页模式不支持');
|
|
@@ -29,7 +32,9 @@ export default /*#__PURE__*/memo(function (props) {
|
|
|
29
32
|
children: [/*#__PURE__*/_jsx(Breadcrumb, {
|
|
30
33
|
items: breadcrumb,
|
|
31
34
|
className: "ccs-breadcrumb"
|
|
32
|
-
}), children
|
|
35
|
+
}), children, /*#__PURE__*/_jsx(DialogElementsHolder, {
|
|
36
|
+
ref: dialogHolderRef
|
|
37
|
+
}, "modal-drawer-holder")]
|
|
33
38
|
})
|
|
34
39
|
});
|
|
35
40
|
});
|