@quansitech/antd-admin 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Column/Cascader.d.ts +3 -0
- package/dist/components/Column/Cascader.js +110 -0
- package/dist/components/Column/File.d.ts +18 -0
- package/dist/components/Column/File.js +176 -0
- package/dist/components/Column/Image.d.ts +10 -0
- package/dist/components/Column/Image.js +104 -0
- package/dist/components/Column/Readonly/Action/Link.d.ts +11 -0
- package/dist/components/Column/Readonly/Action/Link.js +114 -0
- package/dist/components/Column/Readonly/Action/index.d.ts +4 -0
- package/dist/components/Column/Readonly/Action/index.js +3 -0
- package/dist/components/Column/Readonly/Action.d.ts +12 -0
- package/dist/components/Column/Readonly/Action.js +96 -0
- package/dist/components/Column/Readonly/Cascader.d.ts +9 -0
- package/dist/components/Column/Readonly/Cascader.js +52 -0
- package/dist/components/Column/Readonly/File.d.ts +8 -0
- package/dist/components/Column/Readonly/File.js +54 -0
- package/dist/components/Column/Readonly/Image.d.ts +3 -0
- package/dist/components/Column/Readonly/Image.js +69 -0
- package/dist/components/Column/Readonly/Ueditor.d.ts +3 -0
- package/dist/components/Column/Readonly/Ueditor.js +24 -0
- package/dist/components/Column/Readonly/index.d.ts +8 -0
- package/dist/components/Column/Readonly/index.js +7 -0
- package/dist/components/Column/Ueditor.d.ts +27 -0
- package/dist/components/Column/Ueditor.js +333 -0
- package/dist/components/Column/index.d.ts +7 -0
- package/dist/components/Column/index.js +6 -0
- package/dist/components/Form/Action/Button.d.ts +15 -0
- package/dist/components/Form/Action/Button.js +194 -0
- package/dist/components/Form/Action/index.d.ts +4 -0
- package/dist/components/Form/Action/index.js +3 -0
- package/dist/components/Form/Actions.d.ts +6 -0
- package/dist/components/Form/Actions.js +48 -0
- package/dist/components/Form.d.ts +20 -0
- package/dist/components/Form.js +217 -0
- package/dist/components/FormContext.d.ts +7 -0
- package/dist/components/FormContext.js +2 -0
- package/dist/components/Layout/New.d.ts +7 -0
- package/dist/components/Layout/New.js +257 -0
- package/dist/components/Layout.d.ts +4 -0
- package/dist/components/Layout.js +67 -0
- package/dist/components/LayoutContext.d.ts +26 -0
- package/dist/components/LayoutContext.js +2 -0
- package/dist/components/ModalContext.d.ts +8 -0
- package/dist/components/ModalContext.js +6 -0
- package/dist/components/Table/Action/Button.d.ts +10 -0
- package/dist/components/Table/Action/Button.js +166 -0
- package/dist/components/Table/Action/StartEditable.d.ts +10 -0
- package/dist/components/Table/Action/StartEditable.js +79 -0
- package/dist/components/Table/Action/index.d.ts +5 -0
- package/dist/components/Table/Action/index.js +4 -0
- package/dist/components/Table/ToolbarActions.d.ts +6 -0
- package/dist/components/Table/ToolbarActions.js +52 -0
- package/dist/components/Table.d.ts +19 -0
- package/dist/components/Table.js +322 -0
- package/dist/components/TableContext.d.ts +14 -0
- package/dist/components/TableContext.js +2 -0
- package/dist/components/Tabs.d.ts +15 -0
- package/dist/components/Tabs.js +62 -0
- package/dist/env.d.ts +1 -0
- package/dist/global.d.ts +6 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/lib/container.d.ts +9 -0
- package/dist/lib/container.js +93 -0
- package/dist/lib/customRule.d.ts +3 -0
- package/dist/lib/customRule.js +7 -0
- package/dist/lib/global.d.ts +9 -0
- package/dist/lib/global.js +2 -0
- package/dist/lib/helpers.d.ts +14 -0
- package/dist/lib/helpers.js +183 -0
- package/dist/lib/http.d.ts +5 -0
- package/dist/lib/http.js +72 -0
- package/dist/lib/schemaHandler.d.ts +5 -0
- package/dist/lib/schemaHandler.js +133 -0
- package/dist/lib/upload.d.ts +20 -0
- package/dist/lib/upload.js +215 -0
- package/dist/lib/writeExtra.d.ts +1 -0
- package/dist/lib/writeExtra.js +28 -0
- package/dist/types.d.ts +25 -0
- package/package.json +14 -8
- package/components/Column/Cascader.tsx +0 -79
- package/components/Column/File.tsx +0 -166
- package/components/Column/Image.tsx +0 -77
- package/components/Column/Readonly/Action/Link.tsx +0 -78
- package/components/Column/Readonly/Action.tsx +0 -80
- package/components/Column/Readonly/Cascader.tsx +0 -51
- package/components/Column/Readonly/File.tsx +0 -53
- package/components/Column/Readonly/Image.tsx +0 -39
- package/components/Column/Readonly/Ueditor.tsx +0 -18
- package/components/Column/Ueditor.tsx +0 -314
- package/components/Form/Action/Button.tsx +0 -129
- package/components/Form/Actions.tsx +0 -39
- package/components/Form.tsx +0 -177
- package/components/FormContext.ts +0 -9
- package/components/Layout/New.tsx +0 -252
- package/components/Layout.tsx +0 -52
- package/components/LayoutContext.ts +0 -26
- package/components/ModalContext.ts +0 -16
- package/components/Table/Action/Button.tsx +0 -89
- package/components/Table/Action/StartEditable.tsx +0 -59
- package/components/Table/ToolbarActions.tsx +0 -44
- package/components/Table.tsx +0 -280
- package/components/TableContext.ts +0 -15
- package/components/Tabs.tsx +0 -72
- package/lib/container.ts +0 -84
- package/lib/customRule.ts +0 -10
- package/lib/global.ts +0 -11
- package/lib/helpers.tsx +0 -146
- package/lib/http.ts +0 -74
- package/lib/schemaHandler.ts +0 -122
- package/lib/upload.ts +0 -177
- package/lib/writeExtra.js +0 -31
- /package/{components → dist/components}/Column/Readonly/Action/types.d.ts +0 -0
- /package/{components → dist/components}/Column/Readonly/types.d.ts +0 -0
- /package/{components → dist/components}/Column/types.d.ts +0 -0
- /package/{components → dist/components}/Form/Action/types.d.ts +0 -0
- /package/{components → dist/components}/Table/Action/types.d.ts +0 -0
- /package/{components → dist/components}/Table.scss +0 -0
- /package/{components → dist/components}/types.d.ts +0 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
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; }
|
|
6
|
+
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); } }
|
|
7
|
+
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); }); }; }
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
12
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
15
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
16
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
17
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
18
|
+
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; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
20
|
+
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); }
|
|
21
|
+
import React, { Component } from "react";
|
|
22
|
+
import { createScript, filterObjectKeys } from "../../lib/helpers";
|
|
23
|
+
import { Spin } from "antd";
|
|
24
|
+
import { ModalContext } from "../ModalContext";
|
|
25
|
+
import { uniqueId } from "es-toolkit/compat";
|
|
26
|
+
var Ueditor = /*#__PURE__*/function (_Component) {
|
|
27
|
+
_inherits(Ueditor, _Component);
|
|
28
|
+
var _super = _createSuper(Ueditor);
|
|
29
|
+
function Ueditor() {
|
|
30
|
+
var _this;
|
|
31
|
+
_classCallCheck(this, Ueditor);
|
|
32
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
33
|
+
args[_key] = arguments[_key];
|
|
34
|
+
}
|
|
35
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
36
|
+
_defineProperty(_assertThisInitialized(_this), "modalContext", {});
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "editor", null);
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "catching", false);
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "containerRef", null);
|
|
40
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
41
|
+
loading: true,
|
|
42
|
+
containerId: uniqueId('ueditor_'),
|
|
43
|
+
width: ''
|
|
44
|
+
});
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
_createClass(Ueditor, [{
|
|
48
|
+
key: "componentDidMount",
|
|
49
|
+
value: function componentDidMount() {
|
|
50
|
+
var _this$containerRef,
|
|
51
|
+
_this$containerRef2,
|
|
52
|
+
_this$props$rules,
|
|
53
|
+
_this2 = this;
|
|
54
|
+
this.setState({
|
|
55
|
+
width: (_this$containerRef = this.containerRef) !== null && _this$containerRef !== void 0 && _this$containerRef.offsetWidth ? "".concat((_this$containerRef2 = this.containerRef) === null || _this$containerRef2 === void 0 ? void 0 : _this$containerRef2.offsetWidth, "px") : '100%'
|
|
56
|
+
});
|
|
57
|
+
(_this$props$rules = this.props.rules) === null || _this$props$rules === void 0 || _this$props$rules.push({
|
|
58
|
+
validator: function () {
|
|
59
|
+
var _validator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(rule, value) {
|
|
60
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
61
|
+
while (1) switch (_context.prev = _context.next) {
|
|
62
|
+
case 0:
|
|
63
|
+
if (!_this2.catching) {
|
|
64
|
+
_context.next = 2;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
throw new Error('正在抓取图片');
|
|
68
|
+
case 2:
|
|
69
|
+
return _context.abrupt("return", true);
|
|
70
|
+
case 3:
|
|
71
|
+
case "end":
|
|
72
|
+
return _context.stop();
|
|
73
|
+
}
|
|
74
|
+
}, _callee);
|
|
75
|
+
}));
|
|
76
|
+
function validator(_x, _x2) {
|
|
77
|
+
return _validator.apply(this, arguments);
|
|
78
|
+
}
|
|
79
|
+
return validator;
|
|
80
|
+
}()
|
|
81
|
+
});
|
|
82
|
+
if (!window.UE && !window.UE_LOADING_PROMISE) {
|
|
83
|
+
window.UE_LOADING_PROMISE = createScript(this.props.fieldProps.configJsPath || this.props.fieldProps.ueditorPath + '/ueditor.config.js').then(function () {
|
|
84
|
+
return createScript(_this2.props.fieldProps.ueditorPath + '/ueditor.all.js');
|
|
85
|
+
}).then(function () {
|
|
86
|
+
return createScript(_this2.props.fieldProps.ueditorPath + '/lang/zh-cn/zh-cn.js');
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
window.UE_LOADING_PROMISE.then(function () {
|
|
90
|
+
var _this2$props$fieldPro, _this2$props$fieldPro2, _this2$modalContext, _this2$editor;
|
|
91
|
+
var that = _this2;
|
|
92
|
+
window.UE.plugins['forceCatchRemoteImg'] = function () {
|
|
93
|
+
if (this.options.forcecatchremote) {
|
|
94
|
+
this.addListener("afterpaste", function (t, a) {
|
|
95
|
+
var load_src = that.props.fieldProps.ueditorPath + '/img/load.gif';
|
|
96
|
+
var domUtils = window.UE.dom.domUtils;
|
|
97
|
+
var parser = new DOMParser();
|
|
98
|
+
var pasteDom = parser.parseFromString(a.html, "text/html");
|
|
99
|
+
|
|
100
|
+
// @ts-ignore
|
|
101
|
+
var allImgs = domUtils.getElementsByTagName(this.document, "img");
|
|
102
|
+
var imgs = domUtils.getElementsByTagName(pasteDom, "img");
|
|
103
|
+
var notCatch = function notCatch(src) {
|
|
104
|
+
if (src.indexOf(location.host) !== -1) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
if (/(^\.)|(^\/)/.test(src)) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return src.indexOf('img_catch_success') !== -1;
|
|
111
|
+
};
|
|
112
|
+
var catchGo = false;
|
|
113
|
+
for (var i = 0; i < imgs.length; i++) {
|
|
114
|
+
if (notCatch(imgs[i].src)) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
for (var l = 0; l < allImgs.length; l++) {
|
|
118
|
+
if (allImgs[l].src == imgs[i].src) {
|
|
119
|
+
catchGo = true;
|
|
120
|
+
domUtils.setAttributes(allImgs[l], {
|
|
121
|
+
"src": load_src,
|
|
122
|
+
"_src": allImgs[l].src
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (catchGo) {
|
|
128
|
+
var _that$props$form;
|
|
129
|
+
// $('.submit').trigger('startHandlePostData', '正在抓取图片');
|
|
130
|
+
that.catching = true;
|
|
131
|
+
that.props.dataIndex && ((_that$props$form = that.props.form) === null || _that$props$form === void 0 ? void 0 : _that$props$form.validateFields([that.props.dataIndex]));
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
this.addListener("catchremotesuccess", function () {
|
|
135
|
+
var _that$props$form2;
|
|
136
|
+
that.catching = false;
|
|
137
|
+
that.props.dataIndex && ((_that$props$form2 = that.props.form) === null || _that$props$form2 === void 0 ? void 0 : _that$props$form2.validateFields([that.props.dataIndex]));
|
|
138
|
+
// $('.submit').trigger('endHandlePostData');
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// plugins/insert_richtext.js
|
|
144
|
+
/**
|
|
145
|
+
* 抓取微信富文本
|
|
146
|
+
*/
|
|
147
|
+
window.UE.plugin.register('insert_richtext', function () {
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
var me = this;
|
|
150
|
+
function filter(div) {
|
|
151
|
+
var domUtils = window.UE.dom.domUtils;
|
|
152
|
+
var browser = window.UE.browser;
|
|
153
|
+
var utils = window.UE.utils;
|
|
154
|
+
var html;
|
|
155
|
+
var ci;
|
|
156
|
+
if (div.firstChild) {
|
|
157
|
+
//去掉cut中添加的边界值
|
|
158
|
+
var nodes = domUtils.getElementsByTagName(div, 'span');
|
|
159
|
+
for (var i = 0, ni; ni = nodes[i++];) {
|
|
160
|
+
if (ni.id == '_baidu_cut_start' || ni.id == '_baidu_cut_end') {
|
|
161
|
+
domUtils.remove(ni);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (browser.webkit) {
|
|
165
|
+
var brs = div.querySelectorAll('div br');
|
|
166
|
+
for (var _i = 0, bi; bi = brs[_i++];) {
|
|
167
|
+
var pN = bi.parentNode;
|
|
168
|
+
if (pN) {
|
|
169
|
+
if (pN.tagName == 'DIV' && pN.childNodes.length == 1) {
|
|
170
|
+
pN.innerHTML = '<p><br/></p>';
|
|
171
|
+
domUtils.remove(pN);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
var divs = div.querySelectorAll('#baidu_pastebin');
|
|
176
|
+
for (var _i2 = 0, di; di = divs[_i2++];) {
|
|
177
|
+
var _di$parentNode;
|
|
178
|
+
var tmpP = me.document.createElement('p');
|
|
179
|
+
(_di$parentNode = di.parentNode) === null || _di$parentNode === void 0 || _di$parentNode.insertBefore(tmpP, di);
|
|
180
|
+
while (di.firstChild) {
|
|
181
|
+
tmpP.appendChild(di.firstChild);
|
|
182
|
+
}
|
|
183
|
+
domUtils.remove(di);
|
|
184
|
+
}
|
|
185
|
+
var metas = div.querySelectorAll('meta');
|
|
186
|
+
for (var _i3 = 0, _ci; _ci = metas[_i3++];) {
|
|
187
|
+
domUtils.remove(_ci);
|
|
188
|
+
}
|
|
189
|
+
brs = div.querySelectorAll('br');
|
|
190
|
+
for (var _i4 = 0; ci = brs[_i4++];) {
|
|
191
|
+
if (/^apple-/i.test(ci.className)) {
|
|
192
|
+
domUtils.remove(ci);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (browser.gecko) {
|
|
197
|
+
var dirtyNodes = div.querySelectorAll('[_moz_dirty]');
|
|
198
|
+
for (var _i5 = 0; ci = dirtyNodes[_i5++];) {
|
|
199
|
+
ci.removeAttribute('_moz_dirty');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (!browser.ie) {
|
|
203
|
+
var spans = div.querySelectorAll('span.Apple-style-span');
|
|
204
|
+
for (var _i6 = 0, _ci2; _ci2 = spans[_i6++];) {
|
|
205
|
+
domUtils.remove(_ci2, true);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
//ie下使用innerHTML会产生多余的\r\n字符,也会产生 这里过滤掉
|
|
210
|
+
html = div.innerHTML; //.replace(/>(?:(\s| )*?)</g,'><');
|
|
211
|
+
|
|
212
|
+
//过滤word粘贴过来的冗余属性
|
|
213
|
+
html = window.UE.filterWord(html);
|
|
214
|
+
//取消了忽略空白的第二个参数,粘贴过来的有些是有空白的,会被套上相关的标签
|
|
215
|
+
var root = window.UE.htmlparser(html);
|
|
216
|
+
|
|
217
|
+
//如果给了过滤规则就先进行过滤
|
|
218
|
+
if (me.options.filterRules) {
|
|
219
|
+
window.UE.filterNode(root, me.options.filterRules);
|
|
220
|
+
}
|
|
221
|
+
//执行默认的处理
|
|
222
|
+
me.filterInputRule(root);
|
|
223
|
+
//针对chrome的处理
|
|
224
|
+
if (browser.webkit) {
|
|
225
|
+
var br = root.lastChild();
|
|
226
|
+
if (br && br.type == 'element' && br.tagName == 'br') {
|
|
227
|
+
root.removeChild(br);
|
|
228
|
+
}
|
|
229
|
+
utils.each(me.body.querySelectorAll('div'), function (node) {
|
|
230
|
+
if (domUtils.isEmptyBlock(node)) {
|
|
231
|
+
domUtils.remove(node, true);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
html = {
|
|
236
|
+
'html': root.toHtml()
|
|
237
|
+
};
|
|
238
|
+
me.fireEvent('beforepaste', html, root);
|
|
239
|
+
//抢了默认的粘贴,那后边的内容就不执行了,比如表格粘贴
|
|
240
|
+
if (!html.html) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
root = window.UE.htmlparser(html.html, true);
|
|
244
|
+
//如果开启了纯文本模式
|
|
245
|
+
if (me.queryCommandState('pasteplain') === 1) {
|
|
246
|
+
me.execCommand('insertHtml', window.UE.filterNode(root, me.options.filterTxtRules).toHtml(), true);
|
|
247
|
+
} else {
|
|
248
|
+
//文本模式
|
|
249
|
+
window.UE.filterNode(root, me.options.filterTxtRules);
|
|
250
|
+
var txtContent = root.toHtml();
|
|
251
|
+
//完全模式
|
|
252
|
+
var htmlContent = html.html;
|
|
253
|
+
var address = me.selection.getRange().createAddress(true);
|
|
254
|
+
// @ts-ignore
|
|
255
|
+
me.execCommand('insertHtml', me.getOpt('retainOnlyLabelPasted') === true ? getPureHtml(htmlContent) : htmlContent, true);
|
|
256
|
+
}
|
|
257
|
+
me.fireEvent("afterpaste", html);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
bindEvents: {
|
|
262
|
+
'afterInsertRichText': function afterInsertRichText(e, html) {
|
|
263
|
+
var _that$props$form3;
|
|
264
|
+
me.execCommand('cleardoc');
|
|
265
|
+
filter.call(me, html);
|
|
266
|
+
me.document.body.innerHTML = "<section>".concat(html, "</section>");
|
|
267
|
+
me.fireEvent('catchremoteimage');
|
|
268
|
+
that.catching = true;
|
|
269
|
+
that.props.dataIndex && ((_that$props$form3 = that.props.form) === null || _that$props$form3 === void 0 ? void 0 : _that$props$form3.validateFields([that.props.dataIndex]));
|
|
270
|
+
// $('.submit').trigger('startHandlePostData', '正在抓取图片');
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
commands: {}
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
var config = _objectSpread(_objectSpread({}, (_this2$props$fieldPro = _this2.props.fieldProps) === null || _this2$props$fieldPro === void 0 ? void 0 : _this2$props$fieldPro.config), {}, {
|
|
277
|
+
forcecatchremote: typeof ((_this2$props$fieldPro2 = _this2.props.fieldProps) === null || _this2$props$fieldPro2 === void 0 || (_this2$props$fieldPro2 = _this2$props$fieldPro2.config) === null || _this2$props$fieldPro2 === void 0 ? void 0 : _this2$props$fieldPro2.forcecatchremote) === 'undefined' ? true : _this2.props.fieldProps.config.forcecatchremote
|
|
278
|
+
});
|
|
279
|
+
if ((_this2$modalContext = _this2.modalContext) !== null && _this2$modalContext !== void 0 && _this2$modalContext.inModal) {
|
|
280
|
+
config.zIndex = 2000;
|
|
281
|
+
config.topOffset = 0;
|
|
282
|
+
}
|
|
283
|
+
_this2.editor = window.UE.getEditor(_this2.state.containerId, config);
|
|
284
|
+
(_this2$editor = _this2.editor) === null || _this2$editor === void 0 || _this2$editor.ready(function () {
|
|
285
|
+
var _this2$editor4;
|
|
286
|
+
var value = _this2.props.config.value;
|
|
287
|
+
if (value) {
|
|
288
|
+
var _this2$editor2, _this2$props$form, _this2$editor3;
|
|
289
|
+
var div = document.createElement('div');
|
|
290
|
+
div.innerHTML = value;
|
|
291
|
+
(_this2$editor2 = _this2.editor) === null || _this2$editor2 === void 0 || _this2$editor2.setContent(div.innerText || '');
|
|
292
|
+
(_this2$props$form = _this2.props.form) === null || _this2$props$form === void 0 || _this2$props$form.setFieldValue(_this2.props.dataIndex, (_this2$editor3 = _this2.editor) === null || _this2$editor3 === void 0 ? void 0 : _this2$editor3.getContent());
|
|
293
|
+
}
|
|
294
|
+
(_this2$editor4 = _this2.editor) === null || _this2$editor4 === void 0 || _this2$editor4.addListener('contentChange', function () {
|
|
295
|
+
var _this2$props$form2, _this2$editor5;
|
|
296
|
+
(_this2$props$form2 = _this2.props.form) === null || _this2$props$form2 === void 0 || _this2$props$form2.setFieldValue(_this2.props.dataIndex, (_this2$editor5 = _this2.editor) === null || _this2$editor5 === void 0 ? void 0 : _this2$editor5.getContent());
|
|
297
|
+
});
|
|
298
|
+
_this2.setState({
|
|
299
|
+
loading: false
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}, {
|
|
305
|
+
key: "componentWillUnmount",
|
|
306
|
+
value: function componentWillUnmount() {
|
|
307
|
+
var _this$editor;
|
|
308
|
+
(_this$editor = this.editor) === null || _this$editor === void 0 || _this$editor.destroy();
|
|
309
|
+
}
|
|
310
|
+
}, {
|
|
311
|
+
key: "render",
|
|
312
|
+
value: function render() {
|
|
313
|
+
var _this3 = this;
|
|
314
|
+
return /*#__PURE__*/React.createElement(ModalContext.Consumer, null, function (modalContext) {
|
|
315
|
+
_this3.modalContext = modalContext;
|
|
316
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, filterObjectKeys(_this3.props, ['id', 'fieldProps', 'onChange', 'value', 'form', 'config', 'rules', 'ueditorPath', 'dataIndex']), {
|
|
317
|
+
ref: function ref(el) {
|
|
318
|
+
return _this3.containerRef = el;
|
|
319
|
+
}
|
|
320
|
+
}), /*#__PURE__*/React.createElement(Spin, {
|
|
321
|
+
spinning: _this3.state.loading
|
|
322
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
323
|
+
id: _this3.state.containerId,
|
|
324
|
+
style: {
|
|
325
|
+
width: _this3.state.width
|
|
326
|
+
}
|
|
327
|
+
})));
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}]);
|
|
331
|
+
return Ueditor;
|
|
332
|
+
}(Component);
|
|
333
|
+
export { Ueditor as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FormActionType } from "./types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export default function (props: FormActionType & {
|
|
4
|
+
props: any;
|
|
5
|
+
submit?: boolean | {
|
|
6
|
+
confirm?: string;
|
|
7
|
+
};
|
|
8
|
+
request?: RequestOptions;
|
|
9
|
+
link?: {
|
|
10
|
+
url: string;
|
|
11
|
+
};
|
|
12
|
+
back?: boolean;
|
|
13
|
+
reset?: boolean;
|
|
14
|
+
modal?: ModalOptions;
|
|
15
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _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; }
|
|
9
|
+
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); } }
|
|
10
|
+
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); }); }; }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
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."); }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
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; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
import { Button, Popconfirm } from "antd";
|
|
18
|
+
import React, { useContext, useEffect, useState } from "react";
|
|
19
|
+
import http from "../../../lib/http";
|
|
20
|
+
import { FormContext } from "../../FormContext";
|
|
21
|
+
import { modalShow, replaceParams, replaceUrl, routerNavigateTo } from "../../../lib/helpers";
|
|
22
|
+
import { ModalContext } from "../../ModalContext";
|
|
23
|
+
import { TableContext } from "../../TableContext";
|
|
24
|
+
export default function (props) {
|
|
25
|
+
var _props$request;
|
|
26
|
+
var _useState = useState(false),
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
loading = _useState2[0],
|
|
29
|
+
setLoading = _useState2[1];
|
|
30
|
+
var formContext = useContext(FormContext);
|
|
31
|
+
var tableContext = useContext(TableContext);
|
|
32
|
+
var modalContext = useContext(ModalContext);
|
|
33
|
+
var onClick = /*#__PURE__*/function () {
|
|
34
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
35
|
+
var handleAfterAction, _formContext$formRef, _formContext$formRef2, _formContext$formRef3, _formContext$formRef4, _formContext$formRef5;
|
|
36
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
37
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
_context2.prev = 0;
|
|
40
|
+
setLoading(true);
|
|
41
|
+
handleAfterAction = /*#__PURE__*/function () {
|
|
42
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
43
|
+
var _req$afterAction, _req$afterAction2;
|
|
44
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
45
|
+
while (1) switch (_context.prev = _context.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
if (!(req !== null && req !== void 0 && (_req$afterAction = req.afterAction) !== null && _req$afterAction !== void 0 && _req$afterAction.includes('tableReload'))) {
|
|
48
|
+
_context.next = 5;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
if (modalContext.contexts) {
|
|
52
|
+
modalContext.setAfterClose(function () {
|
|
53
|
+
var _modalContext$context;
|
|
54
|
+
(_modalContext$context = modalContext.contexts) === null || _modalContext$context === void 0 || (_modalContext$context = _modalContext$context.tableContext) === null || _modalContext$context === void 0 || _modalContext$context.actionRef.reload();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (!tableContext.actionRef) {
|
|
58
|
+
_context.next = 5;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
_context.next = 5;
|
|
62
|
+
return tableContext.actionRef.reload();
|
|
63
|
+
case 5:
|
|
64
|
+
if (req !== null && req !== void 0 && (_req$afterAction2 = req.afterAction) !== null && _req$afterAction2 !== void 0 && _req$afterAction2.includes('closeModal') && modalContext.inModal) {
|
|
65
|
+
modalContext.closeModal();
|
|
66
|
+
}
|
|
67
|
+
case 6:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee);
|
|
72
|
+
}));
|
|
73
|
+
return function handleAfterAction(_x) {
|
|
74
|
+
return _ref2.apply(this, arguments);
|
|
75
|
+
};
|
|
76
|
+
}();
|
|
77
|
+
if (!props.submit) {
|
|
78
|
+
_context2.next = 6;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
(_formContext$formRef = formContext.formRef) === null || _formContext$formRef === void 0 || (_formContext$formRef = _formContext$formRef.current) === null || _formContext$formRef === void 0 || _formContext$formRef.submit();
|
|
82
|
+
return _context2.abrupt("return");
|
|
83
|
+
case 6:
|
|
84
|
+
if (!props.request) {
|
|
85
|
+
_context2.next = 26;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
_context2.t0 = http;
|
|
89
|
+
_context2.t1 = props.request.method;
|
|
90
|
+
_context2.t2 = props.request.url;
|
|
91
|
+
_context2.t3 = props.request.headers || {};
|
|
92
|
+
_context2.t4 = replaceParams;
|
|
93
|
+
_context2.t5 = props.request.data || {};
|
|
94
|
+
_context2.t6 = _objectSpread;
|
|
95
|
+
_context2.t7 = {};
|
|
96
|
+
_context2.next = 17;
|
|
97
|
+
return (_formContext$formRef2 = formContext.formRef) === null || _formContext$formRef2 === void 0 || (_formContext$formRef2 = _formContext$formRef2.current) === null || _formContext$formRef2 === void 0 ? void 0 : _formContext$formRef2.getFieldsValue();
|
|
98
|
+
case 17:
|
|
99
|
+
_context2.t8 = _context2.sent;
|
|
100
|
+
_context2.t9 = (0, _context2.t6)(_context2.t7, _context2.t8);
|
|
101
|
+
_context2.t10 = (0, _context2.t4)(_context2.t5, _context2.t9);
|
|
102
|
+
_context2.t11 = {
|
|
103
|
+
method: _context2.t1,
|
|
104
|
+
url: _context2.t2,
|
|
105
|
+
headers: _context2.t3,
|
|
106
|
+
data: _context2.t10
|
|
107
|
+
};
|
|
108
|
+
_context2.next = 23;
|
|
109
|
+
return (0, _context2.t0)(_context2.t11);
|
|
110
|
+
case 23:
|
|
111
|
+
_context2.next = 25;
|
|
112
|
+
return handleAfterAction(props.request);
|
|
113
|
+
case 25:
|
|
114
|
+
return _context2.abrupt("return");
|
|
115
|
+
case 26:
|
|
116
|
+
if (!props.modal) {
|
|
117
|
+
_context2.next = 30;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
_context2.next = 29;
|
|
121
|
+
return modalShow(_objectSpread(_objectSpread({}, props.modal), {}, {
|
|
122
|
+
content: _objectSpread(_objectSpread({}, props.modal.content), {}, {
|
|
123
|
+
url: replaceUrl(props.modal.content.url, (_formContext$formRef3 = formContext.formRef) === null || _formContext$formRef3 === void 0 || (_formContext$formRef3 = _formContext$formRef3.current) === null || _formContext$formRef3 === void 0 ? void 0 : _formContext$formRef3.getFieldsValue())
|
|
124
|
+
})
|
|
125
|
+
}));
|
|
126
|
+
case 29:
|
|
127
|
+
return _context2.abrupt("return");
|
|
128
|
+
case 30:
|
|
129
|
+
if (!props.link) {
|
|
130
|
+
_context2.next = 40;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
_context2.t12 = routerNavigateTo;
|
|
134
|
+
_context2.t13 = replaceUrl;
|
|
135
|
+
_context2.t14 = props.link.url;
|
|
136
|
+
_context2.next = 36;
|
|
137
|
+
return (_formContext$formRef4 = formContext.formRef) === null || _formContext$formRef4 === void 0 || (_formContext$formRef4 = _formContext$formRef4.current) === null || _formContext$formRef4 === void 0 ? void 0 : _formContext$formRef4.getFieldsValue();
|
|
138
|
+
case 36:
|
|
139
|
+
_context2.t15 = _context2.sent;
|
|
140
|
+
_context2.t16 = (0, _context2.t13)(_context2.t14, _context2.t15);
|
|
141
|
+
(0, _context2.t12)(_context2.t16);
|
|
142
|
+
return _context2.abrupt("return");
|
|
143
|
+
case 40:
|
|
144
|
+
if (!props.reset) {
|
|
145
|
+
_context2.next = 43;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
(_formContext$formRef5 = formContext.formRef) === null || _formContext$formRef5 === void 0 || (_formContext$formRef5 = _formContext$formRef5.current) === null || _formContext$formRef5 === void 0 || _formContext$formRef5.resetFields();
|
|
149
|
+
return _context2.abrupt("return");
|
|
150
|
+
case 43:
|
|
151
|
+
if (!props.back) {
|
|
152
|
+
_context2.next = 46;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
if (modalContext.inModal) {
|
|
156
|
+
modalContext.closeModal();
|
|
157
|
+
} else {
|
|
158
|
+
history.back();
|
|
159
|
+
}
|
|
160
|
+
return _context2.abrupt("return");
|
|
161
|
+
case 46:
|
|
162
|
+
_context2.prev = 46;
|
|
163
|
+
setLoading(false);
|
|
164
|
+
return _context2.finish(46);
|
|
165
|
+
case 49:
|
|
166
|
+
case "end":
|
|
167
|
+
return _context2.stop();
|
|
168
|
+
}
|
|
169
|
+
}, _callee2, null, [[0,, 46, 49]]);
|
|
170
|
+
}));
|
|
171
|
+
return function onClick() {
|
|
172
|
+
return _ref.apply(this, arguments);
|
|
173
|
+
};
|
|
174
|
+
}();
|
|
175
|
+
useEffect(function () {
|
|
176
|
+
if (props.submit) {
|
|
177
|
+
setLoading(props.loading || false);
|
|
178
|
+
}
|
|
179
|
+
}, [props.loading]);
|
|
180
|
+
var MyButton = function MyButton(_ref3) {
|
|
181
|
+
var onClick = _ref3.onClick;
|
|
182
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({}, props.props, {
|
|
183
|
+
onClick: onClick,
|
|
184
|
+
loading: loading
|
|
185
|
+
}), props.title));
|
|
186
|
+
};
|
|
187
|
+
var confirm = (_typeof(props.submit) === 'object' ? props.submit.confirm : null) || ((_props$request = props.request) === null || _props$request === void 0 ? void 0 : _props$request.confirm);
|
|
188
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, confirm ? /*#__PURE__*/React.createElement(Popconfirm, {
|
|
189
|
+
title: confirm,
|
|
190
|
+
onConfirm: onClick
|
|
191
|
+
}, /*#__PURE__*/React.createElement(MyButton, null)) : /*#__PURE__*/React.createElement(MyButton, {
|
|
192
|
+
onClick: onClick
|
|
193
|
+
}));
|
|
194
|
+
}
|