@ccs-ui/rc-pro 2.2.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,8 +10,8 @@ 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 | undefined | void;
13
+ /** 返回false或Promise false 则阻止弹窗关闭 */
14
+ onOk?: (values: T) => any;
15
15
  };
16
16
  export type DialogButtonRef = {
17
17
  onSetButtons: (e: React.ReactElement) => void;
@@ -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
@@ -81,12 +81,13 @@ export default function useCcsDialog() {
81
81
  dialogRef: modalRef
82
82
  }, "modal-".concat(modalUuid));
83
83
  // 添加page上下文
84
- if (CcsPageContext && CcsPageContext.id) {
85
- dialog = /*#__PURE__*/_jsx(PageContext.Provider, {
86
- value: CcsPageContext,
87
- children: dialog
88
- });
89
- }
84
+ // if (CcsPageContext && CcsPageContext.id) {
85
+ // dialog = (
86
+ // <PageContext.Provider value={CcsPageContext}>
87
+ // {dialog}
88
+ // </PageContext.Provider>
89
+ // );
90
+ // }
90
91
  // 优先使用自定义contextHolder、其次使用全局contextHolder
91
92
  var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
92
93
  if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {