@tiny-codes/react-easy 1.0.3 → 1.0.4
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/CHANGELOG.md +13 -0
- package/es/components/BreakLines/index.js +43 -26
- package/es/components/BreakLines/index.js.map +1 -1
- package/es/components/ConfigProvider/context.js +3 -3
- package/es/components/ConfigProvider/context.js.map +1 -1
- package/es/components/ConfigProvider/index.js +37 -35
- package/es/components/ConfigProvider/index.js.map +1 -1
- package/es/components/ConfirmAction/index.d.ts +74 -6
- package/es/components/ConfirmAction/index.js +210 -104
- package/es/components/ConfirmAction/index.js.map +1 -1
- package/es/components/DeleteConfirmAction/index.js +22 -20
- package/es/components/DeleteConfirmAction/index.js.map +1 -1
- package/es/components/ModalAction/index.d.ts +45 -5
- package/es/components/ModalAction/index.js +393 -209
- package/es/components/ModalAction/index.js.map +1 -1
- package/es/components/index.js +10 -8
- package/es/components/index.js.map +1 -1
- package/es/hooks/index.js +4 -4
- package/es/hooks/index.js.map +1 -1
- package/es/hooks/useContextValidator.js +7 -12
- package/es/hooks/useContextValidator.js.map +1 -1
- package/es/hooks/useLocalizedText.js +6 -4
- package/es/hooks/useLocalizedText.js.map +1 -1
- package/es/hooks/useRefFunction.js +13 -6
- package/es/hooks/useRefFunction.js.map +1 -1
- package/es/hooks/useT.js +11 -8
- package/es/hooks/useT.js.map +1 -1
- package/es/hooks/useValidator.js +7 -4
- package/es/hooks/useValidator.js.map +1 -1
- package/es/hooks/useValidatorBuilder.js +146 -117
- package/es/hooks/useValidatorBuilder.js.map +1 -1
- package/es/hooks/useValidators.js +94 -58
- package/es/hooks/useValidators.js.map +1 -1
- package/es/index.js +2 -2
- package/es/index.js.map +1 -1
- package/es/locales/index.js +19 -13
- package/es/locales/index.js.map +1 -1
- package/es/locales/langs/en-US.js +20 -20
- package/es/locales/langs/en-US.js.map +1 -1
- package/es/locales/langs/en.js +1 -1
- package/es/locales/langs/en.js.map +1 -1
- package/es/locales/langs/zh-CN.js +20 -20
- package/es/locales/langs/zh-CN.js.map +1 -1
- package/es/utils/index.js +1 -1
- package/es/utils/index.js.map +1 -1
- package/lib/components/BreakLines/index.js +50 -37
- package/lib/components/BreakLines/index.js.map +7 -1
- package/lib/components/ConfigProvider/context.js +35 -6
- package/lib/components/ConfigProvider/context.js.map +7 -1
- package/lib/components/ConfigProvider/index.js +56 -42
- package/lib/components/ConfigProvider/index.js.map +7 -1
- package/lib/components/ConfirmAction/index.d.ts +74 -6
- package/lib/components/ConfirmAction/index.js +194 -138
- package/lib/components/ConfirmAction/index.js.map +7 -1
- package/lib/components/DeleteConfirmAction/index.js +50 -51
- package/lib/components/DeleteConfirmAction/index.js.map +7 -1
- package/lib/components/ModalAction/index.d.ts +45 -5
- package/lib/components/ModalAction/index.js +303 -243
- package/lib/components/ModalAction/index.js.map +7 -1
- package/lib/components/index.js +63 -11
- package/lib/components/index.js.map +7 -1
- package/lib/hooks/index.js +49 -5
- package/lib/hooks/index.js.map +7 -1
- package/lib/hooks/useContextValidator.js +47 -11
- package/lib/hooks/useContextValidator.js.map +7 -1
- package/lib/hooks/useLocalizedText.js +41 -15
- package/lib/hooks/useLocalizedText.js.map +7 -1
- package/lib/hooks/useRefFunction.js +34 -21
- package/lib/hooks/useRefFunction.js.map +7 -1
- package/lib/hooks/useT.js +43 -11
- package/lib/hooks/useT.js.map +7 -1
- package/lib/hooks/useValidator.js +41 -12
- package/lib/hooks/useValidator.js.map +7 -1
- package/lib/hooks/useValidatorBuilder.js +149 -132
- package/lib/hooks/useValidatorBuilder.js.map +7 -1
- package/lib/hooks/useValidators.js +104 -67
- package/lib/hooks/useValidators.js.map +7 -1
- package/lib/index.js +26 -3
- package/lib/index.js.map +7 -1
- package/lib/locales/index.js +58 -15
- package/lib/locales/index.js.map +7 -1
- package/lib/locales/langs/en-US.js +46 -22
- package/lib/locales/langs/en-US.js.map +7 -1
- package/lib/locales/langs/en.js +37 -3
- package/lib/locales/langs/en.js.map +7 -1
- package/lib/locales/langs/zh-CN.js +46 -22
- package/lib/locales/langs/zh-CN.js.map +7 -1
- package/lib/utils/index.js +1 -2
- package/lib/utils/index.js.map +7 -1
- package/package.json +14 -15
- package/es/hooks/useValidateContext.d.ts +0 -2
- package/es/hooks/useValidateContext.js +0 -16
- package/es/hooks/useValidateContext.js.map +0 -1
- package/lib/hooks/useValidateContext.d.ts +0 -2
- package/lib/hooks/useValidateContext.js +0 -16
- package/lib/hooks/useValidateContext.js.map +0 -1
|
@@ -1,183 +1,312 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
var _excluded = ["formComp", "formProps", "triggerComponent", "triggerEvent", "triggerProps", "open", "destroyOnClose", "maskClosable", "onOk", "afterOk", "onCancel", "onClose", "children"];
|
|
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
|
+
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
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
+
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."); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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 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; }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
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."); }
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
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; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
23
24
|
import { Button, Form, Modal, Switch, Typography } from 'antd';
|
|
24
25
|
import { isForwardRef } from 'react-is';
|
|
25
|
-
import useContextValidator from
|
|
26
|
+
import useContextValidator from "../../hooks/useContextValidator";
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
29
|
* **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when
|
|
28
30
|
* returning in the `onSave` event of the editing form component
|
|
29
31
|
*
|
|
30
32
|
* **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效
|
|
31
33
|
*/
|
|
32
|
-
|
|
34
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
35
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
36
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
37
|
+
export var SubmitWithoutClosingSymbol = Symbol('[SubmitWithoutClose]');
|
|
33
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
39
|
+
export var genModalActionRenderer = function genModalActionRenderer(defaultProps) {
|
|
40
|
+
var ModalActionRenderer = function ModalActionRenderer(props, ref) {
|
|
41
|
+
var _children;
|
|
42
|
+
var _useState = useState({}),
|
|
43
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
44
|
+
userModalProps = _useState2[0],
|
|
45
|
+
setUserModalProps = _useState2[1];
|
|
46
|
+
var mergedProps = mergeProps(defaultProps, props);
|
|
47
|
+
mergedProps = mergeProps(mergedProps, userModalProps);
|
|
48
|
+
var _mergedProps = mergedProps,
|
|
49
|
+
formComp = _mergedProps.formComp,
|
|
50
|
+
formProps = _mergedProps.formProps,
|
|
51
|
+
_mergedProps$triggerC = _mergedProps.triggerComponent,
|
|
52
|
+
Trigger = _mergedProps$triggerC === void 0 ? Button : _mergedProps$triggerC,
|
|
53
|
+
_mergedProps$triggerE = _mergedProps.triggerEvent,
|
|
54
|
+
triggerEvent = _mergedProps$triggerE === void 0 ? 'onClick' : _mergedProps$triggerE,
|
|
55
|
+
triggerProps = _mergedProps.triggerProps,
|
|
56
|
+
openInProps = _mergedProps.open,
|
|
57
|
+
_mergedProps$destroyO = _mergedProps.destroyOnClose,
|
|
58
|
+
destroyOnClose = _mergedProps$destroyO === void 0 ? true : _mergedProps$destroyO,
|
|
59
|
+
_mergedProps$maskClos = _mergedProps.maskClosable,
|
|
60
|
+
maskClosable = _mergedProps$maskClos === void 0 ? false : _mergedProps$maskClos,
|
|
61
|
+
onOk = _mergedProps.onOk,
|
|
62
|
+
afterOk = _mergedProps.afterOk,
|
|
63
|
+
onCancel = _mergedProps.onCancel,
|
|
64
|
+
_onClose = _mergedProps.onClose,
|
|
65
|
+
children = _mergedProps.children,
|
|
66
|
+
restProps = _objectWithoutProperties(_mergedProps, _excluded);
|
|
67
|
+
useContextValidator();
|
|
68
|
+
var FormComp = formComp;
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
|
+
var triggerEventArgsRef = useRef(undefined);
|
|
71
|
+
var _useState3 = useState(false),
|
|
72
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
73
|
+
open = _useState4[0],
|
|
74
|
+
setOpen = _useState4[1];
|
|
75
|
+
var saveFuncRef = useRef(undefined);
|
|
76
|
+
var _useState5 = useState(false),
|
|
77
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
78
|
+
isSaving = _useState6[0],
|
|
79
|
+
setIsSaving = _useState6[1];
|
|
80
|
+
var _useState7 = useState(null),
|
|
81
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
82
|
+
formCompRef = _useState8[0],
|
|
83
|
+
setFormCompRef = _useState8[1];
|
|
84
|
+
var _useState9 = useState(),
|
|
85
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
86
|
+
form = _useState10[0],
|
|
87
|
+
setForm = _useState10[1];
|
|
88
|
+
var formRef = useRef(form);
|
|
89
|
+
formRef.current = form;
|
|
90
|
+
var destroyOnCloseRef = useRef(destroyOnClose);
|
|
91
|
+
destroyOnCloseRef.current = destroyOnClose;
|
|
92
|
+
var openListenerRef = useRef(undefined);
|
|
93
|
+
|
|
94
|
+
// Listen to the open props changes
|
|
95
|
+
useEffect(function () {
|
|
96
|
+
if (openInProps) {
|
|
97
|
+
setOpen(openInProps);
|
|
98
|
+
}
|
|
99
|
+
}, [openInProps]);
|
|
100
|
+
|
|
101
|
+
// Reset the form after closed
|
|
102
|
+
useEffect(function () {
|
|
103
|
+
if (!destroyOnCloseRef.current && open && formRef.current) {
|
|
104
|
+
formRef.current.resetFields();
|
|
105
|
+
}
|
|
106
|
+
}, [open]);
|
|
107
|
+
|
|
108
|
+
// show trigger
|
|
109
|
+
var showInProps = triggerProps === null || triggerProps === void 0 ? void 0 : triggerProps.show;
|
|
110
|
+
var showTrigger = useMemo(function () {
|
|
111
|
+
if (typeof showInProps === 'boolean') {
|
|
112
|
+
return showInProps;
|
|
113
|
+
} else if (typeof showInProps === 'function') {
|
|
114
|
+
return showInProps(formProps);
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
}, [showInProps, formProps]);
|
|
118
|
+
|
|
119
|
+
// Show the dialog
|
|
120
|
+
var showModal = useCallback(function () {
|
|
121
|
+
var _openListenerRef$curr;
|
|
122
|
+
setOpen(true);
|
|
123
|
+
(_openListenerRef$curr = openListenerRef.current) === null || _openListenerRef$curr === void 0 || _openListenerRef$curr.call(openListenerRef, true);
|
|
124
|
+
}, []);
|
|
125
|
+
// Hide the dialog
|
|
126
|
+
var hideModal = useCallback(function () {
|
|
127
|
+
var _openListenerRef$curr2;
|
|
128
|
+
setOpen(false);
|
|
129
|
+
(_openListenerRef$curr2 = openListenerRef.current) === null || _openListenerRef$curr2 === void 0 || _openListenerRef$curr2.call(openListenerRef, false);
|
|
130
|
+
}, []);
|
|
131
|
+
// Set the dialog status listener
|
|
132
|
+
var setOpenListener = useCallback(function (listener) {
|
|
133
|
+
var _openListenerRef$curr3;
|
|
134
|
+
openListenerRef.current = listener;
|
|
135
|
+
// Call once when initialized
|
|
136
|
+
(_openListenerRef$curr3 = openListenerRef.current) === null || _openListenerRef$curr3 === void 0 || _openListenerRef$curr3.call(openListenerRef, open);
|
|
137
|
+
}, [open]);
|
|
138
|
+
// Receive the onSave callback method passed by the form component
|
|
139
|
+
var setOnSaveHandler = useCallback(function (handler) {
|
|
140
|
+
saveFuncRef.current = handler;
|
|
141
|
+
}, []);
|
|
142
|
+
// Set the dialog status and trigger the onOpenChange event of the form component
|
|
143
|
+
var handleSetOpen = useCallback(function (open) {
|
|
144
|
+
var _openListenerRef$curr4;
|
|
145
|
+
setOpen(open);
|
|
146
|
+
(_openListenerRef$curr4 = openListenerRef.current) === null || _openListenerRef$curr4 === void 0 || _openListenerRef$curr4.call(openListenerRef, open);
|
|
147
|
+
}, []);
|
|
148
|
+
|
|
149
|
+
// Output ref
|
|
150
|
+
useImperativeHandle(ref, function () {
|
|
151
|
+
return _objectSpread(_objectSpread({}, formCompRef), {}, {
|
|
152
|
+
show: showModal
|
|
153
|
+
});
|
|
154
|
+
}, [formCompRef, showModal]);
|
|
155
|
+
|
|
156
|
+
// Render the trigger component
|
|
157
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
158
|
+
children: [showTrigger && /*#__PURE__*/_jsx(Trigger, _objectSpread(_objectSpread(_objectSpread({}, triggerProps), triggerEvent ? _defineProperty({}, triggerEvent, function () {
|
|
159
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
160
|
+
args[_key] = arguments[_key];
|
|
161
|
+
}
|
|
162
|
+
triggerEventArgsRef.current = args;
|
|
163
|
+
showModal();
|
|
164
|
+
if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {
|
|
165
|
+
triggerProps[triggerEvent].apply(triggerProps, args);
|
|
166
|
+
}
|
|
167
|
+
}) : {}), {}, {
|
|
168
|
+
children: (_children = triggerProps.children) !== null && _children !== void 0 ? _children : children
|
|
169
|
+
})), /*#__PURE__*/_jsxs(Modal, _objectSpread(_objectSpread({
|
|
170
|
+
open: open,
|
|
171
|
+
confirmLoading: isSaving,
|
|
172
|
+
destroyOnClose: destroyOnClose,
|
|
173
|
+
maskClosable: maskClosable,
|
|
174
|
+
onOk: ( /*#__PURE__*/function () {
|
|
175
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
|
|
176
|
+
var formData, _saveFuncRef$current, _triggerEventArgsRef$, _ref3, _triggerEventArgsRef$2, result;
|
|
177
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
178
|
+
while (1) switch (_context.prev = _context.next) {
|
|
179
|
+
case 0:
|
|
180
|
+
_context.prev = 0;
|
|
181
|
+
_context.next = 3;
|
|
182
|
+
return form === null || form === void 0 ? void 0 : form.validateFields();
|
|
183
|
+
case 3:
|
|
184
|
+
formData = _context.sent;
|
|
185
|
+
_context.next = 9;
|
|
186
|
+
break;
|
|
187
|
+
case 6:
|
|
188
|
+
_context.prev = 6;
|
|
189
|
+
_context.t0 = _context["catch"](0);
|
|
190
|
+
return _context.abrupt("return");
|
|
191
|
+
case 9:
|
|
192
|
+
if (Object.keys(formData).length === 0) {
|
|
193
|
+
console.warn('form.getFieldsValue() is empty. Please use the form instance passed to formComp instead of creating the form instance yourself.');
|
|
194
|
+
}
|
|
195
|
+
_context.prev = 10;
|
|
196
|
+
setIsSaving(true);
|
|
197
|
+
// First call onSave of the form component
|
|
198
|
+
_context.next = 14;
|
|
199
|
+
return (_saveFuncRef$current = saveFuncRef.current) === null || _saveFuncRef$current === void 0 ? void 0 : _saveFuncRef$current.call.apply(_saveFuncRef$current, [saveFuncRef, formData].concat(_toConsumableArray((_triggerEventArgsRef$ = triggerEventArgsRef.current) !== null && _triggerEventArgsRef$ !== void 0 ? _triggerEventArgsRef$ : [])));
|
|
200
|
+
case 14:
|
|
201
|
+
result = _context.sent;
|
|
202
|
+
if (!(result === SubmitWithoutClosingSymbol)) {
|
|
203
|
+
_context.next = 17;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
throw new Error('SubmitWithoutClosing');
|
|
207
|
+
case 17:
|
|
208
|
+
_context.next = 19;
|
|
209
|
+
return onOk === null || onOk === void 0 ? void 0 : onOk.apply(void 0, [(_ref3 = result) !== null && _ref3 !== void 0 ? _ref3 : formData].concat(_toConsumableArray((_triggerEventArgsRef$2 = triggerEventArgsRef.current) !== null && _triggerEventArgsRef$2 !== void 0 ? _triggerEventArgsRef$2 : [])));
|
|
210
|
+
case 19:
|
|
211
|
+
result = _context.sent;
|
|
212
|
+
if (!(result === SubmitWithoutClosingSymbol)) {
|
|
213
|
+
_context.next = 22;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
throw new Error('SubmitWithoutClosing');
|
|
217
|
+
case 22:
|
|
218
|
+
// If onOK is successful, close the dialog and trigger the afterOk event
|
|
219
|
+
hideModal();
|
|
220
|
+
afterOk === null || afterOk === void 0 || afterOk(result);
|
|
221
|
+
_context.next = 29;
|
|
222
|
+
break;
|
|
223
|
+
case 26:
|
|
224
|
+
_context.prev = 26;
|
|
225
|
+
_context.t1 = _context["catch"](10);
|
|
226
|
+
console.error(_context.t1);
|
|
227
|
+
case 29:
|
|
228
|
+
_context.prev = 29;
|
|
229
|
+
setIsSaving(false);
|
|
230
|
+
return _context.finish(29);
|
|
231
|
+
case 32:
|
|
232
|
+
case "end":
|
|
233
|
+
return _context.stop();
|
|
234
|
+
}
|
|
235
|
+
}, _callee, null, [[0, 6], [10, 26, 29, 32]]);
|
|
236
|
+
}));
|
|
237
|
+
return function (_x) {
|
|
238
|
+
return _ref2.apply(this, arguments);
|
|
239
|
+
};
|
|
240
|
+
}()),
|
|
241
|
+
onCancel: ( /*#__PURE__*/function () {
|
|
242
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e) {
|
|
243
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
244
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
245
|
+
case 0:
|
|
246
|
+
hideModal();
|
|
247
|
+
onCancel === null || onCancel === void 0 || onCancel(e);
|
|
248
|
+
case 2:
|
|
249
|
+
case "end":
|
|
250
|
+
return _context2.stop();
|
|
251
|
+
}
|
|
252
|
+
}, _callee2);
|
|
253
|
+
}));
|
|
254
|
+
return function (_x2) {
|
|
255
|
+
return _ref4.apply(this, arguments);
|
|
256
|
+
};
|
|
257
|
+
}()),
|
|
258
|
+
onClose: function onClose(e) {
|
|
259
|
+
hideModal();
|
|
260
|
+
_onClose === null || _onClose === void 0 || _onClose(e);
|
|
261
|
+
}
|
|
262
|
+
}, restProps), {}, {
|
|
263
|
+
children: [/*#__PURE__*/_jsx(FormCreator, {
|
|
264
|
+
onCreate: setForm
|
|
265
|
+
}), form && /*#__PURE__*/_jsx(FormComp, _objectSpread(_objectSpread({
|
|
266
|
+
ref: isForwardRef(FormComp) ? setFormCompRef : undefined
|
|
267
|
+
}, formProps), {}, {
|
|
268
|
+
form: form,
|
|
269
|
+
onOpenChange: setOpenListener,
|
|
270
|
+
onSave: setOnSaveHandler,
|
|
271
|
+
triggerEventData: triggerEventArgsRef.current,
|
|
272
|
+
setOpen: handleSetOpen,
|
|
273
|
+
updateModalProps: setUserModalProps
|
|
274
|
+
}))]
|
|
275
|
+
}))]
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
return ModalActionRenderer;
|
|
159
279
|
};
|
|
160
280
|
function mergeProps(first, second) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
281
|
+
return _objectSpread(_objectSpread(_objectSpread({}, first), second), {}, {
|
|
282
|
+
okButtonProps: _objectSpread(_objectSpread({}, first === null || first === void 0 ? void 0 : first.okButtonProps), second === null || second === void 0 ? void 0 : second.okButtonProps),
|
|
283
|
+
cancelButtonProps: _objectSpread(_objectSpread({}, first === null || first === void 0 ? void 0 : first.cancelButtonProps), second === null || second === void 0 ? void 0 : second.cancelButtonProps),
|
|
284
|
+
bodyProps: _objectSpread(_objectSpread({}, first === null || first === void 0 ? void 0 : first.bodyProps), second === null || second === void 0 ? void 0 : second.bodyProps),
|
|
285
|
+
maskProps: _objectSpread(_objectSpread({}, first === null || first === void 0 ? void 0 : first.maskProps), second === null || second === void 0 ? void 0 : second.maskProps),
|
|
286
|
+
wrapProps: _objectSpread(_objectSpread({}, first === null || first === void 0 ? void 0 : first.wrapProps), second === null || second === void 0 ? void 0 : second.wrapProps),
|
|
287
|
+
triggerProps: _objectSpread(_objectSpread(_objectSpread({}, first === null || first === void 0 ? void 0 : first.triggerProps), second === null || second === void 0 ? void 0 : second.triggerProps), {}, {
|
|
288
|
+
style: _objectSpread(_objectSpread({}, first !== null && first !== void 0 && first.triggerProps && 'style' in first.triggerProps && _typeof(first.triggerProps.style) === 'object' ? first.triggerProps.style : {}), second !== null && second !== void 0 && second.triggerProps && 'style' in second.triggerProps && _typeof(second.triggerProps.style) === 'object' ? second.triggerProps.style : {})
|
|
289
|
+
})
|
|
290
|
+
});
|
|
166
291
|
}
|
|
167
292
|
function FormCreator(props) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
293
|
+
var onCreate = props.onCreate;
|
|
294
|
+
var onCreateRef = useRef(onCreate);
|
|
295
|
+
onCreateRef.current = onCreate;
|
|
296
|
+
var _Form$useForm = Form.useForm(),
|
|
297
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
298
|
+
form = _Form$useForm2[0];
|
|
299
|
+
|
|
300
|
+
// output ref
|
|
301
|
+
useEffect(function () {
|
|
302
|
+
onCreateRef.current(form);
|
|
303
|
+
return function () {
|
|
304
|
+
onCreateRef.current(undefined);
|
|
305
|
+
};
|
|
306
|
+
}, [form]);
|
|
307
|
+
return null;
|
|
180
308
|
}
|
|
309
|
+
|
|
181
310
|
/**
|
|
182
311
|
* **EN:** Add default properties to the ModalAction component
|
|
183
312
|
*
|
|
@@ -186,59 +315,110 @@ function FormCreator(props) {
|
|
|
186
315
|
* @param WrappedComponent ModalAction component | ModalAction组件
|
|
187
316
|
* @param defaultProps Default properties | 默认属性
|
|
188
317
|
*/
|
|
189
|
-
export
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return
|
|
318
|
+
export var withDefaultModalActionProps = function withDefaultModalActionProps(WrappedComponent, defaultProps) {
|
|
319
|
+
var WithDefaultProps = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
320
|
+
var useDefaultProps = typeof defaultProps === 'function' ? defaultProps : function () {
|
|
321
|
+
return defaultProps;
|
|
322
|
+
};
|
|
323
|
+
var defaults = useDefaultProps();
|
|
324
|
+
var mergedProps = mergeProps(defaults, props);
|
|
325
|
+
WithDefaultProps.displayName = 'ForwardedRef(WithDefaultProps)';
|
|
326
|
+
return /*#__PURE__*/_jsx(WrappedComponent, _objectSpread({
|
|
327
|
+
ref: ref
|
|
328
|
+
}, mergedProps));
|
|
329
|
+
});
|
|
330
|
+
return WithDefaultProps;
|
|
198
331
|
};
|
|
199
|
-
|
|
200
|
-
|
|
332
|
+
var renderModalAction = genModalActionRenderer({});
|
|
333
|
+
var forwardedModalAction = /*#__PURE__*/forwardRef(renderModalAction);
|
|
201
334
|
forwardedModalAction.displayName = 'ForwardedRef(ModalAction)';
|
|
335
|
+
/**
|
|
336
|
+
* **EN:** ModalAction component type
|
|
337
|
+
*
|
|
338
|
+
* **CN:** ModalAction组件的类型
|
|
339
|
+
*/
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* **EN:** ModalAction component with generic type
|
|
343
|
+
*
|
|
344
|
+
* **CN:** ModalAction泛型组件的类型
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* **EN:** ModalAction with specified trigger type (specified form component)
|
|
349
|
+
*
|
|
350
|
+
* **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* **EN:** ModalAction with specified trigger type (unspecified form component, keep generic)
|
|
355
|
+
*
|
|
356
|
+
* **CN:** 已指定Trigger类型的ModalAction(未指定表单组件,保持泛型)
|
|
357
|
+
*/
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* **EN:** Built-in trigger types (specified form components)
|
|
361
|
+
*
|
|
362
|
+
* **CN:** 内置的几种触发器类型(已指定表单组件)
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* **EN:** Built-in trigger types (generic types, unspecified form components)
|
|
367
|
+
*
|
|
368
|
+
* **CN:** 内置的几种触发器类型(泛型类型,未指定表单组件)
|
|
369
|
+
*/
|
|
370
|
+
|
|
202
371
|
/**
|
|
203
372
|
* **EN:** Add trigger types to the ModalAction component
|
|
204
373
|
*
|
|
205
374
|
* **CN:** 给ModalAction组件添加子触发器类型
|
|
206
375
|
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
376
|
+
var addTriggers = function addTriggers(comp) {
|
|
377
|
+
var patchedComp = comp;
|
|
378
|
+
// Type of button trigger
|
|
379
|
+
patchedComp.Button = withDefaultModalActionProps(comp, {
|
|
380
|
+
triggerComponent: Button,
|
|
381
|
+
triggerEvent: 'onClick',
|
|
382
|
+
triggerProps: {}
|
|
383
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
384
|
+
});
|
|
385
|
+
// Type of switch trigger
|
|
386
|
+
patchedComp.Switch = withDefaultModalActionProps(comp, {
|
|
387
|
+
triggerComponent: Switch,
|
|
388
|
+
triggerEvent: 'onChange',
|
|
389
|
+
triggerProps: {}
|
|
390
|
+
}
|
|
391
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
392
|
+
);
|
|
393
|
+
// Type of link trigger
|
|
394
|
+
patchedComp.Link = withDefaultModalActionProps(comp, {
|
|
395
|
+
triggerComponent: Typography.Link,
|
|
396
|
+
triggerEvent: 'onClick',
|
|
397
|
+
triggerProps: {
|
|
398
|
+
style: {
|
|
399
|
+
whiteSpace: 'nowrap'
|
|
400
|
+
}
|
|
221
401
|
}
|
|
222
402
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
patchedComp.Link = withDefaultModalActionProps(comp, {
|
|
226
|
-
triggerComponent: Typography.Link,
|
|
227
|
-
triggerEvent: 'onClick',
|
|
228
|
-
triggerProps: {
|
|
229
|
-
style: { whiteSpace: 'nowrap' },
|
|
230
|
-
},
|
|
231
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
|
-
});
|
|
233
|
-
return patchedComp;
|
|
403
|
+
});
|
|
404
|
+
return patchedComp;
|
|
234
405
|
};
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* **EN:** Dialog component with trigger
|
|
409
|
+
*
|
|
410
|
+
* **CN:** 带触发器的弹窗组件
|
|
411
|
+
*/
|
|
412
|
+
var ModalAction = addTriggers(forwardedModalAction);
|
|
413
|
+
|
|
235
414
|
/**
|
|
236
415
|
* **EN:** Dialog component with trigger
|
|
237
416
|
*
|
|
238
417
|
* **CN:** 带触发器的弹窗组件
|
|
239
418
|
*/
|
|
240
|
-
|
|
419
|
+
|
|
241
420
|
ModalAction.SubmitWithoutClosing = SubmitWithoutClosingSymbol;
|
|
421
|
+
|
|
242
422
|
/**
|
|
243
423
|
* **EN:** Generate a dialog component based on the editing form component
|
|
244
424
|
*
|
|
@@ -248,12 +428,16 @@ ModalAction.SubmitWithoutClosing = SubmitWithoutClosingSymbol;
|
|
|
248
428
|
* @param defaultProps Default properties of the dialog | 弹窗的默认属性
|
|
249
429
|
*/
|
|
250
430
|
export function withModalAction(formComp, defaultProps) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return
|
|
431
|
+
var withForm = withDefaultModalActionProps(forwardedModalAction, function () {
|
|
432
|
+
var useDefaultProps = typeof defaultProps === 'function' ? defaultProps : function () {
|
|
433
|
+
return defaultProps;
|
|
434
|
+
};
|
|
435
|
+
var defaults = useDefaultProps();
|
|
436
|
+
return _objectSpread({
|
|
437
|
+
formComp: formComp
|
|
438
|
+
}, defaults);
|
|
439
|
+
});
|
|
440
|
+
return addTriggers(withForm);
|
|
257
441
|
}
|
|
258
442
|
export default ModalAction;
|
|
259
443
|
//# sourceMappingURL=index.js.map
|