@ccs-ui/rc-pro 2.1.7 → 2.1.8

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/ccs.d.ts CHANGED
@@ -130,4 +130,7 @@ type PropsWithNodeChildren = {
130
130
  type PropsWithElementChildren = {
131
131
  children?: ReactElement;
132
132
  };
133
- export type { AuthButtonItem, MenuType, PropsWithCss, PropsWithElementChildren, PropsWithNodeChildren, RecordType, RouteHistory, TableColumns, TableData, TableFormItems, TableInstance, TableInstanceRef, TriggerChildrenProps, };
133
+ type PropsWithChildren<T> = T & {
134
+ children?: T[];
135
+ };
136
+ export type { AuthButtonItem, MenuType, PropsWithChildren, PropsWithCss, PropsWithElementChildren, PropsWithNodeChildren, RecordType, RouteHistory, TableColumns, TableData, TableFormItems, TableInstance, TableInstanceRef, TriggerChildrenProps, };
@@ -54,6 +54,12 @@ type CcsFieldNamesType = {
54
54
  current: string[];
55
55
  pageSize: string[];
56
56
  };
57
+ type CcsDialogFieldNames = {
58
+ /** 成功标识 */
59
+ success?: string[];
60
+ /** 错误信息提示 */
61
+ errorMsg?: string[];
62
+ };
57
63
  type CssAppConfigType = {
58
64
  /** 主题 */
59
65
  theme?: 'dark' | 'light' | 'colorful';
@@ -71,6 +77,8 @@ type CssAppConfigType = {
71
77
  proTable?: CcsFieldNamesType;
72
78
  /** CcsProTable.Tree 组件字段全局指定 */
73
79
  proTableTree?: Pick<CcsFieldNamesType, 'dataSource'>;
80
+ /** dialog request 判定字段 */
81
+ dialog?: CcsDialogFieldNames;
74
82
  };
75
83
  };
76
84
  declare const DrawerAndModalContext: React.Context<FnContextType<any>>;
@@ -1,7 +1,7 @@
1
1
  import { FormProps } from 'antd';
2
2
  import { DialogFormRef } from './form';
3
3
  import { CcsDialogModalProps } from './hook';
4
- declare const DialogRequestButton: ({ auth, formRef, extraBtn, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "onCancel" | "auth" | "request" | "extraBtn" | "onRequestBefore"> & {
4
+ declare const DialogRequestButton: <TParams, TData>({ auth, formRef, extraBtn, formInitialValues, request, onOk, onClose, }: Pick<CcsDialogModalProps<TParams, TData>, "auth" | "request" | "onOk" | "onClose" | "extraBtn"> & {
5
5
  formRef: React.RefObject<DialogFormRef>;
6
6
  formInitialValues: FormProps['initialValues'];
7
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
1
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -17,6 +17,8 @@ import CcsUtils from '@ccs-ui/utils';
17
17
  import { Button } from 'antd';
18
18
  import { useState } from 'react';
19
19
  import { CcsButton, CcsDialog } from '..';
20
+ import { useDialogFields } from "../hooks/use-app";
21
+ import { getDataFromFields } from "../select";
20
22
  import { jsx as _jsx } from "react/jsx-runtime";
21
23
  import { Fragment as _Fragment } from "react/jsx-runtime";
22
24
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -27,13 +29,14 @@ var DialogRequestButton = function DialogRequestButton(_ref) {
27
29
  _ref$formInitialValue = _ref.formInitialValues,
28
30
  formInitialValues = _ref$formInitialValue === void 0 ? {} : _ref$formInitialValue,
29
31
  request = _ref.request,
30
- onCancel = _ref.onCancel,
31
- onRequestBefore = _ref.onRequestBefore;
32
+ onOk = _ref.onOk,
33
+ onClose = _ref.onClose;
32
34
  var _useState = useState(false),
33
35
  _useState2 = _slicedToArray(_useState, 2),
34
36
  loading = _useState2[0],
35
37
  setLoading = _useState2[1];
36
- var onOk = /*#__PURE__*/function () {
38
+ var fieldNames = useDialogFields();
39
+ var onOkClick = /*#__PURE__*/function () {
37
40
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
38
41
  var _formRef$current;
39
42
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -48,13 +51,40 @@ var DialogRequestButton = function DialogRequestButton(_ref) {
48
51
  case 3:
49
52
  formRef.current.formInstance.validateFields().then(function (values) {
50
53
  setLoading(true);
51
- var params = _objectSpread(_objectSpread({}, formInitialValues), onRequestBefore ? onRequestBefore(values) : values);
54
+ var params = _objectSpread(_objectSpread({}, formInitialValues), values);
52
55
  request(params).then(function (result) {
53
56
  setLoading(false);
54
- if (result !== null && result !== void 0 && result.success && onCancel) {
55
- onCancel(params);
57
+
58
+ // 获取成功标识
59
+ var success = getDataFromFields(result, fieldNames.success);
60
+ // 获取异常信息
61
+ var msg = getDataFromFields(result, fieldNames.errorMsg);
62
+ if (success) {
63
+ if (onOk) {
64
+ var okResult = onOk(params);
65
+ // 返回false阻止关闭对话框
66
+ if (typeof okResult === 'boolean' && okResult === false) {
67
+ return;
68
+ }
69
+
70
+ // 返回promiss
71
+ if (_typeof(okResult) === 'object') {
72
+ try {
73
+ okResult.then(function (d) {
74
+ if (d !== false) onClose();
75
+ });
76
+ } catch (error) {
77
+ onClose();
78
+ }
79
+ }
80
+ return;
81
+ }
82
+ onClose();
56
83
  }
57
- CcsDialog.easyMessage(result);
84
+ CcsDialog.easyMessage({
85
+ success: success,
86
+ msg: msg
87
+ });
58
88
  }).catch(function (err) {
59
89
  setLoading(false);
60
90
  console.log('e', err);
@@ -66,18 +96,18 @@ var DialogRequestButton = function DialogRequestButton(_ref) {
66
96
  }
67
97
  }, _callee);
68
98
  }));
69
- return function onOk() {
99
+ return function onOkClick() {
70
100
  return _ref2.apply(this, arguments);
71
101
  };
72
102
  }();
73
103
  return /*#__PURE__*/_jsxs(_Fragment, {
74
104
  children: [extraBtn, /*#__PURE__*/_jsx(Button, {
75
- onClick: onCancel,
105
+ onClick: onClose,
76
106
  children: "\u53D6\u6D88"
77
107
  }), /*#__PURE__*/_jsx(CcsButton, {
78
108
  auth: auth || '',
79
109
  type: "primary",
80
- onClick: onOk,
110
+ onClick: onOkClick,
81
111
  loading: loading,
82
112
  children: "\u786E\u5B9A"
83
113
  })]
@@ -1,7 +1,7 @@
1
1
  import { FormProps } from 'antd';
2
2
  import { DialogFormRef } from './form';
3
3
  import { CcsDialogModalProps } from './hook';
4
- declare const DialogSelfOkButton: ({ auth, formRef, extraBtn, formInitialValues, onCancel, onOk, }: Pick<CcsDialogModalProps, "onCancel" | "auth" | "onOk" | "extraBtn"> & {
4
+ declare const DialogSelfOkButton: <TParams, TData>({ auth, formRef, extraBtn, formInitialValues, onClose, onOk, }: Pick<CcsDialogModalProps<TParams, TData>, "auth" | "onOk" | "onClose" | "extraBtn"> & {
5
5
  formRef: React.RefObject<DialogFormRef>;
6
6
  formInitialValues: FormProps['initialValues'];
7
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,21 @@
1
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
1
2
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
16
  import CcsUtils from '@ccs-ui/utils';
8
17
  import { Button } from 'antd';
18
+ import { useState } from 'react';
9
19
  import { CcsButton } from '..';
10
20
  import { jsx as _jsx } from "react/jsx-runtime";
11
21
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -16,25 +26,69 @@ var DialogSelfOkButton = function DialogSelfOkButton(_ref) {
16
26
  extraBtn = _ref.extraBtn,
17
27
  _ref$formInitialValue = _ref.formInitialValues,
18
28
  formInitialValues = _ref$formInitialValue === void 0 ? {} : _ref$formInitialValue,
19
- onCancel = _ref.onCancel,
29
+ onClose = _ref.onClose,
20
30
  onOk = _ref.onOk;
21
- var onHandleOk = function onHandleOk() {
22
- var _formRef$current;
23
- if (!((_formRef$current = formRef.current) !== null && _formRef$current !== void 0 && _formRef$current.formInstance)) {
24
- CcsUtils.showWarning(false, "\u672A\u5B9A\u4E49form");
25
- return;
26
- }
27
- formRef.current.formInstance.validateFields().then(function (values) {
28
- var params = _objectSpread(_objectSpread({}, formInitialValues), values);
29
- if (onOk) onOk(params);
30
- if (onCancel) onCancel(params);
31
- });
32
- };
31
+ var _useState = useState(false),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ loading = _useState2[0],
34
+ setLoading = _useState2[1];
35
+ var onHandleOk = /*#__PURE__*/function () {
36
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
37
+ var _formRef$current;
38
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
39
+ while (1) switch (_context.prev = _context.next) {
40
+ case 0:
41
+ if ((_formRef$current = formRef.current) !== null && _formRef$current !== void 0 && _formRef$current.formInstance) {
42
+ _context.next = 3;
43
+ break;
44
+ }
45
+ CcsUtils.showWarning(false, "\u672A\u5B9A\u4E49form");
46
+ return _context.abrupt("return");
47
+ case 3:
48
+ formRef.current.formInstance.validateFields().then(function (values) {
49
+ var params = _objectSpread(_objectSpread({}, formInitialValues), values);
50
+ if (onOk) {
51
+ var okResult = onOk(params);
52
+ // 返回false阻止关闭对话框
53
+ if (typeof okResult === 'boolean' && okResult === false) {
54
+ return;
55
+ }
56
+ // 返回promiss
57
+ if (_typeof(okResult) === 'object') {
58
+ try {
59
+ setLoading(true);
60
+ okResult.then(function (d) {
61
+ if (d !== false) onClose();
62
+ setLoading(false);
63
+ });
64
+ } catch (error) {
65
+ setLoading(false);
66
+ onClose();
67
+ }
68
+ } else {
69
+ // 关闭对话框
70
+ onClose();
71
+ }
72
+ }
73
+ });
74
+ case 4:
75
+ case "end":
76
+ return _context.stop();
77
+ }
78
+ }, _callee);
79
+ }));
80
+ return function onHandleOk() {
81
+ return _ref2.apply(this, arguments);
82
+ };
83
+ }();
33
84
  return /*#__PURE__*/_jsxs(_Fragment, {
34
85
  children: [extraBtn, /*#__PURE__*/_jsx(Button, {
35
- onClick: onCancel,
86
+ onClick: function onClick() {
87
+ return onClose();
88
+ },
36
89
  children: "\u53D6\u6D88"
37
90
  }), /*#__PURE__*/_jsx(CcsButton, {
91
+ loading: loading,
38
92
  auth: auth || '',
39
93
  type: "primary",
40
94
  onClick: onHandleOk,
@@ -1,8 +1,9 @@
1
- /// <reference types="react" />
2
1
  import { CcsDialogDrawer, CcsDialogDrawerProps } from './hook';
3
- export type HookDrawerProps = {
2
+ export type HookDrawerProps<TParams, TData> = {
4
3
  afterClose: () => void;
5
- config: CcsDialogDrawerProps;
4
+ config: CcsDialogDrawerProps<TParams, TData>;
6
5
  };
7
- declare const _default: import("react").ForwardRefExoticComponent<HookDrawerProps & import("react").RefAttributes<CcsDialogDrawer>>;
8
- export default _default;
6
+ declare const HookDrawer: <TParams, TData>(props: HookDrawerProps<TParams, TData> & {
7
+ dialogRef: React.RefObject<CcsDialogDrawer>;
8
+ }) => import("react/jsx-runtime").JSX.Element;
9
+ export default HookDrawer;
@@ -1,7 +1,10 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["auth", "form", "content", "className", "rootStyle", "getContainer", "request", "onClose", "onOk"];
2
3
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
4
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
5
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
7
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -15,15 +18,16 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
15
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
19
  import { Drawer } from 'antd';
17
20
  import classNames from 'classnames';
18
- import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
21
+ import { useImperativeHandle, useRef, useState } from 'react';
19
22
  import CcsDialogButtons, { DialogButtonHolder } from "./button";
20
23
  import { DialogContentContext } from "./context";
21
24
  import DialogRequestButton from "./DialogRequestButton";
22
25
  import DialogForm from "./form";
23
26
  import { jsx as _jsx } from "react/jsx-runtime";
24
- var HookDrawer = function HookDrawer(_ref, ref) {
25
- var hookAfterClose = _ref.afterClose,
26
- config = _ref.config;
27
+ var HookDrawer = function HookDrawer(props) {
28
+ var hookAfterClose = props.afterClose,
29
+ config = props.config,
30
+ dialogRef = props.dialogRef;
27
31
  var _useState = useState(function () {
28
32
  if (config.open === undefined) {
29
33
  return _objectSpread(_objectSpread({}, config), {}, {
@@ -38,7 +42,6 @@ var HookDrawer = function HookDrawer(_ref, ref) {
38
42
  var buttonRef = useRef(null);
39
43
  var footerRef = useRef(null);
40
44
  var formRef = useRef(null);
41
- var closeRef = useRef();
42
45
  var afterClose = function afterClose() {
43
46
  hookAfterClose();
44
47
  };
@@ -49,80 +52,33 @@ var HookDrawer = function HookDrawer(_ref, ref) {
49
52
  rootStyle = innerConfig.rootStyle,
50
53
  getContainer = innerConfig.getContainer,
51
54
  request = innerConfig.request,
52
- onAfterOk = innerConfig.onAfterOk,
53
- onAfterCancel = innerConfig.onAfterCancel,
54
55
  onClose = innerConfig.onClose,
55
- onRequestBefore = innerConfig.onRequestBefore;
56
+ onOk = innerConfig.onOk,
57
+ otherInnerConfig = _objectWithoutProperties(innerConfig, _excluded);
56
58
  var close = /*#__PURE__*/function () {
57
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
58
- var _formRef$current, isClose;
59
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
59
60
  return _regeneratorRuntime().wrap(function _callee$(_context) {
60
61
  while (1) switch (_context.prev = _context.next) {
61
62
  case 0:
62
- if (!closeRef.current) {
63
- _context.next = 6;
64
- break;
65
- }
66
- _context.next = 3;
67
- return closeRef.current((_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.formInstance.getFieldsValue());
68
- case 3:
69
- isClose = _context.sent;
70
- if (isClose) {
71
- _context.next = 6;
72
- break;
73
- }
74
- return _context.abrupt("return");
75
- case 6:
76
63
  setInnerConfig(function (c) {
77
64
  return _objectSpread(_objectSpread({}, c), {}, {
78
65
  open: false
79
66
  });
80
67
  });
81
- if ((e === null || e === void 0 ? void 0 : e.type) === 'click') {
82
- // 通过点击关闭按钮或取消按钮关闭
83
- if (onAfterCancel) {
84
- onAfterCancel(e);
85
- }
86
- } else {
87
- // 通过调用closeDialog关闭
88
- if (onAfterOk) {
89
- onAfterOk(e);
90
- }
91
- }
92
68
 
93
69
  // 入参有onClose
94
- if (onClose) {
95
- onClose(e);
96
- }
97
- case 9:
70
+ if (onClose) onClose();
71
+ case 2:
98
72
  case "end":
99
73
  return _context.stop();
100
74
  }
101
75
  }, _callee);
102
76
  }));
103
- return function close(_x) {
104
- return _ref2.apply(this, arguments);
77
+ return function close() {
78
+ return _ref.apply(this, arguments);
105
79
  };
106
80
  }();
107
-
108
- // 异步关闭
109
- var useCloseDialog = /*#__PURE__*/function () {
110
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(closeFn) {
111
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
112
- while (1) switch (_context2.prev = _context2.next) {
113
- case 0:
114
- closeRef.current = closeFn;
115
- case 1:
116
- case "end":
117
- return _context2.stop();
118
- }
119
- }, _callee2);
120
- }));
121
- return function useCloseDialog(_x2) {
122
- return _ref3.apply(this, arguments);
123
- };
124
- }();
125
- useImperativeHandle(ref, function () {
81
+ useImperativeHandle(dialogRef, function () {
126
82
  return {
127
83
  destroy: close,
128
84
  update: function update(newConfig) {
@@ -149,9 +105,9 @@ var HookDrawer = function HookDrawer(_ref, ref) {
149
105
  return /*#__PURE__*/_jsx(DialogRequestButton, {
150
106
  auth: auth,
151
107
  request: request,
152
- onCancel: close,
108
+ onClose: close,
109
+ onOk: onOk,
153
110
  formRef: formRef,
154
- onRequestBefore: onRequestBefore,
155
111
  formInitialValues: form === null || form === void 0 ? void 0 : form.initialValues
156
112
  });
157
113
  }
@@ -163,7 +119,7 @@ var HookDrawer = function HookDrawer(_ref, ref) {
163
119
  afterOpenChange: function afterOpenChange(open) {
164
120
  if (!open) afterClose();
165
121
  }
166
- }, innerConfig), {}, {
122
+ }, otherInnerConfig), {}, {
167
123
  onClose: close,
168
124
  className: classNames('ccs-dialog-drawer', className),
169
125
  styles: styles,
@@ -182,8 +138,7 @@ var HookDrawer = function HookDrawer(_ref, ref) {
182
138
  buttonType: 'drawer',
183
139
  closeDialog: close,
184
140
  drawerFooterRef: footerRef,
185
- formInitialValues: (form === null || form === void 0 ? void 0 : form.initialValues) || {},
186
- useCloseDialog: useCloseDialog
141
+ formInitialValues: (form === null || form === void 0 ? void 0 : form.initialValues) || {}
187
142
  },
188
143
  children: form ? /*#__PURE__*/_jsx(DialogForm, {
189
144
  ref: formRef,
@@ -193,4 +148,4 @@ var HookDrawer = function HookDrawer(_ref, ref) {
193
148
  })
194
149
  }));
195
150
  };
196
- export default /*#__PURE__*/forwardRef(HookDrawer);
151
+ export default HookDrawer;
@@ -1,8 +1,10 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { CcsDialogModal, CcsDialogModalProps } from './hook';
3
- export type HookModalProps = {
3
+ export type HookModalProps<TParams, TData> = {
4
4
  afterClose: () => void;
5
- config: CcsDialogModalProps;
5
+ config: CcsDialogModalProps<TParams, TData>;
6
6
  };
7
- declare const _default: import("react").ForwardRefExoticComponent<HookModalProps & import("react").RefAttributes<CcsDialogModal>>;
8
- export default _default;
7
+ declare const HookModal: <TParams, TData>(props: HookModalProps<TParams, TData> & {
8
+ dialogRef: React.RefObject<CcsDialogModal>;
9
+ }) => import("react/jsx-runtime").JSX.Element;
10
+ export default HookModal;
@@ -1,7 +1,10 @@
1
+ var _excluded = ["auth", "form", "title", "content", "className", "extraBtn", "request", "onClose", "onOk"];
1
2
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
3
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
4
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
5
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
7
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
8
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
9
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
10
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -15,7 +18,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
15
18
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
19
  import { Modal } from 'antd';
17
20
  import classNames from 'classnames';
18
- import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
21
+ import React, { useImperativeHandle, useRef, useState } from 'react';
19
22
  import Draggable from 'react-draggable';
20
23
  import CcsDialogButtons, { DialogButtonHolder } from "./button";
21
24
  import { DialogContentContext } from "./context";
@@ -59,9 +62,10 @@ var DragModal = function DragModal(_ref) {
59
62
  })
60
63
  });
61
64
  };
62
- var HookModal = function HookModal(_ref2, ref) {
63
- var hookAfterClose = _ref2.afterClose,
64
- config = _ref2.config;
65
+ var HookModal = function HookModal(props) {
66
+ var dialogRef = props.dialogRef,
67
+ hookAfterClose = props.afterClose,
68
+ config = props.config;
65
69
  var _useState = useState(function () {
66
70
  if (config.open === undefined) {
67
71
  return _objectSpread(_objectSpread({}, config), {}, {
@@ -87,7 +91,6 @@ var HookModal = function HookModal(_ref2, ref) {
87
91
  setDragState = _useState4[1];
88
92
  var buttonRef = useRef(null);
89
93
  var formRef = useRef(null);
90
- var closeRef = useRef();
91
94
  var afterClose = function afterClose() {
92
95
  var _innerConfig$afterClo;
93
96
  if (config.destroyOnClose !== false) hookAfterClose();
@@ -97,85 +100,36 @@ var HookModal = function HookModal(_ref2, ref) {
97
100
  form = innerConfig.form,
98
101
  title = innerConfig.title,
99
102
  content = innerConfig.content,
100
- _innerConfig$styles = innerConfig.styles,
101
- styles = _innerConfig$styles === void 0 ? {} : _innerConfig$styles,
102
103
  className = innerConfig.className,
103
104
  extraBtn = innerConfig.extraBtn,
104
105
  request = innerConfig.request,
105
- onCancel = innerConfig.onCancel,
106
- onRequestBefore = innerConfig.onRequestBefore,
107
- onAfterOk = innerConfig.onAfterOk,
108
- onAfterCancel = innerConfig.onAfterCancel;
109
- var close = /*#__PURE__*/function () {
110
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
111
- var _formRef$current, isClose;
106
+ onClose = innerConfig.onClose,
107
+ onOk = innerConfig.onOk,
108
+ otherInnerConfig = _objectWithoutProperties(innerConfig, _excluded);
109
+ var onHandleClose = /*#__PURE__*/function () {
110
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
112
111
  return _regeneratorRuntime().wrap(function _callee$(_context) {
113
112
  while (1) switch (_context.prev = _context.next) {
114
113
  case 0:
115
- if (!closeRef.current) {
116
- _context.next = 6;
117
- break;
118
- }
119
- _context.next = 3;
120
- return closeRef.current((_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.formInstance.getFieldsValue());
121
- case 3:
122
- isClose = _context.sent;
123
- if (isClose) {
124
- _context.next = 6;
125
- break;
126
- }
127
- return _context.abrupt("return");
128
- case 6:
129
114
  setInnerConfig(function (c) {
130
115
  return _objectSpread(_objectSpread({}, c), {}, {
131
116
  open: false
132
117
  });
133
118
  });
134
- if ((e === null || e === void 0 ? void 0 : e.type) === 'click') {
135
- // 通过点击关闭按钮或取消按钮关闭
136
- if (onAfterCancel) {
137
- onAfterCancel(e);
138
- }
139
- } else {
140
- // 通过调用closeDialog关闭
141
- if (onAfterOk) {
142
- onAfterOk(e);
143
- }
144
- }
145
119
 
146
120
  // 入参有onClose
147
- if (onCancel) {
148
- onCancel(e);
149
- }
150
- case 9:
121
+ if (onClose) onClose();
122
+ case 2:
151
123
  case "end":
152
124
  return _context.stop();
153
125
  }
154
126
  }, _callee);
155
127
  }));
156
- return function close(_x) {
157
- return _ref3.apply(this, arguments);
128
+ return function onHandleClose() {
129
+ return _ref2.apply(this, arguments);
158
130
  };
159
131
  }();
160
-
161
- // 异步关闭方法
162
- var useCloseDialog = /*#__PURE__*/function () {
163
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(closeFn) {
164
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
165
- while (1) switch (_context2.prev = _context2.next) {
166
- case 0:
167
- closeRef.current = closeFn;
168
- case 1:
169
- case "end":
170
- return _context2.stop();
171
- }
172
- }, _callee2);
173
- }));
174
- return function useCloseDialog(_x2) {
175
- return _ref4.apply(this, arguments);
176
- };
177
- }();
178
- useImperativeHandle(ref, function () {
132
+ useImperativeHandle(dialogRef, function () {
179
133
  return {
180
134
  destroy: close,
181
135
  update: function update(newConfig) {
@@ -191,22 +145,22 @@ var HookModal = function HookModal(_ref2, ref) {
191
145
  return /*#__PURE__*/_jsx(DialogRequestButton, {
192
146
  auth: auth,
193
147
  request: request,
194
- onCancel: close,
148
+ onClose: onHandleClose,
149
+ onOk: onOk,
195
150
  formRef: formRef,
196
151
  extraBtn: extraBtn,
197
- onRequestBefore: onRequestBefore,
198
152
  formInitialValues: form === null || form === void 0 ? void 0 : form.initialValues
199
153
  });
200
154
  }
201
155
 
202
156
  // 传入onOk参数
203
- if (innerConfig.onOk) {
157
+ if (onOk) {
204
158
  return /*#__PURE__*/_jsx(DialogSelfOkButton, {
205
159
  auth: auth,
206
- onCancel: close,
160
+ onClose: onHandleClose,
207
161
  formRef: formRef,
208
162
  extraBtn: extraBtn,
209
- onOk: innerConfig.onOk,
163
+ onOk: onOk,
210
164
  formInitialValues: form === null || form === void 0 ? void 0 : form.initialValues
211
165
  });
212
166
  }
@@ -218,10 +172,9 @@ var HookModal = function HookModal(_ref2, ref) {
218
172
  });
219
173
  };
220
174
  return /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
221
- onCancel: close,
175
+ onCancel: onHandleClose,
222
176
  afterClose: afterClose
223
- }, innerConfig), {}, {
224
- styles: styles,
177
+ }, otherInnerConfig), {}, {
225
178
  className: classNames('ccs-dialog-modal', className),
226
179
  footer: renderFooter(),
227
180
  title: /*#__PURE__*/_jsx("div", {
@@ -260,8 +213,7 @@ var HookModal = function HookModal(_ref2, ref) {
260
213
  buttonType: 'modal',
261
214
  Buttons: CcsDialogButtons,
262
215
  formInitialValues: (form === null || form === void 0 ? void 0 : form.initialValues) || {},
263
- closeDialog: close,
264
- useCloseDialog: useCloseDialog
216
+ closeDialog: onHandleClose
265
217
  },
266
218
  children: form ? /*#__PURE__*/_jsx(DialogForm, {
267
219
  ref: formRef,
@@ -271,4 +223,4 @@ var HookModal = function HookModal(_ref2, ref) {
271
223
  })
272
224
  }));
273
225
  };
274
- export default /*#__PURE__*/forwardRef(HookModal);
226
+ export default HookModal;
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  import { PropsWithNodeChildren } from '../ccs';
3
3
  import { CcsDialogModalProps } from './hook';
4
- export type DialogButtonsProps = Pick<CcsDialogModalProps, 'okText' | 'onCancel' | 'cancelText' | 'onOk'> & PropsWithNodeChildren & {
4
+ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClose' | 'cancelText'> & PropsWithNodeChildren & {
5
5
  okAuth?: string;
6
6
  loading?: boolean;
7
7
  hideCancel?: boolean;
8
+ onOk?: (values?: T) => void;
8
9
  };
9
10
  export type DialogButtonRef = {
10
11
  onSetButtons: (e: React.ReactElement) => void;
11
12
  };
12
13
  export declare const DialogButtonHolder: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<CcsDialogModalProps, "extraBtn"> & React.RefAttributes<DialogButtonRef>>>;
13
- export default function CcsDialogButtons({ okText, okAuth, loading, children, hideCancel, cancelText, onOk, }: DialogButtonsProps): import("react/jsx-runtime").JSX.Element;
14
+ export default function CcsDialogButtons<TParams>({ okText, okAuth, loading, children, hideCancel, cancelText, onOk, }: DialogButtonsProps<TParams>): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,7 @@ type DialogContextType<T = Store> = {
5
5
  /** 表单初始值 */
6
6
  formInitialValues: T;
7
7
  /** 按钮组件 */
8
- Buttons: (e: DialogButtonsProps) => ReactElement;
8
+ Buttons: (e: DialogButtonsProps<T>) => ReactElement;
9
9
  /** 按钮类型 */
10
10
  buttonType: 'modal' | 'drawer';
11
11
  /** 按钮 ref */
@@ -14,8 +14,6 @@ type DialogContextType<T = Store> = {
14
14
  drawerFooterRef?: RefObject<DialogButtonRef>;
15
15
  /** 关闭弹框,可以设置返回值 */
16
16
  closeDialog: (e?: any) => void;
17
- /** 关闭方法hooks,关闭需拦截时使用 */
18
- useCloseDialog: (closeFn: (values: any) => Promise<boolean>) => void;
19
17
  };
20
18
  declare const DialogContentContext: React.Context<DialogContextType<any>>;
21
19
  declare const useDialogContext: <T = Store>() => DialogContextType<T>;
@@ -23,7 +23,16 @@ export type DialogRequestData = {
23
23
  /** 失败消息 */
24
24
  msg: string;
25
25
  };
26
- export type CcsDialogModalProps = ModalFuncProps & {
26
+ export type Service<TParams, TData> = (params: TParams) => Promise<TData>;
27
+ export type OkEvent<TParams> = (params?: TParams) => Promise<boolean> | boolean | void;
28
+ export type Values<TParams extends any> = (params: TParams) => TParams;
29
+ type DialogEvent<TParams, TData> = {
30
+ /** 确定按钮,返回false 或者 promiss false 则阻止关闭对话框 */
31
+ onOk?: OkEvent<TParams>;
32
+ /** 表单接口请求 */
33
+ request?: Service<TParams, TData>;
34
+ };
35
+ export type CcsDialogModalProps<TParams = any, TData = any> = DialogEvent<TData, TParams> & Omit<ModalFuncProps, 'onCancel' | 'afterOpenChange' | 'onOk' | 'footer'> & {
27
36
  /** antd form */
28
37
  form?: FormProps;
29
38
  /** 表单接口请求权限 */
@@ -32,16 +41,10 @@ export type CcsDialogModalProps = ModalFuncProps & {
32
41
  destroyOnClose?: boolean;
33
42
  /** 通过参数传递的扩展按钮 */
34
43
  extraBtn?: ReactNode;
35
- /** 表单接口请求 */
36
- request?: (values: any) => Promise<DialogRequestData>;
37
- /** request执行前参数处理 */
38
- onRequestBefore?: (values: any) => any;
39
- /** 通过closeDialog方法关闭dialog */
40
- onAfterOk?: (e: any) => void;
41
- /** 通过点击关闭按钮或取消按钮关闭 */
42
- onAfterCancel?: (e: any) => void;
44
+ /** 弹框关闭回调 */
45
+ onClose?: () => void;
43
46
  };
44
- export type CcsDialogDrawerProps = Omit<DrawerProps, 'extra'> & {
47
+ export type CcsDialogDrawerProps<TParams = any, TData = any> = DialogEvent<TData, TParams> & Omit<DrawerProps, 'extra' | 'onClose' | 'onOk' | 'afterOpenChange' | 'footer'> & {
45
48
  /** antd form */
46
49
  form?: FormProps;
47
50
  /** 表单接口请求权限 */
@@ -50,20 +53,14 @@ export type CcsDialogDrawerProps = Omit<DrawerProps, 'extra'> & {
50
53
  content?: ReactNode;
51
54
  /** 通过参数传递的扩展按钮 */
52
55
  extraBtn?: ReactNode;
53
- /** 表单接口请求 */
54
- request?: (values: any) => Promise<any>;
55
- /** request执行前参数处理 */
56
- onRequestBefore?: (values: any) => any;
57
- /** 通过closeDialog方法关闭dialog */
58
- onAfterOk?: (e: any) => void;
59
- /** 通过点击关闭按钮或取消按钮关闭 */
60
- onAfterCancel?: (e: any) => void;
56
+ /** 弹框关闭回调 */
57
+ onClose?: () => void;
61
58
  };
62
59
  export type ModalDialog = (...args: Parameters<ModalFunc>) => ReturnType<ModalFunc>;
63
60
  export type DrawerDialog = (...args: Parameters<ModalFunc>) => ReturnType<DrawerFunc>;
64
61
  export type CcsDialogType = {
65
- openDrawer: (props: CcsDialogDrawerProps) => ReturnType<DrawerDialog>;
66
- openModal: (props: CcsDialogModalProps) => ReturnType<ModalDialog>;
62
+ openDrawer: <TParams = any, TData = any>(props: CcsDialogDrawerProps<TParams, TData>) => ReturnType<DrawerDialog>;
63
+ openModal: <TParams = any, TData = any>(props: CcsDialogModalProps<TParams, TData>) => ReturnType<ModalDialog>;
67
64
  contextHolder: React.JSX.Element;
68
65
  };
69
66
  export type ElementsHolderRef = {
package/es/dialog/hook.js CHANGED
@@ -21,6 +21,13 @@ import usePatchElement from "./usePatchElement";
21
21
  // Add `then` field for `ModalFunc` return instance.
22
22
  import { Fragment as _Fragment } from "react/jsx-runtime";
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
+ // type CcsModalFuncType<TParams, TData> = (
25
+ // config: CcsDialogModalProps<TParams, TData>,
26
+ // ) => {
27
+ // destroy: () => void;
28
+ // update: (configUpdate: ModalFuncProps) => void;
29
+ // };
30
+
24
31
  var ElementsHolder = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (_props, ref) {
25
32
  var _usePatchElement = usePatchElement(),
26
33
  _usePatchElement2 = _slicedToArray(_usePatchElement, 2),
@@ -68,7 +75,7 @@ export default function useCcsDialog() {
68
75
  var _closeFunc;
69
76
  (_closeFunc = closeFunc) === null || _closeFunc === void 0 || _closeFunc();
70
77
  },
71
- ref: modalRef
78
+ dialogRef: modalRef
72
79
  }, "modal-".concat(modalUuid));
73
80
 
74
81
  // 优先使用自定义contextHolder、其次使用全局contextHolder
@@ -134,7 +141,7 @@ export default function useCcsDialog() {
134
141
  var _closeFunc2;
135
142
  (_closeFunc2 = closeFunc) === null || _closeFunc2 === void 0 || _closeFunc2();
136
143
  },
137
- ref: modalRef
144
+ dialogRef: modalRef
138
145
  }, "drawer-".concat(drawerUuid));
139
146
  var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
140
147
  if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
@@ -3,6 +3,17 @@
3
3
  * @returns
4
4
  */
5
5
  declare const useAppConfig: () => import("../context").CssAppConfigType;
6
- export declare const useProTableFields: () => import("../context").CcsFieldNamesType | undefined;
7
- export declare const useProTableTreeFields: () => Pick<import("../context").CcsFieldNamesType, "dataSource"> | undefined;
6
+ export declare const useProTableFields: () => {
7
+ dataSource: string[];
8
+ total: string[];
9
+ current: string[];
10
+ pageSize: string[];
11
+ };
12
+ export declare const useProTableTreeFields: () => {
13
+ dataSource: string[];
14
+ };
15
+ export declare const useDialogFields: () => {
16
+ success: string[];
17
+ errorMsg: string[];
18
+ };
8
19
  export default useAppConfig;
@@ -1,3 +1,9 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
7
  import { useContext } from 'react';
2
8
  import { AppConfigContext } from "../context";
3
9
 
@@ -15,11 +21,26 @@ var useAppConfig = function useAppConfig() {
15
21
  export var useProTableFields = function useProTableFields() {
16
22
  var _context$fieldNames;
17
23
  var context = useContext(AppConfigContext) || {};
18
- return context === null || context === void 0 || (_context$fieldNames = context.fieldNames) === null || _context$fieldNames === void 0 ? void 0 : _context$fieldNames.proTable;
24
+ return _objectSpread({
25
+ dataSource: ['data', 'result'],
26
+ current: ['data', 'pageNo'],
27
+ pageSize: ['data', 'pageSize'],
28
+ total: ['data', 'totalNum']
29
+ }, context === null || context === void 0 || (_context$fieldNames = context.fieldNames) === null || _context$fieldNames === void 0 ? void 0 : _context$fieldNames.proTable);
19
30
  };
20
31
  export var useProTableTreeFields = function useProTableTreeFields() {
21
32
  var _context$fieldNames2;
22
33
  var context = useContext(AppConfigContext) || {};
23
- return context === null || context === void 0 || (_context$fieldNames2 = context.fieldNames) === null || _context$fieldNames2 === void 0 ? void 0 : _context$fieldNames2.proTableTree;
34
+ return _objectSpread({
35
+ dataSource: ['data']
36
+ }, context === null || context === void 0 || (_context$fieldNames2 = context.fieldNames) === null || _context$fieldNames2 === void 0 ? void 0 : _context$fieldNames2.proTableTree);
37
+ };
38
+ export var useDialogFields = function useDialogFields() {
39
+ var _context$fieldNames3;
40
+ var context = useContext(AppConfigContext) || {};
41
+ return _objectSpread({
42
+ success: ['success'],
43
+ errorMsg: ['msg']
44
+ }, context === null || context === void 0 || (_context$fieldNames3 = context.fieldNames) === null || _context$fieldNames3 === void 0 ? void 0 : _context$fieldNames3.dialog);
24
45
  };
25
46
  export default useAppConfig;
@@ -72,10 +72,11 @@
72
72
  }
73
73
 
74
74
  .ccs-table-item-scroll > div {
75
- padding: 10px 16px 16px 16px;
75
+ padding: 10px 16px 16px;
76
76
  flex-direction: column;
77
77
  display: none;
78
78
  }
79
+
79
80
  .ccs-table-item-scroll.route-avtive > div {
80
81
  display: flex;
81
82
  }
@@ -6,7 +6,7 @@
6
6
  .ccs-table-item-scroll > div {
7
7
  display: flex;
8
8
  flex-direction: column;
9
- padding: 10px 16px 16px 16px;
9
+ padding: 10px 16px 16px;
10
10
  }
11
11
  }
12
12
 
@@ -1,12 +1,12 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
2
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
7
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
9
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
10
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
11
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
12
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -110,12 +110,7 @@ var InternalProTable = function InternalProTable(props) {
110
110
  // 接口字段指定全局配置
111
111
  var globalFieldNames = useProTableFields();
112
112
  // 接口字段指定
113
- var fieldNames = ((_props$table = props.table) === null || _props$table === void 0 ? void 0 : _props$table.fieldNames) || globalFieldNames || {
114
- dataSource: ['data', 'result'],
115
- current: ['data', 'pageNo'],
116
- pageSize: ['data', 'pageSize'],
117
- total: ['data', 'totalNum']
118
- };
113
+ var fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), (_props$table = props.table) === null || _props$table === void 0 ? void 0 : _props$table.fieldNames);
119
114
  var onSearchBefore = props.onSearchBefore || onDefaultFormat;
120
115
  var onSearchAfter = props.onSearchAfter || onDefaultFormat;
121
116
 
@@ -4,13 +4,13 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
4
4
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
6
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
8
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
9
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
10
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
11
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
12
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
11
13
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
14
14
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15
15
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
16
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -51,9 +51,7 @@ var TableTree = function TableTree(props) {
51
51
  // 接口字段指定全局配置
52
52
  var globalFieldNames = useProTableTreeFields();
53
53
  // 接口字段指定
54
- var fieldNames = props.fieldNames || globalFieldNames || {
55
- dataSource: ['data']
56
- };
54
+ var fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), props.fieldNames);
57
55
 
58
56
  // 获取数据
59
57
  var _onRequestTree = /*#__PURE__*/function () {
@@ -109,8 +109,7 @@ export function ImageUpload(_ref) {
109
109
  width: '100%'
110
110
  },
111
111
  src: file.preview
112
- }),
113
- footer: null
112
+ })
114
113
  });
115
114
  case 5:
116
115
  case "end":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {