@vuesax-alpha/nightly
Version:
A Component Library for Vue 3
61 lines (56 loc) • 1.94 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../utils/index.js');
require('../../../hooks/index.js');
var notification$1 = require('./notification2.js');
var useNotification = require('./use-notification.js');
var core = require('@vueuse/core');
var index = require('../../../hooks/use-popper-container/index.js');
var index$1 = require('../../../hooks/use-global-config/index.js');
var shared = require('@vue/shared');
const globalContainer = {
"top-right": null,
"top-center": null,
"top-left": null,
"bottom-right": null,
"bottom-center": null,
"bottom-left": null
};
const notification = (options = {}) => {
var _a, _b;
if (!core.isClient)
return {
close: () => void 0
};
if (typeof options === "string" || vue.isVNode(options)) {
options = { content: options };
}
const position = options.position || "bottom-right";
const { id, selector } = useNotification.useNotificationContainerId();
if (!globalContainer[position] && !document.body.querySelector(selector.value)) {
globalContainer[position] = index.createContainer(`${id.value}-${position}`);
const { ns } = index$1.useGlobalComponentSettings("notification");
(_a = globalContainer[position]) == null ? void 0 : _a.classList.add(ns.is(position));
}
const vm = vue.createVNode(
notification$1["default"],
{ ...options, position },
vue.isVNode(options.content) ? {
default: () => shared.isObject(options) ? options.content : null
} : null
);
const container = document.createElement("div");
vue.render(vm, container);
(_b = globalContainer[position]) == null ? void 0 : _b.appendChild(container.firstChild);
const close = () => {
;
vm.component.exposed.close();
};
return {
close
};
};
exports["default"] = notification;
exports.notification = notification;
//# sourceMappingURL=notify.js.map