@ccs-ui/rc-pro 2.1.9 → 2.2.0
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/button/index.d.ts +1 -1
- package/es/dialog/HookDrawer.js +33 -30
- package/es/dialog/HookModal.js +26 -41
- package/es/dialog/button.d.ts +13 -3
- package/es/dialog/button.js +187 -40
- package/es/dialog/context.d.ts +10 -6
- package/es/dialog/context.js +3 -0
- package/es/dialog/drawer-footer.d.ts +6 -1
- package/es/dialog/drawer-footer.js +33 -49
- package/es/dialog/form.d.ts +5 -4
- package/es/dialog/form.js +5 -4
- package/es/dialog/hook.d.ts +19 -19
- package/es/dialog/hook.js +9 -8
- package/es/dialog/index.d.ts +2 -2
- package/es/dialog/index.js +2 -2
- package/package.json +1 -1
- package/es/dialog/DialogRequestButton.d.ts +0 -8
- package/es/dialog/DialogRequestButton.js +0 -116
- package/es/dialog/DialogSelfOkButton.d.ts +0 -8
- package/es/dialog/DialogSelfOkButton.js +0 -99
package/es/button/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare function ModalConfirm({ modalRef }: {
|
|
|
45
45
|
}): import("react/jsx-runtime").JSX.Element;
|
|
46
46
|
type CcsAuthButtonProps = Omit<ButtonProps, 'onClick'> & {
|
|
47
47
|
/** 权限标识 */
|
|
48
|
-
auth
|
|
48
|
+
auth?: string;
|
|
49
49
|
/** 文本 */
|
|
50
50
|
text?: string;
|
|
51
51
|
/** 二次确认消息 */
|
package/es/dialog/HookDrawer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
+
var _excluded = ["auth", "form", "content", "extraBtn", "className", "rootStyle", "getContainer", "requestFieldNames", "preventRequestHandle", "request", "onClose", "onOk"];
|
|
3
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; }
|
|
4
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); } }
|
|
5
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); }); }; }
|
|
@@ -18,10 +18,10 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
18
18
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
19
|
import { Drawer } from 'antd';
|
|
20
20
|
import classNames from 'classnames';
|
|
21
|
-
import { useImperativeHandle, useRef, useState } from 'react';
|
|
22
|
-
import
|
|
21
|
+
import { useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
22
|
+
import { DialogButtonHolder } from "./button";
|
|
23
23
|
import { DialogContentContext } from "./context";
|
|
24
|
-
import
|
|
24
|
+
import { FooterButtonHolder } from "./drawer-footer";
|
|
25
25
|
import DialogForm from "./form";
|
|
26
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
27
|
var HookDrawer = function HookDrawer(props) {
|
|
@@ -48,14 +48,17 @@ var HookDrawer = function HookDrawer(props) {
|
|
|
48
48
|
var auth = innerConfig.auth,
|
|
49
49
|
form = innerConfig.form,
|
|
50
50
|
content = innerConfig.content,
|
|
51
|
+
extraBtn = innerConfig.extraBtn,
|
|
51
52
|
className = innerConfig.className,
|
|
52
53
|
rootStyle = innerConfig.rootStyle,
|
|
53
54
|
getContainer = innerConfig.getContainer,
|
|
55
|
+
requestFieldNames = innerConfig.requestFieldNames,
|
|
56
|
+
preventRequestHandle = innerConfig.preventRequestHandle,
|
|
54
57
|
request = innerConfig.request,
|
|
55
58
|
onClose = innerConfig.onClose,
|
|
56
59
|
onOk = innerConfig.onOk,
|
|
57
60
|
otherInnerConfig = _objectWithoutProperties(innerConfig, _excluded);
|
|
58
|
-
var
|
|
61
|
+
var onHandleClose = /*#__PURE__*/function () {
|
|
59
62
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
60
63
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
61
64
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -74,13 +77,13 @@ var HookDrawer = function HookDrawer(props) {
|
|
|
74
77
|
}
|
|
75
78
|
}, _callee);
|
|
76
79
|
}));
|
|
77
|
-
return function
|
|
80
|
+
return function onHandleClose() {
|
|
78
81
|
return _ref.apply(this, arguments);
|
|
79
82
|
};
|
|
80
83
|
}();
|
|
81
84
|
useImperativeHandle(dialogRef, function () {
|
|
82
85
|
return {
|
|
83
|
-
destroy:
|
|
86
|
+
destroy: onHandleClose,
|
|
84
87
|
update: function update(newConfig) {
|
|
85
88
|
setInnerConfig(function (originConfig) {
|
|
86
89
|
return _objectSpread(_objectSpread({}, originConfig), newConfig);
|
|
@@ -100,48 +103,48 @@ var HookDrawer = function HookDrawer(props) {
|
|
|
100
103
|
styles.mask = _objectSpread({
|
|
101
104
|
background: 'rgba(0, 0, 0, 0.1)'
|
|
102
105
|
}, styles.mask);
|
|
103
|
-
var renderExtra = function
|
|
104
|
-
if (request) {
|
|
105
|
-
return /*#__PURE__*/_jsx(DialogRequestButton, {
|
|
106
|
-
auth: auth,
|
|
107
|
-
request: request,
|
|
108
|
-
onClose: close,
|
|
109
|
-
onOk: onOk,
|
|
110
|
-
formRef: formRef,
|
|
111
|
-
formInitialValues: form === null || form === void 0 ? void 0 : form.initialValues
|
|
112
|
-
});
|
|
113
|
-
}
|
|
106
|
+
var renderExtra = useMemo(function () {
|
|
114
107
|
return /*#__PURE__*/_jsx(DialogButtonHolder, {
|
|
115
|
-
|
|
108
|
+
auth: auth,
|
|
109
|
+
request: request,
|
|
110
|
+
onClose: onHandleClose,
|
|
111
|
+
onOk: onOk,
|
|
112
|
+
formRef: formRef,
|
|
113
|
+
extraBtn: extraBtn,
|
|
114
|
+
formInitialValues: form === null || form === void 0 ? void 0 : form.initialValues,
|
|
115
|
+
buttonRef: buttonRef,
|
|
116
|
+
preventRequestHandle: preventRequestHandle,
|
|
117
|
+
requestFieldNames: requestFieldNames
|
|
116
118
|
});
|
|
117
|
-
};
|
|
119
|
+
}, []);
|
|
118
120
|
return /*#__PURE__*/_jsx(Drawer, _objectSpread(_objectSpread({
|
|
119
121
|
afterOpenChange: function afterOpenChange(open) {
|
|
120
|
-
if (!open) afterClose();
|
|
121
|
-
}
|
|
122
|
+
if (!open && config.destroyOnClose !== false) afterClose();
|
|
123
|
+
},
|
|
124
|
+
extra: renderExtra,
|
|
125
|
+
footer: /*#__PURE__*/_jsx(FooterButtonHolder, {
|
|
126
|
+
buttonRef: footerRef
|
|
127
|
+
})
|
|
122
128
|
}, otherInnerConfig), {}, {
|
|
123
|
-
onClose:
|
|
129
|
+
onClose: onHandleClose,
|
|
124
130
|
className: classNames('ccs-dialog-drawer', className),
|
|
125
131
|
styles: styles,
|
|
126
132
|
rootStyle: _objectSpread(_objectSpread({}, !isCrInProp ? {
|
|
127
133
|
position: 'absolute'
|
|
128
134
|
} : {}), rootStyle),
|
|
129
135
|
getContainer: isCrInProp ? getContainer : onGetContainer,
|
|
130
|
-
extra: renderExtra(),
|
|
131
|
-
footer: /*#__PURE__*/_jsx(DialogButtonHolder, {
|
|
132
|
-
ref: footerRef
|
|
133
|
-
}),
|
|
134
136
|
children: /*#__PURE__*/_jsx(DialogContentContext.Provider, {
|
|
135
137
|
value: {
|
|
136
|
-
|
|
138
|
+
formRef: formRef,
|
|
137
139
|
buttonRef: buttonRef,
|
|
138
140
|
buttonType: 'drawer',
|
|
139
|
-
|
|
141
|
+
onOkCallBack: onOk,
|
|
142
|
+
closeDialog: onHandleClose,
|
|
140
143
|
drawerFooterRef: footerRef,
|
|
141
144
|
formInitialValues: (form === null || form === void 0 ? void 0 : form.initialValues) || {}
|
|
142
145
|
},
|
|
143
146
|
children: form ? /*#__PURE__*/_jsx(DialogForm, {
|
|
144
|
-
|
|
147
|
+
formRef: formRef,
|
|
145
148
|
formProps: form,
|
|
146
149
|
children: content
|
|
147
150
|
}) : content
|
package/es/dialog/HookModal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["auth", "form", "title", "content", "className", "
|
|
1
|
+
var _excluded = ["auth", "form", "title", "content", "extraBtn", "className", "hideFooter", "preventRequestHandle", "requestFieldNames", "onOk", "request", "onClose"];
|
|
2
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 _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; }
|
|
4
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); } }
|
|
@@ -18,12 +18,10 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
18
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); }
|
|
19
19
|
import { Modal } from 'antd';
|
|
20
20
|
import classNames from 'classnames';
|
|
21
|
-
import React, { useImperativeHandle, useRef, useState } from 'react';
|
|
21
|
+
import React, { useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
22
22
|
import Draggable from 'react-draggable';
|
|
23
|
-
import
|
|
23
|
+
import { DialogButtonHolder } from "./button";
|
|
24
24
|
import { DialogContentContext } from "./context";
|
|
25
|
-
import DialogRequestButton from "./DialogRequestButton";
|
|
26
|
-
import DialogSelfOkButton from "./DialogSelfOkButton";
|
|
27
25
|
import DialogForm from "./form";
|
|
28
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
29
27
|
var DragModal = function DragModal(_ref) {
|
|
@@ -100,11 +98,14 @@ var HookModal = function HookModal(props) {
|
|
|
100
98
|
form = innerConfig.form,
|
|
101
99
|
title = innerConfig.title,
|
|
102
100
|
content = innerConfig.content,
|
|
103
|
-
className = innerConfig.className,
|
|
104
101
|
extraBtn = innerConfig.extraBtn,
|
|
102
|
+
className = innerConfig.className,
|
|
103
|
+
hideFooter = innerConfig.hideFooter,
|
|
104
|
+
preventRequestHandle = innerConfig.preventRequestHandle,
|
|
105
|
+
requestFieldNames = innerConfig.requestFieldNames,
|
|
106
|
+
onOk = innerConfig.onOk,
|
|
105
107
|
request = innerConfig.request,
|
|
106
108
|
onClose = innerConfig.onClose,
|
|
107
|
-
onOk = innerConfig.onOk,
|
|
108
109
|
otherInnerConfig = _objectWithoutProperties(innerConfig, _excluded);
|
|
109
110
|
var onHandleClose = /*#__PURE__*/function () {
|
|
110
111
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -131,7 +132,7 @@ var HookModal = function HookModal(props) {
|
|
|
131
132
|
}();
|
|
132
133
|
useImperativeHandle(dialogRef, function () {
|
|
133
134
|
return {
|
|
134
|
-
destroy:
|
|
135
|
+
destroy: onHandleClose,
|
|
135
136
|
update: function update(newConfig) {
|
|
136
137
|
setInnerConfig(function (originConfig) {
|
|
137
138
|
return _objectSpread(_objectSpread({}, originConfig), newConfig);
|
|
@@ -139,44 +140,27 @@ var HookModal = function HookModal(props) {
|
|
|
139
140
|
}
|
|
140
141
|
};
|
|
141
142
|
});
|
|
142
|
-
var renderFooter = function
|
|
143
|
-
// 传入接口请求参数
|
|
144
|
-
if (request) {
|
|
145
|
-
return /*#__PURE__*/_jsx(DialogRequestButton, {
|
|
146
|
-
auth: auth,
|
|
147
|
-
request: request,
|
|
148
|
-
onClose: onHandleClose,
|
|
149
|
-
onOk: onOk,
|
|
150
|
-
formRef: formRef,
|
|
151
|
-
extraBtn: extraBtn,
|
|
152
|
-
formInitialValues: form === null || form === void 0 ? void 0 : form.initialValues
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// 传入onOk参数
|
|
157
|
-
if (onOk) {
|
|
158
|
-
return /*#__PURE__*/_jsx(DialogSelfOkButton, {
|
|
159
|
-
auth: auth,
|
|
160
|
-
onClose: onHandleClose,
|
|
161
|
-
formRef: formRef,
|
|
162
|
-
extraBtn: extraBtn,
|
|
163
|
-
onOk: onOk,
|
|
164
|
-
formInitialValues: form === null || form === void 0 ? void 0 : form.initialValues
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
143
|
+
var renderFooter = useMemo(function () {
|
|
168
144
|
// 对话框中使用buttons生成按钮
|
|
169
145
|
return /*#__PURE__*/_jsx(DialogButtonHolder, {
|
|
146
|
+
auth: auth,
|
|
147
|
+
request: request,
|
|
148
|
+
onClose: onHandleClose,
|
|
149
|
+
onOk: onOk,
|
|
150
|
+
formRef: formRef,
|
|
170
151
|
extraBtn: extraBtn,
|
|
171
|
-
|
|
152
|
+
formInitialValues: form === null || form === void 0 ? void 0 : form.initialValues,
|
|
153
|
+
buttonRef: buttonRef,
|
|
154
|
+
preventRequestHandle: preventRequestHandle,
|
|
155
|
+
requestFieldNames: requestFieldNames
|
|
172
156
|
});
|
|
173
|
-
};
|
|
157
|
+
}, []);
|
|
174
158
|
return /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
|
|
175
159
|
onCancel: onHandleClose,
|
|
176
160
|
afterClose: afterClose
|
|
177
161
|
}, otherInnerConfig), {}, {
|
|
178
162
|
className: classNames('ccs-dialog-modal', className),
|
|
179
|
-
footer: renderFooter
|
|
163
|
+
footer: hideFooter ? undefined : renderFooter,
|
|
180
164
|
title: /*#__PURE__*/_jsx("div", {
|
|
181
165
|
style: {
|
|
182
166
|
width: '100%',
|
|
@@ -209,14 +193,15 @@ var HookModal = function HookModal(props) {
|
|
|
209
193
|
},
|
|
210
194
|
children: /*#__PURE__*/_jsx(DialogContentContext.Provider, {
|
|
211
195
|
value: {
|
|
196
|
+
formRef: formRef,
|
|
212
197
|
buttonRef: buttonRef,
|
|
213
198
|
buttonType: 'modal',
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
199
|
+
onOkCallBack: onOk,
|
|
200
|
+
closeDialog: onHandleClose,
|
|
201
|
+
formInitialValues: (form === null || form === void 0 ? void 0 : form.initialValues) || {}
|
|
217
202
|
},
|
|
218
203
|
children: form ? /*#__PURE__*/_jsx(DialogForm, {
|
|
219
|
-
|
|
204
|
+
formRef: formRef,
|
|
220
205
|
formProps: form,
|
|
221
206
|
children: content
|
|
222
207
|
}) : content
|
package/es/dialog/button.d.ts
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FormProps } from 'antd';
|
|
2
|
+
import React, { RefObject } from 'react';
|
|
2
3
|
import { PropsWithNodeChildren } from '../ccs';
|
|
4
|
+
import { DialogFormRef } from './form';
|
|
3
5
|
import { CcsDialogModalProps } from './hook';
|
|
4
6
|
export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClose' | 'cancelText'> & PropsWithNodeChildren & {
|
|
7
|
+
/** 按钮权限 */
|
|
5
8
|
okAuth?: string;
|
|
9
|
+
/** loading 状态 */
|
|
6
10
|
loading?: boolean;
|
|
11
|
+
/** 隐藏取消按钮 */
|
|
7
12
|
hideCancel?: boolean;
|
|
8
|
-
|
|
13
|
+
/** 返回Promise false 则阻止弹窗关闭 */
|
|
14
|
+
onOk?: (values?: T) => Promise<boolean> | boolean;
|
|
9
15
|
};
|
|
10
16
|
export type DialogButtonRef = {
|
|
11
17
|
onSetButtons: (e: React.ReactElement) => void;
|
|
12
18
|
};
|
|
13
|
-
export declare const DialogButtonHolder:
|
|
19
|
+
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "onClose" | "onOk" | "auth" | "extraBtn" | "request" | "requestFieldNames" | "preventRequestHandle"> & {
|
|
20
|
+
formRef: React.RefObject<DialogFormRef<TParams>>;
|
|
21
|
+
formInitialValues: FormProps['initialValues'];
|
|
22
|
+
buttonRef: RefObject<DialogButtonRef>;
|
|
23
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
24
|
export default function CcsDialogButtons<TParams>({ okText, okAuth, loading, children, hideCancel, cancelText, onOk, }: DialogButtonsProps<TParams>): import("react/jsx-runtime").JSX.Element;
|
package/es/dialog/button.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
function
|
|
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
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
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
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
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
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); }
|
|
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); }); }; }
|
|
9
|
+
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); }
|
|
7
10
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
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."); }
|
|
9
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); }
|
|
@@ -11,67 +14,212 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
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; } }
|
|
12
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
16
|
import { CcsButton } from "./..";
|
|
14
|
-
import CcsUtils from '@ccs-ui/utils';
|
|
15
17
|
import { Button, Form } from 'antd';
|
|
16
|
-
import React, { useEffect, useImperativeHandle,
|
|
18
|
+
import React, { useEffect, useImperativeHandle, useState } from 'react';
|
|
17
19
|
import CcsDialog from '.';
|
|
20
|
+
import { useDialogFields } from "../hooks/use-app";
|
|
21
|
+
import { getDataFromFields } from "../select";
|
|
18
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
23
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
20
24
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
-
export var DialogButtonHolder =
|
|
22
|
-
var
|
|
25
|
+
export var DialogButtonHolder = function DialogButtonHolder(_ref) {
|
|
26
|
+
var auth = _ref.auth,
|
|
27
|
+
extraBtn = _ref.extraBtn,
|
|
28
|
+
formRef = _ref.formRef,
|
|
29
|
+
request = _ref.request,
|
|
30
|
+
onOk = _ref.onOk,
|
|
31
|
+
onClose = _ref.onClose,
|
|
32
|
+
buttonRef = _ref.buttonRef,
|
|
33
|
+
requestFieldNames = _ref.requestFieldNames,
|
|
34
|
+
formInitialValues = _ref.formInitialValues,
|
|
35
|
+
preventRequestHandle = _ref.preventRequestHandle;
|
|
23
36
|
var _useState = useState(),
|
|
24
37
|
_useState2 = _slicedToArray(_useState, 2),
|
|
25
38
|
buttons = _useState2[0],
|
|
26
39
|
setButtons = _useState2[1];
|
|
27
|
-
var
|
|
28
|
-
|
|
40
|
+
var _useState3 = useState(false),
|
|
41
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
|
+
loading = _useState4[0],
|
|
43
|
+
setLoading = _useState4[1];
|
|
44
|
+
var globalFieldNames = useDialogFields();
|
|
45
|
+
useImperativeHandle(buttonRef, function () {
|
|
29
46
|
return {
|
|
30
47
|
onSetButtons: function onSetButtons(e) {
|
|
31
|
-
|
|
48
|
+
setButtons(e);
|
|
32
49
|
}
|
|
33
50
|
};
|
|
34
51
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
|
|
53
|
+
// 处理关闭
|
|
54
|
+
var onHandleClose = function onHandleClose(params, result) {
|
|
55
|
+
if (onOk) {
|
|
56
|
+
var okResult = onOk(params, result);
|
|
57
|
+
// 返回false阻止关闭对话框
|
|
58
|
+
if (typeof okResult === 'boolean' && okResult === false) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 返回promiss
|
|
63
|
+
if (_typeof(okResult) === 'object') {
|
|
64
|
+
setLoading(true);
|
|
65
|
+
try {
|
|
66
|
+
okResult.then(function (d) {
|
|
67
|
+
setLoading(false);
|
|
68
|
+
if (d !== false) onClose();
|
|
69
|
+
});
|
|
70
|
+
} catch (error) {
|
|
71
|
+
setLoading(false);
|
|
72
|
+
onClose();
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
onClose();
|
|
38
77
|
} else {
|
|
39
|
-
|
|
40
|
-
noBtnRef.current.parentElement.style.padding = '0px';
|
|
78
|
+
onClose();
|
|
41
79
|
}
|
|
42
|
-
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// 确定事件
|
|
83
|
+
var onOkClick = /*#__PURE__*/function () {
|
|
84
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
85
|
+
var _formRef$current;
|
|
86
|
+
var values, form, formValues;
|
|
87
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
88
|
+
while (1) switch (_context.prev = _context.next) {
|
|
89
|
+
case 0:
|
|
90
|
+
values = {};
|
|
91
|
+
form = (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.formInstance; // 存在form 获取form值
|
|
92
|
+
if (!form) {
|
|
93
|
+
_context.next = 7;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
_context.next = 5;
|
|
97
|
+
return form.validateFields();
|
|
98
|
+
case 5:
|
|
99
|
+
formValues = _context.sent;
|
|
100
|
+
values = _objectSpread(_objectSpread({}, formInitialValues), formValues);
|
|
101
|
+
case 7:
|
|
102
|
+
if (!request) {
|
|
103
|
+
_context.next = 11;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
setLoading(true);
|
|
107
|
+
request(values).then(function (result) {
|
|
108
|
+
setLoading(false);
|
|
109
|
+
|
|
110
|
+
// 不处理请求结果
|
|
111
|
+
if (preventRequestHandle) {
|
|
112
|
+
onHandleClose(values, result);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
var fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), requestFieldNames);
|
|
116
|
+
|
|
117
|
+
// 获取成功标识
|
|
118
|
+
var success = getDataFromFields(result, fieldNames.success);
|
|
119
|
+
// 获取异常信息
|
|
120
|
+
var msg = getDataFromFields(result, fieldNames.errorMsg);
|
|
121
|
+
if (success) {
|
|
122
|
+
// 关闭对话框
|
|
123
|
+
onHandleClose(values, result);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// 抛出操作结果
|
|
127
|
+
CcsDialog.easyMessage({
|
|
128
|
+
success: success,
|
|
129
|
+
msg: msg
|
|
130
|
+
});
|
|
131
|
+
}).catch(function (err) {
|
|
132
|
+
setLoading(false);
|
|
133
|
+
console.log('e', err);
|
|
134
|
+
});
|
|
135
|
+
return _context.abrupt("return");
|
|
136
|
+
case 11:
|
|
137
|
+
onHandleClose(values);
|
|
138
|
+
case 12:
|
|
139
|
+
case "end":
|
|
140
|
+
return _context.stop();
|
|
141
|
+
}
|
|
142
|
+
}, _callee);
|
|
143
|
+
}));
|
|
144
|
+
return function onOkClick() {
|
|
145
|
+
return _ref2.apply(this, arguments);
|
|
146
|
+
};
|
|
147
|
+
}();
|
|
148
|
+
if (!buttons) {
|
|
149
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
150
|
+
children: [extraBtn, /*#__PURE__*/_jsx(Button, {
|
|
151
|
+
onClick: onClose,
|
|
152
|
+
children: "\u53D6\u6D88"
|
|
153
|
+
}), /*#__PURE__*/_jsx(CcsButton, {
|
|
154
|
+
auth: auth,
|
|
155
|
+
type: "primary",
|
|
156
|
+
loading: loading,
|
|
157
|
+
onClick: onOkClick,
|
|
158
|
+
children: "\u786E\u5B9A"
|
|
159
|
+
})]
|
|
160
|
+
});
|
|
161
|
+
}
|
|
43
162
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
44
|
-
children: [extraBtn, buttons
|
|
45
|
-
ref: noBtnRef
|
|
46
|
-
})]
|
|
163
|
+
children: [extraBtn, buttons]
|
|
47
164
|
});
|
|
48
|
-
}
|
|
49
|
-
export default function CcsDialogButtons(
|
|
50
|
-
var okText =
|
|
51
|
-
okAuth =
|
|
52
|
-
loading =
|
|
53
|
-
children =
|
|
54
|
-
hideCancel =
|
|
55
|
-
cancelText =
|
|
56
|
-
onOk =
|
|
165
|
+
};
|
|
166
|
+
export default function CcsDialogButtons(_ref3) {
|
|
167
|
+
var okText = _ref3.okText,
|
|
168
|
+
okAuth = _ref3.okAuth,
|
|
169
|
+
loading = _ref3.loading,
|
|
170
|
+
children = _ref3.children,
|
|
171
|
+
hideCancel = _ref3.hideCancel,
|
|
172
|
+
cancelText = _ref3.cancelText,
|
|
173
|
+
onOk = _ref3.onOk;
|
|
57
174
|
var _CcsDialog$useInstanc = CcsDialog.useInstance(),
|
|
58
175
|
closeDialog = _CcsDialog$useInstanc.closeDialog,
|
|
59
176
|
buttonRef = _CcsDialog$useInstanc.buttonRef,
|
|
60
177
|
formInitialValues = _CcsDialog$useInstanc.formInitialValues,
|
|
61
|
-
buttonType = _CcsDialog$useInstanc.buttonType
|
|
178
|
+
buttonType = _CcsDialog$useInstanc.buttonType,
|
|
179
|
+
onOkCallBack = _CcsDialog$useInstanc.onOkCallBack;
|
|
62
180
|
var form = Form.useFormInstance();
|
|
63
|
-
var onOkClick = function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
181
|
+
var onOkClick = /*#__PURE__*/function () {
|
|
182
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
183
|
+
var values, formValues, isOk;
|
|
184
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
185
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
186
|
+
case 0:
|
|
187
|
+
if (onOk) {
|
|
188
|
+
_context2.next = 2;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
return _context2.abrupt("return");
|
|
192
|
+
case 2:
|
|
193
|
+
// form返回表单值和所有初始值
|
|
194
|
+
values = {};
|
|
195
|
+
if (!form) {
|
|
196
|
+
_context2.next = 8;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
_context2.next = 6;
|
|
200
|
+
return form.validateFields();
|
|
201
|
+
case 6:
|
|
202
|
+
formValues = _context2.sent;
|
|
203
|
+
values = _objectSpread(_objectSpread({}, formInitialValues), formValues);
|
|
204
|
+
case 8:
|
|
205
|
+
_context2.next = 10;
|
|
206
|
+
return onOk(values);
|
|
207
|
+
case 10:
|
|
208
|
+
isOk = _context2.sent;
|
|
209
|
+
if (isOk !== false) {
|
|
210
|
+
closeDialog();
|
|
211
|
+
onOkCallBack === null || onOkCallBack === void 0 || onOkCallBack(values);
|
|
212
|
+
}
|
|
213
|
+
case 12:
|
|
214
|
+
case "end":
|
|
215
|
+
return _context2.stop();
|
|
216
|
+
}
|
|
217
|
+
}, _callee2);
|
|
218
|
+
}));
|
|
219
|
+
return function onOkClick() {
|
|
220
|
+
return _ref4.apply(this, arguments);
|
|
221
|
+
};
|
|
222
|
+
}();
|
|
75
223
|
useEffect(function () {
|
|
76
224
|
var _buttonRef$current;
|
|
77
225
|
if (!onOk && !children) return;
|
|
@@ -94,7 +242,6 @@ export default function CcsDialogButtons(_ref2) {
|
|
|
94
242
|
children: btns
|
|
95
243
|
});
|
|
96
244
|
}
|
|
97
|
-
CcsUtils.showWarning(!!buttonRef.current, "\u68C0\u6D4B\u5230".concat(buttonType === 'modal' ? 'openModal' : 'openDrawer', "\u4F20\u5165request\u53C2\u6570\uFF0CButtons\u5C06\u4E0D\u80FD\u751F\u6548\u3002"));
|
|
98
245
|
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.onSetButtons(btns);
|
|
99
246
|
});
|
|
100
247
|
return /*#__PURE__*/_jsx(_Fragment, {});
|