@quansitech/antd-admin 1.1.1 → 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 +13 -6
- 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 -251
- 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 -149
- 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,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MenuDataItem } from "@ant-design/pro-components";
|
|
3
|
+
declare type LayoutContextValue = {
|
|
4
|
+
assignProps: (props: LayoutProps) => void;
|
|
5
|
+
props: LayoutProps;
|
|
6
|
+
};
|
|
7
|
+
export declare type LayoutProps = {
|
|
8
|
+
title?: string;
|
|
9
|
+
metaTitle?: string;
|
|
10
|
+
topMenuActiveKey?: string;
|
|
11
|
+
menuActiveKey?: string;
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
topMenu?: {
|
|
14
|
+
name: string;
|
|
15
|
+
key: string;
|
|
16
|
+
}[];
|
|
17
|
+
menuList?: MenuDataItem[];
|
|
18
|
+
logo?: string;
|
|
19
|
+
userMenu?: {
|
|
20
|
+
title: string;
|
|
21
|
+
url: string;
|
|
22
|
+
type: string;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
export declare const LayoutContext: import("react").Context<LayoutContextValue>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type ModalContextProps = {
|
|
3
|
+
inModal: boolean;
|
|
4
|
+
closeModal: () => void;
|
|
5
|
+
contexts?: Record<string, any>;
|
|
6
|
+
setAfterClose(callback: () => void): void;
|
|
7
|
+
};
|
|
8
|
+
export declare const ModalContext: import("react").Context<ModalContextProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TableActionProps } from "./types";
|
|
3
|
+
export default function (props: TableActionProps & {
|
|
4
|
+
props: Record<string, any>;
|
|
5
|
+
link?: {
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
request?: RequestOptions;
|
|
9
|
+
modal?: ModalOptions;
|
|
10
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,166 @@
|
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
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."); }
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
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
|
+
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; }
|
|
10
|
+
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); } }
|
|
11
|
+
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); }); }; }
|
|
12
|
+
import { Button, Popconfirm } from "antd";
|
|
13
|
+
import React, { useContext, useEffect, useState } from "react";
|
|
14
|
+
import { TableContext } from "../../TableContext";
|
|
15
|
+
import http from "../../../lib/http";
|
|
16
|
+
import { modalShow, routerNavigateTo } from "../../../lib/helpers";
|
|
17
|
+
export default function (props) {
|
|
18
|
+
var tableContext = useContext(TableContext);
|
|
19
|
+
var onClick = /*#__PURE__*/function () {
|
|
20
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
21
|
+
var _tableContext$actionR;
|
|
22
|
+
var rowKey, data, _props$selectedRows, _loop, _ret, key;
|
|
23
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
24
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
25
|
+
case 0:
|
|
26
|
+
rowKey = tableContext.getTableProps().rowKey;
|
|
27
|
+
if (!props.link) {
|
|
28
|
+
_context2.next = 4;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
routerNavigateTo(props.link.url);
|
|
32
|
+
return _context2.abrupt("return");
|
|
33
|
+
case 4:
|
|
34
|
+
if (!props.request) {
|
|
35
|
+
_context2.next = 26;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
setLoading(true);
|
|
39
|
+
data = props.request.data || {};
|
|
40
|
+
if (!props.relateSelection) {
|
|
41
|
+
_context2.next = 19;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
data.selection = (_props$selectedRows = props.selectedRows) === null || _props$selectedRows === void 0 ? void 0 : _props$selectedRows.map(function (item) {
|
|
45
|
+
return item[rowKey];
|
|
46
|
+
});
|
|
47
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
48
|
+
var _props$selectedRows2;
|
|
49
|
+
var matches;
|
|
50
|
+
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
if (!(typeof data[key] !== 'string')) {
|
|
54
|
+
_context.next = 2;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
return _context.abrupt("return", 0);
|
|
58
|
+
case 2:
|
|
59
|
+
matches = data[key].match(/^__(\w+)__$/);
|
|
60
|
+
if (matches) {
|
|
61
|
+
_context.next = 5;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
return _context.abrupt("return", 0);
|
|
65
|
+
case 5:
|
|
66
|
+
data[key] = (_props$selectedRows2 = props.selectedRows) === null || _props$selectedRows2 === void 0 ? void 0 : _props$selectedRows2.map(function (item) {
|
|
67
|
+
return item[matches[1]];
|
|
68
|
+
});
|
|
69
|
+
case 6:
|
|
70
|
+
case "end":
|
|
71
|
+
return _context.stop();
|
|
72
|
+
}
|
|
73
|
+
}, _loop);
|
|
74
|
+
});
|
|
75
|
+
_context2.t0 = _regeneratorRuntime().keys(data);
|
|
76
|
+
case 11:
|
|
77
|
+
if ((_context2.t1 = _context2.t0()).done) {
|
|
78
|
+
_context2.next = 19;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
key = _context2.t1.value;
|
|
82
|
+
return _context2.delegateYield(_loop(), "t2", 14);
|
|
83
|
+
case 14:
|
|
84
|
+
_ret = _context2.t2;
|
|
85
|
+
if (!(_ret === 0)) {
|
|
86
|
+
_context2.next = 17;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
return _context2.abrupt("continue", 11);
|
|
90
|
+
case 17:
|
|
91
|
+
_context2.next = 11;
|
|
92
|
+
break;
|
|
93
|
+
case 19:
|
|
94
|
+
_context2.prev = 19;
|
|
95
|
+
_context2.next = 22;
|
|
96
|
+
return http({
|
|
97
|
+
url: props.request.url,
|
|
98
|
+
method: props.request.method,
|
|
99
|
+
headers: props.request.headers || {},
|
|
100
|
+
data: data
|
|
101
|
+
});
|
|
102
|
+
case 22:
|
|
103
|
+
_context2.prev = 22;
|
|
104
|
+
setLoading(false);
|
|
105
|
+
return _context2.finish(22);
|
|
106
|
+
case 25:
|
|
107
|
+
return _context2.abrupt("return");
|
|
108
|
+
case 26:
|
|
109
|
+
if (!props.modal) {
|
|
110
|
+
_context2.next = 30;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
_context2.next = 29;
|
|
114
|
+
return modalShow(props.modal);
|
|
115
|
+
case 29:
|
|
116
|
+
return _context2.abrupt("return");
|
|
117
|
+
case 30:
|
|
118
|
+
_context2.next = 32;
|
|
119
|
+
return (_tableContext$actionR = tableContext.actionRef) === null || _tableContext$actionR === void 0 ? void 0 : _tableContext$actionR.reload();
|
|
120
|
+
case 32:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context2.stop();
|
|
123
|
+
}
|
|
124
|
+
}, _callee, null, [[19,, 22, 25]]);
|
|
125
|
+
}));
|
|
126
|
+
return function onClick() {
|
|
127
|
+
return _ref.apply(this, arguments);
|
|
128
|
+
};
|
|
129
|
+
}();
|
|
130
|
+
var _useState = useState(false),
|
|
131
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
132
|
+
loading = _useState2[0],
|
|
133
|
+
setLoading = _useState2[1];
|
|
134
|
+
var _useState3 = useState(props.props.disabled),
|
|
135
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
136
|
+
disabled = _useState4[0],
|
|
137
|
+
setDisabled = _useState4[1];
|
|
138
|
+
useEffect(function () {
|
|
139
|
+
var _props$selectedRows3;
|
|
140
|
+
if (!props.relateSelection) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
setDisabled(((_props$selectedRows3 = props.selectedRows) === null || _props$selectedRows3 === void 0 ? void 0 : _props$selectedRows3.length) === 0);
|
|
144
|
+
}, [props.selectedRows]);
|
|
145
|
+
var ButtonComponent = function ButtonComponent() {
|
|
146
|
+
var _props$request;
|
|
147
|
+
if ((_props$request = props.request) !== null && _props$request !== void 0 && _props$request.confirm) {
|
|
148
|
+
return /*#__PURE__*/React.createElement(Popconfirm, {
|
|
149
|
+
title: props.request.confirm,
|
|
150
|
+
onConfirm: onClick
|
|
151
|
+
}, /*#__PURE__*/React.createElement(Button, _extends({
|
|
152
|
+
loading: loading
|
|
153
|
+
}, props.props, {
|
|
154
|
+
disabled: disabled
|
|
155
|
+
}), props.title));
|
|
156
|
+
} else {
|
|
157
|
+
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
158
|
+
loading: loading,
|
|
159
|
+
onClick: onClick
|
|
160
|
+
}, props.props, {
|
|
161
|
+
disabled: disabled
|
|
162
|
+
}), props.title);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ButtonComponent, null));
|
|
166
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ButtonProps } from "antd";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { TableActionProps } from "./types";
|
|
4
|
+
export default function (props: TableActionProps & {
|
|
5
|
+
props: ButtonProps;
|
|
6
|
+
saveRequest: {
|
|
7
|
+
url: string;
|
|
8
|
+
method: string;
|
|
9
|
+
};
|
|
10
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,79 @@
|
|
|
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 _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 asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
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."); }
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
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; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
import { Button, Space } from "antd";
|
|
13
|
+
import { TableContext } from "../../TableContext";
|
|
14
|
+
import React, { useContext, useState } from "react";
|
|
15
|
+
import http from "../../../lib/http";
|
|
16
|
+
export default function (props) {
|
|
17
|
+
var tableContext = useContext(TableContext);
|
|
18
|
+
var onStartClick = function onStartClick() {
|
|
19
|
+
var rowKey = tableContext.getTableProps().rowKey;
|
|
20
|
+
tableContext.getTableProps().dataSource.map(function (item) {
|
|
21
|
+
var _tableContext$actionR;
|
|
22
|
+
(_tableContext$actionR = tableContext.actionRef) === null || _tableContext$actionR === void 0 || _tableContext$actionR.startEditable(item[rowKey], item);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var onCancelClick = function onCancelClick() {
|
|
26
|
+
var rowKey = tableContext.getTableProps().rowKey;
|
|
27
|
+
tableContext.getTableProps().dataSource.map(function (item) {
|
|
28
|
+
var _tableContext$actionR2;
|
|
29
|
+
(_tableContext$actionR2 = tableContext.actionRef) === null || _tableContext$actionR2 === void 0 || _tableContext$actionR2.cancelEditable(item[rowKey]);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var _useState = useState(false),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
loading = _useState2[0],
|
|
35
|
+
setLoading = _useState2[1];
|
|
36
|
+
var onSaveClick = /*#__PURE__*/function () {
|
|
37
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
38
|
+
var _tableContext$actionR3;
|
|
39
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
40
|
+
while (1) switch (_context.prev = _context.next) {
|
|
41
|
+
case 0:
|
|
42
|
+
setLoading(true);
|
|
43
|
+
_context.prev = 1;
|
|
44
|
+
_context.next = 4;
|
|
45
|
+
return http({
|
|
46
|
+
method: props.saveRequest.method,
|
|
47
|
+
url: props.saveRequest.url,
|
|
48
|
+
data: tableContext.getEditedValues()
|
|
49
|
+
});
|
|
50
|
+
case 4:
|
|
51
|
+
_context.next = 6;
|
|
52
|
+
return (_tableContext$actionR3 = tableContext.actionRef) === null || _tableContext$actionR3 === void 0 ? void 0 : _tableContext$actionR3.reload();
|
|
53
|
+
case 6:
|
|
54
|
+
_context.prev = 6;
|
|
55
|
+
setLoading(false);
|
|
56
|
+
return _context.finish(6);
|
|
57
|
+
case 9:
|
|
58
|
+
onCancelClick();
|
|
59
|
+
case 10:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}, _callee, null, [[1,, 6, 9]]);
|
|
64
|
+
}));
|
|
65
|
+
return function onSaveClick() {
|
|
66
|
+
return _ref.apply(this, arguments);
|
|
67
|
+
};
|
|
68
|
+
}();
|
|
69
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, tableContext.editableKeys.length > 0 ? /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
|
|
70
|
+
loading: loading,
|
|
71
|
+
type: 'primary',
|
|
72
|
+
onClick: onSaveClick
|
|
73
|
+
}, "\u4FDD\u5B58"), /*#__PURE__*/React.createElement(Button, {
|
|
74
|
+
danger: true,
|
|
75
|
+
onClick: onCancelClick
|
|
76
|
+
}, "\u53D6\u6D88")) : /*#__PURE__*/React.createElement(Button, _extends({}, props.props, {
|
|
77
|
+
onClick: onStartClick
|
|
78
|
+
}), props.title));
|
|
79
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
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; }
|
|
12
|
+
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; } }
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
import React, { lazy, useEffect, useState } from "react";
|
|
15
|
+
import container from "../../lib/container";
|
|
16
|
+
import { Badge, Space } from "antd";
|
|
17
|
+
import { upperFirst } from "es-toolkit";
|
|
18
|
+
export default function (_ref) {
|
|
19
|
+
var actions = _ref.actions,
|
|
20
|
+
selectedRows = _ref.selectedRows;
|
|
21
|
+
var _useState = useState([]),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
components = _useState2[0],
|
|
24
|
+
setComponents = _useState2[1];
|
|
25
|
+
useEffect(function () {
|
|
26
|
+
setComponents(actions.map(function (a) {
|
|
27
|
+
return {
|
|
28
|
+
Component: /*#__PURE__*/lazy(function () {
|
|
29
|
+
return container.get('Table.Action.' + upperFirst(a.type));
|
|
30
|
+
}),
|
|
31
|
+
props: _objectSpread({}, a)
|
|
32
|
+
};
|
|
33
|
+
}));
|
|
34
|
+
}, []);
|
|
35
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Space, {
|
|
36
|
+
wrap: true
|
|
37
|
+
}, components.map(function (c) {
|
|
38
|
+
return c.props.badge ? /*#__PURE__*/React.createElement(Badge, {
|
|
39
|
+
key: c.props.title,
|
|
40
|
+
count: c.props.badge,
|
|
41
|
+
style: {
|
|
42
|
+
zIndex: 100
|
|
43
|
+
}
|
|
44
|
+
}, /*#__PURE__*/React.createElement(c.Component, _extends({}, c.props, {
|
|
45
|
+
selectedRows: selectedRows
|
|
46
|
+
}))) : /*#__PURE__*/React.createElement(c.Component, _extends({
|
|
47
|
+
key: c.props.title
|
|
48
|
+
}, c.props, {
|
|
49
|
+
selectedRows: selectedRows
|
|
50
|
+
}));
|
|
51
|
+
})));
|
|
52
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ProColumnType, ProTableProps } from "@ant-design/pro-components";
|
|
3
|
+
import { TablePaginationConfig } from "antd/es/table";
|
|
4
|
+
import { TableActionProps } from "./Table/Action/types";
|
|
5
|
+
import "./Table.scss";
|
|
6
|
+
export type TableProps = ProTableProps<any, any> & {
|
|
7
|
+
columns: ProColumnType[];
|
|
8
|
+
dataSource: any[];
|
|
9
|
+
pagination: TablePaginationConfig & {
|
|
10
|
+
paramName?: string;
|
|
11
|
+
};
|
|
12
|
+
rowKey: string;
|
|
13
|
+
defaultSearchValue?: Record<string, any>;
|
|
14
|
+
actions: TableActionProps[];
|
|
15
|
+
searchUrl: string;
|
|
16
|
+
search?: boolean;
|
|
17
|
+
extraRenderValues?: Record<string, any>[];
|
|
18
|
+
};
|
|
19
|
+
export default function (props: TableProps): React.JSX.Element;
|