@pointcloud/pcloud-components 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/esm/DCascader/index.d.ts +4 -8
- package/dist/esm/DCascader/index.js +53 -36
- package/dist/esm/DForm/DItem.d.ts +28 -0
- package/dist/esm/DForm/DItem.js +31 -0
- package/dist/esm/DForm/DItemsMap.d.ts +33 -0
- package/dist/esm/DForm/DItemsMap.js +148 -0
- package/dist/esm/DForm/helper.d.ts +6 -0
- package/dist/esm/DForm/helper.js +56 -0
- package/dist/esm/DForm/index.d.ts +20 -0
- package/dist/esm/DForm/index.js +60 -0
- package/dist/esm/DForm/index.less +31 -0
- package/dist/esm/DSelect/index.d.ts +1 -1
- package/dist/esm/DTreeSelect/index.d.ts +1 -1
- package/dist/esm/DTreeSelect/index.js +64 -43
- package/dist/esm/DUpload/helper.d.ts +105 -0
- package/dist/esm/DUpload/helper.js +265 -0
- package/dist/esm/DUpload/index.d.ts +55 -0
- package/dist/esm/DUpload/index.js +380 -0
- package/dist/esm/DUpload/index.less +18 -0
- package/dist/esm/LModal/index.d.ts +5 -0
- package/dist/esm/LModal/index.js +54 -0
- package/dist/esm/LModal/interface.d.ts +8 -0
- package/dist/esm/LModal/interface.js +1 -0
- package/dist/esm/LModal/styles/index.less +25 -0
- package/dist/esm/Loading/index.d.ts +2 -2
- package/dist/esm/Loading/index.js +4 -6
- package/dist/esm/Loading/interface.d.ts +3 -2
- package/dist/esm/Loading/loading.d.ts +1 -1
- package/dist/esm/Loading/loading.js +27 -5
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +4 -1
- package/dist/umd/pcloud-components.min.css +1 -1
- package/dist/umd/pcloud-components.min.js +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
var _excluded = ["value", "thumbOption", "uploadButton", "itemClassName", "enablePreview", "className", "maxCount", "children", "itemRender", "customRequest", "onRemove", "onDownload", "onPreview", "onChange", "defaultFileList", "showUploadList", "fileList"];
|
|
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(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
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."); }
|
|
13
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
15
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
|
+
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."); }
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
19
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
20
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
22
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
23
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
24
|
+
/*
|
|
25
|
+
* @Author : wangfeihu
|
|
26
|
+
* @Date : 2023-06-16 09:37:07
|
|
27
|
+
* @LastEditors : wangfeihu
|
|
28
|
+
* @LastEditTime : 2023-06-30 16:32:19
|
|
29
|
+
* @Description : 基于antd的Upload组件
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import React, { forwardRef, useEffect, useMemo, useRef, useState, useContext } from 'react';
|
|
33
|
+
import { Upload } from 'antd';
|
|
34
|
+
import helper from "./helper";
|
|
35
|
+
import { ConfigContext } from "../ConfigProvider";
|
|
36
|
+
import "./index.less";
|
|
37
|
+
var defaultUploadButton = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
|
|
38
|
+
style: {
|
|
39
|
+
fontSize: 18
|
|
40
|
+
}
|
|
41
|
+
}, "+"), /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
style: {
|
|
43
|
+
marginTop: 8
|
|
44
|
+
}
|
|
45
|
+
}, "\u4E0A\u4F20"));
|
|
46
|
+
function downloadFn(file) {
|
|
47
|
+
if (file instanceof Blob) {
|
|
48
|
+
helper.downloadFile(file);
|
|
49
|
+
} else if (file !== null && file !== void 0 && file.url) {
|
|
50
|
+
var fileName = (file === null || file === void 0 ? void 0 : file.fileName) || (file === null || file === void 0 ? void 0 : file.name) || (file === null || file === void 0 ? void 0 : file.id) || (file === null || file === void 0 ? void 0 : file.uid);
|
|
51
|
+
helper.downloadFile(file.url, typeof fileName === 'number' ? String(fileName) : fileName);
|
|
52
|
+
} else {
|
|
53
|
+
if (file) throw new TypeError("\u8FD4\u56DE\u503C\u5FC5\u987B\u662FBlob\u6216Dupload\u5BF9\u8C61,\u4F46\u5374\u5F97\u5230\u4E00\u4E2A: ".concat(_typeof(file)));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function previewFn(file) {
|
|
57
|
+
if (file instanceof Blob) {
|
|
58
|
+
helper.previewFile(file);
|
|
59
|
+
} else if (file !== null && file !== void 0 && file.url) {
|
|
60
|
+
helper.previewFile(file.url);
|
|
61
|
+
} else {
|
|
62
|
+
if (file) throw new TypeError("\u8FD4\u56DE\u503C\u5FC5\u987B\u662FBlob\u6216Dupload\u5BF9\u8C61,\u4F46\u5374\u5F97\u5230\u4E00\u4E2A: ".concat(_typeof(file)));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function downloadOrPreview(file, fn, execFn) {
|
|
66
|
+
if (typeof fn === 'function') {
|
|
67
|
+
var resultFile = fn(file);
|
|
68
|
+
if (resultFile && 'then' in resultFile && typeof resultFile.then === 'function') {
|
|
69
|
+
resultFile.then(function (_file) {
|
|
70
|
+
return execFn(_file);
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
execFn(resultFile);
|
|
74
|
+
}
|
|
75
|
+
// 默认的预览逻辑
|
|
76
|
+
} else {
|
|
77
|
+
execFn(file);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function InternalUpload(props, ref) {
|
|
81
|
+
var value = props.value,
|
|
82
|
+
thumbOption = props.thumbOption,
|
|
83
|
+
uploadButton = props.uploadButton,
|
|
84
|
+
_props$itemClassName = props.itemClassName,
|
|
85
|
+
itemClassName = _props$itemClassName === void 0 ? '' : _props$itemClassName,
|
|
86
|
+
enablePreview = props.enablePreview,
|
|
87
|
+
_props$className = props.className,
|
|
88
|
+
className = _props$className === void 0 ? '' : _props$className,
|
|
89
|
+
_props$maxCount = props.maxCount,
|
|
90
|
+
maxCount = _props$maxCount === void 0 ? 10 : _props$maxCount,
|
|
91
|
+
children = props.children,
|
|
92
|
+
itemRender = props.itemRender,
|
|
93
|
+
customRequest = props.customRequest,
|
|
94
|
+
onRemove = props.onRemove,
|
|
95
|
+
onDownload = props.onDownload,
|
|
96
|
+
onPreview = props.onPreview,
|
|
97
|
+
onChange = props.onChange,
|
|
98
|
+
defaultFileList = props.defaultFileList,
|
|
99
|
+
showUploadList = props.showUploadList,
|
|
100
|
+
_fileList = props.fileList,
|
|
101
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
102
|
+
var _useContext = useContext(ConfigContext),
|
|
103
|
+
getPrefixCls = _useContext.getPrefixCls;
|
|
104
|
+
var _useState = useState([]),
|
|
105
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
106
|
+
fileList = _useState2[0],
|
|
107
|
+
setFileList = _useState2[1];
|
|
108
|
+
|
|
109
|
+
// 缓存的文件列表
|
|
110
|
+
var listRef = useRef({
|
|
111
|
+
timer: null,
|
|
112
|
+
list: []
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// 缩略图相关选项
|
|
116
|
+
var _thumbOption = useMemo(function () {
|
|
117
|
+
return thumbOption === null ? thumbOption : helper.getThumbOption(thumbOption);
|
|
118
|
+
}, [thumbOption]);
|
|
119
|
+
function updateFileList(file, status) {
|
|
120
|
+
var needChange = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
121
|
+
var thumbUrl = arguments.length > 3 ? arguments[3] : undefined;
|
|
122
|
+
file.status = status;
|
|
123
|
+
file.thumbUrl = thumbUrl;
|
|
124
|
+
file.id = file.uid;
|
|
125
|
+
var list = _toConsumableArray(listRef.current.list);
|
|
126
|
+
setFileList(list);
|
|
127
|
+
if (onChange && needChange) {
|
|
128
|
+
onChange(list, {
|
|
129
|
+
file: file,
|
|
130
|
+
fileList: list
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
var customRequestFun = /*#__PURE__*/function () {
|
|
135
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestOption) {
|
|
136
|
+
var file, _list, _thumbOption$filter, base64Url, _thumbOption$onError, _compress, _base64Url, _thumbOption$onError2;
|
|
137
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
138
|
+
while (1) switch (_context.prev = _context.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
file = requestOption.file; // 若超出最大限制则不上传
|
|
141
|
+
if (!(listRef.current.list.filter(function (item) {
|
|
142
|
+
return (item === null || item === void 0 ? void 0 : item.status) !== 'removed';
|
|
143
|
+
}).length >= maxCount)) {
|
|
144
|
+
_context.next = 3;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
return _context.abrupt("return");
|
|
148
|
+
case 3:
|
|
149
|
+
// 标记当前文件为新上传的
|
|
150
|
+
file.source = 'upload';
|
|
151
|
+
|
|
152
|
+
// 用户自定义的上传逻辑
|
|
153
|
+
if (!(typeof customRequest === 'function')) {
|
|
154
|
+
_context.next = 9;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
_list = customRequest(file, listRef.current.list, requestOption);
|
|
158
|
+
if (_list && 'then' in _list && typeof _list.then === 'function') {
|
|
159
|
+
_list.then(function (list) {
|
|
160
|
+
if (list) {
|
|
161
|
+
setFileList(_toConsumableArray(list));
|
|
162
|
+
listRef.current.list = _toConsumableArray(list);
|
|
163
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(list, {
|
|
164
|
+
file: file,
|
|
165
|
+
fileList: list
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
} else if (_list instanceof Array) {
|
|
170
|
+
if (_list) {
|
|
171
|
+
setFileList(_toConsumableArray(_list));
|
|
172
|
+
listRef.current.list = _toConsumableArray(_list);
|
|
173
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(_list, {
|
|
174
|
+
file: file,
|
|
175
|
+
fileList: _list
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
_context.next = 42;
|
|
180
|
+
break;
|
|
181
|
+
case 9:
|
|
182
|
+
// 默认的上传逻辑
|
|
183
|
+
listRef.current.list.push(file);
|
|
184
|
+
if (!(_thumbOption && typeof _thumbOption.getThumbUrl === 'function')) {
|
|
185
|
+
_context.next = 25;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
updateFileList(file, 'uploading');
|
|
189
|
+
_context.prev = 12;
|
|
190
|
+
_context.next = 15;
|
|
191
|
+
return _thumbOption.getThumbUrl(file, _thumbOption);
|
|
192
|
+
case 15:
|
|
193
|
+
base64Url = _context.sent;
|
|
194
|
+
updateFileList(file, 'done', false, base64Url);
|
|
195
|
+
_context.next = 23;
|
|
196
|
+
break;
|
|
197
|
+
case 19:
|
|
198
|
+
_context.prev = 19;
|
|
199
|
+
_context.t0 = _context["catch"](12);
|
|
200
|
+
(_thumbOption$onError = _thumbOption.onError) === null || _thumbOption$onError === void 0 ? void 0 : _thumbOption$onError.call(_thumbOption, _context.t0);
|
|
201
|
+
updateFileList(file, 'done', false);
|
|
202
|
+
case 23:
|
|
203
|
+
_context.next = 42;
|
|
204
|
+
break;
|
|
205
|
+
case 25:
|
|
206
|
+
if (!(_thumbOption && (_thumbOption$filter = _thumbOption.filter) !== null && _thumbOption$filter !== void 0 && _thumbOption$filter.call(_thumbOption, file))) {
|
|
207
|
+
_context.next = 41;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
_compress = file.size > _thumbOption.size ? _thumbOption.compress : null;
|
|
211
|
+
updateFileList(file, 'uploading');
|
|
212
|
+
_context.prev = 28;
|
|
213
|
+
_context.next = 31;
|
|
214
|
+
return helper.imageToBase64(file, _compress);
|
|
215
|
+
case 31:
|
|
216
|
+
_base64Url = _context.sent;
|
|
217
|
+
updateFileList(file, 'done', false, _base64Url);
|
|
218
|
+
_context.next = 39;
|
|
219
|
+
break;
|
|
220
|
+
case 35:
|
|
221
|
+
_context.prev = 35;
|
|
222
|
+
_context.t1 = _context["catch"](28);
|
|
223
|
+
(_thumbOption$onError2 = _thumbOption.onError) === null || _thumbOption$onError2 === void 0 ? void 0 : _thumbOption$onError2.call(_thumbOption, _context.t1);
|
|
224
|
+
updateFileList(file, 'done', false);
|
|
225
|
+
case 39:
|
|
226
|
+
_context.next = 42;
|
|
227
|
+
break;
|
|
228
|
+
case 41:
|
|
229
|
+
updateFileList(file, 'done');
|
|
230
|
+
case 42:
|
|
231
|
+
case "end":
|
|
232
|
+
return _context.stop();
|
|
233
|
+
}
|
|
234
|
+
}, _callee, null, [[12, 19], [28, 35]]);
|
|
235
|
+
}));
|
|
236
|
+
return function customRequestFun(_x2) {
|
|
237
|
+
return _ref.apply(this, arguments);
|
|
238
|
+
};
|
|
239
|
+
}();
|
|
240
|
+
var onRemoveFun = function onRemoveFun(file) {
|
|
241
|
+
// 用户自定义的删除逻辑
|
|
242
|
+
if (typeof onRemove === 'function') {
|
|
243
|
+
var _list2 = onRemove(file, listRef.current.list);
|
|
244
|
+
if (_list2 && 'then' in _list2 && typeof _list2.then === 'function') {
|
|
245
|
+
_list2.then(function (list) {
|
|
246
|
+
if (list) {
|
|
247
|
+
setFileList(_toConsumableArray(list));
|
|
248
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(list, {
|
|
249
|
+
file: file,
|
|
250
|
+
fileList: list
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
} else if (_list2 instanceof Array) {
|
|
255
|
+
if (_list2) {
|
|
256
|
+
setFileList(_toConsumableArray(_list2));
|
|
257
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(_list2, {
|
|
258
|
+
file: file,
|
|
259
|
+
fileList: _list2
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
// 默认的删除逻辑
|
|
265
|
+
if (file.source === 'upload') {
|
|
266
|
+
var index = listRef.current.list.findIndex(function (item) {
|
|
267
|
+
return item.uid === file.uid;
|
|
268
|
+
});
|
|
269
|
+
if (index >= 0) listRef.current.list.splice(index, 1);
|
|
270
|
+
} else {
|
|
271
|
+
file.status = 'removed';
|
|
272
|
+
}
|
|
273
|
+
var _list3 = _toConsumableArray(listRef.current.list);
|
|
274
|
+
setFileList(_list3);
|
|
275
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(_list3, {
|
|
276
|
+
file: file,
|
|
277
|
+
fileList: _list3
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
var _onDownload = function _onDownload(file) {
|
|
282
|
+
return downloadOrPreview(file, onDownload, downloadFn);
|
|
283
|
+
};
|
|
284
|
+
var _onPreview = function _onPreview(file) {
|
|
285
|
+
return downloadOrPreview(file, onPreview, previewFn);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
// 拦截listItem的渲染,添加类名,强制修改预览图标的样式
|
|
289
|
+
var _itemRender = function _itemRender(originNode, file) {
|
|
290
|
+
// 给列表项添加类名,用以修改预览图标样式
|
|
291
|
+
var _enablePreview = typeof enablePreview === 'function' ? enablePreview(file) : enablePreview;
|
|
292
|
+
var _itemClassName = _enablePreview ? "".concat(originNode.props.className, " ").concat(itemClassName, " preview") : "".concat(originNode.props.className, " ").concat(itemClassName);
|
|
293
|
+
var _originNode = _objectSpread(_objectSpread({}, originNode), {}, {
|
|
294
|
+
props: _objectSpread(_objectSpread({}, originNode.props), {}, {
|
|
295
|
+
title: (file === null || file === void 0 ? void 0 : file.fileName) || (file === null || file === void 0 ? void 0 : file.name) || '',
|
|
296
|
+
className: _itemClassName
|
|
297
|
+
})
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// 解决下载、删除按钮在Form组件 disable状态下被禁用的问题
|
|
301
|
+
var action = helper.deepFindJsx(_originNode, function (item) {
|
|
302
|
+
var _item$props;
|
|
303
|
+
return ((_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.className) === 'ant-upload-list-item-actions' && item.type === 'span';
|
|
304
|
+
});
|
|
305
|
+
if (action) {
|
|
306
|
+
// 查找下载、删除图标,将其外层包裹的的Button组件删除掉
|
|
307
|
+
var actionChildren = action.props.children.map(function (item, index) {
|
|
308
|
+
if (index > 0) {
|
|
309
|
+
var _item$props2, _item$props3, _children2;
|
|
310
|
+
var _children = (item === null || item === void 0 ? void 0 : (_item$props2 = item.props) === null || _item$props2 === void 0 ? void 0 : _item$props2.children) || (item === null || item === void 0 ? void 0 : (_item$props3 = item.props) === null || _item$props3 === void 0 ? void 0 : _item$props3.icon);
|
|
311
|
+
if ((_children2 = _children) !== null && _children2 !== void 0 && _children2.props) {
|
|
312
|
+
_children = _objectSpread(_objectSpread({}, _children), {}, {
|
|
313
|
+
key: index,
|
|
314
|
+
props: _objectSpread(_objectSpread({
|
|
315
|
+
title: item.props.title
|
|
316
|
+
}, _children.props), {}, {
|
|
317
|
+
onClick: function onClick(e) {
|
|
318
|
+
var _item$props$onClick, _item$props4;
|
|
319
|
+
return (_item$props$onClick = (_item$props4 = item.props).onClick) === null || _item$props$onClick === void 0 ? void 0 : _item$props$onClick.call(_item$props4, e);
|
|
320
|
+
}
|
|
321
|
+
})
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
return _children || item;
|
|
325
|
+
}
|
|
326
|
+
return item;
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
// 替换修改后的action
|
|
330
|
+
var _children3 = _toConsumableArray(_originNode.props.children);
|
|
331
|
+
_children3[1] = _objectSpread(_objectSpread({}, _children3[1]), {}, {
|
|
332
|
+
props: _objectSpread(_objectSpread({}, _children3[1].props), {}, {
|
|
333
|
+
children: actionChildren
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
var _originNodeClone = _objectSpread(_objectSpread({}, _originNode), {}, {
|
|
337
|
+
props: _objectSpread(_objectSpread({}, _originNode.props), {}, {
|
|
338
|
+
children: _children3
|
|
339
|
+
})
|
|
340
|
+
});
|
|
341
|
+
return _originNodeClone;
|
|
342
|
+
}
|
|
343
|
+
return _originNode;
|
|
344
|
+
};
|
|
345
|
+
var _showUploadList = typeof showUploadList === 'boolean' ? showUploadList : _objectSpread(_objectSpread({}, showUploadList), {}, {
|
|
346
|
+
showPreviewIcon: true,
|
|
347
|
+
showDownloadIcon: true
|
|
348
|
+
});
|
|
349
|
+
var _finalFileList = listRef.current.list.filter(function (item) {
|
|
350
|
+
return item.status !== 'removed';
|
|
351
|
+
});
|
|
352
|
+
var _props = _objectSpread({
|
|
353
|
+
maxCount: maxCount,
|
|
354
|
+
action: undefined,
|
|
355
|
+
className: "".concat(getPrefixCls('upload'), " ").concat(className),
|
|
356
|
+
// @ts-ignore
|
|
357
|
+
fileList: fileList,
|
|
358
|
+
itemRender: itemRender || _itemRender,
|
|
359
|
+
customRequest: customRequestFun,
|
|
360
|
+
onRemove: onRemoveFun,
|
|
361
|
+
onDownload: _onDownload,
|
|
362
|
+
onPreview: _onPreview,
|
|
363
|
+
showUploadList: _showUploadList
|
|
364
|
+
}, otherProps);
|
|
365
|
+
var _uploadButton = uploadButton === null ? null : uploadButton || children || defaultUploadButton;
|
|
366
|
+
useEffect(function () {
|
|
367
|
+
var list = helper.getUploadFile(_fileList || value || defaultFileList, maxCount);
|
|
368
|
+
listRef.current.list = list;
|
|
369
|
+
setFileList(list);
|
|
370
|
+
}, [_fileList, value, defaultFileList]);
|
|
371
|
+
return /*#__PURE__*/React.createElement(Upload, _extends({
|
|
372
|
+
listType: "picture-card"
|
|
373
|
+
}, _props, {
|
|
374
|
+
fileList: _finalFileList,
|
|
375
|
+
ref: ref
|
|
376
|
+
}), _finalFileList.length >= maxCount ? null : _uploadButton);
|
|
377
|
+
}
|
|
378
|
+
var DUpload = /*#__PURE__*/forwardRef(InternalUpload);
|
|
379
|
+
DUpload.imageToBase64 = helper.imageToBase64;
|
|
380
|
+
export default DUpload;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@import '../commonStyle/index.less';
|
|
2
|
+
.@{prefix}-upload {
|
|
3
|
+
.preview .ant-upload-list-item-actions a[target='_blank'][rel='noopener noreferrer'] {
|
|
4
|
+
opacity: initial !important;
|
|
5
|
+
pointer-events: initial !important;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.ant-upload-list.ant-upload-list-picture-card .ant-upload-span {
|
|
9
|
+
.ant-upload-list-item-thumbnail {
|
|
10
|
+
height: 46px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ant-upload-list-item-name {
|
|
14
|
+
position: absolute;
|
|
15
|
+
display: initial;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _excluded = ["children", "mode"];
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
+
import { ConfigContext } from "../ConfigProvider";
|
|
11
|
+
import { Modal } from 'antd';
|
|
12
|
+
import React, { useContext, useEffect, useMemo, useRef } from 'react';
|
|
13
|
+
import "./styles/index.less";
|
|
14
|
+
function LModal(props) {
|
|
15
|
+
var children = props.children,
|
|
16
|
+
_props$mode = props.mode,
|
|
17
|
+
mode = _props$mode === void 0 ? 'absolute' : _props$mode,
|
|
18
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
19
|
+
var _useContext = useContext(ConfigContext),
|
|
20
|
+
getPrefixCls = _useContext.getPrefixCls;
|
|
21
|
+
var containerRef = useRef();
|
|
22
|
+
var style = useMemo(function () {
|
|
23
|
+
var _otherProps$style;
|
|
24
|
+
return _objectSpread({
|
|
25
|
+
getContainer: containerRef.current,
|
|
26
|
+
width: ((_otherProps$style = otherProps.style) === null || _otherProps$style === void 0 ? void 0 : _otherProps$style.width) || '80%',
|
|
27
|
+
centered: true
|
|
28
|
+
}, otherProps);
|
|
29
|
+
}, [otherProps]);
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
if (otherProps.visible) {
|
|
32
|
+
document.body.style.overflow = 'hidden';
|
|
33
|
+
} else {
|
|
34
|
+
document.body.style.overflow = '';
|
|
35
|
+
}
|
|
36
|
+
return function () {
|
|
37
|
+
document.body.style.overflow = '';
|
|
38
|
+
};
|
|
39
|
+
}, [otherProps.visible]);
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
if (containerRef.current) {
|
|
42
|
+
if (mode === 'absolute') {
|
|
43
|
+
containerRef.current.parentElement.style.position = '';
|
|
44
|
+
} else {
|
|
45
|
+
containerRef.current.parentElement.style.position = 'relative';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, [mode, containerRef.current]);
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
ref: containerRef,
|
|
51
|
+
className: "".concat(getPrefixCls('modal-container'), " ").concat(getPrefixCls(mode === 'absolute' ? 'absolute-modal-container' : 'relative-modal-container'))
|
|
52
|
+
}, /*#__PURE__*/React.createElement(Modal, style, children));
|
|
53
|
+
}
|
|
54
|
+
export default LModal;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModalProps } from 'antd';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
declare type IModalProps = Omit<ModalProps, 'width' | 'className'>;
|
|
4
|
+
export interface LModalProps extends IModalProps {
|
|
5
|
+
children?: ReactNode | undefined;
|
|
6
|
+
mode?: 'absolute' | 'relative';
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@import '../../commonStyle/index.less';
|
|
2
|
+
.@{prefix}-modal-container {
|
|
3
|
+
.ant-modal-wrap {
|
|
4
|
+
.ant-modal {
|
|
5
|
+
max-width: unset;
|
|
6
|
+
height: 100%;
|
|
7
|
+
.ant-modal-content {
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.@{prefix}-absolute-modal-container {
|
|
16
|
+
.ant-modal-wrap {
|
|
17
|
+
position: fixed;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.@{prefix}-relative-modal-container {
|
|
22
|
+
.ant-modal-wrap {
|
|
23
|
+
position: absolute;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Loading from './loading';
|
|
2
|
-
import { LoadingProps } from './interface';
|
|
2
|
+
import { LoadingProps, LoadingInstanceProps } from './interface';
|
|
3
3
|
declare const _default: {
|
|
4
|
-
open(
|
|
4
|
+
open(params?: LoadingInstanceProps): LoadingProps;
|
|
5
5
|
close(): void;
|
|
6
6
|
getInstance(): LoadingProps;
|
|
7
7
|
};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import Loading from "./loading";
|
|
2
2
|
var loadingInstance = null;
|
|
3
|
-
var getLoadingInstance = function getLoadingInstance(
|
|
4
|
-
loadingInstance = loadingInstance || Loading.newInstance(
|
|
5
|
-
tip: tip
|
|
6
|
-
});
|
|
3
|
+
var getLoadingInstance = function getLoadingInstance(params) {
|
|
4
|
+
loadingInstance = loadingInstance || Loading.newInstance(params);
|
|
7
5
|
return loadingInstance;
|
|
8
6
|
};
|
|
9
7
|
export default {
|
|
10
|
-
open: function open(
|
|
11
|
-
return getLoadingInstance(
|
|
8
|
+
open: function open(params) {
|
|
9
|
+
return getLoadingInstance(params);
|
|
12
10
|
},
|
|
13
11
|
close: function close() {
|
|
14
12
|
if (loadingInstance) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactInstance } from 'react';
|
|
2
2
|
export interface LoadingInstanceProps {
|
|
3
3
|
/**
|
|
4
4
|
* @description 加载的文字提示
|
|
5
5
|
* @default '数据请求中...'
|
|
6
6
|
*/
|
|
7
7
|
tip?: string;
|
|
8
|
+
container?: ReactInstance | undefined;
|
|
8
9
|
}
|
|
9
10
|
export interface LoadingProps {
|
|
10
|
-
open: (
|
|
11
|
+
open: (param: LoadingInstanceProps) => React.ReactDOM;
|
|
11
12
|
close: () => void;
|
|
12
13
|
getInstance: () => React.ReactDOM;
|
|
13
14
|
}
|
|
@@ -3,7 +3,7 @@ import { LoadingInstanceProps } from './interface';
|
|
|
3
3
|
import './styles/index.less';
|
|
4
4
|
declare function Loading(props: LoadingInstanceProps): React.JSX.Element;
|
|
5
5
|
declare namespace Loading {
|
|
6
|
-
var newInstance:
|
|
6
|
+
var newInstance: (args: LoadingInstanceProps) => {
|
|
7
7
|
destroy(): void;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
var _excluded = ["container"];
|
|
1
2
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
2
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; }
|
|
3
6
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
7
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
5
|
-
import React, { useContext } from 'react';
|
|
8
|
+
import React, { useContext, useEffect } from 'react';
|
|
6
9
|
import ReactDOM from 'react-dom';
|
|
7
10
|
import { Spin } from 'antd';
|
|
8
11
|
import classNames from 'classnames';
|
|
9
12
|
import { ConfigContext } from "../ConfigProvider";
|
|
10
13
|
import "./styles/index.less";
|
|
14
|
+
var parentElement;
|
|
11
15
|
function Loading(props) {
|
|
12
16
|
var _props$tip = props.tip,
|
|
13
17
|
tip = _props$tip === void 0 ? '数据请求中...' : _props$tip;
|
|
@@ -16,6 +20,12 @@ function Loading(props) {
|
|
|
16
20
|
getPrefixCls = _useContext.getPrefixCls;
|
|
17
21
|
var classname = getPrefixCls('loading');
|
|
18
22
|
var wrapperClass = classNames(_defineProperty({}, "".concat(prefixCls, "-loading"), !!prefixCls), classname);
|
|
23
|
+
useEffect(function () {
|
|
24
|
+
document.body.style.overflow = 'hidden';
|
|
25
|
+
return function () {
|
|
26
|
+
document.body.style.overflow = '';
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
19
29
|
return /*#__PURE__*/React.createElement("div", {
|
|
20
30
|
className: wrapperClass
|
|
21
31
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -27,14 +37,26 @@ function Loading(props) {
|
|
|
27
37
|
})));
|
|
28
38
|
}
|
|
29
39
|
Loading.newInstance = function newNotificationInstance(args) {
|
|
40
|
+
var _ref = args || {},
|
|
41
|
+
container = _ref.container,
|
|
42
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
30
43
|
var div = document.createElement('div');
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
var element = ReactDOM.findDOMNode(container);
|
|
45
|
+
if (element) {
|
|
46
|
+
element.appendChild(div);
|
|
47
|
+
element.style.position = 'relative';
|
|
48
|
+
} else {
|
|
49
|
+
document.body.appendChild(div);
|
|
50
|
+
}
|
|
51
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(Loading, otherProps), div);
|
|
33
52
|
return {
|
|
34
53
|
destroy: function destroy() {
|
|
35
|
-
var _document$body;
|
|
36
54
|
ReactDOM.unmountComponentAtNode(div);
|
|
37
|
-
(
|
|
55
|
+
if (element) {
|
|
56
|
+
element === null || element === void 0 ? void 0 : element.removeChild(div);
|
|
57
|
+
} else {
|
|
58
|
+
document.body.removeChild(div);
|
|
59
|
+
}
|
|
38
60
|
}
|
|
39
61
|
};
|
|
40
62
|
};
|