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