react-strawberry-toast 1.5.1 → 1.5.3
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/README.md +0 -1
- package/dist/headless.js +1 -1
- package/dist/headless.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,7 +64,6 @@ function App() {
|
|
|
64
64
|
| containerId | ID shown in the Toast Container Unique ID | String | |
|
|
65
65
|
| pauseOnHover | Option that sets the timer to stop or not when a hover event occurs | Boolean | true |
|
|
66
66
|
| icon | The icon to be displayed in the toast | ReactNode | |
|
|
67
|
-
| toastType | Toast Type | default, custom, success, error, loading, warn | default |
|
|
68
67
|
| timeOut | Time for toast to disappear | Number | 3000 |
|
|
69
68
|
| removeTimeOut | Time for toast to remove In Toast List | Number | 200 |
|
|
70
69
|
|
package/dist/headless.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var I=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var I=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var g=(t,s)=>{for(var r in s)I(t,r,{get:s[r],enumerable:!0})},U=(t,s,r,m)=>{if(s&&typeof s=="object"||typeof s=="function")for(let T of _(s))!w.call(t,T)&&T!==r&&I(t,T,{get:()=>s[T],enumerable:!(m=x(s,T))||m.enumerable});return t};var D=t=>U(I({},"__esModule",{value:!0}),t);var L={};g(L,{toast:()=>n,useToasts:()=>H});module.exports=D(L);var h=require("react");var M=()=>{let t=0;return()=>`react-strawberry-toast_${t++}`};var f=class{state=[];listeners=new Set;activatedToasts=new Set;toastTimers=new Map;constructor(){}subscribe(s){return this.listeners.add(s),()=>{this.listeners.delete(s)}}setState(s){this.state=typeof s=="function"?s(this.state):s,this.listeners.forEach(r=>r())}getSnapShot(){return this.state}};var b=t=>{let s=e=>{let a=t.toastTimers.get(e);clearTimeout(a),t.toastTimers.delete(e)},r=e=>{t.activatedToasts.add(e)},m=e=>t.activatedToasts.has(e),T=(e,a=200)=>{m(e)&&(t.activatedToasts.delete(e),setTimeout(()=>{t.state=t.state.filter(o=>o.toastId!==e),t.setState([...t.state])},a),s(e))},d=()=>{t.setState([])},A=(e,a,o)=>{t.state=t.state.map(c=>c.toastId===e?{...c,...o,updated:new Date().getTime(),data:a}:c),t.setState([...t.state])},S=e=>{let a=new Date().getTime();t.state=t.state.map(o=>o.toastId===e?{...o,pausedAt:a}:o),s(e)},O=(e,a)=>{let o=setTimeout(()=>{var y;t.state=t.state.map(u=>u.toastId===e?{...u,isVisible:!1}:u),t.setState([...t.state]);let c=(y=t.state.find(u=>u.toastId===e))==null?void 0:y.removeTimeOut;T(e,c)},a>2147483647?2147483647:a);t.toastTimers.set(e,o)};return{setActive:r,isActive:m,disappear:O,resume:e=>{if(t.toastTimers.has(e))return;let a=t.state.find(c=>c.toastId===e);if(!a)return;let o=a.createdAt+(a.timeOut||3e3)-(a.pausedAt||0);O(e,o)},pause:S,replace:A,remove:T,allClear:d}};var i=new f,P=M(),R=()=>(t,s={})=>{let{timeOut:r=3e3,removeTimeOut:m=200,toastId:T}=s,d=T||P();if(n.isActive(d))throw new Error("A duplicate custom ID is not available.");let A=new Date().getTime(),S={timeOut:r>2147483647?2147483647:r,toastId:d,data:t,pausedAt:null,updated:null,createdAt:A,removeTimeOut:m,isVisible:!0};return i.state.push(S),i.setState([...i.state]),d},n=(t,s={})=>R()(t,s),p=b(i);n.setActive=p.setActive;n.isActive=p.isActive;n.disappear=p.disappear;n.resume=p.resume;n.pause=p.pause;n.replace=p.replace;n.remove=p.remove;n.allClear=p.allClear;var H=()=>(0,h.useSyncExternalStore)(i.subscribe.bind(i),i.getSnapShot.bind(i),i.getSnapShot.bind(i));
|
package/dist/headless.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useSyncExternalStore as x}from"react";var y=()=>{let t=0;return()
|
|
1
|
+
import{useSyncExternalStore as x}from"react";var y=()=>{let t=0;return()=>`react-strawberry-toast_${t++}`};var f=class{state=[];listeners=new Set;activatedToasts=new Set;toastTimers=new Map;constructor(){}subscribe(a){return this.listeners.add(a),()=>{this.listeners.delete(a)}}setState(a){this.state=typeof a=="function"?a(this.state):a,this.listeners.forEach(p=>p())}getSnapShot(){return this.state}};var M=t=>{let a=e=>{let s=t.toastTimers.get(e);clearTimeout(s),t.toastTimers.delete(e)},p=e=>{t.activatedToasts.add(e)},u=e=>t.activatedToasts.has(e),l=(e,s=200)=>{u(e)&&(t.activatedToasts.delete(e),setTimeout(()=>{t.state=t.state.filter(r=>r.toastId!==e),t.setState([...t.state])},s),a(e))},m=()=>{t.setState([])},A=(e,s,r)=>{t.state=t.state.map(T=>T.toastId===e?{...T,...r,updated:new Date().getTime(),data:s}:T),t.setState([...t.state])},S=e=>{let s=new Date().getTime();t.state=t.state.map(r=>r.toastId===e?{...r,pausedAt:s}:r),a(e)},E=(e,s)=>{let r=setTimeout(()=>{var O;t.state=t.state.map(c=>c.toastId===e?{...c,isVisible:!1}:c),t.setState([...t.state]);let T=(O=t.state.find(c=>c.toastId===e))==null?void 0:O.removeTimeOut;l(e,T)},s>2147483647?2147483647:s);t.toastTimers.set(e,r)};return{setActive:p,isActive:u,disappear:E,resume:e=>{if(t.toastTimers.has(e))return;let s=t.state.find(T=>T.toastId===e);if(!s)return;let r=s.createdAt+(s.timeOut||3e3)-(s.pausedAt||0);E(e,r)},pause:S,replace:A,remove:l,allClear:m}};var o=new f,b=y(),h=()=>(t,a={})=>{let{timeOut:p=3e3,removeTimeOut:u=200,toastId:l}=a,m=l||b();if(i.isActive(m))throw new Error("A duplicate custom ID is not available.");let A=new Date().getTime(),S={timeOut:p>2147483647?2147483647:p,toastId:m,data:t,pausedAt:null,updated:null,createdAt:A,removeTimeOut:u,isVisible:!0};return o.state.push(S),o.setState([...o.state]),m},i=(t,a={})=>h()(t,a),n=M(o);i.setActive=n.setActive;i.isActive=n.isActive;i.disappear=n.disappear;i.resume=n.resume;i.pause=n.pause;i.replace=n.replace;i.remove=n.remove;i.allClear=n.allClear;var X=()=>x(o.subscribe.bind(o),o.getSnapShot.bind(o),o.getSnapShot.bind(o));export{i as toast,X as useToasts};
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var k=Object.defineProperty;var
|
|
2
|
+
"use strict";var k=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var tt=Object.prototype.hasOwnProperty;var et=(t,a)=>{for(var o in a)k(t,o,{get:a[o],enumerable:!0})},at=(t,a,o,c)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of Z(a))!tt.call(t,n)&&n!==o&&k(t,n,{get:()=>a[n],enumerable:!(c=Q(a,n))||c.enumerable});return t};var ot=t=>at(k({},"__esModule",{value:!0}),t);var pt={};et(pt,{ToastContainer:()=>ct,toast:()=>r,toastStore:()=>f,useToasts:()=>M});module.exports=ot(pt);var D=()=>{let t=0;return()=>`react-strawberry-toast_${t++}`};var A=class{state=[];listeners=new Set;activatedToasts=new Set;toastTimers=new Map;constructor(){}subscribe(a){return this.listeners.add(a),()=>{this.listeners.delete(a)}}setState(a){this.state=typeof a=="function"?a(this.state):a,this.listeners.forEach(o=>o())}getSnapShot(){return this.state}};var l="react-strawberry-toast";var u=require("react/jsx-runtime");function rt(){return(0,u.jsxs)("svg",{stroke:"none",fill:"none",strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",height:"22",width:"22",xmlns:"http://www.w3.org/2000/svg",children:[(0,u.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z"}),(0,u.jsx)("path",{d:"M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z",strokeWidth:"0",fill:"#1ab173"})]})}function st(){return(0,u.jsx)("svg",{stroke:"none",fill:"#eb2639",strokeWidth:"2",viewBox:"0 0 24 24",height:"22",width:"22",xmlns:"http://www.w3.org/2000/svg",children:(0,u.jsx)("path",{d:"M11.953 2C6.465 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.493 2 11.953 2zM13 17h-2v-2h2v2zm0-4h-2V7h2v6z"})})}function it(){return(0,u.jsx)("svg",{stroke:"none",fill:"#fcba03",strokeWidth:"0",viewBox:"0 0 1024 1024",height:"22",width:"22",xmlns:"http://www.w3.org/2000/svg",children:(0,u.jsx)("path",{d:"M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zM480 416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416zm32 352a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z"})})}var b={success:(0,u.jsx)(rt,{}),error:(0,u.jsx)(st,{}),loading:(0,u.jsx)("div",{className:`${l}__loading`}),warn:(0,u.jsx)(it,{})};var L=t=>{let a=e=>{let s=t.toastTimers.get(e);clearTimeout(s),t.toastTimers.delete(e)},o=e=>{t.activatedToasts.add(e)},c=e=>t.activatedToasts.has(e),n=(e,s=200)=>{c(e)&&(t.activatedToasts.delete(e),setTimeout(()=>{t.state=t.state.filter(i=>i.toastId!==e),t.setState([...t.state])},s),a(e))},T=()=>{t.setState([])},d=(e,s,i)=>{t.state=t.state.map(p=>p.toastId===e?{...p,...i,updated:new Date().getTime(),data:s}:p),t.setState([...t.state])},_=e=>{let s=new Date().getTime();t.state=t.state.map(i=>i.toastId===e?{...i,pausedAt:s}:i),a(e)},m=(e,s)=>{let i=setTimeout(()=>{var S;t.state=t.state.map(g=>g.toastId===e?{...g,isVisible:!1}:g),t.setState([...t.state]);let p=(S=t.state.find(g=>g.toastId===e))==null?void 0:S.removeTimeOut;n(e,p)},s>2147483647?2147483647:s);t.toastTimers.set(e,i)};return{setActive:o,isActive:c,disappear:m,resume:e=>{if(t.toastTimers.has(e))return;let s=t.state.find(p=>p.toastId===e);if(!s)return;let i=s.createdAt+(s.timeOut||3e3)-(s.pausedAt||0);m(e,i)},pause:_,replace:d,remove:n,allClear:T}};var f=new A,nt=D(),x=(t="default")=>(a,o={})=>{let{timeOut:c=3e3,removeTimeOut:n=200,pauseOnHover:T=!0,toastId:d,className:_,style:m,align:y}=o,e=d||nt();if(r.isActive(e))throw new Error("A duplicate custom ID is not available.");let s=new Date().getTime(),i={updated:null,pausedAt:null,className:_||"",style:m||{},icon:o.icon||null,containerId:o.containerId||null,position:o.position||null,timeOut:c>2147483647?2147483647:c,align:y||"",toastId:e,data:a,createdAt:s,toastType:t,pauseOnHover:T,removeTimeOut:n,isVisible:!0};return f.state.push(i),f.setState([...f.state]),e},r=(t,a={})=>x()(t,a),h=L(f);r.setActive=h.setActive;r.isActive=h.isActive;r.disappear=h.disappear;r.resume=h.resume;r.pause=h.pause;r.replace=h.replace;r.remove=h.remove;r.allClear=h.allClear;r.success=x("success");r.error=x("error");r.warn=x("warn");r.loading=x("loading");r.custom=x("custom");r.promise=(t,a,o={})=>{let{loading:c,success:n,error:T}=a,d=r.loading(c,{...o,timeOut:2147483647}),_={toastId:d,close:()=>r.disappear(d,0),immediatelyClose:()=>{r.disappear(d,0),r.remove(d,0)},icons:{success:b.success,error:b.error,warn:b.warn,loading:b.loading},isVisible:!0},m=o.timeOut||=3e3;t.then(y=>{r.replace(d,typeof n=="function"?n(y,_):n,{...o,timeOut:m>2147483647?2147483647:m,toastType:"success"})}).catch(y=>{r.replace(d,typeof T=="function"?T(y,_):T,{...o,timeOut:m>2147483647?2147483647:m,toastType:"error"})})};var N=require("react");var z=require("react");function H({condition:t,children:a}){let o=z.Children.toArray(a);if(o.length>2)throw new Error("The number of children exceeds two.");return o.find(c=>t?c.key===".0":c.key===".1")}function W({children:t}){return t}function Y({children:t}){return t}var V=({isVisible:t,position:a})=>t?/top/i.test(a)?`${l}__fade-in`:`${l}__fade-in-reverse`:/bottom/i.test(a)?`${l}__fade-out-reverse`:`${l}__fade-out`;var E=require("react"),O=(t,a)=>{let o=(0,E.useRef)(a);(0,E.useEffect)(()=>{o.current=a},[a]),(0,E.useEffect)(()=>(window.addEventListener(t,o.current),()=>{window.removeEventListener(t,o.current)}),[t])};var w=require("react/jsx-runtime");function U({toastProps:t,pauseOnActivate:a}){let{toastId:o,isVisible:c,timeOut:n,containerId:T,className:d,style:_,icon:m,updated:y,toastType:e,position:s,data:i,pauseOnHover:p,align:S}=t,g=V({isVisible:c,position:s}),R=typeof i=="function"?i({toastId:o,close:()=>r.disappear(o,0),immediatelyClose:()=>{r.disappear(o,0),r.remove(o,0)},icons:{success:b.success,error:b.error,warn:b.warn,loading:b.loading},isVisible:c}):i,G=()=>{p&&r.pause(o)},j=()=>{p&&r.resume(o)},q=()=>{a&&r.resume(o)},F=()=>{a&&r.pause(o)};O("focus",q),O("blur",F),(0,N.useEffect)(()=>{r.isActive(o)||(r.setActive(o),r.disappear(o,n))},[o]),(0,N.useEffect)(()=>{y!==null&&r.disappear(o,n)},[y]);let $=m||(e==="custom"||e==="default"?null:b[e]),J=/center/i.test(s)?"-center":/left/i.test(s)?"-left":"-right",K=e==="custom"?"":`${l}__toast${S?`-${S}`:J} ${g}`;return(0,w.jsx)("div",{role:"alert",className:K,"data-testid":`container-${T||"default"}`,onMouseEnter:G,onMouseLeave:j,children:(0,w.jsxs)(H,{condition:e!=="custom",children:[(0,w.jsx)(W,{children:(0,w.jsxs)("div",{className:d||`${l}__toast-content`,style:_,children:[$&&(0,w.jsx)("span",{className:`${l}__toast-icon`,children:$}),R]})}),(0,w.jsx)(Y,{children:R})]})})}var X=require("react");var M=()=>(0,X.useSyncExternalStore)(f.subscribe.bind(f),f.getSnapShot.bind(f),f.getSnapShot.bind(f));var B=({position:t,reverse:a=!1})=>/top/i.test(t)?a?"column-reverse":"column":/bottom/i.test(t)?a?"column":"column-reverse":"column";var P=require("react/jsx-runtime");function ct({className:t,style:a,limit:o,position:c="top-center",containerId:n="",gap:T=9,reverse:d=!1,pauseOnActivate:_=!0}){let y=M().reduce((e,s)=>{let i=s.position||c;return s.position=i,e[i]=e[i]||[],e[i].push(s),e},{});return(0,P.jsx)("div",{id:`${l}__root`,children:Object.entries(y).map(([e,s])=>{let i=B({position:e,reverse:d});return(0,P.jsx)("div",{"data-testid":e,className:`${`${l}__z9999`} ${t||`${l}__toast-container ${l}__${e}`}`,style:{flexDirection:i,gap:T,...a},children:s.filter(p=>n?p.containerId===n:!p.containerId).slice(0,o).map(p=>(0,P.jsx)(U,{toastProps:p,pauseOnActivate:_},p.toastId))},e)})})}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var
|
|
2
|
+
var N=()=>{let t=0;return()=>`react-strawberry-toast_${t++}`};var S=class{state=[];listeners=new Set;activatedToasts=new Set;toastTimers=new Map;constructor(){}subscribe(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}setState(r){this.state=typeof r=="function"?r(this.state):r,this.listeners.forEach(a=>a())}getSnapShot(){return this.state}};var c="react-strawberry-toast";import{jsx as _,jsxs as Z}from"react/jsx-runtime";function J(){return Z("svg",{stroke:"none",fill:"none",strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",height:"22",width:"22",xmlns:"http://www.w3.org/2000/svg",children:[_("path",{stroke:"none",d:"M0 0h24v24H0z"}),_("path",{d:"M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z",strokeWidth:"0",fill:"#1ab173"})]})}function K(){return _("svg",{stroke:"none",fill:"#eb2639",strokeWidth:"2",viewBox:"0 0 24 24",height:"22",width:"22",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M11.953 2C6.465 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.493 2 11.953 2zM13 17h-2v-2h2v2zm0-4h-2V7h2v6z"})})}function Q(){return _("svg",{stroke:"none",fill:"#fcba03",strokeWidth:"0",viewBox:"0 0 1024 1024",height:"22",width:"22",xmlns:"http://www.w3.org/2000/svg",children:_("path",{d:"M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zM480 416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416zm32 352a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z"})})}var T={success:_(J,{}),error:_(K,{}),loading:_("div",{className:`${c}__loading`}),warn:_(Q,{})};var M=t=>{let r=e=>{let s=t.toastTimers.get(e);clearTimeout(s),t.toastTimers.delete(e)},a=e=>{t.activatedToasts.add(e)},p=e=>t.activatedToasts.has(e),l=(e,s=200)=>{p(e)&&(t.activatedToasts.delete(e),setTimeout(()=>{t.state=t.state.filter(i=>i.toastId!==e),t.setState([...t.state])},s),r(e))},u=()=>{t.setState([])},d=(e,s,i)=>{t.state=t.state.map(n=>n.toastId===e?{...n,...i,updated:new Date().getTime(),data:s}:n),t.setState([...t.state])},b=e=>{let s=new Date().getTime();t.state=t.state.map(i=>i.toastId===e?{...i,pausedAt:s}:i),r(e)},m=(e,s)=>{let i=setTimeout(()=>{var x;t.state=t.state.map(w=>w.toastId===e?{...w,isVisible:!1}:w),t.setState([...t.state]);let n=(x=t.state.find(w=>w.toastId===e))==null?void 0:x.removeTimeOut;l(e,n)},s>2147483647?2147483647:s);t.toastTimers.set(e,i)};return{setActive:a,isActive:p,disappear:m,resume:e=>{if(t.toastTimers.has(e))return;let s=t.state.find(n=>n.toastId===e);if(!s)return;let i=s.createdAt+(s.timeOut||3e3)-(s.pausedAt||0);m(e,i)},pause:b,replace:d,remove:l,allClear:u}};var y=new S,tt=N(),g=(t="default")=>(r,a={})=>{let{timeOut:p=3e3,removeTimeOut:l=200,pauseOnHover:u=!0,toastId:d,className:b,style:m,align:f}=a,e=d||tt();if(o.isActive(e))throw new Error("A duplicate custom ID is not available.");let s=new Date().getTime(),i={updated:null,pausedAt:null,className:b||"",style:m||{},icon:a.icon||null,containerId:a.containerId||null,position:a.position||null,timeOut:p>2147483647?2147483647:p,align:f||"",toastId:e,data:r,createdAt:s,toastType:t,pauseOnHover:u,removeTimeOut:l,isVisible:!0};return y.state.push(i),y.setState([...y.state]),e},o=(t,r={})=>g()(t,r),h=M(y);o.setActive=h.setActive;o.isActive=h.isActive;o.disappear=h.disappear;o.resume=h.resume;o.pause=h.pause;o.replace=h.replace;o.remove=h.remove;o.allClear=h.allClear;o.success=g("success");o.error=g("error");o.warn=g("warn");o.loading=g("loading");o.custom=g("custom");o.promise=(t,r,a={})=>{let{loading:p,success:l,error:u}=r,d=o.loading(p,{...a,timeOut:2147483647}),b={toastId:d,close:()=>o.disappear(d,0),immediatelyClose:()=>{o.disappear(d,0),o.remove(d,0)},icons:{success:T.success,error:T.error,warn:T.warn,loading:T.loading},isVisible:!0},m=a.timeOut||=3e3;t.then(f=>{o.replace(d,typeof l=="function"?l(f,b):l,{...a,timeOut:m>2147483647?2147483647:m,toastType:"success"})}).catch(f=>{o.replace(d,typeof u=="function"?u(f,b):u,{...a,timeOut:m>2147483647?2147483647:m,toastType:"error"})})};import{useEffect as H}from"react";import{Children as et}from"react";function R({condition:t,children:r}){let a=et.toArray(r);if(a.length>2)throw new Error("The number of children exceeds two.");return a.find(p=>t?p.key===".0":p.key===".1")}function $({children:t}){return t}function D({children:t}){return t}var L=({isVisible:t,position:r})=>t?/top/i.test(r)?`${c}__fade-in`:`${c}__fade-in-reverse`:/bottom/i.test(r)?`${c}__fade-out-reverse`:`${c}__fade-out`;import{useEffect as z,useRef as at}from"react";var P=(t,r)=>{let a=at(r);z(()=>{a.current=r},[r]),z(()=>(window.addEventListener(t,a.current),()=>{window.removeEventListener(t,a.current)}),[t])};import{jsx as A,jsxs as W}from"react/jsx-runtime";function Y({toastProps:t,pauseOnActivate:r}){let{toastId:a,isVisible:p,timeOut:l,containerId:u,className:d,style:b,icon:m,updated:f,toastType:e,position:s,data:i,pauseOnHover:n,align:x}=t,w=L({isVisible:p,position:s}),C=typeof i=="function"?i({toastId:a,close:()=>o.disappear(a,0),immediatelyClose:()=>{o.disappear(a,0),o.remove(a,0)},icons:{success:T.success,error:T.error,warn:T.warn,loading:T.loading},isVisible:p}):i,X=()=>{n&&o.pause(a)},B=()=>{n&&o.resume(a)},G=()=>{r&&o.resume(a)},j=()=>{r&&o.pause(a)};P("focus",G),P("blur",j),H(()=>{o.isActive(a)||(o.setActive(a),o.disappear(a,l))},[a]),H(()=>{f!==null&&o.disappear(a,l)},[f]);let O=m||(e==="custom"||e==="default"?null:T[e]),q=/center/i.test(s)?"-center":/left/i.test(s)?"-left":"-right",F=e==="custom"?"":`${c}__toast${x?`-${x}`:q} ${w}`;return A("div",{role:"alert",className:F,"data-testid":`container-${u||"default"}`,onMouseEnter:X,onMouseLeave:B,children:W(R,{condition:e!=="custom",children:[A($,{children:W("div",{className:d||`${c}__toast-content`,style:b,children:[O&&A("span",{className:`${c}__toast-icon`,children:O}),C]})}),A(D,{children:C})]})})}import{useSyncExternalStore as ot}from"react";var V=()=>ot(y.subscribe.bind(y),y.getSnapShot.bind(y),y.getSnapShot.bind(y));var U=({position:t,reverse:r=!1})=>/top/i.test(t)?r?"column-reverse":"column":/bottom/i.test(t)?r?"column":"column-reverse":"column";import{jsx as k}from"react/jsx-runtime";function Xt({className:t,style:r,limit:a,position:p="top-center",containerId:l="",gap:u=9,reverse:d=!1,pauseOnActivate:b=!0}){let f=V().reduce((e,s)=>{let i=s.position||p;return s.position=i,e[i]=e[i]||[],e[i].push(s),e},{});return k("div",{id:`${c}__root`,children:Object.entries(f).map(([e,s])=>{let i=U({position:e,reverse:d});return k("div",{"data-testid":e,className:`${`${c}__z9999`} ${t||`${c}__toast-container ${c}__${e}`}`,style:{flexDirection:i,gap:u,...r},children:s.filter(n=>l?n.containerId===l:!n.containerId).slice(0,a).map(n=>k(Y,{toastProps:n,pauseOnActivate:b},n.toastId))},e)})})}export{Xt as ToastContainer,o as toast,y as toastStore,V as useToasts};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@keyframes l3{to{transform:rotate(1turn)}}@keyframes react-strawberry-toast_fade-in{0%{transform:translateY(-100%);opacity
|
|
1
|
+
@keyframes l3{to{transform:rotate(1turn)}}@keyframes react-strawberry-toast_fade-in{0%{transform:translateY(-100%) scale(.6);opacity:.2}to{transform:translateY(0) scale(1);opacity:1}}@keyframes react-strawberry-toast_fade-out{0%{transform:translateY(0);opacity:1}to{transform:translateY(-100%);opacity:.2}}@keyframes react-strawberry-toast_fade-in-reverse{0%{transform:translateY(100%) scale(.6);opacity:.2}to{transform:translateY(0) scale(1);opacity:1}}@keyframes react-strawberry-toast_fade-out-reverse{0%{transform:translateY(0);opacity:1}to{transform:translateY(100%);opacity:.2}}.react-strawberry-toast__z9999{z-index:9999}.react-strawberry-toast__toast-container{pointer-events:auto;position:fixed;z-index:9999;display:flex}.react-strawberry-toast__top-left{top:16px;left:16px}.react-strawberry-toast__top-center{top:16px;left:50%;transform:translate(-50%)}.react-strawberry-toast__top-right{top:16px;right:16px}.react-strawberry-toast__bottom-left{bottom:16px;left:16px}.react-strawberry-toast__bottom-center{bottom:16px;left:50%;transform:translate(-50%)}.react-strawberry-toast__bottom-right{bottom:16px;right:16px}.react-strawberry-toast__toast-left{display:flex}.react-strawberry-toast__toast-center{display:flex;justify-content:center}.react-strawberry-toast__toast-right{display:flex;justify-content:flex-end}.react-strawberry-toast__toast-content{box-sizing:border-box;background-color:#fff;padding:10px;display:flex;align-items:center;gap:5px;border-radius:8px;box-shadow:2px 4px 10px #0000001a;min-height:47px;max-width:368px}.react-strawberry-toast__toast-icon{width:22px;height:22px;display:flex;align-items:center;justify-content:center}.react-strawberry-toast__fade-in{animation:react-strawberry-toast_fade-in .3s cubic-bezier(.43,.14,.2,1.05)}.react-strawberry-toast__fade-out{animation:react-strawberry-toast_fade-out .3s cubic-bezier(.43,.14,.2,1.05)}.react-strawberry-toast__fade-in-reverse{animation:react-strawberry-toast_fade-in-reverse .3s cubic-bezier(.43,.14,.2,1.05)}.react-strawberry-toast__fade-out-reverse{animation:react-strawberry-toast_fade-out-reverse .3s cubic-bezier(.43,.14,.2,1.05)}.react-strawberry-toast__loading{width:18px;padding:3.5px;aspect-ratio:1;border-radius:50%;background:#6f6f70;--_m: conic-gradient(#0000 10%, #000), linear-gradient(#000 0 0) content-box;-webkit-mask:var(--_m);mask:var(--_m);-webkit-mask-composite:source-out;mask-composite:subtract;animation:l3 1s infinite linear}
|