Skip to content

Commit

Permalink
3.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kyvg committed Oct 28, 2024
1 parent 78075d0 commit 946f73b
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 126 deletions.
245 changes: 123 additions & 122 deletions dist/index.es.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,76 @@
(function(){"use strict";var o;try{if(typeof document<"u"){var e=document.createElement("style");e.nonce=(o=document.head.querySelector("meta[property=csp-nonce]"))==null?void 0:o.content,e.appendChild(document.createTextNode(".vue-notification-group{display:block;position:fixed;z-index:5000}.vue-notification-wrapper{display:block;overflow:hidden;width:100%;margin:0;padding:0}.notification-title{font-weight:600}.vue-notification-template{display:block;box-sizing:border-box;background:#fff;text-align:left}.vue-notification{display:block;box-sizing:border-box;text-align:left;font-size:12px;padding:10px;margin:0 5px 5px;color:#fff;background:#44a4fc;border-left:5px solid #187FE7}.vue-notification.warn{background:#ffb648;border-left-color:#f48a06}.vue-notification.error{background:#e54d42;border-left-color:#b82e24}.vue-notification.success{background:#68cd86;border-left-color:#42a85f}.vn-fade-enter-active,.vn-fade-leave-active,.vn-fade-move{transition:all .5s}.vn-fade-enter-from,.vn-fade-leave-to{opacity:0}")),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
import { defineComponent as Z, ref as M, computed as y, onMounted as tt, createVNode as l, TransitionGroup as et, mergeProps as nt, Fragment as k, isVNode as it } from "vue";
const j = /* @__PURE__ */ new Map();
class ot {
constructor(i, o, a) {
this.remaining = o, this.callback = i, this.notifyItem = a, this.resume();
}
pause() {
clearTimeout(this.notifyItem.timer), this.remaining -= Date.now() - this.start;
}
resume() {
this.start = Date.now(), clearTimeout(this.notifyItem.timer), this.notifyItem.timer = setTimeout(this.callback, this.remaining);
}
}
function at(t) {
return { all: t = t || /* @__PURE__ */ new Map(), on: function(i, o) {
var a = t.get(i);
a ? a.push(o) : t.set(i, [o]);
}, off: function(i, o) {
var a = t.get(i);
a && (o ? a.splice(a.indexOf(o) >>> 0, 1) : t.set(i, []));
}, emit: function(i, o) {
var a = t.get(i);
import { defineComponent as U, ref as X, computed as g, onMounted as Z, createVNode as l, TransitionGroup as tt, mergeProps as et, Fragment as $, isVNode as nt } from "vue";
const R = /* @__PURE__ */ new Map();
function ot(t) {
return { all: t = t || /* @__PURE__ */ new Map(), on: function(o, i) {
var a = t.get(o);
a ? a.push(i) : t.set(o, [i]);
}, off: function(o, i) {
var a = t.get(o);
a && (i ? a.splice(a.indexOf(i) >>> 0, 1) : t.set(o, []));
}, emit: function(o, i) {
var a = t.get(o);
a && a.slice().map(function(r) {
r(o);
r(i);
}), (a = t.get("*")) && a.slice().map(function(r) {
r(i, o);
r(o, i);
});
} };
}
const h = at(), b = "[-+]?[0-9]*.?[0-9]+", H = [
const v = ot(), T = "[-+]?[0-9]*.?[0-9]+", M = [
{
name: "px",
regexp: new RegExp(`^${b}px$`)
regexp: new RegExp(`^${T}px$`)
},
{
name: "%",
regexp: new RegExp(`^${b}%$`)
regexp: new RegExp(`^${T}%$`)
},
/**
* Fallback option
* If no suffix specified, assigning "px"
*/
{
name: "px",
regexp: new RegExp(`^${b}$`)
regexp: new RegExp(`^${T}$`)
}
], st = (t) => {
], it = (t) => {
if (t === "auto")
return {
type: t,
value: 0
};
for (let i = 0; i < H.length; i++) {
const o = H[i];
if (o.regexp.test(t))
for (let o = 0; o < M.length; o++) {
const i = M[o];
if (i.regexp.test(t))
return {
type: o.name,
type: i.name,
value: parseFloat(t)
};
}
return {
type: "",
value: t
};
}, rt = (t) => {
}, at = (t) => {
switch (typeof t) {
case "number":
return { type: "px", value: t };
case "string":
return st(t);
return it(t);
default:
return { type: "", value: t };
}
}, R = {
}, H = {
x: /* @__PURE__ */ new Set(["left", "center", "right"]),
y: /* @__PURE__ */ new Set(["top", "bottom"])
}, lt = /* @__PURE__ */ ((t) => () => t++)(0), ct = (t) => typeof t != "string" ? [] : t.split(/\s+/gi).filter(Boolean), ut = (t) => {
typeof t == "string" && (t = ct(t));
let i = null, o = null;
}, st = /* @__PURE__ */ ((t) => () => t++)(0), rt = (t) => typeof t != "string" ? [] : t.split(/\s+/gi).filter(Boolean), lt = (t) => {
typeof t == "string" && (t = rt(t));
let o = null, i = null;
return t.forEach((a) => {
R.y.has(a) && (o = a), R.x.has(a) && (i = a);
}), { x: i, y: o };
}, T = {
H.y.has(a) && (i = a), H.x.has(a) && (o = a);
}), { x: o, y: i };
}, b = {
position: ["top", "right"],
cssAnimation: "vn-fade",
velocityAnimation: {
Expand All @@ -94,14 +83,25 @@ const h = at(), b = "[-+]?[0-9]*.?[0-9]+", H = [
opacity: [0, 1]
}
}
}, ct = (t, o) => {
let i, a, r = o;
const y = () => {
a = Date.now(), i = setTimeout(t, r);
}, m = () => {
clearTimeout(i), r -= Date.now() - a;
};
return y(), {
start: y,
stop: m
};
};
function ft(t) {
return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !it(t);
function ut(t) {
return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !nt(t);
}
const g = {
const x = {
IDLE: 0,
DESTROYED: 2
}, dt = /* @__PURE__ */ Z({
}, ft = /* @__PURE__ */ U({
// eslint-disable-next-line vue/multi-word-component-names
name: "notifications",
props: {
Expand All @@ -123,7 +123,7 @@ const g = {
},
position: {
type: [String, Array],
default: () => T.position
default: () => b.position
},
classes: {
type: [String, Array],
Expand All @@ -139,12 +139,12 @@ const g = {
animation: {
type: Object,
default() {
return T.velocityAnimation;
return b.velocityAnimation;
}
},
animationName: {
type: String,
default: T.cssAnimation
default: b.cssAnimation
},
speed: {
type: Number,
Expand Down Expand Up @@ -190,126 +190,127 @@ const g = {
},
slots: Object,
setup: (t, {
emit: i,
slots: o,
emit: o,
slots: i,
expose: a
}) => {
const r = M([]), x = M(null), D = j.get("velocity"), v = y(() => t.animationType === "velocity"), c = y(() => r.value.filter((e) => e.state !== g.DESTROYED)), S = y(() => rt(t.width)), N = y(() => {
const r = X([]), y = R.get("velocity"), m = g(() => t.animationType === "velocity"), c = g(() => r.value.filter((e) => e.state !== x.DESTROYED)), D = g(() => at(t.width)), S = g(() => {
const {
x: e,
y: n
} = ut(t.position), s = S.value.value, u = S.value.type, p = {
} = lt(t.position), s = D.value.value, u = D.value.type, p = {
width: s + u
};
return n && (p[n] = "0px"), e && (e === "center" ? p.left = `calc(50% - ${+s / 2}${u})` : p[e] = "0px"), p;
}), B = y(() => v.value ? {
onEnter: q,
onLeave: z,
onAfterLeave: w
} : {}), C = (e) => {
i("click", e), t.closeOnClick && d(e);
}, L = () => {
var e;
t.pauseOnHover && ((e = x.value) == null || e.pause());
}, P = () => {
var e;
t.pauseOnHover && ((e = x.value) == null || e.resume());
}, Y = (e = {}) => {
}), j = g(() => m.value ? {
onEnter: G,
onLeave: W,
onAfterLeave: O
} : {}), B = (e) => {
o("click", e), t.closeOnClick && d(e);
}, L = (e) => {
var n;
t.pauseOnHover && ((n = e.timer) == null || n.stop());
}, k = (e) => {
var n;
t.pauseOnHover && ((n = e.timer) == null || n.start());
}, C = (e = {}) => {
if (e.group || (e.group = ""), e.data || (e.data = {}), t.group !== e.group)
return;
if (e.clean || e.clear) {
W();
F();
return;
}
const n = typeof e.duration == "number" ? e.duration : t.duration, s = typeof e.speed == "number" ? e.speed : t.speed, u = typeof e.ignoreDuplicates == "boolean" ? e.ignoreDuplicates : t.ignoreDuplicates, {
title: p,
text: J,
type: K,
data: Q,
id: U
text: q,
type: z,
data: J,
id: K
} = e, f = {
id: U || lt(),
id: K || st(),
title: p,
text: J,
type: K,
state: g.IDLE,
text: q,
type: z,
state: x.IDLE,
speed: s,
length: n + 2 * s,
data: Q,
data: J,
duplicates: 0
};
n >= 0 && (x.value = new ot(() => d(f), f.length, f));
const I = "bottom" in N.value, X = t.reverse ? !I : I;
let m = -1;
const A = c.value.find(($) => $.title === e.title && $.text === e.text);
n >= 0 && (f.timer = ct(() => d(f), f.length));
const w = "bottom" in S.value, Q = t.reverse ? !w : w;
let h = -1;
const A = c.value.find((I) => I.title === e.title && I.text === e.text);
if (u && A) {
A.duplicates++;
return;
}
X ? (r.value.push(f), i("start", f), c.value.length > t.max && (m = 0)) : (r.value.unshift(f), i("start", f), c.value.length > t.max && (m = c.value.length - 1)), m !== -1 && d(c.value[m]);
}, V = (e) => {
G(e);
}, _ = (e) => ["vue-notification-template", t.classes, e.type || ""], F = (e) => v.value ? void 0 : {
Q ? (r.value.push(f), o("start", f), c.value.length > t.max && (h = 0)) : (r.value.unshift(f), o("start", f), c.value.length > t.max && (h = c.value.length - 1)), h !== -1 && d(c.value[h]);
}, P = (e) => {
_(e);
}, Y = (e) => ["vue-notification-template", t.classes, e.type || ""], V = (e) => m.value ? void 0 : {
transition: `all ${e.speed}ms`
}, d = (e) => {
clearTimeout(e.timer), e.state = g.DESTROYED, w(), i("destroy", e);
}, G = (e) => {
var n;
(n = e.timer) == null || n.stop(), e.state = x.DESTROYED, O(), o("destroy", e);
}, _ = (e) => {
const n = r.value.find((s) => s.id === e);
n && d(n);
}, W = () => {
}, F = () => {
c.value.forEach(d);
}, O = (e, n) => {
}, N = (e, n) => {
var u;
const s = (u = t.animation) == null ? void 0 : u[e];
return typeof s == "function" ? s(n) : s;
}, q = (e, n) => {
const s = O("enter", e);
D(e, s, {
}, G = (e, n) => {
const s = N("enter", e);
y(e, s, {
duration: t.speed,
complete: n
});
}, z = (e, n) => {
const s = O("leave", e);
D(e, s, {
}, W = (e, n) => {
const s = N("leave", e);
y(e, s, {
duration: t.speed,
complete: n
});
};
function w() {
r.value = r.value.filter((e) => e.state !== g.DESTROYED);
function O() {
r.value = r.value.filter((e) => e.state !== x.DESTROYED);
}
return tt(() => {
h.on("add", Y), h.on("close", V);
return Z(() => {
v.on("add", C), v.on("close", P);
}), () => {
let e;
return l("div", {
class: "vue-notification-group",
style: N.value
}, [l(et, nt(B.value, {
style: S.value
}, [l(tt, et(j.value, {
tag: "div",
css: !v.value,
css: !m.value,
name: t.animationName
}), ft(e = c.value.map((n) => l("div", {
}), ut(e = c.value.map((n) => l("div", {
key: n.id,
class: "vue-notification-wrapper",
style: F(n),
style: V(n),
"data-id": n.id,
onMouseenter: L,
onMouseleave: P
}, [o.body ? o.body({
onMouseenter: () => L(n),
onMouseleave: () => k(n)
}, [i.body ? i.body({
item: n,
class: [t.classes, n.type],
close: () => d(n)
}) : l("div", {
class: _(n),
onClick: () => C(n)
}, [t.dangerouslySetInnerHtml ? l(k, null, [n.title ? l("div", {
class: Y(n),
onClick: () => B(n)
}, [t.dangerouslySetInnerHtml ? l($, null, [n.title ? l("div", {
class: "notification-title",
innerHTML: n.title
}, null) : null, l("div", {
class: "notification-content",
innerHTML: n.text
}, null)]) : l(k, null, [n.title ? l("div", {
}, null)]) : l($, null, [n.title ? l("div", {
class: "notification-title"
}, [n.title]) : null, l("div", {
class: "notification-content"
Expand All @@ -319,23 +320,23 @@ const g = {
};
}
}), E = (t) => {
typeof t == "string" && (t = { title: "", text: t }), typeof t == "object" && h.emit("add", t);
typeof t == "string" && (t = { title: "", text: t }), typeof t == "object" && v.emit("add", t);
};
E.close = (t) => {
h.emit("close", t);
v.emit("close", t);
};
const gt = () => ({ notify: E }), pt = "Notifications";
function yt(t, i = {}) {
Object.entries(i).forEach((a) => j.set(...a));
const o = i.name || "notify";
t.config.globalProperties["$" + o] = E, t.component(i.componentName || pt, dt);
const mt = () => ({ notify: E }), dt = "Notifications";
function pt(t, o = {}) {
Object.entries(o).forEach((a) => R.set(...a));
const i = o.name || "notify";
t.config.globalProperties["$" + i] = E, t.component(o.componentName || dt, ft);
}
const ht = {
install: yt
const gt = {
install: pt
};
export {
dt as Notifications,
ht as default,
ft as Notifications,
gt as default,
E as notify,
gt as useNotification
mt as useNotification
};
Loading

0 comments on commit 946f73b

Please sign in to comment.