iglooform 3.0.16 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/.dumi/tmp/core/defineApp.ts +2 -1
  2. package/.dumi/tmp/core/helmet.ts +1 -1
  3. package/.dumi/tmp/core/history.ts +1 -1
  4. package/.dumi/tmp/core/historyIntelli.ts +1 -1
  5. package/.dumi/tmp/core/plugin.ts +6 -1
  6. package/.dumi/tmp/core/pluginConfig.ts +11 -0
  7. package/.dumi/tmp/core/polyfill.ts +197 -197
  8. package/.dumi/tmp/core/route.tsx +33 -33
  9. package/.dumi/tmp/dumi/exports.ts +1 -1
  10. package/.dumi/tmp/dumi/locales/runtime.tsx +2 -2
  11. package/.dumi/tmp/dumi/meta/index.ts +33 -33
  12. package/.dumi/tmp/dumi/meta/runtime.ts +1 -1
  13. package/.dumi/tmp/dumi/theme/ContextWrapper.tsx +3 -3
  14. package/.dumi/tmp/dumi/theme/builtins/API.ts +1 -1
  15. package/.dumi/tmp/dumi/theme/builtins/Badge.ts +1 -1
  16. package/.dumi/tmp/dumi/theme/builtins/Container.ts +1 -1
  17. package/.dumi/tmp/dumi/theme/builtins/Previewer.ts +1 -1
  18. package/.dumi/tmp/dumi/theme/builtins/SourceCode.ts +1 -1
  19. package/.dumi/tmp/dumi/theme/builtins/Table.ts +1 -1
  20. package/.dumi/tmp/dumi/theme/builtins/Tree.ts +1 -1
  21. package/.dumi/tmp/dumi/theme/layouts/DocLayout.ts +1 -1
  22. package/.dumi/tmp/dumi/theme/loading.tsx +1 -1
  23. package/.dumi/tmp/dumi/theme/nprogress.css +3 -3
  24. package/.dumi/tmp/dumi/theme/slots/ColorSwitch.ts +1 -1
  25. package/.dumi/tmp/dumi/theme/slots/Content.ts +1 -1
  26. package/.dumi/tmp/dumi/theme/slots/ContentFooter.ts +1 -1
  27. package/.dumi/tmp/dumi/theme/slots/ContentTabs.ts +1 -1
  28. package/.dumi/tmp/dumi/theme/slots/Features.ts +1 -1
  29. package/.dumi/tmp/dumi/theme/slots/Footer.ts +1 -1
  30. package/.dumi/tmp/dumi/theme/slots/Header.ts +1 -1
  31. package/.dumi/tmp/dumi/theme/slots/HeaderExtra.ts +1 -1
  32. package/.dumi/tmp/dumi/theme/slots/Hero.ts +1 -1
  33. package/.dumi/tmp/dumi/theme/slots/HeroTitle.ts +1 -1
  34. package/.dumi/tmp/dumi/theme/slots/LangSwitch.ts +1 -1
  35. package/.dumi/tmp/dumi/theme/slots/Logo.ts +1 -1
  36. package/.dumi/tmp/dumi/theme/slots/Navbar.ts +1 -1
  37. package/.dumi/tmp/dumi/theme/slots/NavbarExtra.ts +1 -1
  38. package/.dumi/tmp/dumi/theme/slots/NotFound.ts +1 -1
  39. package/.dumi/tmp/dumi/theme/slots/PreviewerActions.ts +1 -1
  40. package/.dumi/tmp/dumi/theme/slots/PreviewerActionsExtra.ts +1 -1
  41. package/.dumi/tmp/dumi/theme/slots/RtlSwitch.ts +1 -1
  42. package/.dumi/tmp/dumi/theme/slots/SearchBar.ts +2 -2
  43. package/.dumi/tmp/dumi/theme/slots/SearchResult.ts +1 -1
  44. package/.dumi/tmp/dumi/theme/slots/Sidebar.ts +1 -1
  45. package/.dumi/tmp/dumi/theme/slots/SocialIcon.ts +1 -1
  46. package/.dumi/tmp/dumi/theme/slots/Toc.ts +1 -1
  47. package/.dumi/tmp/exports.ts +5 -4
  48. package/.dumi/tmp/plugin-antd/runtime.tsx +65 -0
  49. package/.dumi/tmp/plugin-antd/runtimeConfig.d.ts +6 -0
  50. package/.dumi/tmp/plugin-antd/types.d.ts +14 -0
  51. package/.dumi/tmp/testBrowser.tsx +4 -2
  52. package/.dumi/tmp/umi.ts +5 -3
  53. package/es/documents/index.d.ts +1 -1
  54. package/es/documents/index.js +32 -38
  55. package/es/locale/en-US/messages.json +1 -0
  56. package/es/locale/id-ID/messages.json +1 -0
  57. package/es/locale/th-TH/messages.json +1 -0
  58. package/es/locale/vi-VN/messages.json +1 -0
  59. package/es/locale/zh-CN/messages.json +1 -0
  60. package/es/locale/zh-TW/messages.json +1 -0
  61. package/es/media/file-icon.d.ts +9 -0
  62. package/es/media/file-icon.js +93 -0
  63. package/es/media/index.d.ts +9 -4
  64. package/es/media/index.js +211 -85
  65. package/es/media/preview.js +18 -1
  66. package/es/media/style/file-icon.less +53 -0
  67. package/es/upload-preview/index.js +6 -9
  68. package/es/utils/form-utils.d.ts +1 -1
  69. package/es/utils/form-utils.js +1 -1
  70. package/es/utils/tools.d.ts +2 -1
  71. package/es/utils/tools.js +53 -11
  72. package/lib/documents/index.d.ts +1 -1
  73. package/lib/documents/index.js +31 -37
  74. package/lib/locale/en-US/messages.json +1 -0
  75. package/lib/locale/id-ID/messages.json +1 -0
  76. package/lib/locale/th-TH/messages.json +1 -0
  77. package/lib/locale/vi-VN/messages.json +1 -0
  78. package/lib/locale/zh-CN/messages.json +1 -0
  79. package/lib/locale/zh-TW/messages.json +1 -0
  80. package/lib/media/file-icon.d.ts +9 -0
  81. package/lib/media/file-icon.js +99 -0
  82. package/lib/media/index.d.ts +9 -4
  83. package/lib/media/index.js +210 -84
  84. package/lib/media/preview.js +17 -1
  85. package/lib/media/style/file-icon.less +53 -0
  86. package/lib/upload-preview/index.js +5 -8
  87. package/lib/utils/form-utils.d.ts +1 -1
  88. package/lib/utils/form-utils.js +1 -1
  89. package/lib/utils/tools.d.ts +2 -1
  90. package/lib/utils/tools.js +55 -12
  91. package/package.json +1 -1
  92. package/.idea/codeStyles/Project.xml +0 -59
  93. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  94. package/.idea/iglooform.iml +0 -12
  95. package/.idea/modules.xml +0 -8
  96. package/.idea/prettier.xml +0 -6
  97. package/.idea/vcs.xml +0 -6
  98. package/es/admin-amount/style/index.d.ts +0 -0
  99. package/es/babel-plugin-import-option.d.ts +0 -7
  100. package/es/back-top/index.d.ts +0 -5
  101. package/es/input/style/amount/index.d.ts +0 -2
  102. package/es/input/style/index.d.ts +0 -2
  103. package/es/input/style/input-date/index.d.ts +0 -2
  104. package/es/input/style/otp/index.d.ts +0 -2
  105. package/es/input/style/phone-number/index.d.ts +0 -2
  106. package/es/input/style/text-area/index.d.ts +0 -2
  107. package/es/locale/locale-provider.d.ts +0 -11
  108. package/es/login-page/index.d.ts +0 -7
  109. package/es/message/style/index.d.ts +0 -1
  110. package/es/platform/platform-card/index.d.ts +0 -12
  111. package/es/platform/switch-platform/index.d.ts +0 -12
  112. package/es/tabs/index.d.ts +0 -15
  113. package/lib/admin-amount/style/index.d.ts +0 -0
  114. package/lib/babel-plugin-import-option.d.ts +0 -7
  115. package/lib/back-top/index.d.ts +0 -5
  116. package/lib/input/style/amount/index.d.ts +0 -2
  117. package/lib/input/style/index.d.ts +0 -2
  118. package/lib/input/style/input-date/index.d.ts +0 -2
  119. package/lib/input/style/otp/index.d.ts +0 -2
  120. package/lib/input/style/phone-number/index.d.ts +0 -2
  121. package/lib/input/style/text-area/index.d.ts +0 -2
  122. package/lib/locale/locale-provider.d.ts +0 -11
  123. package/lib/login-page/index.d.ts +0 -7
  124. package/lib/message/style/index.d.ts +0 -1
  125. package/lib/platform/platform-card/index.d.ts +0 -12
  126. package/lib/platform/switch-platform/index.d.ts +0 -12
  127. package/lib/tabs/index.d.ts +0 -15
  128. package/yarn-error.log +0 -16168
package/es/utils/tools.js CHANGED
@@ -1,3 +1,13 @@
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
+ 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; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _iterableToArrayLimit(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; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
11
  export var parseFileSize = function parseFileSize(size) {
2
12
  switch (true) {
3
13
  case size === undefined:
@@ -14,17 +24,20 @@ export var parseFileSize = function parseFileSize(size) {
14
24
  return ">1000GB";
15
25
  }
16
26
  };
17
- export function classifyType(type) {
18
- if (type.includes('image')) {
19
- return 'image';
27
+ export function classifyType(mimeType) {
28
+ var CONFIGS = [['image', 'image/jpeg image/apng image/avif image/bmp image/vnd.microsoft.icon image/png image/gif image/svg+xml image/tiff image/webp'], ['video', 'video/mp4 video/x-msvideo video/mpeg video/ogg video/mp2t video/webm'], ['pdf', 'application/pdf'], ['eps', 'application/postscript'], ['doc', 'application/msword'], ['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'], ['xls', 'application/vnd.ms-excel'], ['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'], ['csv', 'text/csv'], ['ppt', 'application/vnd.ms-powerpoint'], ['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'], ['txt', 'text/plain']];
29
+ var type = 'unknown';
30
+ for (var i = 0, len = CONFIGS.length; i < len; i++) {
31
+ var _CONFIGS$i = _slicedToArray(CONFIGS[i], 2),
32
+ _type = _CONFIGS$i[0],
33
+ mimeListStr = _CONFIGS$i[1];
34
+ var typeList = mimeListStr.split(/[\s\n]+/);
35
+ if (typeList.includes(mimeType)) {
36
+ type = _type;
37
+ break;
38
+ }
20
39
  }
21
- if (type.includes('video')) {
22
- return 'video';
23
- }
24
- if (type.includes('pdf')) {
25
- return 'pdf';
26
- }
27
- return 'unknown';
40
+ return type;
28
41
  }
29
42
  export var downloadByUrl = function downloadByUrl(filename, url) {
30
43
  var pom = document.createElement('a');
@@ -44,4 +57,33 @@ export var getFileNameByUrl = function getFileNameByUrl(fileUrl) {
44
57
  var ary = url.pathname.split('/');
45
58
  var filename = ary[ary.length - 1].replace(/\.[^/.]+$/, '');
46
59
  return filename;
47
- };
60
+ };
61
+ export var getResourceContentType = /*#__PURE__*/function () {
62
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resourceUrl) {
63
+ var r, contentType;
64
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
65
+ while (1) switch (_context.prev = _context.next) {
66
+ case 0:
67
+ _context.prev = 0;
68
+ _context.next = 3;
69
+ return fetch(resourceUrl, {
70
+ cache: 'force-cache'
71
+ });
72
+ case 3:
73
+ r = _context.sent;
74
+ contentType = r.headers.get('Content-Type');
75
+ return _context.abrupt("return", contentType);
76
+ case 8:
77
+ _context.prev = 8;
78
+ _context.t0 = _context["catch"](0);
79
+ return _context.abrupt("return", 'unknown');
80
+ case 11:
81
+ case "end":
82
+ return _context.stop();
83
+ }
84
+ }, _callee, null, [[0, 8]]);
85
+ }));
86
+ return function getResourceContentType(_x2) {
87
+ return _ref.apply(this, arguments);
88
+ };
89
+ }();
@@ -11,5 +11,5 @@ declare const Documents: FC<{
11
11
  docNames?: string[];
12
12
  showAllPages?: boolean;
13
13
  destroyOnClose?: boolean;
14
- } & Pick<MediaWithPreviewProps, 'download'>>;
14
+ } & Pick<MediaWithPreviewProps, 'getNonCORSUrl' | 'download'>>;
15
15
  export default Documents;
@@ -10,15 +10,9 @@ var _invariant = _interopRequireDefault(require("invariant"));
10
10
  var _media = _interopRequireDefault(require("../media"));
11
11
  var _tools = require("../utils/tools");
12
12
  var _jsxRuntime = require("react/jsx-runtime");
13
- var _excluded = ["docList", "docNames", "className", "style", "showAllPages", "destroyOnClose"];
14
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
14
  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); }
16
15
  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; }
17
- 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; }
18
- 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; }
19
- 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; }
20
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
21
- 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); }
22
16
  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; }
23
17
  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
18
  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); } }
@@ -29,8 +23,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
29
23
  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; }
30
24
  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; } }
31
25
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
32
- 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; }
33
- 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; }
34
26
  var Documents = function Documents(_ref) {
35
27
  var _ref$docList = _ref.docList,
36
28
  docList = _ref$docList === void 0 ? [] : _ref$docList,
@@ -42,7 +34,8 @@ var Documents = function Documents(_ref) {
42
34
  showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
43
35
  _ref$destroyOnClose = _ref.destroyOnClose,
44
36
  destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose,
45
- mediaPreviewProps = _objectWithoutProperties(_ref, _excluded);
37
+ getNonCORSUrl = _ref.getNonCORSUrl,
38
+ download = _ref.download;
46
39
  var _useState = (0, _react.useState)(0),
47
40
  _useState2 = _slicedToArray(_useState, 2),
48
41
  current = _useState2[0],
@@ -54,7 +47,7 @@ var Documents = function Documents(_ref) {
54
47
  (0, _react.useEffect)(function () {
55
48
  var typedList = docList.map( /*#__PURE__*/function () {
56
49
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(srcConfig) {
57
- var src, type, r, contentType, _type;
50
+ var src, _type, nonCORSSrc, contentType, type;
58
51
  return _regeneratorRuntime().wrap(function _callee$(_context) {
59
52
  while (1) switch (_context.prev = _context.next) {
60
53
  case 0:
@@ -62,36 +55,30 @@ var Documents = function Documents(_ref) {
62
55
  _context.next = 5;
63
56
  break;
64
57
  }
65
- src = srcConfig.src, type = srcConfig.type;
58
+ src = srcConfig.src, _type = srcConfig.type;
66
59
  (0, _invariant.default)(typeof src === 'string', 'When the item in docList is object, it must has a src attribute.');
67
- (0, _invariant.default)(typeof type === 'string', 'When the item in docList is object, it must has a type attribute.');
60
+ (0, _invariant.default)(typeof _type === 'string', 'When the item in docList is object, it must has a type attribute.');
68
61
  return _context.abrupt("return", srcConfig);
69
62
  case 5:
70
- _context.prev = 5;
71
- _context.next = 8;
72
- return fetch(srcConfig, {
73
- cache: 'force-cache'
74
- });
75
- case 8:
76
- r = _context.sent;
77
- contentType = r.headers.get('content-type');
78
- _type = (0, _tools.classifyType)(contentType);
79
- return _context.abrupt("return", {
80
- type: _type,
81
- src: srcConfig
82
- });
83
- case 14:
84
- _context.prev = 14;
85
- _context.t0 = _context["catch"](5);
63
+ _context.next = 7;
64
+ return getNonCORSUrl === null || getNonCORSUrl === void 0 ? void 0 : getNonCORSUrl(srcConfig);
65
+ case 7:
66
+ nonCORSSrc = _context.sent;
67
+ _context.next = 10;
68
+ return (0, _tools.getResourceContentType)(nonCORSSrc !== null && nonCORSSrc !== void 0 ? nonCORSSrc : srcConfig);
69
+ case 10:
70
+ contentType = _context.sent;
71
+ type = (0, _tools.classifyType)(contentType);
86
72
  return _context.abrupt("return", {
87
- type: 'unknown',
88
- src: srcConfig
73
+ type: type,
74
+ src: srcConfig,
75
+ nonCORSSrc: nonCORSSrc
89
76
  });
90
- case 17:
77
+ case 13:
91
78
  case "end":
92
79
  return _context.stop();
93
80
  }
94
- }, _callee, null, [[5, 14]]);
81
+ }, _callee);
95
82
  }));
96
83
  return function (_x2) {
97
84
  return _ref2.apply(this, arguments);
@@ -114,13 +101,18 @@ var Documents = function Documents(_ref) {
114
101
  size: [8, 8],
115
102
  wrap: true,
116
103
  children: list.map(function (_ref3, index) {
117
- var src = _ref3.src,
118
- type = _ref3.type;
104
+ var _src = _ref3.src,
105
+ type = _ref3.type,
106
+ nonCORSSrc = _ref3.nonCORSSrc;
107
+ var src = !!nonCORSSrc ? {
108
+ origin: _src,
109
+ nonCORS: nonCORSSrc
110
+ } : _src;
119
111
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
120
112
  style: {
121
113
  left: "".concat((index - current) * 100, "%")
122
114
  },
123
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_media.default, _objectSpread({
115
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_media.default, {
124
116
  list: list,
125
117
  index: index,
126
118
  src: src,
@@ -130,8 +122,10 @@ var Documents = function Documents(_ref) {
130
122
  style: style,
131
123
  name: docNames[index],
132
124
  showAllPages: showAllPages,
133
- destroyOnClose: destroyOnClose
134
- }, mediaPreviewProps))
125
+ destroyOnClose: destroyOnClose,
126
+ download: download,
127
+ getNonCORSUrl: getNonCORSUrl
128
+ })
135
129
  }, index);
136
130
  })
137
131
  });
@@ -22,6 +22,7 @@
22
22
  "Data Processing...": "Data Processing...",
23
23
  "Date": "Date",
24
24
  "Done": "Done",
25
+ "Download": "Download",
25
26
  "Drag and drop a file here": "Drag and drop a file here",
26
27
  "Edit": "Edit",
27
28
  "Encrypted PDF": "Encrypted PDF",
@@ -22,6 +22,7 @@
22
22
  "Data Processing...": "Data Diproses",
23
23
  "Date": "Tanggal",
24
24
  "Done": "Selesai",
25
+ "Download": "",
25
26
  "Drag and drop a file here": "Geser dan Letakkan Dokumen disini",
26
27
  "Edit": "Ubah",
27
28
  "Encrypted PDF": "PDF terenkripsi",
@@ -22,6 +22,7 @@
22
22
  "Data Processing...": "กำลังประมวลผลข้อมูล...",
23
23
  "Date": "วันที่",
24
24
  "Done": "เสร็จแล้ว",
25
+ "Download": "",
25
26
  "Drag and drop a file here": "ลากและวางไฟล์มาที่นี่",
26
27
  "Edit": "แก้ไข",
27
28
  "Encrypted PDF": "PDF ที่เข้ารหัส",
@@ -22,6 +22,7 @@
22
22
  "Data Processing...": "Đang xử lý dữ liệu...",
23
23
  "Date": "Ngày",
24
24
  "Done": "Xong",
25
+ "Download": "",
25
26
  "Drag and drop a file here": "Thả tệp tin vào đây",
26
27
  "Edit": "Sửa",
27
28
  "Encrypted PDF": "PDF được mã hóa",
@@ -22,6 +22,7 @@
22
22
  "Data Processing...": "导入中",
23
23
  "Date": "日期",
24
24
  "Done": "完成",
25
+ "Download": "",
25
26
  "Drag and drop a file here": "拖拽一个文件到这里",
26
27
  "Edit": "编辑",
27
28
  "Encrypted PDF": "加密的PDF文件",
@@ -22,6 +22,7 @@
22
22
  "Data Processing...": "數據處理中。。。",
23
23
  "Date": "日期",
24
24
  "Done": "完成",
25
+ "Download": "",
25
26
  "Drag and drop a file here": "拖放文件至此",
26
27
  "Edit": "編輯",
27
28
  "Encrypted PDF": "",
@@ -0,0 +1,9 @@
1
+ import type { FC } from 'react';
2
+ import './style/file-icon.less';
3
+ type Props = {
4
+ type: string;
5
+ onDownloadClick?: () => void;
6
+ disabledDownload?: boolean;
7
+ };
8
+ declare const FileIcon: FC<Props>;
9
+ export default FileIcon;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _iglooicon = require("iglooicon");
9
+ var _locale = require("../locale");
10
+ require("./style/file-icon.less");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+ 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."); }
14
+ 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); }
15
+ 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; }
16
+ 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; } }
17
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
+ var INIT_BG_COLOR = '#FFFFFF';
19
+ var DEFAULT_BG_COLOR = '#5858FF';
20
+ var CONFIG_COLORS = [['#5858FF', 'jpeg jpg png eps gif svg tiff img webp'], ['#0E7AE3', 'doc dox'], ['#108043', 'xls xlsx csv'], ['#DE3618', 'ppt pptx pdf'], ['#666666', 'txt']];
21
+ var getColor = function getColor(type) {
22
+ var color = INIT_BG_COLOR;
23
+ for (var i = 0, len = CONFIG_COLORS.length; i < len; i++) {
24
+ var _CONFIG_COLORS$i = _slicedToArray(CONFIG_COLORS[i], 2),
25
+ hex = _CONFIG_COLORS$i[0],
26
+ typeListStr = _CONFIG_COLORS$i[1];
27
+ var typeList = typeListStr.split(/[\s\n]+/);
28
+ if (typeList.includes(type)) {
29
+ color = hex;
30
+ break;
31
+ }
32
+ }
33
+ // fix icon flashing issue
34
+ return color === INIT_BG_COLOR ? DEFAULT_BG_COLOR : color;
35
+ };
36
+ var getType = function getType(type) {
37
+ return type === 'unknown' ? 'File' : type.toUpperCase();
38
+ };
39
+ var FileIcon = function FileIcon(props) {
40
+ var typeProp = props.type,
41
+ onDownloadClick = props.onDownloadClick,
42
+ disabledDownload = props.disabledDownload;
43
+ var _useContext = (0, _react.useContext)(_locale.LocaleContext),
44
+ formatMessage = _useContext.formatMessage;
45
+ var color = getColor(typeProp);
46
+ var type = getType(typeProp);
47
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
48
+ className: "igloo-media-file-container",
49
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
50
+ width: "48",
51
+ height: "48",
52
+ viewBox: "0 0 48 48",
53
+ fill: "none",
54
+ xmlns: "http://www.w3.org/2000/svg",
55
+ style: {
56
+ userSelect: 'none'
57
+ },
58
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
59
+ d: "M41.0195 16.279V40.9995C41.0195 43.3015 39.1535 45.1675 36.8515 45.1675H11.1485C8.84647 45.1675 6.98047 43.3015 6.98047 40.9995V7.00003C6.98047 4.69803 8.84647 2.83203 11.1485 2.83203H28.364L41.0195 16.279Z",
60
+ fill: color
61
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
62
+ d: "M36.849 46H11.146C8.38803 46 6.14453 43.756 6.14453 40.999V7.001C6.14403 4.244 8.38803 2 11.146 2H28.3615C28.5915 2 28.811 2.095 28.9685 2.2605L41.6245 15.706C41.77 15.8605 41.851 16.067 41.851 16.2785V40.999C41.851 43.756 39.607 46 36.849 46ZM11.146 3.666C9.30753 3.666 7.81153 5.161 7.81153 7.001V40.999C7.81153 42.839 9.30753 44.334 11.146 44.334H36.8495C38.688 44.334 40.184 42.839 40.184 40.999V16.6095L28.001 3.666H11.146Z",
63
+ fill: color
64
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
65
+ d: "M41.0188 16.279H31.1418C29.6073 16.279 28.3633 15.035 28.3633 13.5005V2.83203L41.0188 16.279Z",
66
+ fill: "white",
67
+ fillOpacity: "0.8"
68
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
69
+ d: "M41.0208 17.1125H31.1437C29.1522 17.1125 27.5312 15.4925 27.5312 13.501V2.83397C27.5312 2.49197 27.7397 2.18547 28.0577 2.05797C28.3747 1.93597 28.7378 2.01747 28.9723 2.26147L41.6282 15.707C41.8562 15.951 41.9183 16.304 41.7863 16.6105C41.6543 16.9145 41.3533 17.1125 41.0208 17.1125ZM29.1987 4.93697V13.501C29.1987 14.573 30.0712 15.4465 31.1437 15.4465H39.0918L29.1987 4.93697Z",
70
+ fill: color
71
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("text", {
72
+ x: "24",
73
+ y: "34",
74
+ fill: "white",
75
+ fontSize: "12",
76
+ fontFamily: "Arial",
77
+ fontWeight: "bold",
78
+ textAnchor: "middle",
79
+ children: type
80
+ })]
81
+ }), !disabledDownload && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
82
+ className: "igloo-media-file-mask",
83
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
84
+ className: "igloo-media-file-download-container",
85
+ onClick: onDownloadClick,
86
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_iglooicon.DownloadOutlined, {
87
+ className: "igloo-media-file-download-icon"
88
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
89
+ className: "igloo-media-file-download-text",
90
+ children: formatMessage({
91
+ id: 'Download'
92
+ })
93
+ })]
94
+ })
95
+ })]
96
+ });
97
+ };
98
+ var _default = FileIcon;
99
+ exports.default = _default;
@@ -1,17 +1,21 @@
1
1
  import { FC, CSSProperties } from 'react';
2
2
  import './style';
3
- type Download = boolean | {
4
- getUrl: (src: string) => Promise<string> | string;
3
+ type Download = false | {
5
4
  actionType?: 'downloadBlob' | 'openUrl';
6
5
  };
6
+ type GetNonCORSUrl = (originUrl: string) => Promise<string> | string;
7
7
  interface Props {
8
- src: string;
8
+ src: string | {
9
+ origin: string;
10
+ nonCORS: string;
11
+ };
9
12
  name?: string;
10
- type?: 'image' | 'video' | 'pdf';
13
+ type?: string;
11
14
  index?: number;
12
15
  list?: Array<{
13
16
  type: string;
14
17
  src: string;
18
+ nonCORSSrc?: string;
15
19
  }>;
16
20
  docNames?: string[];
17
21
  className?: any;
@@ -19,6 +23,7 @@ interface Props {
19
23
  showAllPages?: boolean;
20
24
  destroyOnClose?: boolean;
21
25
  download?: Download;
26
+ getNonCORSUrl?: GetNonCORSUrl;
22
27
  }
23
28
  declare const MediaWithPreview: FC<Props>;
24
29
  export default MediaWithPreview;