UNPKG

3.09 kBJavaScriptView Raw
1var __create = Object.create;
2var __defProp = Object.defineProperty;
3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4var __getOwnPropNames = Object.getOwnPropertyNames;
5var __getProtoOf = Object.getPrototypeOf;
6var __hasOwnProp = Object.prototype.hasOwnProperty;
7var __export = (target, all) => {
8 for (var name in all)
9 __defProp(target, name, { get: all[name], enumerable: true });
10};
11var __copyProps = (to, from, except, desc) => {
12 if (from && typeof from === "object" || typeof from === "function") {
13 for (let key of __getOwnPropNames(from))
14 if (!__hasOwnProp.call(to, key) && key !== except)
15 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16 }
17 return to;
18};
19var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20 // If the importer is in node compatibility mode or this is not an ESM
21 // file that has been converted to a CommonJS file using a Babel-
22 // compatible transform (i.e. "__esModule" has not been set), then set
23 // "default" to the CommonJS "module.exports" for node compatibility.
24 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25 mod
26));
27var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28var stdin_exports = {};
29__export(stdin_exports, {
30 showImagePreview: () => showImagePreview
31});
32module.exports = __toCommonJS(stdin_exports);
33var import_vue = require("vue");
34var import_utils = require("../utils");
35var import_mount_component = require("../utils/mount-component");
36var import_ImagePreview = __toESM(require("./ImagePreview"));
37let instance;
38const defaultConfig = {
39 loop: true,
40 images: [],
41 maxZoom: 3,
42 minZoom: 1 / 3,
43 onScale: void 0,
44 onClose: void 0,
45 onChange: void 0,
46 vertical: false,
47 teleport: "body",
48 className: "",
49 showIndex: true,
50 closeable: false,
51 closeIcon: "clear",
52 transition: void 0,
53 beforeClose: void 0,
54 doubleScale: true,
55 overlayStyle: void 0,
56 overlayClass: void 0,
57 startPosition: 0,
58 swipeDuration: 300,
59 showIndicators: false,
60 closeOnPopstate: true,
61 closeOnClickOverlay: true,
62 closeIconPosition: "top-right"
63};
64function initInstance() {
65 ({
66 instance
67 } = (0, import_mount_component.mountComponent)({
68 setup() {
69 const {
70 state,
71 toggle
72 } = (0, import_mount_component.usePopupState)();
73 const onClosed = () => {
74 state.images = [];
75 };
76 return () => (0, import_vue.createVNode)(import_ImagePreview.default, (0, import_vue.mergeProps)(state, {
77 "onClosed": onClosed,
78 "onUpdate:show": toggle
79 }), null);
80 }
81 }));
82}
83const showImagePreview = (options, startPosition = 0) => {
84 if (!import_utils.inBrowser) {
85 return;
86 }
87 if (!instance) {
88 initInstance();
89 }
90 options = Array.isArray(options) ? {
91 images: options,
92 startPosition
93 } : options;
94 instance.open((0, import_utils.extend)({}, defaultConfig, options));
95 return instance;
96};