@pijushgupta/toastbite 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/toastbite.cjs.js +1 -1
- package/dist/toastbite.es.js +52 -52
- package/dist/toastbite.umd.js +1 -1
- package/package.json +1 -1
- package/src/components/useToast.js +2 -1
package/dist/toastbite.cjs.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),u=(n,o)=>{const s=n.__vccOpts||n;for(const[c,r]of o)s[c]=r;return s},m={};function _(n,o){return t.openBlock(),t.createElementBlock("div",null,o[0]||(o[0]=[t.createStaticVNode('<div><div class="toast-top-left top-left"></div></div><div><div class="toast-top-center top-center"></div></div><div><div class="toast-top-right top-right"></div></div><div><div class="toast-bottom-left bottom-left"></div></div><div><div class="toast-bottom-center bottom-center"></div></div><div><div class="toast-bottom-right bottom-right"></div></div>',6)]))}const f=u(m,[["render",_]]),i=t.reactive([]);function b({location:n,title:o,content:s,icon:c,iconColor:r,timeout:e=2e3}){var l;e=e===!0?2e3:typeof e=="number"&&!isNaN(e)?e:2e3,i.push({id:Date.now(),iconColor:r||"toast-blue dark:toast-blue",location:["top-left","top-right","top-center","bottom-left","bottom-right","bottom-center"].includes(n)?`.${n}`:".bottom-right",title:o,content:s,icon:c,timeout:e}),((l=i[0])==null?void 0:l.timeout)!==!1&&setTimeout(()=>{var a;d((a=i[0])==null?void 0:a.id)},i[0].timeout)}function d(n){const o=i.findIndex(s=>s.id===n);o!==-1&&i.splice(o,1)}function p(){return{toasts:i,addToast:b,removeToast:d}}const h={id:"toast-default",class:"toast-card",role:"alert"},g=["innerHTML"],k={class:"toast-title"},N={class:"toast-content"},E=["onClick"],T={__name:"Toastify",setup(n){const{removeToast:o,toasts:s}=p();return(c,r)=>(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(s),e=>(t.openBlock(),t.createBlock(t.Teleport,{key:e.id,to:e.location},[t.createElementVNode("div",h,[t.createElementVNode("div",{class:t.normalizeClass([e.iconColor,"toast-icon-wrap"]),innerHTML:e.icon},null,10,g),t.createElementVNode("div",null,[t.createElementVNode("div",k,t.toDisplayString(e.title),1),t.createElementVNode("div",N,t.toDisplayString(e.content),1)]),t.createElementVNode("button",{type:"button",class:"toast-close",onClick:l=>t.unref(o)(e.id),"aria-label":"Close"},r[0]||(r[0]=[t.createElementVNode("span",{class:"sr-only"},"Close",-1),t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-x"},[t.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),t.createElementVNode("path",{d:"M18 6l-12 12"}),t.createElementVNode("path",{d:"M6 6l12 12"})],-1)]),8,E)])],8,["to"]))),128))}},V={__name:"ToastTemplate",setup(n){return(o,s)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(f),t.createVNode(T)],64))}},v=document.createElement("div");document.body.appendChild(v);app=t.createApp(V);app.mount(v);exports.useToast=p;
|
package/dist/toastbite.es.js
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
import { createElementBlock as d, openBlock as l, createStaticVNode as b, reactive as g, Fragment as
|
2
|
-
const
|
3
|
-
const
|
4
|
-
for (const [c,
|
5
|
-
|
6
|
-
return
|
1
|
+
import { createElementBlock as d, openBlock as l, createStaticVNode as b, reactive as g, Fragment as m, renderList as k, unref as v, createBlock as T, Teleport as x, createElementVNode as e, normalizeClass as w, toDisplayString as u, createVNode as _, createApp as y } from "vue";
|
2
|
+
const C = (n, o) => {
|
3
|
+
const s = n.__vccOpts || n;
|
4
|
+
for (const [c, i] of o)
|
5
|
+
s[c] = i;
|
6
|
+
return s;
|
7
7
|
}, M = {};
|
8
|
-
function
|
9
|
-
return l(), d("div", null,
|
8
|
+
function N(n, o) {
|
9
|
+
return l(), d("div", null, o[0] || (o[0] = [
|
10
10
|
b('<div><div class="toast-top-left top-left"></div></div><div><div class="toast-top-center top-center"></div></div><div><div class="toast-top-right top-right"></div></div><div><div class="toast-bottom-left bottom-left"></div></div><div><div class="toast-bottom-center bottom-center"></div></div><div><div class="toast-bottom-right bottom-right"></div></div>', 6)
|
11
11
|
]));
|
12
12
|
}
|
13
|
-
const
|
14
|
-
function
|
13
|
+
const B = /* @__PURE__ */ C(M, [["render", N]]), r = g([]);
|
14
|
+
function $({ location: n, title: o, content: s, icon: c, iconColor: i, timeout: t = 2e3 }) {
|
15
15
|
var a;
|
16
|
-
r.push({
|
16
|
+
t = t === !0 ? 2e3 : typeof t == "number" && !isNaN(t) ? t : 2e3, r.push({
|
17
17
|
id: Date.now(),
|
18
|
-
iconColor:
|
19
|
-
location: ["top-left", "top-right", "top-center", "bottom-left", "bottom-right", "bottom-center"].includes(
|
20
|
-
title:
|
21
|
-
content:
|
18
|
+
iconColor: i || "toast-blue dark:toast-blue",
|
19
|
+
location: ["top-left", "top-right", "top-center", "bottom-left", "bottom-right", "bottom-center"].includes(n) ? `.${n}` : ".bottom-right",
|
20
|
+
title: o,
|
21
|
+
content: s,
|
22
22
|
icon: c,
|
23
|
-
timeout:
|
23
|
+
timeout: t
|
24
24
|
}), ((a = r[0]) == null ? void 0 : a.timeout) !== !1 && setTimeout(() => {
|
25
|
-
var
|
26
|
-
f((
|
25
|
+
var p;
|
26
|
+
f((p = r[0]) == null ? void 0 : p.id);
|
27
27
|
}, r[0].timeout);
|
28
28
|
}
|
29
|
-
function f(
|
30
|
-
const
|
31
|
-
|
29
|
+
function f(n) {
|
30
|
+
const o = r.findIndex((s) => s.id === n);
|
31
|
+
o !== -1 && r.splice(o, 1);
|
32
32
|
}
|
33
|
-
function
|
34
|
-
return { toasts: r, addToast:
|
33
|
+
function E() {
|
34
|
+
return { toasts: r, addToast: $, removeToast: f };
|
35
35
|
}
|
36
|
-
const
|
36
|
+
const H = {
|
37
37
|
id: "toast-default",
|
38
38
|
class: "toast-card",
|
39
39
|
role: "alert"
|
40
|
-
},
|
40
|
+
}, L = ["innerHTML"], V = { class: "toast-title" }, z = { class: "toast-content" }, D = ["onClick"], S = {
|
41
41
|
__name: "Toastify",
|
42
|
-
setup(
|
43
|
-
const { removeToast:
|
44
|
-
return (c,
|
45
|
-
key:
|
46
|
-
to:
|
42
|
+
setup(n) {
|
43
|
+
const { removeToast: o, toasts: s } = E();
|
44
|
+
return (c, i) => (l(!0), d(m, null, k(v(s), (t) => (l(), T(x, {
|
45
|
+
key: t.id,
|
46
|
+
to: t.location
|
47
47
|
}, [
|
48
|
-
|
49
|
-
|
50
|
-
class: w([
|
51
|
-
innerHTML:
|
52
|
-
}, null, 10,
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
e("div", H, [
|
49
|
+
e("div", {
|
50
|
+
class: w([t.iconColor, "toast-icon-wrap"]),
|
51
|
+
innerHTML: t.icon
|
52
|
+
}, null, 10, L),
|
53
|
+
e("div", null, [
|
54
|
+
e("div", V, u(t.title), 1),
|
55
|
+
e("div", z, u(t.content), 1)
|
56
56
|
]),
|
57
|
-
|
57
|
+
e("button", {
|
58
58
|
type: "button",
|
59
59
|
class: "toast-close",
|
60
|
-
onClick: (a) =>
|
60
|
+
onClick: (a) => v(o)(t.id),
|
61
61
|
"aria-label": "Close"
|
62
|
-
},
|
63
|
-
|
64
|
-
|
62
|
+
}, i[0] || (i[0] = [
|
63
|
+
e("span", { class: "sr-only" }, "Close", -1),
|
64
|
+
e("svg", {
|
65
65
|
xmlns: "http://www.w3.org/2000/svg",
|
66
66
|
width: "24",
|
67
67
|
height: "24",
|
@@ -73,13 +73,13 @@ const L = {
|
|
73
73
|
"stroke-linejoin": "round",
|
74
74
|
class: "icon icon-tabler icons-tabler-outline icon-tabler-x"
|
75
75
|
}, [
|
76
|
-
|
76
|
+
e("path", {
|
77
77
|
stroke: "none",
|
78
78
|
d: "M0 0h24v24H0z",
|
79
79
|
fill: "none"
|
80
80
|
}),
|
81
|
-
|
82
|
-
|
81
|
+
e("path", { d: "M18 6l-12 12" }),
|
82
|
+
e("path", { d: "M6 6l12 12" })
|
83
83
|
], -1)
|
84
84
|
]), 8, D)
|
85
85
|
])
|
@@ -87,16 +87,16 @@ const L = {
|
|
87
87
|
}
|
88
88
|
}, j = {
|
89
89
|
__name: "ToastTemplate",
|
90
|
-
setup(
|
91
|
-
return (
|
92
|
-
|
93
|
-
|
90
|
+
setup(n) {
|
91
|
+
return (o, s) => (l(), d(m, null, [
|
92
|
+
_(B),
|
93
|
+
_(S)
|
94
94
|
], 64));
|
95
95
|
}
|
96
96
|
}, h = document.createElement("div");
|
97
97
|
document.body.appendChild(h);
|
98
|
-
app =
|
98
|
+
app = y(j);
|
99
99
|
app.mount(h);
|
100
100
|
export {
|
101
|
-
|
101
|
+
E as useToast
|
102
102
|
};
|
package/dist/toastbite.umd.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
(function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s.Toastbite={},s.Vue))})(this,function(s,t){"use strict";const _=(o
|
1
|
+
(function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s.Toastbite={},s.Vue))})(this,function(s,t){"use strict";const _=(n,o)=>{const i=n.__vccOpts||n;for(const[l,c]of o)i[l]=c;return i},h={};function b(n,o){return t.openBlock(),t.createElementBlock("div",null,o[0]||(o[0]=[t.createStaticVNode('<div><div class="toast-top-left top-left"></div></div><div><div class="toast-top-center top-center"></div></div><div><div class="toast-top-right top-right"></div></div><div><div class="toast-bottom-left bottom-left"></div></div><div><div class="toast-bottom-center bottom-center"></div></div><div><div class="toast-bottom-right bottom-right"></div></div>',6)]))}const u=_(h,[["render",b]]),r=t.reactive([]);function k({location:n,title:o,content:i,icon:l,iconColor:c,timeout:e=2e3}){var d;e=e===!0?2e3:typeof e=="number"&&!isNaN(e)?e:2e3,r.push({id:Date.now(),iconColor:c||"toast-blue dark:toast-blue",location:["top-left","top-right","top-center","bottom-left","bottom-right","bottom-center"].includes(n)?`.${n}`:".bottom-right",title:o,content:i,icon:l,timeout:e}),((d=r[0])==null?void 0:d.timeout)!==!1&&setTimeout(()=>{var f;a((f=r[0])==null?void 0:f.id)},r[0].timeout)}function a(n){const o=r.findIndex(i=>i.id===n);o!==-1&&r.splice(o,1)}function p(){return{toasts:r,addToast:k,removeToast:a}}const g={id:"toast-default",class:"toast-card",role:"alert"},T=["innerHTML"],N={class:"toast-title"},E={class:"toast-content"},V=["onClick"],v={__name:"Toastify",setup(n){const{removeToast:o,toasts:i}=p();return(l,c)=>(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(i),e=>(t.openBlock(),t.createBlock(t.Teleport,{key:e.id,to:e.location},[t.createElementVNode("div",g,[t.createElementVNode("div",{class:t.normalizeClass([e.iconColor,"toast-icon-wrap"]),innerHTML:e.icon},null,10,T),t.createElementVNode("div",null,[t.createElementVNode("div",N,t.toDisplayString(e.title),1),t.createElementVNode("div",E,t.toDisplayString(e.content),1)]),t.createElementVNode("button",{type:"button",class:"toast-close",onClick:d=>t.unref(o)(e.id),"aria-label":"Close"},c[0]||(c[0]=[t.createElementVNode("span",{class:"sr-only"},"Close",-1),t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-x"},[t.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),t.createElementVNode("path",{d:"M18 6l-12 12"}),t.createElementVNode("path",{d:"M6 6l12 12"})],-1)]),8,V)])],8,["to"]))),128))}},y={__name:"ToastTemplate",setup(n){return(o,i)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(u),t.createVNode(v)],64))}},m=document.createElement("div");document.body.appendChild(m),app=t.createApp(y),app.mount(m),s.useToast=p,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -5,6 +5,7 @@ import { reactive } from "vue";
|
|
5
5
|
const toasts = reactive([]);
|
6
6
|
|
7
7
|
function addToast({ location, title, content, icon,iconColor,timeout = 2000}) {
|
8
|
+
timeout = timeout === true ? 2000 : (typeof timeout === "number" && !isNaN(timeout) ? timeout : 2000)
|
8
9
|
toasts.push({
|
9
10
|
id: Date.now(),
|
10
11
|
iconColor:iconColor?iconColor:'toast-blue dark:toast-blue',
|
@@ -16,7 +17,7 @@ function addToast({ location, title, content, icon,iconColor,timeout = 2000}) {
|
|
16
17
|
});
|
17
18
|
|
18
19
|
// Auto-remove after 5s
|
19
|
-
if(toasts[0]?.timeout !== false
|
20
|
+
if(toasts[0]?.timeout !== false){
|
20
21
|
setTimeout(() => {
|
21
22
|
removeToast(toasts[0]?.id);
|
22
23
|
},toasts[0].timeout);
|