@lemon-fe/kits 1.4.29 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/app-provider/index.js +10 -5
- package/es/components/app-portal/index.d.ts +19 -0
- package/es/components/app-portal/index.js +3 -0
- package/es/hooks/use-batch-operator/index.d.ts +4 -0
- package/es/hooks/use-batch-operator/index.js +63 -56
- package/es/hooks/use-render-modal/index.d.ts +4 -0
- package/es/hooks/use-render-modal/index.js +18 -0
- package/package.json +2 -2
package/es/app-provider/index.js
CHANGED
|
@@ -11,6 +11,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
11
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
import React, { createContext, useMemo, useContext, useCallback } from 'react';
|
|
14
|
+
import AppPortal from "../components/app-portal";
|
|
14
15
|
import { PageLoading, message, Modal, ConfigProvider, Result, Button, RequestErrorMessage } from '@lemon-fe/components';
|
|
15
16
|
import { HooksConfigProvider, useLatestRef } from '@lemon-fe/hooks';
|
|
16
17
|
import { isRequestError } from '@lemon-fe/utils';
|
|
@@ -118,12 +119,16 @@ export default function AppProvider(props) {
|
|
|
118
119
|
}, props.hooksConfig);
|
|
119
120
|
return result;
|
|
120
121
|
}, [props.hooksConfig, locale, _showError]);
|
|
121
|
-
return /*#__PURE__*/
|
|
122
|
+
return /*#__PURE__*/_jsx(AppContext.Provider, {
|
|
122
123
|
value: appContext,
|
|
123
|
-
children:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
children: /*#__PURE__*/_jsxs(AppPortal.Host, {
|
|
125
|
+
children: [/*#__PURE__*/_jsx(AppPortal.Slot, {
|
|
126
|
+
slot: "modal"
|
|
127
|
+
}), messageContextHolder, modalContextHolder, /*#__PURE__*/_jsx(HooksConfigProvider, {
|
|
128
|
+
value: hooksConfig,
|
|
129
|
+
children: props.children
|
|
130
|
+
})]
|
|
131
|
+
})
|
|
127
132
|
});
|
|
128
133
|
}
|
|
129
134
|
AppProvider.useApp = useApp;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const AppPortal: {
|
|
3
|
+
(props: {
|
|
4
|
+
children: import("react").ReactNode;
|
|
5
|
+
slot: string;
|
|
6
|
+
}): null;
|
|
7
|
+
Host: (props: {
|
|
8
|
+
children: import("react").ReactNode;
|
|
9
|
+
}) => JSX.Element;
|
|
10
|
+
Slot: import("react").NamedExoticComponent<{
|
|
11
|
+
slot: string;
|
|
12
|
+
render?: ((children: import("react").ReactNode) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
usePortal: (slot: string) => {
|
|
15
|
+
add: (node: import("react").ReactNode) => void;
|
|
16
|
+
remove: () => void;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default AppPortal;
|
|
@@ -121,6 +121,10 @@ interface Props<RecordType extends Record<string, any> = Record<string, any>, Re
|
|
|
121
121
|
* @description 并发数
|
|
122
122
|
*/
|
|
123
123
|
concurrency?: number;
|
|
124
|
+
/**
|
|
125
|
+
* 处理结果列配置
|
|
126
|
+
*/
|
|
127
|
+
resultColType?: Partial<ColType<RecordType>>;
|
|
124
128
|
}
|
|
125
129
|
export default function useBatchOperate<RecordType extends Record<string, any> = Record<string, any>, ResultType = any, ParamsType = any>(options: Props<RecordType, ResultType, ParamsType>): {
|
|
126
130
|
run: (rows: RecordType[], otherOpts?: Partial<Props<RecordType, ResultType, ParamsType>>) => void;
|
|
@@ -2,18 +2,18 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
function _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; }
|
|
5
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
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; } }
|
|
8
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
5
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
6
|
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."); }
|
|
11
|
-
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); }
|
|
12
7
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
13
8
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
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); } }
|
|
16
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
17
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
18
|
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); } }
|
|
19
19
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -27,13 +27,13 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
27
27
|
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; }
|
|
28
28
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
29
29
|
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); }
|
|
30
|
-
import { Tooltip } from 'antd';
|
|
30
|
+
import { ConfigProvider, Tooltip } from 'antd';
|
|
31
31
|
import React, { useContext, Component, createRef } from 'react';
|
|
32
|
-
import { unmountComponentAtNode, render } from 'react-dom';
|
|
33
32
|
import { AppContext } from "../../app-provider";
|
|
33
|
+
import useRenderModal from "../use-render-modal";
|
|
34
34
|
import defaultLocale from "./locale/zh_CN";
|
|
35
|
-
import {
|
|
36
|
-
import { Actions,
|
|
35
|
+
import { ComponentConfigureContext, Modal, Row, Spin, Typography } from '@lemon-fe/components';
|
|
36
|
+
import { Actions, DataGrid, Icons, Layout, Section } from '@lemon-fe/components';
|
|
37
37
|
import { Subject } from '@lemon-fe/utils';
|
|
38
38
|
import { get } from 'lodash';
|
|
39
39
|
import PQueue from 'p-queue';
|
|
@@ -94,12 +94,23 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
94
94
|
_defineProperty(_assertThisInitialized(_this), "executeUntilBlocked", function () {
|
|
95
95
|
var results = _this.state.results;
|
|
96
96
|
var params = _this.props.params;
|
|
97
|
-
results.
|
|
97
|
+
_this.queue.addAll(Array.from(results.entries()).flatMap(function (_ref) {
|
|
98
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
99
|
+
id = _ref2[0],
|
|
100
|
+
result = _ref2[1];
|
|
98
101
|
if (!result.loading && result.error && result.stepIdx !== undefined) {
|
|
99
102
|
var stepIdx = result.stepIdx;
|
|
100
|
-
|
|
103
|
+
return [function () {
|
|
104
|
+
return new Promise(function (res) {
|
|
105
|
+
_this.processNode(id, stepIdx, params, function () {
|
|
106
|
+
res();
|
|
107
|
+
}, true);
|
|
108
|
+
});
|
|
109
|
+
}];
|
|
101
110
|
}
|
|
102
|
-
|
|
111
|
+
return [];
|
|
112
|
+
}));
|
|
113
|
+
_this.queue.start();
|
|
103
114
|
});
|
|
104
115
|
_defineProperty(_assertThisInitialized(_this), "handleClose", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
105
116
|
var _this$props, onBeforeClose, onClose, data, results, value;
|
|
@@ -109,10 +120,10 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
109
120
|
_this$props = _this.props, onBeforeClose = _this$props.onBeforeClose, onClose = _this$props.onClose;
|
|
110
121
|
data = _this.state.data;
|
|
111
122
|
results = new Map();
|
|
112
|
-
_toConsumableArray(_this.state.results).forEach(function (
|
|
113
|
-
var
|
|
114
|
-
key =
|
|
115
|
-
item =
|
|
123
|
+
_toConsumableArray(_this.state.results).forEach(function (_ref4) {
|
|
124
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
125
|
+
key = _ref5[0],
|
|
126
|
+
item = _ref5[1];
|
|
116
127
|
if (!item.loading) {
|
|
117
128
|
results.set(key, item.result || item.error);
|
|
118
129
|
}
|
|
@@ -138,9 +149,9 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
138
149
|
open: false
|
|
139
150
|
});
|
|
140
151
|
if (onClose) {
|
|
141
|
-
value = _toConsumableArray(results).filter(function (
|
|
142
|
-
var
|
|
143
|
-
val =
|
|
152
|
+
value = _toConsumableArray(results).filter(function (_ref6) {
|
|
153
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
154
|
+
val = _ref7[1];
|
|
144
155
|
return !_this.isError(val);
|
|
145
156
|
});
|
|
146
157
|
onClose(new Map(value), {
|
|
@@ -441,16 +452,16 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
441
452
|
var mProcess = [];
|
|
442
453
|
if (_handler) {
|
|
443
454
|
mProcess = [{
|
|
444
|
-
handler: function handler(
|
|
445
|
-
var data =
|
|
446
|
-
payload =
|
|
455
|
+
handler: function handler(_ref8) {
|
|
456
|
+
var data = _ref8.data,
|
|
457
|
+
payload = _ref8.payload;
|
|
447
458
|
return _handler(data, params, payload);
|
|
448
459
|
},
|
|
449
|
-
render: function render(
|
|
450
|
-
var data =
|
|
451
|
-
error =
|
|
452
|
-
result =
|
|
453
|
-
next =
|
|
460
|
+
render: function render(_ref9) {
|
|
461
|
+
var data = _ref9.data,
|
|
462
|
+
error = _ref9.error,
|
|
463
|
+
result = _ref9.result,
|
|
464
|
+
next = _ref9.next;
|
|
454
465
|
var reload = function reload(payload) {
|
|
455
466
|
next({
|
|
456
467
|
type: 'restart',
|
|
@@ -535,12 +546,13 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
535
546
|
resultStateText = _this$locale2.resultStateText,
|
|
536
547
|
pendingStateText = _this$locale2.pendingStateText,
|
|
537
548
|
progressStateText = _this$locale2.progressStateText;
|
|
549
|
+
var resultColType = this.props.resultColType;
|
|
538
550
|
var cols = columns ? _toConsumableArray(columns) : [{
|
|
539
551
|
title: indexText,
|
|
540
552
|
colId: 'id',
|
|
541
553
|
dataIndex: typeof rowKey === 'string' ? rowKey : undefined,
|
|
542
|
-
render: function render(val, record, idx,
|
|
543
|
-
var node =
|
|
554
|
+
render: function render(val, record, idx, _ref10) {
|
|
555
|
+
var node = _ref10.node;
|
|
544
556
|
return node.id;
|
|
545
557
|
}
|
|
546
558
|
}];
|
|
@@ -557,10 +569,10 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
557
569
|
lockVisible: true,
|
|
558
570
|
resizable: false,
|
|
559
571
|
suppressColumnsToolPanel: true,
|
|
560
|
-
render: function render(val, record, idx,
|
|
561
|
-
var context =
|
|
562
|
-
node =
|
|
563
|
-
api =
|
|
572
|
+
render: function render(val, record, idx, _ref11) {
|
|
573
|
+
var context = _ref11.context,
|
|
574
|
+
node = _ref11.node,
|
|
575
|
+
api = _ref11.api;
|
|
564
576
|
var key = node.id;
|
|
565
577
|
return /*#__PURE__*/_jsx(Icons.Delete, {
|
|
566
578
|
onClick: function onClick() {
|
|
@@ -591,7 +603,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
591
603
|
});
|
|
592
604
|
}
|
|
593
605
|
});
|
|
594
|
-
cols.push({
|
|
606
|
+
cols.push(_objectSpread({
|
|
595
607
|
title: resultStateText,
|
|
596
608
|
colId: '$$result',
|
|
597
609
|
flex: 1,
|
|
@@ -630,17 +642,17 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
630
642
|
}
|
|
631
643
|
return null;
|
|
632
644
|
}
|
|
633
|
-
});
|
|
645
|
+
}, resultColType));
|
|
634
646
|
return cols;
|
|
635
647
|
}
|
|
636
648
|
}, {
|
|
637
649
|
key: "getError",
|
|
638
650
|
value: function getError() {
|
|
639
651
|
var res = new Map();
|
|
640
|
-
_toConsumableArray(this.state.results).forEach(function (
|
|
641
|
-
var
|
|
642
|
-
key =
|
|
643
|
-
item =
|
|
652
|
+
_toConsumableArray(this.state.results).forEach(function (_ref12) {
|
|
653
|
+
var _ref13 = _slicedToArray(_ref12, 2),
|
|
654
|
+
key = _ref13[0],
|
|
655
|
+
item = _ref13[1];
|
|
644
656
|
if (!item.loading) {
|
|
645
657
|
res.set(key, item.result || item.error);
|
|
646
658
|
}
|
|
@@ -749,8 +761,6 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
749
761
|
},
|
|
750
762
|
columns: cols,
|
|
751
763
|
rowKey: rowKey,
|
|
752
|
-
localeText: this.props.locale.DataGrid.localeText,
|
|
753
|
-
locale: this.props.locale.DataGrid,
|
|
754
764
|
sideBar: sideBar,
|
|
755
765
|
customColumnPanelStorage: customColumnPanelStorage
|
|
756
766
|
})
|
|
@@ -762,31 +772,28 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
762
772
|
return BatchOperate;
|
|
763
773
|
}(Component);
|
|
764
774
|
export default function useBatchOperate(options) {
|
|
765
|
-
var ctx = useContext(ConfigProvider.ConfigContext);
|
|
766
|
-
var componentCtx = useContext(ComponentConfigureContext);
|
|
767
775
|
var _useContext = useContext(AppContext),
|
|
768
776
|
batchOperatorConfig = _useContext.batchOperatorConfig;
|
|
777
|
+
var ctx = useContext(ConfigProvider.ConfigContext);
|
|
778
|
+
var componentCtx = useContext(ComponentConfigureContext);
|
|
779
|
+
var locale = ctx.locale;
|
|
780
|
+
var renderModal = useRenderModal();
|
|
769
781
|
var run = function run(rows) {
|
|
770
782
|
var otherOpts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
locale = ctx.locale;
|
|
775
|
-
render( /*#__PURE__*/_jsx(ConfigProvider, {
|
|
776
|
-
prefixCls: getPrefixCls(),
|
|
777
|
-
iconPrefixCls: iconPrefixCls,
|
|
778
|
-
children: /*#__PURE__*/_jsx(ComponentConfigureContext.Provider, {
|
|
783
|
+
return renderModal(function (_ref14) {
|
|
784
|
+
var _afterClose2 = _ref14.afterClose;
|
|
785
|
+
return /*#__PURE__*/_jsx(ComponentConfigureContext.Provider, {
|
|
779
786
|
value: componentCtx,
|
|
780
787
|
children: /*#__PURE__*/_jsx(BatchOperate, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
781
788
|
rows: rows
|
|
782
|
-
},
|
|
789
|
+
}, batchOperatorConfig), options), otherOpts), {}, {
|
|
783
790
|
locale: locale,
|
|
784
791
|
afterClose: function afterClose() {
|
|
785
|
-
|
|
792
|
+
_afterClose2();
|
|
786
793
|
}
|
|
787
794
|
}))
|
|
788
|
-
})
|
|
789
|
-
})
|
|
795
|
+
});
|
|
796
|
+
});
|
|
790
797
|
};
|
|
791
798
|
return {
|
|
792
799
|
run: run,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import AppPortal from "../../components/app-portal";
|
|
4
|
+
import { uniqueId } from 'lodash';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export default function useRenderModal() {
|
|
7
|
+
var portal = AppPortal.usePortal('modal');
|
|
8
|
+
return useCallback(function (render) {
|
|
9
|
+
var key = uniqueId('use-render-modal');
|
|
10
|
+
portal.add( /*#__PURE__*/_jsx(React.Fragment, {
|
|
11
|
+
children: render({
|
|
12
|
+
afterClose: function afterClose() {
|
|
13
|
+
portal.remove();
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
}, key));
|
|
17
|
+
}, []);
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/kits",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"registry": "https://registry.npmjs.org"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "781302ee24991559affd0c16e83cca2ce5bb8c5e"
|
|
51
51
|
}
|