@ccs-ui/rc-pro 2.2.1 → 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 +3 -3
- package/es/dialog/button.js +26 -18
- package/es/dialog/hook.d.ts +1 -0
- package/es/dialog/hook.js +7 -19
- 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
|
@@ -10,13 +10,13 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
|
|
|
10
10
|
loading?: boolean;
|
|
11
11
|
/** 隐藏取消按钮 */
|
|
12
12
|
hideCancel?: boolean;
|
|
13
|
-
/** 返回Promise false 则阻止弹窗关闭 */
|
|
14
|
-
onOk?: (values
|
|
13
|
+
/** 返回false或Promise false 则阻止弹窗关闭 */
|
|
14
|
+
onOk?: (values: T) => any;
|
|
15
15
|
};
|
|
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/button.js
CHANGED
|
@@ -60,17 +60,12 @@ export var DialogButtonHolder = function DialogButtonHolder(_ref) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// 返回promiss
|
|
63
|
-
if (_typeof(okResult) === 'object') {
|
|
63
|
+
if (_typeof(okResult) === 'object' && okResult.then) {
|
|
64
64
|
setLoading(true);
|
|
65
|
-
|
|
66
|
-
okResult.then(function (d) {
|
|
67
|
-
setLoading(false);
|
|
68
|
-
if (d !== false) onClose();
|
|
69
|
-
});
|
|
70
|
-
} catch (error) {
|
|
65
|
+
okResult.then(function (d) {
|
|
71
66
|
setLoading(false);
|
|
72
|
-
onClose();
|
|
73
|
-
}
|
|
67
|
+
if (d !== false) onClose();
|
|
68
|
+
});
|
|
74
69
|
return;
|
|
75
70
|
}
|
|
76
71
|
onClose();
|
|
@@ -180,7 +175,7 @@ export default function CcsDialogButtons(_ref3) {
|
|
|
180
175
|
var form = Form.useFormInstance();
|
|
181
176
|
var onOkClick = /*#__PURE__*/function () {
|
|
182
177
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
183
|
-
var values, formValues,
|
|
178
|
+
var values, formValues, okResult;
|
|
184
179
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
185
180
|
while (1) switch (_context2.prev = _context2.next) {
|
|
186
181
|
case 0:
|
|
@@ -202,15 +197,28 @@ export default function CcsDialogButtons(_ref3) {
|
|
|
202
197
|
formValues = _context2.sent;
|
|
203
198
|
values = _objectSpread(_objectSpread({}, formInitialValues), formValues);
|
|
204
199
|
case 8:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (isOk !== false) {
|
|
210
|
-
closeDialog();
|
|
211
|
-
onOkCallBack === null || onOkCallBack === void 0 || onOkCallBack(values);
|
|
200
|
+
okResult = onOk(values); // 返回false阻止关闭对话框
|
|
201
|
+
if (!(okResult === false)) {
|
|
202
|
+
_context2.next = 11;
|
|
203
|
+
break;
|
|
212
204
|
}
|
|
213
|
-
|
|
205
|
+
return _context2.abrupt("return");
|
|
206
|
+
case 11:
|
|
207
|
+
if (!(_typeof(okResult) === 'object' && okResult.then)) {
|
|
208
|
+
_context2.next = 14;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
okResult.then(function (d) {
|
|
212
|
+
if (d !== false) {
|
|
213
|
+
closeDialog();
|
|
214
|
+
onOkCallBack === null || onOkCallBack === void 0 || onOkCallBack(d);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
return _context2.abrupt("return");
|
|
218
|
+
case 14:
|
|
219
|
+
closeDialog();
|
|
220
|
+
onOkCallBack === null || onOkCallBack === void 0 || onOkCallBack(okResult);
|
|
221
|
+
case 16:
|
|
214
222
|
case "end":
|
|
215
223
|
return _context2.stop();
|
|
216
224
|
}
|
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,15 +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 = /*#__PURE__*/_jsx(PageContext.Provider, {
|
|
86
|
-
value: CcsPageContext,
|
|
87
|
-
children: dialog
|
|
88
|
-
});
|
|
89
|
-
}
|
|
83
|
+
|
|
90
84
|
// 优先使用自定义contextHolder、其次使用全局contextHolder
|
|
91
|
-
var $holderRef = holderRef.current ? holderRef :
|
|
85
|
+
var $holderRef = holderRef.current ? holderRef : dialogHolderRef;
|
|
92
86
|
if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
|
|
93
87
|
// 加载了contextHolder
|
|
94
88
|
closeFunc = $holderRef.current.patchElement(dialog);
|
|
@@ -153,14 +147,8 @@ export default function useCcsDialog() {
|
|
|
153
147
|
dialogRef: dialogRef
|
|
154
148
|
}, "drawer-".concat(drawerUuid));
|
|
155
149
|
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
dialog = /*#__PURE__*/_jsx(PageContext.Provider, {
|
|
159
|
-
value: CcsPageContext,
|
|
160
|
-
children: dialog
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
|
|
150
|
+
// 优先使用自定义contextHolder、其次使用全局contextHolder
|
|
151
|
+
var $holderRef = holderRef.current ? holderRef : dialogHolderRef;
|
|
164
152
|
if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
|
|
165
153
|
var _$holderRef$current;
|
|
166
154
|
// 加载了contextHolder
|
|
@@ -239,7 +227,7 @@ export default function useCcsDialog() {
|
|
|
239
227
|
return {
|
|
240
228
|
openDrawer: fns.openDrawer,
|
|
241
229
|
openModal: fns.openModal,
|
|
242
|
-
contextHolder: /*#__PURE__*/_jsx(
|
|
230
|
+
contextHolder: /*#__PURE__*/_jsx(DialogElementsHolder, {
|
|
243
231
|
ref: holderRef
|
|
244
232
|
}, "modal-holder")
|
|
245
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
|
});
|