react-simple-toasts
Advanced tools
Comparing version 5.8.3 to 5.9.0
@@ -1,2 +0,2 @@ | ||
import t,{useRef as e,useState as n,Fragment as o,cloneElement as i}from"react";import*as a from"react-dom";var r=function(){return r=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)};var s={toast_container:"style_toast_container__DT-ei","toast-message":"style_toast-message__-UN8x","top-center":"style_top-center__zZFy4","bottom-center":"style_bottom-center__NH15O",center:"style_center__GLmmM","toast-content":"style_toast-content__jaj36","toast-theme-content":"style_toast-theme-content__JPkou",clickable:"style_clickable__F3Zx7",loading:"style_loading__tn5sw","spinner-wrap":"style_spinner-wrap__kOodK",spinner:"style_spinner__mu5OS",spin:"style_spin__Ez3u3"};!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&o.firstChild?o.insertBefore(i,o.firstChild):o.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}("#style_toast_container__DT-ei * {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n.style_toast-message__-UN8x {\n opacity: 0;\n position: fixed;\n z-index: 1000;\n width: -webkit-max-content;\n width: -moz-max-content;\n width: max-content;\n max-width: 90%;\n -webkit-transition: opacity 0.3s, -webkit-transform 0.3s;\n transition: opacity 0.3s, -webkit-transform 0.3s;\n transition: opacity 0.3s, transform 0.3s;\n transition: opacity 0.3s, transform 0.3s, -webkit-transform 0.3s;\n}\n.style_top-center__zZFy4,\n.style_bottom-center__NH15O,\n.style_center__GLmmM {\n left: 50%;\n}\n.style_toast-message__-UN8x.toast-enter-active,\n.style_toast-message__-UN8x.toast-appear-active {\n opacity: 1;\n}\n.style_toast-message__-UN8x.toast-exit-active {\n opacity: 0;\n}\n.style_toast-content__jaj36 {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n.style_toast-theme-content__JPkou {\n -webkit-transition: all 0.2s;\n transition: all 0.2s;\n}\n.style_clickable__F3Zx7 {\n cursor: pointer;\n}\n.style_loading__tn5sw .style_spinner-wrap__kOodK {\n visibility: visible;\n opacity: 1;\n width: 1.1em;\n margin-right: 12px;\n}\n.style_spinner-wrap__kOodK {\n display: inline-block;\n visibility: hidden;\n opacity: 0;\n width: 0;\n margin-right: 0;\n}\n.style_spinner__mu5OS {\n display: block;\n overflow: hidden;\n width: 1.1em;\n height: 1.1em;\n border: 2px solid rgba(255, 255, 255, 0.3);\n border-radius: 50%;\n border-top-color: #fff;\n vertical-align: middle;\n text-indent: -99999px;\n -webkit-animation: style_spin__Ez3u3 1s ease-in-out infinite;\n animation: style_spin__Ez3u3 1s ease-in-out infinite;\n}\n@-webkit-keyframes style_spin__Ez3u3 {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@keyframes style_spin__Ez3u3 {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n");var l,c=r({},a),d=c.version,u=c.render;c.unmountComponentAtNode;try{Number((d||"").split(".")[0])>=18&&c.createRoot&&(l=c.createRoot)}catch(t){}function f(t){var e=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;e&&"object"==typeof e&&(e.usingClientEntryPoint=t)}var _="__rc_react_root__";function p(t,e){null==l?function(t,e){u(t,e)}(t,e):function(t,e){f(!0);var n=e[_]||l(e);f(!1),n.render(t),e[_]=n}(t,e)}var m=function(){return Date.now()+Math.floor(1e16*Math.random())},v=function(){return"undefined"!=typeof window},b=function(t,e){var n=t.replace(/[rgb(]|[)]/g,"").split(",").map((function(t){return t.trim()})),o=n[0],i=n[1],a=n[2];return"rgba(".concat(o,", ").concat(i,", ").concat(a,", ").concat(e,")")},g=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.filter(Boolean).join(" ")},y=2147483647,h={BOTTOM_LEFT:"bottom-left",BOTTOM_CENTER:"bottom-center",BOTTOM_RIGHT:"bottom-right",TOP_LEFT:"top-left",TOP_CENTER:"top-center",TOP_RIGHT:"top-right",CENTER:"center"},x={DARK:"dark",LIGHT:"light",SUCCESS:"success",INFO:"info",WARNING:"warning",FAILURE:"failure",PLAIN:"plain",FROSTED_GLASS:"frosted-glass",PINK_DAWN:"pink-dawn",CHROMA:"chroma",BLUE_DUSK:"blue-dusk",OCEAN_WAVE:"ocean-wave"};function k(){return k=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},k.apply(this,arguments)}var E={"toast-blue-dusk":"_toast-blue-dusk_pnidt_1","toast-chroma":"_toast-chroma_1u0sn_1","toast-dark":"_toast-dark_1uck5_1","toast-failure":"_toast-failure_1xuna_1","toast-frosted-glass":"_toast-frosted-glass_lv9sk_1","toast-frosted-glass-wrapper":"_toast-frosted-glass-wrapper_lv9sk_6","toast-info":"_toast-info_v91zz_1","toast-light":"_toast-light_1t8t0_1","toast-ocean-wave":"_toast-ocean-wave_1cgng_1","toast-pink-dawn":"_toast-pink-dawn_13jqk_1","toast-plain":"_toast-plain_11plr_1","toast-success":"_toast-success_1dljs_1","toast-warning":"_toast-warning_ohu7r_1"},w="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function O(e){var n=e.color,o=n&&b(n,.3);return t.createElement("span",{className:s["spinner-wrap"]},t.createElement("span",{className:s.spinner,style:{border:"2px solid ".concat(o),borderTopColor:n}},"loading"))}function T(o){var i=o.id,a=o.message,r=o.className,l=o.clickable,c=o.position,d=o.isExit,u=o.render,f=o.theme,_=o.offsetX,p=o.offsetY,m=o.baseOffsetX,v=o.baseOffsetY,b=o.zIndex,y=o.loading,x=o.onClick,T=o._onEnter,C=e(null),N=null==c?void 0:c.includes("top"),I=null==c?void 0:c.includes("bottom"),R=null==c?void 0:c.includes("right"),z=null==c?void 0:c.includes("left"),S=null==c?void 0:c.includes("-center"),j=c===h.CENTER,A=n(!1),L=A[0],Y=A[1],D=n({transform:"translate(".concat(_,", ").concat(j?"calc(50% - 20px)":"".concat(parseInt(p||"0")+20*(N?-1:1),"px"),")")}),F=D[0],P=D[1],U=n(!!y),X=U[0],B=U[1],H=n(),M=H[0],G=H[1],V=j?"50%":N?v:void 0,K=I?v:void 0,W=R?m:void 0,Z=S||j?"50%":z?m:void 0;w((function(){var t="translate(".concat(_,", ").concat(p,")");P({top:V,right:W,bottom:K,left:Z,zIndex:b,transform:t,WebkitTransform:t})}),[_,p,b,V,W,K,Z]),w((function(){var t;if(null!=(null===(t=C.current)||void 0===t?void 0:t.clientHeight)&&!L){var e=C.current.clientWidth,n=C.current.clientHeight;C.current&&(null==T||T({target:C.current,width:e,height:n})),Y(!0)}}),[L,T]),w((function(){if(C.current){var t=C.current.querySelector("span"),e=t&&window.getComputedStyle(t).color;e&&G(e)}}),[]),w((function(){if(y instanceof Promise)return B(!0),void y.then((function(){B(!1)}));B(!!y)}),[y]);var q=g(s["toast-message"],s[c||"bottom-center"],E["toast-".concat(f,"-wrapper")],L?"toast-enter-active":"",d?"toast-exit-active":"",X?s.loading:""),J=g(s["toast-content"],l?s.clickable:"",!u&&E["toast-".concat(f)],!u&&f?s["toast-theme-content"]:"",f||"",r),Q={onClick:x,tabIndex:0,role:"button"};return t.createElement("div",{ref:C,id:i.toString(),className:q,style:F},t.createElement("div",k({className:J},l&&Q),X&&t.createElement(O,{color:M}),u?u(a):a))}var C=function(t){return!(!t||"object"!=typeof t)&&("message"in t||"duration"in t||"loading"in t)},N=[],I=function(){var t,e,n,o=v()&&document.getElementById(s.toast_container);v()&&!o&&(e=s.toast_container,(n=document.createElement("div")).setAttribute("id",e),t=n,document.body.appendChild(t)),N&&Array.isArray(N)||(N=[])},R={duration:3e3,className:"",position:"bottom-center",offsetX:30,offsetY:30,gap:10,clickClosable:!1,render:null,maxVisibleToasts:null,isReversedOrder:!1,theme:null,zIndex:null},z=function(t){var e=Object.values(h);if(!e.includes(t))throw new Error("Invalid position value. Expected one of ".concat(e.join(", ")," but got ").concat(t));return!0},S=function(t){v()&&(t.theme&&(R.theme=t.theme),t.duration&&(R.duration=t.duration),t.className&&(R.className=t.className),t.position&&z(t.position)&&(R.position=t.position),t.clickClosable&&(R.clickClosable=t.clickClosable),t.render&&(R.render=t.render),t.maxVisibleToasts&&(R.maxVisibleToasts=t.maxVisibleToasts),t.isReversedOrder&&(R.isReversedOrder=t.isReversedOrder),null!=t.zIndex&&(R.zIndex=t.zIndex),null!=t.offsetX&&(R.offsetX=t.offsetX),null!=t.offsetY&&(R.offsetY=t.offsetY),null!=t.gap&&(R.gap=t.gap))};function j(){return t.createElement(t.Fragment,null,N.map((function(e){var n=e.position.includes("top")?function(t){for(var e=[],n=t.length-1;n>=0;n--)e.push(t[n]);return e}(N):N,a=n.findIndex((function(t){return t.id===e.id})),r=n.slice(a+1).filter((function(t){return t.position===e.position&&!t.isExit})),s=r.reduce((function(t,n){var o;return t+(null!==(o=n.height)&&void 0!==o?o:0)+e.gap}),0),l=e.position.includes("left")||e.position.includes("right")?"0%":"-50%",c=s*(e.position.includes("top")?1:-1),d="center"===e.position?"calc(-50% - ".concat(-1*c,"px)"):"".concat(c,"px");return t.createElement(o,{key:e.id},i(e.component,{isExit:e.isExit,offsetX:l,offsetY:d,_onEnter:function(t){return function(t,e){N.forEach((function(n){n.id===t.id&&(n.startCloseTimer(),n.height=e.height)})),A()}(e,t)}}))})))}var A=function(){if(v()){var e=document.getElementById(s.toast_container);e&&p(t.createElement(j,null),e)}},L=function(){N.forEach((function(t){return t.isExit=!0})),A()};function Y(t,e){var n,o=N.findIndex((function(e){return e.id===t}));N[o]&&(N[o].isExit=!0),null===(n=e.onCloseStart)||void 0===n||n.call(e),A(),setTimeout((function(){var n;N=N.filter((function(e){return e.id!==t})),null===(n=e.onClose)||void 0===n||n.call(e),A()}),300)}function D(e,n){var o;if(!v())return{close:function(){return null},updateDuration:function(){return null},update:function(){return null}};var i=m(),a=n||{},s=a.duration,l=a.clickable,c=void 0!==l&&l,d=a.clickClosable,u=void 0===d?R.clickClosable:d,f=a.className,_=void 0===f?R.className:f,p=a.position,b=void 0===p?R.position:p,g=a.offsetX,h=void 0===g?R.offsetX:g,x=a.offsetY,k=void 0===x?R.offsetY:x,E=a.gap,w=void 0===E?R.gap:E,O=a.maxVisibleToasts,S=void 0===O?R.maxVisibleToasts:O,j=a.isReversedOrder,L=void 0===j?R.isReversedOrder:j,D=a.render,F=void 0===D?R.render:D,P=a.theme,U=void 0===P?R.theme:P,X=a.zIndex,B=void 0===X?R.zIndex:X,H=a.loading,M=a.onClick,G=void 0===M?void 0:M,V=a.onClose,K=void 0===V?void 0:V,W=a.onCloseStart,Z=void 0===W?void 0:W,q=void 0===s?R.duration:s,J={onClose:K,onCloseStart:Z};z(b),I();var Q=function(t){u&&(o&&clearTimeout(o),Y(i,J)),null==G||G(t)},$=function(t,e){void 0===t&&(t=q),null===t||0===t||t>y||(o&&clearTimeout(o),o=window.setTimeout((function(){Y(i,r(r({},J),{onCloseStart:function(){var t;null==e||e(),null===(t=J.onClose)||void 0===t||t.call(J)}}))}),t))},tt={id:i,message:e,position:b,startCloseTimer:$,gap:w,component:t.createElement(T,{id:i,message:e,className:_,clickable:c||u,position:b,baseOffsetX:h,baseOffsetY:k,render:F,theme:U,zIndex:B||void 0,loading:H,onClick:Q})};if(L?N.unshift(tt):N.push(tt),S)for(var et=N.length-S,nt=0;nt<et;nt++)Y(N[nt].id,J);return A(),{close:function(){return Y(i,J)},updateDuration:function(t){void 0===t&&(t=q),$(t)},update:function(n,o){var a,r,s=N.findIndex((function(t){return t.id===i})),l=C(n)?n.duration:o;if(N[s]){var d=null!==(a=C(n)?n.message:n)&&void 0!==a?a:e,f=!!C(n)&&(null!==(r=n.loading)&&void 0!==r?r:H),p=C(n)?n.theme:U;N[s].message=d,N[s].component=t.createElement(T,{id:i,message:d,className:_,clickable:c||u,position:b,baseOffsetX:h,baseOffsetY:k,render:F,theme:p,loading:f,onClick:Q})}A(),void 0!==l&&$(l)}}}function F(t,e){return D(t,"number"==typeof e||null===e?{duration:e}:e)}var P=function(t){var e=m();return function(n,o){if("number"==typeof o)return D(n,{toastInstanceId:e,duration:o||t.duration});if(void 0===o||"object"==typeof o)return D(n,r(r({toastInstanceId:e},t),o));throw new Error("Invalid durationOrOptions type")}};export{x as Themes,L as clearToasts,P as createToast,F as default,S as toastConfig}; | ||
import t,{useRef as e,useState as n,Fragment as o,cloneElement as i}from"react";import*as a from"react-dom";var r=function(){return r=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)};var s={toast_container:"style_toast_container__DT-ei","toast-message":"style_toast-message__-UN8x","top-center":"style_top-center__zZFy4","bottom-center":"style_bottom-center__NH15O",center:"style_center__GLmmM","toast-content":"style_toast-content__jaj36","toast-theme-content":"style_toast-theme-content__JPkou",clickable:"style_clickable__F3Zx7",loading:"style_loading__tn5sw","spinner-wrap":"style_spinner-wrap__kOodK",spinner:"style_spinner__mu5OS",spin:"style_spin__Ez3u3"};!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&o.firstChild?o.insertBefore(i,o.firstChild):o.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}("#style_toast_container__DT-ei * {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n.style_toast-message__-UN8x {\n opacity: 0;\n position: fixed;\n z-index: 1000;\n width: -webkit-max-content;\n width: -moz-max-content;\n width: max-content;\n max-width: 90%;\n -webkit-transition: opacity 0.3s, -webkit-transform 0.3s;\n transition: opacity 0.3s, -webkit-transform 0.3s;\n transition: opacity 0.3s, transform 0.3s;\n transition: opacity 0.3s, transform 0.3s, -webkit-transform 0.3s;\n}\n.style_top-center__zZFy4,\n.style_bottom-center__NH15O,\n.style_center__GLmmM {\n left: 50%;\n}\n.style_toast-message__-UN8x.toast-enter-active,\n.style_toast-message__-UN8x.toast-appear-active {\n opacity: 1;\n}\n.style_toast-message__-UN8x.toast-exit-active {\n opacity: 0;\n}\n.style_toast-content__jaj36 {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n.style_toast-theme-content__JPkou {\n -webkit-transition: all 0.2s;\n transition: all 0.2s;\n}\n.style_clickable__F3Zx7 {\n cursor: pointer;\n}\n.style_loading__tn5sw .style_spinner-wrap__kOodK {\n visibility: visible;\n opacity: 1;\n width: 1.1em;\n margin-right: 12px;\n}\n.style_spinner-wrap__kOodK {\n display: inline-block;\n visibility: hidden;\n opacity: 0;\n width: 0;\n margin-right: 0;\n}\n.style_spinner__mu5OS {\n display: block;\n overflow: hidden;\n width: 1.1em;\n height: 1.1em;\n border: 2px solid rgba(255, 255, 255, 0.3);\n border-radius: 50%;\n border-top-color: #fff;\n vertical-align: middle;\n text-indent: -99999px;\n -webkit-animation: style_spin__Ez3u3 1s ease-in-out infinite;\n animation: style_spin__Ez3u3 1s ease-in-out infinite;\n}\n@-webkit-keyframes style_spin__Ez3u3 {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@keyframes style_spin__Ez3u3 {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n");var l,c=r({},a),d=c.version,u=c.render;c.unmountComponentAtNode;try{Number((d||"").split(".")[0])>=18&&c.createRoot&&(l=c.createRoot)}catch(t){}function f(t){var e=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;e&&"object"==typeof e&&(e.usingClientEntryPoint=t)}var _="__rc_react_root__";function p(t,e){null==l?function(t,e){u(t,e)}(t,e):function(t,e){f(!0);var n=e[_]||l(e);f(!1),n.render(t),e[_]=n}(t,e)}var m=function(){return Date.now()+Math.floor(1e16*Math.random())},v=function(){return"undefined"!=typeof window},g=function(t,e){var n=t.replace(/[rgb(]|[)]/g,"").split(",").map((function(t){return t.trim()})),o=n[0],i=n[1],a=n[2];return"rgba(".concat(o,", ").concat(i,", ").concat(a,", ").concat(e,")")},b=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.filter(Boolean).join(" ")},y=2147483647,h={BOTTOM_LEFT:"bottom-left",BOTTOM_CENTER:"bottom-center",BOTTOM_RIGHT:"bottom-right",TOP_LEFT:"top-left",TOP_CENTER:"top-center",TOP_RIGHT:"top-right",CENTER:"center"},x={DARK:"dark",LIGHT:"light",SUCCESS:"success",INFO:"info",WARNING:"warning",FAILURE:"failure",PLAIN:"plain",FROSTED_GLASS:"frosted-glass",PINK_DAWN:"pink-dawn",CHROMA:"chroma",BLUE_DUSK:"blue-dusk",OCEAN_WAVE:"ocean-wave",SUNSET:"sunset",MOONLIGHT:"moonlight"};function k(){return k=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},k.apply(this,arguments)}var E={"toast-blue-dusk":"_toast-blue-dusk_pnidt_1","toast-chroma":"_toast-chroma_1u0sn_1","toast-dark":"_toast-dark_1uck5_1","toast-failure":"_toast-failure_1xuna_1","toast-frosted-glass":"_toast-frosted-glass_lv9sk_1","toast-frosted-glass-wrapper":"_toast-frosted-glass-wrapper_lv9sk_6","toast-info":"_toast-info_v91zz_1","toast-light":"_toast-light_1t8t0_1","toast-moonlight":"_toast-moonlight_128j9_1","toast-ocean-wave":"_toast-ocean-wave_1cgng_1","toast-pink-dawn":"_toast-pink-dawn_13jqk_1","toast-plain":"_toast-plain_11plr_1","toast-success":"_toast-success_1dljs_1","toast-sunset":"_toast-sunset_1tanv_1","toast-warning":"_toast-warning_ohu7r_1"},w="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function O(e){var n=e.color,o=n&&g(n,.3);return t.createElement("span",{className:s["spinner-wrap"]},t.createElement("span",{className:s.spinner,style:{border:"2px solid ".concat(o),borderTopColor:n}},"loading"))}function T(o){var i=o.id,a=o.message,r=o.className,l=o.clickable,c=o.position,d=o.isExit,u=o.render,f=o.theme,_=o.offsetX,p=o.offsetY,m=o.baseOffsetX,v=o.baseOffsetY,g=o.zIndex,y=o.loading,x=o.onClick,T=o._onEnter,N=e(null),C=null==c?void 0:c.includes("top"),I=null==c?void 0:c.includes("bottom"),R=null==c?void 0:c.includes("right"),S=null==c?void 0:c.includes("left"),z=null==c?void 0:c.includes("-center"),j=c===h.CENTER,A=n(!1),L=A[0],U=A[1],Y=n({transform:"translate(".concat(_,", ").concat(j?"calc(50% - 20px)":"".concat(parseInt(p||"0")+20*(C?-1:1),"px"),")")}),D=Y[0],F=Y[1],P=n(!!y),X=P[0],B=P[1],H=n(),M=H[0],G=H[1],V=j?"50%":C?v:void 0,K=I?v:void 0,W=R?m:void 0,Z=z||j?"50%":S?m:void 0;w((function(){var t="translate(".concat(_,", ").concat(p,")");F({top:V,right:W,bottom:K,left:Z,zIndex:g,transform:t,WebkitTransform:t})}),[_,p,g,V,W,K,Z]),w((function(){var t;if(null!=(null===(t=N.current)||void 0===t?void 0:t.clientHeight)&&!L){var e=N.current.clientWidth,n=N.current.clientHeight;N.current&&(null==T||T({target:N.current,width:e,height:n})),U(!0)}}),[L,T]),w((function(){if(N.current){var t=N.current.querySelector("span"),e=t&&window.getComputedStyle(t).color;e&&G(e)}}),[]),w((function(){if(y instanceof Promise)return B(!0),void y.then((function(){B(!1)}));B(!!y)}),[y]);var q=b(s["toast-message"],s[c||"bottom-center"],E["toast-".concat(f,"-wrapper")],L?"toast-enter-active":"",d?"toast-exit-active":"",X?s.loading:""),J=b(s["toast-content"],l?s.clickable:"",!u&&E["toast-".concat(f)],!u&&f?s["toast-theme-content"]:"",f||"",r),Q={onClick:x,tabIndex:0,role:"button"};return t.createElement("div",{ref:N,id:i.toString(),className:q,style:D},t.createElement("div",k({className:J},l&&Q),X&&t.createElement(O,{color:M}),u?u(a):a))}var N=function(t){return!(!t||"object"!=typeof t)&&("message"in t||"duration"in t||"loading"in t)},C=[],I=function(){var t,e,n,o=v()&&document.getElementById(s.toast_container);v()&&!o&&(e=s.toast_container,(n=document.createElement("div")).setAttribute("id",e),t=n,document.body.appendChild(t)),C&&Array.isArray(C)||(C=[])},R={duration:3e3,className:"",position:"bottom-center",offsetX:30,offsetY:30,gap:10,clickClosable:!1,render:null,maxVisibleToasts:null,isReversedOrder:!1,theme:null,zIndex:null},S=function(t){var e=Object.values(h);if(!e.includes(t))throw new Error("Invalid position value. Expected one of ".concat(e.join(", ")," but got ").concat(t));return!0},z=function(t){v()&&(t.theme&&(R.theme=t.theme),t.duration&&(R.duration=t.duration),t.className&&(R.className=t.className),t.position&&S(t.position)&&(R.position=t.position),t.clickClosable&&(R.clickClosable=t.clickClosable),t.render&&(R.render=t.render),t.maxVisibleToasts&&(R.maxVisibleToasts=t.maxVisibleToasts),t.isReversedOrder&&(R.isReversedOrder=t.isReversedOrder),null!=t.zIndex&&(R.zIndex=t.zIndex),null!=t.offsetX&&(R.offsetX=t.offsetX),null!=t.offsetY&&(R.offsetY=t.offsetY),null!=t.gap&&(R.gap=t.gap))};function j(){return t.createElement(t.Fragment,null,C.map((function(e){var n=e.position.includes("top")?function(t){for(var e=[],n=t.length-1;n>=0;n--)e.push(t[n]);return e}(C):C,a=n.findIndex((function(t){return t.id===e.id})),r=n.slice(a+1).filter((function(t){return t.position===e.position&&!t.isExit})),s=r.reduce((function(t,n){var o;return t+(null!==(o=n.height)&&void 0!==o?o:0)+e.gap}),0),l=e.position.includes("left")||e.position.includes("right")?"0%":"-50%",c=s*(e.position.includes("top")?1:-1),d="center"===e.position?"calc(-50% - ".concat(-1*c,"px)"):"".concat(c,"px");return t.createElement(o,{key:e.id},i(e.component,{isExit:e.isExit,offsetX:l,offsetY:d,_onEnter:function(t){return function(t,e){C.forEach((function(n){n.id===t.id&&(n.startCloseTimer(),n.height=e.height)})),A()}(e,t)}}))})))}var A=function(){if(v()){var e=document.getElementById(s.toast_container);e&&p(t.createElement(j,null),e)}},L=function(){C.forEach((function(t){return t.isExit=!0})),A()};function U(t,e){var n,o=C.findIndex((function(e){return e.id===t}));C[o]&&(C[o].isExit=!0),null===(n=e.onCloseStart)||void 0===n||n.call(e),A(),setTimeout((function(){var n;C=C.filter((function(e){return e.id!==t})),null===(n=e.onClose)||void 0===n||n.call(e),A()}),300)}function Y(e,n){var o;if(!v())return{close:function(){return null},updateDuration:function(){return null},update:function(){return null}};var i=m(),a=n||{},s=a.duration,l=a.clickable,c=void 0!==l&&l,d=a.clickClosable,u=void 0===d?R.clickClosable:d,f=a.className,_=void 0===f?R.className:f,p=a.position,g=void 0===p?R.position:p,b=a.offsetX,h=void 0===b?R.offsetX:b,x=a.offsetY,k=void 0===x?R.offsetY:x,E=a.gap,w=void 0===E?R.gap:E,O=a.maxVisibleToasts,z=void 0===O?R.maxVisibleToasts:O,j=a.isReversedOrder,L=void 0===j?R.isReversedOrder:j,Y=a.render,D=void 0===Y?R.render:Y,F=a.theme,P=void 0===F?R.theme:F,X=a.zIndex,B=void 0===X?R.zIndex:X,H=a.loading,M=a.onClick,G=void 0===M?void 0:M,V=a.onClose,K=void 0===V?void 0:V,W=a.onCloseStart,Z=void 0===W?void 0:W,q=void 0===s?R.duration:s,J={onClose:K,onCloseStart:Z};S(g),I();var Q=function(t){u&&(o&&clearTimeout(o),U(i,J)),null==G||G(t)},$=function(t,e){void 0===t&&(t=q),null===t||0===t||t>y||(o&&clearTimeout(o),o=window.setTimeout((function(){U(i,r(r({},J),{onCloseStart:function(){var t;null==e||e(),null===(t=J.onClose)||void 0===t||t.call(J)}}))}),t))},tt={id:i,message:e,position:g,startCloseTimer:$,gap:w,component:t.createElement(T,{id:i,message:e,className:_,clickable:c||u,position:g,baseOffsetX:h,baseOffsetY:k,render:D,theme:P,zIndex:B||void 0,loading:H,onClick:Q})};if(L?C.unshift(tt):C.push(tt),z)for(var et=C.length-z,nt=0;nt<et;nt++)U(C[nt].id,J);return A(),{close:function(){return U(i,J)},updateDuration:function(t){void 0===t&&(t=q),$(t)},update:function(n,o){var a,r,s=C.findIndex((function(t){return t.id===i})),l=N(n)?n.duration:o;if(C[s]){var d=null!==(a=N(n)?n.message:n)&&void 0!==a?a:e,f=!!N(n)&&(null!==(r=n.loading)&&void 0!==r?r:H),p=N(n)?n.theme:P;C[s].message=d,C[s].component=t.createElement(T,{id:i,message:d,className:_,clickable:c||u,position:g,baseOffsetX:h,baseOffsetY:k,render:D,theme:p,loading:f,onClick:Q})}A(),void 0!==l&&$(l)}}}function D(t,e){return Y(t,"number"==typeof e||null===e?{duration:e}:e)}var F=function(t){var e=m();return function(n,o){if("number"==typeof o)return Y(n,{toastInstanceId:e,duration:o||t.duration});if(void 0===o||"object"==typeof o)return Y(n,r(r({toastInstanceId:e},t),o));throw new Error("Invalid durationOrOptions type")}};export{x as Themes,L as clearToasts,F as createToast,D as default,z as toastConfig}; | ||
//# sourceMappingURL=index.es.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");function e(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var n=e(require("react-dom")),o=function(){return o=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)};var i={toast_container:"style_toast_container__DT-ei","toast-message":"style_toast-message__-UN8x","top-center":"style_top-center__zZFy4","bottom-center":"style_bottom-center__NH15O",center:"style_center__GLmmM","toast-content":"style_toast-content__jaj36","toast-theme-content":"style_toast-theme-content__JPkou",clickable:"style_clickable__F3Zx7",loading:"style_loading__tn5sw","spinner-wrap":"style_spinner-wrap__kOodK",spinner:"style_spinner__mu5OS",spin:"style_spin__Ez3u3"};!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&o.firstChild?o.insertBefore(i,o.firstChild):o.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}("#style_toast_container__DT-ei * {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n.style_toast-message__-UN8x {\n opacity: 0;\n position: fixed;\n z-index: 1000;\n width: -webkit-max-content;\n width: -moz-max-content;\n width: max-content;\n max-width: 90%;\n -webkit-transition: opacity 0.3s, -webkit-transform 0.3s;\n transition: opacity 0.3s, -webkit-transform 0.3s;\n transition: opacity 0.3s, transform 0.3s;\n transition: opacity 0.3s, transform 0.3s, -webkit-transform 0.3s;\n}\n.style_top-center__zZFy4,\n.style_bottom-center__NH15O,\n.style_center__GLmmM {\n left: 50%;\n}\n.style_toast-message__-UN8x.toast-enter-active,\n.style_toast-message__-UN8x.toast-appear-active {\n opacity: 1;\n}\n.style_toast-message__-UN8x.toast-exit-active {\n opacity: 0;\n}\n.style_toast-content__jaj36 {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n.style_toast-theme-content__JPkou {\n -webkit-transition: all 0.2s;\n transition: all 0.2s;\n}\n.style_clickable__F3Zx7 {\n cursor: pointer;\n}\n.style_loading__tn5sw .style_spinner-wrap__kOodK {\n visibility: visible;\n opacity: 1;\n width: 1.1em;\n margin-right: 12px;\n}\n.style_spinner-wrap__kOodK {\n display: inline-block;\n visibility: hidden;\n opacity: 0;\n width: 0;\n margin-right: 0;\n}\n.style_spinner__mu5OS {\n display: block;\n overflow: hidden;\n width: 1.1em;\n height: 1.1em;\n border: 2px solid rgba(255, 255, 255, 0.3);\n border-radius: 50%;\n border-top-color: #fff;\n vertical-align: middle;\n text-indent: -99999px;\n -webkit-animation: style_spin__Ez3u3 1s ease-in-out infinite;\n animation: style_spin__Ez3u3 1s ease-in-out infinite;\n}\n@-webkit-keyframes style_spin__Ez3u3 {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@keyframes style_spin__Ez3u3 {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n");var r,a=o({},n),s=a.version,l=a.render;a.unmountComponentAtNode;try{Number((s||"").split(".")[0])>=18&&a.createRoot&&(r=a.createRoot)}catch(t){}function c(t){var e=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;e&&"object"==typeof e&&(e.usingClientEntryPoint=t)}var u="__rc_react_root__";function d(t,e){null==r?function(t,e){l(t,e)}(t,e):function(t,e){c(!0);var n=e[u]||r(e);c(!1),n.render(t),e[u]=n}(t,e)}var f=function(){return Date.now()+Math.floor(1e16*Math.random())},_=function(){return"undefined"!=typeof window},p=function(t,e){var n=t.replace(/[rgb(]|[)]/g,"").split(",").map((function(t){return t.trim()})),o=n[0],i=n[1],r=n[2];return"rgba(".concat(o,", ").concat(i,", ").concat(r,", ").concat(e,")")},m=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.filter(Boolean).join(" ")},v=2147483647,b={BOTTOM_LEFT:"bottom-left",BOTTOM_CENTER:"bottom-center",BOTTOM_RIGHT:"bottom-right",TOP_LEFT:"top-left",TOP_CENTER:"top-center",TOP_RIGHT:"top-right",CENTER:"center"};function g(){return g=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},g.apply(this,arguments)}var y={"toast-blue-dusk":"_toast-blue-dusk_pnidt_1","toast-chroma":"_toast-chroma_1u0sn_1","toast-dark":"_toast-dark_1uck5_1","toast-failure":"_toast-failure_1xuna_1","toast-frosted-glass":"_toast-frosted-glass_lv9sk_1","toast-frosted-glass-wrapper":"_toast-frosted-glass-wrapper_lv9sk_6","toast-info":"_toast-info_v91zz_1","toast-light":"_toast-light_1t8t0_1","toast-ocean-wave":"_toast-ocean-wave_1cgng_1","toast-pink-dawn":"_toast-pink-dawn_13jqk_1","toast-plain":"_toast-plain_11plr_1","toast-success":"_toast-success_1dljs_1","toast-warning":"_toast-warning_ohu7r_1"},h="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function x(e){var n=e.color,o=n&&p(n,.3);return t.createElement("span",{className:i["spinner-wrap"]},t.createElement("span",{className:i.spinner,style:{border:"2px solid ".concat(o),borderTopColor:n}},"loading"))}function k(e){var n=e.id,o=e.message,r=e.className,a=e.clickable,s=e.position,l=e.isExit,c=e.render,u=e.theme,d=e.offsetX,f=e.offsetY,_=e.baseOffsetX,p=e.baseOffsetY,v=e.zIndex,k=e.loading,E=e.onClick,w=e._onEnter,O=t.useRef(null),T=null==s?void 0:s.includes("top"),C=null==s?void 0:s.includes("bottom"),N=null==s?void 0:s.includes("right"),I=null==s?void 0:s.includes("left"),S=null==s?void 0:s.includes("-center"),j=s===b.CENTER,R=t.useState(!1),z=R[0],A=R[1],P=t.useState({transform:"translate(".concat(d,", ").concat(j?"calc(50% - 20px)":"".concat(parseInt(f||"0")+20*(T?-1:1),"px"),")")}),L=P[0],D=P[1],F=t.useState(!!k),Y=F[0],U=F[1],X=t.useState(),B=X[0],M=X[1],H=j?"50%":T?p:void 0,G=C?p:void 0,V=N?_:void 0,K=S||j?"50%":I?_:void 0;h((function(){var t="translate(".concat(d,", ").concat(f,")");D({top:H,right:V,bottom:G,left:K,zIndex:v,transform:t,WebkitTransform:t})}),[d,f,v,H,V,G,K]),h((function(){var t;if(null!=(null===(t=O.current)||void 0===t?void 0:t.clientHeight)&&!z){var e=O.current.clientWidth,n=O.current.clientHeight;O.current&&(null==w||w({target:O.current,width:e,height:n})),A(!0)}}),[z,w]),h((function(){if(O.current){var t=O.current.querySelector("span"),e=t&&window.getComputedStyle(t).color;e&&M(e)}}),[]),h((function(){if(k instanceof Promise)return U(!0),void k.then((function(){U(!1)}));U(!!k)}),[k]);var W=m(i["toast-message"],i[s||"bottom-center"],y["toast-".concat(u,"-wrapper")],z?"toast-enter-active":"",l?"toast-exit-active":"",Y?i.loading:""),q=m(i["toast-content"],a?i.clickable:"",!c&&y["toast-".concat(u)],!c&&u?i["toast-theme-content"]:"",u||"",r),Z={onClick:E,tabIndex:0,role:"button"};return t.createElement("div",{ref:O,id:n.toString(),className:W,style:L},t.createElement("div",g({className:q},a&&Z),Y&&t.createElement(x,{color:B}),c?c(o):o))}var E=function(t){return!(!t||"object"!=typeof t)&&("message"in t||"duration"in t||"loading"in t)},w=[],O=function(){var t,e,n,o=_()&&document.getElementById(i.toast_container);_()&&!o&&(e=i.toast_container,(n=document.createElement("div")).setAttribute("id",e),t=n,document.body.appendChild(t)),w&&Array.isArray(w)||(w=[])},T={duration:3e3,className:"",position:"bottom-center",offsetX:30,offsetY:30,gap:10,clickClosable:!1,render:null,maxVisibleToasts:null,isReversedOrder:!1,theme:null,zIndex:null},C=function(t){var e=Object.values(b);if(!e.includes(t))throw new Error("Invalid position value. Expected one of ".concat(e.join(", ")," but got ").concat(t));return!0};function N(){return t.createElement(t.Fragment,null,w.map((function(e){var n=e.position.includes("top")?function(t){for(var e=[],n=t.length-1;n>=0;n--)e.push(t[n]);return e}(w):w,o=n.findIndex((function(t){return t.id===e.id})),i=n.slice(o+1).filter((function(t){return t.position===e.position&&!t.isExit})),r=i.reduce((function(t,n){var o;return t+(null!==(o=n.height)&&void 0!==o?o:0)+e.gap}),0),a=e.position.includes("left")||e.position.includes("right")?"0%":"-50%",s=r*(e.position.includes("top")?1:-1),l="center"===e.position?"calc(-50% - ".concat(-1*s,"px)"):"".concat(s,"px");return t.createElement(t.Fragment,{key:e.id},t.cloneElement(e.component,{isExit:e.isExit,offsetX:a,offsetY:l,_onEnter:function(t){return function(t,e){w.forEach((function(n){n.id===t.id&&(n.startCloseTimer(),n.height=e.height)})),I()}(e,t)}}))})))}var I=function(){if(_()){var e=document.getElementById(i.toast_container);e&&d(t.createElement(N,null),e)}};function S(t,e){var n,o=w.findIndex((function(e){return e.id===t}));w[o]&&(w[o].isExit=!0),null===(n=e.onCloseStart)||void 0===n||n.call(e),I(),setTimeout((function(){var n;w=w.filter((function(e){return e.id!==t})),null===(n=e.onClose)||void 0===n||n.call(e),I()}),300)}function j(e,n){var i;if(!_())return{close:function(){return null},updateDuration:function(){return null},update:function(){return null}};var r=f(),a=n||{},s=a.duration,l=a.clickable,c=void 0!==l&&l,u=a.clickClosable,d=void 0===u?T.clickClosable:u,p=a.className,m=void 0===p?T.className:p,b=a.position,g=void 0===b?T.position:b,y=a.offsetX,h=void 0===y?T.offsetX:y,x=a.offsetY,N=void 0===x?T.offsetY:x,j=a.gap,R=void 0===j?T.gap:j,z=a.maxVisibleToasts,A=void 0===z?T.maxVisibleToasts:z,P=a.isReversedOrder,L=void 0===P?T.isReversedOrder:P,D=a.render,F=void 0===D?T.render:D,Y=a.theme,U=void 0===Y?T.theme:Y,X=a.zIndex,B=void 0===X?T.zIndex:X,M=a.loading,H=a.onClick,G=void 0===H?void 0:H,V=a.onClose,K=void 0===V?void 0:V,W=a.onCloseStart,q=void 0===W?void 0:W,Z=void 0===s?T.duration:s,J={onClose:K,onCloseStart:q};C(g),O();var Q=function(t){d&&(i&&clearTimeout(i),S(r,J)),null==G||G(t)},$=function(t,e){void 0===t&&(t=Z),null===t||0===t||t>v||(i&&clearTimeout(i),i=window.setTimeout((function(){S(r,o(o({},J),{onCloseStart:function(){var t;null==e||e(),null===(t=J.onClose)||void 0===t||t.call(J)}}))}),t))},tt={id:r,message:e,position:g,startCloseTimer:$,gap:R,component:t.createElement(k,{id:r,message:e,className:m,clickable:c||d,position:g,baseOffsetX:h,baseOffsetY:N,render:F,theme:U,zIndex:B||void 0,loading:M,onClick:Q})};if(L?w.unshift(tt):w.push(tt),A)for(var et=w.length-A,nt=0;nt<et;nt++)S(w[nt].id,J);return I(),{close:function(){return S(r,J)},updateDuration:function(t){void 0===t&&(t=Z),$(t)},update:function(n,o){var i,a,s=w.findIndex((function(t){return t.id===r})),l=E(n)?n.duration:o;if(w[s]){var u=null!==(i=E(n)?n.message:n)&&void 0!==i?i:e,f=!!E(n)&&(null!==(a=n.loading)&&void 0!==a?a:M),_=E(n)?n.theme:U;w[s].message=u,w[s].component=t.createElement(k,{id:r,message:u,className:m,clickable:c||d,position:g,baseOffsetX:h,baseOffsetY:N,render:F,theme:_,loading:f,onClick:Q})}I(),void 0!==l&&$(l)}}}exports.Themes={DARK:"dark",LIGHT:"light",SUCCESS:"success",INFO:"info",WARNING:"warning",FAILURE:"failure",PLAIN:"plain",FROSTED_GLASS:"frosted-glass",PINK_DAWN:"pink-dawn",CHROMA:"chroma",BLUE_DUSK:"blue-dusk",OCEAN_WAVE:"ocean-wave"},exports.clearToasts=function(){w.forEach((function(t){return t.isExit=!0})),I()},exports.createToast=function(t){var e=f();return function(n,i){if("number"==typeof i)return j(n,{toastInstanceId:e,duration:i||t.duration});if(void 0===i||"object"==typeof i)return j(n,o(o({toastInstanceId:e},t),i));throw new Error("Invalid durationOrOptions type")}},exports.default=function(t,e){return j(t,"number"==typeof e||null===e?{duration:e}:e)},exports.toastConfig=function(t){_()&&(t.theme&&(T.theme=t.theme),t.duration&&(T.duration=t.duration),t.className&&(T.className=t.className),t.position&&C(t.position)&&(T.position=t.position),t.clickClosable&&(T.clickClosable=t.clickClosable),t.render&&(T.render=t.render),t.maxVisibleToasts&&(T.maxVisibleToasts=t.maxVisibleToasts),t.isReversedOrder&&(T.isReversedOrder=t.isReversedOrder),null!=t.zIndex&&(T.zIndex=t.zIndex),null!=t.offsetX&&(T.offsetX=t.offsetX),null!=t.offsetY&&(T.offsetY=t.offsetY),null!=t.gap&&(T.gap=t.gap))}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");function e(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var n=e(require("react-dom")),o=function(){return o=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)};var i={toast_container:"style_toast_container__DT-ei","toast-message":"style_toast-message__-UN8x","top-center":"style_top-center__zZFy4","bottom-center":"style_bottom-center__NH15O",center:"style_center__GLmmM","toast-content":"style_toast-content__jaj36","toast-theme-content":"style_toast-theme-content__JPkou",clickable:"style_clickable__F3Zx7",loading:"style_loading__tn5sw","spinner-wrap":"style_spinner-wrap__kOodK",spinner:"style_spinner__mu5OS",spin:"style_spin__Ez3u3"};!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&o.firstChild?o.insertBefore(i,o.firstChild):o.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}("#style_toast_container__DT-ei * {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n.style_toast-message__-UN8x {\n opacity: 0;\n position: fixed;\n z-index: 1000;\n width: -webkit-max-content;\n width: -moz-max-content;\n width: max-content;\n max-width: 90%;\n -webkit-transition: opacity 0.3s, -webkit-transform 0.3s;\n transition: opacity 0.3s, -webkit-transform 0.3s;\n transition: opacity 0.3s, transform 0.3s;\n transition: opacity 0.3s, transform 0.3s, -webkit-transform 0.3s;\n}\n.style_top-center__zZFy4,\n.style_bottom-center__NH15O,\n.style_center__GLmmM {\n left: 50%;\n}\n.style_toast-message__-UN8x.toast-enter-active,\n.style_toast-message__-UN8x.toast-appear-active {\n opacity: 1;\n}\n.style_toast-message__-UN8x.toast-exit-active {\n opacity: 0;\n}\n.style_toast-content__jaj36 {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n.style_toast-theme-content__JPkou {\n -webkit-transition: all 0.2s;\n transition: all 0.2s;\n}\n.style_clickable__F3Zx7 {\n cursor: pointer;\n}\n.style_loading__tn5sw .style_spinner-wrap__kOodK {\n visibility: visible;\n opacity: 1;\n width: 1.1em;\n margin-right: 12px;\n}\n.style_spinner-wrap__kOodK {\n display: inline-block;\n visibility: hidden;\n opacity: 0;\n width: 0;\n margin-right: 0;\n}\n.style_spinner__mu5OS {\n display: block;\n overflow: hidden;\n width: 1.1em;\n height: 1.1em;\n border: 2px solid rgba(255, 255, 255, 0.3);\n border-radius: 50%;\n border-top-color: #fff;\n vertical-align: middle;\n text-indent: -99999px;\n -webkit-animation: style_spin__Ez3u3 1s ease-in-out infinite;\n animation: style_spin__Ez3u3 1s ease-in-out infinite;\n}\n@-webkit-keyframes style_spin__Ez3u3 {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@keyframes style_spin__Ez3u3 {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n");var r,a=o({},n),s=a.version,l=a.render;a.unmountComponentAtNode;try{Number((s||"").split(".")[0])>=18&&a.createRoot&&(r=a.createRoot)}catch(t){}function c(t){var e=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;e&&"object"==typeof e&&(e.usingClientEntryPoint=t)}var u="__rc_react_root__";function d(t,e){null==r?function(t,e){l(t,e)}(t,e):function(t,e){c(!0);var n=e[u]||r(e);c(!1),n.render(t),e[u]=n}(t,e)}var f=function(){return Date.now()+Math.floor(1e16*Math.random())},_=function(){return"undefined"!=typeof window},p=function(t,e){var n=t.replace(/[rgb(]|[)]/g,"").split(",").map((function(t){return t.trim()})),o=n[0],i=n[1],r=n[2];return"rgba(".concat(o,", ").concat(i,", ").concat(r,", ").concat(e,")")},m=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.filter(Boolean).join(" ")},v=2147483647,b={BOTTOM_LEFT:"bottom-left",BOTTOM_CENTER:"bottom-center",BOTTOM_RIGHT:"bottom-right",TOP_LEFT:"top-left",TOP_CENTER:"top-center",TOP_RIGHT:"top-right",CENTER:"center"};function g(){return g=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},g.apply(this,arguments)}var y={"toast-blue-dusk":"_toast-blue-dusk_pnidt_1","toast-chroma":"_toast-chroma_1u0sn_1","toast-dark":"_toast-dark_1uck5_1","toast-failure":"_toast-failure_1xuna_1","toast-frosted-glass":"_toast-frosted-glass_lv9sk_1","toast-frosted-glass-wrapper":"_toast-frosted-glass-wrapper_lv9sk_6","toast-info":"_toast-info_v91zz_1","toast-light":"_toast-light_1t8t0_1","toast-moonlight":"_toast-moonlight_128j9_1","toast-ocean-wave":"_toast-ocean-wave_1cgng_1","toast-pink-dawn":"_toast-pink-dawn_13jqk_1","toast-plain":"_toast-plain_11plr_1","toast-success":"_toast-success_1dljs_1","toast-sunset":"_toast-sunset_1tanv_1","toast-warning":"_toast-warning_ohu7r_1"},h="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function x(e){var n=e.color,o=n&&p(n,.3);return t.createElement("span",{className:i["spinner-wrap"]},t.createElement("span",{className:i.spinner,style:{border:"2px solid ".concat(o),borderTopColor:n}},"loading"))}function E(e){var n=e.id,o=e.message,r=e.className,a=e.clickable,s=e.position,l=e.isExit,c=e.render,u=e.theme,d=e.offsetX,f=e.offsetY,_=e.baseOffsetX,p=e.baseOffsetY,v=e.zIndex,E=e.loading,k=e.onClick,w=e._onEnter,O=t.useRef(null),T=null==s?void 0:s.includes("top"),C=null==s?void 0:s.includes("bottom"),N=null==s?void 0:s.includes("right"),I=null==s?void 0:s.includes("left"),S=null==s?void 0:s.includes("-center"),j=s===b.CENTER,R=t.useState(!1),z=R[0],A=R[1],L=t.useState({transform:"translate(".concat(d,", ").concat(j?"calc(50% - 20px)":"".concat(parseInt(f||"0")+20*(T?-1:1),"px"),")")}),P=L[0],D=L[1],F=t.useState(!!E),U=F[0],Y=F[1],X=t.useState(),B=X[0],M=X[1],H=j?"50%":T?p:void 0,G=C?p:void 0,V=N?_:void 0,K=S||j?"50%":I?_:void 0;h((function(){var t="translate(".concat(d,", ").concat(f,")");D({top:H,right:V,bottom:G,left:K,zIndex:v,transform:t,WebkitTransform:t})}),[d,f,v,H,V,G,K]),h((function(){var t;if(null!=(null===(t=O.current)||void 0===t?void 0:t.clientHeight)&&!z){var e=O.current.clientWidth,n=O.current.clientHeight;O.current&&(null==w||w({target:O.current,width:e,height:n})),A(!0)}}),[z,w]),h((function(){if(O.current){var t=O.current.querySelector("span"),e=t&&window.getComputedStyle(t).color;e&&M(e)}}),[]),h((function(){if(E instanceof Promise)return Y(!0),void E.then((function(){Y(!1)}));Y(!!E)}),[E]);var W=m(i["toast-message"],i[s||"bottom-center"],y["toast-".concat(u,"-wrapper")],z?"toast-enter-active":"",l?"toast-exit-active":"",U?i.loading:""),q=m(i["toast-content"],a?i.clickable:"",!c&&y["toast-".concat(u)],!c&&u?i["toast-theme-content"]:"",u||"",r),Z={onClick:k,tabIndex:0,role:"button"};return t.createElement("div",{ref:O,id:n.toString(),className:W,style:P},t.createElement("div",g({className:q},a&&Z),U&&t.createElement(x,{color:B}),c?c(o):o))}var k=function(t){return!(!t||"object"!=typeof t)&&("message"in t||"duration"in t||"loading"in t)},w=[],O=function(){var t,e,n,o=_()&&document.getElementById(i.toast_container);_()&&!o&&(e=i.toast_container,(n=document.createElement("div")).setAttribute("id",e),t=n,document.body.appendChild(t)),w&&Array.isArray(w)||(w=[])},T={duration:3e3,className:"",position:"bottom-center",offsetX:30,offsetY:30,gap:10,clickClosable:!1,render:null,maxVisibleToasts:null,isReversedOrder:!1,theme:null,zIndex:null},C=function(t){var e=Object.values(b);if(!e.includes(t))throw new Error("Invalid position value. Expected one of ".concat(e.join(", ")," but got ").concat(t));return!0};function N(){return t.createElement(t.Fragment,null,w.map((function(e){var n=e.position.includes("top")?function(t){for(var e=[],n=t.length-1;n>=0;n--)e.push(t[n]);return e}(w):w,o=n.findIndex((function(t){return t.id===e.id})),i=n.slice(o+1).filter((function(t){return t.position===e.position&&!t.isExit})),r=i.reduce((function(t,n){var o;return t+(null!==(o=n.height)&&void 0!==o?o:0)+e.gap}),0),a=e.position.includes("left")||e.position.includes("right")?"0%":"-50%",s=r*(e.position.includes("top")?1:-1),l="center"===e.position?"calc(-50% - ".concat(-1*s,"px)"):"".concat(s,"px");return t.createElement(t.Fragment,{key:e.id},t.cloneElement(e.component,{isExit:e.isExit,offsetX:a,offsetY:l,_onEnter:function(t){return function(t,e){w.forEach((function(n){n.id===t.id&&(n.startCloseTimer(),n.height=e.height)})),I()}(e,t)}}))})))}var I=function(){if(_()){var e=document.getElementById(i.toast_container);e&&d(t.createElement(N,null),e)}};function S(t,e){var n,o=w.findIndex((function(e){return e.id===t}));w[o]&&(w[o].isExit=!0),null===(n=e.onCloseStart)||void 0===n||n.call(e),I(),setTimeout((function(){var n;w=w.filter((function(e){return e.id!==t})),null===(n=e.onClose)||void 0===n||n.call(e),I()}),300)}function j(e,n){var i;if(!_())return{close:function(){return null},updateDuration:function(){return null},update:function(){return null}};var r=f(),a=n||{},s=a.duration,l=a.clickable,c=void 0!==l&&l,u=a.clickClosable,d=void 0===u?T.clickClosable:u,p=a.className,m=void 0===p?T.className:p,b=a.position,g=void 0===b?T.position:b,y=a.offsetX,h=void 0===y?T.offsetX:y,x=a.offsetY,N=void 0===x?T.offsetY:x,j=a.gap,R=void 0===j?T.gap:j,z=a.maxVisibleToasts,A=void 0===z?T.maxVisibleToasts:z,L=a.isReversedOrder,P=void 0===L?T.isReversedOrder:L,D=a.render,F=void 0===D?T.render:D,U=a.theme,Y=void 0===U?T.theme:U,X=a.zIndex,B=void 0===X?T.zIndex:X,M=a.loading,H=a.onClick,G=void 0===H?void 0:H,V=a.onClose,K=void 0===V?void 0:V,W=a.onCloseStart,q=void 0===W?void 0:W,Z=void 0===s?T.duration:s,J={onClose:K,onCloseStart:q};C(g),O();var Q=function(t){d&&(i&&clearTimeout(i),S(r,J)),null==G||G(t)},$=function(t,e){void 0===t&&(t=Z),null===t||0===t||t>v||(i&&clearTimeout(i),i=window.setTimeout((function(){S(r,o(o({},J),{onCloseStart:function(){var t;null==e||e(),null===(t=J.onClose)||void 0===t||t.call(J)}}))}),t))},tt={id:r,message:e,position:g,startCloseTimer:$,gap:R,component:t.createElement(E,{id:r,message:e,className:m,clickable:c||d,position:g,baseOffsetX:h,baseOffsetY:N,render:F,theme:Y,zIndex:B||void 0,loading:M,onClick:Q})};if(P?w.unshift(tt):w.push(tt),A)for(var et=w.length-A,nt=0;nt<et;nt++)S(w[nt].id,J);return I(),{close:function(){return S(r,J)},updateDuration:function(t){void 0===t&&(t=Z),$(t)},update:function(n,o){var i,a,s=w.findIndex((function(t){return t.id===r})),l=k(n)?n.duration:o;if(w[s]){var u=null!==(i=k(n)?n.message:n)&&void 0!==i?i:e,f=!!k(n)&&(null!==(a=n.loading)&&void 0!==a?a:M),_=k(n)?n.theme:Y;w[s].message=u,w[s].component=t.createElement(E,{id:r,message:u,className:m,clickable:c||d,position:g,baseOffsetX:h,baseOffsetY:N,render:F,theme:_,loading:f,onClick:Q})}I(),void 0!==l&&$(l)}}}exports.Themes={DARK:"dark",LIGHT:"light",SUCCESS:"success",INFO:"info",WARNING:"warning",FAILURE:"failure",PLAIN:"plain",FROSTED_GLASS:"frosted-glass",PINK_DAWN:"pink-dawn",CHROMA:"chroma",BLUE_DUSK:"blue-dusk",OCEAN_WAVE:"ocean-wave",SUNSET:"sunset",MOONLIGHT:"moonlight"},exports.clearToasts=function(){w.forEach((function(t){return t.isExit=!0})),I()},exports.createToast=function(t){var e=f();return function(n,i){if("number"==typeof i)return j(n,{toastInstanceId:e,duration:i||t.duration});if(void 0===i||"object"==typeof i)return j(n,o(o({toastInstanceId:e},t),i));throw new Error("Invalid durationOrOptions type")}},exports.default=function(t,e){return j(t,"number"==typeof e||null===e?{duration:e}:e)},exports.toastConfig=function(t){_()&&(t.theme&&(T.theme=t.theme),t.duration&&(T.duration=t.duration),t.className&&(T.className=t.className),t.position&&C(t.position)&&(T.position=t.position),t.clickClosable&&(T.clickClosable=t.clickClosable),t.render&&(T.render=t.render),t.maxVisibleToasts&&(T.maxVisibleToasts=t.maxVisibleToasts),t.isReversedOrder&&(T.isReversedOrder=t.isReversedOrder),null!=t.zIndex&&(T.zIndex=t.zIndex),null!=t.offsetX&&(T.offsetX=t.offsetX),null!=t.offsetY&&(T.offsetY=t.offsetY),null!=t.gap&&(T.gap=t.gap))}; | ||
//# sourceMappingURL=index.js.map |
@@ -24,2 +24,4 @@ export declare const SET_TIMEOUT_MAX = 2147483647; | ||
readonly OCEAN_WAVE: "ocean-wave"; | ||
readonly SUNSET: "sunset"; | ||
readonly MOONLIGHT: "moonlight"; | ||
}; |
{ | ||
"name": "react-simple-toasts", | ||
"version": "5.8.3", | ||
"description": "Lightweight, user-friendly toast message library for React applications. Add beautiful notifications to your React apps.", | ||
"version": "5.9.0", | ||
"description": "Instant, lightweight toast notifications for React. No providers or containers needed.", | ||
"author": "almond-bongbong", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/almond-bongbong/react-simple-toasts", |
# React Simple Toasts | ||
React Simple Toasts is a lightweight, user-friendly toast message library for React applications. Add beautiful notifications to your React apps. | ||
Instant, lightweight toast notifications for React. No providers or containers needed. 🍃 | ||
[![NPM](https://img.shields.io/npm/v/react-simple-toasts.svg)](https://www.npmjs.com/package/react-simple-toasts) | ||
@@ -29,3 +28,3 @@ ![NPM Downloads](https://img.shields.io/npm/dw/react-simple-toasts.svg) | ||
```jsx | ||
import toast from 'react-simple-toasts'; | ||
import toast, { toastConfig } from 'react-simple-toasts'; | ||
import 'react-simple-toasts/dist/theme/dark.css'; // choose your theme | ||
@@ -32,0 +31,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
42649
29
372
0
66