97 lines
3.0 KiB
JavaScript
97 lines
3.0 KiB
JavaScript
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
// file that has been converted to a CommonJS file using a Babel-
|
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
mod
|
|
));
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
var stdin_exports = {};
|
|
__export(stdin_exports, {
|
|
showImagePreview: () => showImagePreview
|
|
});
|
|
module.exports = __toCommonJS(stdin_exports);
|
|
var import_vue = require("vue");
|
|
var import_utils = require("../utils");
|
|
var import_mount_component = require("../utils/mount-component");
|
|
var import_ImagePreview = __toESM(require("./ImagePreview"));
|
|
let instance;
|
|
const defaultConfig = {
|
|
loop: true,
|
|
images: [],
|
|
maxZoom: 3,
|
|
minZoom: 1 / 3,
|
|
onScale: void 0,
|
|
onClose: void 0,
|
|
onChange: void 0,
|
|
vertical: false,
|
|
teleport: "body",
|
|
className: "",
|
|
showIndex: true,
|
|
closeable: false,
|
|
closeIcon: "clear",
|
|
transition: void 0,
|
|
beforeClose: void 0,
|
|
doubleScale: true,
|
|
overlayStyle: void 0,
|
|
overlayClass: void 0,
|
|
startPosition: 0,
|
|
swipeDuration: 300,
|
|
showIndicators: false,
|
|
closeOnPopstate: true,
|
|
closeOnClickOverlay: true,
|
|
closeIconPosition: "top-right"
|
|
};
|
|
function initInstance() {
|
|
({
|
|
instance
|
|
} = (0, import_mount_component.mountComponent)({
|
|
setup() {
|
|
const {
|
|
state,
|
|
toggle
|
|
} = (0, import_mount_component.usePopupState)();
|
|
const onClosed = () => {
|
|
state.images = [];
|
|
};
|
|
return () => (0, import_vue.createVNode)(import_ImagePreview.default, (0, import_vue.mergeProps)(state, {
|
|
"onClosed": onClosed,
|
|
"onUpdate:show": toggle
|
|
}), null);
|
|
}
|
|
}));
|
|
}
|
|
const showImagePreview = (options, startPosition = 0) => {
|
|
if (!import_utils.inBrowser) {
|
|
return;
|
|
}
|
|
if (!instance) {
|
|
initInstance();
|
|
}
|
|
options = Array.isArray(options) ? {
|
|
images: options,
|
|
startPosition
|
|
} : options;
|
|
instance.open((0, import_utils.extend)({}, defaultConfig, options));
|
|
return instance;
|
|
};
|