@ccs-ui/rc-pro 2.2.0 → 2.2.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.
@@ -11,12 +11,12 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
11
11
  /** 隐藏取消按钮 */
12
12
  hideCancel?: boolean;
13
13
  /** 返回Promise false 则阻止弹窗关闭 */
14
- onOk?: (values?: T) => Promise<boolean> | boolean;
14
+ onOk?: (values?: T) => Promise<boolean> | boolean | undefined | void;
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>, "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>, "auth" | "request" | "onOk" | "onClose" | "extraBtn" | "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,18 @@ export default function useCcsDialog() {
77
80
  },
78
81
  dialogRef: modalRef
79
82
  }, "modal-".concat(modalUuid));
80
-
83
+ // 添加page上下文
84
+ if (CcsPageContext && CcsPageContext.id) {
85
+ dialog = /*#__PURE__*/_jsx(PageContext.Provider, {
86
+ value: CcsPageContext,
87
+ children: dialog
88
+ });
89
+ }
81
90
  // 优先使用自定义contextHolder、其次使用全局contextHolder
82
91
  var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
83
92
  if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
84
93
  // 加载了contextHolder
85
- closeFunc = $holderRef.current.patchElement(modal);
94
+ closeFunc = $holderRef.current.patchElement(dialog);
86
95
  } else {
87
96
  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
97
  // 未加载contextHolder,创建dom
@@ -90,7 +99,7 @@ export default function useCcsDialog() {
90
99
  document.body.append(dialogEle);
91
100
  var root = createRoot(dialogEle);
92
101
  root.render( /*#__PURE__*/_jsx(_Fragment, {
93
- children: modal
102
+ children: dialog
94
103
  }));
95
104
  closeFunc = function closeFunc() {
96
105
  setTimeout(function () {
@@ -135,7 +144,7 @@ export default function useCcsDialog() {
135
144
  drawerUuid += 1;
136
145
  var dialogRef = /*#__PURE__*/React.createRef();
137
146
  var closeFunc;
138
- var modal = /*#__PURE__*/_jsx(HookDrawer, {
147
+ var dialog = /*#__PURE__*/_jsx(HookDrawer, {
139
148
  config: config,
140
149
  afterClose: function afterClose() {
141
150
  var _closeFunc2;
@@ -143,11 +152,19 @@ export default function useCcsDialog() {
143
152
  },
144
153
  dialogRef: dialogRef
145
154
  }, "drawer-".concat(drawerUuid));
155
+
156
+ // 添加page上下文
157
+ if (CcsPageContext && CcsPageContext.id) {
158
+ dialog = /*#__PURE__*/_jsx(PageContext.Provider, {
159
+ value: CcsPageContext,
160
+ children: dialog
161
+ });
162
+ }
146
163
  var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
147
164
  if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
148
165
  var _$holderRef$current;
149
166
  // 加载了contextHolder
150
- closeFunc = (_$holderRef$current = $holderRef.current) === null || _$holderRef$current === void 0 ? void 0 : _$holderRef$current.patchElement(modal);
167
+ closeFunc = (_$holderRef$current = $holderRef.current) === null || _$holderRef$current === void 0 ? void 0 : _$holderRef$current.patchElement(dialog);
151
168
  } else {
152
169
  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
170
  // 未加载contextHolder,创建dom
@@ -155,7 +172,7 @@ export default function useCcsDialog() {
155
172
  document.body.append(dialogEle);
156
173
  var root = createRoot(dialogEle);
157
174
  root.render( /*#__PURE__*/_jsx(_Fragment, {
158
- children: modal
175
+ children: dialog
159
176
  }));
160
177
  closeFunc = function closeFunc() {
161
178
  setTimeout(function () {
@@ -181,7 +198,6 @@ export default function useCcsDialog() {
181
198
  }
182
199
  },
183
200
  update: function update(newConfig) {
184
- console.log('newConfig', newConfig, dialogRef.current);
185
201
  function updateAction() {
186
202
  var _dialogRef$current2;
187
203
  (_dialogRef$current2 = dialogRef.current) === null || _dialogRef$current2 === void 0 || _dialogRef$current2.update(newConfig);
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",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {