function-call.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. // 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. ));
  27. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  28. var stdin_exports = {};
  29. __export(stdin_exports, {
  30. showImagePreview: () => showImagePreview
  31. });
  32. module.exports = __toCommonJS(stdin_exports);
  33. var import_vue = require("vue");
  34. var import_utils = require("../utils");
  35. var import_mount_component = require("../utils/mount-component");
  36. var import_ImagePreview = __toESM(require("./ImagePreview"));
  37. let instance;
  38. const 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. };
  64. function 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. }
  83. const 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. };