@ccs-ui/rc-pro 2.2.0 → 2.2.1-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.
@@ -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>, "onClose" | "onOk" | "auth" | "extraBtn" | "request" | "requestFieldNames" | "preventRequestHandle"> & {
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>;
@@ -229,7 +229,7 @@ export default function CcsDialogButtons(_ref3) {
229
229
  onClick: closeDialog,
230
230
  children: cancelText || '取消'
231
231
  }), /*#__PURE__*/_jsx(CcsButton, {
232
- auth: okAuth || '',
232
+ auth: okAuth,
233
233
  type: "primary",
234
234
  loading: loading,
235
235
  onClick: onOkClick,
@@ -24,7 +24,7 @@ export type DialogRequestData = {
24
24
  msg: string;
25
25
  };
26
26
  export type Service<TParams, TData> = (params: TParams) => Promise<TData>;
27
- export type OkEvent<TParams, TData> = (params?: TParams, result?: TData) => Promise<boolean> | boolean | void;
27
+ export type OkEvent<TParams, TData> = (params?: TParams, result?: TData) => Promise<boolean | undefined> | boolean | void;
28
28
  export type Values<TParams extends any> = (params: TParams) => TParams;
29
29
  type DialogProps<TParams, TData> = {
30
30
  /** antd form */
package/es/dialog/hook.js CHANGED
@@ -13,6 +13,8 @@ import CcsUtils from '@ccs-ui/utils';
13
13
  import _debounce from 'lodash.debounce';
14
14
  import React from 'react';
15
15
  import { createRoot } from 'react-dom/client';
16
+ import { useCcsPage } from '..';
17
+ import { PageContext } from "../context";
16
18
  import useAppConfig from "../hooks/use-app";
17
19
  import HookDrawer from "./HookDrawer";
18
20
  import HookModal from "./HookModal";
@@ -53,6 +55,7 @@ export default function useCcsDialog() {
53
55
  actionQueue = _React$useState2[0],
54
56
  setActionQueue = _React$useState2[1];
55
57
  var appConfig = useAppConfig() || {};
58
+ var CcsPageContext = useCcsPage();
56
59
  React.useEffect(function () {
57
60
  if (actionQueue.length) {
58
61
  var cloneQueue = _toConsumableArray(actionQueue);
@@ -69,7 +72,7 @@ export default function useCcsDialog() {
69
72
  // 关闭事件
70
73
  var closeFunc;
71
74
  // modal
72
- var modal = /*#__PURE__*/_jsx(HookModal, {
75
+ var dialog = /*#__PURE__*/_jsx(HookModal, {
73
76
  config: config,
74
77
  afterClose: function afterClose() {
75
78
  var _closeFunc;
@@ -77,12 +80,19 @@ export default function useCcsDialog() {
77
80
  },
78
81
  dialogRef: modalRef
79
82
  }, "modal-".concat(modalUuid));
80
-
83
+ console.log('modal CcsPageContext ...', CcsPageContext);
84
+ // 添加page上下文
85
+ if (CcsPageContext && CcsPageContext.id) {
86
+ dialog = /*#__PURE__*/_jsx(PageContext.Provider, {
87
+ value: CcsPageContext,
88
+ children: dialog
89
+ });
90
+ }
81
91
  // 优先使用自定义contextHolder、其次使用全局contextHolder
82
92
  var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
83
93
  if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
84
94
  // 加载了contextHolder
85
- closeFunc = $holderRef.current.patchElement(modal);
95
+ closeFunc = $holderRef.current.patchElement(dialog);
86
96
  } else {
87
97
  CcsUtils.showWarning(false, "\u672A\u4F7F\u7528CssAppConfig\u5168\u5C40\u914D\u7F6E\u3001\u4E5F\u672A\u5C06contextHolder\u63D2\u5165\u7EC4\u4EF6\u4E2D\uFF0C\u5C06\u65E0\u6CD5\u9002\u914Dantd\u4E3B\u9898\u914D\u7F6E\u548C\u83B7\u53D6context\u3002");
88
98
  // 未加载contextHolder,创建dom
@@ -90,7 +100,7 @@ export default function useCcsDialog() {
90
100
  document.body.append(dialogEle);
91
101
  var root = createRoot(dialogEle);
92
102
  root.render( /*#__PURE__*/_jsx(_Fragment, {
93
- children: modal
103
+ children: dialog
94
104
  }));
95
105
  closeFunc = function closeFunc() {
96
106
  setTimeout(function () {
@@ -135,7 +145,7 @@ export default function useCcsDialog() {
135
145
  drawerUuid += 1;
136
146
  var dialogRef = /*#__PURE__*/React.createRef();
137
147
  var closeFunc;
138
- var modal = /*#__PURE__*/_jsx(HookDrawer, {
148
+ var dialog = /*#__PURE__*/_jsx(HookDrawer, {
139
149
  config: config,
140
150
  afterClose: function afterClose() {
141
151
  var _closeFunc2;
@@ -143,11 +153,19 @@ export default function useCcsDialog() {
143
153
  },
144
154
  dialogRef: dialogRef
145
155
  }, "drawer-".concat(drawerUuid));
156
+ console.log('drawer CcsPageContext ...', CcsPageContext);
157
+ // 添加page上下文
158
+ if (CcsPageContext && CcsPageContext.id) {
159
+ dialog = /*#__PURE__*/_jsx(PageContext.Provider, {
160
+ value: CcsPageContext,
161
+ children: dialog
162
+ });
163
+ }
146
164
  var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
147
165
  if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
148
166
  var _$holderRef$current;
149
167
  // 加载了contextHolder
150
- closeFunc = (_$holderRef$current = $holderRef.current) === null || _$holderRef$current === void 0 ? void 0 : _$holderRef$current.patchElement(modal);
168
+ closeFunc = (_$holderRef$current = $holderRef.current) === null || _$holderRef$current === void 0 ? void 0 : _$holderRef$current.patchElement(dialog);
151
169
  } else {
152
170
  CcsUtils.showWarning(false, "\u672A\u4F7F\u7528CssAppConfig\u5168\u5C40\u914D\u7F6E\u3001\u4E5F\u672A\u5C06contextHolder\u63D2\u5165\u7EC4\u4EF6\u4E2D\uFF0C\u5C06\u65E0\u6CD5\u9002\u914Dantd\u4E3B\u9898\u914D\u7F6E\u548C\u83B7\u53D6context\u3002");
153
171
  // 未加载contextHolder,创建dom
@@ -155,7 +173,7 @@ export default function useCcsDialog() {
155
173
  document.body.append(dialogEle);
156
174
  var root = createRoot(dialogEle);
157
175
  root.render( /*#__PURE__*/_jsx(_Fragment, {
158
- children: modal
176
+ children: dialog
159
177
  }));
160
178
  closeFunc = function closeFunc() {
161
179
  setTimeout(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "2.2.0",
3
+ "version": "2.2.1-beta-1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {