@ccs-ui/rc-pro 2.2.1-beta-1 → 2.2.2

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.
@@ -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?: T) => Promise<boolean> | boolean;
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>, "onOk" | "onClose" | "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>;
@@ -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
- try {
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, isOk;
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
- _context2.next = 10;
206
- return onOk(values);
207
- case 10:
208
- isOk = _context2.sent;
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
- case 12:
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.js CHANGED
@@ -80,14 +80,14 @@ export default function useCcsDialog() {
80
80
  },
81
81
  dialogRef: modalRef
82
82
  }, "modal-".concat(modalUuid));
83
- console.log('modal CcsPageContext ...', CcsPageContext);
84
83
  // 添加page上下文
85
- if (CcsPageContext && CcsPageContext.id) {
86
- dialog = /*#__PURE__*/_jsx(PageContext.Provider, {
87
- value: CcsPageContext,
88
- children: dialog
89
- });
90
- }
84
+ // if (CcsPageContext && CcsPageContext.id) {
85
+ // dialog = (
86
+ // <PageContext.Provider value={CcsPageContext}>
87
+ // {dialog}
88
+ // </PageContext.Provider>
89
+ // );
90
+ // }
91
91
  // 优先使用自定义contextHolder、其次使用全局contextHolder
92
92
  var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
93
93
  if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
@@ -153,7 +153,7 @@ export default function useCcsDialog() {
153
153
  },
154
154
  dialogRef: dialogRef
155
155
  }, "drawer-".concat(drawerUuid));
156
- console.log('drawer CcsPageContext ...', CcsPageContext);
156
+
157
157
  // 添加page上下文
158
158
  if (CcsPageContext && CcsPageContext.id) {
159
159
  dialog = /*#__PURE__*/_jsx(PageContext.Provider, {
@@ -199,7 +199,6 @@ export default function useCcsDialog() {
199
199
  }
200
200
  },
201
201
  update: function update(newConfig) {
202
- console.log('newConfig', newConfig, dialogRef.current);
203
202
  function updateAction() {
204
203
  var _dialogRef$current2;
205
204
  (_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.1-beta-1",
3
+ "version": "2.2.2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {