@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.
Files changed (119) hide show
  1. package/dist/components/Column/Cascader.d.ts +3 -0
  2. package/dist/components/Column/Cascader.js +110 -0
  3. package/dist/components/Column/File.d.ts +18 -0
  4. package/dist/components/Column/File.js +176 -0
  5. package/dist/components/Column/Image.d.ts +10 -0
  6. package/dist/components/Column/Image.js +104 -0
  7. package/dist/components/Column/Readonly/Action/Link.d.ts +11 -0
  8. package/dist/components/Column/Readonly/Action/Link.js +114 -0
  9. package/dist/components/Column/Readonly/Action/index.d.ts +4 -0
  10. package/dist/components/Column/Readonly/Action/index.js +3 -0
  11. package/dist/components/Column/Readonly/Action.d.ts +12 -0
  12. package/dist/components/Column/Readonly/Action.js +96 -0
  13. package/dist/components/Column/Readonly/Cascader.d.ts +9 -0
  14. package/dist/components/Column/Readonly/Cascader.js +52 -0
  15. package/dist/components/Column/Readonly/File.d.ts +8 -0
  16. package/dist/components/Column/Readonly/File.js +54 -0
  17. package/dist/components/Column/Readonly/Image.d.ts +3 -0
  18. package/dist/components/Column/Readonly/Image.js +69 -0
  19. package/dist/components/Column/Readonly/Ueditor.d.ts +3 -0
  20. package/dist/components/Column/Readonly/Ueditor.js +24 -0
  21. package/dist/components/Column/Readonly/index.d.ts +8 -0
  22. package/dist/components/Column/Readonly/index.js +7 -0
  23. package/dist/components/Column/Ueditor.d.ts +27 -0
  24. package/dist/components/Column/Ueditor.js +333 -0
  25. package/dist/components/Column/index.d.ts +7 -0
  26. package/dist/components/Column/index.js +6 -0
  27. package/dist/components/Form/Action/Button.d.ts +15 -0
  28. package/dist/components/Form/Action/Button.js +194 -0
  29. package/dist/components/Form/Action/index.d.ts +4 -0
  30. package/dist/components/Form/Action/index.js +3 -0
  31. package/dist/components/Form/Actions.d.ts +6 -0
  32. package/dist/components/Form/Actions.js +48 -0
  33. package/dist/components/Form.d.ts +20 -0
  34. package/dist/components/Form.js +217 -0
  35. package/dist/components/FormContext.d.ts +7 -0
  36. package/dist/components/FormContext.js +2 -0
  37. package/dist/components/Layout/New.d.ts +7 -0
  38. package/dist/components/Layout/New.js +257 -0
  39. package/dist/components/Layout.d.ts +4 -0
  40. package/dist/components/Layout.js +67 -0
  41. package/dist/components/LayoutContext.d.ts +26 -0
  42. package/dist/components/LayoutContext.js +2 -0
  43. package/dist/components/ModalContext.d.ts +8 -0
  44. package/dist/components/ModalContext.js +6 -0
  45. package/dist/components/Table/Action/Button.d.ts +10 -0
  46. package/dist/components/Table/Action/Button.js +166 -0
  47. package/dist/components/Table/Action/StartEditable.d.ts +10 -0
  48. package/dist/components/Table/Action/StartEditable.js +79 -0
  49. package/dist/components/Table/Action/index.d.ts +5 -0
  50. package/dist/components/Table/Action/index.js +4 -0
  51. package/dist/components/Table/ToolbarActions.d.ts +6 -0
  52. package/dist/components/Table/ToolbarActions.js +52 -0
  53. package/dist/components/Table.d.ts +19 -0
  54. package/dist/components/Table.js +322 -0
  55. package/dist/components/TableContext.d.ts +14 -0
  56. package/dist/components/TableContext.js +2 -0
  57. package/dist/components/Tabs.d.ts +15 -0
  58. package/dist/components/Tabs.js +62 -0
  59. package/dist/env.d.ts +1 -0
  60. package/dist/global.d.ts +6 -0
  61. package/dist/index.d.ts +7 -0
  62. package/dist/index.js +7 -0
  63. package/dist/lib/container.d.ts +9 -0
  64. package/dist/lib/container.js +93 -0
  65. package/dist/lib/customRule.d.ts +3 -0
  66. package/dist/lib/customRule.js +7 -0
  67. package/dist/lib/global.d.ts +9 -0
  68. package/dist/lib/global.js +2 -0
  69. package/dist/lib/helpers.d.ts +14 -0
  70. package/dist/lib/helpers.js +183 -0
  71. package/dist/lib/http.d.ts +5 -0
  72. package/dist/lib/http.js +72 -0
  73. package/dist/lib/schemaHandler.d.ts +5 -0
  74. package/dist/lib/schemaHandler.js +133 -0
  75. package/dist/lib/upload.d.ts +20 -0
  76. package/dist/lib/upload.js +215 -0
  77. package/dist/lib/writeExtra.d.ts +1 -0
  78. package/dist/lib/writeExtra.js +28 -0
  79. package/dist/types.d.ts +25 -0
  80. package/package.json +14 -8
  81. package/components/Column/Cascader.tsx +0 -79
  82. package/components/Column/File.tsx +0 -166
  83. package/components/Column/Image.tsx +0 -77
  84. package/components/Column/Readonly/Action/Link.tsx +0 -78
  85. package/components/Column/Readonly/Action.tsx +0 -80
  86. package/components/Column/Readonly/Cascader.tsx +0 -51
  87. package/components/Column/Readonly/File.tsx +0 -53
  88. package/components/Column/Readonly/Image.tsx +0 -39
  89. package/components/Column/Readonly/Ueditor.tsx +0 -18
  90. package/components/Column/Ueditor.tsx +0 -314
  91. package/components/Form/Action/Button.tsx +0 -129
  92. package/components/Form/Actions.tsx +0 -39
  93. package/components/Form.tsx +0 -177
  94. package/components/FormContext.ts +0 -9
  95. package/components/Layout/New.tsx +0 -252
  96. package/components/Layout.tsx +0 -52
  97. package/components/LayoutContext.ts +0 -26
  98. package/components/ModalContext.ts +0 -16
  99. package/components/Table/Action/Button.tsx +0 -89
  100. package/components/Table/Action/StartEditable.tsx +0 -59
  101. package/components/Table/ToolbarActions.tsx +0 -44
  102. package/components/Table.tsx +0 -280
  103. package/components/TableContext.ts +0 -15
  104. package/components/Tabs.tsx +0 -72
  105. package/lib/container.ts +0 -84
  106. package/lib/customRule.ts +0 -10
  107. package/lib/global.ts +0 -11
  108. package/lib/helpers.tsx +0 -146
  109. package/lib/http.ts +0 -74
  110. package/lib/schemaHandler.ts +0 -122
  111. package/lib/upload.ts +0 -177
  112. package/lib/writeExtra.js +0 -31
  113. /package/{components → dist/components}/Column/Readonly/Action/types.d.ts +0 -0
  114. /package/{components → dist/components}/Column/Readonly/types.d.ts +0 -0
  115. /package/{components → dist/components}/Column/types.d.ts +0 -0
  116. /package/{components → dist/components}/Form/Action/types.d.ts +0 -0
  117. /package/{components → dist/components}/Table/Action/types.d.ts +0 -0
  118. /package/{components → dist/components}/Table.scss +0 -0
  119. /package/{components → dist/components}/types.d.ts +0 -0
@@ -0,0 +1,3 @@
1
+ import { ColumnProps } from "./types";
2
+ import React from "react";
3
+ export default function (props: ColumnProps): React.JSX.Element;
@@ -0,0 +1,110 @@
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 _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; }
3
+ 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); } }
4
+ 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); }); }; }
5
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
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."); }
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+ 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."); }
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
+ 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; }
13
+ 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; } }
14
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
+ import { Cascader } from "antd";
16
+ import React, { useEffect, useState } from "react";
17
+ import http from "../../lib/http";
18
+ export default function (props) {
19
+ var _useState = useState(),
20
+ _useState2 = _slicedToArray(_useState, 2),
21
+ options = _useState2[0],
22
+ setOptions = _useState2[1];
23
+ var _useState3 = useState(),
24
+ _useState4 = _slicedToArray(_useState3, 2),
25
+ values = _useState4[0],
26
+ setValues = _useState4[1];
27
+ useEffect(function () {
28
+ var value = props.config.value;
29
+ setOptions(props.config.options);
30
+
31
+ // 远程获取数据
32
+ if (props.fieldProps.loadDataUrl) {
33
+ http({
34
+ url: props.fieldProps.loadDataUrl,
35
+ method: 'get',
36
+ params: {
37
+ value: value
38
+ }
39
+ }).then(function (res) {
40
+ setOptions(res.data);
41
+ if (value) {
42
+ var findValue = function findValue(options, value) {
43
+ for (var i = 0; i < options.length; i++) {
44
+ var option = options[i];
45
+ if (option.value === value) {
46
+ return [option.value];
47
+ } else if (option.children) {
48
+ return [option.value].concat(_toConsumableArray(findValue(option.children, value)));
49
+ }
50
+ }
51
+ };
52
+ setValues(findValue(res.data, value));
53
+ }
54
+ });
55
+ }
56
+ }, []);
57
+ var loadData = /*#__PURE__*/function () {
58
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(selectedOptions) {
59
+ var targetOption, res;
60
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
61
+ while (1) switch (_context.prev = _context.next) {
62
+ case 0:
63
+ targetOption = selectedOptions[selectedOptions.length - 1];
64
+ if (!targetOption.children) {
65
+ _context.next = 3;
66
+ break;
67
+ }
68
+ return _context.abrupt("return");
69
+ case 3:
70
+ targetOption.loading = true;
71
+ _context.next = 6;
72
+ return http(props.fieldProps.loadDataUrl, {
73
+ params: {
74
+ selected: targetOption.value
75
+ }
76
+ });
77
+ case 6:
78
+ res = _context.sent;
79
+ targetOption.loading = false;
80
+ targetOption.children = res.data;
81
+ setOptions(_toConsumableArray(options));
82
+ case 10:
83
+ case "end":
84
+ return _context.stop();
85
+ }
86
+ }, _callee);
87
+ }));
88
+ return function loadData(_x) {
89
+ return _ref.apply(this, arguments);
90
+ };
91
+ }();
92
+ var onChange = function onChange(values) {
93
+ setValues(values);
94
+ if (!(values !== null && values !== void 0 && values.length)) {
95
+ props.form.setFieldValue(props.dataIndex, undefined);
96
+ return;
97
+ }
98
+ var value = values[values.length - 1];
99
+ props.form.setFieldValue(props.dataIndex, value);
100
+ };
101
+ return /*#__PURE__*/React.createElement("div", {
102
+ className: props.className
103
+ }, /*#__PURE__*/React.createElement(Cascader, {
104
+ options: options,
105
+ onChange: onChange,
106
+ placeholder: '请选择',
107
+ value: values,
108
+ loadData: props.fieldProps.loadDataUrl ? loadData : undefined
109
+ }));
110
+ }
@@ -0,0 +1,18 @@
1
+ import { UploadFile } from "antd";
2
+ import React, { ReactNode } from "react";
3
+ import { ColumnProps } from "./types";
4
+ import { UploadListType } from "antd/es/upload/interface";
5
+ export default function (props: ColumnProps & {
6
+ fieldProps?: {
7
+ uploadRequest: {
8
+ policyGetUrl: string;
9
+ };
10
+ maxCount?: number;
11
+ };
12
+ uploadButton?: (fileList: UploadFile[]) => ReactNode;
13
+ listType?: UploadListType;
14
+ onPreview?: (file: UploadFile) => Promise<void>;
15
+ renderUploader?: (attr: {
16
+ dom: JSX.Element;
17
+ }) => ReactNode;
18
+ }): React.JSX.Element;
@@ -0,0 +1,176 @@
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 _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; }
3
+ 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); } }
4
+ 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); }); }; }
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 _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); }
8
+ 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; }
9
+ 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; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ 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); }
12
+ import { Alert, Button, Spin, Tooltip, Upload } from "antd";
13
+ import React, { useContext, useEffect, useState } from "react";
14
+ import { beforeUpload as _beforeUpload, customRequest } from "../../lib/upload";
15
+ import { DndContext, PointerSensor, useSensor } from '@dnd-kit/core';
16
+ import { arrayMove, SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';
17
+ import { CSS } from '@dnd-kit/utilities';
18
+ import { FormContext } from "../FormContext";
19
+ import { TableContext } from "../TableContext";
20
+ var DraggableUploadListItem = function DraggableUploadListItem(_ref) {
21
+ var originNode = _ref.originNode,
22
+ file = _ref.file;
23
+ var _useSortable = useSortable({
24
+ id: file.uid
25
+ }),
26
+ attributes = _useSortable.attributes,
27
+ listeners = _useSortable.listeners,
28
+ setNodeRef = _useSortable.setNodeRef,
29
+ transform = _useSortable.transform,
30
+ transition = _useSortable.transition,
31
+ isDragging = _useSortable.isDragging;
32
+ var style = {
33
+ transform: CSS.Translate.toString(transform),
34
+ transition: transition,
35
+ cursor: 'move',
36
+ height: '100%'
37
+ };
38
+ return /*#__PURE__*/React.createElement("div", _extends({
39
+ ref: setNodeRef,
40
+ style: style
41
+ // prevent preview event when drag end
42
+ ,
43
+ className: isDragging ? 'is-dragging' : ''
44
+ }, attributes, listeners), file.status === 'error' && isDragging ? originNode.props.children : originNode);
45
+ };
46
+ export default function (props) {
47
+ var _props$fieldProps, _props$fieldProps2, _props$fieldProps3, _props$fieldProps4;
48
+ var _useState = useState(true),
49
+ _useState2 = _slicedToArray(_useState, 2),
50
+ loading = _useState2[0],
51
+ setLoading = _useState2[1];
52
+ var _useState3 = useState([]),
53
+ _useState4 = _slicedToArray(_useState3, 2),
54
+ fileList = _useState4[0],
55
+ setFileList = _useState4[1];
56
+ var formContext = useContext(FormContext);
57
+ var tableContext = useContext(TableContext);
58
+ var handlePreview = /*#__PURE__*/function () {
59
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
60
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
61
+ while (1) switch (_context.prev = _context.next) {
62
+ case 0:
63
+ if (!file.url && !file.preview) {
64
+ file.preview = URL.createObjectURL(file.originFileObj);
65
+ }
66
+ window.open(file.url || file.preview);
67
+ case 2:
68
+ case "end":
69
+ return _context.stop();
70
+ }
71
+ }, _callee);
72
+ }));
73
+ return function handlePreview(_x) {
74
+ return _ref2.apply(this, arguments);
75
+ };
76
+ }();
77
+ useEffect(function () {
78
+ var extraRenderValue = [];
79
+ if (formContext && formContext.extraRenderValues) {
80
+ var _formContext$extraRen;
81
+ extraRenderValue = (_formContext$extraRen = formContext.extraRenderValues[props.dataIndex]) !== null && _formContext$extraRen !== void 0 ? _formContext$extraRen : [];
82
+ } else if (tableContext && tableContext.extraRenderValues) {
83
+ var _tableContext$extraRe, _tableContext$extraRe2;
84
+ console.log(111);
85
+ extraRenderValue = (_tableContext$extraRe = (_tableContext$extraRe2 = tableContext.extraRenderValues[props.index]) === null || _tableContext$extraRe2 === void 0 ? void 0 : _tableContext$extraRe2[props.schema.dataIndex]) !== null && _tableContext$extraRe !== void 0 ? _tableContext$extraRe : [];
86
+ }
87
+ setFileList(extraRenderValue.map(function (item) {
88
+ return {
89
+ uid: item.id,
90
+ status: 'done',
91
+ url: item.url,
92
+ name: item.name,
93
+ hash_id: item.hash_id,
94
+ response: {
95
+ file_id: item.id,
96
+ url: item.url
97
+ }
98
+ };
99
+ }));
100
+ setLoading(false);
101
+ }, []);
102
+ useEffect(function () {
103
+ var _props$form;
104
+ (_props$form = props.form) === null || _props$form === void 0 || _props$form.setFieldValue(props.dataIndex, fileList.map(function (file) {
105
+ if (file.status === 'done') {
106
+ file.url = file.response.url || file.response.file_url;
107
+ }
108
+ return file;
109
+ }));
110
+ }, [fileList]);
111
+ var uploadButton = /*#__PURE__*/React.createElement(Tooltip, {
112
+ title: fileList.length >= (((_props$fieldProps = props.fieldProps) === null || _props$fieldProps === void 0 ? void 0 : _props$fieldProps.maxCount) || 1) ? '最多只能上传' + (((_props$fieldProps2 = props.fieldProps) === null || _props$fieldProps2 === void 0 ? void 0 : _props$fieldProps2.maxCount) || 1) + '个文件' : ''
113
+ }, /*#__PURE__*/React.createElement(Button, {
114
+ disabled: fileList.length >= (((_props$fieldProps3 = props.fieldProps) === null || _props$fieldProps3 === void 0 ? void 0 : _props$fieldProps3.maxCount) || 1)
115
+ }, "\u4E0A\u4F20\u6587\u4EF6"));
116
+ var sensor = useSensor(PointerSensor, {
117
+ activationConstraint: {
118
+ distance: 10
119
+ }
120
+ });
121
+ var onDragEnd = function onDragEnd(_ref3) {
122
+ var active = _ref3.active,
123
+ over = _ref3.over;
124
+ if (active.id !== (over === null || over === void 0 ? void 0 : over.id)) {
125
+ setFileList(function (prev) {
126
+ var activeIndex = prev.findIndex(function (i) {
127
+ return i.uid === active.id;
128
+ });
129
+ var overIndex = prev.findIndex(function (i) {
130
+ return i.uid === (over === null || over === void 0 ? void 0 : over.id);
131
+ });
132
+ return arrayMove(prev, activeIndex, overIndex);
133
+ });
134
+ }
135
+ };
136
+ var uploader = /*#__PURE__*/React.createElement(Upload, _extends({}, props.fieldProps, {
137
+ action: props.fieldProps.uploadRequest.policyGetUrl,
138
+ listType: props.listType || 'text',
139
+ fileList: fileList,
140
+ itemRender: function itemRender(originNode, file) {
141
+ return /*#__PURE__*/React.createElement(DraggableUploadListItem, {
142
+ originNode: originNode,
143
+ file: file
144
+ });
145
+ },
146
+ onPreview: props.onPreview || handlePreview,
147
+ onChange: function onChange(_ref4) {
148
+ var fileList = _ref4.fileList;
149
+ return setFileList(fileList);
150
+ },
151
+ beforeUpload: function beforeUpload(f, fl) {
152
+ return _beforeUpload(f, fl, fileList);
153
+ },
154
+ customRequest: customRequest
155
+ }), props.uploadButton ? props.uploadButton(fileList) : uploadButton);
156
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (_props$fieldProps4 = props.fieldProps) !== null && _props$fieldProps4 !== void 0 && _props$fieldProps4.uploadRequest ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Spin, {
157
+ spinning: loading
158
+ }, /*#__PURE__*/React.createElement(DndContext, {
159
+ sensors: [sensor],
160
+ onDragEnd: onDragEnd
161
+ }, /*#__PURE__*/React.createElement(SortableContext, {
162
+ items: fileList.map(function (i) {
163
+ return i.uid;
164
+ }),
165
+ strategy: verticalListSortingStrategy
166
+ }, props.renderUploader ? props.renderUploader({
167
+ dom: uploader
168
+ }) : uploader)), /*#__PURE__*/React.createElement("div", {
169
+ style: {
170
+ marginBottom: '16px'
171
+ }
172
+ }))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Alert, {
173
+ message: '缺少 uploadRequest 属性',
174
+ type: "error"
175
+ })));
176
+ }
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { ColumnProps } from "./types";
3
+ export default function (props: ColumnProps & {
4
+ fieldProps?: {
5
+ maxCount?: number;
6
+ crop?: {
7
+ ratio: string;
8
+ };
9
+ };
10
+ }): React.JSX.Element;
@@ -0,0 +1,104 @@
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 { Col, Image, Row } from "antd";
13
+ import React, { useState } from "react";
14
+ import { PlusOutlined } from '@ant-design/icons';
15
+ import { getBase64 } from "../../lib/upload";
16
+ import File from "./File";
17
+ import ImgCrop from 'antd-img-crop';
18
+ export default function (props) {
19
+ var _useState = useState(false),
20
+ _useState2 = _slicedToArray(_useState, 2),
21
+ previewOpen = _useState2[0],
22
+ setPreviewOpen = _useState2[1];
23
+ var _useState3 = useState(''),
24
+ _useState4 = _slicedToArray(_useState3, 2),
25
+ previewImage = _useState4[0],
26
+ setPreviewImage = _useState4[1];
27
+ var handlePreview = /*#__PURE__*/function () {
28
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
29
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
30
+ while (1) switch (_context.prev = _context.next) {
31
+ case 0:
32
+ if (!(!file.url && !file.preview)) {
33
+ _context.next = 4;
34
+ break;
35
+ }
36
+ _context.next = 3;
37
+ return getBase64(file.originFileObj);
38
+ case 3:
39
+ file.preview = _context.sent;
40
+ case 4:
41
+ setPreviewImage(file.url || file.preview);
42
+ setPreviewOpen(true);
43
+ case 6:
44
+ case "end":
45
+ return _context.stop();
46
+ }
47
+ }, _callee);
48
+ }));
49
+ return function handlePreview(_x) {
50
+ return _ref.apply(this, arguments);
51
+ };
52
+ }();
53
+ var uploadButton = function uploadButton(fileList) {
54
+ var _props$fieldProps;
55
+ return fileList.length < (((_props$fieldProps = props.fieldProps) === null || _props$fieldProps === void 0 ? void 0 : _props$fieldProps.maxCount) || 1) ? /*#__PURE__*/React.createElement(Row, {
56
+ justify: 'center'
57
+ }, /*#__PURE__*/React.createElement(Col, {
58
+ flex: 1
59
+ }, /*#__PURE__*/React.createElement(PlusOutlined, {
60
+ size: 18
61
+ }), /*#__PURE__*/React.createElement("div", {
62
+ style: {
63
+ marginTop: 8
64
+ }
65
+ }, "\u4E0A\u4F20"))) : null;
66
+ };
67
+ var renderUploader = function renderUploader(_ref2) {
68
+ var _props$fieldProps2;
69
+ var dom = _ref2.dom;
70
+ if ((_props$fieldProps2 = props.fieldProps) !== null && _props$fieldProps2 !== void 0 && _props$fieldProps2.crop) {
71
+ var aspects = props.fieldProps.crop.ratio.split(/[\/:]/);
72
+ var aspect = Number(aspects);
73
+ if (aspects.length === 2) {
74
+ aspect = parseInt(aspects[0]) / parseInt(aspects[1]);
75
+ }
76
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ImgCrop, {
77
+ rotationSlider: true,
78
+ aspect: aspect
79
+ }, dom));
80
+ } else {
81
+ return dom;
82
+ }
83
+ };
84
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(File, _extends({}, props, {
85
+ uploadButton: uploadButton,
86
+ listType: 'picture-card',
87
+ onPreview: handlePreview,
88
+ renderUploader: renderUploader
89
+ })), previewImage && /*#__PURE__*/React.createElement(Image, {
90
+ wrapperStyle: {
91
+ display: 'none'
92
+ },
93
+ preview: {
94
+ visible: previewOpen,
95
+ onVisibleChange: function onVisibleChange(visible) {
96
+ return setPreviewOpen(visible);
97
+ },
98
+ afterOpenChange: function afterOpenChange(visible) {
99
+ return !visible && setPreviewImage('');
100
+ }
101
+ },
102
+ src: previewImage
103
+ }));
104
+ }
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { TableColumnActionProps } from "./types";
3
+ type Props = TableColumnActionProps & {
4
+ href?: string;
5
+ request?: RequestOptions;
6
+ modal?: ModalOptions;
7
+ modalByField?: string;
8
+ danger?: boolean;
9
+ };
10
+ export default function (props: Props): React.JSX.Element;
11
+ export {};