function-call.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. Dialog: () => Dialog
  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_Dialog = __toESM(require("./Dialog"));
  33. let instance;
  34. function initInstance() {
  35. const Wrapper = {
  36. setup() {
  37. const {
  38. state,
  39. toggle
  40. } = (0, import_mount_component.usePopupState)();
  41. return () => (0, import_vue.createVNode)(import_Dialog.default, (0, import_vue.mergeProps)(state, {
  42. "onUpdate:show": toggle
  43. }), null);
  44. }
  45. };
  46. ({
  47. instance
  48. } = (0, import_mount_component.mountComponent)(Wrapper));
  49. }
  50. function Dialog(options) {
  51. if (!import_utils.inBrowser) {
  52. return Promise.resolve();
  53. }
  54. return new Promise((resolve, reject) => {
  55. if (!instance) {
  56. initInstance();
  57. }
  58. instance.open((0, import_utils.extend)({}, Dialog.currentOptions, options, {
  59. callback: (action) => {
  60. (action === "confirm" ? resolve : reject)(action);
  61. }
  62. }));
  63. });
  64. }
  65. Dialog.defaultOptions = {
  66. title: "",
  67. width: "",
  68. theme: null,
  69. message: "",
  70. overlay: true,
  71. callback: null,
  72. teleport: "body",
  73. className: "",
  74. allowHtml: false,
  75. lockScroll: true,
  76. transition: void 0,
  77. beforeClose: null,
  78. overlayClass: "",
  79. overlayStyle: void 0,
  80. messageAlign: "",
  81. cancelButtonText: "",
  82. cancelButtonColor: null,
  83. cancelButtonDisabled: false,
  84. confirmButtonText: "",
  85. confirmButtonColor: null,
  86. confirmButtonDisabled: false,
  87. showConfirmButton: true,
  88. showCancelButton: false,
  89. closeOnPopstate: true,
  90. closeOnClickOverlay: false
  91. };
  92. Dialog.currentOptions = (0, import_utils.extend)({}, Dialog.defaultOptions);
  93. Dialog.alert = Dialog;
  94. Dialog.confirm = (options) => Dialog((0, import_utils.extend)({
  95. showCancelButton: true
  96. }, options));
  97. Dialog.close = () => {
  98. if (instance) {
  99. instance.toggle(false);
  100. }
  101. };
  102. Dialog.setDefaultOptions = (options) => {
  103. (0, import_utils.extend)(Dialog.currentOptions, options);
  104. };
  105. Dialog.resetDefaultOptions = () => {
  106. Dialog.currentOptions = (0, import_utils.extend)({}, Dialog.defaultOptions);
  107. };
  108. Dialog.Component = (0, import_utils.withInstall)(import_Dialog.default);
  109. Dialog.install = (app) => {
  110. app.use(Dialog.Component);
  111. app.config.globalProperties.$dialog = Dialog;
  112. };