react-toastify
Advanced tools
Comparing version 7.0.0 to 7.0.1
@@ -146,2 +146,5 @@ 'use strict'; | ||
var baseClassName = React.useRef(); | ||
var animationStep = React.useRef(0 | ||
/* Enter */ | ||
); | ||
React.useLayoutEffect(function () { | ||
@@ -154,3 +157,3 @@ onEnter(); | ||
var onEnter = function onEnter() { | ||
function onEnter() { | ||
var node = nodeRef.current; | ||
@@ -160,21 +163,29 @@ baseClassName.current = node.className; | ||
node.addEventListener('animationend', onEntered); | ||
}; | ||
} | ||
var onEntered = function onEntered() { | ||
function onEntered() { | ||
var node = nodeRef.current; | ||
node.removeEventListener('animationend', onEntered); | ||
node.className = baseClassName.current; | ||
}; | ||
var onExit = function onExit() { | ||
if (animationStep.current === 0 | ||
/* Enter */ | ||
) { | ||
node.className = baseClassName.current; | ||
} | ||
} | ||
function onExit() { | ||
animationStep.current = 1 | ||
/* Exit */ | ||
; | ||
var node = nodeRef.current; | ||
node.className += " " + exitClassName; | ||
node.addEventListener('animationend', onExited); | ||
}; | ||
} | ||
var onExited = function onExited() { | ||
function onExited() { | ||
var node = nodeRef.current; | ||
node.removeEventListener('animationend', onExited); | ||
collapse ? collapseToast(node, done, collapseDuration) : done(); | ||
}; | ||
} | ||
@@ -181,0 +192,0 @@ return React__default.createElement(React__default.Fragment, null, children); |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),o=e(require("clsx")),r=require("react-dom");function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function a(e){return"number"==typeof e&&!isNaN(e)}function i(e){return"boolean"==typeof e}function c(e){return"string"==typeof e}function u(e){return"function"==typeof e}function l(e){return c(e)||u(e)?e:null}function d(e){return 0===e||e}var f=!("undefined"==typeof window||!window.document||!window.document.createElement);function p(e){return t.isValidElement(e)||c(e)||u(e)||a(e)}var m={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},g={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default",DARK:"dark"};function v(e,t,n){void 0===n&&(n=300);var o=e.scrollHeight,r=e.style;requestAnimationFrame((function(){r.minHeight="initial",r.height=o+"px",r.transition="all "+n+"ms",requestAnimationFrame((function(){r.height="0",r.padding="0",r.margin="0",setTimeout(t,n)}))}))}function y(e){var o=e.enter,r=e.exit,s=e.appendPosition,a=void 0!==s&&s,i=e.collapse,c=void 0===i||i,u=e.collapseDuration,l=void 0===u?300:u;return function(e){var s=e.children,i=e.position,u=e.preventExitTransition,d=e.done,f=e.nodeRef,p=e.isIn,m=a?o+"--"+i:o,g=a?r+"--"+i:r,y=t.useRef();t.useLayoutEffect((function(){T()}),[]),t.useEffect((function(){p||(u?E():b())}),[p]);var T=function(){var e=f.current;y.current=e.className,e.className+=" "+m,e.addEventListener("animationend",h)},h=function e(){var t=f.current;t.removeEventListener("animationend",e),t.className=y.current},b=function(){var e=f.current;e.className+=" "+g,e.addEventListener("animationend",E)},E=function e(){var t=f.current;t.removeEventListener("animationend",e),c?v(t,d,l):d()};return n.createElement(n.Fragment,null,s)}}var T={list:new Map,emitQueue:new Map,on:function(e,t){return this.list.has(e)||this.list.set(e,[]),this.list.get(e).push(t),this},off:function(e,t){if(t){var n=this.list.get(e).filter((function(e){return e!==t}));return this.list.set(e,n),this}return this.list.delete(e),this},cancelEmit:function(e){var t=this.emitQueue.get(e);return t&&(t.forEach(clearTimeout),this.emitQueue.delete(e)),this},emit:function(e){for(var t=this,n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];this.list.has(e)&&this.list.get(e).forEach((function(n){var r=setTimeout((function(){n.apply(void 0,o)}),0);t.emitQueue.has(e)||t.emitQueue.set(e,[]),t.emitQueue.get(e).push(r)}))}};function h(e,n){void 0===n&&(n=!1);var o=t.useRef(e);return t.useEffect((function(){n&&(o.current=e)})),o.current}function b(e,t){switch(t.type){case 0:return[].concat(e,[t.toastId]).filter((function(e){return e!==t.staleId}));case 1:return d(t.toastId)?e.filter((function(e){return e!==t.toastId})):[]}}function E(e){var n=t.useReducer((function(e){return e+1}),0)[1],o=t.useReducer(b,[]),r=o[0],s=o[1],f=t.useRef(null),m=h(0),g=h([]),v=h({}),y=h({toastKey:1,displayedToast:0,props:e,containerId:null,isToastActive:E,getToast:function(e){return v[e]||null}});function E(e){return-1!==r.indexOf(e)}function O(e){var t=e.containerId,n=y.props;n.limit&&(!t||y.containerId===t&&n.enableMultiContainer)&&(m-=g.length,g=[])}function C(e){var t=g.length;if((m=d(e)?m-1:m-y.displayedToast)<0&&(m=0),t>0){var n=d(e)?1:y.props.limit;if(1===t||1===n)y.displayedToast++,I();else{var o=n>t?t:n;y.displayedToast=o;for(var r=0;r<o;r++)I()}}s({type:1,toastId:e})}function I(){var e=g.shift(),t=e.toastContent,n=e.toastProps,o=e.staleId;setTimeout((function(){x(t,n,o)}),500)}function _(e,o){var r=o.delay,s=o.staleId,d=function(e,t){if(null==e)return{};var n,o,r={},s=Object.keys(e);for(o=0;o<s.length;o++)t.indexOf(n=s[o])>=0||(r[n]=e[n]);return r}(o,["delay","staleId"]);if(p(e)&&(T=d,!(!f.current||y.props.enableMultiContainer&&T.containerId!==y.props.containerId||v[T.toastId]&&null==T.updateId))){var T,h=d.toastId,b=y.props,E=function(){return C(h)},O=null==d.updateId;O&&m++;var I,_,N={toastId:h,updateId:d.updateId,isIn:!1,key:d.key||y.toastKey++,type:d.type,closeToast:E,closeButton:d.closeButton,rtl:b.rtl,position:d.position||b.position,transition:d.transition||b.transition,className:l(d.className||b.toastClassName),bodyClassName:l(d.bodyClassName||b.bodyClassName),style:d.style||b.toastStyle,bodyStyle:d.bodyStyle||b.bodyStyle,onClick:d.onClick||b.onClick,pauseOnHover:i(d.pauseOnHover)?d.pauseOnHover:b.pauseOnHover,pauseOnFocusLoss:i(d.pauseOnFocusLoss)?d.pauseOnFocusLoss:b.pauseOnFocusLoss,draggable:i(d.draggable)?d.draggable:b.draggable,draggablePercent:a(d.draggablePercent)?d.draggablePercent:b.draggablePercent,draggableDirection:d.draggableDirection||b.draggableDirection,closeOnClick:i(d.closeOnClick)?d.closeOnClick:b.closeOnClick,progressClassName:l(d.progressClassName||b.progressClassName),progressStyle:d.progressStyle||b.progressStyle,autoClose:(I=d.autoClose,_=b.autoClose,!1===I||a(I)&&I>0?I:_),hideProgressBar:i(d.hideProgressBar)?d.hideProgressBar:b.hideProgressBar,progress:d.progress,role:c(d.role)?d.role:b.role,deleteToast:function(){!function(e){delete v[e],n()}(h)}};u(d.onOpen)&&(N.onOpen=d.onOpen),u(d.onClose)&&(N.onClose=d.onClose),"y"===N.draggableDirection&&80===N.draggablePercent&&(N.draggablePercent*=1.5);var R=b.closeButton;!1===d.closeButton||p(d.closeButton)?R=d.closeButton:!0===d.closeButton&&(R=!p(b.closeButton)||b.closeButton),N.closeButton=R;var P=e;t.isValidElement(e)&&!c(e.type)?P=t.cloneElement(e,{closeToast:E,toastProps:N}):u(e)&&(P=e({closeToast:E,toastProps:N})),b.limit&&b.limit>0&&m>b.limit&&O?g.push({toastContent:P,toastProps:N,staleId:s}):a(r)&&r>0?setTimeout((function(){x(P,N,s)}),r):x(P,N,s)}}function x(e,t,n){var o=t.toastId;n&&delete v[n],v[o]={content:e,props:t},s({type:0,toastId:o,staleId:n})}return t.useEffect((function(){return y.containerId=e.containerId,T.cancelEmit(3).on(0,_).on(1,(function(e){return f.current&&C(e)})).on(5,O).emit(2,y),function(){return T.emit(3,y)}}),[]),t.useEffect((function(){y.isToastActive=E,y.displayedToast=r.length,T.emit(4,r.length,e.containerId)}),[r]),t.useEffect((function(){y.props=e})),{getToastToRender:function(t){for(var n={},o=e.newestOnTop?Object.keys(v).reverse():Object.keys(v),r=0;r<o.length;r++){var s=v[o[r]],a=s.props.position;n[a]||(n[a]=[]),n[a].push(s)}return Object.keys(n).map((function(e){return t(e,n[e])}))},collection:v,containerRef:f,isToastActive:E}}function O(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientX:e.clientX}function C(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientY:e.clientY}function I(e){var n=t.useState(!0),o=n[0],r=n[1],s=t.useState(!1),a=s[0],i=s[1],c=t.useRef(null),l=h({start:0,x:0,y:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,boundingRect:null}),d=h(e,!0),f=e.autoClose,p=e.pauseOnHover,m=e.closeToast,g=e.onClick,v=e.closeOnClick;function y(t){if(e.draggable){var n=c.current;l.canCloseOnClick=!0,l.canDrag=!0,l.boundingRect=n.getBoundingClientRect(),n.style.transition="",l.x=O(t.nativeEvent),l.y=C(t.nativeEvent),"x"===e.draggableDirection?(l.start=l.x,l.removalDistance=n.offsetWidth*(e.draggablePercent/100)):(l.start=l.y,l.removalDistance=n.offsetHeight*(e.draggablePercent/100))}}function T(){if(l.boundingRect){var t=l.boundingRect;e.pauseOnHover&&l.x>=t.left&&l.x<=t.right&&l.y>=t.top&&l.y<=t.bottom?E():b()}}function b(){r(!0)}function E(){r(!1)}function I(t){if(l.canDrag){t.preventDefault();var n=c.current;o&&E(),l.x=O(t),l.y=C(t),l.delta="x"===e.draggableDirection?l.x-l.start:l.y-l.start,l.start!==l.x&&(l.canCloseOnClick=!1),n.style.transform="translate"+e.draggableDirection+"("+l.delta+"px)",n.style.opacity=""+(1-Math.abs(l.delta/l.removalDistance))}}function _(){var t=c.current;if(l.canDrag){if(l.canDrag=!1,Math.abs(l.delta)>l.removalDistance)return i(!0),void e.closeToast();t.style.transition="transform 0.2s, opacity 0.2s",t.style.transform="translate"+e.draggableDirection+"(0)",t.style.opacity="1"}}t.useEffect((function(){return u(e.onOpen)&&e.onOpen(t.isValidElement(e.children)&&e.children.props),function(){u(d.onClose)&&d.onClose(t.isValidElement(d.children)&&d.children.props)}}),[]),t.useEffect((function(){return e.draggable&&(document.addEventListener("mousemove",I),document.addEventListener("mouseup",_),document.addEventListener("touchmove",I),document.addEventListener("touchend",_)),function(){e.draggable&&(document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",I),document.removeEventListener("touchend",_))}}),[e.draggable]),t.useEffect((function(){return e.pauseOnFocusLoss&&(document.hasFocus()||E(),window.addEventListener("focus",b),window.addEventListener("blur",E)),function(){e.pauseOnFocusLoss&&(window.removeEventListener("focus",b),window.removeEventListener("blur",E))}}),[e.pauseOnFocusLoss]);var x={onMouseDown:y,onTouchStart:y,onMouseUp:T,onTouchEnd:T};return f&&p&&(x.onMouseEnter=E,x.onMouseLeave=b),v&&(x.onClick=function(e){g&&g(e),l.canCloseOnClick&&m()}),{playToast:b,pauseToast:E,isRunning:o,preventExitTransition:a,toastRef:c,eventHandlers:x}}function _(e){var n=e.closeToast,o=e.ariaLabel;return t.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+e.type,type:"button",onClick:function(e){e.stopPropagation(),n(e)},"aria-label":void 0===o?"close":o},t.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},t.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}function x(e){var n,r,a=e.closeToast,i=e.type,c=e.className,l=e.controlledProgress,d=e.progress,f=e.rtl,p=e.isIn,m=s({},e.style,{animationDuration:e.delay+"ms",animationPlayState:e.isRunning?"running":"paused",opacity:e.hide?0:1});l&&(m.transform="scaleX("+d+")");var g=o("Toastify__progress-bar",l?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar--"+i,((n={})["Toastify__progress-bar--rtl"]=f,n)),v=u(c)?c({rtl:f,type:i,defaultClassName:g}):o(g,c),y=((r={})[l&&d>=1?"onTransitionEnd":"onAnimationEnd"]=l&&d<1?null:function(){p&&a()},r);return t.createElement("div",Object.assign({role:"progressbar",className:v,style:m},y))}x.defaultProps={type:g.DEFAULT,hide:!1};var N=function(e){var n,r=I(e),s=r.isRunning,a=r.preventExitTransition,i=r.toastRef,c=r.eventHandlers,l=e.closeButton,d=e.children,f=e.autoClose,p=e.onClick,m=e.type,g=e.hideProgressBar,v=e.closeToast,y=e.transition,T=e.position,h=e.className,b=e.style,E=e.bodyClassName,O=e.bodyStyle,C=e.progressClassName,_=e.progressStyle,N=e.updateId,R=e.role,P=e.progress,L=e.rtl,k=e.toastId,w=e.deleteToast,D=e.isIn,B=o("Toastify__toast","Toastify__toast--"+m,((n={})["Toastify__toast--rtl"]=L,n)),S=u(h)?h({rtl:L,position:T,type:m,defaultClassName:B}):o(B,h),F=!!P;return t.createElement(y,{isIn:D,done:w,position:T,preventExitTransition:a,nodeRef:i},t.createElement("div",Object.assign({id:k,onClick:p,className:S},c,{style:b,ref:i}),t.createElement("div",Object.assign({},D&&{role:R},{className:u(E)?E({type:m}):o("Toastify__toast-body",E),style:O}),d),function(e){if(e){var n={closeToast:v,type:m};return u(e)?e(n):t.isValidElement(e)?t.cloneElement(e,n):void 0}}(l),(f||F)&&t.createElement(x,Object.assign({},N&&!F?{key:"pb-"+N}:{},{rtl:L,delay:f,isRunning:s,isIn:D,closeToast:v,hide:g,type:m,style:_,className:C,controlledProgress:F,progress:P}))))},R=y({enter:"Toastify--animate Toastify__bounce-enter",exit:"Toastify--animate Toastify__bounce-exit",appendPosition:!0}),P=y({enter:"Toastify--animate Toastify__slide-enter",exit:"Toastify--animate Toastify__slide-exit",appendPosition:!0}),L=y({enter:"Toastify--animate Toastify__zoom-enter",exit:"Toastify--animate Toastify__zoom-exit"}),k=y({enter:"Toastify--animate Toastify__flip-enter",exit:"Toastify--animate Toastify__flip-exit"}),w=function(e){var n=E(e),r=n.isToastActive,a=e.className,i=e.style,c=e.rtl;function d(e){var t,n=o("Toastify__toast-container","Toastify__toast-container--"+e,((t={})["Toastify__toast-container--rtl"]=c,t));return u(a)?a({position:e,rtl:c,defaultClassName:n}):o(n,l(a))}return t.createElement("div",{ref:n.containerRef,className:"Toastify",id:e.containerId},(0,n.getToastToRender)((function(e,n){var o=0===n.length?s({},i,{pointerEvents:"none"}):s({},i);return t.createElement("div",{className:d(e),style:o,key:"container-"+e},n.map((function(e){var n=e.content,o=e.props;return t.createElement(N,Object.assign({},o,{isIn:r(o.toastId),key:"toast-"+o.key,closeButton:!0===o.closeButton?_:o.closeButton}),n)})))})))};w.defaultProps={position:m.TOP_RIGHT,transition:R,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:_,pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,draggableDirection:"x",role:"alert"};var D,B,S,F=new Map,A=[],M=!1;function H(){return Math.random().toString(36).substr(2,9)}function j(e){return e&&(c(e.toastId)||a(e.toastId))?e.toastId:H()}function Q(e,n){return F.size>0?T.emit(0,e,n):(A.push({content:e,options:n}),M&&f&&(M=!1,B=document.createElement("div"),document.body.appendChild(B),r.render(t.createElement(w,Object.assign({},S)),B))),n.toastId}function U(e,t){return s({},t,{type:t&&t.type||e,toastId:j(t)})}var q=function(e){return function(t,n){return Q(t,U(e,n))}},z=function(e,t){return Q(e,U(g.DEFAULT,t))};z.success=q(g.SUCCESS),z.info=q(g.INFO),z.error=q(g.ERROR),z.warning=q(g.WARNING),z.dark=q(g.DARK),z.warn=z.warning,z.dismiss=function(e){return T.emit(1,e)},z.clearWaitingQueue=function(e){return void 0===e&&(e={}),T.emit(5,e)},z.isActive=function(e){var t=!1;return F.forEach((function(n){n.isToastActive&&n.isToastActive(e)&&(t=!0)})),t},z.update=function(e,t){void 0===t&&(t={}),setTimeout((function(){var n=function(e,t){var n=F.get(t.containerId||D);return n?n.getToast(e):null}(e,t);if(n){var o=n.content,r=s({},n.props,t,{toastId:t.toastId||e,updateId:H()});r.toastId!==e&&(r.staleId=e);var a=r.render||o;delete r.render,Q(a,r)}}),0)},z.done=function(e){z.update(e,{progress:1})},z.onChange=function(e){return u(e)&&T.on(4,e),function(){u(e)&&T.off(4,e)}},z.configure=function(e){void 0===e&&(e={}),M=!0,S=e},z.POSITION=m,z.TYPE=g,T.on(2,(function(e){F.set(D=e.containerId||e,e),A.forEach((function(e){T.emit(0,e.content,e.options)})),A=[]})).on(3,(function(e){F.delete(e.containerId||e),0===F.size&&T.off(0).off(1).off(5),f&&B&&document.body.removeChild(B)})),exports.Bounce=R,exports.Flip=k,exports.Slide=P,exports.ToastContainer=w,exports.Zoom=L,exports.collapseToast=v,exports.cssTransition=y,exports.toast=z,exports.useToast=I,exports.useToastContainer=E; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),o=e(require("clsx")),r=require("react-dom");function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function a(e){return"number"==typeof e&&!isNaN(e)}function i(e){return"boolean"==typeof e}function c(e){return"string"==typeof e}function u(e){return"function"==typeof e}function l(e){return c(e)||u(e)?e:null}function d(e){return 0===e||e}var f=!("undefined"==typeof window||!window.document||!window.document.createElement);function p(e){return t.isValidElement(e)||c(e)||u(e)||a(e)}var m={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},g={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default",DARK:"dark"};function v(e,t,n){void 0===n&&(n=300);var o=e.scrollHeight,r=e.style;requestAnimationFrame((function(){r.minHeight="initial",r.height=o+"px",r.transition="all "+n+"ms",requestAnimationFrame((function(){r.height="0",r.padding="0",r.margin="0",setTimeout(t,n)}))}))}function y(e){var o=e.enter,r=e.exit,s=e.appendPosition,a=void 0!==s&&s,i=e.collapse,c=void 0===i||i,u=e.collapseDuration,l=void 0===u?300:u;return function(e){var s=e.children,i=e.position,u=e.preventExitTransition,d=e.done,f=e.nodeRef,p=e.isIn,m=a?o+"--"+i:o,g=a?r+"--"+i:r,y=t.useRef(),T=t.useRef(0);function h(){var e=f.current;e.removeEventListener("animationend",h),0===T.current&&(e.className=y.current)}function b(){var e=f.current;e.removeEventListener("animationend",b),c?v(e,d,l):d()}return t.useLayoutEffect((function(){var e;y.current=(e=f.current).className,e.className+=" "+m,e.addEventListener("animationend",h)}),[]),t.useEffect((function(){p||(u?b():function(){T.current=1;var e=f.current;e.className+=" "+g,e.addEventListener("animationend",b)}())}),[p]),n.createElement(n.Fragment,null,s)}}var T={list:new Map,emitQueue:new Map,on:function(e,t){return this.list.has(e)||this.list.set(e,[]),this.list.get(e).push(t),this},off:function(e,t){if(t){var n=this.list.get(e).filter((function(e){return e!==t}));return this.list.set(e,n),this}return this.list.delete(e),this},cancelEmit:function(e){var t=this.emitQueue.get(e);return t&&(t.forEach(clearTimeout),this.emitQueue.delete(e)),this},emit:function(e){for(var t=this,n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];this.list.has(e)&&this.list.get(e).forEach((function(n){var r=setTimeout((function(){n.apply(void 0,o)}),0);t.emitQueue.has(e)||t.emitQueue.set(e,[]),t.emitQueue.get(e).push(r)}))}};function h(e,n){void 0===n&&(n=!1);var o=t.useRef(e);return t.useEffect((function(){n&&(o.current=e)})),o.current}function b(e,t){switch(t.type){case 0:return[].concat(e,[t.toastId]).filter((function(e){return e!==t.staleId}));case 1:return d(t.toastId)?e.filter((function(e){return e!==t.toastId})):[]}}function E(e){var n=t.useReducer((function(e){return e+1}),0)[1],o=t.useReducer(b,[]),r=o[0],s=o[1],f=t.useRef(null),m=h(0),g=h([]),v=h({}),y=h({toastKey:1,displayedToast:0,props:e,containerId:null,isToastActive:E,getToast:function(e){return v[e]||null}});function E(e){return-1!==r.indexOf(e)}function O(e){var t=e.containerId,n=y.props;n.limit&&(!t||y.containerId===t&&n.enableMultiContainer)&&(m-=g.length,g=[])}function C(e){var t=g.length;if((m=d(e)?m-1:m-y.displayedToast)<0&&(m=0),t>0){var n=d(e)?1:y.props.limit;if(1===t||1===n)y.displayedToast++,I();else{var o=n>t?t:n;y.displayedToast=o;for(var r=0;r<o;r++)I()}}s({type:1,toastId:e})}function I(){var e=g.shift(),t=e.toastContent,n=e.toastProps,o=e.staleId;setTimeout((function(){x(t,n,o)}),500)}function _(e,o){var r=o.delay,s=o.staleId,d=function(e,t){if(null==e)return{};var n,o,r={},s=Object.keys(e);for(o=0;o<s.length;o++)t.indexOf(n=s[o])>=0||(r[n]=e[n]);return r}(o,["delay","staleId"]);if(p(e)&&(T=d,!(!f.current||y.props.enableMultiContainer&&T.containerId!==y.props.containerId||v[T.toastId]&&null==T.updateId))){var T,h=d.toastId,b=y.props,E=function(){return C(h)},O=null==d.updateId;O&&m++;var I,_,R={toastId:h,updateId:d.updateId,isIn:!1,key:d.key||y.toastKey++,type:d.type,closeToast:E,closeButton:d.closeButton,rtl:b.rtl,position:d.position||b.position,transition:d.transition||b.transition,className:l(d.className||b.toastClassName),bodyClassName:l(d.bodyClassName||b.bodyClassName),style:d.style||b.toastStyle,bodyStyle:d.bodyStyle||b.bodyStyle,onClick:d.onClick||b.onClick,pauseOnHover:i(d.pauseOnHover)?d.pauseOnHover:b.pauseOnHover,pauseOnFocusLoss:i(d.pauseOnFocusLoss)?d.pauseOnFocusLoss:b.pauseOnFocusLoss,draggable:i(d.draggable)?d.draggable:b.draggable,draggablePercent:a(d.draggablePercent)?d.draggablePercent:b.draggablePercent,draggableDirection:d.draggableDirection||b.draggableDirection,closeOnClick:i(d.closeOnClick)?d.closeOnClick:b.closeOnClick,progressClassName:l(d.progressClassName||b.progressClassName),progressStyle:d.progressStyle||b.progressStyle,autoClose:(I=d.autoClose,_=b.autoClose,!1===I||a(I)&&I>0?I:_),hideProgressBar:i(d.hideProgressBar)?d.hideProgressBar:b.hideProgressBar,progress:d.progress,role:c(d.role)?d.role:b.role,deleteToast:function(){!function(e){delete v[e],n()}(h)}};u(d.onOpen)&&(R.onOpen=d.onOpen),u(d.onClose)&&(R.onClose=d.onClose),"y"===R.draggableDirection&&80===R.draggablePercent&&(R.draggablePercent*=1.5);var N=b.closeButton;!1===d.closeButton||p(d.closeButton)?N=d.closeButton:!0===d.closeButton&&(N=!p(b.closeButton)||b.closeButton),R.closeButton=N;var P=e;t.isValidElement(e)&&!c(e.type)?P=t.cloneElement(e,{closeToast:E,toastProps:R}):u(e)&&(P=e({closeToast:E,toastProps:R})),b.limit&&b.limit>0&&m>b.limit&&O?g.push({toastContent:P,toastProps:R,staleId:s}):a(r)&&r>0?setTimeout((function(){x(P,R,s)}),r):x(P,R,s)}}function x(e,t,n){var o=t.toastId;n&&delete v[n],v[o]={content:e,props:t},s({type:0,toastId:o,staleId:n})}return t.useEffect((function(){return y.containerId=e.containerId,T.cancelEmit(3).on(0,_).on(1,(function(e){return f.current&&C(e)})).on(5,O).emit(2,y),function(){return T.emit(3,y)}}),[]),t.useEffect((function(){y.isToastActive=E,y.displayedToast=r.length,T.emit(4,r.length,e.containerId)}),[r]),t.useEffect((function(){y.props=e})),{getToastToRender:function(t){for(var n={},o=e.newestOnTop?Object.keys(v).reverse():Object.keys(v),r=0;r<o.length;r++){var s=v[o[r]],a=s.props.position;n[a]||(n[a]=[]),n[a].push(s)}return Object.keys(n).map((function(e){return t(e,n[e])}))},collection:v,containerRef:f,isToastActive:E}}function O(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientX:e.clientX}function C(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientY:e.clientY}function I(e){var n=t.useState(!0),o=n[0],r=n[1],s=t.useState(!1),a=s[0],i=s[1],c=t.useRef(null),l=h({start:0,x:0,y:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,boundingRect:null}),d=h(e,!0),f=e.autoClose,p=e.pauseOnHover,m=e.closeToast,g=e.onClick,v=e.closeOnClick;function y(t){if(e.draggable){var n=c.current;l.canCloseOnClick=!0,l.canDrag=!0,l.boundingRect=n.getBoundingClientRect(),n.style.transition="",l.x=O(t.nativeEvent),l.y=C(t.nativeEvent),"x"===e.draggableDirection?(l.start=l.x,l.removalDistance=n.offsetWidth*(e.draggablePercent/100)):(l.start=l.y,l.removalDistance=n.offsetHeight*(e.draggablePercent/100))}}function T(){if(l.boundingRect){var t=l.boundingRect;e.pauseOnHover&&l.x>=t.left&&l.x<=t.right&&l.y>=t.top&&l.y<=t.bottom?E():b()}}function b(){r(!0)}function E(){r(!1)}function I(t){if(l.canDrag){t.preventDefault();var n=c.current;o&&E(),l.x=O(t),l.y=C(t),l.delta="x"===e.draggableDirection?l.x-l.start:l.y-l.start,l.start!==l.x&&(l.canCloseOnClick=!1),n.style.transform="translate"+e.draggableDirection+"("+l.delta+"px)",n.style.opacity=""+(1-Math.abs(l.delta/l.removalDistance))}}function _(){var t=c.current;if(l.canDrag){if(l.canDrag=!1,Math.abs(l.delta)>l.removalDistance)return i(!0),void e.closeToast();t.style.transition="transform 0.2s, opacity 0.2s",t.style.transform="translate"+e.draggableDirection+"(0)",t.style.opacity="1"}}t.useEffect((function(){return u(e.onOpen)&&e.onOpen(t.isValidElement(e.children)&&e.children.props),function(){u(d.onClose)&&d.onClose(t.isValidElement(d.children)&&d.children.props)}}),[]),t.useEffect((function(){return e.draggable&&(document.addEventListener("mousemove",I),document.addEventListener("mouseup",_),document.addEventListener("touchmove",I),document.addEventListener("touchend",_)),function(){e.draggable&&(document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",I),document.removeEventListener("touchend",_))}}),[e.draggable]),t.useEffect((function(){return e.pauseOnFocusLoss&&(document.hasFocus()||E(),window.addEventListener("focus",b),window.addEventListener("blur",E)),function(){e.pauseOnFocusLoss&&(window.removeEventListener("focus",b),window.removeEventListener("blur",E))}}),[e.pauseOnFocusLoss]);var x={onMouseDown:y,onTouchStart:y,onMouseUp:T,onTouchEnd:T};return f&&p&&(x.onMouseEnter=E,x.onMouseLeave=b),v&&(x.onClick=function(e){g&&g(e),l.canCloseOnClick&&m()}),{playToast:b,pauseToast:E,isRunning:o,preventExitTransition:a,toastRef:c,eventHandlers:x}}function _(e){var n=e.closeToast,o=e.ariaLabel;return t.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+e.type,type:"button",onClick:function(e){e.stopPropagation(),n(e)},"aria-label":void 0===o?"close":o},t.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},t.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}function x(e){var n,r,a=e.closeToast,i=e.type,c=e.className,l=e.controlledProgress,d=e.progress,f=e.rtl,p=e.isIn,m=s({},e.style,{animationDuration:e.delay+"ms",animationPlayState:e.isRunning?"running":"paused",opacity:e.hide?0:1});l&&(m.transform="scaleX("+d+")");var g=o("Toastify__progress-bar",l?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar--"+i,((n={})["Toastify__progress-bar--rtl"]=f,n)),v=u(c)?c({rtl:f,type:i,defaultClassName:g}):o(g,c),y=((r={})[l&&d>=1?"onTransitionEnd":"onAnimationEnd"]=l&&d<1?null:function(){p&&a()},r);return t.createElement("div",Object.assign({role:"progressbar",className:v,style:m},y))}x.defaultProps={type:g.DEFAULT,hide:!1};var R=function(e){var n,r=I(e),s=r.isRunning,a=r.preventExitTransition,i=r.toastRef,c=r.eventHandlers,l=e.closeButton,d=e.children,f=e.autoClose,p=e.onClick,m=e.type,g=e.hideProgressBar,v=e.closeToast,y=e.transition,T=e.position,h=e.className,b=e.style,E=e.bodyClassName,O=e.bodyStyle,C=e.progressClassName,_=e.progressStyle,R=e.updateId,N=e.role,P=e.progress,L=e.rtl,k=e.toastId,w=e.deleteToast,D=e.isIn,B=o("Toastify__toast","Toastify__toast--"+m,((n={})["Toastify__toast--rtl"]=L,n)),S=u(h)?h({rtl:L,position:T,type:m,defaultClassName:B}):o(B,h),F=!!P;return t.createElement(y,{isIn:D,done:w,position:T,preventExitTransition:a,nodeRef:i},t.createElement("div",Object.assign({id:k,onClick:p,className:S},c,{style:b,ref:i}),t.createElement("div",Object.assign({},D&&{role:N},{className:u(E)?E({type:m}):o("Toastify__toast-body",E),style:O}),d),function(e){if(e){var n={closeToast:v,type:m};return u(e)?e(n):t.isValidElement(e)?t.cloneElement(e,n):void 0}}(l),(f||F)&&t.createElement(x,Object.assign({},R&&!F?{key:"pb-"+R}:{},{rtl:L,delay:f,isRunning:s,isIn:D,closeToast:v,hide:g,type:m,style:_,className:C,controlledProgress:F,progress:P}))))},N=y({enter:"Toastify--animate Toastify__bounce-enter",exit:"Toastify--animate Toastify__bounce-exit",appendPosition:!0}),P=y({enter:"Toastify--animate Toastify__slide-enter",exit:"Toastify--animate Toastify__slide-exit",appendPosition:!0}),L=y({enter:"Toastify--animate Toastify__zoom-enter",exit:"Toastify--animate Toastify__zoom-exit"}),k=y({enter:"Toastify--animate Toastify__flip-enter",exit:"Toastify--animate Toastify__flip-exit"}),w=function(e){var n=E(e),r=n.isToastActive,a=e.className,i=e.style,c=e.rtl;function d(e){var t,n=o("Toastify__toast-container","Toastify__toast-container--"+e,((t={})["Toastify__toast-container--rtl"]=c,t));return u(a)?a({position:e,rtl:c,defaultClassName:n}):o(n,l(a))}return t.createElement("div",{ref:n.containerRef,className:"Toastify",id:e.containerId},(0,n.getToastToRender)((function(e,n){var o=0===n.length?s({},i,{pointerEvents:"none"}):s({},i);return t.createElement("div",{className:d(e),style:o,key:"container-"+e},n.map((function(e){var n=e.content,o=e.props;return t.createElement(R,Object.assign({},o,{isIn:r(o.toastId),key:"toast-"+o.key,closeButton:!0===o.closeButton?_:o.closeButton}),n)})))})))};w.defaultProps={position:m.TOP_RIGHT,transition:N,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:_,pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,draggableDirection:"x",role:"alert"};var D,B,S,F=new Map,A=[],M=!1;function H(){return Math.random().toString(36).substr(2,9)}function j(e){return e&&(c(e.toastId)||a(e.toastId))?e.toastId:H()}function Q(e,n){return F.size>0?T.emit(0,e,n):(A.push({content:e,options:n}),M&&f&&(M=!1,B=document.createElement("div"),document.body.appendChild(B),r.render(t.createElement(w,Object.assign({},S)),B))),n.toastId}function U(e,t){return s({},t,{type:t&&t.type||e,toastId:j(t)})}var q=function(e){return function(t,n){return Q(t,U(e,n))}},z=function(e,t){return Q(e,U(g.DEFAULT,t))};z.success=q(g.SUCCESS),z.info=q(g.INFO),z.error=q(g.ERROR),z.warning=q(g.WARNING),z.dark=q(g.DARK),z.warn=z.warning,z.dismiss=function(e){return T.emit(1,e)},z.clearWaitingQueue=function(e){return void 0===e&&(e={}),T.emit(5,e)},z.isActive=function(e){var t=!1;return F.forEach((function(n){n.isToastActive&&n.isToastActive(e)&&(t=!0)})),t},z.update=function(e,t){void 0===t&&(t={}),setTimeout((function(){var n=function(e,t){var n=F.get(t.containerId||D);return n?n.getToast(e):null}(e,t);if(n){var o=n.content,r=s({},n.props,t,{toastId:t.toastId||e,updateId:H()});r.toastId!==e&&(r.staleId=e);var a=r.render||o;delete r.render,Q(a,r)}}),0)},z.done=function(e){z.update(e,{progress:1})},z.onChange=function(e){return u(e)&&T.on(4,e),function(){u(e)&&T.off(4,e)}},z.configure=function(e){void 0===e&&(e={}),M=!0,S=e},z.POSITION=m,z.TYPE=g,T.on(2,(function(e){F.set(D=e.containerId||e,e),A.forEach((function(e){T.emit(0,e.content,e.options)})),A=[]})).on(3,(function(e){F.delete(e.containerId||e),0===F.size&&T.off(0).off(1).off(5),f&&B&&document.body.removeChild(B)})),exports.Bounce=N,exports.Flip=k,exports.Slide=P,exports.ToastContainer=w,exports.Zoom=L,exports.collapseToast=v,exports.cssTransition=y,exports.toast=z,exports.useToast=I,exports.useToastContainer=E; | ||
//# sourceMappingURL=react-toastify.cjs.production.min.js.map |
@@ -139,2 +139,5 @@ import React__default, { isValidElement, useRef, useLayoutEffect, useEffect, useReducer, cloneElement, useState, createElement } from 'react'; | ||
var baseClassName = useRef(); | ||
var animationStep = useRef(0 | ||
/* Enter */ | ||
); | ||
useLayoutEffect(function () { | ||
@@ -147,3 +150,3 @@ onEnter(); | ||
var onEnter = function onEnter() { | ||
function onEnter() { | ||
var node = nodeRef.current; | ||
@@ -153,21 +156,29 @@ baseClassName.current = node.className; | ||
node.addEventListener('animationend', onEntered); | ||
}; | ||
} | ||
var onEntered = function onEntered() { | ||
function onEntered() { | ||
var node = nodeRef.current; | ||
node.removeEventListener('animationend', onEntered); | ||
node.className = baseClassName.current; | ||
}; | ||
var onExit = function onExit() { | ||
if (animationStep.current === 0 | ||
/* Enter */ | ||
) { | ||
node.className = baseClassName.current; | ||
} | ||
} | ||
function onExit() { | ||
animationStep.current = 1 | ||
/* Exit */ | ||
; | ||
var node = nodeRef.current; | ||
node.className += " " + exitClassName; | ||
node.addEventListener('animationend', onExited); | ||
}; | ||
} | ||
var onExited = function onExited() { | ||
function onExited() { | ||
var node = nodeRef.current; | ||
node.removeEventListener('animationend', onExited); | ||
collapse ? collapseToast(node, done, collapseDuration) : done(); | ||
}; | ||
} | ||
@@ -174,0 +185,0 @@ return React__default.createElement(React__default.Fragment, null, children); |
{ | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
379722
3494