iglooform 3.0.15 → 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.
- package/.dumi/tmp/core/defineApp.ts +1 -2
- package/.dumi/tmp/core/plugin.ts +1 -6
- package/.dumi/tmp/core/pluginConfig.ts +0 -11
- package/.dumi/tmp/dumi/theme/ContextWrapper.tsx +2 -2
- package/.dumi/tmp/dumi/theme/nprogress.css +3 -3
- package/.dumi/tmp/exports.ts +0 -1
- package/.dumi/tmp/testBrowser.tsx +0 -2
- package/.dumi/tmp/umi.ts +1 -3
- package/es/documents/index.d.ts +4 -2
- package/es/documents/index.js +12 -3
- package/es/media/index.d.ts +5 -0
- package/es/media/index.js +83 -7
- package/es/media/style/index.less +5 -1
- package/es/utils/form-utils.d.ts +1 -1
- package/es/utils/form-utils.js +1 -1
- package/es/utils/tools.d.ts +2 -0
- package/es/utils/tools.js +20 -1
- package/lib/documents/index.d.ts +4 -2
- package/lib/documents/index.js +12 -3
- package/lib/media/index.d.ts +5 -0
- package/lib/media/index.js +82 -7
- package/lib/media/style/index.less +5 -1
- package/lib/utils/form-utils.d.ts +1 -1
- package/lib/utils/form-utils.js +1 -1
- package/lib/utils/tools.d.ts +2 -0
- package/lib/utils/tools.js +23 -2
- package/package.json +1 -1
- package/.dumi/tmp/plugin-antd/runtime.tsx +0 -65
- package/.dumi/tmp/plugin-antd/runtimeConfig.d.ts +0 -6
- package/.dumi/tmp/plugin-antd/types.d.ts +0 -14
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// This file is generated by Umi automatically
|
|
3
3
|
// DO NOT CHANGE IT MANUALLY!
|
|
4
|
-
import type { IRuntimeConfig as Plugin0 } from '/Users/lei/iglooform/.dumi/tmp/plugin-antd/runtimeConfig.d'
|
|
5
4
|
interface IDefaultRuntimeConfig {
|
|
6
5
|
onRouteChange?: (props: { routes: any, clientRoutes: any, location: any, action: any, isFirst: boolean }) => void;
|
|
7
6
|
patchRoutes?: (props: { routes: any }) => void;
|
|
@@ -10,7 +9,7 @@ interface IDefaultRuntimeConfig {
|
|
|
10
9
|
rootContainer?: (lastRootContainer: JSX.Element, args?: any) => void;
|
|
11
10
|
[key: string]: any;
|
|
12
11
|
}
|
|
13
|
-
export type RuntimeConfig = IDefaultRuntimeConfig
|
|
12
|
+
export type RuntimeConfig = IDefaultRuntimeConfig
|
|
14
13
|
|
|
15
14
|
export function defineApp(config: RuntimeConfig): RuntimeConfig {
|
|
16
15
|
return config;
|
package/.dumi/tmp/core/plugin.ts
CHANGED
|
@@ -5,7 +5,6 @@ import * as Plugin_0 from '@@/core/exportStaticRuntimePlugin.ts';
|
|
|
5
5
|
import * as Plugin_1 from '@@/core/helmet.ts';
|
|
6
6
|
import * as Plugin_2 from '@@/dumi/meta/runtime.ts';
|
|
7
7
|
import * as Plugin_3 from '@@/dumi/locales/runtime.tsx';
|
|
8
|
-
import * as Plugin_4 from '/Users/lei/iglooform/.dumi/tmp/plugin-antd/runtime.tsx';
|
|
9
8
|
import { PluginManager } from 'umi';
|
|
10
9
|
|
|
11
10
|
function __defaultExport (obj) {
|
|
@@ -32,15 +31,11 @@ export function getPlugins() {
|
|
|
32
31
|
apply: Plugin_3,
|
|
33
32
|
path: process.env.NODE_ENV === 'production' ? void 0 : '@@/dumi/locales/runtime.tsx',
|
|
34
33
|
},
|
|
35
|
-
{
|
|
36
|
-
apply: Plugin_4,
|
|
37
|
-
path: process.env.NODE_ENV === 'production' ? void 0 : '/Users/lei/iglooform/.dumi/tmp/plugin-antd/runtime.tsx',
|
|
38
|
-
},
|
|
39
34
|
];
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
export function getValidKeys() {
|
|
43
|
-
return ['patchRoutes','patchClientRoutes','modifyContextOpts','modifyClientRenderOpts','rootContainer','innerProvider','i18nProvider','accessProvider','dataflowProvider','outerProvider','render','onRouteChange','modifyCodeSandboxData','modifyStackBlitzData',
|
|
38
|
+
return ['patchRoutes','patchClientRoutes','modifyContextOpts','modifyClientRenderOpts','rootContainer','innerProvider','i18nProvider','accessProvider','dataflowProvider','outerProvider','render','onRouteChange','modifyCodeSandboxData','modifyStackBlitzData',];
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
let pluginManager = null;
|
|
@@ -269,17 +269,6 @@ interface IConfigTypes {
|
|
|
269
269
|
};
|
|
270
270
|
run: {
|
|
271
271
|
globals?: (Array<string> | undefined);
|
|
272
|
-
};
|
|
273
|
-
antd: {
|
|
274
|
-
configProvider?: ({ [x: string]: any } | undefined);
|
|
275
|
-
dark?: (boolean | undefined);
|
|
276
|
-
compact?: (boolean | undefined);
|
|
277
|
-
import?: (boolean | undefined);
|
|
278
|
-
style?: ("less" | "css" | undefined);
|
|
279
|
-
theme?: ({ [x: string]: any } | undefined);
|
|
280
|
-
appConfig?: ({ [x: string]: any } | undefined);
|
|
281
|
-
momentPicker?: (boolean | undefined);
|
|
282
|
-
styleProvider?: ({ [x: string]: any } | undefined);
|
|
283
272
|
};
|
|
284
273
|
};
|
|
285
274
|
|
|
@@ -30,7 +30,7 @@ export default function DumiContextWrapper() {
|
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<SiteContext.Provider value={{
|
|
33
|
-
pkg: {"name":"iglooform","version":"
|
|
33
|
+
pkg: {"name":"iglooform","version":"2.5.60","license":"MIT"},
|
|
34
34
|
historyType: "browser",
|
|
35
35
|
entryExports,
|
|
36
36
|
demos,
|
|
@@ -39,7 +39,7 @@ export default function DumiContextWrapper() {
|
|
|
39
39
|
loading,
|
|
40
40
|
setLoading,
|
|
41
41
|
hostname: undefined,
|
|
42
|
-
themeConfig: {"footer":"Copyright © 2024 | Powered by <a href=\"https://d.umijs.org\" target=\"_blank\" rel=\"noreferrer\">dumi</a>","prefersColor":{"default":"light","switch":true},"nprogress":true,"lastUpdated":true
|
|
42
|
+
themeConfig: {"footer":"Copyright © 2024 | Powered by <a href=\"https://d.umijs.org\" target=\"_blank\" rel=\"noreferrer\">dumi</a>","prefersColor":{"default":"light","switch":true},"nprogress":true,"lastUpdated":true},
|
|
43
43
|
_2_level_nav_available: false,
|
|
44
44
|
}}>
|
|
45
45
|
{outlet}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
right: 0px;
|
|
20
20
|
width: 100px;
|
|
21
21
|
height: 100%;
|
|
22
|
-
box-shadow: 0 0 10px
|
|
22
|
+
box-shadow: 0 0 10px #1677ff, 0 0 5px #1677ff;
|
|
23
23
|
opacity: 1.0;
|
|
24
24
|
transform: rotate(3deg) translate(0px, -4px);
|
|
25
25
|
}
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
height: 18px;
|
|
38
38
|
box-sizing: border-box;
|
|
39
39
|
border: solid 2px transparent;
|
|
40
|
-
border-top-color:
|
|
41
|
-
border-left-color:
|
|
40
|
+
border-top-color: #1677ff;
|
|
41
|
+
border-left-color: #1677ff;
|
|
42
42
|
border-radius: 50%;
|
|
43
43
|
animation: nprogress-spinner 400ms linear infinite;
|
|
44
44
|
}
|
package/.dumi/tmp/exports.ts
CHANGED
|
@@ -9,10 +9,8 @@ import { createPluginManager } from './core/plugin';
|
|
|
9
9
|
import { getRoutes } from './core/route';
|
|
10
10
|
import type { Location } from 'history';
|
|
11
11
|
|
|
12
|
-
import '/Users/lei/iglooform/.dumi/global.less';
|
|
13
12
|
import { getPluginManager as getDumiPluginManager } from './core/plugin';
|
|
14
13
|
import { setPluginManager as setDumiPluginManager } from '/Users/lei/iglooform/node_modules/dumi/dist/client/theme-api/utils.js';
|
|
15
|
-
import 'antd/dist/reset.css';
|
|
16
14
|
const publicPath = '/';
|
|
17
15
|
const runtimePublicPath = false;
|
|
18
16
|
|
package/.dumi/tmp/umi.ts
CHANGED
|
@@ -2,17 +2,15 @@
|
|
|
2
2
|
// This file is generated by Umi automatically
|
|
3
3
|
// DO NOT CHANGE IT MANUALLY!
|
|
4
4
|
import './core/polyfill';
|
|
5
|
-
import '/Users/lei/iglooform/.dumi/global.less';
|
|
6
5
|
import { getPluginManager as getDumiPluginManager } from './core/plugin';
|
|
7
6
|
import { setPluginManager as setDumiPluginManager } from '/Users/lei/iglooform/node_modules/dumi/dist/client/theme-api/utils.js';
|
|
8
|
-
import 'antd/dist/reset.css';
|
|
9
7
|
import { renderClient } from '/Users/lei/iglooform/node_modules/@umijs/renderer-react';
|
|
10
8
|
import { getRoutes } from './core/route';
|
|
11
9
|
import { createPluginManager } from './core/plugin';
|
|
12
10
|
import { createHistory } from './core/history';
|
|
13
11
|
import Loading from '@@/dumi/theme/loading';
|
|
14
12
|
import { ApplyPluginsType } from 'umi';
|
|
15
|
-
|
|
13
|
+
|
|
16
14
|
|
|
17
15
|
const publicPath = "/";
|
|
18
16
|
const runtimePublicPath = false;
|
package/es/documents/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { FC, CSSProperties } from 'react';
|
|
1
|
+
import React, { FC, CSSProperties } from 'react';
|
|
2
|
+
import MediaWithPreview from '../media';
|
|
3
|
+
type MediaWithPreviewProps = React.ComponentProps<typeof MediaWithPreview>;
|
|
2
4
|
declare const Documents: FC<{
|
|
3
5
|
docList: Array<string | {
|
|
4
6
|
src: string;
|
|
@@ -9,5 +11,5 @@ declare const Documents: FC<{
|
|
|
9
11
|
docNames?: string[];
|
|
10
12
|
showAllPages?: boolean;
|
|
11
13
|
destroyOnClose?: boolean;
|
|
12
|
-
}
|
|
14
|
+
} & Pick<MediaWithPreviewProps, 'download'>>;
|
|
13
15
|
export default Documents;
|
package/es/documents/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var _excluded = ["docList", "docNames", "className", "style", "showAllPages", "destroyOnClose"];
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
1
7
|
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
8
|
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
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
@@ -8,6 +14,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
8
14
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
15
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
10
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
11
19
|
import React, { useState, useEffect } from 'react';
|
|
12
20
|
import { Space } from 'antd';
|
|
13
21
|
import invariant from 'invariant';
|
|
@@ -24,7 +32,8 @@ var Documents = function Documents(_ref) {
|
|
|
24
32
|
_ref$showAllPages = _ref.showAllPages,
|
|
25
33
|
showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
|
|
26
34
|
_ref$destroyOnClose = _ref.destroyOnClose,
|
|
27
|
-
destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose
|
|
35
|
+
destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose,
|
|
36
|
+
mediaPreviewProps = _objectWithoutProperties(_ref, _excluded);
|
|
28
37
|
var _useState = useState(0),
|
|
29
38
|
_useState2 = _slicedToArray(_useState, 2),
|
|
30
39
|
current = _useState2[0],
|
|
@@ -102,7 +111,7 @@ var Documents = function Documents(_ref) {
|
|
|
102
111
|
style: {
|
|
103
112
|
left: "".concat((index - current) * 100, "%")
|
|
104
113
|
},
|
|
105
|
-
children: /*#__PURE__*/_jsx(MediaWithPreview, {
|
|
114
|
+
children: /*#__PURE__*/_jsx(MediaWithPreview, _objectSpread({
|
|
106
115
|
list: list,
|
|
107
116
|
index: index,
|
|
108
117
|
src: src,
|
|
@@ -113,7 +122,7 @@ var Documents = function Documents(_ref) {
|
|
|
113
122
|
name: docNames[index],
|
|
114
123
|
showAllPages: showAllPages,
|
|
115
124
|
destroyOnClose: destroyOnClose
|
|
116
|
-
})
|
|
125
|
+
}, mediaPreviewProps))
|
|
117
126
|
}, index);
|
|
118
127
|
})
|
|
119
128
|
});
|
package/es/media/index.d.ts
CHANGED
|
@@ -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;
|
package/es/media/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
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
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
1
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
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."); }
|
|
3
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); }
|
|
@@ -6,11 +10,12 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
6
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
11
|
import React, { useState, useEffect } from 'react';
|
|
8
12
|
import { Modal } from 'antd';
|
|
13
|
+
import { downloadByUrl, getFileNameByUrl } from "../utils/tools";
|
|
9
14
|
import Media from "./media";
|
|
10
15
|
import PreviewMedia from "./preview";
|
|
11
16
|
import classnames from 'classnames';
|
|
12
17
|
import Typography from "../typography";
|
|
13
|
-
import { MinusOutlined, PlusOutlined, ArrowRightOutlined, ArrowLeftOutlined, CrossOutlined } from 'iglooicon';
|
|
18
|
+
import { MinusOutlined, PlusOutlined, ArrowRightOutlined, ArrowLeftOutlined, CrossOutlined, DownloadOutlined } from 'iglooicon';
|
|
14
19
|
import "./style";
|
|
15
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
21
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -42,7 +47,8 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
42
47
|
_ref$showAllPages = _ref.showAllPages,
|
|
43
48
|
showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
|
|
44
49
|
_ref$destroyOnClose = _ref.destroyOnClose,
|
|
45
|
-
destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose
|
|
50
|
+
destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose,
|
|
51
|
+
download = _ref.download;
|
|
46
52
|
var _useState = useState(1),
|
|
47
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
48
54
|
scale = _useState2[0],
|
|
@@ -94,6 +100,12 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
94
100
|
return document.body.removeEventListener('keydown', handleKeyDown);
|
|
95
101
|
};
|
|
96
102
|
}, [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
|
+
};
|
|
97
109
|
var open = function open() {
|
|
98
110
|
setShowModal(true);
|
|
99
111
|
};
|
|
@@ -137,6 +149,61 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
137
149
|
e.preventDefault();
|
|
138
150
|
setScale(scale + 0.2);
|
|
139
151
|
};
|
|
152
|
+
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) {
|
|
157
|
+
case 0:
|
|
158
|
+
currentUrl = getCurrentUrl();
|
|
159
|
+
filename = getFileNameByUrl(currentUrl);
|
|
160
|
+
downloadUrl = currentUrl;
|
|
161
|
+
actionType = 'downloadBlob';
|
|
162
|
+
if (!(_typeof(download) === 'object')) {
|
|
163
|
+
_context.next = 10;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
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:
|
|
179
|
+
if (!(actionType === 'downloadBlob')) {
|
|
180
|
+
_context.next = 21;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
_context.next = 13;
|
|
184
|
+
return fetch(downloadUrl);
|
|
185
|
+
case 13:
|
|
186
|
+
res = _context.sent;
|
|
187
|
+
_context.next = 16;
|
|
188
|
+
return res.blob();
|
|
189
|
+
case 16:
|
|
190
|
+
blob = _context.sent;
|
|
191
|
+
url = window.URL.createObjectURL(blob);
|
|
192
|
+
downloadByUrl(filename, url);
|
|
193
|
+
_context.next = 22;
|
|
194
|
+
break;
|
|
195
|
+
case 21:
|
|
196
|
+
downloadByUrl(filename, downloadUrl);
|
|
197
|
+
case 22:
|
|
198
|
+
case "end":
|
|
199
|
+
return _context.stop();
|
|
200
|
+
}
|
|
201
|
+
}, _callee);
|
|
202
|
+
}));
|
|
203
|
+
return function onDownloadClick() {
|
|
204
|
+
return _ref2.apply(this, arguments);
|
|
205
|
+
};
|
|
206
|
+
}();
|
|
140
207
|
var getTranslateX = function getTranslateX(index) {
|
|
141
208
|
if (list.length < 3) {
|
|
142
209
|
return index - current;
|
|
@@ -198,9 +265,9 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
198
265
|
})]
|
|
199
266
|
}), /*#__PURE__*/_jsxs("div", {
|
|
200
267
|
className: "igloo-media-list",
|
|
201
|
-
children: [Boolean(list && !!list.length) && list.map(function (
|
|
202
|
-
var src =
|
|
203
|
-
type =
|
|
268
|
+
children: [Boolean(list && !!list.length) && list.map(function (_ref3, index) {
|
|
269
|
+
var src = _ref3.src,
|
|
270
|
+
type = _ref3.type;
|
|
204
271
|
return /*#__PURE__*/_jsx("div", {
|
|
205
272
|
className: classnames({
|
|
206
273
|
'igloo-media-animating': needShowAnimation(index),
|
|
@@ -228,7 +295,7 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
228
295
|
}, index), /*#__PURE__*/_jsx(MinusOutlined, {
|
|
229
296
|
onClick: zoomIn,
|
|
230
297
|
className: classnames({
|
|
231
|
-
'igloo-preview-
|
|
298
|
+
'igloo-preview-action-btn': true,
|
|
232
299
|
'igloo-preview-zoom-in': true,
|
|
233
300
|
'igloo-preview-disabled': scale <= 0.5
|
|
234
301
|
}),
|
|
@@ -238,13 +305,22 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
|
|
|
238
305
|
}), /*#__PURE__*/_jsx(PlusOutlined, {
|
|
239
306
|
onClick: zoomOut,
|
|
240
307
|
className: classnames({
|
|
241
|
-
'igloo-preview-
|
|
308
|
+
'igloo-preview-action-btn': true,
|
|
242
309
|
'igloo-preview-zoom-out': true,
|
|
243
310
|
'igloo-preview-disabled': scale >= 2
|
|
244
311
|
}),
|
|
245
312
|
style: {
|
|
246
313
|
fontSize: 24
|
|
247
314
|
}
|
|
315
|
+
}), download && /*#__PURE__*/_jsx(DownloadOutlined, {
|
|
316
|
+
onClick: onDownloadClick,
|
|
317
|
+
className: classnames({
|
|
318
|
+
'igloo-preview-action-btn': true,
|
|
319
|
+
'igloo-preview-download-btn': true
|
|
320
|
+
}),
|
|
321
|
+
style: {
|
|
322
|
+
fontSize: 24
|
|
323
|
+
}
|
|
248
324
|
}), (list.length > 2 || list.length === 2 && current === 1) && /*#__PURE__*/_jsx(ArrowLeftOutlined, {
|
|
249
325
|
className: "igloo-media-page-btn",
|
|
250
326
|
style: {
|
package/es/utils/form-utils.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare const calcFormItemProps: (config: FormItemConfig, extraProps: For
|
|
|
51
51
|
elementProps: {
|
|
52
52
|
[key: string]: any;
|
|
53
53
|
};
|
|
54
|
-
display:
|
|
54
|
+
display: 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;
|
package/es/utils/form-utils.js
CHANGED
|
@@ -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
|
|
367
|
+
display: !ignore & calcShouldRender(name, dependencies, asserts, shouldRender, shouldRenderCode, form),
|
|
368
368
|
previewFormater: previewFormater || extraPreviewFormater
|
|
369
369
|
};
|
|
370
370
|
};
|
package/es/utils/tools.d.ts
CHANGED
|
@@ -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;
|
package/es/utils/tools.js
CHANGED
|
@@ -25,4 +25,23 @@ export function classifyType(type) {
|
|
|
25
25
|
return 'pdf';
|
|
26
26
|
}
|
|
27
27
|
return 'unknown';
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
|
+
export var downloadByUrl = function downloadByUrl(filename, url) {
|
|
30
|
+
var pom = document.createElement('a');
|
|
31
|
+
pom.setAttribute('href', url);
|
|
32
|
+
pom.setAttribute('target', '_blank');
|
|
33
|
+
pom.setAttribute('download', filename);
|
|
34
|
+
if (document.createEvent) {
|
|
35
|
+
var event = document.createEvent('MouseEvents');
|
|
36
|
+
event.initEvent('click', true, true);
|
|
37
|
+
pom.dispatchEvent(event);
|
|
38
|
+
} else {
|
|
39
|
+
pom.click();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export var getFileNameByUrl = function getFileNameByUrl(fileUrl) {
|
|
43
|
+
var url = new URL(fileUrl);
|
|
44
|
+
var ary = url.pathname.split('/');
|
|
45
|
+
var filename = ary[ary.length - 1].replace(/\.[^/.]+$/, '');
|
|
46
|
+
return filename;
|
|
47
|
+
};
|
package/lib/documents/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { FC, CSSProperties } from 'react';
|
|
1
|
+
import React, { FC, CSSProperties } from 'react';
|
|
2
|
+
import MediaWithPreview from '../media';
|
|
3
|
+
type MediaWithPreviewProps = React.ComponentProps<typeof MediaWithPreview>;
|
|
2
4
|
declare const Documents: FC<{
|
|
3
5
|
docList: Array<string | {
|
|
4
6
|
src: string;
|
|
@@ -9,5 +11,5 @@ declare const Documents: FC<{
|
|
|
9
11
|
docNames?: string[];
|
|
10
12
|
showAllPages?: boolean;
|
|
11
13
|
destroyOnClose?: boolean;
|
|
12
|
-
}
|
|
14
|
+
} & Pick<MediaWithPreviewProps, 'download'>>;
|
|
13
15
|
export default Documents;
|
package/lib/documents/index.js
CHANGED
|
@@ -10,9 +10,15 @@ 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; }
|
|
17
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); }
|
|
18
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); } }
|
|
@@ -23,6 +29,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
23
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; }
|
|
24
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; } }
|
|
25
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; }
|
|
26
34
|
var Documents = function Documents(_ref) {
|
|
27
35
|
var _ref$docList = _ref.docList,
|
|
28
36
|
docList = _ref$docList === void 0 ? [] : _ref$docList,
|
|
@@ -33,7 +41,8 @@ var Documents = function Documents(_ref) {
|
|
|
33
41
|
_ref$showAllPages = _ref.showAllPages,
|
|
34
42
|
showAllPages = _ref$showAllPages === void 0 ? true : _ref$showAllPages,
|
|
35
43
|
_ref$destroyOnClose = _ref.destroyOnClose,
|
|
36
|
-
destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose
|
|
44
|
+
destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose,
|
|
45
|
+
mediaPreviewProps = _objectWithoutProperties(_ref, _excluded);
|
|
37
46
|
var _useState = (0, _react.useState)(0),
|
|
38
47
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
48
|
current = _useState2[0],
|
|
@@ -111,7 +120,7 @@ var Documents = function Documents(_ref) {
|
|
|
111
120
|
style: {
|
|
112
121
|
left: "".concat((index - current) * 100, "%")
|
|
113
122
|
},
|
|
114
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_media.default, {
|
|
123
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_media.default, _objectSpread({
|
|
115
124
|
list: list,
|
|
116
125
|
index: index,
|
|
117
126
|
src: src,
|
|
@@ -122,7 +131,7 @@ var Documents = function Documents(_ref) {
|
|
|
122
131
|
name: docNames[index],
|
|
123
132
|
showAllPages: showAllPages,
|
|
124
133
|
destroyOnClose: destroyOnClose
|
|
125
|
-
})
|
|
134
|
+
}, mediaPreviewProps))
|
|
126
135
|
}, index);
|
|
127
136
|
})
|
|
128
137
|
});
|
package/lib/media/index.d.ts
CHANGED
|
@@ -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;
|
package/lib/media/index.js
CHANGED
|
@@ -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 (
|
|
211
|
-
var src =
|
|
212
|
-
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-
|
|
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-
|
|
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: {
|
|
@@ -51,7 +51,7 @@ export declare const calcFormItemProps: (config: FormItemConfig, extraProps: For
|
|
|
51
51
|
elementProps: {
|
|
52
52
|
[key: string]: any;
|
|
53
53
|
};
|
|
54
|
-
display:
|
|
54
|
+
display: 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;
|
package/lib/utils/form-utils.js
CHANGED
|
@@ -372,7 +372,7 @@ var calcFormItemProps = function calcFormItemProps(config, extraProps, form, par
|
|
|
372
372
|
dependencies: antdDependencies
|
|
373
373
|
},
|
|
374
374
|
elementProps: elementProps,
|
|
375
|
-
display: !ignore
|
|
375
|
+
display: !ignore & calcShouldRender(name, dependencies, asserts, shouldRender, shouldRenderCode, form),
|
|
376
376
|
previewFormater: previewFormater || extraPreviewFormater
|
|
377
377
|
};
|
|
378
378
|
};
|
package/lib/utils/tools.d.ts
CHANGED
|
@@ -1,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;
|
package/lib/utils/tools.js
CHANGED
|
@@ -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,65 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
// This file is generated by Umi automatically
|
|
3
|
-
// DO NOT CHANGE IT MANUALLY!
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import {
|
|
6
|
-
Modal,
|
|
7
|
-
ConfigProvider,
|
|
8
|
-
message,
|
|
9
|
-
notification,
|
|
10
|
-
} from 'antd';
|
|
11
|
-
import { ApplyPluginsType } from 'umi';
|
|
12
|
-
import { getPluginManager } from '../core/plugin';
|
|
13
|
-
|
|
14
|
-
let cacheAntdConfig = null;
|
|
15
|
-
|
|
16
|
-
const getAntdConfig = () => {
|
|
17
|
-
if(!cacheAntdConfig){
|
|
18
|
-
cacheAntdConfig = getPluginManager().applyPlugins({
|
|
19
|
-
key: 'antd',
|
|
20
|
-
type: ApplyPluginsType.modify,
|
|
21
|
-
initialValue: {
|
|
22
|
-
...{"theme":{"token":{"colorPrimary":"#5858FF","colorError":"#F52209","colorSuccess":"#108043","colorInfo":"#1E90FF","colorWarning":"#CF8909","controlHeight":48,"controlHeightSM":24,"controlOutlineWidth":0,"borderRadius":3,"fontSize":16,"lineHeight":1.2857,"fontFamily":"Roboto"},"components":{"Radio":{"radioSize":22,"dotSize":8,"buttonCheckedBgDisabled":"rgba(0, 0, 0, 0.04)"},"Pagination":{"itemSizeSM":40},"DatePicker":{"pickerPanelCellWidth":36}}}},
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return cacheAntdConfig;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function rootContainer(rawContainer) {
|
|
30
|
-
const {
|
|
31
|
-
appConfig,
|
|
32
|
-
...finalConfigProvider
|
|
33
|
-
} = getAntdConfig();
|
|
34
|
-
let container = rawContainer;
|
|
35
|
-
if (finalConfigProvider.prefixCls) {
|
|
36
|
-
Modal.config({
|
|
37
|
-
rootPrefixCls: finalConfigProvider.prefixCls
|
|
38
|
-
});
|
|
39
|
-
message.config({
|
|
40
|
-
prefixCls: `${finalConfigProvider.prefixCls}-message`
|
|
41
|
-
});
|
|
42
|
-
notification.config({
|
|
43
|
-
prefixCls: `${finalConfigProvider.prefixCls}-notification`
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (finalConfigProvider.iconPrefixCls) {
|
|
48
|
-
// Icons in message need to set iconPrefixCls via ConfigProvider.config()
|
|
49
|
-
ConfigProvider.config({
|
|
50
|
-
iconPrefixCls: finalConfigProvider.iconPrefixCls,
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
if (finalConfigProvider.theme) {
|
|
55
|
-
// Pass config theme to static method
|
|
56
|
-
ConfigProvider.config({
|
|
57
|
-
theme: finalConfigProvider.theme,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
container = <ConfigProvider {...finalConfigProvider}>{container}</ConfigProvider>;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return container;
|
|
65
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// This file is generated by Umi automatically
|
|
2
|
-
// DO NOT CHANGE IT MANUALLY!
|
|
3
|
-
import type { ConfigProviderProps } from 'antd/es/config-provider';
|
|
4
|
-
|
|
5
|
-
type Prettify<T> = {
|
|
6
|
-
[K in keyof T]: T[K];
|
|
7
|
-
} & {};
|
|
8
|
-
|
|
9
|
-
type AntdConfig = Prettify<{}
|
|
10
|
-
& ConfigProviderProps
|
|
11
|
-
|
|
12
|
-
>;
|
|
13
|
-
|
|
14
|
-
export type RuntimeAntdConfig = (memo: AntdConfig) => AntdConfig;
|