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/media/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  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; }
2
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
2
  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
3
  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); }); }; }
4
+ 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); }
5
5
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
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
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); }
@@ -10,29 +10,18 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import React, { useState, useEffect } from 'react';
12
12
  import { Modal } from 'antd';
13
- import { downloadByUrl, getFileNameByUrl } from "../utils/tools";
13
+ import { downloadByUrl, getFileNameByUrl, getResourceContentType, classifyType } from "../utils/tools";
14
14
  import Media from "./media";
15
15
  import PreviewMedia from "./preview";
16
16
  import classnames from 'classnames';
17
17
  import Typography from "../typography";
18
+ import FileIcon from "./file-icon";
18
19
  import { MinusOutlined, PlusOutlined, ArrowRightOutlined, ArrowLeftOutlined, CrossOutlined, DownloadOutlined } from 'iglooicon';
19
20
  import "./style";
20
21
  import { jsx as _jsx } from "react/jsx-runtime";
21
22
  import { jsxs as _jsxs } from "react/jsx-runtime";
22
- function ClassifyType(type) {
23
- if (type.includes('image')) {
24
- return 'image';
25
- }
26
- if (type.includes('video')) {
27
- return 'video';
28
- }
29
- if (type.includes('pdf')) {
30
- return 'pdf';
31
- }
32
- return 'unknown';
33
- }
34
23
  var MediaWithPreview = function MediaWithPreview(_ref) {
35
- var src = _ref.src,
24
+ var srcProp = _ref.src,
36
25
  name = _ref.name,
37
26
  className = _ref.className,
38
27
  _ref$index = _ref.index,
@@ -48,43 +37,88 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
48
37
  showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
49
38
  _ref$destroyOnClose = _ref.destroyOnClose,
50
39
  destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose,
51
- download = _ref.download;
52
- var _useState = useState(1),
40
+ _ref$download = _ref.download,
41
+ download = _ref$download === void 0 ? {
42
+ actionType: 'downloadBlob'
43
+ } : _ref$download,
44
+ getNonCORSUrl = _ref.getNonCORSUrl;
45
+ var _ref2 = _typeof(srcProp) === 'object' ? [srcProp.origin, srcProp.nonCORS] : [srcProp],
46
+ _ref3 = _slicedToArray(_ref2, 2),
47
+ src = _ref3[0],
48
+ nonCORSSrcProp = _ref3[1];
49
+ var _useState = useState(nonCORSSrcProp),
53
50
  _useState2 = _slicedToArray(_useState, 2),
54
- scale = _useState2[0],
55
- setScale = _useState2[1];
56
- var _useState3 = useState(type),
51
+ nonCORSSrc = _useState2[0],
52
+ setNonCORSSrc = _useState2[1];
53
+ var _useState3 = useState(1),
57
54
  _useState4 = _slicedToArray(_useState3, 2),
58
- mediaType = _useState4[0],
59
- setType = _useState4[1];
60
- var _useState5 = useState(false),
55
+ scale = _useState4[0],
56
+ setScale = _useState4[1];
57
+ var _useState5 = useState(type),
61
58
  _useState6 = _slicedToArray(_useState5, 2),
62
- showModal = _useState6[0],
63
- setShowModal = _useState6[1];
64
- var _useState7 = useState(index),
59
+ mediaType = _useState6[0],
60
+ setType = _useState6[1];
61
+ var _useState7 = useState(false),
65
62
  _useState8 = _slicedToArray(_useState7, 2),
66
- current = _useState8[0],
67
- setCurrent = _useState8[1];
68
- var _useState9 = useState(''),
63
+ showModal = _useState8[0],
64
+ setShowModal = _useState8[1];
65
+ var _useState9 = useState(index),
69
66
  _useState10 = _slicedToArray(_useState9, 2),
70
- direction = _useState10[0],
71
- setDirection = _useState10[1];
67
+ current = _useState10[0],
68
+ setCurrent = _useState10[1];
69
+ var _useState11 = useState(''),
70
+ _useState12 = _slicedToArray(_useState11, 2),
71
+ direction = _useState12[0],
72
+ setDirection = _useState12[1];
73
+ useEffect(function () {
74
+ setNonCORSSrc(nonCORSSrcProp);
75
+ }, [nonCORSSrcProp]);
72
76
  useEffect(function () {
73
77
  if (mediaType) {
74
78
  return;
75
79
  }
76
80
  var unmounted = false;
77
- fetch(src, {
78
- cache: 'force-cache'
79
- }).then(function (r) {
80
- var contentType = r.headers.get('content-type');
81
- var typeClass = ClassifyType(contentType);
82
- !unmounted && setType(typeClass);
83
- });
81
+ var execute = /*#__PURE__*/function () {
82
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
83
+ var _nonCORSSrc, contentType, typeClass;
84
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
85
+ while (1) switch (_context.prev = _context.next) {
86
+ case 0:
87
+ _context.t0 = nonCORSSrc;
88
+ if (_context.t0) {
89
+ _context.next = 5;
90
+ break;
91
+ }
92
+ _context.next = 4;
93
+ return getNonCORSUrl === null || getNonCORSUrl === void 0 ? void 0 : getNonCORSUrl(src);
94
+ case 4:
95
+ _context.t0 = _context.sent;
96
+ case 5:
97
+ _nonCORSSrc = _context.t0;
98
+ _context.next = 8;
99
+ return getResourceContentType(_nonCORSSrc !== null && _nonCORSSrc !== void 0 ? _nonCORSSrc : src);
100
+ case 8:
101
+ contentType = _context.sent;
102
+ typeClass = classifyType(contentType);
103
+ if (!unmounted) {
104
+ !nonCORSSrc && setNonCORSSrc(_nonCORSSrc);
105
+ setType(typeClass);
106
+ }
107
+ case 11:
108
+ case "end":
109
+ return _context.stop();
110
+ }
111
+ }, _callee);
112
+ }));
113
+ return function execute() {
114
+ return _ref4.apply(this, arguments);
115
+ };
116
+ }();
117
+ execute();
84
118
  return function () {
85
119
  unmounted = true;
86
120
  };
87
- }, [src]);
121
+ }, [src, nonCORSSrc]);
88
122
  useEffect(function () {
89
123
  var handleKeyDown = function handleKeyDown(e) {
90
124
  if (!showModal || list.length === 1) return;
@@ -100,12 +134,34 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
100
134
  return document.body.removeEventListener('keydown', handleKeyDown);
101
135
  };
102
136
  }, [showModal]);
103
- var getCurrentUrl = function getCurrentUrl() {
104
- var _list$current;
105
- var isList = Boolean(list && !!list.length);
106
- if (!isList) return src;
107
- return list === null || list === void 0 ? void 0 : (_list$current = list[current]) === null || _list$current === void 0 ? void 0 : _list$current.src;
108
- };
137
+ var canRenderMedia = ['pdf', 'video', 'image'].includes(mediaType);
138
+ var getCurrentDownloadUrl = /*#__PURE__*/function () {
139
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
140
+ var _ref7;
141
+ var isList, _ref6, _current, _nonCORSSrc, _src;
142
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
143
+ while (1) switch (_context2.prev = _context2.next) {
144
+ case 0:
145
+ isList = Boolean(list && !!list.length);
146
+ if (isList) {
147
+ _context2.next = 3;
148
+ break;
149
+ }
150
+ 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);
151
+ case 3:
152
+ _current = list === null || list === void 0 ? void 0 : list[current];
153
+ _nonCORSSrc = _current.nonCORSSrc, _src = _current.src;
154
+ 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);
155
+ case 6:
156
+ case "end":
157
+ return _context2.stop();
158
+ }
159
+ }, _callee2);
160
+ }));
161
+ return function getCurrentDownloadUrl() {
162
+ return _ref5.apply(this, arguments);
163
+ };
164
+ }();
109
165
  var open = function open() {
110
166
  setShowModal(true);
111
167
  };
@@ -150,58 +206,124 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
150
206
  setScale(scale + 0.2);
