iglooform 3.0.14 → 3.0.16

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 (77) hide show
  1. package/.dumi/tmp/core/defineApp.ts +1 -2
  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 +1 -6
  6. package/.dumi/tmp/core/pluginConfig.ts +0 -11
  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 +4 -5
  48. package/.dumi/tmp/testBrowser.tsx +2 -4
  49. package/.dumi/tmp/umi.ts +3 -5
  50. package/.idea/codeStyles/Project.xml +59 -0
  51. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  52. package/.idea/iglooform.iml +7 -4
  53. package/.idea/prettier.xml +6 -0
  54. package/es/documents/index.d.ts +10 -3
  55. package/es/documents/index.js +42 -19
  56. package/es/media/index.d.ts +5 -0
  57. package/es/media/index.js +83 -7
  58. package/es/media/style/index.less +5 -1
  59. package/es/utils/form-utils.d.ts +1 -1
  60. package/es/utils/form-utils.js +1 -1
  61. package/es/utils/tools.d.ts +2 -0
  62. package/es/utils/tools.js +20 -1
  63. package/lib/documents/index.d.ts +10 -3
  64. package/lib/documents/index.js +42 -19
  65. package/lib/media/index.d.ts +5 -0
  66. package/lib/media/index.js +82 -7
  67. package/lib/media/style/index.less +5 -1
  68. package/lib/utils/form-utils.d.ts +1 -1
  69. package/lib/utils/form-utils.js +1 -1
  70. package/lib/utils/tools.d.ts +2 -0
  71. package/lib/utils/tools.js +23 -2
  72. package/package.json +1 -1
  73. package/yarn-error.log +16168 -0
  74. package/.dumi/tmp/plugin-antd/runtime.tsx +0 -65
  75. package/.dumi/tmp/plugin-antd/runtimeConfig.d.ts +0 -6
  76. package/.dumi/tmp/plugin-antd/types.d.ts +0 -14
  77. package/.idea/misc.xml +0 -5
@@ -1,19 +1,26 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
7
  var _react = _interopRequireWildcard(require("react"));
9
8
  var _antd = require("antd");
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"];
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  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); }
15
16
  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); }
16
22
  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
+ 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); }
17
24
  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); } }
18
25
  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); }); }; }
19
26
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -22,15 +29,20 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
22
29
  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; }
23
30
  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; } }
24
31
  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; }
25
34
  var Documents = function Documents(_ref) {
26
35
  var _ref$docList = _ref.docList,
27
36
  docList = _ref$docList === void 0 ? [] : _ref$docList,
28
37
  _ref$docNames = _ref.docNames,
29
38
  docNames = _ref$docNames === void 0 ? [] : _ref$docNames,
39
+ className = _ref.className,
40
+ style = _ref.style,
30
41
  _ref$showAllPages = _ref.showAllPages,
31
42
  showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
32
43
  _ref$destroyOnClose = _ref.destroyOnClose,
33
- destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose;
44
+ destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose,
45
+ mediaPreviewProps = _objectWithoutProperties(_ref, _excluded);
34
46
  var _useState = (0, _react.useState)(0),
35
47
  _useState2 = _slicedToArray(_useState, 2),
36
48
  current = _useState2[0],
@@ -41,36 +53,45 @@ var Documents = function Documents(_ref) {
41
53
  setList = _useState4[1];
42
54
  (0, _react.useEffect)(function () {
43
55
  var typedList = docList.map( /*#__PURE__*/function () {
44
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(src) {
45
- var r, contentType, type;
56
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(srcConfig) {
57
+ var src, type, r, contentType, _type;
46
58
  return _regeneratorRuntime().wrap(function _callee$(_context) {
47
59
  while (1) switch (_context.prev = _context.next) {
48
60
  case 0:
49
- _context.prev = 0;
50
- _context.next = 3;
51
- return fetch(src, {
61
+ if (!(_typeof(srcConfig) === 'object')) {
62
+ _context.next = 5;
63
+ break;
64
+ }
65
+ src = srcConfig.src, type = srcConfig.type;
66
+ (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.');
68
+ return _context.abrupt("return", srcConfig);
69
+ case 5:
70
+ _context.prev = 5;
71
+ _context.next = 8;
72
+ return fetch(srcConfig, {
52
73
  cache: 'force-cache'
53
74
  });
54
- case 3:
75
+ case 8:
55
76
  r = _context.sent;
56
77
  contentType = r.headers.get('content-type');
57
- type = (0, _tools.classifyType)(contentType);
78
+ _type = (0, _tools.classifyType)(contentType);
58
79
  return _context.abrupt("return", {
59
- type: type,
60
- src: src
80
+ type: _type,
81
+ src: srcConfig
61
82
  });
62
- case 9:
63
- _context.prev = 9;
64
- _context.t0 = _context["catch"](0);
83
+ case 14:
84
+ _context.prev = 14;
85
+ _context.t0 = _context["catch"](5);
65
86
  return _context.abrupt("return", {
66
87
  type: 'unknown',
67
- src: src
88
+ src: srcConfig
68
89
  });
69
- case 12:
90
+ case 17:
70
91
  case "end":
71
92
  return _context.stop();
72
93
  }
73
- }, _callee, null, [[0, 9]]);
94
+ }, _callee, null, [[5, 14]]);
74
95
  }));
75
96
  return function (_x2) {
76
97
  return _ref2.apply(this, arguments);
@@ -99,16 +120,18 @@ var Documents = function Documents(_ref) {
99
120
  style: {
100
121
  left: "".concat((index - current) * 100, "%")
101
122
  },
102
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_media.default, {
123
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_media.default, _objectSpread({
103
124
  list: list,
104
125
  index: index,
105
126
  src: src,
106
127
  type: type,
107
128
  docNames: docNames,
129
+ className: className,
130
+ style: style,
108
131
  name: docNames[index],
109
132
  showAllPages: showAllPages,
110
133
  destroyOnClose: destroyOnClose
111
- })
134
+ }, mediaPreviewProps))
112
135
  }, index);
113
136
  })
114
137
  });
@@ -1,5 +1,9 @@
1
1
  import { FC, CSSProperties } from 'react';
2
2
  import './style';
3
+ type Download = boolean | {
4
+ getUrl: (src: string) => Promise<string> | string;
5
+ actionType?: 'downloadBlob' | 'openUrl';
6
+ };
3
7
  interface Props {
4
8
  src: string;
5
9
  name?: string;
@@ -14,6 +18,7 @@ interface Props {
14
18
  style?: CSSProperties;
15
19
  showAllPages?: boolean;
16
20
  destroyOnClose?: boolean;
21
+ download?: Download;
17
22
  }
18
23
  declare const MediaWithPreview: FC<Props>;
19
24
  export default MediaWithPreview;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
7
  var _react = _interopRequireWildcard(require("react"));
9
8
  var _antd = require("antd");
9
+ var _tools = require("../utils/tools");
10
10
  var _media = _interopRequireDefault(require("./media"));
11
11
  var _preview = _interopRequireDefault(require("./preview"));
12
12
  var _classnames = _interopRequireDefault(require("classnames"));
@@ -17,6 +17,10 @@ var _jsxRuntime = require("react/jsx-runtime");
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
21
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
22
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
23
+ 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); }); }; }
20
24
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
21
25
  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."); }
22
26
  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); }
@@ -51,7 +55,8 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
51
55
  _ref$showAllPages = _ref.showAllPages,
52
56
  showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
53
57
  _ref$destroyOnClose = _ref.destroyOnClose,
54
- destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose;
58
+ destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose,
59
+ download = _ref.download;
55
60
  var _useState = (0, _react.useState)(1),
56
61
  _useState2 = _slicedToArray(_useState, 2),
57
62
  scale = _useState2[0],
@@ -103,6 +108,12 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
103
108
  return document.body.removeEventListener('keydown', handleKeyDown);
104
109
  };
105
110
  }, [showModal]);
111
+ var getCurrentUrl = function getCurrentUrl() {
112
+ var _list$current;
113
+ var isList = Boolean(list && !!list.length);
114
+ if (!isList) return src;
115
+ return list === null || list === void 0 ? void 0 : (_list$current = list[current]) === null || _list$current === void 0 ? void 0 : _list$current.src;
116
+ };
106
117
  var open = function open() {
107
118
  setShowModal(true);
108
119
  };
@@ -146,6 +157,61 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
146
157
  e.preventDefault();
147
158
  setScale(scale + 0.2);
148
159
  };
160
+ var onDownloadClick = /*#__PURE__*/function () {
161
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
162
+ var currentUrl, filename, downloadUrl, actionType, res, blob, url;
163
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
164
+ while (1) switch (_context.prev = _context.next) {
165
+ case 0:
166
+ currentUrl = getCurrentUrl();
167
+ filename = (0, _tools.getFileNameByUrl)(currentUrl);
168
+ downloadUrl = currentUrl;
169
+ actionType = 'downloadBlob';
170
+ if (!(_typeof(download) === 'object')) {
171
+ _context.next = 10;
172
+ break;
173
+ }
174
+ if (!(download !== null && download !== void 0 && download.getUrl)) {
175
+ _context.next = 9;
176
+ break;
177
+ }
178
+ _context.next = 8;
179
+ return download.getUrl(currentUrl);
180
+ case 8:
181
+ downloadUrl = _context.sent;
182
+ case 9:
183
+ if (download !== null && download !== void 0 && download.actionType) {
184
+ actionType = download.actionType;
185
+ }
186
+ case 10:
187
+ if (!(actionType === 'downloadBlob')) {
188
+ _context.next = 21;
189
+ break;
190
+ }
191
+ _context.next = 13;
192
+ return fetch(downloadUrl);
193
+ case 13:
194
+ res = _context.sent;
195
+ _context.next = 16;
196
+ return res.blob();
197
+ case 16:
198
+ blob = _context.sent;
199
+ url = window.URL.createObjectURL(blob);
200
+ (0, _tools.downloadByUrl)(filename, url);
201
+ _context.next = 22;
202
+ break;
203
+ case 21:
204
+ (0, _tools.downloadByUrl)(filename, downloadUrl);
205
+ case 22:
206
+ case "end":
207
+ return _context.stop();
208
+ }
209
+ }, _callee);
210
+ }));
211
+ return function onDownloadClick() {
212
+ return _ref2.apply(this, arguments);
213
+ };
214
+ }();
149
215
  var getTranslateX = function getTranslateX(index) {
150
216
  if (list.length < 3) {
151
217
  return index - current;
@@ -207,9 +273,9 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
207
273
  })]
208
274
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
209
275
  className: "igloo-media-list",
210
- children: [Boolean(list && !!list.length) && list.map(function (_ref2, index) {
211
- var src = _ref2.src,
212
- type = _ref2.type;
276
+ children: [Boolean(list && !!list.length) && list.map(function (_ref3, index) {
277
+ var src = _ref3.src,
278
+ type = _ref3.type;
213
279
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
214
280
  className: (0, _classnames.default)({
215
281
  'igloo-media-animating': needShowAnimation(index),
@@ -237,7 +303,7 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
237
303
  }, index), /*#__PURE__*/(0, _jsxRuntime.jsx)(_iglooicon.MinusOutlined, {
238
304
  onClick: zoomIn,
239
305
  className: (0, _classnames.default)({
240
- 'igloo-preview-zoom-btn': true,
306
+ 'igloo-preview-action-btn': true,
241
307
  'igloo-preview-zoom-in': true,
242
308
  'igloo-preview-disabled': scale <= 0.5
243
309
  }),
@@ -247,13 +313,22 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
247
313
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_iglooicon.PlusOutlined, {
248
314
  onClick: zoomOut,
249
315
  className: (0, _classnames.default)({
250
- 'igloo-preview-zoom-btn': true,
316
+ 'igloo-preview-action-btn': true,
251
317
  'igloo-preview-zoom-out': true,
252
318
  'igloo-preview-disabled': scale >= 2
253
319
  }),
254
320
  style: {
255
321
  fontSize: 24
256
322
  }
323
+ }), download && /*#__PURE__*/(0, _jsxRuntime.jsx)(_iglooicon.DownloadOutlined, {
324
+ onClick: onDownloadClick,
325
+ className: (0, _classnames.default)({
326
+ 'igloo-preview-action-btn': true,
327
+ 'igloo-preview-download-btn': true
328
+ }),
329
+ style: {
330
+ fontSize: 24
331
+ }
257
332
  }), (list.length > 2 || list.length === 2 && current === 1) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_iglooicon.ArrowLeftOutlined, {
258
333
  className: "igloo-media-page-btn",
259
334
  style: {
@@ -116,7 +116,11 @@
116
116
  right: 80px;
117
117
  }
118
118
 
119
- .igloo-preview-zoom-btn {
119
+ .igloo-preview-download-btn {
120
+ right: 136px;
121
+ }
122
+
123
+ .igloo-preview-action-btn {
120
124
  position: fixed;
121
125
  bottom: 24px;
122
126
  display: flex;
@@ -51,7 +51,7 @@ export declare const calcFormItemProps: (config: FormItemConfig, extraProps: For
51
51
  elementProps: {
52
52
  [key: string]: any;
53
53
  };
54
- display: any;
54
+ display: number;
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;
@@ -372,7 +372,7 @@ var calcFormItemProps = function calcFormItemProps(config, extraProps, form, par
372
372
  dependencies: antdDependencies
373
373
  },
374
374
  elementProps: elementProps,
375
- display: !ignore && calcShouldRender(name, dependencies, asserts, shouldRender, shouldRenderCode, form),
375
+ display: !ignore & calcShouldRender(name, dependencies, asserts, shouldRender, shouldRenderCode, form),
376
376
  previewFormater: previewFormater || extraPreviewFormater
377
377
  };
378
378
  };
@@ -1,2 +1,4 @@
1
1
  export declare const parseFileSize: (size: number) => string;
2
2
  export declare function classifyType(type: string): "image" | "video" | "pdf" | "unknown";
3
+ export declare const downloadByUrl: (filename: string, url: string) => void;
4
+ export declare const getFileNameByUrl: (fileUrl: string) => string;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.classifyType = classifyType;
7
- exports.parseFileSize = void 0;
7
+ exports.parseFileSize = exports.getFileNameByUrl = exports.downloadByUrl = void 0;
8
8
  var parseFileSize = function parseFileSize(size) {
9
9
  switch (true) {
10
10
  case size === undefined:
@@ -33,4 +33,25 @@ function classifyType(type) {
33
33
  return 'pdf';
34
34
  }
35
35
  return 'unknown';
36
- }
36
+ }
37
+ var downloadByUrl = function downloadByUrl(filename, url) {
38
+ var pom = document.createElement('a');
39
+ pom.setAttribute('href', url);
40
+ pom.setAttribute('target', '_blank');
41
+ pom.setAttribute('download', filename);
42
+ if (document.createEvent) {
43
+ var event = document.createEvent('MouseEvents');
44
+ event.initEvent('click', true, true);
45
+ pom.dispatchEvent(event);
46
+ } else {
47
+ pom.click();
48
+ }
49
+ };
50
+ exports.downloadByUrl = downloadByUrl;
51
+ var getFileNameByUrl = function getFileNameByUrl(fileUrl) {
52
+ var url = new URL(fileUrl);
53
+ var ary = url.pathname.split('/');
54
+ var filename = ary[ary.length - 1].replace(/\.[^/.]+$/, '');
55
+ return filename;
56
+ };
57
+ exports.getFileNameByUrl = getFileNameByUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iglooform",
3
- "version": "3.0.14",
3
+ "version": "3.0.16",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "build-dev": "dumi build",