UNPKG

@shopware-ag/meteor-component-library

Version:

The meteor component library is a Vue component library developed by Shopware. It is based on the [Meteor Design System](https://shopware.design/).

110 lines (109 loc) 4.05 kB
import '../mt-toast.css'; "use strict"; const vue = require("vue"); const MtToastNotification = require("./MtToastNotification.js"); const _pluginVue_exportHelper = require("../_plugin-vue_export-helper-9c783a34.js"); require("../mt-icon.vue_vue_type_style_index_0_lang-0a28c7b6.js"); require("./MtButton.js"); require("../useIsInsideTooltip-f4674e27.js"); require("./MtLoader.js"); require("./MtText.js"); const _hoisted_1 = { class: "mt-toast--bottom-center" }; const _hoisted_2 = { class: "mt-toast--bottom-right" }; const _sfc_main = /* @__PURE__ */ vue.defineComponent({ __name: "mt-toast", props: { /** * A collection of toasts. The most current one needs to be prepended. */ toasts: { type: Array, required: true } }, emits: ["remove-toast"], setup(__props, { emit: __emit }) { const emit = __emit; const props = __props; const isHovered = vue.ref(false); const toasts = vue.toRef(() => props.toasts); const hoverTimeoutId = vue.ref(void 0); const quickToast = vue.computed(() => { const ct = toasts.value.filter((t) => { return !t.action && t.type !== "critical" && !t.dismissible; }); return ct[0]; }); const rightToasts = vue.computed(() => { return toasts.value.filter((t) => { return t.action || t.type === "critical" || t.dismissible; }); }); const classes = vue.computed(() => { return { "mt-toast--collapsed": !isHovered.value, "mt-toast--expanded": isHovered.value }; }); vue.watch(quickToast, (_, oldToast) => { if (!oldToast) { return; } emit("remove-toast", oldToast.id); }); function onMouseEnter() { if (hoverTimeoutId.value) { window.clearTimeout(hoverTimeoutId.value); } isHovered.value = true; } function onMouseLeave() { hoverTimeoutId.value = window.setTimeout(() => { isHovered.value = false; }, 500); } return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock("div", { class: vue.normalizeClass(["mt-toast", classes.value]), onMouseenter: onMouseEnter, onMouseleave: onMouseLeave }, [ _cache[1] || (_cache[1] = vue.createElementVNode("div", { class: "mt-toast--bottom-left" }, null, -1)), vue.createElementVNode("div", _hoisted_1, [ vue.createVNode(vue.Transition, { name: "quick-toasts" }, { default: vue.withCtx(() => [ quickToast.value ? (vue.openBlock(), vue.createBlock(MtToastNotification, { toast: quickToast.value, onRemoveToast: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("remove-toast", quickToast.value.id)), "quick-display": true, key: quickToast.value.id }, null, 8, ["toast"])) : vue.createCommentVNode("", true) ]), _: 1 }) ]), vue.createElementVNode("div", _hoisted_2, [ vue.createVNode(vue.TransitionGroup, { name: "toasts" }, { default: vue.withCtx(() => [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(rightToasts.value, (toast, index) => { return vue.openBlock(), vue.createBlock(MtToastNotification, { key: toast.id, toast, onRemoveToast: ($event) => _ctx.$emit("remove-toast", toast.id), style: vue.normalizeStyle({ "--num": index }), index }, null, 8, ["toast", "onRemoveToast", "style", "index"]); }), 128)) ]), _: 1 }) ]) ], 34); }; } }); const mtToast_vue_vue_type_style_index_0_scoped_49c93b73_lang = ""; const mtToast_vue_vue_type_style_index_1_lang = ""; const mtToast = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__scopeId", "data-v-49c93b73"]]); module.exports = mtToast; //# sourceMappingURL=MtToast.js.map