function-call.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. var __create = Object.create;
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __getProtoOf = Object.getPrototypeOf;
  6. var __hasOwnProp = Object.prototype.hasOwnProperty;
  7. var __export = (target, all) => {
  8. for (var name in all)
  9. __defProp(target, name, { get: all[name], enumerable: true });
  10. };
  11. var __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. };
  19. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  20. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  21. mod
  22. ));
  23. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  24. var stdin_exports = {};
  25. __export(stdin_exports, {
  26. ImagePreview: () => ImagePreview
  27. });
  28. module.exports = __toCommonJS(stdin_exports);
  29. var import_vue = require("vue");
  30. var import_utils = require("../utils");
  31. var import_mount_component = require("../utils/mount-component");
  32. var import_ImagePreview = __toESM(require("./ImagePreview"));
  33. let instance;
  34. const defaultConfig = {
  35. loop: true,
  36. images: [],
  37. maxZoom: 3,
  38. minZoom: 1 / 3,
  39. onScale: void 0,
  40. onClose: void 0,
  41. onChange: void 0,
  42. teleport: "body",
  43. className: "",
  44. showIndex: true,
  45. closeable: false,
  46. closeIcon: "clear",
  47. transition: void 0,
  48. beforeClose: void 0,
  49. overlayStyle: void 0,
  50. overlayClass: void 0,
  51. startPosition: 0,
  52. swipeDuration: 300,
  53. showIndicators: false,
  54. closeOnPopstate: true,
  55. closeIconPosition: "top-right"
  56. };
  57. function initInstance() {
  58. ({
  59. instance
  60. } = (0, import_mount_component.mountComponent)({
  61. setup() {
  62. const {
  63. state,
  64. toggle
  65. } = (0, import_mount_component.usePopupState)();
  66. const onClosed = () => {
  67. state.images = [];
  68. };
  69. return () => (0, import_vue.createVNode)(import_ImagePreview.default, (0, import_vue.mergeProps)(state, {
  70. "onClosed": onClosed,
  71. "onUpdate:show": toggle
  72. }), null);
  73. }
  74. }));
  75. }
  76. const ImagePreview = (options, startPosition = 0) => {
  77. if (!import_utils.inBrowser) {
  78. return;
  79. }
  80. if (!instance) {
  81. initInstance();
  82. }
  83. options = Array.isArray(options) ? {
  84. images: options,
  85. startPosition
  86. } : options;
  87. instance.open((0, import_utils.extend)({}, defaultConfig, options));
  88. return instance;
  89. };
  90. ImagePreview.Component = (0, import_utils.withInstall)(import_ImagePreview.default);
  91. ImagePreview.install = (app) => {
  92. app.use(ImagePreview.Component);
  93. };