151
207
  };
152
208
  var onDownloadClick = /*#__PURE__*/function () {
153
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
154
- var currentUrl, filename, downloadUrl, actionType, res, blob, url;
155
- return _regeneratorRuntime().wrap(function _callee$(_context) {
156
- while (1) switch (_context.prev = _context.next) {
209
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(downloadUrl) {
210
+ var filename, actionType, res, blob, url;
211
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
212
+ while (1) switch (_context3.prev = _context3.next) {
157
213
  case 0:
158
- currentUrl = getCurrentUrl();
159
- filename = getFileNameByUrl(currentUrl);
160
- downloadUrl = currentUrl;
161
- actionType = 'downloadBlob';
162
- if (!(_typeof(download) === 'object')) {
163
- _context.next = 10;
214
+ filename = getFileNameByUrl(downloadUrl);
215
+ if (download) {
216
+ _context3.next = 3;
164
217
  break;
165
218
  }
166
- if (!(download !== null && download !== void 0 && download.getUrl)) {
167
- _context.next = 9;
168
- break;
169
- }
170
- _context.next = 8;
171
- return download.getUrl(currentUrl);
172
- case 8:
173
- downloadUrl = _context.sent;
174
- case 9:
175
- if (download !== null && download !== void 0 && download.actionType) {
176
- actionType = download.actionType;
177
- }
178
- case 10:
219
+ return _context3.abrupt("return");
220
+ case 3:
221
+ actionType = download.actionType;
179
222
  if (!(actionType === 'downloadBlob')) {
180
- _context.next = 21;
223
+ _context3.next = 21;
181
224
  break;
182
225
  }
183
- _context.next = 13;
226
+ _context3.prev = 5;
227
+ _context3.next = 8;
184
228
  return fetch(downloadUrl);
185
- case 13:
186
- res = _context.sent;
187
- _context.next = 16;
229
+ case 8:
230
+ res = _context3.sent;
231
+ _context3.next = 11;
188
232
  return res.blob();
189
- case 16:
190
- blob = _context.sent;
233
+ case 11:
234
+ blob = _context3.sent;
191
235
  url = window.URL.createObjectURL(blob);
192
236
  downloadByUrl(filename, url);
193
- _context.next = 22;
237
+ _context3.next = 19;
238
+ break;
239
+ case 16:
240
+ _context3.prev = 16;
241
+ _context3.t0 = _context3["catch"](5);
242
+ console.warn(_context3.t0.message);
243
+ case 19:
244
+ _context3.next = 22;
194
245
  break;
195
246
  case 21:
196
247
  downloadByUrl(filename, downloadUrl);
197
248
  case 22:
198
249
  case "end":
199
- return _context.stop();
250
+ return _context3.stop();
200
251
  }
201
- }, _callee);
252
+ }, _callee3, null, [[5, 16]]);
202
253
  }));
