New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sweetalert2

Package Overview
Dependencies
Maintainers
1
Versions
743
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sweetalert2 - npm Package Compare versions

Comparing version 5.0.1 to 5.0.2

9

dist/sweetalert2.common.js
/*!
* sweetalert2 v5.0.1
* sweetalert2 v5.0.2
* Released under the MIT License.

@@ -1106,3 +1106,6 @@ */

if (input.attributes.hasOwnProperty(j)) {
input.removeAttribute(input.attributes[j].name);
var attrName = input.attributes[j].name;
if (attrName !== 'type' && attrName !== 'value') {
input.removeAttribute(attrName);
}
}

@@ -1486,3 +1489,3 @@ }

sweetAlert.version = '5.0.1';
sweetAlert.version = '5.0.2';

@@ -1489,0 +1492,0 @@ window.sweetAlert = window.swal = sweetAlert;

/*!
* sweetalert2 v5.0.1
* sweetalert2 v5.0.2
* Released under the MIT License.

@@ -1110,3 +1110,6 @@ */

if (input.attributes.hasOwnProperty(j)) {
input.removeAttribute(input.attributes[j].name);
var attrName = input.attributes[j].name;
if (attrName !== 'type' && attrName !== 'value') {
input.removeAttribute(attrName);
}
}

@@ -1490,3 +1493,3 @@ }

sweetAlert.version = '5.0.1';
sweetAlert.version = '5.0.2';

