iglooform 3.0.16 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dumi/tmp/core/defineApp.ts +2 -1
- package/.dumi/tmp/core/helmet.ts +1 -1
- package/.dumi/tmp/core/history.ts +1 -1
- package/.dumi/tmp/core/historyIntelli.ts +1 -1
- package/.dumi/tmp/core/plugin.ts +6 -1
- package/.dumi/tmp/core/pluginConfig.ts +11 -0
- package/.dumi/tmp/core/polyfill.ts +197 -197
- package/.dumi/tmp/core/route.tsx +33 -33
- package/.dumi/tmp/dumi/exports.ts +1 -1
- package/.dumi/tmp/dumi/locales/runtime.tsx +2 -2
- package/.dumi/tmp/dumi/meta/index.ts +33 -33
- package/.dumi/tmp/dumi/meta/runtime.ts +1 -1
- package/.dumi/tmp/dumi/theme/ContextWrapper.tsx +3 -3
- package/.dumi/tmp/dumi/theme/builtins/API.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Badge.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Container.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Previewer.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/SourceCode.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Table.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Tree.ts +1 -1
- package/.dumi/tmp/dumi/theme/layouts/DocLayout.ts +1 -1
- package/.dumi/tmp/dumi/theme/loading.tsx +1 -1
- package/.dumi/tmp/dumi/theme/nprogress.css +3 -3
- package/.dumi/tmp/dumi/theme/slots/ColorSwitch.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Content.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/ContentFooter.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/ContentTabs.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Features.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Footer.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Header.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/HeaderExtra.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Hero.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/HeroTitle.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/LangSwitch.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Logo.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Navbar.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/NavbarExtra.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/NotFound.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/PreviewerActions.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/PreviewerActionsExtra.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/RtlSwitch.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/SearchBar.ts +2 -2
- package/.dumi/tmp/dumi/theme/slots/SearchResult.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Sidebar.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/SocialIcon.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Toc.ts +1 -1
- package/.dumi/tmp/exports.ts +5 -4
- package/.dumi/tmp/plugin-antd/runtime.tsx +65 -0
- package/.dumi/tmp/plugin-antd/runtimeConfig.d.ts +6 -0
- package/.dumi/tmp/plugin-antd/types.d.ts +14 -0
- package/.dumi/tmp/testBrowser.tsx +4 -2
- package/.dumi/tmp/umi.ts +5 -3
- package/es/documents/index.d.ts +1 -1
- package/es/documents/index.js +32 -38
- package/es/locale/en-US/messages.json +1 -0
- package/es/locale/id-ID/messages.json +1 -0
- package/es/locale/th-TH/messages.json +1 -0
- package/es/locale/vi-VN/messages.json +1 -0
- package/es/locale/zh-CN/messages.json +1 -0
- package/es/locale/zh-TW/messages.json +1 -0
- package/es/media/file-icon.d.ts +9 -0
- package/es/media/file-icon.js +93 -0
- package/es/media/index.d.ts +9 -4
- package/es/media/index.js +211 -85
- package/es/media/preview.js +18 -1
- package/es/media/style/file-icon.less +53 -0
- package/es/upload-photo/index.js +2 -4
- package/es/upload-preview/index.js +6 -9
- package/es/utils/form-utils.d.ts +1 -1
- package/es/utils/form-utils.js +1 -1
- package/es/utils/tools.d.ts +2 -1
- package/es/utils/tools.js +53 -11
- package/lib/documents/index.d.ts +1 -1
- package/lib/documents/index.js +31 -37
- package/lib/locale/en-US/messages.json +1 -0
- package/lib/locale/id-ID/messages.json +1 -0
- package/lib/locale/th-TH/messages.json +1 -0
- package/lib/locale/vi-VN/messages.json +1 -0
- package/lib/locale/zh-CN/messages.json +1 -0
- package/lib/locale/zh-TW/messages.json +1 -0
- package/lib/media/file-icon.d.ts +9 -0
- package/lib/media/file-icon.js +99 -0
- package/lib/media/index.d.ts +9 -4
- package/lib/media/index.js +210 -84
- package/lib/media/preview.js +17 -1
- package/lib/media/style/file-icon.less +53 -0
- package/lib/upload-photo/index.js +2 -4
- package/lib/upload-preview/index.js +5 -8
- package/lib/utils/form-utils.d.ts +1 -1
- package/lib/utils/form-utils.js +1 -1
- package/lib/utils/tools.d.ts +2 -1
- package/lib/utils/tools.js +55 -12
- package/package.json +1 -1
- package/.idea/codeStyles/Project.xml +0 -59
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/iglooform.iml +0 -12
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -6
- package/es/confirmation/style/index.d.ts +0 -1
- package/es/form-context.d.ts +0 -28
- package/es/ocr/micro-blink/style/index.d.ts +0 -1
- package/es/types.d.ts +0 -183
- package/lib/confirmation/style/index.d.ts +0 -1
- package/lib/form-context.d.ts +0 -28
- package/lib/ocr/micro-blink/style/index.d.ts +0 -1
- package/lib/types.d.ts +0 -183
- package/yarn-error.log +0 -16168
package/lib/media/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var _media = _interopRequireDefault(require("./media"));
|
|
|
11
11
|
var _preview = _interopRequireDefault(require("./preview"));
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
13
|
var _typography = _interopRequireDefault(require("../typography"));
|
|
14
|
+
var _fileIcon = _interopRequireDefault(require("./file-icon"));
|
|
14
15
|
var _iglooicon = require("iglooicon");
|
|
15
16
|
require("./style");
|
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -18,29 +19,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
21
|
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; }
|
|
21
|
-
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); }
|
|
22
22
|
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); } }
|
|
23
23
|
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); }); }; }
|
|
24
|
+
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
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
25
26
|
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."); }
|
|
26
27
|
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); }
|
|
27
28
|
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; }
|
|
28
29
|
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; } }
|
|
29
30
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
30
|
-
function ClassifyType(type) {
|
|
31
|
-
if (type.includes('image')) {
|
|
32
|
-
return 'image';
|
|
33
|
-
}
|
|
34
|
-
if (type.includes('video')) {
|
|
35
|
-
return 'video';
|
|
36
|
-
}
|
|
37
|
-
if (type.includes('pdf')) {
|
|
38
|
-
return 'pdf';
|
|
39
|
-
}
|
|
40
|
-
return 'unknown';
|
|
41
|
-
}
|
|
42
31
|
var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
43
|
-
var
|
|
32
|
+
var srcProp = _ref.src,
|
|
44
33
|
name = _ref.name,
|
|
45
34
|
className = _ref.className,
|
|
46
35
|
_ref$index = _ref.index,
|
|
@@ -56,43 +45,88 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
56
45
|
showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
|
|
57
46
|
_ref$destroyOnClose = _ref.destroyOnClose,
|
|
58
47
|
destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose,
|
|
59
|
-
download = _ref.download
|
|
60
|
-
|
|
48
|
+
_ref$download = _ref.download,
|
|
49
|
+
download = _ref$download === void 0 ? {
|
|
50
|
+
actionType: 'downloadBlob'
|
|
51
|
+
} : _ref$download,
|
|
52
|
+
getNonCORSUrl = _ref.getNonCORSUrl;
|
|
53
|
+
var _ref2 = _typeof(srcProp) === 'object' ? [srcProp.origin, srcProp.nonCORS] : [srcProp],
|
|
54
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
55
|
+
src = _ref3[0],
|
|
56
|
+
nonCORSSrcProp = _ref3[1];
|
|
57
|
+
var _useState = (0, _react.useState)(nonCORSSrcProp),
|
|
61
58
|
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var _useState3 = (0, _react.useState)(
|
|
59
|
+
nonCORSSrc = _useState2[0],
|
|
60
|
+
setNonCORSSrc = _useState2[1];
|
|
61
|
+
var _useState3 = (0, _react.useState)(1),
|
|
65
62
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var _useState5 = (0, _react.useState)(
|
|
63
|
+
scale = _useState4[0],
|
|
64
|
+
setScale = _useState4[1];
|
|
65
|
+
var _useState5 = (0, _react.useState)(type),
|
|
69
66
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var _useState7 = (0, _react.useState)(
|
|
67
|
+
mediaType = _useState6[0],
|
|
68
|
+
setType = _useState6[1];
|
|
69
|
+
var _useState7 = (0, _react.useState)(false),
|
|
73
70
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var _useState9 = (0, _react.useState)(
|
|
71
|
+
showModal = _useState8[0],
|
|
72
|
+
setShowModal = _useState8[1];
|
|
73
|
+
var _useState9 = (0, _react.useState)(index),
|
|
77
74
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
current = _useState10[0],
|
|
76
|
+
setCurrent = _useState10[1];
|
|
77
|
+
var _useState11 = (0, _react.useState)(''),
|
|
78
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
79
|
+
direction = _useState12[0],
|
|
80
|
+
setDirection = _useState12[1];
|
|
81
|
+
(0, _react.useEffect)(function () {
|
|
82
|
+
setNonCORSSrc(nonCORSSrcProp);
|
|
83
|
+
}, [nonCORSSrcProp]);
|
|
80
84
|
(0, _react.useEffect)(function () {
|
|
81
85
|
if (mediaType) {
|
|
82
86
|
return;
|
|
83
87
|
}
|
|
84
88
|
var unmounted = false;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
var execute = /*#__PURE__*/function () {
|
|
90
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
91
|
+
var _nonCORSSrc, contentType, typeClass;
|
|
92
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
93
|
+
while (1) switch (_context.prev = _context.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
_context.t0 = nonCORSSrc;
|
|
96
|
+
if (_context.t0) {
|
|
97
|
+
_context.next = 5;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
_context.next = 4;
|
|
101
|
+
return getNonCORSUrl === null || getNonCORSUrl === void 0 ? void 0 : getNonCORSUrl(src);
|
|
102
|
+
case 4:
|
|
103
|
+
_context.t0 = _context.sent;
|
|
104
|
+
case 5:
|
|
105
|
+
_nonCORSSrc = _context.t0;
|
|
106
|
+
_context.next = 8;
|
|
107
|
+
return (0, _tools.getResourceContentType)(_nonCORSSrc !== null && _nonCORSSrc !== void 0 ? _nonCORSSrc : src);
|
|
108
|
+
case 8:
|
|
109
|
+
contentType = _context.sent;
|
|
110
|
+
typeClass = (0, _tools.classifyType)(contentType);
|
|
111
|
+
if (!unmounted) {
|
|
112
|
+
!nonCORSSrc && setNonCORSSrc(_nonCORSSrc);
|
|
113
|
+
setType(typeClass);
|
|
114
|
+
}
|
|
115
|
+
case 11:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee);
|
|
120
|
+
}));
|
|
121
|
+
return function execute() {
|
|
122
|
+
return _ref4.apply(this, arguments);
|
|
123
|
+
};
|
|
124
|
+
}();
|
|
125
|
+
execute();
|
|
92
126
|
return function () {
|
|
93
127
|
unmounted = true;
|
|
94
128
|
};
|
|
95
|
-
}, [src]);
|
|
129
|
+
}, [src, nonCORSSrc]);
|
|
96
130
|
(0, _react.useEffect)(function () {
|
|
97
131
|
var handleKeyDown = function handleKeyDown(e) {
|
|
98
132
|
if (!showModal || list.length === 1) return;
|
|
@@ -108,12 +142,34 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
108
142
|
return document.body.removeEventListener('keydown', handleKeyDown);
|
|
109
143
|
};
|
|
110
144
|
}, [showModal]);
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
145
|
+
var canRenderMedia = ['pdf', 'video', 'image'].includes(mediaType);
|
|
146
|
+
var getCurrentDownloadUrl = /*#__PURE__*/function () {
|
|
147
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
148
|
+
var _ref7;
|
|
149
|
+
var isList, _ref6, _current, _nonCORSSrc, _src;
|
|
150
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
151
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
152
|
+
case 0:
|
|
153
|
+
isList = Boolean(list && !!list.length);
|
|
154
|
+
if (isList) {
|
|
155
|
+
_context2.next = 3;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
return _context2.abrupt("return", (_ref6 = nonCORSSrc !== null && nonCORSSrc !== void 0 ? nonCORSSrc : getNonCORSUrl === null || getNonCORSUrl === void 0 ? void 0 : getNonCORSUrl(src)) !== null && _ref6 !== void 0 ? _ref6 : src);
|
|
159
|
+
case 3:
|
|
160
|
+
_current = list === null || list === void 0 ? void 0 : list[current];
|
|
161
|
+
_nonCORSSrc = _current.nonCORSSrc, _src = _current.src;
|
|
162
|
+
return _context2.abrupt("return", (_ref7 = _nonCORSSrc !== null && _nonCORSSrc !== void 0 ? _nonCORSSrc : getNonCORSUrl === null || getNonCORSUrl === void 0 ? void 0 : getNonCORSUrl(_src)) !== null && _ref7 !== void 0 ? _ref7 : _src);
|
|
163
|
+
case 6:
|
|
164
|
+
case "end":
|
|
165
|
+
return _context2.stop();
|
|
166
|
+
}
|
|
167
|
+
}, _callee2);
|
|
168
|
+
}));
|
|
169
|
+
return function getCurrentDownloadUrl() {
|
|
170
|
+
return _ref5.apply(this, arguments);
|
|
171
|
+
};
|
|
172
|
+
}();
|
|
117
173
|
var open = function open() {
|
|
118
174
|
setShowModal(true);
|
|
119
175
|
};
|
|
@@ -158,58 +214,124 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
158
214
|
setScale(scale + 0.2);
|
|
159
215
|
};
|
|
160
216
|
var onDownloadClick = /*#__PURE__*/function () {
|
|
161
|
-
var
|
|
162
|
-
var
|
|
163
|
-
return _regeneratorRuntime().wrap(function
|
|
164
|
-
while (1) switch (
|
|
217
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(downloadUrl) {
|
|
218
|
+
var filename, actionType, res, blob, url;
|
|
219
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
220
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
165
221
|
case 0:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
actionType = 'downloadBlob';
|
|
170
|
-
if (!(_typeof(download) === 'object')) {
|
|
171
|
-
_context.next = 10;
|
|
222
|
+
filename = (0, _tools.getFileNameByUrl)(downloadUrl);
|
|
223
|
+
if (download) {
|
|
224
|
+
_context3.next = 3;
|
|
172
225
|
break;
|
|
173
226
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
_context.next = 8;
|
|
179
|
-
return download.getUrl(currentUrl);
|
|
180
|
-
case 8:
|
|
181
|
-
downloadUrl = _context.sent;
|
|
182
|
-
case 9:
|
|
183
|
-
if (download !== null && download !== void 0 && download.actionType) {
|
|
184
|
-
actionType = download.actionType;
|
|
185
|
-
}
|
|
186
|
-
case 10:
|
|
227
|
+
return _context3.abrupt("return");
|
|
228
|
+
case 3:
|
|
229
|
+
actionType = download.actionType;
|
|
187
230
|
if (!(actionType === 'downloadBlob')) {
|
|
188
|
-
|
|
231
|
+
_context3.next = 21;
|
|
189
232
|
break;
|
|
190
233
|
}
|
|
191
|
-
|
|
234
|
+
_context3.prev = 5;
|
|
235
|
+
_context3.next = 8;
|
|
192
236
|
return fetch(downloadUrl);
|
|
193
|
-
case
|
|
194
|
-
res =
|
|
195
|
-
|
|
237
|
+
case 8:
|
|
238
|
+
res = _context3.sent;
|
|
239
|
+
_context3.next = 11;
|
|
196
240
|
return res.blob();
|
|
197
|
-
case
|
|
198
|
-
blob =
|
|
241
|
+
case 11:
|
|
242
|
+
blob = _context3.sent;
|
|
199
243
|
url = window.URL.createObjectURL(blob);
|
|
200
244
|
(0, _tools.downloadByUrl)(filename, url);
|
|
201
|
-
|
|
245
|
+
_context3.next = 19;
|
|
246
|
+
break;
|
|
247
|
+
case 16:
|
|
248
|
+
_context3.prev = 16;
|
|
249
|
+
_context3.t0 = _context3["catch"](5);
|
|
250
|
+
console.warn(_context3.t0.message);
|
|
251
|
+
case 19:
|
|
252
|
+
_context3.next = 22;
|
|
202
253
|
break;
|
|
203
254
|
case 21:
|
|
204
255
|
(0, _tools.downloadByUrl)(filename, downloadUrl);
|
|
205
256
|
case 22:
|
|
206
257
|
case "end":
|
|
207
|
-
return
|
|
258
|
+
return _context3.stop();
|
|
208
259
|
}
|
|
209
|
-
},
|
|
260
|
+
}, _callee3, null, [[5, 16]]);
|
|
210
261
|
}));
|
|
211
|
-
return function onDownloadClick() {
|
|
212
|
-
return
|
|
262
|
+
return function onDownloadClick(_x2) {
|
|
263
|
+
return _ref8.apply(this, arguments);
|
|
264
|
+
};
|
|
265
|
+
}();
|
|
266
|
+
var onDownloadByModal = /*#__PURE__*/function () {
|
|
267
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
268
|
+
var downloadUrl;
|
|
269
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
270
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
271
|
+
case 0:
|
|
272
|
+
_context4.next = 2;
|
|
273
|
+
return getCurrentDownloadUrl();
|
|
274
|
+
case 2:
|
|
275
|
+
downloadUrl = _context4.sent;
|
|
276
|
+
return _context4.abrupt("return", onDownloadClick(downloadUrl));
|
|
277
|
+
case 4:
|
|
278
|
+
case "end":
|
|
279
|
+
return _context4.stop();
|
|
280
|
+
}
|
|
281
|
+
}, _callee4);
|
|
282
|
+
}));
|
|
283
|
+
return function onDownloadByModal() {
|
|
284
|
+
return _ref9.apply(this, arguments);
|
|
285
|
+
};
|
|
286
|
+
}();
|
|
287
|
+
var onDownloadByFileIcon = /*#__PURE__*/function () {
|
|
288
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
289
|
+
var _ref11;
|
|
290
|
+
var downloadUrl;
|
|
291
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
292
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
293
|
+
case 0:
|
|
294
|
+
if (!(nonCORSSrc !== null && nonCORSSrc !== void 0)) {
|
|
295
|
+
_context5.next = 4;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
_context5.t1 = nonCORSSrc;
|
|
299
|
+
_context5.next = 7;
|
|
300
|
+
break;
|
|
301
|
+
case 4:
|
|
302
|
+
_context5.next = 6;
|
|
303
|
+
return getNonCORSUrl === null || getNonCORSUrl === void 0 ? void 0 : getNonCORSUrl(src);
|
|
304
|
+
case 6:
|
|
305
|
+
_context5.t1 = _context5.sent;
|
|
306
|
+
case 7:
|
|
307
|
+
_context5.t2 = _ref11 = _context5.t1;
|
|
308
|
+
_context5.t0 = _context5.t2 !== null;
|
|
309
|
+
if (!_context5.t0) {
|
|
310
|
+
_context5.next = 11;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
_context5.t0 = _ref11 !== void 0;
|
|
314
|
+
case 11:
|
|
315
|
+
if (!_context5.t0) {
|
|
316
|
+
_context5.next = 15;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
_context5.t3 = _ref11;
|
|
320
|
+
_context5.next = 16;
|
|
321
|
+
break;
|
|
322
|
+
case 15:
|
|
323
|
+
_context5.t3 = src;
|
|
324
|
+
case 16:
|
|
325
|
+
downloadUrl = _context5.t3;
|
|
326
|
+
return _context5.abrupt("return", onDownloadClick(downloadUrl));
|
|
327
|
+
case 18:
|
|
328
|
+
case "end":
|
|
329
|
+
return _context5.stop();
|
|
330
|
+
}
|
|
331
|
+
}, _callee5);
|
|
332
|
+
}));
|
|
333
|
+
return function onDownloadByFileIcon() {
|
|
334
|
+
return _ref10.apply(this, arguments);
|
|
213
335
|
};
|
|
214
336
|
}();
|
|
215
337
|
var getTranslateX = function getTranslateX(index) {
|
|
@@ -244,11 +366,15 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
244
366
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
245
367
|
className: className,
|
|
246
368
|
style: style,
|
|
247
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_media.default, {
|
|
369
|
+
children: [canRenderMedia ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_media.default, {
|
|
248
370
|
type: mediaType,
|
|
249
371
|
src: src,
|
|
250
372
|
onClick: open,
|
|
251
373
|
name: name
|
|
374
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_fileIcon.default, {
|
|
375
|
+
type: mediaType,
|
|
376
|
+
onDownloadClick: onDownloadByFileIcon,
|
|
377
|
+
disabledDownload: !download
|
|
252
378
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Modal, {
|
|
253
379
|
open: showModal,
|
|
254
380
|
onCancel: close,
|
|
@@ -273,9 +399,9 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
273
399
|
})]
|
|
274
400
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
275
401
|
className: "igloo-media-list",
|
|
276
|
-
children: [Boolean(list && !!list.length) && list.map(function (
|
|
277
|
-
var src =
|
|
278
|
-
type =
|
|
402
|
+
children: [Boolean(list && !!list.length) && list.map(function (_ref12, index) {
|
|
403
|
+
var src = _ref12.src,
|
|
404
|
+
type = _ref12.type;
|
|
279
405
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
280
406
|
className: (0, _classnames.default)({
|
|
281
407
|
'igloo-media-animating': needShowAnimation(index),
|
|
@@ -321,7 +447,7 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
321
447
|
fontSize: 24
|
|
322
448
|
}
|
|
323
449
|
}), download && /*#__PURE__*/(0, _jsxRuntime.jsx)(_iglooicon.DownloadOutlined, {
|
|
324
|
-
onClick:
|
|
450
|
+
onClick: onDownloadByModal,
|
|
325
451
|
className: (0, _classnames.default)({
|
|
326
452
|
'igloo-preview-action-btn': true,
|
|
327
453
|
'igloo-preview-download-btn': true
|
package/lib/media/preview.js
CHANGED
|
@@ -10,6 +10,7 @@ var _entry = require("react-pdf/dist/esm/entry.webpack");
|
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
var _iglooicon = require("iglooicon");
|
|
12
12
|
var _antd = require("antd");
|
|
13
|
+
var _typography = _interopRequireDefault(require("../typography"));
|
|
13
14
|
var _modal = _interopRequireDefault(require("../modal"));
|
|
14
15
|
var _password = _interopRequireDefault(require("../input/password"));
|
|
15
16
|
var _button = _interopRequireDefault(require("../button"));
|
|
@@ -217,6 +218,8 @@ var MediaItem = function MediaItem(_ref3) {
|
|
|
217
218
|
showAllPages = _ref3.showAllPages;
|
|
218
219
|
var top = offset.top,
|
|
219
220
|
left = offset.left;
|
|
221
|
+
var _useContext2 = (0, _react.useContext)(_locale.LocaleContext),
|
|
222
|
+
formatMessage = _useContext2.formatMessage;
|
|
220
223
|
switch (type) {
|
|
221
224
|
case 'video':
|
|
222
225
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("video", {
|
|
@@ -236,7 +239,7 @@ var MediaItem = function MediaItem(_ref3) {
|
|
|
236
239
|
isCurrent: isCurrent,
|
|
237
240
|
showAllPages: showAllPages
|
|
238
241
|
});
|
|
239
|
-
|
|
242
|
+
case 'image':
|
|
240
243
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
241
244
|
src: src,
|
|
242
245
|
style: {
|
|
@@ -246,6 +249,19 @@ var MediaItem = function MediaItem(_ref3) {
|
|
|
246
249
|
position: 'absolute'
|
|
247
250
|
}
|
|
248
251
|
});
|
|
252
|
+
default:
|
|
253
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
254
|
+
className: "igloo-upload-prevew-not-supported",
|
|
255
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_iglooicon.ErrorFilled, {
|
|
256
|
+
className: "igloo-upload-prevew-not-supported-icon"
|
|
257
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.default, {
|
|
258
|
+
level: "body1",
|
|
259
|
+
className: "igloo-upload-prevew-not-supported-text",
|
|
260
|
+
children: formatMessage({
|
|
261
|
+
id: 'No preview for this file. Only support image, video or PDF file.'
|
|
262
|
+
})
|
|
263
|
+
})]
|
|
264
|
+
});
|
|
249
265
|
}
|
|
250
266
|
};
|
|
251
267
|
var Media = function Media(_ref4) {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.igloo-media-file-container {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: 80px;
|
|
4
|
+
height: 80px;
|
|
5
|
+
display: flex;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
align-items: center;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
border: 1px solid rgb(238, 238, 238);
|
|
10
|
+
&:hover {
|
|
11
|
+
.igloo-media-file-mask {
|
|
12
|
+
transform: translateY(0);
|
|
13
|
+
opacity: 1;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
.igloo-media-file-mask {
|
|
17
|
+
transform: translateY(100%);
|
|
18
|
+
opacity: 0;
|
|
19
|
+
transition: all ease 0.3s;
|
|
20
|
+
position: absolute;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
25
|
+
}
|
|
26
|
+
.igloo-media-file-download-container {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
align-items: center;
|
|
30
|
+
height: 100%;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
|
|
33
|
+
gap: 2px;
|
|
34
|
+
&:active {
|
|
35
|
+
.igloo-media-file-download-icon,
|
|
36
|
+
.igloo-media-file-download-text {
|
|
37
|
+
color: #bdbdbd;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
.igloo-media-file-download-icon {
|
|
41
|
+
transition: color ease 0.3s;
|
|
42
|
+
color: #fff;
|
|
43
|
+
}
|
|
44
|
+
.igloo-media-file-download-text {
|
|
45
|
+
transition: color ease 0.3s;
|
|
46
|
+
font-weight: 500;
|
|
47
|
+
font-size: 12px;
|
|
48
|
+
line-height: 16px;
|
|
49
|
+
color: #fff;
|
|
50
|
+
user-select: none;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -16,7 +16,6 @@ var _uploadPreview = _interopRequireDefault(require("../upload-preview"));
|
|
|
16
16
|
var _agentDetect = require("../utils/agent-detect");
|
|
17
17
|
var _iglooicon = require("iglooicon");
|
|
18
18
|
var _media = _interopRequireDefault(require("../upload-preview/media"));
|
|
19
|
-
var _tools = require("../utils/tools");
|
|
20
19
|
var _media2 = _interopRequireDefault(require("./media"));
|
|
21
20
|
var _formContext = _interopRequireDefault(require("../form-context"));
|
|
22
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -151,7 +150,6 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
151
150
|
_props$capture = props.capture,
|
|
152
151
|
capture = _props$capture === void 0 ? false : _props$capture,
|
|
153
152
|
disabled = props.disabled;
|
|
154
|
-
console.log(props, 'props');
|
|
155
153
|
var _useContext2 = (0, _react.useContext)(_locale.LocaleContext),
|
|
156
154
|
formatMessage = _useContext2.formatMessage;
|
|
157
155
|
var _useState = (0, _react.useState)((0, _agentDetect.isMobileAgent)()),
|
|
@@ -315,7 +313,7 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
315
313
|
dataUrl = URL.createObjectURL(file);
|
|
316
314
|
dataUrlRef.current.push(dataUrl);
|
|
317
315
|
name = file.name, size = file.size, mimeType = file.type;
|
|
318
|
-
type = (
|
|
316
|
+
type = ClassifyType(mimeType);
|
|
319
317
|
if (!(type === 'unknown')) {
|
|
320
318
|
_context4.next = 10;
|
|
321
319
|
break;
|
|
@@ -514,7 +512,7 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
514
512
|
_modal.default.noFooter({
|
|
515
513
|
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_media.default, {
|
|
516
514
|
src: dataUrl,
|
|
517
|
-
type: (
|
|
515
|
+
type: ClassifyType(type)
|
|
518
516
|
}),
|
|
519
517
|
title: name,
|
|
520
518
|
className: 'igloo-upload-photo-preview-modal',
|
|
@@ -53,23 +53,20 @@ var UploadPreview = function UploadPreview(_ref) {
|
|
|
53
53
|
if (!files || !files.length) return;
|
|
54
54
|
var typedList = files.map( /*#__PURE__*/function () {
|
|
55
55
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(src) {
|
|
56
|
-
var
|
|
56
|
+
var contentType, type;
|
|
57
57
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
58
58
|
while (1) switch (_context.prev = _context.next) {
|
|
59
59
|
case 0:
|
|
60
60
|
_context.next = 2;
|
|
61
|
-
return
|
|
62
|
-
cache: 'force-cache'
|
|
63
|
-
});
|
|
61
|
+
return (0, _tools.getResourceContentType)(src);
|
|
64
62
|
case 2:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
type = contentType ? (0, _tools.classifyType)(contentType) : 'unknown';
|
|
63
|
+
contentType = _context.sent;
|
|
64
|
+
type = (0, _tools.classifyType)(contentType);
|
|
68
65
|
return _context.abrupt("return", {
|
|
69
66
|
type: type,
|
|
70
67
|
src: src
|
|
71
68
|
});
|
|
72
|
-
case
|
|
69
|
+
case 5:
|
|
73
70
|
case "end":
|
|
74
71
|
return _context.stop();
|
|
75
72
|
}
|
|
@@ -51,7 +51,7 @@ export declare const calcFormItemProps: (config: FormItemConfig, extraProps: For
|
|
|
51
51
|
elementProps: {
|
|
52
52
|
[key: string]: any;
|
|
53
53
|
};
|
|
54
|
-
display:
|
|
54
|
+
display: any;
|
|
55
55
|
previewFormater: ((value: any, form?: FormInstance<any> | undefined) => any) | undefined;
|
|
56
56
|
};
|
|
57
57
|
export declare const calcDisabled: (disabled?: boolean | FormItemAssert | FormItemAssert[], form?: FormInstance) => boolean;
|
package/lib/utils/form-utils.js
CHANGED
|
@@ -372,7 +372,7 @@ var calcFormItemProps = function calcFormItemProps(config, extraProps, form, par
|
|
|
372
372
|
dependencies: antdDependencies
|
|
373
373
|
},
|
|
374
374
|
elementProps: elementProps,
|
|
375
|
-
display: !ignore
|
|
375
|
+
display: !ignore && calcShouldRender(name, dependencies, asserts, shouldRender, shouldRenderCode, form),
|
|
376
376
|
previewFormater: previewFormater || extraPreviewFormater
|
|
377
377
|
};
|
|
378
378
|
};
|
package/lib/utils/tools.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const parseFileSize: (size: number) => string;
|
|
2
|
-
export declare function classifyType(
|
|
2
|
+
export declare function classifyType(mimeType: string): string;
|
|
3
3
|
export declare const downloadByUrl: (filename: string, url: string) => void;
|
|
4
4
|
export declare const getFileNameByUrl: (fileUrl: string) => string;
|
|
5
|
+
export declare const getResourceContentType: (resourceUrl: string) => Promise<string | null>;
|