203
- return function onDownloadClick() {
204
- return _ref2.apply(this, arguments);
254
+ return function onDownloadClick(_x2) {
255
+ return _ref8.apply(this, arguments);
256
+ };
257
+ }();
258
+ var onDownloadByModal = /*#__PURE__*/function () {
259
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
260
+ var downloadUrl;
261
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
262
+ while (1) switch (_context4.prev = _context4.next) {
263
+ case 0:
264
+ _context4.next = 2;
265
+ return getCurrentDownloadUrl();
266
+ case 2:
267
+ downloadUrl = _context4.sent;
268
+ return _context4.abrupt("return", onDownloadClick(downloadUrl));
269
+ case 4:
270
+ case "end":
271
+ return _context4.stop();
272
+ }
273
+ }, _callee4);
274
+ }));
275
+ return function onDownloadByModal() {
276
+ return _ref9.apply(this, arguments);
277
+ };
278
+ }();
279
+ var onDownloadByFileIcon = /*#__PURE__*/function () {
280
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
281
+ var _ref11;
282
+ var downloadUrl;
283
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
284
+ while (1) switch (_context5.prev = _context5.next) {
285
+ case 0:
286
+ if (!(nonCORSSrc !== null && nonCORSSrc !== void 0)) {
287
+ _context5.next = 4;
288
+ break;
289
+ }
290
+ _context5.t1 = nonCORSSrc;
291
+ _context5.next = 7;
292
+ break;
293
+ case 4:
294
+ _context5.next = 6;
295
+ return getNonCORSUrl === null || getNonCORSUrl === void 0 ? void 0 : getNonCORSUrl(src);
296
+ case 6:
297
+ _context5.t1 = _context5.sent;
298
+ case 7:
299
+ _context5.t2 = _ref11 = _context5.t1;
300
+ _context5.t0 = _context5.t2 !== null;
301
+ if (!_context5.t0) {
302
+ _context5.next = 11;
303
+ break;
304
+ }
305
+ _context5.t0 = _ref11 !== void 0;
306
+ case 11:
307
+ if (!_context5.t0) {
308
+ _context5.next = 15;
309
+ break;
310
+ }
311
+ _context5.t3 = _ref11;
312
+ _context5.next = 16;
313
+ break;
314
+ case 15:
315
+ _context5.t3 = src;
316
+ case 16:
317
+ downloadUrl = _context5.t3;
318
+ return _context5.abrupt("return", onDownloadClick(downloadUrl));
319
+ case 18:
320
+ case "end":
321
+ return _context5.stop();
322
+ }
323
+ }, _callee5);
324
+ }));
325
+ return function onDownloadByFileIcon() {
326
+ return _ref10.apply(this, arguments);
205
327
  };
206
328
  }();
