@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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),p=(o,e)=>{const n=o.__vccOpts||o;for(const[c,s]of e)n[c]=s;return n},v={};function _(o,e){return t.openBlock(),t.createElementBlock("div",null,e[0]||(e[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=p(v,[["render",_]]),r=t.reactive([]);function h({location:o,title:e,content:n,icon:c,iconColor:s,timeout:i=2e3}){var l;r.push({id:Date.now(),iconColor:s||"toast-blue dark:toast-blue",location:["top-left","top-right","top-center","bottom-left","bottom-right","bottom-center"].includes(o)?`.${o}`:".bottom-right",title:e,content:n,icon:c,timeout:i}),((l=r[0])==null?void 0:l.timeout)!==!1&&setTimeout(()=>{var a;d((a=r[0])==null?void 0:a.id)},r[0].timeout)}function d(o){const e=r.findIndex(n=>n.id===o);e!==-1&&r.splice(e,1)}function u(){return{toasts:r,addToast:h,removeToast:d}}const b={id:"toast-default",class:"toast-card",role:"alert"},g=["innerHTML"],k={class:"toast-title"},E={class:"toast-content"},N=["onClick"],T={__name:"Toastify",setup(o){const{removeToast:e,toasts:n}=u();return(c,s)=>(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n),i=>(t.openBlock(),t.createBlock(t.Teleport,{key:i.id,to:i.location},[t.createElementVNode("div",b,[t.createElementVNode("div",{class:t.normalizeClass([i.iconColor,"toast-icon-wrap"]),innerHTML:i.icon},null,10,g),t.createElementVNode("div",null,[t.createElementVNode("div",k,t.toDisplayString(i.title),1),t.createElementVNode("div",E,t.toDisplayString(i.content),1)]),t.createElementVNode("button",{type:"button",class:"toast-close",onClick:l=>t.unref(e)(i.id),"aria-label":"Close"},s[0]||(s[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,N)])],8,["to"]))),128))}},V={__name:"ToastTemplate",setup(o){return(e,n)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(f),t.createVNode(T)],64))}},m=document.createElement("div");document.body.appendChild(m);app=t.createApp(V);app.mount(m);exports.useToast=u;
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;
@@ -1,67 +1,67 @@
1
- import { createElementBlock as d, openBlock as l, createStaticVNode as b, reactive as g, Fragment as _, renderList as k, unref as p, createBlock as T, Teleport as x, createElementVNode as o, normalizeClass as w, toDisplayString as u, createVNode as m, createApp as C } from "vue";
2
- const y = (e, t) => {
3
- const n = e.__vccOpts || e;
4
- for (const [c, s] of t)
5
- n[c] = s;
6
- return n;
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 B(e, t) {
9
- return l(), d("div", null, t[0] || (t[0] = [
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 $ = /* @__PURE__ */ y(M, [["render", B]]), r = g([]);
14
- function E({ location: e, title: t, content: n, icon: c, iconColor: s, timeout: i = 2e3 }) {
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: s || "toast-blue dark:toast-blue",
19
- location: ["top-left", "top-right", "top-center", "bottom-left", "bottom-right", "bottom-center"].includes(e) ? `.${e}` : ".bottom-right",
20
- title: t,
21
- content: n,
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: i
23
+ timeout: t
24
24
  }), ((a = r[0]) == null ? void 0 : a.timeout) !== !1 && setTimeout(() => {
25
- var v;
26
- f((v = r[0]) == null ? void 0 : v.id);
25
+ var p;
26
+ f((p = r[0]) == null ? void 0 : p.id);
27
27
  }, r[0].timeout);
28
28
  }
29
- function f(e) {
30
- const t = r.findIndex((n) => n.id === e);
31
- t !== -1 && r.splice(t, 1);
29
+ function f(n) {
30
+ const o = r.findIndex((s) => s.id === n);
31
+ o !== -1 && r.splice(o, 1);
32
32
  }
33
- function H() {
34
- return { toasts: r, addToast: E, removeToast: f };
33
+ function E() {
34
+ return { toasts: r, addToast: $, removeToast: f };
35
35
  }
36
- const L = {
36
+ const H = {
37
37
  id: "toast-default",
38
38
  class: "toast-card",
39
39
  role: "alert"
40
- }, N = ["innerHTML"], V = { class: "toast-title" }, z = { class: "toast-content" }, D = ["onClick"], S = {
40
+ }, L = ["innerHTML"], V = { class: "toast-title" }, z = { class: "toast-content" }, D = ["onClick"], S = {
41
41
  __name: "Toastify",
42
- setup(e) {
43
- const { removeToast: t, toasts: n } = H();
44
- return (c, s) => (l(!0), d(_, null, k(p(n), (i) => (l(), T(x, {
45
- key: i.id,
46
- to: i.location
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
- o("div", L, [
49
- o("div", {
50
- class: w([i.iconColor, "toast-icon-wrap"]),
51
- innerHTML: i.icon
52
- }, null, 10, N),
53
- o("div", null, [
54
- o("div", V, u(i.title), 1),
55
- o("div", z, u(i.content), 1)
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
- o("button", {
57
+ e("button", {
58
58
  type: "button",
59
59
  class: "toast-close",
60
- onClick: (a) => p(t)(i.id),
60
+ onClick: (a) => v(o)(t.id),
61
61
  "aria-label": "Close"
62
- }, s[0] || (s[0] = [
63
- o("span", { class: "sr-only" }, "Close", -1),
64
- o("svg", {
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
- o("path", {
76
+ e("path", {
77
77
  stroke: "none",
78
78
  d: "M0 0h24v24H0z",
79
79
  fill: "none"
80
80
  }),
81
- o("path", { d: "M18 6l-12 12" }),
82
- o("path", { d: "M6 6l12 12" })
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(e) {
91
- return (t, n) => (l(), d(_, null, [
92
- m($),
93
- m(S)
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 = C(j);
98
+ app = y(j);
99
99
  app.mount(h);
100
100
  export {
101
- H as useToast
101
+ E as useToast
102
102
  };
@@ -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,e)=>{const n=o.__vccOpts||o;for(const[l,c]of e)n[l]=c;return n},h={};function b(o,e){return t.openBlock(),t.createElementBlock("div",null,e[0]||(e[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:o,title:e,content:n,icon:l,iconColor:c,timeout:i=2e3}){var d;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(o)?`.${o}`:".bottom-right",title:e,content:n,icon:l,timeout:i}),((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(o){const e=r.findIndex(n=>n.id===o);e!==-1&&r.splice(e,1)}function p(){return{toasts:r,addToast:k,removeToast:a}}const g={id:"toast-default",class:"toast-card",role:"alert"},T=["innerHTML"],E={class:"toast-title"},V={class:"toast-content"},N=["onClick"],v={__name:"Toastify",setup(o){const{removeToast:e,toasts:n}=p();return(l,c)=>(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(n),i=>(t.openBlock(),t.createBlock(t.Teleport,{key:i.id,to:i.location},[t.createElementVNode("div",g,[t.createElementVNode("div",{class:t.normalizeClass([i.iconColor,"toast-icon-wrap"]),innerHTML:i.icon},null,10,T),t.createElementVNode("div",null,[t.createElementVNode("div",E,t.toDisplayString(i.title),1),t.createElementVNode("div",V,t.toDisplayString(i.content),1)]),t.createElementVNode("button",{type:"button",class:"toast-close",onClick:d=>t.unref(e)(i.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,N)])],8,["to"]))),128))}},y={__name:"ToastTemplate",setup(o){return(e,n)=>(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"})});
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pijushgupta/toastbite",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A simple Vue toast notification library",
5
5
  "main": "dist/toastbite.cjs.js",
6
6
  "module": "dist/toastbite.es.js",
@@ -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);