function-call.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. closeNotify: () => closeNotify,
  31. resetNotifyDefaultOptions: () => resetNotifyDefaultOptions,
  32. setNotifyDefaultOptions: () => setNotifyDefaultOptions,
  33. showNotify: () => showNotify
  34. });
  35. module.exports = __toCommonJS(stdin_exports);
  36. var import_vue = require("vue");
  37. var import_utils = require("../utils");
  38. var import_mount_component = require("../utils/mount-component");
  39. var import_Notify = __toESM(require("./Notify"));
  40. let timer;
  41. let instance;
  42. const parseOptions = (message) => (0, import_utils.isObject)(message) ? message : {
  43. message
  44. };
  45. function initInstance() {
  46. ({
  47. instance
  48. } = (0, import_mount_component.mountComponent)({
  49. setup() {
  50. const {
  51. state,
  52. toggle
  53. } = (0, import_mount_component.usePopupState)();
  54. return () => (0, import_vue.createVNode)(import_Notify.default, (0, import_vue.mergeProps)(state, {
  55. "onUpdate:show": toggle
  56. }), null);
  57. }
  58. }));
  59. }
  60. const getDefaultOptions = () => ({
  61. type: "danger",
  62. color: void 0,
  63. message: "",
  64. onClose: void 0,
  65. onClick: void 0,
  66. onOpened: void 0,
  67. duration: 3e3,
  68. position: void 0,
  69. className: "",
  70. lockScroll: false,
  71. background: void 0
  72. });
  73. let currentOptions = getDefaultOptions();
  74. const closeNotify = () => {
  75. if (instance) {
  76. instance.toggle(false);
  77. }
  78. };
  79. function showNotify(options) {
  80. if (!import_utils.inBrowser) {
  81. return;
  82. }
  83. if (!instance) {
  84. initInstance();
  85. }
  86. options = (0, import_utils.extend)({}, currentOptions, parseOptions(options));
  87. instance.open(options);
  88. clearTimeout(timer);
  89. if (options.duration > 0) {
  90. timer = setTimeout(closeNotify, options.duration);
  91. }
  92. return instance;
  93. }
  94. const setNotifyDefaultOptions = (options) => (0, import_utils.extend)(currentOptions, options);
  95. const resetNotifyDefaultOptions = () => {
  96. currentOptions = getDefaultOptions();
  97. };