207
329
  var getTranslateX = function getTranslateX(index) {
@@ -236,11 +358,15 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
236
358
  return /*#__PURE__*/_jsxs("div", {
237
359
  className: className,
238
360
  style: style,
239
- children: [/*#__PURE__*/_jsx(Media, {
361
+ children: [canRenderMedia ? /*#__PURE__*/_jsx(Media, {
240
362
  type: mediaType,
241
363
  src: src,
242
364
  onClick: open,
243
365
  name: name
366
+ }) : /*#__PURE__*/_jsx(FileIcon, {
367
+ type: mediaType,
368
+ onDownloadClick: onDownloadByFileIcon,
369
+ disabledDownload: !download
244
370
  }), /*#__PURE__*/_jsxs(Modal, {
245
371
  open: showModal,
246
372
  onCancel: close,
@@ -265,9 +391,9 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
265
391
  })]
266
392
  }), /*#__PURE__*/_jsxs("div", {
267
393
  className: "igloo-media-list",
268
- children: [Boolean(list && !!list.length) && list.map(function (_ref3, index) {
269
- var src = _ref3.src,
270
- type = _ref3.type;
394
+ children: [Boolean(list && !!list.length) && list.map(function (_ref12, index) {
395
+ var src = _ref12.src,
396
+ type = _ref12.type;
271
397
  return /*#__PURE__*/_jsx("div", {
272
398
  className: classnames({
273
399
  'igloo-media-animating': needShowAnimation(index),
@@ -313,7 +439,7 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
313
439
  fontSize: 24
314
440
  }
315
441
  }), download && /*#__PURE__*/_jsx(DownloadOutlined, {
316
- onClick: onDownloadClick,
442
+ onClick: onDownloadByModal,
317
443
  className: classnames({
318
444
  'igloo-preview-action-btn': true,
319
445
  'igloo-preview-download-btn': true
@@ -15,6 +15,8 @@ import { Document, Page } from 'react-pdf/dist/esm/entry.webpack';
15
15
  import classnames from 'classnames';
16
16
  import { ArrowLeftOutlined, ArrowRightOutlined } from 'iglooicon';
17
17
  import { Grid, message } from 'antd';
18
+ import { ErrorFilled } from 'iglooicon';
19
+ import Typography from "../typography";
18
20
  import Modal from "../modal";
19
21
  import Password from "../input/password";
20
22
  import Button from "../button";
@@ -210,6 +212,8 @@ var MediaItem = function MediaItem(_ref3) {
210
212
  showAllPages = _ref3.showAllPages;
211
213
  var top = offset.top,
212
214
  left = offset.left;
215
+ var _useContext2 = useContext(LocaleContext),
216
+ formatMessage = _useContext2.formatMessage;
213
217
  switch (type) {
214
218
  case 'video':
215
219
  return /*#__PURE__*/_jsx("video", {
@@ -229,7 +233,7 @@ var MediaItem = function MediaItem(_ref3) {
229
233
  isCurrent: isCurrent,
230
234
  showAllPages: showAllPages
231
235
  });
232
- default:
236
+ case 'image':
233
237
  return /*#__PURE__*/_jsx("img", {
234
238
  src: src,
235
239
  style: {
@@ -239,6 +243,19 @@ var MediaItem = function MediaItem(_ref3) {
239
243
  position: 'absolute'
240
244
  }
241
245
  });
246
+ default:
247
+ return /*#__PURE__*/_jsxs("div", {
248
+ className: "igloo-upload-prevew-not-supported",
249
+ children: [/*#__PURE__*/_jsx(ErrorFilled, {
250
+ className: "igloo-upload-prevew-not-supported-icon"
251
+ }), /*#__PURE__*/_jsx(Typography, {
252
+ level: "body1",
253
+ className: "igloo-upload-prevew-not-supported-text",
254
+ children: formatMessage({
255
+ id: 'No preview for this file. Only support image, video or PDF file.'
256
+ })
257
+ })]
258
+ });
242
259
  }
243
260
  };
244
261
  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
+ }
@@ -11,7 +11,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import { useState, useEffect, useContext } from 'react';
12
12
  import Typography from "../typography";
13
13
  import Modal from "../modal";
14
- import { classifyType } from "../utils/tools";
14
+ import { classifyType, getResourceContentType } from "../utils/tools";
15
15
  import Media from "./media";
16
16
  import Button from "../button";
17
17
  import { AttachOutlined, ArrowLeftOutlined, ArrowRightOutlined } from 'iglooicon';
@@ -47,23 +47,20 @@ var UploadPreview = function UploadPreview(_ref) {
47
47
  if (!files || !files.length) return;
48
48
  var typedList = files.map( /*#__PURE__*/function () {
49
49
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(src) {
50
- var r, contentType, type;
50
+ var contentType, type;
51
51
  return _regeneratorRuntime().wrap(function _callee$(_context) {
52
52
  while (1) switch (_context.prev = _context.next) {
53
53
  case 0:
54
54
  _context.next = 2;
55
- return fetch(src, {
56
- cache: 'force-cache'
57
- });
55
+ return getResourceContentType(src);
58
56
  case 2:
59
- r = _context.sent;
60
- contentType = r.headers.get('content-type');
61
- type = contentType ? classifyType(contentType) : 'unknown';
57
+ contentType = _context.sent;
58
+ type = classifyType(contentType);
62
59
  return _context.abrupt("return", {
63
60
  type: type,
64
61
  src: src
65
62
  });
66
- case 6:
63
+ case 5:
67
64
  case "end":
68
65
  return _context.stop();
69
66
  }
@@ -51,7 +51,7 @@ export declare const calcFormItemProps: (config: FormItemConfig, extraProps: For
51
51
  elementProps: {
52
52
  [key: string]: any;
53
53
  };
54
- display: number;
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;
@@ -364,7 +364,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
364
364
  dependencies: antdDependencies
365
365
  },
366
366
  elementProps: elementProps,
367
- display: !ignore & calcShouldRender(name, dependencies, asserts, shouldRender, shouldRenderCode, form),
367
+ display: !ignore && calcShouldRender(name, dependencies, asserts, shouldRender, shouldRenderCode, form),
368
368
  previewFormater: previewFormater || extraPreviewFormater
369
369
  };
370
370
  };
@@ -1,4 +1,5 @@
1
1
  export declare const parseFileSize: (size: number) => string;
2
- export declare function classifyType(type: string): "image" | "video" | "pdf" | "unknown";
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>;