@@ -1493,0 +1496,0 @@ window.sweetAlert = window.swal = sweetAlert;

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Sweetalert2=t()}(this,function(){"use strict";function e(){null===f.previousBodyPadding&&document.body.scrollHeight>window.innerHeight&&(f.previousBodyPadding=document.body.style.paddingRight,document.body.style.paddingRight=j()+"px")}function t(){null!==f.previousBodyPadding&&(document.body.style.paddingRight=f.previousBodyPadding,f.previousBodyPadding=null)}function n(){if(void 0===arguments[0])return console.error("SweetAlert2 expects at least 1 attribute!"),!1;var e=d({},D);switch(typeof arguments[0]){case"string":e.title=arguments[0],e.text=arguments[1]||"",e.type=arguments[2]||"";break;case"object":d(e,arguments[0]),e.extraParams=arguments[0].extraParams,"email"===e.input&&null===e.inputValidator&&(e.inputValidator=function(e){return new Promise(function(t,n){var o=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;o.test(e)?t():n("Invalid email address")})});break;default:return console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}K(e);var t=v();return new Promise(function(n,r){function i(t,n){for(var o=k(e.focusCancel),r=0;r<o.length;r++){t+=n,t===o.length?t=0:-1===t&&(t=o.length-1);var i=o[t];if(M(i))return i.focus()}}function l(t){var n=t||window.event,a=n.keyCode||n.which;if(-1!==[9,13,32,27].indexOf(a)){for(var l=n.target||n.srcElement,s=k(e.focusCancel),c=-1,u=0;u<s.length;u++)if(l===s[u]){c=u;break}9===a?(n.shiftKey?i(c,-1):i(c,1),T(n)):13===a||32===a?-1===c&&(e.focusCancel?O(L,n):O(S,n)):27===a&&e.allowEscapeKey===!0&&(o.closeModal(e.onClose),r("esc"))}}e.timer&&(t.timeout=setTimeout(function(){o.closeModal(e.onClose),r("timer")},e.timer));var s=function(n){switch(n=n||e.input){case"select":case"textarea":case"file":return P(t,a[n]);case"checkbox":return t.querySelector("."+a.checkbox+" input");case"radio":return t.querySelector("."+a.radio+" input:checked")||t.querySelector("."+a.radio+" input:first-child");case"range":return t.querySelector("."+a.range+" input");default:return P(t,a.input)}},c=function(){var t=s();if(!t)return null;switch(e.input){case"checkbox":return t.checked?1:0;case"radio":return t.checked?t.value:null;case"file":return t.files.length?t.files[0]:null;default:return e.inputAutoTrim?t.value.trim():t.value}};e.input&&setTimeout(function(){var e=s();e&&x(e)},0);var d,m=function(t){e.showLoaderOnConfirm&&o.showLoading(),e.preConfirm?e.preConfirm(t,e.extraParams).then(function(r){o.closeModal(e.onClose),n(r||t)},function(e){o.hideLoading(),e&&o.showValidationError(e)}):(o.closeModal(e.onClose),n(t))},v=function(t){var n=t||window.event,i=n.target||n.srcElement,a=b(),l=w(),s=a===i||a.contains(i),u=l===i||l.contains(i);switch(n.type){case"mouseover":case"mouseup":e.buttonsStyling&&(s?a.style.backgroundColor=p(e.confirmButtonColor,-.1):u&&(l.style.backgroundColor=p(e.cancelButtonColor,-.1)));break;case"mouseout":e.buttonsStyling&&(s?a.style.backgroundColor=e.confirmButtonColor:u&&(l.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(s?a.style.backgroundColor=p(e.confirmButtonColor,-.2):u&&(l.style.backgroundColor=p(e.cancelButtonColor,-.2)));break;case"click":if(s&&o.isVisible())if(e.input){var d=c();e.inputValidator?(o.disableInput(),e.inputValidator(d,e.extraParams).then(function(){o.enableInput(),m(d)},function(e){o.enableInput(),e&&o.showValidationError(e)})):m(d)}else m(!0);else u&&o.isVisible()&&(o.closeModal(e.onClose),r("cancel"))}},h=t.querySelectorAll("button");for(d=0;d<h.length;d++)h[d].onclick=v,h[d].onmouseover=v,h[d].onmouseout=v,h[d].onmousedown=v;C().onclick=function(){o.closeModal(e.onClose),r("close")},u.onclick=function(t){t.target===u&&e.allowOutsideClick&&(o.closeModal(e.onClose),r("overlay"))};var S=b(),L=w();e.reverseButtons?S.parentNode.insertBefore(L,S):S.parentNode.insertBefore(S,L),f.previousWindowKeyDown=window.onkeydown,window.onkeydown=l,e.buttonsStyling&&(S.style.borderLeftColor=e.confirmButtonColor,S.style.borderRightColor=e.confirmButtonColor),o.showLoading=o.enableLoading=function(){A(y()),A(S,"inline-block"),E(S,"loading"),E(t,"loading"),S.disabled=!0,L.disabled=!0},o.hideLoading=o.disableLoading=function(){e.showConfirmButton||(q(S),e.showCancelButton||q(y())),B(S,"loading"),B(t,"loading"),S.disabled=!1,L.disabled=!1},o.enableButtons=function(){S.disabled=!1,L.disabled=!1},o.disableButtons=function(){S.disabled=!0,L.disabled=!0},o.enableConfirmButton=function(){S.disabled=!1},o.disableConfirmButton=function(){S.disabled=!0},o.enableInput=function(){var e=s();if(!e)return!1;if("radio"===e.type)for(var t=e.parentNode.parentNode,n=t.querySelectorAll("input"),o=0;o<n.length;o++)n[o].disabled=!1;else e.disabled=!1},o.disableInput=function(){var e=s();if(!e)return!1;if(e&&"radio"===e.type)for(var t=e.parentNode.parentNode,n=t.querySelectorAll("input"),o=0;o<n.length;o++)n[o].disabled=!0;else e.disabled=!0},o.showValidationError=function(e){var n=t.querySelector("."+a.validationerror);n.innerHTML=e,A(n),I();var o=s();x(o),E(o,"error")},o.resetValidationError=function(){var e=t.querySelector("."+a.validationerror);q(e),I();var n=s();n&&B(n,"error")},o.getProgressSteps=function(){return e.progressSteps},o.setProgressSteps=function(t){e.progressSteps=t,K(e)},o.showProgressSteps=function(){A(g())},o.hideProgressSteps=function(){q(g())},o.enableButtons(),o.hideLoading(),o.resetValidationError();var V,H=["input","file","range","select","radio","checkbox","textarea"];for(d=0;d<H.length;d++){var N=a[H[d]],j=P(t,N);if(V=s(H[d])){for(var D in V.attributes)V.attributes.hasOwnProperty(D)&&V.removeAttribute(V.attributes[D].name);for(var W in e.inputAttributes)V.setAttribute(W,e.inputAttributes[W])}j.className=N,e.inputClass&&E(j,e.inputClass),q(j)}var U;switch(e.input){case"text":case"email":case"password":case"number":case"tel":V=P(t,a.input),V.value=e.inputValue,V.placeholder=e.inputPlaceholder,V.type=e.input,A(V);break;case"file":V=P(t,a.file),V.placeholder=e.inputPlaceholder,V.type=e.input,A(V);break;case"range":var z=P(t,a.range),Q=z.querySelector("input"),Y=z.querySelector("output");Q.value=e.inputValue,Q.type=e.input,Y.value=e.inputValue,A(z);break;case"select":var Z=P(t,a.select);if(Z.innerHTML="",e.inputPlaceholder){var F=document.createElement("option");F.innerHTML=e.inputPlaceholder,F.value="",F.disabled=!0,F.selected=!0,Z.appendChild(F)}U=function(t){for(var n in t){var o=document.createElement("option");o.value=n,o.innerHTML=t[n],e.inputValue===n&&(o.selected=!0),Z.appendChild(o)}A(Z),Z.focus()};break;case"radio":var J=P(t,a.radio);J.innerHTML="",U=function(t){for(var n in t){var o=1,r=document.createElement("input"),i=document.createElement("label"),l=document.createElement("span");r.type="radio",r.name=a.radio,r.value=n,r.id=a.radio+"-"+o++,e.inputValue===n&&(r.checked=!0),l.innerHTML=t[n],i.appendChild(r),i.appendChild(l),i["for"]=r.id,J.appendChild(i)}A(J);var s=J.querySelectorAll("input");s.length&&s[0].focus()};break;case"checkbox":var $=P(t,a.checkbox),_=s("checkbox");_.type="checkbox",_.value=1,_.id=a.checkbox,_.checked=Boolean(e.inputValue);var G=$.getElementsByTagName("span");G.length&&$.removeChild(G[0]),G=document.createElement("span"),G.innerHTML=e.inputPlaceholder,$.appendChild(G),A($);break;case"textarea":var X=P(t,a.textarea);X.value=e.inputValue,X.placeholder=e.inputPlaceholder,A(X);break;case null:break;default:console.error('SweetAlert2: Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox", "textarea" or "file", got "'+e.input+'"')}"select"!==e.input&&"radio"!==e.input||(e.inputOptions instanceof Promise?(o.showLoading(),e.inputOptions.then(function(e){o.hideLoading(),U(e),I()})):"object"==typeof e.inputOptions?U(e.inputOptions):console.error("SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got "+typeof e.inputOptions)),I(),R(e.animation,e.onOpen),i(-1,1),u.scrollTop=0})}function o(){var e=arguments,t=v();return null===t&&(o.init(),t=v()),o.isVisible()&&o.close(),n.apply(this,e)}var r="swal2-",i=function(e){var t={};for(var n in e)t[e[n]]=r+e[n];return t},a=i(["container","in","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","file","range","select","radio","checkbox","textarea","validationerror","progresssteps","activeprogressstep","progresscircle","progressline"]),l=i(["success","warning","info","question","error"]),s={title:"",text:"",html:"",type:null,customClass:"",animation:!0,allowOutsideClick:!0,allowEscapeKey:!0,showConfirmButton:!0,showCancelButton:!1,preConfirm:null,confirmButtonText:"OK",confirmButtonColor:"#3085d6",confirmButtonClass:null,cancelButtonText:"Cancel",cancelButtonColor:"#aaa",cancelButtonClass:null,buttonsStyling:!0,reverseButtons:!1,focusCancel:!1,showCloseButton:!1,showLoaderOnConfirm:!1,imageUrl:null,imageWidth:null,imageHeight:null,imageClass:null,timer:null,width:500,padding:20,background:"#fff",input:null,inputPlaceholder:"",inputValue:"",inputOptions:{},inputAutoTrim:!0,inputClass:null,inputAttributes:{},inputValidator:null,progressSteps:[],currentProgressStep:null,progressStepsDistance:"40px",onOpen:null,onClose:null},c='<div class="'+a.modal+'" style="display: none" tabIndex="-1"><ul class="'+a.progresssteps+'"></ul><div class="'+a.icon+" "+l.error+'"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="'+a.icon+" "+l.question+'">?</div><div class="'+a.icon+" "+l.warning+'">!</div><div class="'+a.icon+" "+l.info+'">i</div><div class="'+a.icon+" "+l.success+'"><span class="line tip"></span> <span class="line long"></span><div class="placeholder"></div> <div class="fix"></div></div><img class="'+a.image+'"><h2></h2><div class="'+a.content+'"></div><input class="'+a.input+'"><input class="'+a.file+'"><div class="'+a.range+'"><output></output><input type="range"></div><select class="'+a.select+'"></select><div class="'+a.radio+'"></div><label for="'+a.checkbox+'" class="'+a.checkbox+'"><input type="checkbox"></label><textarea class="'+a.textarea+'"></textarea><div class="'+a.validationerror+'"></div><hr class="'+a.spacer+'"><button type="button" class="'+a.confirm+'">OK</button><button type="button" class="'+a.cancel+'">Cancel</button><span class="'+a.close+'">&times;</span></div>',u=document.createElement("div");u.className=a.container,u.innerHTML=c;var d=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},p=function(e,t){e=String(e).replace(/[^0-9a-f]/gi,""),e.length<6&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),t=t||0;for(var n="#",o=0;3>o;o++){var r=parseInt(e.substr(2*o,2),16);r=Math.round(Math.min(Math.max(0,r+r*t),255)).toString(16),n+=("00"+r).substr(r.length)}return n},f={previousWindowKeyDown:null,previousActiveElement:null,previousBodyPadding:null},m=function(e){return u.querySelector("."+e)},v=function(){return m(a.modal)},h=function(){var e=v();return e.querySelectorAll("."+a.icon)},y=function(){return m(a.spacer)},g=function(){return m(a.progresssteps)},b=function(){return m(a.confirm)},w=function(){return m(a.cancel)},C=function(){return m(a.close)},k=function(e){var t=[b(),w()];return e&&t.reverse(),t.concat(Array.prototype.slice.call(v().querySelectorAll("button:not([class^="+r+"]), input:not([type=hidden]), textarea, select")))},S=function(e,t){return e.classList.contains(t)},x=function(e){e.focus();var t=e.value;e.value="",e.value=t},E=function(e,t){if(e&&t){var n=t.split(/\s+/);n.forEach(function(t){e.classList.add(t)})}},B=function(e,t){if(e&&t){var n=t.split(/\s+/);n.forEach(function(t){e.classList.remove(t)})}},P=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(S(e.childNodes[n],t))return e.childNodes[n]},A=function(e,t){t||(t="block"),e.style.opacity="",e.style.display=t},q=function(e){e.style.opacity="",e.style.display="none"},L=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},M=function(e){return e.offsetWidth||e.offsetHeight||e.getClientRects().length},V=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},O=function(e){if("function"==typeof MouseEvent){var t=new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0});e.dispatchEvent(t)}else if(document.createEvent){var n=document.createEvent("MouseEvents");n.initEvent("click",!1,!1),e.dispatchEvent(n)}else document.createEventObject?e.fireEvent("onclick"):"function"==typeof e.onclick&&e.onclick()},T=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},H=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",OAnimation:"oAnimationEnd oanimationend",msAnimation:"MSAnimationEnd",animation:"animationend"};for(var n in t)if(t.hasOwnProperty(n)&&void 0!==e.style[n])return t[n];return!1}(),N=function(){var e=v();window.onkeydown=f.previousWindowKeyDown,f.previousActiveElement&&f.previousActiveElement.focus&&f.previousActiveElement.focus(),clearTimeout(e.timeout)},j=function(){var e=document.createElement("div");e.style.width="50px",e.style.height="50px",e.style.overflow="scroll",document.body.appendChild(e);var t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t},I=function(){var e=v(),t=e.style.display;e.style.minHeight="",A(e),e.style.minHeight=e.scrollHeight+1+"px",e.style.display=t},D=d({},s),W=[],K=function(e){var t=v();for(var n in e)s.hasOwnProperty(n)||"extraParams"===n||console.warn('SweetAlert2: Unknown parameter "'+n+'"');t.style.width="number"==typeof e.width?e.width+"px":e.width,t.style.padding=e.padding+"px",t.style.background=e.background;var o=t.querySelector("h2"),r=t.querySelector("."+a.content),i=b(),c=w(),u=t.querySelector("."+a.close);o.innerHTML=e.title.split("\n").join("<br>");var d;if(e.text||e.html){if("object"==typeof e.html)if(r.innerHTML="",0 in e.html)for(d=0;d in e.html;d++)r.appendChild(e.html[d].cloneNode(!0));else r.appendChild(e.html.cloneNode(!0));else r.innerHTML=e.html||e.text.split("\n").join("<br>");A(r)}else q(r);e.showCloseButton?A(u):q(u),t.className=a.modal,e.customClass&&E(t,e.customClass);var p=g(),f=parseInt(null===e.currentProgressStep?swal.getQueueStep():e.currentProgressStep,10);e.progressSteps.length?(A(p),L(p),f>=e.progressSteps.length&&console.warn("SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),e.progressSteps.forEach(function(t,n){var o=document.createElement("li");if(E(o,a.progresscircle),o.innerHTML=t,n===f&&E(o,a.activeprogressstep),p.appendChild(o),n!==e.progressSteps.length-1){var r=document.createElement("li");E(r,a.progressline),r.style.width=e.progressStepsDistance,p.appendChild(r)}})):q(p);var m=h();for(d=0;d<m.length;d++)q(m[d]);if(e.type){var C=!1;for(var k in l)if(e.type===k){C=!0;break}if(!C)return console.error("SweetAlert2: Unknown alert type: "+e.type),!1;var S=t.querySelector("."+a.icon+"."+l[e.type]);switch(A(S),e.type){case"success":E(S,"animate"),E(S.querySelector(".tip"),"animate-success-tip"),E(S.querySelector(".long"),"animate-success-long");break;case"error":E(S,"animate-error-icon"),E(S.querySelector(".x-mark"),"animate-x-mark");break;case"warning":E(S,"pulse-warning")}}var x=t.querySelector("."+a.image);e.imageUrl?(x.setAttribute("src",e.imageUrl),A(x),e.imageWidth?x.setAttribute("width",e.imageWidth):x.removeAttribute("width"),e.imageHeight?x.setAttribute("height",e.imageHeight):x.removeAttribute("height"),x.className=a.image,e.imageClass&&E(x,e.imageClass)):q(x),e.showCancelButton?c.style.display="inline-block":q(c),e.showConfirmButton?V(i,"display"):q(i);var P=y();e.showConfirmButton||e.showCancelButton?A(P):q(P),i.innerHTML=e.confirmButtonText,c.innerHTML=e.cancelButtonText,e.buttonsStyling&&(i.style.backgroundColor=e.confirmButtonColor,c.style.backgroundColor=e.cancelButtonColor),i.className=a.confirm,E(i,e.confirmButtonClass),c.className=a.cancel,E(c,e.cancelButtonClass),e.buttonsStyling?(E(i,"styled"),E(c,"styled")):(B(i,"styled"),B(c,"styled"),i.style.backgroundColor=i.style.borderLeftColor=i.style.borderRightColor="",c.style.backgroundColor=c.style.borderLeftColor=c.style.borderRightColor=""),e.animation===!0?B(t,"no-animation"):E(t,"no-animation")},R=function(t,n){var o=v();t?(E(o,"show-swal2"),E(u,"fade"),B(o,"hide-swal2")):B(o,"fade"),A(o),u.style.overflowY="hidden",H&&!S(o,"no-animation")?o.addEventListener(H,function r(){o.removeEventListener(H,r),u.style.overflowY="auto"}):u.style.overflowY="auto",E(u,"in"),E(document.body,a["in"]),e(),f.previousActiveElement=document.activeElement,null!==n&&"function"==typeof n&&n.call(this,o)};return o.isVisible=function(){var e=v();return M(e)},o.queue=function(e){W=e;var t=v()||o.init(),n=function(){W=[],t.removeAttribute("data-queue-step")};return new Promise(function(e,r){!function i(a,l){a<W.length?(t.setAttribute("data-queue-step",a),o(W[a]).then(function(){i(a+1,l)},function(e){n(),r(e)})):(n(),e())}(0)})},o.getQueueStep=function(){return v().getAttribute("data-queue-step")},o.insertQueueStep=function(e,t){return t&&t<W.length?W.splice(t,0,e):W.push(e)},o.deleteQueueStep=function(e){"undefined"!=typeof W[e]&&W.splice(e,1)},o.close=o.closeModal=function(e){var n=v();B(n,"show-swal2"),E(n,"hide-swal2");var o=n.querySelector("."+a.icon+"."+l.success);B(o,"animate"),B(o.querySelector(".tip"),"animate-success-tip"),B(o.querySelector(".long"),"animate-success-long");var r=n.querySelector("."+a.icon+"."+l.error);B(r,"animate-error-icon"),B(r.querySelector(".x-mark"),"animate-x-mark");var i=n.querySelector("."+a.icon+"."+l.warning);B(i,"pulse-warning"),N(),H&&!S(n,"no-animation")?n.addEventListener(H,function s(){n.removeEventListener(H,s),S(n,"hide-swal2")&&(q(n),B(u,"in"),B(document.body,a["in"]),t())}):(q(n),B(u,"in"),B(document.body,a["in"]),t()),null!==e&&"function"==typeof e&&e.call(this,n)},o.clickConfirm=function(){b().click()},o.clickCancel=function(){w().click()},o.init=function(){if("undefined"==typeof document)return void console.error("SweetAlert2 requires document to initialize");if(!document.getElementsByClassName(a.container).length){document.body.appendChild(u);var e=v(),t=P(e,a.input),n=P(e,a.file),r=e.querySelector("."+a.range+" input"),i=P(e,a.select),l=e.querySelector("."+a.checkbox+" input"),s=P(e,a.textarea);return t.oninput=function(){o.resetValidationError()},t.onkeyup=function(e){e.stopPropagation(),13===e.keyCode&&o.clickConfirm()},n.onchange=function(){o.resetValidationError()},r.oninput=function(){o.resetValidationError(),r.previousSibling.value=r.value},r.onchange=function(){o.resetValidationError(),r.previousSibling.value=r.value},i.onchange=function(){o.resetValidationError()},l.onchange=function(){o.resetValidationError()},s.oninput=function(){o.resetValidationError()},e}},o.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");d(D,e)},o.resetDefaults=function(){D=d({},s)},o.version="5.0.1",window.sweetAlert=window.swal=o,function(){"complete"===document.readyState||"interactive"===document.readyState&&document.body?o.init():document.addEventListener("DOMContentLoaded",function e(){document.removeEventListener("DOMContentLoaded",e,!1),o.init()},!1)}(),"function"==typeof Promise?Promise.prototype.done=Promise.prototype.done||function(){return this["catch"](function(){})}:console.warn("SweetAlert2: Please inlude Promise polyfill BEFORE including sweetalert2.js if IE10+ support needed."),o});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Sweetalert2=t()}(this,function(){"use strict";function e(){null===f.previousBodyPadding&&document.body.scrollHeight>window.innerHeight&&(f.previousBodyPadding=document.body.style.paddingRight,document.body.style.paddingRight=j()+"px")}function t(){null!==f.previousBodyPadding&&(document.body.style.paddingRight=f.previousBodyPadding,f.previousBodyPadding=null)}function n(){if(void 0===arguments[0])return console.error("SweetAlert2 expects at least 1 attribute!"),!1;var e=d({},D);switch(typeof arguments[0]){case"string":e.title=arguments[0],e.text=arguments[1]||"",e.type=arguments[2]||"";break;case"object":d(e,arguments[0]),e.extraParams=arguments[0].extraParams,"email"===e.input&&null===e.inputValidator&&(e.inputValidator=function(e){return new Promise(function(t,n){var o=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;o.test(e)?t():n("Invalid email address")})});break;default:return console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}K(e);var t=v();return new Promise(function(n,r){function i(t,n){for(var o=k(e.focusCancel),r=0;r<o.length;r++){t+=n,t===o.length?t=0:-1===t&&(t=o.length-1);var i=o[t];if(M(i))return i.focus()}}function l(t){var n=t||window.event,a=n.keyCode||n.which;if(-1!==[9,13,32,27].indexOf(a)){for(var l=n.target||n.srcElement,s=k(e.focusCancel),c=-1,u=0;u<s.length;u++)if(l===s[u]){c=u;break}9===a?(n.shiftKey?i(c,-1):i(c,1),T(n)):13===a||32===a?-1===c&&(e.focusCancel?O(L,n):O(S,n)):27===a&&e.allowEscapeKey===!0&&(o.closeModal(e.onClose),r("esc"))}}e.timer&&(t.timeout=setTimeout(function(){o.closeModal(e.onClose),r("timer")},e.timer));var s=function(n){switch(n=n||e.input){case"select":case"textarea":case"file":return P(t,a[n]);case"checkbox":return t.querySelector("."+a.checkbox+" input");case"radio":return t.querySelector("."+a.radio+" input:checked")||t.querySelector("."+a.radio+" input:first-child");case"range":return t.querySelector("."+a.range+" input");default:return P(t,a.input)}},c=function(){var t=s();if(!t)return null;switch(e.input){case"checkbox":return t.checked?1:0;case"radio":return t.checked?t.value:null;case"file":return t.files.length?t.files[0]:null;default:return e.inputAutoTrim?t.value.trim():t.value}};e.input&&setTimeout(function(){var e=s();e&&x(e)},0);var d,m=function(t){e.showLoaderOnConfirm&&o.showLoading(),e.preConfirm?e.preConfirm(t,e.extraParams).then(function(r){o.closeModal(e.onClose),n(r||t)},function(e){o.hideLoading(),e&&o.showValidationError(e)}):(o.closeModal(e.onClose),n(t))},v=function(t){var n=t||window.event,i=n.target||n.srcElement,a=b(),l=w(),s=a===i||a.contains(i),u=l===i||l.contains(i);switch(n.type){case"mouseover":case"mouseup":e.buttonsStyling&&(s?a.style.backgroundColor=p(e.confirmButtonColor,-.1):u&&(l.style.backgroundColor=p(e.cancelButtonColor,-.1)));break;case"mouseout":e.buttonsStyling&&(s?a.style.backgroundColor=e.confirmButtonColor:u&&(l.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(s?a.style.backgroundColor=p(e.confirmButtonColor,-.2):u&&(l.style.backgroundColor=p(e.cancelButtonColor,-.2)));break;case"click":if(s&&o.isVisible())if(e.input){var d=c();e.inputValidator?(o.disableInput(),e.inputValidator(d,e.extraParams).then(function(){o.enableInput(),m(d)},function(e){o.enableInput(),e&&o.showValidationError(e)})):m(d)}else m(!0);else u&&o.isVisible()&&(o.closeModal(e.onClose),r("cancel"))}},h=t.querySelectorAll("button");for(d=0;d<h.length;d++)h[d].onclick=v,h[d].onmouseover=v,h[d].onmouseout=v,h[d].onmousedown=v;C().onclick=function(){o.closeModal(e.onClose),r("close")},u.onclick=function(t){t.target===u&&e.allowOutsideClick&&(o.closeModal(e.onClose),r("overlay"))};var S=b(),L=w();e.reverseButtons?S.parentNode.insertBefore(L,S):S.parentNode.insertBefore(S,L),f.previousWindowKeyDown=window.onkeydown,window.onkeydown=l,e.buttonsStyling&&(S.style.borderLeftColor=e.confirmButtonColor,S.style.borderRightColor=e.confirmButtonColor),o.showLoading=o.enableLoading=function(){A(y()),A(S,"inline-block"),E(S,"loading"),E(t,"loading"),S.disabled=!0,L.disabled=!0},o.hideLoading=o.disableLoading=function(){e.showConfirmButton||(q(S),e.showCancelButton||q(y())),B(S,"loading"),B(t,"loading"),S.disabled=!1,L.disabled=!1},o.enableButtons=function(){S.disabled=!1,L.disabled=!1},o.disableButtons=function(){S.disabled=!0,L.disabled=!0},o.enableConfirmButton=function(){S.disabled=!1},o.disableConfirmButton=function(){S.disabled=!0},o.enableInput=function(){var e=s();if(!e)return!1;if("radio"===e.type)for(var t=e.parentNode.parentNode,n=t.querySelectorAll("input"),o=0;o<n.length;o++)n[o].disabled=!1;else e.disabled=!1},o.disableInput=function(){var e=s();if(!e)return!1;if(e&&"radio"===e.type)for(var t=e.parentNode.parentNode,n=t.querySelectorAll("input"),o=0;o<n.length;o++)n[o].disabled=!0;else e.disabled=!0},o.showValidationError=function(e){var n=t.querySelector("."+a.validationerror);n.innerHTML=e,A(n),I();var o=s();x(o),E(o,"error")},o.resetValidationError=function(){var e=t.querySelector("."+a.validationerror);q(e),I();var n=s();n&&B(n,"error")},o.getProgressSteps=function(){return e.progressSteps},o.setProgressSteps=function(t){e.progressSteps=t,K(e)},o.showProgressSteps=function(){A(g())},o.hideProgressSteps=function(){q(g())},o.enableButtons(),o.hideLoading(),o.resetValidationError();var V,H=["input","file","range","select","radio","checkbox","textarea"];for(d=0;d<H.length;d++){var N=a[H[d]],j=P(t,N);if(V=s(H[d])){for(var D in V.attributes)if(V.attributes.hasOwnProperty(D)){var W=V.attributes[D].name;"type"!==W&&"value"!==W&&V.removeAttribute(W)}for(var U in e.inputAttributes)V.setAttribute(U,e.inputAttributes[U])}j.className=N,e.inputClass&&E(j,e.inputClass),q(j)}var z;switch(e.input){case"text":case"email":case"password":case"number":case"tel":V=P(t,a.input),V.value=e.inputValue,V.placeholder=e.inputPlaceholder,V.type=e.input,A(V);break;case"file":V=P(t,a.file),V.placeholder=e.inputPlaceholder,V.type=e.input,A(V);break;case"range":var Q=P(t,a.range),Y=Q.querySelector("input"),Z=Q.querySelector("output");Y.value=e.inputValue,Y.type=e.input,Z.value=e.inputValue,A(Q);break;case"select":var F=P(t,a.select);if(F.innerHTML="",e.inputPlaceholder){var J=document.createElement("option");J.innerHTML=e.inputPlaceholder,J.value="",J.disabled=!0,J.selected=!0,F.appendChild(J)}z=function(t){for(var n in t){var o=document.createElement("option");o.value=n,o.innerHTML=t[n],e.inputValue===n&&(o.selected=!0),F.appendChild(o)}A(F),F.focus()};break;case"radio":var $=P(t,a.radio);$.innerHTML="",z=function(t){for(var n in t){var o=1,r=document.createElement("input"),i=document.createElement("label"),l=document.createElement("span");r.type="radio",r.name=a.radio,r.value=n,r.id=a.radio+"-"+o++,e.inputValue===n&&(r.checked=!0),l.innerHTML=t[n],i.appendChild(r),i.appendChild(l),i["for"]=r.id,$.appendChild(i)}A($);var s=$.querySelectorAll("input");s.length&&s[0].focus()};break;case"checkbox":var _=P(t,a.checkbox),G=s("checkbox");G.type="checkbox",G.value=1,G.id=a.checkbox,G.checked=Boolean(e.inputValue);var X=_.getElementsByTagName("span");X.length&&_.removeChild(X[0]),X=document.createElement("span"),X.innerHTML=e.inputPlaceholder,_.appendChild(X),A(_);break;case"textarea":var ee=P(t,a.textarea);ee.value=e.inputValue,ee.placeholder=e.inputPlaceholder,A(ee);break;case null:break;default:console.error('SweetAlert2: Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox", "textarea" or "file", got "'+e.input+'"')}"select"!==e.input&&"radio"!==e.input||(e.inputOptions instanceof Promise?(o.showLoading(),e.inputOptions.then(function(e){o.hideLoading(),z(e),I()})):"object"==typeof e.inputOptions?z(e.inputOptions):console.error("SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got "+typeof e.inputOptions)),I(),R(e.animation,e.onOpen),i(-1,1),u.scrollTop=0})}function o(){var e=arguments,t=v();return null===t&&(o.init(),t=v()),o.isVisible()&&o.close(),n.apply(this,e)}var r="swal2-",i=function(e){var t={};for(var n in e)t[e[n]]=r+e[n];return t},a=i(["container","in","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","file","range","select","radio","checkbox","textarea","validationerror","progresssteps","activeprogressstep","progresscircle","progressline"]),l=i(["success","warning","info","question","error"]),s={title:"",text:"",html:"",type:null,customClass:"",animation:!0,allowOutsideClick:!0,allowEscapeKey:!0,showConfirmButton:!0,showCancelButton:!1,preConfirm:null,confirmButtonText:"OK",confirmButtonColor:"#3085d6",confirmButtonClass:null,cancelButtonText:"Cancel",cancelButtonColor:"#aaa",cancelButtonClass:null,buttonsStyling:!0,reverseButtons:!1,focusCancel:!1,showCloseButton:!1,showLoaderOnConfirm:!1,imageUrl:null,imageWidth:null,imageHeight:null,imageClass:null,timer:null,width:500,padding:20,background:"#fff",input:null,inputPlaceholder:"",inputValue:"",inputOptions:{},inputAutoTrim:!0,inputClass:null,inputAttributes:{},inputValidator:null,progressSteps:[],currentProgressStep:null,progressStepsDistance:"40px",onOpen:null,onClose:null},c='<div class="'+a.modal+'" style="display: none" tabIndex="-1"><ul class="'+a.progresssteps+'"></ul><div class="'+a.icon+" "+l.error+'"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="'+a.icon+" "+l.question+'">?</div><div class="'+a.icon+" "+l.warning+'">!</div><div class="'+a.icon+" "+l.info+'">i</div><div class="'+a.icon+" "+l.success+'"><span class="line tip"></span> <span class="line long"></span><div class="placeholder"></div> <div class="fix"></div></div><img class="'+a.image+'"><h2></h2><div class="'+a.content+'"></div><input class="'+a.input+'"><input class="'+a.file+'"><div class="'+a.range+'"><output></output><input type="range"></div><select class="'+a.select+'"></select><div class="'+a.radio+'"></div><label for="'+a.checkbox+'" class="'+a.checkbox+'"><input type="checkbox"></label><textarea class="'+a.textarea+'"></textarea><div class="'+a.validationerror+'"></div><hr class="'+a.spacer+'"><button type="button" class="'+a.confirm+'">OK</button><button type="button" class="'+a.cancel+'">Cancel</button><span class="'+a.close+'">&times;</span></div>',u=document.createElement("div");u.className=a.container,u.innerHTML=c;var d=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},p=function(e,t){e=String(e).replace(/[^0-9a-f]/gi,""),e.length<6&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),t=t||0;for(var n="#",o=0;3>o;o++){var r=parseInt(e.substr(2*o,2),16);r=Math.round(Math.min(Math.max(0,r+r*t),255)).toString(16),n+=("00"+r).substr(r.length)}return n},f={previousWindowKeyDown:null,previousActiveElement:null,previousBodyPadding:null},m=function(e){return u.querySelector("."+e)},v=function(){return m(a.modal)},h=function(){var e=v();return e.querySelectorAll("."+a.icon)},y=function(){return m(a.spacer)},g=function(){return m(a.progresssteps)},b=function(){return m(a.confirm)},w=function(){return m(a.cancel)},C=function(){return m(a.close)},k=function(e){var t=[b(),w()];return e&&t.reverse(),t.concat(Array.prototype.slice.call(v().querySelectorAll("button:not([class^="+r+"]), input:not([type=hidden]), textarea, select")))},S=function(e,t){return e.classList.contains(t)},x=function(e){e.focus();var t=e.value;e.value="",e.value=t},E=function(e,t){if(e&&t){var n=t.split(/\s+/);n.forEach(function(t){e.classList.add(t)})}},B=function(e,t){if(e&&t){var n=t.split(/\s+/);n.forEach(function(t){e.classList.remove(t)})}},P=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(S(e.childNodes[n],t))return e.childNodes[n]},A=function(e,t){t||(t="block"),e.style.opacity="",e.style.display=t},q=function(e){e.style.opacity="",e.style.display="none"},L=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},M=function(e){return e.offsetWidth||e.offsetHeight||e.getClientRects().length},V=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},O=function(e){if("function"==typeof MouseEvent){var t=new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0});e.dispatchEvent(t)}else if(document.createEvent){var n=document.createEvent("MouseEvents");n.initEvent("click",!1,!1),e.dispatchEvent(n)}else document.createEventObject?e.fireEvent("onclick"):"function"==typeof e.onclick&&e.onclick()},T=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},H=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",OAnimation:"oAnimationEnd oanimationend",msAnimation:"MSAnimationEnd",animation:"animationend"};for(var n in t)if(t.hasOwnProperty(n)&&void 0!==e.style[n])return t[n];return!1}(),N=function(){var e=v();window.onkeydown=f.previousWindowKeyDown,f.previousActiveElement&&f.previousActiveElement.focus&&f.previousActiveElement.focus(),clearTimeout(e.timeout)},j=function(){var e=document.createElement("div");e.style.width="50px",e.style.height="50px",e.style.overflow="scroll",document.body.appendChild(e);var t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t},I=function(){var e=v(),t=e.style.display;e.style.minHeight="",A(e),e.style.minHeight=e.scrollHeight+1+"px",e.style.display=t},D=d({},s),W=[],K=function(e){var t=v();for(var n in e)s.hasOwnProperty(n)||"extraParams"===n||console.warn('SweetAlert2: Unknown parameter "'+n+'"');t.style.width="number"==typeof e.width?e.width+"px":e.width,t.style.padding=e.padding+"px",t.style.background=e.background;var o=t.querySelector("h2"),r=t.querySelector("."+a.content),i=b(),c=w(),u=t.querySelector("."+a.close);o.innerHTML=e.title.split("\n").join("<br>");var d;if(e.text||e.html){if("object"==typeof e.html)if(r.innerHTML="",0 in e.html)for(d=0;d in e.html;d++)r.appendChild(e.html[d].cloneNode(!0));else r.appendChild(e.html.cloneNode(!0));else r.innerHTML=e.html||e.text.split("\n").join("<br>");A(r)}else q(r);e.showCloseButton?A(u):q(u),t.className=a.modal,e.customClass&&E(t,e.customClass);var p=g(),f=parseInt(null===e.currentProgressStep?swal.getQueueStep():e.currentProgressStep,10);e.progressSteps.length?(A(p),L(p),f>=e.progressSteps.length&&console.warn("SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),e.progressSteps.forEach(function(t,n){var o=document.createElement("li");if(E(o,a.progresscircle),o.innerHTML=t,n===f&&E(o,a.activeprogressstep),p.appendChild(o),n!==e.progressSteps.length-1){var r=document.createElement("li");E(r,a.progressline),r.style.width=e.progressStepsDistance,p.appendChild(r)}})):q(p);var m=h();for(d=0;d<m.length;d++)q(m[d]);if(e.type){var C=!1;for(var k in l)if(e.type===k){C=!0;break}if(!C)return console.error("SweetAlert2: Unknown alert type: "+e.type),!1;var S=t.querySelector("."+a.icon+"."+l[e.type]);switch(A(S),e.type){case"success":E(S,"animate"),E(S.querySelector(".tip"),"animate-success-tip"),E(S.querySelector(".long"),"animate-success-long");break;case"error":E(S,"animate-error-icon"),E(S.querySelector(".x-mark"),"animate-x-mark");break;case"warning":E(S,"pulse-warning")}}var x=t.querySelector("."+a.image);e.imageUrl?(x.setAttribute("src",e.imageUrl),A(x),e.imageWidth?x.setAttribute("width",e.imageWidth):x.removeAttribute("width"),e.imageHeight?x.setAttribute("height",e.imageHeight):x.removeAttribute("height"),x.className=a.image,e.imageClass&&E(x,e.imageClass)):q(x),e.showCancelButton?c.style.display="inline-block":q(c),e.showConfirmButton?V(i,"display"):q(i);var P=y();e.showConfirmButton||e.showCancelButton?A(P):q(P),i.innerHTML=e.confirmButtonText,c.innerHTML=e.cancelButtonText,e.buttonsStyling&&(i.style.backgroundColor=e.confirmButtonColor,c.style.backgroundColor=e.cancelButtonColor),i.className=a.confirm,E(i,e.confirmButtonClass),c.className=a.cancel,E(c,e.cancelButtonClass),e.buttonsStyling?(E(i,"styled"),E(c,"styled")):(B(i,"styled"),B(c,"styled"),i.style.backgroundColor=i.style.borderLeftColor=i.style.borderRightColor="",c.style.backgroundColor=c.style.borderLeftColor=c.style.borderRightColor=""),e.animation===!0?B(t,"no-animation"):E(t,"no-animation")},R=function(t,n){var o=v();t?(E(o,"show-swal2"),E(u,"fade"),B(o,"hide-swal2")):B(o,"fade"),A(o),u.style.overflowY="hidden",H&&!S(o,"no-animation")?o.addEventListener(H,function r(){o.removeEventListener(H,r),u.style.overflowY="auto"}):u.style.overflowY="auto",E(u,"in"),E(document.body,a["in"]),e(),f.previousActiveElement=document.activeElement,null!==n&&"function"==typeof n&&n.call(this,o)};return o.isVisible=function(){var e=v();return M(e)},o.queue=function(e){W=e;var t=v()||o.init(),n=function(){W=[],t.removeAttribute("data-queue-step")};return new Promise(function(e,r){!function i(a,l){a<W.length?(t.setAttribute("data-queue-step",a),o(W[a]).then(function(){i(a+1,l)},function(e){n(),r(e)})):(n(),e())}(0)})},o.getQueueStep=function(){return v().getAttribute("data-queue-step")},o.insertQueueStep=function(e,t){return t&&t<W.length?W.splice(t,0,e):W.push(e)},o.deleteQueueStep=function(e){"undefined"!=typeof W[e]&&W.splice(e,1)},o.close=o.closeModal=function(e){var n=v();B(n,"show-swal2"),E(n,"hide-swal2");var o=n.querySelector("."+a.icon+"."+l.success);B(o,"animate"),B(o.querySelector(".tip"),"animate-success-tip"),B(o.querySelector(".long"),"animate-success-long");var r=n.querySelector("."+a.icon+"."+l.error);B(r,"animate-error-icon"),B(r.querySelector(".x-mark"),"animate-x-mark");var i=n.querySelector("."+a.icon+"."+l.warning);B(i,"pulse-warning"),N(),H&&!S(n,"no-animation")?n.addEventListener(H,function s(){n.removeEventListener(H,s),S(n,"hide-swal2")&&(q(n),B(u,"in"),B(document.body,a["in"]),t())}):(q(n),B(u,"in"),B(document.body,a["in"]),t()),null!==e&&"function"==typeof e&&e.call(this,n)},o.clickConfirm=function(){b().click()},o.clickCancel=function(){w().click()},o.init=function(){if("undefined"==typeof document)return void console.error("SweetAlert2 requires document to initialize");if(!document.getElementsByClassName(a.container).length){document.body.appendChild(u);var e=v(),t=P(e,a.input),n=P(e,a.file),r=e.querySelector("."+a.range+" input"),i=P(e,a.select),l=e.querySelector("."+a.checkbox+" input"),s=P(e,a.textarea);return t.oninput=function(){o.resetValidationError()},t.onkeyup=function(e){e.stopPropagation(),13===e.keyCode&&o.clickConfirm()},n.onchange=function(){o.resetValidationError()},r.oninput=function(){o.resetValidationError(),r.previousSibling.value=r.value},r.onchange=function(){o.resetValidationError(),r.previousSibling.value=r.value},i.onchange=function(){o.resetValidationError()},l.onchange=function(){o.resetValidationError()},s.oninput=function(){o.resetValidationError()},e}},o.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");d(D,e)},o.resetDefaults=function(){D=d({},s)},o.version="5.0.2",window.sweetAlert=window.swal=o,function(){"complete"===document.readyState||"interactive"===document.readyState&&document.body?o.init():document.addEventListener("DOMContentLoaded",function e(){document.removeEventListener("DOMContentLoaded",e,!1),o.init()},!1)}(),"function"==typeof Promise?Promise.prototype.done=Promise.prototype.done||function(){return this["catch"](function(){})}:console.warn("SweetAlert2: Please inlude Promise polyfill BEFORE including sweetalert2.js if IE10+ support needed."),o});
{
"name": "sweetalert2",
"version": "5.0.1",
"version": "5.0.2",
"repository": "https://github.com/limonte/sweetalert2.git",

@@ -5,0 +5,0 @@ "homepage": "https://limonte.github.io/sweetalert2/",

@@ -735,3 +735,6 @@ 'use strict';

if (input.attributes.hasOwnProperty(j)) {
input.removeAttribute(input.attributes[j].name);
var attrName = input.attributes[j].name;
if (attrName !== 'type' && attrName !== 'value') {
input.removeAttribute(attrName);
}
}

@@ -738,0 +741,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc