vue-sonner
Advanced tools
Comparing version 1.2.2 to 1.2.3
var Ut = Object.defineProperty; | ||
var Kt = (s, a, t) => a in s ? Ut(s, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[a] = t; | ||
var B = (s, a, t) => Kt(s, typeof a != "symbol" ? a + "" : a, t); | ||
import { ref as p, watchEffect as W, defineComponent as vt, computed as y, onMounted as Yt, onUnmounted as Gt, openBlock as l, createElementBlock as h, normalizeClass as Y, normalizeStyle as ut, unref as L, createBlock as G, resolveDynamicComponent as Z, renderSlot as P, createCommentVNode as j, mergeProps as ct, Fragment as V, createElementVNode as M, normalizeProps as Lt, createTextVNode as Nt, toDisplayString as lt, renderList as gt, useAttrs as qt, nextTick as Jt, watch as Rt, withCtx as K, createVNode as X } from "vue"; | ||
import { ref as p, watchEffect as N, defineComponent as vt, computed as y, onMounted as Yt, watch as Ft, onUnmounted as Gt, openBlock as l, createElementBlock as h, normalizeClass as Y, normalizeStyle as ct, unref as L, createBlock as q, resolveDynamicComponent as Z, renderSlot as P, createCommentVNode as V, mergeProps as ut, Fragment as W, createElementVNode as M, normalizeProps as Lt, createTextVNode as Nt, toDisplayString as lt, renderList as gt, useAttrs as qt, nextTick as Jt, withCtx as X, createVNode as G } from "vue"; | ||
function Xt(s) { | ||
@@ -77,3 +77,3 @@ if (!s || typeof document > "u") return; | ||
g = !1; | ||
const v = typeof t.error == "function" ? await t.error( | ||
const b = typeof t.error == "function" ? await t.error( | ||
`HTTP error! status: ${d.status}` | ||
@@ -84,7 +84,7 @@ ) : t.error, f = typeof t.description == "function" ? ( | ||
) : t.description; | ||
this.create({ id: r, type: "error", message: v, description: f }); | ||
this.create({ id: r, type: "error", message: b, description: f }); | ||
} else if (t.success !== void 0) { | ||
g = !1; | ||
const v = typeof t.success == "function" ? await t.success(d) : t.success, f = typeof t.description == "function" ? await t.description(d) : t.description; | ||
this.create({ id: r, type: "success", message: v, description: f }); | ||
const b = typeof t.success == "function" ? await t.success(d) : t.success, f = typeof t.description == "function" ? await t.description(d) : t.description; | ||
this.create({ id: r, type: "success", message: b, description: f }); | ||
} | ||
@@ -94,6 +94,6 @@ }).catch(async (d) => { | ||
g = !1; | ||
const v = typeof t.error == "function" ? await t.error(d) : t.error, f = typeof t.description == "function" ? await t.description( | ||
const b = typeof t.error == "function" ? await t.error(d) : t.error, f = typeof t.description == "function" ? await t.description( | ||
d | ||
) : t.description; | ||
this.create({ id: r, type: "error", message: v, description: f }); | ||
this.create({ id: r, type: "error", message: b, description: f }); | ||
} | ||
@@ -104,5 +104,5 @@ }).finally(() => { | ||
}), m = () => new Promise( | ||
(d, v) => x.then( | ||
() => k[0] === "reject" ? v(k[1]) : d(k[1]) | ||
).catch(v) | ||
(d, b) => x.then( | ||
() => k[0] === "reject" ? b(k[1]) : d(k[1]) | ||
).catch(b) | ||
); | ||
@@ -151,3 +151,3 @@ return typeof r != "string" && typeof r != "number" ? { unwrap: m } : Object.assign(r, { unwrap: m }); | ||
const s = p(!1); | ||
return W(() => { | ||
return N(() => { | ||
const a = () => { | ||
@@ -163,3 +163,3 @@ s.value = document.hidden; | ||
const s = p([]); | ||
return W((a) => { | ||
return N((a) => { | ||
const t = $.subscribe((r) => { | ||
@@ -222,20 +222,20 @@ if ("dismiss" in r && r.dismiss) | ||
setup(s, { emit: a }) { | ||
const t = s, r = a, n = p(!1), g = p(!1), k = p(!1), x = p(!1), m = p(0), d = p(0), v = p(null), f = p(null), N = y(() => t.index === 0), ft = y(() => t.index + 1 <= t.visibleToasts), I = y(() => t.toast.type), R = y(() => t.toast.dismissible !== !1), pt = y(() => t.toast.class || ""), ht = y(() => t.descriptionClass || ""), o = t.toast.style || {}, i = y( | ||
const t = s, r = a, n = p(!1), g = p(!1), k = p(!1), x = p(!1), m = p(0), d = p(0), b = p(null), f = p(null), R = y(() => t.index === 0), ft = y(() => t.index + 1 <= t.visibleToasts), I = y(() => t.toast.type), F = y(() => t.toast.dismissible !== !1), pt = y(() => t.toast.class || ""), ht = y(() => t.descriptionClass || ""), o = t.toast.style || {}, i = y( | ||
() => t.heights.findIndex((e) => e.toastId === t.toast.id) || 0 | ||
), c = y(() => t.toast.closeButton ?? t.closeButton), C = y( | ||
), u = y(() => t.toast.closeButton ?? t.closeButton), C = y( | ||
() => t.toast.duration || t.duration || re | ||
), S = p(0), T = p(0), F = p(0), z = p(null), U = y(() => t.position.split("-")), tt = y(() => U.value[0]), et = y(() => U.value[1]), at = y(() => typeof t.toast.title != "string"), ot = y( | ||
), S = p(0), T = p(0), j = p(0), z = p(null), U = y(() => t.position.split("-")), tt = y(() => U.value[0]), et = y(() => U.value[1]), at = y(() => typeof t.toast.title != "string"), ot = y( | ||
() => typeof t.toast.description != "string" | ||
), st = y(() => t.heights.reduce((e, u, w) => w >= i.value ? e : e + u.height, 0)), nt = ae(), rt = y(() => t.toast.invert || t.invert), H = y(() => I.value === "loading"); | ||
), st = y(() => t.heights.reduce((e, c, w) => w >= i.value ? e : e + c.height, 0)), nt = ae(), rt = y(() => t.toast.invert || t.invert), H = y(() => I.value === "loading"); | ||
Yt(() => { | ||
if (!n.value) return; | ||
const e = f.value, u = e == null ? void 0 : e.style.height; | ||
const e = f.value, c = e == null ? void 0 : e.style.height; | ||
e.style.height = "auto"; | ||
const w = e.getBoundingClientRect().height; | ||
e.style.height = u, d.value = w; | ||
e.style.height = c, d.value = w; | ||
let E; | ||
t.heights.find( | ||
(b) => b.toastId === t.toast.id | ||
(v) => v.toastId === t.toast.id | ||
) ? E = t.heights.map( | ||
(b) => b.toastId === t.toast.id ? { ...b, height: w } : b | ||
(v) => v.toastId === t.toast.id ? { ...v, height: w } : v | ||
) : E = [ | ||
@@ -250,6 +250,6 @@ { | ||
}); | ||
function q() { | ||
function K() { | ||
g.value = !0, m.value = T.value; | ||
const e = t.heights.filter( | ||
(u) => u.toastId !== t.toast.id | ||
(c) => c.toastId !== t.toast.id | ||
); | ||
@@ -261,10 +261,10 @@ r("update:heights", e), setTimeout(() => { | ||
function bt() { | ||
var e, u; | ||
H.value || !R.value || (q(), (u = (e = t.toast).onDismiss) == null || u.call(e, t.toast)); | ||
var e, c; | ||
H.value || !F.value || (K(), (c = (e = t.toast).onDismiss) == null || c.call(e, t.toast)); | ||
} | ||
function jt(e) { | ||
H.value || !R.value || (v.value = /* @__PURE__ */ new Date(), m.value = T.value, e.target.setPointerCapture(e.pointerId), e.target.tagName !== "BUTTON" && (k.value = !0, z.value = { x: e.clientX, y: e.clientY })); | ||
H.value || !F.value || (b.value = /* @__PURE__ */ new Date(), m.value = T.value, e.target.setPointerCapture(e.pointerId), e.target.tagName !== "BUTTON" && (k.value = !0, z.value = { x: e.clientX, y: e.clientY })); | ||
} | ||
function Vt() { | ||
var E, D, b, A, O; | ||
var E, D, v, A, O; | ||
if (x.value) return; | ||
@@ -274,5 +274,5 @@ z.value = null; | ||
((E = f.value) == null ? void 0 : E.style.getPropertyValue("--swipe-amount").replace("px", "")) || 0 | ||
), u = (/* @__PURE__ */ new Date()).getTime() - ((D = v.value) == null ? void 0 : D.getTime()), w = Math.abs(e) / u; | ||
), c = (/* @__PURE__ */ new Date()).getTime() - ((D = b.value) == null ? void 0 : D.getTime()), w = Math.abs(e) / c; | ||
if (Math.abs(e) >= ie || w > 0.11) { | ||
m.value = T.value, (A = (b = t.toast).onDismiss) == null || A.call(b, t.toast), q(), x.value = !0; | ||
m.value = T.value, (A = (v = t.toast).onDismiss) == null || A.call(v, t.toast), K(), x.value = !0; | ||
return; | ||
@@ -284,36 +284,41 @@ } | ||
var O; | ||
if (!z.value || !R.value) return; | ||
const u = e.clientY - z.value.y, w = e.clientX - z.value.x, D = (U.value[0] === "top" ? Math.min : Math.max)(0, u), b = e.pointerType === "touch" ? 10 : 2; | ||
Math.abs(D) > b ? (O = f.value) == null || O.style.setProperty("--swipe-amount", `${u}px`) : Math.abs(w) > b && (z.value = null); | ||
if (!z.value || !F.value) return; | ||
const c = e.clientY - z.value.y, w = e.clientX - z.value.x, D = (U.value[0] === "top" ? Math.min : Math.max)(0, c), v = e.pointerType === "touch" ? 10 : 2; | ||
Math.abs(D) > v ? (O = f.value) == null || O.style.setProperty("--swipe-amount", `${c}px`) : Math.abs(w) > v && (z.value = null); | ||
} | ||
return W(() => { | ||
return N(() => { | ||
T.value = i.value * (t == null ? void 0 : t.gap) + st.value; | ||
}), W((e) => { | ||
}), N((e) => { | ||
if (t.toast.promise && I.value === "loading" || t.toast.duration === 1 / 0 || t.toast.type === "loading") | ||
return; | ||
let u, w = C.value; | ||
let c, w = C.value; | ||
const E = () => { | ||
if (F.value < S.value) { | ||
const b = (/* @__PURE__ */ new Date()).getTime() - S.value; | ||
w = w - b; | ||
if (j.value < S.value) { | ||
const v = (/* @__PURE__ */ new Date()).getTime() - S.value; | ||
w = w - v; | ||
} | ||
F.value = (/* @__PURE__ */ new Date()).getTime(); | ||
j.value = (/* @__PURE__ */ new Date()).getTime(); | ||
}, D = () => { | ||
w !== 1 / 0 && (S.value = (/* @__PURE__ */ new Date()).getTime(), u = setTimeout(() => { | ||
var b, A; | ||
(A = (b = t.toast).onAutoClose) == null || A.call(b, t.toast), q(); | ||
w !== 1 / 0 && (S.value = (/* @__PURE__ */ new Date()).getTime(), c = setTimeout(() => { | ||
var v, A; | ||
(A = (v = t.toast).onAutoClose) == null || A.call(v, t.toast), K(); | ||
}, w)); | ||
}; | ||
t.expanded || t.interacting || t.pauseWhenPageIsHidden && nt ? E() : D(), e(() => { | ||
clearTimeout(u); | ||
clearTimeout(c); | ||
}); | ||
}), Yt(() => { | ||
}), Ft( | ||
() => t.toast.delete, | ||
(e) => { | ||
e && K(); | ||
} | ||
), Yt(() => { | ||
if (f.value) { | ||
const e = f.value.getBoundingClientRect().height; | ||
d.value = e; | ||
const u = [ | ||
const c = [ | ||
{ toastId: t.toast.id, height: e, position: t.toast.position }, | ||
...t.heights | ||
]; | ||
r("update:heights", u); | ||
r("update:heights", c); | ||
} | ||
@@ -324,8 +329,8 @@ n.value = !0; | ||
const e = t.heights.filter( | ||
(u) => u.toastId !== t.toast.id | ||
(c) => c.toastId !== t.toast.id | ||
); | ||
r("update:heights", e); | ||
} | ||
}), (e, u) => { | ||
var w, E, D, b, A, O, yt, wt, kt, xt, Tt, Bt, St, Ct, $t, It, Et, Pt, Dt, zt, Ht, At, Mt, Ot; | ||
}), (e, c) => { | ||
var w, E, D, v, A, O, yt, wt, kt, xt, Tt, Bt, St, Ct, $t, It, Et, Pt, Dt, zt, Ht, At, Mt, Ot; | ||
return l(), h("li", { | ||
@@ -347,3 +352,3 @@ ref_key: "toastRef", | ||
// @ts-ignore | ||
(A = (b = e.toast) == null ? void 0 : b.classes) == null ? void 0 : A[I.value] | ||
(A = (v = e.toast) == null ? void 0 : v.classes) == null ? void 0 : A[I.value] | ||
)), | ||
@@ -359,5 +364,5 @@ "data-rich-colors": e.toast.richColors ?? e.defaultRichColors, | ||
"data-index": e.index, | ||
"data-front": N.value, | ||
"data-front": R.value, | ||
"data-swiping": k.value, | ||
"data-dismissible": R.value, | ||
"data-dismissible": F.value, | ||
"data-type": I.value, | ||
@@ -367,3 +372,3 @@ "data-invert": rt.value, | ||
"data-expanded": !!(e.expanded || e.expandByDefault && n.value), | ||
style: ut({ | ||
style: ct({ | ||
"--index": e.index, | ||
@@ -381,3 +386,3 @@ "--toasts-before": e.index, | ||
}, [ | ||
c.value && !e.toast.component ? (l(), h("button", { | ||
u.value && !e.toast.component ? (l(), h("button", { | ||
key: 0, | ||
@@ -390,11 +395,11 @@ "aria-label": e.closeButtonAriaLabel || "Close toast", | ||
}, [ | ||
(xt = e.icons) != null && xt.close ? (l(), G(Z((Tt = e.icons) == null ? void 0 : Tt.close), { key: 0 })) : P(e.$slots, "close-icon", { key: 1 }) | ||
], 10, se)) : j("", !0), | ||
e.toast.component ? (l(), G(Z(e.toast.component), ct({ key: 1 }, e.toast.componentProps, { onCloseToast: bt }), null, 16)) : (l(), h(V, { key: 2 }, [ | ||
(xt = e.icons) != null && xt.close ? (l(), q(Z((Tt = e.icons) == null ? void 0 : Tt.close), { key: 0 })) : P(e.$slots, "close-icon", { key: 1 }) | ||
], 10, se)) : V("", !0), | ||
e.toast.component ? (l(), q(Z(e.toast.component), ut({ key: 1 }, e.toast.componentProps, { onCloseToast: bt }), null, 16)) : (l(), h(W, { key: 2 }, [ | ||
I.value !== "default" || e.toast.icon || e.toast.promise ? (l(), h("div", ne, [ | ||
(e.toast.promise || I.value === "loading") && !e.toast.icon ? P(e.$slots, "loading-icon", { key: 0 }) : j("", !0), | ||
e.toast.icon ? (l(), G(Z(e.toast.icon), { key: 1 })) : (l(), h(V, { key: 2 }, [ | ||
I.value === "success" ? P(e.$slots, "success-icon", { key: 0 }) : I.value === "error" ? P(e.$slots, "error-icon", { key: 1 }) : I.value === "warning" ? P(e.$slots, "warning-icon", { key: 2 }) : I.value === "info" ? P(e.$slots, "info-icon", { key: 3 }) : j("", !0) | ||
(e.toast.promise || I.value === "loading") && !e.toast.icon ? P(e.$slots, "loading-icon", { key: 0 }) : V("", !0), | ||
e.toast.icon ? (l(), q(Z(e.toast.icon), { key: 1 })) : (l(), h(W, { key: 2 }, [ | ||
I.value === "success" ? P(e.$slots, "success-icon", { key: 0 }) : I.value === "error" ? P(e.$slots, "error-icon", { key: 1 }) : I.value === "warning" ? P(e.$slots, "warning-icon", { key: 2 }) : I.value === "info" ? P(e.$slots, "info-icon", { key: 3 }) : V("", !0) | ||
], 64)) | ||
])) : j("", !0), | ||
])) : V("", !0), | ||
M("div", { | ||
@@ -408,3 +413,3 @@ "data-content": "", | ||
}, [ | ||
at.value ? (l(), G(Z(e.toast.title), Lt(ct({ key: 0 }, e.toast.componentProps)), null, 16)) : (l(), h(V, { key: 1 }, [ | ||
at.value ? (l(), q(Z(e.toast.title), Lt(ut({ key: 0 }, e.toast.componentProps)), null, 16)) : (l(), h(W, { key: 1 }, [ | ||
Nt(lt(e.toast.title), 1) | ||
@@ -425,29 +430,29 @@ ], 64)) | ||
}, [ | ||
ot.value ? (l(), G(Z(e.toast.description), Lt(ct({ key: 0 }, e.toast.componentProps)), null, 16)) : (l(), h(V, { key: 1 }, [ | ||
ot.value ? (l(), q(Z(e.toast.description), Lt(ut({ key: 0 }, e.toast.componentProps)), null, 16)) : (l(), h(W, { key: 1 }, [ | ||
Nt(lt(e.toast.description), 1) | ||
], 64)) | ||
], 2)) : j("", !0) | ||
], 2)) : V("", !0) | ||
], 2), | ||
e.toast.cancel ? (l(), h("button", { | ||
key: 1, | ||
style: ut(e.toast.cancelButtonStyle || e.cancelButtonStyle), | ||
style: ct(e.toast.cancelButtonStyle || e.cancelButtonStyle), | ||
class: Y(e.cn((Dt = e.classes) == null ? void 0 : Dt.cancelButton, (zt = e.toast.classes) == null ? void 0 : zt.cancelButton)), | ||
"data-button": "", | ||
"data-cancel": "", | ||
onClick: u[0] || (u[0] = (it) => { | ||
onClick: c[0] || (c[0] = (it) => { | ||
var J, Q; | ||
L(dt)(e.toast.cancel) && R.value && ((Q = (J = e.toast.cancel).onClick) == null || Q.call(J, it), q()); | ||
L(dt)(e.toast.cancel) && F.value && ((Q = (J = e.toast.cancel).onClick) == null || Q.call(J, it), K()); | ||
}) | ||
}, lt(L(dt)(e.toast.cancel) ? (Ht = e.toast.cancel) == null ? void 0 : Ht.label : e.toast.cancel), 7)) : j("", !0), | ||
}, lt(L(dt)(e.toast.cancel) ? (Ht = e.toast.cancel) == null ? void 0 : Ht.label : e.toast.cancel), 7)) : V("", !0), | ||
e.toast.action ? (l(), h("button", { | ||
key: 2, | ||
style: ut(e.toast.actionButtonStyle || e.actionButtonStyle), | ||
style: ct(e.toast.actionButtonStyle || e.actionButtonStyle), | ||
class: Y(e.cn((At = e.classes) == null ? void 0 : At.actionButton, (Mt = e.toast.classes) == null ? void 0 : Mt.actionButton)), | ||
"data-button": "", | ||
"data-action": "", | ||
onClick: u[1] || (u[1] = (it) => { | ||
onClick: c[1] || (c[1] = (it) => { | ||
var J, Q; | ||
L(dt)(e.toast.action) && (it.defaultPrevented || ((Q = (J = e.toast.action).onClick) == null || Q.call(J, it), q())); | ||
L(dt)(e.toast.action) && (it.defaultPrevented || ((Q = (J = e.toast.action).onClick) == null || Q.call(J, it), K())); | ||
}) | ||
}, lt(L(dt)(e.toast.action) ? (Ot = e.toast.action) == null ? void 0 : Ot.label : e.toast.action), 7)) : j("", !0) | ||
}, lt(L(dt)(e.toast.action) ? (Ot = e.toast.action) == null ? void 0 : Ot.label : e.toast.action), 7)) : V("", !0) | ||
], 64)) | ||
@@ -462,3 +467,3 @@ ], 46, oe); | ||
return t; | ||
}, ue = {}, ce = { | ||
}, ce = {}, ue = { | ||
xmlns: "http://www.w3.org/2000/svg", | ||
@@ -475,3 +480,3 @@ width: "12", | ||
function fe(s, a) { | ||
return l(), h("svg", ce, a[0] || (a[0] = [ | ||
return l(), h("svg", ue, a[0] || (a[0] = [ | ||
M("line", { | ||
@@ -491,3 +496,3 @@ x1: "18", | ||
} | ||
const pe = /* @__PURE__ */ _(ue, [["render", fe]]), he = ["data-visible"], ge = { class: "sonner-spinner" }, me = /* @__PURE__ */ vt({ | ||
const pe = /* @__PURE__ */ _(ce, [["render", fe]]), he = ["data-visible"], ge = { class: "sonner-spinner" }, me = /* @__PURE__ */ vt({ | ||
__name: "Loader", | ||
@@ -504,3 +509,3 @@ props: { | ||
M("div", ge, [ | ||
(l(!0), h(V, null, gt(L(a), (n) => (l(), h("div", { | ||
(l(!0), h(W, null, gt(L(a), (n) => (l(), h("div", { | ||
key: `spinner-bar-${n}`, | ||
@@ -576,3 +581,3 @@ class: "sonner-loading-bar" | ||
} | ||
const ze = /* @__PURE__ */ _(Ee, [["render", De]]), He = ["aria-label"], Ae = ["dir", "data-theme", "data-rich-colors", "data-y-position", "data-x-position"], Me = 3, Ft = "32px", Oe = 356, Ye = 14, Le = typeof window < "u" && typeof document < "u"; | ||
const ze = /* @__PURE__ */ _(Ee, [["render", De]]), He = ["aria-label"], Ae = ["dir", "data-theme", "data-rich-colors", "data-y-position", "data-x-position"], Me = 3, Rt = "32px", Oe = 356, Ye = 14, Le = typeof window < "u" && typeof document < "u"; | ||
function Ne(...s) { | ||
@@ -599,3 +604,3 @@ return s.filter(Boolean).join(" "); | ||
style: { default: () => ({}) }, | ||
offset: { default: Ft }, | ||
offset: { default: Rt }, | ||
dir: { default: "auto" }, | ||
@@ -619,13 +624,13 @@ icons: {}, | ||
a.theme !== "system" ? a.theme : typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" | ||
), v = p(null), f = p(null), N = p(!1), ft = a.hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, ""); | ||
), b = p(null), f = p(null), R = p(!1), ft = a.hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, ""); | ||
function I(o) { | ||
var i; | ||
(i = n.value.find((c) => c.id === o.id)) != null && i.delete || $.dismiss(o.id), n.value = n.value.filter(({ id: c }) => c !== o.id); | ||
(i = n.value.find((u) => u.id === o.id)) != null && i.delete || $.dismiss(o.id), n.value = n.value.filter(({ id: u }) => u !== o.id); | ||
} | ||
function R(o) { | ||
var i, c; | ||
N.value && !((c = (i = o.currentTarget) == null ? void 0 : i.contains) != null && c.call(i, o.relatedTarget)) && (N.value = !1, f.value && (f.value.focus({ preventScroll: !0 }), f.value = null)); | ||
function F(o) { | ||
var i, u; | ||
R.value && !((u = (i = o.currentTarget) == null ? void 0 : i.contains) != null && u.call(i, o.relatedTarget)) && (R.value = !1, f.value && (f.value.focus({ preventScroll: !0 }), f.value = null)); | ||
} | ||
function pt(o) { | ||
o.target instanceof HTMLElement && o.target.dataset.dismissible === "false" || N.value || (N.value = !0, f.value = o.relatedTarget); | ||
o.target instanceof HTMLElement && o.target.dataset.dismissible === "false" || R.value || (R.value = !0, f.value = o.relatedTarget); | ||
} | ||
@@ -635,7 +640,7 @@ function ht(o) { | ||
} | ||
return W((o) => { | ||
const i = $.subscribe((c) => { | ||
if (c.dismiss) { | ||
return N((o) => { | ||
const i = $.subscribe((u) => { | ||
if (u.dismiss) { | ||
n.value = n.value.map( | ||
(C) => C.id === c.id ? { ...C, delete: !0 } : C | ||
(C) => C.id === u.id ? { ...C, delete: !0 } : C | ||
); | ||
@@ -646,9 +651,9 @@ return; | ||
const C = n.value.findIndex( | ||
(S) => S.id === c.id | ||
(S) => S.id === u.id | ||
); | ||
C !== -1 ? n.value = [ | ||
...n.value.slice(0, C), | ||
{ ...n.value[C], ...c }, | ||
{ ...n.value[C], ...u }, | ||
...n.value.slice(C + 1) | ||
] : n.value = [c, ...n.value]; | ||
] : n.value = [u, ...n.value]; | ||
}); | ||
@@ -659,3 +664,3 @@ }); | ||
}); | ||
}), Rt( | ||
}), Ft( | ||
() => a.theme, | ||
@@ -671,20 +676,14 @@ (o) => { | ||
} | ||
), Rt( | ||
() => v.value, | ||
() => { | ||
if (v.value) | ||
return () => { | ||
f.value && (f.value.focus({ preventScroll: !0 }), f.value = null, N.value = !1); | ||
}; | ||
} | ||
), W(() => { | ||
), N(() => { | ||
b.value && f.value && (f.value.focus({ preventScroll: !0 }), f.value = null, R.value = !1); | ||
}), N(() => { | ||
n.value.length <= 1 && (x.value = !1); | ||
}), W((o) => { | ||
function i(c) { | ||
}), N((o) => { | ||
function i(u) { | ||
const C = a.hotkey.every( | ||
(F) => c[F] || c.code === F | ||
), S = Array.isArray(v.value) ? v.value[0] : v.value; | ||
(j) => u[j] || u.code === j | ||
), S = Array.isArray(b.value) ? b.value[0] : b.value; | ||
C && (x.value = !0, S == null || S.focus()); | ||
const T = document.activeElement === v.value || (S == null ? void 0 : S.contains(document.activeElement)); | ||
c.code === "Escape" && T && (x.value = !1); | ||
const T = document.activeElement === b.value || (S == null ? void 0 : S.contains(document.activeElement)); | ||
u.code === "Escape" && T && (x.value = !1); | ||
} | ||
@@ -698,9 +697,9 @@ Le && (document.addEventListener("keydown", i), o(() => { | ||
}, [ | ||
(l(!0), h(V, null, gt(g.value, (c, C) => { | ||
(l(!0), h(W, null, gt(g.value, (u, C) => { | ||
var S; | ||
return l(), h("ol", ct({ | ||
key: c, | ||
return l(), h("ol", ut({ | ||
key: u, | ||
ref_for: !0, | ||
ref_key: "listRef", | ||
ref: v, | ||
ref: b, | ||
"data-sonner-toaster": "", | ||
@@ -712,7 +711,7 @@ class: a.class, | ||
"data-rich-colors": o.richColors, | ||
"data-y-position": c.split("-")[0], | ||
"data-x-position": c.split("-")[1], | ||
"data-y-position": u.split("-")[0], | ||
"data-x-position": u.split("-")[1], | ||
style: { | ||
"--front-toast-height": `${(S = k.value[0]) == null ? void 0 : S.height}px`, | ||
"--offset": typeof o.offset == "number" ? `${o.offset}px` : o.offset || Ft, | ||
"--offset": typeof o.offset == "number" ? `${o.offset}px` : o.offset || Rt, | ||
"--width": `${Oe}px`, | ||
@@ -724,3 +723,3 @@ "--gap": `${o.gap}px`, | ||
}, o.$attrs, { | ||
onBlur: R, | ||
onBlur: F, | ||
onFocus: pt, | ||
@@ -735,11 +734,11 @@ onMouseenter: i[1] || (i[1] = () => x.value = !0), | ||
}), [ | ||
(l(!0), h(V, null, gt(n.value.filter( | ||
(T) => !T.position && C === 0 || T.position === c | ||
), (T, F) => { | ||
(l(!0), h(W, null, gt(n.value.filter( | ||
(T) => !T.position && C === 0 || T.position === u | ||
), (T, j) => { | ||
var z, U, tt, et, at, ot, st, nt, rt; | ||
return l(), G(de, { | ||
return l(), q(de, { | ||
key: T.id, | ||
heights: k.value.filter((H) => H.position === T.position), | ||
icons: o.icons, | ||
index: F, | ||
index: j, | ||
toast: T, | ||
@@ -754,4 +753,4 @@ defaultRichColors: o.richColors, | ||
interacting: m.value, | ||
position: c, | ||
style: ut((at = o.toastOptions) == null ? void 0 : at.style), | ||
position: u, | ||
style: ct((at = o.toastOptions) == null ? void 0 : at.style), | ||
unstyled: (ot = o.toastOptions) == null ? void 0 : ot.unstyled, | ||
@@ -772,10 +771,10 @@ classes: (st = o.toastOptions) == null ? void 0 : st.classes, | ||
}, { | ||
"close-icon": K(() => [ | ||
"close-icon": X(() => [ | ||
P(o.$slots, "close-icon", {}, () => [ | ||
X(pe) | ||
G(pe) | ||
]) | ||
]), | ||
"loading-icon": K(() => [ | ||
"loading-icon": X(() => [ | ||
P(o.$slots, "loading-icon", {}, () => [ | ||
X(me, { | ||
G(me, { | ||
visible: T.type === "loading" | ||
@@ -785,20 +784,20 @@ }, null, 8, ["visible"]) | ||
]), | ||
"success-icon": K(() => [ | ||
"success-icon": X(() => [ | ||
P(o.$slots, "success-icon", {}, () => [ | ||
X(we) | ||
G(we) | ||
]) | ||
]), | ||
"error-icon": K(() => [ | ||
"error-icon": X(() => [ | ||
P(o.$slots, "error-icon", {}, () => [ | ||
X(ze) | ||
G(ze) | ||
]) | ||
]), | ||
"warning-icon": K(() => [ | ||
"warning-icon": X(() => [ | ||
P(o.$slots, "warning-icon", {}, () => [ | ||
X(Ie) | ||
G(Ie) | ||
]) | ||
]), | ||
"info-icon": K(() => [ | ||
"info-icon": X(() => [ | ||
P(o.$slots, "info-icon", {}, () => [ | ||
X(Be) | ||
G(Be) | ||
]) | ||
@@ -805,0 +804,0 @@ ]), |
{ | ||
"name": "vue-sonner", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"type": "module", | ||
@@ -8,2 +8,3 @@ "author": "xiaoluoboding <xiaoluoboding@gmail.com>", | ||
"dev": "vite", | ||
"build:dev": "vite build --mode lib --watch", | ||
"build:docs": "vite build --mode docs", | ||
@@ -10,0 +11,0 @@ "build:lib": "vite build --mode lib && pnpm run build:types", |
@@ -35,2 +35,3 @@ # Sonner for Vue | ||
- [Installation](#installation) | ||
- [Test](#test) | ||
- [Usage](#usage) | ||
@@ -78,2 +79,29 @@ - [For Vue 3](#for-vue-3) | ||
## Test | ||
To run the test you need two separate CLI window : | ||
### Launching the test | ||
To launch the test, you need to go in the test directory | ||
```bash | ||
cd ./test | ||
``` | ||
and launch the following command | ||
```bash | ||
cd ./test | ||
pnpm test:e2e --ui | ||
``` | ||
### Build and watch for change in order to fix the test | ||
This command will build the vue-sonner library in lib mode, and add a watch so every time you modify the code of the library, you will have a new bundle and can run the test again. | ||
```bash | ||
pnpm build:dev | ||
``` | ||
## Usage | ||
@@ -80,0 +108,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
264743
501
1156