react-strawberry-toast 2.1.0 → 3.0.0

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.
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
2
2
 
3
3
  type Position = 'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-left' | 'top-center' | 'top-right';
4
4
  type ToastType = 'default' | 'custom' | 'success' | 'error' | 'loading' | 'warn' | 'info';
5
+ type CapitalizedToastType = Capitalize<ToastType>;
5
6
  interface BaseOptions {
6
7
  toastId?: string;
7
8
  timeOut?: number;
@@ -33,7 +34,7 @@ interface ToastDataCallback {
33
34
  close: () => void;
34
35
  immediatelyClose: () => void;
35
36
  isVisible: boolean;
36
- icons: Record<Exclude<ToastType, 'default' | 'custom'>, ReactNode>;
37
+ Icons: Record<Exclude<CapitalizedToastType, 'Default' | 'Custom'> | 'Close', () => ReactNode>;
37
38
  }
38
39
  type ToastState = ToastBaseState & BaseOptions;
39
40
  type ToastDataWithCallback = (props: ToastDataCallback) => ReactNode;
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
2
2
 
3
3
  type Position = 'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-left' | 'top-center' | 'top-right';
4
4
  type ToastType = 'default' | 'custom' | 'success' | 'error' | 'loading' | 'warn' | 'info';
5
+ type CapitalizedToastType = Capitalize<ToastType>;
5
6
  interface BaseOptions {
6
7
  toastId?: string;
7
8
  timeOut?: number;
@@ -33,7 +34,7 @@ interface ToastDataCallback {
33
34
  close: () => void;
34
35
  immediatelyClose: () => void;
35
36
  isVisible: boolean;
36
- icons: Record<Exclude<ToastType, 'default' | 'custom'>, ReactNode>;
37
+ Icons: Record<Exclude<CapitalizedToastType, 'Default' | 'Custom'> | 'Close', () => ReactNode>;
37
38
  }
38
39
  type ToastState = ToastBaseState & BaseOptions;
39
40
  type ToastDataWithCallback = (props: ToastDataCallback) => ReactNode;
package/dist/headless.js CHANGED
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var g=(t,s)=>{for(var r in s)v(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&&v(t,T,{get:()=>s[T],enumerable:!(m=x(s,T))||m.enumerable});return t};var D=t=>U(v({},"__esModule",{value:!0}),t);var L={};g(L,{toast:()=>n,useToasts:()=>H});module.exports=D(L);var b=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 h=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.state.forEach(e=>{I(e.toastId,0)})},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)},I=(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:I,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);I(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=h(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,b.useSyncExternalStore)(i.subscribe.bind(i),i.getSnapShot.bind(i),i.getSnapShot.bind(i));
1
+ "use strict";var v=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var g=(t,s)=>{for(var r in s)v(t,r,{get:s[r],enumerable:!0})},U=(t,s,r,d)=>{if(s&&typeof s=="object"||typeof s=="function")for(let T of x(s))!_.call(t,T)&&T!==r&&v(t,T,{get:()=>s[T],enumerable:!(d=w(s,T))||d.enumerable});return t};var D=t=>U(v({},"__esModule",{value:!0}),t);var L={};g(L,{toast:()=>n,useToasts:()=>H});module.exports=D(L);var b=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 h=t=>{let s=e=>{let a=t.toastTimers.get(e);clearTimeout(a),t.toastTimers.delete(e)},r=e=>{t.activatedToasts.add(e)},d=e=>t.activatedToasts.has(e),T=(e,a=200)=>{d(e)&&(t.activatedToasts.delete(e),setTimeout(()=>{t.state=t.state.filter(o=>o.toastId!==e),t.setState([...t.state])},a),s(e))},c=()=>{t.state.forEach(e=>{I(e.toastId,0)})},A=(e,a,o)=>{t.state=t.state.map(m=>m.toastId===e?{...m,...o,updated:new Date().getTime(),data:a}:m),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)},I=(e,a)=>{let o=window.setTimeout(()=>{var y;t.state=t.state.map(u=>u.toastId===e?{...u,isVisible:!1}:u),t.setState([...t.state]);let m=(y=t.state.find(u=>u.toastId===e))==null?void 0:y.removeTimeOut;T(e,m)},a>2147483647?2147483647:a);t.toastTimers.set(e,o)};return{setActive:r,isActive:d,disappear:I,resume:e=>{if(t.toastTimers.has(e))return;let a=t.state.find(m=>m.toastId===e);if(!a)return;let o=a.createdAt+(a.timeOut||3e3)-(a.pausedAt||0);I(e,o)},pause:S,replace:A,remove:T,allClear:c}};var i=new f,P=M(),R=()=>(t,s={})=>{let{timeOut:r=3e3,removeTimeOut:d=200,toastId:T}=s,c=T||P();if(n.isActive(c))throw new Error("A duplicate custom ID is not available.");let A=new Date().getTime(),S={timeOut:r>2147483647?2147483647:r,toastId:c,data:t,pausedAt:null,updated:null,createdAt:A,removeTimeOut:d,isVisible:!0};return i.state.push(S),i.setState([...i.state]),c},n=(t,s={})=>R()(t,s),p=h(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,b.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()=>`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.state.forEach(e=>{I(e.toastId,0)})},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)},I=(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:I,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);I(e,r)},pause:S,replace:A,remove:l,allClear:m}};var o=new f,h=y(),b=()=>(t,a={})=>{let{timeOut:p=3e3,removeTimeOut:u=200,toastId:l}=a,m=l||h();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={})=>b()(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};
1
+ import{useSyncExternalStore as w}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))},d=()=>{t.state.forEach(e=>{I(e.toastId,0)})},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)},I=(e,s)=>{let r=window.setTimeout(()=>{var O;t.state=t.state.map(m=>m.toastId===e?{...m,isVisible:!1}:m),t.setState([...t.state]);let T=(O=t.state.find(m=>m.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:I,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);I(e,r)},pause:S,replace:A,remove:l,allClear:d}};var o=new f,h=y(),b=()=>(t,a={})=>{let{timeOut:p=3e3,removeTimeOut:u=200,toastId:l}=a,d=l||h();if(i.isActive(d))throw new Error("A duplicate custom ID is not available.");let A=new Date().getTime(),S={timeOut:p>2147483647?2147483647:p,toastId:d,data:t,pausedAt:null,updated:null,createdAt:A,removeTimeOut:u,isVisible:!0};return o.state.push(S),o.setState([...o.state]),d},i=(t,a={})=>b()(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=()=>w(o.subscribe.bind(o),o.getSnapShot.bind(o),o.getSnapShot.bind(o));export{i as toast,X as useToasts};
package/dist/index.d.mts CHANGED
@@ -1,8 +1,9 @@
1
- import React$1, { ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
 
4
4
  type Position = 'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-left' | 'top-center' | 'top-right';
5
5
  type ToastType = 'default' | 'custom' | 'success' | 'error' | 'loading' | 'warn' | 'info';
6
+ type CapitalizedToastType = Capitalize<ToastType>;
6
7
  interface BaseOptions {
7
8
  toastId?: string;
8
9
  timeOut?: number;
@@ -34,7 +35,7 @@ interface ToastDataCallback {
34
35
  close: () => void;
35
36
  immediatelyClose: () => void;
36
37
  isVisible: boolean;
37
- icons: Record<Exclude<ToastType, 'default' | 'custom'>, ReactNode>;
38
+ Icons: Record<Exclude<CapitalizedToastType, 'Default' | 'Custom'> | 'Close', () => ReactNode>;
38
39
  }
39
40
  type ToastState = ToastBaseState & BaseOptions;
40
41
  type ToastDataWithCallback = (props: ToastDataCallback) => ReactNode;
@@ -43,6 +44,23 @@ type NonHeadlessToastState = Required<Options & {
43
44
  }> & Omit<ToastState, 'data'> & {
44
45
  data: ToastDataWithCallback | ReactNode;
45
46
  };
47
+ interface ToastContainerProps {
48
+ className?: string;
49
+ style?: React.CSSProperties;
50
+ position?: Position;
51
+ containerId?: string;
52
+ reverse?: boolean;
53
+ gap?: number;
54
+ pauseOnActivate?: boolean;
55
+ stack?: boolean;
56
+ }
57
+ type AddionalProps = {
58
+ order: number;
59
+ toastsBySamePosition: Array<NonHeadlessToastState>;
60
+ } & Required<Pick<ToastContainerProps, 'gap' | 'pauseOnActivate' | 'stack'>>;
61
+ interface ToasterProps {
62
+ toastProps: NonHeadlessToastState & AddionalProps;
63
+ }
46
64
 
47
65
  type Listener = () => void;
48
66
  declare class ToastStore<T = ToastState> {
@@ -85,17 +103,8 @@ declare const toast: {
85
103
  }, options?: Options): void;
86
104
  };
87
105
 
88
- interface ToastContainerProps {
89
- className?: string;
90
- style?: React$1.CSSProperties;
91
- position?: Position;
92
- containerId?: string;
93
- reverse?: boolean;
94
- gap?: number;
95
- pauseOnActivate?: boolean;
96
- }
97
- declare function ToastContainer({ className, style, position: globalPosition, containerId, gap, reverse, pauseOnActivate, }: ToastContainerProps): react_jsx_runtime.JSX.Element;
106
+ declare function ToastContainer({ className, style, position: globalPosition, containerId, gap, reverse, pauseOnActivate, stack, }: ToastContainerProps): react_jsx_runtime.JSX.Element;
98
107
 
99
108
  declare const useToasts: () => Array<NonHeadlessToastState>;
100
109
 
101
- export { type BaseOptions, type NonHeadlessToastState, type Options, type Position, type ToastBaseState, ToastContainer, type ToastDataCallback, type ToastDataWithCallback, type ToastState, type ToastType, toast, toastStore, useToasts };
110
+ export { type AddionalProps, type BaseOptions, type CapitalizedToastType, type NonHeadlessToastState, type Options, type Position, type ToastBaseState, ToastContainer, type ToastContainerProps, type ToastDataCallback, type ToastDataWithCallback, type ToastState, type ToastType, type ToasterProps, toast, toastStore, useToasts };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import React$1, { ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
 
4
4
  type Position = 'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-left' | 'top-center' | 'top-right';
5
5
  type ToastType = 'default' | 'custom' | 'success' | 'error' | 'loading' | 'warn' | 'info';
6
+ type CapitalizedToastType = Capitalize<ToastType>;
6
7
  interface BaseOptions {
7
8
  toastId?: string;
8
9
  timeOut?: number;
@@ -34,7 +35,7 @@ interface ToastDataCallback {
34
35
  close: () => void;
35
36
  immediatelyClose: () => void;
36
37
  isVisible: boolean;
37
- icons: Record<Exclude<ToastType, 'default' | 'custom'>, ReactNode>;
38
+ Icons: Record<Exclude<CapitalizedToastType, 'Default' | 'Custom'> | 'Close', () => ReactNode>;
38
39
  }
39
40
  type ToastState = ToastBaseState & BaseOptions;
40
41
  type ToastDataWithCallback = (props: ToastDataCallback) => ReactNode;
@@ -43,6 +44,23 @@ type NonHeadlessToastState = Required<Options & {
43
44
  }> & Omit<ToastState, 'data'> & {
44
45
  data: ToastDataWithCallback | ReactNode;
45
46
  };
47
+ interface ToastContainerProps {
48
+ className?: string;
49
+ style?: React.CSSProperties;
50
+ position?: Position;
51
+ containerId?: string;
52
+ reverse?: boolean;
53
+ gap?: number;
54
+ pauseOnActivate?: boolean;
55
+ stack?: boolean;
56
+ }
57
+ type AddionalProps = {
58
+ order: number;
59
+ toastsBySamePosition: Array<NonHeadlessToastState>;
60
+ } & Required<Pick<ToastContainerProps, 'gap' | 'pauseOnActivate' | 'stack'>>;
61
+ interface ToasterProps {
62
+ toastProps: NonHeadlessToastState & AddionalProps;
63
+ }
46
64
 
47
65
  type Listener = () => void;
48
66
  declare class ToastStore<T = ToastState> {
@@ -85,17 +103,8 @@ declare const toast: {
85
103
  }, options?: Options): void;
86
104
  };
87
105
 
88
- interface ToastContainerProps {
89
- className?: string;
90
- style?: React$1.CSSProperties;
91
- position?: Position;
92
- containerId?: string;
93
- reverse?: boolean;
94
- gap?: number;
95
- pauseOnActivate?: boolean;
96
- }
97
- declare function ToastContainer({ className, style, position: globalPosition, containerId, gap, reverse, pauseOnActivate, }: ToastContainerProps): react_jsx_runtime.JSX.Element;
106
+ declare function ToastContainer({ className, style, position: globalPosition, containerId, gap, reverse, pauseOnActivate, stack, }: ToastContainerProps): react_jsx_runtime.JSX.Element;
98
107
 
99
108
  declare const useToasts: () => Array<NonHeadlessToastState>;
100
109
 
101
- export { type BaseOptions, type NonHeadlessToastState, type Options, type Position, type ToastBaseState, ToastContainer, type ToastDataCallback, type ToastDataWithCallback, type ToastState, type ToastType, toast, toastStore, useToasts };
110
+ export { type AddionalProps, type BaseOptions, type CapitalizedToastType, type NonHeadlessToastState, type Options, type Position, type ToastBaseState, ToastContainer, type ToastContainerProps, type ToastDataCallback, type ToastDataWithCallback, type ToastState, type ToastType, type ToasterProps, toast, toastStore, useToasts };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";var B=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var pt=Object.prototype.hasOwnProperty;var dt=(t,s)=>{for(var e in s)B(t,e,{get:s[e],enumerable:!0})},ut=(t,s,e,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let l of lt(s))!pt.call(t,l)&&l!==e&&B(t,l,{get:()=>s[l],enumerable:!(c=ct(s,l))||c.enumerable});return t};var mt=t=>ut(B({},"__esModule",{value:!0}),t);var yt={};dt(yt,{ToastContainer:()=>vt,toast:()=>a,toastStore:()=>h,useToasts:()=>Y});module.exports=mt(yt);var q=()=>{let t=0;return()=>`react-strawberry-toast_${t++}`};var k=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(e=>e())}getSnapShot(){return this.state}};var p="react-strawberry-toast";var m=require("react/jsx-runtime");function Tt(){return(0,m.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,m.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z"}),(0,m.jsx)("path",{className:"react-strawberry-toast-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:"#1dca82"})]})}function J({fill:t}){return(0,m.jsx)("svg",{stroke:"none",fill:t,strokeWidth:"2",viewBox:"0 0 24 24",height:"22",width:"22",xmlns:"http://www.w3.org/2000/svg",children:(0,m.jsx)("path",{className:"react-strawberry-toast-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 ft(){return(0,m.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,m.jsx)("path",{className:"react-strawberry-toast-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"})})}function K(){return(0,m.jsx)("svg",{fill:"#8b8b8b",strokeWidth:"0",viewBox:"0 0 512 512",height:"15px",width:"15px",xmlns:"http://www.w3.org/2000/svg",children:(0,m.jsx)("path",{className:"react-strawberry-toast-path",d:"M400 145.49 366.51 112 256 222.51 145.49 112 112 145.49 222.51 256 112 366.51 145.49 400 256 289.49 366.51 400 400 366.51 289.49 256 400 145.49z"})})}var T={success:(0,m.jsx)(Tt,{}),error:(0,m.jsx)(J,{fill:"#eb2639"}),loading:(0,m.jsx)("div",{className:`${p}__loading`}),warn:(0,m.jsx)(ft,{}),info:(0,m.jsx)(J,{fill:"#5365e7"})};var Q=t=>{let s=r=>{let o=t.toastTimers.get(r);clearTimeout(o),t.toastTimers.delete(r)},e=r=>{t.activatedToasts.add(r)},c=r=>t.activatedToasts.has(r),l=(r,o=200)=>{c(r)&&(t.activatedToasts.delete(r),setTimeout(()=>{t.state=t.state.filter(n=>n.toastId!==r),t.setState([...t.state])},o),s(r))},v=()=>{t.state.forEach(r=>{u(r.toastId,0)})},d=(r,o,n)=>{t.state=t.state.map(i=>i.toastId===r?{...i,...n,updated:new Date().getTime(),data:o}:i),t.setState([...t.state])},y=r=>{let o=new Date().getTime();t.state=t.state.map(n=>n.toastId===r?{...n,pausedAt:o}:n),s(r)},u=(r,o)=>{let n=setTimeout(()=>{var w;t.state=t.state.map(b=>b.toastId===r?{...b,isVisible:!1}:b),t.setState([...t.state]);let i=(w=t.state.find(b=>b.toastId===r))==null?void 0:w.removeTimeOut;l(r,i)},o>2147483647?2147483647:o);t.toastTimers.set(r,n)};return{setActive:e,isActive:c,disappear:u,resume:r=>{if(t.toastTimers.has(r))return;let o=t.state.find(i=>i.toastId===r);if(!o)return;let n=o.createdAt+(o.timeOut||3e3)-(o.pausedAt||0);u(r,n)},pause:y,replace:d,remove:l,allClear:v}};var h=new k,ht=q(),E=(t="default")=>(s,e={})=>{let{timeOut:c=3e3,removeTimeOut:l=200,pauseOnHover:v=!0,toastId:d,className:y,style:u,target:f,closeButton:r}=e,o=d||ht();if(a.isActive(o))throw new Error("A duplicate custom ID is not available.");let n=new Date().getTime(),i={updated:null,pausedAt:null,className:y||null,style:u||{},icon:e.icon||null,containerId:e.containerId||null,position:e.position||null,timeOut:c>2147483647?2147483647:c,toastId:o,data:s,createdAt:n,toastType:t,pauseOnHover:v,removeTimeOut:l,closeButton:r||!1,target:f||null,isVisible:!0};return h.state.push(i),h.setState([...h.state]),o},a=(t,s={})=>E()(t,s),A=Q(h);a.setActive=A.setActive;a.isActive=A.isActive;a.disappear=A.disappear;a.resume=A.resume;a.pause=A.pause;a.replace=A.replace;a.remove=A.remove;a.allClear=A.allClear;a.success=E("success");a.error=E("error");a.warn=E("warn");a.info=E("info");a.loading=E("loading");a.custom=E("custom");a.promise=(t,s,e={})=>{let{loading:c,success:l,error:v}=s,d=a.loading(c,{...e,timeOut:2147483647}),y={toastId:d,close:()=>a.disappear(d,0),immediatelyClose:()=>{a.disappear(d,0),a.remove(d,0)},icons:{success:T.success,error:T.error,warn:T.warn,loading:T.loading,info:T.info},isVisible:!0},u=e.timeOut||=3e3;t.then(f=>{a.replace(d,typeof l=="function"?l(f,y):l,{...e,timeOut:u>2147483647?2147483647:u,toastType:"success"})}).catch(f=>{a.replace(d,typeof v=="function"?v(f,y):v,{...e,timeOut:u>2147483647?2147483647:u,toastType:"error"})})};var _=require("react");var Z=require("react");function tt({condition:t,children:s}){let e=Z.Children.toArray(s);if(e.length>2)throw new Error("The number of children exceeds two.");return e.find(c=>t?c.key===".0":c.key===".1")}function et({children:t}){return t}function st({children:t}){return t}var ot=({isVisible:t,position:s})=>s?t?/top/i.test(s)?`${p}__fade-in`:`${p}__fade-in-reverse`:/bottom/i.test(s)?`${p}__fade-out-reverse`:`${p}__fade-out`:t?`${p}__fade-in`:`${p}__fade-out`;var P=require("react"),L=(t,s)=>{let e=(0,P.useRef)(s);(0,P.useEffect)(()=>{e.current=s},[s]),(0,P.useEffect)(()=>(window.addEventListener(t,e.current),()=>{window.removeEventListener(t,e.current)}),[t])};var g=require("react/jsx-runtime"),O=new Map;function U({toastProps:t}){let s=(0,_.useRef)(null),{toastId:e,isVisible:c,timeOut:l,containerId:v,className:d,style:y,icon:u,pauseOnActivate:f,updated:r,toastType:o,position:n,data:i,pauseOnHover:w,closeButton:b,samePositionLists:H,gap:x,order:C,target:N}=t,X=ot({isVisible:c,position:n}),F=typeof i=="function"?i({toastId:e,close:()=>a.disappear(e,0),immediatelyClose:()=>{a.disappear(e,0),a.remove(e,0)},icons:{success:T.success,error:T.error,warn:T.warn,loading:T.loading,info:T.info},isVisible:c}):i,rt=()=>{f&&a.resume(e)},nt=()=>{f&&a.pause(e)},G=()=>{N&&requestAnimationFrame(()=>{if(s.current){let M=N.element.getBoundingClientRect(),[D,W]=N.offset||[0,0];s.current.style.top=`${M.y+W+window.scrollY}px`,s.current.style.left=`${M.x+D+window.scrollX}px`}})};L("focus",rt),L("blur",nt),L("resize",G),(0,_.useEffect)(()=>{a.isActive(e)||(a.setActive(e),a.disappear(e,l)),G()},[e]),(0,_.useEffect)(()=>{if(s.current&&!N){let M=O.get(e)||s.current.getBoundingClientRect().height;O.set(e,M);let D=/left/.test(n)?50:/center/.test(n)?0:-50,W=/bottom/.test(n)?0:1,it=H.filter((z,$)=>$<=C-W).reduce((z,$)=>/bottom/.test(n)?z-=x+(O.get($.toastId)||0):z+=x+(O.get($.toastId)||0),0);s.current.style.transition="transform 0.2s cubic-bezier(0.43, 0.14, 0.2, 1.05)",s.current.style.transform=`translate(${D}%, ${it}px)`}return()=>{O.delete(e)}},[C]),(0,_.useEffect)(()=>{r!==null&&a.disappear(e,l)},[r]);let j=u||(o==="custom"||o==="default"?null:T[o]);return(0,g.jsx)("output",{role:"status",ref:s,className:`${p}__toast-content-container`,"data-testid":`container-${v||"default"}`,onMouseEnter:()=>{w&&a.pause(e)},onMouseLeave:()=>{w&&a.resume(e)},children:(0,g.jsxs)(tt,{condition:o!=="custom",children:[(0,g.jsx)(et,{children:(0,g.jsxs)("div",{className:d??`${p}__toast-content ${p}__toast-${o} ${a.isActive(e)?"":X}`,style:y,children:[j&&(0,g.jsx)("span",{className:`${p}__toast-icon`,children:j}),F,b&&(0,g.jsx)("button",{"data-testid":`${e}__close-button`,className:`${p}__close-button`,onClick:()=>{a.disappear(e,0)},type:"button",children:(0,g.jsx)(K,{})})]})}),(0,g.jsx)(st,{children:(0,g.jsx)("div",{className:d??`${a.isActive(e)?"":X}`,children:F})})]})})}var at=require("react");var Y=()=>(0,at.useSyncExternalStore)(h.subscribe.bind(h),h.getSnapShot.bind(h),h.getSnapShot.bind(h));var I=require("react/jsx-runtime");function vt({className:t,style:s,position:e="top-center",containerId:c="",gap:l=9,reverse:v=!1,pauseOnActivate:d=!0}){let y=Y(),u=o=>{var n;return(n=o.target)==null?void 0:n.element},f=o=>c?o.containerId===c:!o.containerId,r=y.filter(o=>!u(o)).reduce((o,n)=>{let i=n.position||e;return n.position=i,o[i]=o[i]||[],o[i].push(n),o},{});return(0,I.jsxs)("div",{id:`${p}__root`,"data-container-id":c,children:[y.filter(u).filter(f).map((o,n,i)=>{let w=Object.assign(o,{gap:l,order:n,samePositionLists:i,pauseOnActivate:d});return(0,I.jsx)(U,{toastProps:w},o.toastId)}),Object.entries(r).map(([o,n])=>{let i=n.filter(f),w=v?i.reverse():i;return(0,I.jsx)("div",{"data-testid":o,className:`${p}__z9999 ${t??`${p}__toast-container ${p}__${o}`}`,style:s,children:w.map((b,H,x)=>{let C=Object.assign(b,{gap:l,order:H,samePositionLists:x,pauseOnActivate:d});return(0,I.jsx)(U,{toastProps:C},b.toastId)})},o)})]})}
2
+ "use strict";var q=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var Et=Object.prototype.hasOwnProperty;var bt=(t,s)=>{for(var e in s)q(t,e,{get:s[e],enumerable:!0})},wt=(t,s,e,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let l of St(s))!Et.call(t,l)&&l!==e&&q(t,l,{get:()=>s[l],enumerable:!(c=gt(s,l))||c.enumerable});return t};var It=t=>wt(q({},"__esModule",{value:!0}),t);var Ot={};bt(Ot,{ToastContainer:()=>Ct,toast:()=>o,toastStore:()=>S,useToasts:()=>Q});module.exports=It(Ot);var rt=()=>{let t=0;return()=>`react-strawberry-toast_${t++}`};var U=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(e=>e())}getSnapShot(){return this.state}};var p="react-strawberry-toast";var T=require("react/jsx-runtime");function At(){return(0,T.jsx)("svg",{stroke:"none",fill:"none",strokeWidth:"0",viewBox:"2 2 20 20",strokeLinecap:"round",strokeLinejoin:"round",height:"18",width:"18",xmlns:"http://www.w3.org/2000/svg",children:(0,T.jsx)("path",{className:"react-strawberry-toast-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:"var(--toast-color-success)"})})}function nt({fill:t}){return(0,T.jsx)("svg",{stroke:"none",fill:t,strokeWidth:"2",viewBox:"2 2 20 20",height:"18",width:"18",xmlns:"http://www.w3.org/2000/svg",children:(0,T.jsx)("path",{className:"react-strawberry-toast-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 _t(){return(0,T.jsx)("svg",{stroke:"none",fill:"#fcba03",strokeWidth:"0",viewBox:"56 120 912 800",height:"18",width:"18",xmlns:"http://www.w3.org/2000/svg",children:(0,T.jsx)("path",{className:"react-strawberry-toast-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"})})}function W(){return(0,T.jsx)("svg",{fill:"var(--toast-close-button)",strokeWidth:"0",viewBox:"112 112 288 288",height:"8",width:"8",xmlns:"http://www.w3.org/2000/svg",children:(0,T.jsx)("path",{className:"react-strawberry-toast-path",d:"M400 145.49 366.51 112 256 222.51 145.49 112 112 145.49 222.51 256 112 366.51 145.49 400 256 289.49 366.51 400 400 366.51 289.49 256 400 145.49z"})})}var v={success:(0,T.jsx)(At,{}),error:(0,T.jsx)(nt,{fill:"var(--toast-color-error)"}),loading:(0,T.jsx)("div",{className:`${p}__loading`}),warn:(0,T.jsx)(_t,{}),info:(0,T.jsx)(nt,{fill:"var(--toast-color-info)"})};var it=t=>{let s=r=>{let n=t.toastTimers.get(r);clearTimeout(n),t.toastTimers.delete(r)},e=r=>{t.activatedToasts.add(r)},c=r=>t.activatedToasts.has(r),l=(r,n=200)=>{c(r)&&(t.activatedToasts.delete(r),setTimeout(()=>{t.state=t.state.filter(a=>a.toastId!==r),t.setState([...t.state])},n),s(r))},b=()=>{t.state.forEach(r=>{u(r.toastId,0)})},d=(r,n,a)=>{t.state=t.state.map(i=>i.toastId===r?{...i,...a,updated:new Date().getTime(),data:n}:i),t.setState([...t.state])},y=r=>{let n=new Date().getTime();t.state=t.state.map(a=>a.toastId===r?{...a,pausedAt:n}:a),s(r)},u=(r,n)=>{let a=window.setTimeout(()=>{var m;t.state=t.state.map(w=>w.toastId===r?{...w,isVisible:!1}:w),t.setState([...t.state]);let i=(m=t.state.find(w=>w.toastId===r))==null?void 0:m.removeTimeOut;l(r,i)},n>2147483647?2147483647:n);t.toastTimers.set(r,a)};return{setActive:e,isActive:c,disappear:u,resume:r=>{if(t.toastTimers.has(r))return;let n=t.state.find(i=>i.toastId===r);if(!n)return;let a=n.createdAt+(n.timeOut||3e3)-(n.pausedAt||0);u(r,a)},pause:y,replace:d,remove:l,allClear:b}};var S=new U,xt=rt(),C=(t="default")=>(s,e={})=>{let{timeOut:c=3e3,removeTimeOut:l=200,pauseOnHover:b=!0,toastId:d,className:y,style:u,target:h,closeButton:r}=e,n=d||xt();if(o.isActive(n))throw new Error("A duplicate custom ID is not available.");let a=new Date().getTime(),i={updated:null,pausedAt:null,className:y||null,style:u||{},icon:e.icon||null,containerId:e.containerId||null,position:e.position||null,timeOut:c>2147483647?2147483647:c,toastId:n,data:s,createdAt:a,toastType:t,pauseOnHover:b,removeTimeOut:l,closeButton:r||!1,target:h||null,isVisible:!0};return S.state.push(i),S.setState([...S.state]),n},o=(t,s={})=>C()(t,s),_=it(S);o.setActive=_.setActive;o.isActive=_.isActive;o.disappear=_.disappear;o.resume=_.resume;o.pause=_.pause;o.replace=_.replace;o.remove=_.remove;o.allClear=_.allClear;o.success=C("success");o.error=C("error");o.warn=C("warn");o.info=C("info");o.loading=C("loading");o.custom=C("custom");o.promise=(t,s,e={})=>{let{loading:c,success:l,error:b}=s,d=o.loading(c,{...e,timeOut:2147483647}),y={toastId:d,close:()=>o.disappear(d,0),immediatelyClose:()=>{o.disappear(d,0),o.remove(d,0)},Icons:{Success:()=>v.success,Error:()=>v.error,Warn:()=>v.warn,Loading:()=>v.loading,Info:()=>v.info,Close:W},isVisible:!0},u=e.timeOut||=3e3;t.then(h=>{o.replace(d,typeof l=="function"?l(h,y):l,{...e,timeOut:u>2147483647?2147483647:u,toastType:"success"})}).catch(h=>{o.replace(d,typeof b=="function"?b(h,y):b,{...e,timeOut:u>2147483647?2147483647:u,toastType:"error"})})};var A=require("react");var ct=require("react");function lt({condition:t,children:s}){let e=ct.Children.toArray(s);if(e.length>2)throw new Error("The number of children exceeds two.");return e.find(c=>t?c.key===".0":c.key===".1")}function pt({children:t}){return t}function dt({children:t}){return t}var ut=({isVisible:t,position:s})=>s?t?/top/i.test(s)?`${p}__fade-in`:`${p}__fade-in-reverse`:/bottom/i.test(s)?`${p}__fade-out-reverse`:`${p}__fade-out`:t?`${p}__fade-in`:`${p}__fade-out`;var D=require("react"),X=(t,s)=>{let e=(0,D.useRef)(s);(0,D.useEffect)(()=>{e.current=s},[s]),(0,D.useEffect)(()=>(window.addEventListener(t,e.current),()=>{window.removeEventListener(t,e.current)}),[t])};var E=require("react/jsx-runtime"),z=new Map;function K({toastProps:t}){let s=(0,A.useRef)(null),{toastId:e,isVisible:c,timeOut:l,containerId:b,className:d,style:y,icon:u,pauseOnActivate:h,updated:r,toastType:n,position:a,data:i,pauseOnHover:m,closeButton:w,toastsBySamePosition:O,gap:P,order:x,target:N,stack:B}=t,Z=ut({isVisible:c,position:a}),$=typeof i=="function"?i({toastId:e,close:()=>o.disappear(e,0),immediatelyClose:()=>{o.disappear(e,0),o.remove(e,0)},Icons:{Success:()=>v.success,Error:()=>v.error,Warn:()=>v.warn,Loading:()=>v.loading,Info:()=>v.info,Close:W},isVisible:c}):i,ft=()=>{h&&o.resume(e)},Tt=()=>{h&&o.pause(e)},tt=()=>{N&&requestAnimationFrame(()=>{if(s.current){let f=N.element.getBoundingClientRect(),[k,R]=N.offset||[0,0];s.current.style.top=`${f.y+R+window.scrollY}px`,s.current.style.left=`${f.x+k+window.scrollX}px`}})};X("focus",ft),X("blur",Tt),X("resize",tt),(0,A.useEffect)(()=>{o.isActive(e)||(o.setActive(e),o.disappear(e,l)),tt()},[e]),(0,A.useEffect)(()=>{if(!s.current||N)return;let f=s.current,k=z.get(e)||f.getBoundingClientRect().height;z.set(e,k);let R=/left/.test(a)?50:/center/.test(a)?0:-50,V=/bottom/.test(a),st=()=>{let L=V?-(P+k):0,H=O.slice(0,x).reduce((F,G)=>F+P+(z.get(G.toastId)||0),0);return L+(V?-H:H)};if(B){let L=O.length,H=L-1-x,F=O[L-1],G=z.get(F.toastId)||k,yt=1-H*.05,ot=H*10,vt=V?-(G+P):0,ht=V?-ot:ot,j=()=>{f.style.transition="transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease",f.style.transform=`translate(${R}%, ${vt+ht}px) scale(${yt})`,f.style.zIndex=String(x+1),L-3>x&&(f.style.opacity="0")},at=()=>{f.style.transition="transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease",f.style.transform=`translate(${R}%, ${st()}px) scale(1)`,f.style.opacity="1"};j();let g=f.parentElement;return g==null||g.addEventListener("mouseenter",at),g==null||g.addEventListener("mouseleave",j),()=>{g==null||g.removeEventListener("mouseenter",at),g==null||g.removeEventListener("mouseleave",j)}}return f.style.transition="transform 0.2s cubic-bezier(0.43, 0.14, 0.2, 1.05)",f.style.transform=`translate(${R}%, ${st()}px)`,()=>{z.delete(e)}},[x,B,O.length]),(0,A.useEffect)(()=>{r!==null&&o.disappear(e,l)},[r]);let et=u||(n==="custom"||n==="default"?null:v[n]);return(0,E.jsx)("output",{role:"status",ref:s,className:`${p}__toast-content-container`,"aria-live":n==="error"?"assertive":"polite",tabIndex:0,onMouseEnter:()=>{m&&o.pause(e)},onMouseLeave:()=>{m&&o.resume(e)},children:(0,E.jsxs)(lt,{condition:n!=="custom",children:[(0,E.jsx)(pt,{children:(0,E.jsxs)("div",{className:`${p}__toast-content ${p}__toast-${n} ${o.isActive(e)?"":Z} ${d}`,style:y,children:[et&&(0,E.jsx)(E.Fragment,{children:et}),$,w&&(0,E.jsx)("button",{"aria-label":"Close Toast Button",className:`${p}__close-button`,onClick:()=>{o.disappear(e,0)},type:"button",children:(0,E.jsx)(W,{})})]})}),(0,E.jsx)(dt,{children:(0,A.isValidElement)($)?(0,A.cloneElement)($,{style:{...$.props.style,...y},className:`${$.props.className||""} ${o.isActive(e)?"":Z} ${d}`.trim()}):$})]})})}var mt=require("react");var Q=()=>(0,mt.useSyncExternalStore)(S.subscribe.bind(S),S.getSnapShot.bind(S),S.getSnapShot.bind(S));var M=require("react/jsx-runtime");function Ct({className:t,style:s,position:e="top-center",containerId:c="",gap:l=9,reverse:b=!1,pauseOnActivate:d=!0,stack:y=!1}){let u=Q(),h=a=>{var i;return(i=a.target)==null?void 0:i.element},r=a=>c?a.containerId===c:!a.containerId,n=u.filter(a=>!h(a)).reduce((a,i)=>{let m=i.position||e;return i.position=m,a[m]=a[m]||[],a[m].push(i),a},{});return(0,M.jsxs)("div",{id:`${p}__root`,"data-container-id":c,children:[u.filter(h).filter(r).map((a,i,m)=>{let w=Object.assign(a,{gap:l,order:i,toastsBySamePosition:m,pauseOnActivate:d,stack:y});return(0,M.jsx)(K,{toastProps:w},a.toastId)}),Object.entries(n).map(([a,i])=>{let m=i.filter(r),w=b&&!y?m.reverse():m,O=`${p}__toast-container ${p}__${a} ${t}`;return(0,M.jsx)("div",{className:O,style:s,children:w.map((P,x,N)=>{let B=Object.assign(P,{gap:l,order:x,toastsBySamePosition:N,pauseOnActivate:d,stack:y});return(0,M.jsx)(K,{toastProps:B},P.toastId)})},a)})]})}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var F=()=>{let t=0;return()=>`react-strawberry-toast_${t++}`};var N=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(s=>s())}getSnapShot(){return this.state}};var c="react-strawberry-toast";import{jsx as m,jsxs as ct}from"react/jsx-runtime";function nt(){return ct("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:[m("path",{stroke:"none",d:"M0 0h24v24H0z"}),m("path",{className:"react-strawberry-toast-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:"#1dca82"})]})}function G({fill:t}){return m("svg",{stroke:"none",fill:t,strokeWidth:"2",viewBox:"0 0 24 24",height:"22",width:"22",xmlns:"http://www.w3.org/2000/svg",children:m("path",{className:"react-strawberry-toast-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 m("svg",{stroke:"none",fill:"#fcba03",strokeWidth:"0",viewBox:"0 0 1024 1024",height:"22",width:"22",xmlns:"http://www.w3.org/2000/svg",children:m("path",{className:"react-strawberry-toast-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"})})}function j(){return m("svg",{fill:"#8b8b8b",strokeWidth:"0",viewBox:"0 0 512 512",height:"15px",width:"15px",xmlns:"http://www.w3.org/2000/svg",children:m("path",{className:"react-strawberry-toast-path",d:"M400 145.49 366.51 112 256 222.51 145.49 112 112 145.49 222.51 256 112 366.51 145.49 400 256 289.49 366.51 400 400 366.51 289.49 256 400 145.49z"})})}var T={success:m(nt,{}),error:m(G,{fill:"#eb2639"}),loading:m("div",{className:`${c}__loading`}),warn:m(it,{}),info:m(G,{fill:"#5365e7"})};var q=t=>{let a=r=>{let e=t.toastTimers.get(r);clearTimeout(e),t.toastTimers.delete(r)},s=r=>{t.activatedToasts.add(r)},l=r=>t.activatedToasts.has(r),u=(r,e=200)=>{l(r)&&(t.activatedToasts.delete(r),setTimeout(()=>{t.state=t.state.filter(n=>n.toastId!==r),t.setState([...t.state])},e),a(r))},h=()=>{t.state.forEach(r=>{d(r.toastId,0)})},p=(r,e,n)=>{t.state=t.state.map(i=>i.toastId===r?{...i,...n,updated:new Date().getTime(),data:e}:i),t.setState([...t.state])},v=r=>{let e=new Date().getTime();t.state=t.state.map(n=>n.toastId===r?{...n,pausedAt:e}:n),a(r)},d=(r,e)=>{let n=setTimeout(()=>{var S;t.state=t.state.map(g=>g.toastId===r?{...g,isVisible:!1}:g),t.setState([...t.state]);let i=(S=t.state.find(g=>g.toastId===r))==null?void 0:S.removeTimeOut;u(r,i)},e>2147483647?2147483647:e);t.toastTimers.set(r,n)};return{setActive:s,isActive:l,disappear:d,resume:r=>{if(t.toastTimers.has(r))return;let e=t.state.find(i=>i.toastId===r);if(!e)return;let n=e.createdAt+(e.timeOut||3e3)-(e.pausedAt||0);d(r,n)},pause:v,replace:p,remove:u,allClear:h}};var y=new N,lt=F(),A=(t="default")=>(a,s={})=>{let{timeOut:l=3e3,removeTimeOut:u=200,pauseOnHover:h=!0,toastId:p,className:v,style:d,target:f,closeButton:r}=s,e=p||lt();if(o.isActive(e))throw new Error("A duplicate custom ID is not available.");let n=new Date().getTime(),i={updated:null,pausedAt:null,className:v||null,style:d||{},icon:s.icon||null,containerId:s.containerId||null,position:s.position||null,timeOut:l>2147483647?2147483647:l,toastId:e,data:a,createdAt:n,toastType:t,pauseOnHover:h,removeTimeOut:u,closeButton:r||!1,target:f||null,isVisible:!0};return y.state.push(i),y.setState([...y.state]),e},o=(t,a={})=>A()(t,a),w=q(y);o.setActive=w.setActive;o.isActive=w.isActive;o.disappear=w.disappear;o.resume=w.resume;o.pause=w.pause;o.replace=w.replace;o.remove=w.remove;o.allClear=w.allClear;o.success=A("success");o.error=A("error");o.warn=A("warn");o.info=A("info");o.loading=A("loading");o.custom=A("custom");o.promise=(t,a,s={})=>{let{loading:l,success:u,error:h}=a,p=o.loading(l,{...s,timeOut:2147483647}),v={toastId:p,close:()=>o.disappear(p,0),immediatelyClose:()=>{o.disappear(p,0),o.remove(p,0)},icons:{success:T.success,error:T.error,warn:T.warn,loading:T.loading,info:T.info},isVisible:!0},d=s.timeOut||=3e3;t.then(f=>{o.replace(p,typeof u=="function"?u(f,v):u,{...s,timeOut:d>2147483647?2147483647:d,toastType:"success"})}).catch(f=>{o.replace(p,typeof h=="function"?h(f,v):h,{...s,timeOut:d>2147483647?2147483647:d,toastType:"error"})})};import{useEffect as W,useRef as ut}from"react";import{Children as pt}from"react";function J({condition:t,children:a}){let s=pt.toArray(a);if(s.length>2)throw new Error("The number of children exceeds two.");return s.find(l=>t?l.key===".0":l.key===".1")}function K({children:t}){return t}function Q({children:t}){return t}var Z=({isVisible:t,position:a})=>a?t?/top/i.test(a)?`${c}__fade-in`:`${c}__fade-in-reverse`:/bottom/i.test(a)?`${c}__fade-out-reverse`:`${c}__fade-out`:t?`${c}__fade-in`:`${c}__fade-out`;import{useEffect as tt,useRef as dt}from"react";var $=(t,a)=>{let s=dt(a);tt(()=>{s.current=a},[a]),tt(()=>(window.addEventListener(t,s.current),()=>{window.removeEventListener(t,s.current)}),[t])};import{jsx as E,jsxs as et}from"react/jsx-runtime";var _=new Map;function z({toastProps:t}){let a=ut(null),{toastId:s,isVisible:l,timeOut:u,containerId:h,className:p,style:v,icon:d,pauseOnActivate:f,updated:r,toastType:e,position:n,data:i,pauseOnHover:S,closeButton:g,samePositionLists:k,gap:I,order:P,target:O}=t,V=Z({isVisible:l,position:n}),U=typeof i=="function"?i({toastId:s,close:()=>o.disappear(s,0),immediatelyClose:()=>{o.disappear(s,0),o.remove(s,0)},icons:{success:T.success,error:T.error,warn:T.warn,loading:T.loading,info:T.info},isVisible:l}):i,ot=()=>{f&&o.resume(s)},at=()=>{f&&o.pause(s)},Y=()=>{O&&requestAnimationFrame(()=>{if(a.current){let x=O.element.getBoundingClientRect(),[R,L]=O.offset||[0,0];a.current.style.top=`${x.y+L+window.scrollY}px`,a.current.style.left=`${x.x+R+window.scrollX}px`}})};$("focus",ot),$("blur",at),$("resize",Y),W(()=>{o.isActive(s)||(o.setActive(s),o.disappear(s,u)),Y()},[s]),W(()=>{if(a.current&&!O){let x=_.get(s)||a.current.getBoundingClientRect().height;_.set(s,x);let R=/left/.test(n)?50:/center/.test(n)?0:-50,L=/bottom/.test(n)?0:1,rt=k.filter((H,C)=>C<=P-L).reduce((H,C)=>/bottom/.test(n)?H-=I+(_.get(C.toastId)||0):H+=I+(_.get(C.toastId)||0),0);a.current.style.transition="transform 0.2s cubic-bezier(0.43, 0.14, 0.2, 1.05)",a.current.style.transform=`translate(${R}%, ${rt}px)`}return()=>{_.delete(s)}},[P]),W(()=>{r!==null&&o.disappear(s,u)},[r]);let X=d||(e==="custom"||e==="default"?null:T[e]);return E("output",{role:"status",ref:a,className:`${c}__toast-content-container`,"data-testid":`container-${h||"default"}`,onMouseEnter:()=>{S&&o.pause(s)},onMouseLeave:()=>{S&&o.resume(s)},children:et(J,{condition:e!=="custom",children:[E(K,{children:et("div",{className:p??`${c}__toast-content ${c}__toast-${e} ${o.isActive(s)?"":V}`,style:v,children:[X&&E("span",{className:`${c}__toast-icon`,children:X}),U,g&&E("button",{"data-testid":`${s}__close-button`,className:`${c}__close-button`,onClick:()=>{o.disappear(s,0)},type:"button",children:E(j,{})})]})}),E(Q,{children:E("div",{className:p??`${o.isActive(s)?"":V}`,children:U})})]})})}import{useSyncExternalStore as mt}from"react";var st=()=>mt(y.subscribe.bind(y),y.getSnapShot.bind(y),y.getSnapShot.bind(y));import{jsx as B,jsxs as Tt}from"react/jsx-runtime";function Jt({className:t,style:a,position:s="top-center",containerId:l="",gap:u=9,reverse:h=!1,pauseOnActivate:p=!0}){let v=st(),d=e=>{var n;return(n=e.target)==null?void 0:n.element},f=e=>l?e.containerId===l:!e.containerId,r=v.filter(e=>!d(e)).reduce((e,n)=>{let i=n.position||s;return n.position=i,e[i]=e[i]||[],e[i].push(n),e},{});return Tt("div",{id:`${c}__root`,"data-container-id":l,children:[v.filter(d).filter(f).map((e,n,i)=>{let S=Object.assign(e,{gap:u,order:n,samePositionLists:i,pauseOnActivate:p});return B(z,{toastProps:S},e.toastId)}),Object.entries(r).map(([e,n])=>{let i=n.filter(f),S=h?i.reverse():i;return B("div",{"data-testid":e,className:`${c}__z9999 ${t??`${c}__toast-container ${c}__${e}`}`,style:a,children:S.map((g,k,I)=>{let P=Object.assign(g,{gap:u,order:k,samePositionLists:I,pauseOnActivate:p});return B(z,{toastProps:P},g.toastId)})},e)})]})}export{Jt as ToastContainer,o as toast,y as toastStore,st as useToasts};
2
+ var st=()=>{let t=0;return()=>`react-strawberry-toast_${t++}`};var z=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(e=>e())}getSnapShot(){return this.state}};var c="react-strawberry-toast";import{jsx as y}from"react/jsx-runtime";function vt(){return y("svg",{stroke:"none",fill:"none",strokeWidth:"0",viewBox:"2 2 20 20",strokeLinecap:"round",strokeLinejoin:"round",height:"18",width:"18",xmlns:"http://www.w3.org/2000/svg",children:y("path",{className:"react-strawberry-toast-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:"var(--toast-color-success)"})})}function ot({fill:t}){return y("svg",{stroke:"none",fill:t,strokeWidth:"2",viewBox:"2 2 20 20",height:"18",width:"18",xmlns:"http://www.w3.org/2000/svg",children:y("path",{className:"react-strawberry-toast-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 ht(){return y("svg",{stroke:"none",fill:"#fcba03",strokeWidth:"0",viewBox:"56 120 912 800",height:"18",width:"18",xmlns:"http://www.w3.org/2000/svg",children:y("path",{className:"react-strawberry-toast-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"})})}function L(){return y("svg",{fill:"var(--toast-close-button)",strokeWidth:"0",viewBox:"112 112 288 288",height:"8",width:"8",xmlns:"http://www.w3.org/2000/svg",children:y("path",{className:"react-strawberry-toast-path",d:"M400 145.49 366.51 112 256 222.51 145.49 112 112 145.49 222.51 256 112 366.51 145.49 400 256 289.49 366.51 400 400 366.51 289.49 256 400 145.49z"})})}var v={success:y(vt,{}),error:y(ot,{fill:"var(--toast-color-error)"}),loading:y("div",{className:`${c}__loading`}),warn:y(ht,{}),info:y(ot,{fill:"var(--toast-color-info)"})};var at=t=>{let r=a=>{let n=t.toastTimers.get(a);clearTimeout(n),t.toastTimers.delete(a)},e=a=>{t.activatedToasts.add(a)},l=a=>t.activatedToasts.has(a),m=(a,n=200)=>{l(a)&&(t.activatedToasts.delete(a),setTimeout(()=>{t.state=t.state.filter(s=>s.toastId!==a),t.setState([...t.state])},n),r(a))},S=()=>{t.state.forEach(a=>{d(a.toastId,0)})},p=(a,n,s)=>{t.state=t.state.map(i=>i.toastId===a?{...i,...s,updated:new Date().getTime(),data:n}:i),t.setState([...t.state])},T=a=>{let n=new Date().getTime();t.state=t.state.map(s=>s.toastId===a?{...s,pausedAt:n}:s),r(a)},d=(a,n)=>{let s=window.setTimeout(()=>{var u;t.state=t.state.map(E=>E.toastId===a?{...E,isVisible:!1}:E),t.setState([...t.state]);let i=(u=t.state.find(E=>E.toastId===a))==null?void 0:u.removeTimeOut;m(a,i)},n>2147483647?2147483647:n);t.toastTimers.set(a,s)};return{setActive:e,isActive:l,disappear:d,resume:a=>{if(t.toastTimers.has(a))return;let n=t.state.find(i=>i.toastId===a);if(!n)return;let s=n.createdAt+(n.timeOut||3e3)-(n.pausedAt||0);d(a,s)},pause:T,replace:p,remove:m,allClear:S}};var b=new z,gt=st(),_=(t="default")=>(r,e={})=>{let{timeOut:l=3e3,removeTimeOut:m=200,pauseOnHover:S=!0,toastId:p,className:T,style:d,target:h,closeButton:a}=e,n=p||gt();if(o.isActive(n))throw new Error("A duplicate custom ID is not available.");let s=new Date().getTime(),i={updated:null,pausedAt:null,className:T||null,style:d||{},icon:e.icon||null,containerId:e.containerId||null,position:e.position||null,timeOut:l>2147483647?2147483647:l,toastId:n,data:r,createdAt:s,toastType:t,pauseOnHover:S,removeTimeOut:m,closeButton:a||!1,target:h||null,isVisible:!0};return b.state.push(i),b.setState([...b.state]),n},o=(t,r={})=>_()(t,r),I=at(b);o.setActive=I.setActive;o.isActive=I.isActive;o.disappear=I.disappear;o.resume=I.resume;o.pause=I.pause;o.replace=I.replace;o.remove=I.remove;o.allClear=I.allClear;o.success=_("success");o.error=_("error");o.warn=_("warn");o.info=_("info");o.loading=_("loading");o.custom=_("custom");o.promise=(t,r,e={})=>{let{loading:l,success:m,error:S}=r,p=o.loading(l,{...e,timeOut:2147483647}),T={toastId:p,close:()=>o.disappear(p,0),immediatelyClose:()=>{o.disappear(p,0),o.remove(p,0)},Icons:{Success:()=>v.success,Error:()=>v.error,Warn:()=>v.warn,Loading:()=>v.loading,Info:()=>v.info,Close:L},isVisible:!0},d=e.timeOut||=3e3;t.then(h=>{o.replace(p,typeof m=="function"?m(h,T):m,{...e,timeOut:d>2147483647?2147483647:d,toastType:"success"})}).catch(h=>{o.replace(p,typeof S=="function"?S(h,T):S,{...e,timeOut:d>2147483647?2147483647:d,toastType:"error"})})};import{useEffect as G,useRef as bt,cloneElement as wt,isValidElement as It}from"react";import{Children as St}from"react";function rt({condition:t,children:r}){let e=St.toArray(r);if(e.length>2)throw new Error("The number of children exceeds two.");return e.find(l=>t?l.key===".0":l.key===".1")}function nt({children:t}){return t}function it({children:t}){return t}var ct=({isVisible:t,position:r})=>r?t?/top/i.test(r)?`${c}__fade-in`:`${c}__fade-in-reverse`:/bottom/i.test(r)?`${c}__fade-out-reverse`:`${c}__fade-out`:t?`${c}__fade-in`:`${c}__fade-out`;import{useEffect as lt,useRef as Et}from"react";var V=(t,r)=>{let e=Et(r);lt(()=>{e.current=r},[r]),lt(()=>(window.addEventListener(t,e.current),()=>{window.removeEventListener(t,e.current)}),[t])};import{Fragment as At,jsx as N,jsxs as pt}from"react/jsx-runtime";var H=new Map;function j({toastProps:t}){let r=bt(null),{toastId:e,isVisible:l,timeOut:m,containerId:S,className:p,style:T,icon:d,pauseOnActivate:h,updated:a,toastType:n,position:s,data:i,pauseOnHover:u,closeButton:E,toastsBySamePosition:x,gap:C,order:A,target:O,stack:W}=t,J=ct({isVisible:l,position:s}),P=typeof i=="function"?i({toastId:e,close:()=>o.disappear(e,0),immediatelyClose:()=>{o.disappear(e,0),o.remove(e,0)},Icons:{Success:()=>v.success,Error:()=>v.error,Warn:()=>v.warn,Loading:()=>v.loading,Info:()=>v.info,Close:L},isVisible:l}):i,ut=()=>{h&&o.resume(e)},mt=()=>{h&&o.pause(e)},K=()=>{O&&requestAnimationFrame(()=>{if(r.current){let f=O.element.getBoundingClientRect(),[$,M]=O.offset||[0,0];r.current.style.top=`${f.y+M+window.scrollY}px`,r.current.style.left=`${f.x+$+window.scrollX}px`}})};V("focus",ut),V("blur",mt),V("resize",K),G(()=>{o.isActive(e)||(o.setActive(e),o.disappear(e,m)),K()},[e]),G(()=>{if(!r.current||O)return;let f=r.current,$=H.get(e)||f.getBoundingClientRect().height;H.set(e,$);let M=/left/.test(s)?50:/center/.test(s)?0:-50,D=/bottom/.test(s),Z=()=>{let k=D?-(C+$):0,R=x.slice(0,A).reduce((U,Y)=>U+C+(H.get(Y.toastId)||0),0);return k+(D?-R:R)};if(W){let k=x.length,R=k-1-A,U=x[k-1],Y=H.get(U.toastId)||$,ft=1-R*.05,tt=R*10,Tt=D?-(Y+C):0,yt=D?-tt:tt,X=()=>{f.style.transition="transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease",f.style.transform=`translate(${M}%, ${Tt+yt}px) scale(${ft})`,f.style.zIndex=String(A+1),k-3>A&&(f.style.opacity="0")},et=()=>{f.style.transition="transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease",f.style.transform=`translate(${M}%, ${Z()}px) scale(1)`,f.style.opacity="1"};X();let g=f.parentElement;return g==null||g.addEventListener("mouseenter",et),g==null||g.addEventListener("mouseleave",X),()=>{g==null||g.removeEventListener("mouseenter",et),g==null||g.removeEventListener("mouseleave",X)}}return f.style.transition="transform 0.2s cubic-bezier(0.43, 0.14, 0.2, 1.05)",f.style.transform=`translate(${M}%, ${Z()}px)`,()=>{H.delete(e)}},[A,W,x.length]),G(()=>{a!==null&&o.disappear(e,m)},[a]);let Q=d||(n==="custom"||n==="default"?null:v[n]);return N("output",{role:"status",ref:r,className:`${c}__toast-content-container`,"aria-live":n==="error"?"assertive":"polite",tabIndex:0,onMouseEnter:()=>{u&&o.pause(e)},onMouseLeave:()=>{u&&o.resume(e)},children:pt(rt,{condition:n!=="custom",children:[N(nt,{children:pt("div",{className:`${c}__toast-content ${c}__toast-${n} ${o.isActive(e)?"":J} ${p}`,style:T,children:[Q&&N(At,{children:Q}),P,E&&N("button",{"aria-label":"Close Toast Button",className:`${c}__close-button`,onClick:()=>{o.disappear(e,0)},type:"button",children:N(L,{})})]})}),N(it,{children:It(P)?wt(P,{style:{...P.props.style,...T},className:`${P.props.className||""} ${o.isActive(e)?"":J} ${p}`.trim()}):P})]})})}import{useSyncExternalStore as _t}from"react";var dt=()=>_t(b.subscribe.bind(b),b.getSnapShot.bind(b),b.getSnapShot.bind(b));import{jsx as q,jsxs as xt}from"react/jsx-runtime";function le({className:t,style:r,position:e="top-center",containerId:l="",gap:m=9,reverse:S=!1,pauseOnActivate:p=!0,stack:T=!1}){let d=dt(),h=s=>{var i;return(i=s.target)==null?void 0:i.element},a=s=>l?s.containerId===l:!s.containerId,n=d.filter(s=>!h(s)).reduce((s,i)=>{let u=i.position||e;return i.position=u,s[u]=s[u]||[],s[u].push(i),s},{});return xt("div",{id:`${c}__root`,"data-container-id":l,children:[d.filter(h).filter(a).map((s,i,u)=>{let E=Object.assign(s,{gap:m,order:i,toastsBySamePosition:u,pauseOnActivate:p,stack:T});return q(j,{toastProps:E},s.toastId)}),Object.entries(n).map(([s,i])=>{let u=i.filter(a),E=S&&!T?u.reverse():u,x=`${c}__toast-container ${c}__${s} ${t}`;return q("div",{className:x,style:r,children:E.map((C,A,O)=>{let W=Object.assign(C,{gap:m,order:A,toastsBySamePosition:O,pauseOnActivate:p,stack:T});return q(j,{toastProps:W},C.toastId)})},s)})]})}export{le as ToastContainer,o as toast,b as toastStore,dt 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%) scale(.2);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(.2);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{width:100%;position:fixed;z-index:9999;display:flex;align-items:center;flex-direction:column}.react-strawberry-toast__top-left{top:16px;left:calc(-50% + 16px)}.react-strawberry-toast__top-center{top:16px;left:50%;transform:translate(-50%)}.react-strawberry-toast__top-right{top:16px;right:calc(-50% + 16px)}.react-strawberry-toast__bottom-left{bottom:8px;left:calc(-50% + 16px)}.react-strawberry-toast__bottom-center{bottom:8px;left:50%;transform:translate(-50%)}.react-strawberry-toast__bottom-right{bottom:8px;right:calc(-50% + 16px)}.react-strawberry-toast__toast-content-container{position:absolute;pointer-events:none}.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}.react-strawberry-toast__toast-content{pointer-events:auto;box-sizing:border-box;background-color:#fff;padding:10px;display:flex;align-items:center;gap:5px;border-radius:8px;box-shadow:2px 2px 6px 2px #0000001a;min-height:47px;max-width:368px}.react-strawberry-toast__close-button{background:transparent;border:none;outline:none;width:15px;height:15px;cursor:pointer}
1
+ @keyframes l3{to{transform:rotate(1turn)}}@keyframes react-strawberry-toast_fade-in{0%{transform:translateY(-100%) scale(.2);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(.2);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__toast-container{--toast-color-success: #1dca82;--toast-color-error: #eb2639;--toast-color-warn: #fcba03;--toast-color-info: #5365e7;--toast-close-button: #8b8b8b;width:100%;position:fixed;z-index:9999;display:flex;align-items:center;flex-direction:column;pointer-events:none}.react-strawberry-toast__top-left{top:var(--toast-offset, 16px);left:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__top-center{top:var(--toast-offset, 16px);left:50%;transform:translate(-50%)}.react-strawberry-toast__top-right{top:var(--toast-offset, 16px);right:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__bottom-left{bottom:calc(var(--toast-offset, 16px) - 8px);left:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__bottom-center{bottom:calc(var(--toast-offset, 16px) - 8px);left:50%;transform:translate(-50%)}.react-strawberry-toast__bottom-right{bottom:calc(var(--toast-offset, 16px) - 8px);right:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__toast-content-container{position:absolute;pointer-events:auto}.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}.react-strawberry-toast__toast-content{display:flex;align-items:center;box-sizing:border-box;background-color:var(--toast-bg, #fff);padding:var(--toast-padding-x, 8px) var(--toast-padding-y, 12px);gap:var(--toast-gap, 6px);border-radius:var(--toast-border-radius, 8px);box-shadow:var(--toast-box-shadow, 2px 2px 6px 2px rgba(0, 0, 0, .1));max-width:var(--toast-max-width, 368px)}.react-strawberry-toast__close-button{background:transparent;border:none;outline:none;width:8px;height:8px;cursor:pointer}
package/dist/style2.css CHANGED
@@ -1 +1 @@
1
- @keyframes l3{to{transform:rotate(1turn)}}@keyframes react-strawberry-toast_fade-in{0%{transform:translateY(-100%) scale(.2);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(.2);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{width:100%;position:fixed;z-index:9999;display:flex;align-items:center;flex-direction:column}.react-strawberry-toast__top-left{top:16px;left:calc(-50% + 16px)}.react-strawberry-toast__top-center{top:16px;left:50%;transform:translate(-50%)}.react-strawberry-toast__top-right{top:16px;right:calc(-50% + 16px)}.react-strawberry-toast__bottom-left{bottom:8px;left:calc(-50% + 16px)}.react-strawberry-toast__bottom-center{bottom:8px;left:50%;transform:translate(-50%)}.react-strawberry-toast__bottom-right{bottom:8px;right:calc(-50% + 16px)}.react-strawberry-toast__toast-content-container{position:absolute;pointer-events:none}.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}.react-strawberry-toast__toast-content{pointer-events:auto;box-sizing:border-box;background-color:#fff;padding:10px 10px 10px 15px;display:flex;align-items:center;gap:5px;width:314px;border-radius:8px;box-shadow:2px 2px 6px 2px #0000001a;min-height:54px;max-width:368px;position:relative}.react-strawberry-toast__toast-success:before{content:"";display:inline-block;top:0;left:0;width:7px;height:100%;position:absolute;border-top-left-radius:8px;border-bottom-left-radius:8px;background-color:#1dca82}.react-strawberry-toast__toast-error:before{content:"";display:inline-block;top:0;left:0;width:7px;height:100%;position:absolute;border-top-left-radius:8px;border-bottom-left-radius:8px;background-color:#eb2639}.react-strawberry-toast__toast-warn:before{content:"";display:inline-block;top:0;left:0;width:7px;height:100%;position:absolute;border-top-left-radius:8px;border-bottom-left-radius:8px;background-color:#fcba03}.react-strawberry-toast__toast-info:before{content:"";display:inline-block;top:0;left:0;width:7px;height:100%;position:absolute;border-top-left-radius:8px;border-bottom-left-radius:8px;background-color:#5365e7}.react-strawberry-toast__close-button{background:transparent;border:none;outline:none;width:15px;height:15px;cursor:pointer;position:absolute;right:0;transform:translate(-10px)}
1
+ @keyframes l3{to{transform:rotate(1turn)}}@keyframes react-strawberry-toast_fade-in{0%{transform:translateY(-100%) scale(.2);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(.2);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__toast-container{--toast-color-success: #1dca82;--toast-color-error: #eb2639;--toast-color-warn: #fcba03;--toast-color-info: #5365e7;--toast-close-button: #8b8b8b;width:100%;position:fixed;z-index:9999;display:flex;align-items:center;flex-direction:column;pointer-events:none}.react-strawberry-toast__top-left{top:var(--toast-offset, 16px);left:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__top-center{top:var(--toast-offset, 16px);left:50%;transform:translate(-50%)}.react-strawberry-toast__top-right{top:var(--toast-offset, 16px);right:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__bottom-left{bottom:calc(var(--toast-offset, 16px) - 8px);left:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__bottom-center{bottom:calc(var(--toast-offset, 16px) - 8px);left:50%;transform:translate(-50%)}.react-strawberry-toast__bottom-right{bottom:calc(var(--toast-offset, 16px) - 8px);right:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__toast-content-container{position:absolute;pointer-events:auto}.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}.react-strawberry-toast__toast-content{position:relative;box-sizing:border-box;display:flex;align-items:center;gap:var(--toast-gap, 6px);border-radius:var(--toast-border-radius, 8px);box-shadow:var(--toast-box-shadow, 2px 2px 6px 2px rgba(0, 0, 0, .1));max-width:var(--toast-max-width, 368px);background-color:var(--toast-bg, #fff);padding:var(--toast-padding-x, 8px) var(--toast-padding-y, 12px)}.react-strawberry-toast__toast-success:before{content:"";display:inline-block;top:0;left:0;width:6px;height:100%;position:absolute;border-top-left-radius:8px;border-bottom-left-radius:8px;background-color:var(--toast-color-success)}.react-strawberry-toast__toast-error:before{content:"";display:inline-block;top:0;left:0;width:6px;height:100%;position:absolute;border-top-left-radius:8px;border-bottom-left-radius:8px;background-color:var(--toast-color-error)}.react-strawberry-toast__toast-warn:before{content:"";display:inline-block;top:0;left:0;width:6px;height:100%;position:absolute;border-top-left-radius:8px;border-bottom-left-radius:8px;background-color:var(--toast-color-warn)}.react-strawberry-toast__toast-info:before{content:"";display:inline-block;top:0;left:0;width:6px;height:100%;position:absolute;border-top-left-radius:8px;border-bottom-left-radius:8px;background-color:var(--toast-color-info)}.react-strawberry-toast__close-button{background:transparent;border:none;outline:none;width:8px;height:8px;cursor:pointer;position:absolute;right:0;transform:translate(-10px)}
package/dist/style3.css CHANGED
@@ -1 +1 @@
1
- @keyframes l3{to{transform:rotate(1turn)}}@keyframes react-strawberry-toast_fade-in{0%{transform:translateY(-100%) scale(.2);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(.2);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{width:100%;position:fixed;z-index:9999;display:flex;align-items:center;flex-direction:column}.react-strawberry-toast__top-left{top:16px;left:calc(-50% + 16px)}.react-strawberry-toast__top-center{top:16px;left:50%;transform:translate(-50%)}.react-strawberry-toast__top-right{top:16px;right:calc(-50% + 16px)}.react-strawberry-toast__bottom-left{bottom:8px;left:calc(-50% + 16px)}.react-strawberry-toast__bottom-center{bottom:8px;left:50%;transform:translate(-50%)}.react-strawberry-toast__bottom-right{bottom:8px;right:calc(-50% + 16px)}.react-strawberry-toast__toast-content-container{position:absolute;pointer-events:none}.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}.react-strawberry-toast__toast-content{pointer-events:auto;box-sizing:border-box;padding:10px;display:flex;align-items:center;gap:5px;width:314px;border-radius:8px;box-shadow:2px 2px 6px 2px #0000001a;min-height:54px;max-width:368px;position:relative;background-color:#fff}.react-strawberry-toast__toast-success{color:#fff;background-color:#1dca82}.react-strawberry-toast__toast-error{color:#fff;background-color:#eb2639}.react-strawberry-toast__toast-warn{color:#fff;background-color:#fcba03}.react-strawberry-toast__toast-info{color:#fff;background-color:#5365e7}.react-strawberry-toast__close-button{background:transparent;border:none;outline:none;width:15px;height:15px;cursor:pointer;position:absolute;right:0;transform:translate(-10px)}svg .react-strawberry-toast-path{fill:#fff}
1
+ @keyframes l3{to{transform:rotate(1turn)}}@keyframes react-strawberry-toast_fade-in{0%{transform:translateY(-100%) scale(.2);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(.2);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__toast-container{--toast-color-success: #1dca82;--toast-color-error: #eb2639;--toast-color-warn: #fcba03;--toast-color-info: #5365e7;--toast-close-button: #8b8b8b;width:100%;position:fixed;z-index:9999;display:flex;align-items:center;flex-direction:column;pointer-events:none}.react-strawberry-toast__top-left{top:var(--toast-offset, 16px);left:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__top-center{top:var(--toast-offset, 16px);left:50%;transform:translate(-50%)}.react-strawberry-toast__top-right{top:var(--toast-offset, 16px);right:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__bottom-left{bottom:calc(var(--toast-offset, 16px) - 8px);left:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__bottom-center{bottom:calc(var(--toast-offset, 16px) - 8px);left:50%;transform:translate(-50%)}.react-strawberry-toast__bottom-right{bottom:calc(var(--toast-offset, 16px) - 8px);right:calc(-50% + var(--toast-offset, 16px))}.react-strawberry-toast__toast-content-container{position:absolute;pointer-events:auto}.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}.react-strawberry-toast__toast-content{position:relative;box-sizing:border-box;display:flex;align-items:center;padding:var(--toast-padding-x, 8px) var(--toast-padding-y, 12px);gap:var(--toast-gap, 6px);border-radius:var(--toast-border-radius, 8px);box-shadow:var(--toast-box-shadow, 2px 2px 6px 2px rgba(0, 0, 0, .1));max-width:var(--toast-max-width, 368px);background-color:var(--toast-bg, #fff)}.react-strawberry-toast__toast-success{color:#fff;background-color:var(--toast-color-success)}.react-strawberry-toast__toast-error{color:#fff;background-color:var(--toast-color-error)}.react-strawberry-toast__toast-warn{color:#fff;background-color:var(--toast-color-warn)}.react-strawberry-toast__toast-info{color:#fff;background-color:var(--toast-color-info)}.react-strawberry-toast__close-button{background:transparent;border:none;outline:none;width:8px;height:8px;cursor:pointer;position:absolute;right:0;transform:translate(-10px)}svg .react-strawberry-toast-path{fill:var(--toast-bg, #fff)}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-strawberry-toast",
3
3
  "description": "A simple and customizable React toast library",
4
- "version": "2.1.0",
4
+ "version": "3.0.0",
5
5
  "author": "dkpark10",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -56,6 +56,7 @@
56
56
  "test": "vitest",
57
57
  "test:e2e": "npx playwright test",
58
58
  "test:e2e:ui": "npx playwright test --ui",
59
+ "test:e2e:update": "npx playwright test --update-snapshots",
59
60
  "prepare": "cp ../../README.md ./README.md",
60
61
  "deploy": "pnpm run prepare && pnpm run test --run && pnpm run test:e2e && pnpm run build && npm publish --access=public"
61
62
  },