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
742
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 4.0.9 to 4.0.10

24

dist/sweetalert2.common.js
/*!
* sweetalert2 v4.0.9
* sweetalert2 v4.0.10
* Released under the MIT License.

@@ -196,15 +196,19 @@ */

var addClass = function(elem, className) {
if (className && !hasClass(elem, className)) {
elem.className += ' ' + className;
if (!elem || !className) {
return;
}
var classes = className.split(/\s+/);
for (var i in classes) {
elem.classList.add(classes[i]);
}
};
var removeClass = function(elem, className) {
var newClass = ' ' + elem.className.replace(/[\t\r\n]/g, ' ') + ' ';
if (hasClass(elem, className)) {
while (newClass.indexOf(' ' + className + ' ') >= 0) {
newClass = newClass.replace(' ' + className + ' ', ' ');
}
elem.className = newClass.replace(/^\s+|\s+$/g, '');
if (!elem || !className) {
return;
}
var classes = className.split(/\s+/);
for (var i in classes) {
elem.classList.remove(classes[i]);
}
};

@@ -1294,3 +1298,3 @@

sweetAlert.version = '4.0.9';
sweetAlert.version = '4.0.10';

@@ -1297,0 +1301,0 @@ window.sweetAlert = window.swal = sweetAlert;

/*!
* sweetalert2 v4.0.9
* sweetalert2 v4.0.10
* Released under the MIT License.

@@ -200,15 +200,19 @@ */

var addClass = function(elem, className) {
if (className && !hasClass(elem, className)) {
elem.className += ' ' + className;
if (!elem || !className) {
return;
}
var classes = className.split(/\s+/);
for (var i in classes) {
elem.classList.add(classes[i]);
}
};
var removeClass = function(elem, className) {
var newClass = ' ' + elem.className.replace(/[\t\r\n]/g, ' ') + ' ';
if (hasClass(elem, className)) {
while (newClass.indexOf(' ' + className + ' ') >= 0) {
newClass = newClass.replace(' ' + className + ' ', ' ');
}
elem.className = newClass.replace(/^\s+|\s+$/g, '');
if (!elem || !className) {
return;
}
var classes = className.split(/\s+/);
for (var i in classes) {
elem.classList.remove(classes[i]);
}
};

@@ -1298,3 +1302,3 @@

sweetAlert.version = '4.0.9';
sweetAlert.version = '4.0.10';

@@ -1301,0 +1305,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(){if(void 0===arguments[0])return console.error("sweetAlert2 expects at least 1 attribute!"),!1;var e=c({},V);switch(typeof arguments[0]){case"string":e.title=arguments[0],e.text=arguments[1]||"",e.type=arguments[2]||"";break;case"object":c(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('Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}H(e);var o=f();return new Promise(function(r,a){function l(e,t){for(var n=0;n<N.length;n++)if(e+=t,e===N.length?e=0:-1===e&&(e=N.length-1),N[e].offsetWidth||N[e].offsetHeight||N[e].getClientRects().length)return void N[e].focus()}function c(n){var o=n||window.event,i=o.keyCode||o.which;if(-1!==[9,13,32,27].indexOf(i)){for(var r=o.target||o.srcElement,c=-1,s=0;s<N.length;s++)if(r===N[s]){c=s;break}9===i?(o.shiftKey?l(c,-1):l(c,1),P(o)):13===i||32===i?-1===c&&T(M,o):27===i&&e.allowEscapeKey===!0&&(t.closeModal(e.onClose),a("esc"))}}e.timer&&(o.timeout=setTimeout(function(){t.closeModal(e.onClose),a("timer")},e.timer));var u=function(){switch(e.input){case"select":return k(o,i.select);case"radio":return o.querySelector("."+i.radio+" input:checked")||o.querySelector("."+i.radio+" input:first-child");case"checkbox":return o.querySelector("#"+i.checkbox);case"textarea":return k(o,i.textarea);default:return k(o,i.input)}},p=function(){var t=u();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=u();e&&g(e)},0);var f,L=function(n){e.showLoaderOnConfirm&&t.showLoading(),e.preConfirm?e.preConfirm(n,e.extraParams).then(function(o){t.closeModal(e.onClose),r(o||n)},function(e){t.hideLoading(),e&&t.showValidationError(e)}):(t.closeModal(e.onClose),r(n))},q=function(n){var i=n||window.event,r=i.target||i.srcElement,l=v()===r||v().contains(r),c=y()===r||y().contains(r),u=b(o,"visible");switch(i.type){case"mouseover":case"mouseup":case"focus":e.buttonsStyling&&(l?r.style.backgroundColor=s(e.confirmButtonColor,-.1):c&&(r.style.backgroundColor=s(e.cancelButtonColor,-.1)));break;case"mouseout":case"blur":e.buttonsStyling&&(l?r.style.backgroundColor=e.confirmButtonColor:c&&(r.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(l?r.style.backgroundColor=s(e.confirmButtonColor,-.2):c&&(r.style.backgroundColor=s(e.cancelButtonColor,-.2)));break;case"click":if(l&&u)if(e.input){var d=p();e.inputValidator?(t.disableInput(),e.inputValidator(d,e.extraParams).then(function(){t.enableInput(),L(d)},function(e){t.enableInput(),e&&t.showValidationError(e)})):L(d)}else L(!0);else c&&u&&(t.closeModal(e.onClose),a("cancel"))}},A=o.querySelectorAll("button");for(f=0;f<A.length;f++)A[f].onclick=q,A[f].onmouseover=q,A[f].onmouseout=q,A[f].onmousedown=q;h().onclick=function(){t.closeModal(e.onClose),a("close")},m().onclick=function(){e.allowOutsideClick&&(t.closeModal(e.onClose),a("overlay"))};var M=v(),O=y(),N=[M,O].concat(Array.prototype.slice.call(o.querySelectorAll("button:not([class^="+n+"]), input:not([type=hidden]), textarea, select")));for(f=0;f<N.length;f++)N[f].onfocus=q,N[f].onblur=q;e.reverseButtons&&M.parentNode.insertBefore(O,M),d.previousWindowKeyDown=window.onkeydown,window.onkeydown=c,e.buttonsStyling&&(M.style.borderLeftColor=e.confirmButtonColor,M.style.borderRightColor=e.confirmButtonColor),t.showLoading=t.enableLoading=function(){w(M,"loading"),w(o,"loading"),M.disabled=!0,O.disabled=!0},t.hideLoading=t.disableLoading=function(){C(M,"loading"),C(o,"loading"),M.disabled=!1,O.disabled=!1},t.enableButtons=function(){M.disabled=!1,O.disabled=!1},t.disableButtons=function(){M.disabled=!0,O.disabled=!0},t.enableInput=function(){var e=u();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},t.disableInput=function(){var e=u();if("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},t.showValidationError=function(e){var t=o.querySelector("."+i.validationerror);t.innerHTML=e,E(t);var n=u();g(n),w(n,"error")},t.resetValidationError=function(){var e=o.querySelector("."+i.validationerror);B(e);var t=u();t&&C(t,"error")},t.enableButtons(),t.hideLoading(),t.resetValidationError();var V,H=["input","select","radio","checkbox","textarea"];for(f=0;f<H.length;f++){var j=i[H[f]];for(V=k(o,j);V.attributes.length>0;)V.removeAttribute(V.attributes[0].name);for(var K in e.inputAttributes)V.setAttribute(K,e.inputAttributes[K]);V.className=j,e.inputClass&&w(V,e.inputClass),S(V)}var W;switch(e.input){case"text":case"email":case"password":case"file":V=k(o,i.input),V.value=e.inputValue,V.placeholder=e.inputPlaceholder,V.type=e.input,x(V);break;case"select":var U=k(o,i.select);if(U.innerHTML="",e.inputPlaceholder){var z=document.createElement("option");z.innerHTML=e.inputPlaceholder,z.value="",z.disabled=!0,z.selected=!0,U.appendChild(z)}W=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),U.appendChild(o)}x(U),U.focus()};break;case"radio":var R=k(o,i.radio);R.innerHTML="",W=function(t){for(var n in t){var o=1,r=document.createElement("input"),a=document.createElement("label"),l=document.createElement("span");r.type="radio",r.name=i.radio,r.value=n,r.id=i.radio+"-"+o++,e.inputValue===n&&(r.checked=!0),l.innerHTML=t[n],a.appendChild(r),a.appendChild(l),a["for"]=r.id,R.appendChild(a)}x(R);var c=R.querySelectorAll("input");c.length&&c[0].focus()};break;case"checkbox":var Z=k(o,i.checkbox),$=o.querySelector("#"+i.checkbox);$.value=1,$.checked=Boolean(e.inputValue);var _=Z.getElementsByTagName("span");_.length&&Z.removeChild(_[0]),_=document.createElement("span"),_.innerHTML=e.inputPlaceholder,Z.appendChild(_),x(Z);break;case"textarea":var F=k(o,i.textarea);F.value=e.inputValue,F.placeholder=e.inputPlaceholder,x(F);break;case null:break;default:console.error('Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox", "textarea" or "file", got '+typeof arguments[0])}"select"!==e.input&&"radio"!==e.input||(e.inputOptions instanceof Promise?(t.showLoading(),e.inputOptions.then(function(e){t.hideLoading(),W(e)})):"object"==typeof e.inputOptions?W(e.inputOptions):console.error("Unexpected type of inputOptions! Expected object or Promise, got "+e.inputOptions)),I(),D(e.animation,e.onOpen),l(-1,1)})}function t(){var n=arguments,o=f();return null===o&&(t.init(),o=f()),b(o,"visible")&&N(),e.apply(this,n)}var n="swal2-",o=function(e){var t={};for(var o in e)t[e[o]]=n+e[o];return t},i=o(["container","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","select","radio","checkbox","textarea","validationerror"]),r=o(["success","warning","info","question","error"]),a={title:"",text:"",html:"",type:null,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,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,onOpen:null,onClose:null},l='<div class="'+i.overlay+'" tabIndex="-1"></div><div class="'+i.modal+'" style="display: none" tabIndex="-1"><div class="'+i.icon+" "+r.error+'"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="'+i.icon+" "+r.question+'">?</div><div class="'+i.icon+" "+r.warning+'">!</div><div class="'+i.icon+" "+r.info+'">i</div><div class="'+i.icon+" "+r.success+'"><span class="line tip"></span> <span class="line long"></span><div class="placeholder"></div> <div class="fix"></div></div><img class="'+i.image+'"><h2></h2><div class="'+i.content+'"></div><input class="'+i.input+'"><select class="'+i.select+'"></select><div class="'+i.radio+'"></div><label for="'+i.checkbox+'" class="'+i.checkbox+'"><input type="checkbox" id="'+i.checkbox+'"></label><textarea class="'+i.textarea+'"></textarea><div class="'+i.validationerror+'"></div><hr class="'+i.spacer+'"><button class="'+i.confirm+'">OK</button><button class="'+i.cancel+'">Cancel</button><span class="'+i.close+'">&times;</span></div>',c=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},s=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 i=parseInt(e.substr(2*o,2),16);i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),n+=("00"+i).substr(i.length)}return n},u=n+"mediaquery",d={previousWindowKeyDown:null,previousActiveElement:null},p=function(e){return document.querySelector("."+e)},f=function(){return p(i.modal)},m=function(){return p(i.overlay)},v=function(){return p(i.confirm)},y=function(){return p(i.cancel)},h=function(){return p(i.close)},b=function(e,t){return e.classList.contains(t)},g=function(e){e.focus();var t=e.value;e.value="",e.value=t},w=function(e,t){t&&!b(e,t)&&(e.className+=" "+t)},C=function(e,t){var n=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(b(e,t)){for(;n.indexOf(" "+t+" ")>=0;)n=n.replace(" "+t+" "," ");e.className=n.replace(/^\s+|\s+$/g,"")}},k=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(b(e.childNodes[n],t))return e.childNodes[n]},x=function(e){e.style.opacity="",e.style.display="block"},E=function(e){if(e&&!e.length)return x(e);for(var t=0;t<e.length;++t)x(e[t])},S=function(e){e.style.opacity="",e.style.display="none"},B=function(e){if(e&&!e.length)return S(e);for(var t=0;t<e.length;++t)S(e[t])},L=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},q=function(e){var t=e.style.display;e.style.left="-9999px",e.style.display="block";var n=e.clientHeight;return e.style.left="",e.style.display=t,"-"+parseInt(n/2,10)+"px"},A=function(e,t){if(+e.style.opacity<1){t=t||16,e.style.opacity=0,e.style.display="block";var n=+new Date,o=function(){var i=+e.style.opacity+(new Date-n)/100;e.style.opacity=i>1?1:i,n=+new Date,+e.style.opacity<1&&setTimeout(o,t)};o()}},M=function(e,t){if(+e.style.opacity>0){t=t||16;var n=e.style.opacity,o=+new Date,i=function(){var r=new Date-o,a=+e.style.opacity-r/(100*n);e.style.opacity=a,o=+new Date,+e.style.opacity>0?setTimeout(i,t):S(e)};i()}},T=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()},P=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},O=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",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=f();window.onkeydown=d.previousWindowKeyDown,d.previousActiveElement&&d.previousActiveElement.focus(),clearTimeout(e.timeout);var t=document.getElementsByTagName("head")[0],n=document.getElementById(u);n&&t.removeChild(n)},V=c({},a),H=function(e){var t,n=f();n.style.width=e.width+"px",n.style.padding=e.padding+"px",n.style.marginLeft=-e.width/2+"px",n.style.background=e.background;var o=document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",a.id=u;var l=5,c=e.width+parseInt(e.width*(l/100)*2,10);a.innerHTML="@media screen and (max-width: "+c+"px) {."+i.modal+" {width: auto !important;left: "+l+"% !important;right: "+l+"% !important;margin-left: 0 !important;}}",o.appendChild(a);var s=n.querySelector("h2"),d=n.querySelector("."+i.content),p=v(),m=y(),h=n.querySelector("."+i.spacer),b=n.querySelector("."+i.close);if(s.innerHTML=e.title.split("\n").join("<br>"),e.text||e.html){if("object"==typeof e.html)if(d.innerHTML="",0 in e.html)for(t=0;t in e.html;t++)d.appendChild(e.html[t]);else d.appendChild(e.html);else d.innerHTML=e.html||e.text.split("\n").join("<br>");E(d)}else B(d);if(e.showCloseButton?E(b):B(b),n.className=i.modal,e.customClass&&w(n,e.customClass),B(n.querySelectorAll("."+i.icon)),e.type){var g=!1;for(var k in r)if(e.type===k){g=!0;break}if(!g)return console.error("Unknown alert type: "+e.type),!1;var x=n.querySelector("."+i.icon+"."+r[e.type]);switch(E(x),e.type){case"success":w(x,"animate"),w(x.querySelector(".tip"),"animate-success-tip"),w(x.querySelector(".long"),"animate-success-long");break;case"error":w(x,"animate-error-icon"),w(x.querySelector(".x-mark"),"animate-x-mark");break;case"warning":w(x,"pulse-warning")}}var S=n.querySelector("."+i.image);e.imageUrl?(S.setAttribute("src",e.imageUrl),E(S),e.imageWidth&&S.setAttribute("width",e.imageWidth),e.imageHeight&&S.setAttribute("height",e.imageHeight),e.imageClass&&w(S,e.imageClass)):B(S),e.showCancelButton?m.style.display="inline-block":B(m),e.showConfirmButton?L(p,"display"):B(p),e.showConfirmButton||e.showCancelButton?E(h):B(h),p.innerHTML=e.confirmButtonText,m.innerHTML=e.cancelButtonText,e.buttonsStyling&&(p.style.backgroundColor=e.confirmButtonColor,m.style.backgroundColor=e.cancelButtonColor),p.className=i.confirm,w(p,e.confirmButtonClass),m.className=i.cancel,w(m,e.cancelButtonClass),e.buttonsStyling?(w(p,"styled"),w(m,"styled")):(C(p,"styled"),C(m,"styled"),p.style.backgroundColor=p.style.borderLeftColor=p.style.borderRightColor="",m.style.backgroundColor=m.style.borderLeftColor=m.style.borderRightColor=""),e.animation===!0?C(n,"no-animation"):w(n,"no-animation")},D=function(e,t){var n=f();e?(A(m(),10),w(n,"show-swal2"),C(n,"hide-swal2")):E(m()),E(n),d.previousActiveElement=document.activeElement,w(n,"visible"),null!==t&&"function"==typeof t&&t.call(this,n)},I=function(){var e=f();e.style.marginTop=q(e)};return t.queue=function(e){return new Promise(function(n,o){!function i(r,a){r<e.length?t(e[r]).then(function(){i(r+1,a)},function(e){o(e)}):n()}(0)})},t.close=t.closeModal=function(e){var t=f();C(t,"show-swal2"),w(t,"hide-swal2"),C(t,"visible");var n=t.querySelector("."+i.icon+"."+r.success);C(n,"animate"),C(n.querySelector(".tip"),"animate-success-tip"),C(n.querySelector(".long"),"animate-success-long");var o=t.querySelector("."+i.icon+"."+r.error);C(o,"animate-error-icon"),C(o.querySelector(".x-mark"),"animate-x-mark");var a=t.querySelector("."+i.icon+"."+r.warning);C(a,"pulse-warning"),N(),O&&!b(t,"no-animation")?t.addEventListener(O,function l(){t.removeEventListener(O,l),b(t,"hide-swal2")&&(S(t),M(m(),0))}):(S(t),S(m())),null!==e&&"function"==typeof e&&e.call(this,t)},t.clickConfirm=function(){v().click()},t.clickCancel=function(){y().click()},t.init=function(){if("undefined"==typeof document)return void console.log("SweetAlert2 requires document to initialize");if(!document.getElementsByClassName(i.container).length){var e=document.createElement("div");e.className=i.container,e.innerHTML=l,document.body.appendChild(e);var n=f(),o=k(n,i.input),r=k(n,i.select),a=n.querySelector("#"+i.checkbox),c=k(n,i.textarea);o.oninput=function(){t.resetValidationError()},o.onkeyup=function(e){e.stopPropagation(),13===e.keyCode&&t.clickConfirm()},r.onchange=function(){t.resetValidationError()},a.onchange=function(){t.resetValidationError()},c.oninput=function(){t.resetValidationError()},window.addEventListener("resize",I,!1)}},t.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");c(V,e)},t.resetDefaults=function(){V=c({},a)},t.version="4.0.9",window.sweetAlert=window.swal=t,function(){"complete"===document.readyState||"interactive"===document.readyState&&document.body?t.init():document.addEventListener("DOMContentLoaded",function e(){document.removeEventListener("DOMContentLoaded",e,!1),t.init()},!1)}(),"function"==typeof Promise&&(Promise.prototype.done=function(){return this["catch"](function(){})}),t});
!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(){if(void 0===arguments[0])return console.error("sweetAlert2 expects at least 1 attribute!"),!1;var e=c({},H);switch(typeof arguments[0]){case"string":e.title=arguments[0],e.text=arguments[1]||"",e.type=arguments[2]||"";break;case"object":c(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('Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}N(e);var o=f();return new Promise(function(r,a){function l(e,t){for(var n=0;n<V.length;n++)if(e+=t,e===V.length?e=0:-1===e&&(e=V.length-1),V[e].offsetWidth||V[e].offsetHeight||V[e].getClientRects().length)return void V[e].focus()}function c(n){var o=n||window.event,i=o.keyCode||o.which;if(-1!==[9,13,32,27].indexOf(i)){for(var r=o.target||o.srcElement,c=-1,s=0;s<V.length;s++)if(r===V[s]){c=s;break}9===i?(o.shiftKey?l(c,-1):l(c,1),P(o)):13===i||32===i?-1===c&&T(M,o):27===i&&e.allowEscapeKey===!0&&(t.closeModal(e.onClose),a("esc"))}}e.timer&&(o.timeout=setTimeout(function(){t.closeModal(e.onClose),a("timer")},e.timer));var u=function(){switch(e.input){case"select":return k(o,i.select);case"radio":return o.querySelector("."+i.radio+" input:checked")||o.querySelector("."+i.radio+" input:first-child");case"checkbox":return o.querySelector("#"+i.checkbox);case"textarea":return k(o,i.textarea);default:return k(o,i.input)}},p=function(){var t=u();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=u();e&&g(e)},0);var f,L=function(n){e.showLoaderOnConfirm&&t.showLoading(),e.preConfirm?e.preConfirm(n,e.extraParams).then(function(o){t.closeModal(e.onClose),r(o||n)},function(e){t.hideLoading(),e&&t.showValidationError(e)}):(t.closeModal(e.onClose),r(n))},q=function(n){var i=n||window.event,r=i.target||i.srcElement,l=v()===r||v().contains(r),c=y()===r||y().contains(r),u=b(o,"visible");switch(i.type){case"mouseover":case"mouseup":case"focus":e.buttonsStyling&&(l?r.style.backgroundColor=s(e.confirmButtonColor,-.1):c&&(r.style.backgroundColor=s(e.cancelButtonColor,-.1)));break;case"mouseout":case"blur":e.buttonsStyling&&(l?r.style.backgroundColor=e.confirmButtonColor:c&&(r.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(l?r.style.backgroundColor=s(e.confirmButtonColor,-.2):c&&(r.style.backgroundColor=s(e.cancelButtonColor,-.2)));break;case"click":if(l&&u)if(e.input){var d=p();e.inputValidator?(t.disableInput(),e.inputValidator(d,e.extraParams).then(function(){t.enableInput(),L(d)},function(e){t.enableInput(),e&&t.showValidationError(e)})):L(d)}else L(!0);else c&&u&&(t.closeModal(e.onClose),a("cancel"))}},A=o.querySelectorAll("button");for(f=0;f<A.length;f++)A[f].onclick=q,A[f].onmouseover=q,A[f].onmouseout=q,A[f].onmousedown=q;h().onclick=function(){t.closeModal(e.onClose),a("close")},m().onclick=function(){e.allowOutsideClick&&(t.closeModal(e.onClose),a("overlay"))};var M=v(),O=y(),V=[M,O].concat(Array.prototype.slice.call(o.querySelectorAll("button:not([class^="+n+"]), input:not([type=hidden]), textarea, select")));for(f=0;f<V.length;f++)V[f].onfocus=q,V[f].onblur=q;e.reverseButtons&&M.parentNode.insertBefore(O,M),d.previousWindowKeyDown=window.onkeydown,window.onkeydown=c,e.buttonsStyling&&(M.style.borderLeftColor=e.confirmButtonColor,M.style.borderRightColor=e.confirmButtonColor),t.showLoading=t.enableLoading=function(){w(M,"loading"),w(o,"loading"),M.disabled=!0,O.disabled=!0},t.hideLoading=t.disableLoading=function(){C(M,"loading"),C(o,"loading"),M.disabled=!1,O.disabled=!1},t.enableButtons=function(){M.disabled=!1,O.disabled=!1},t.disableButtons=function(){M.disabled=!0,O.disabled=!0},t.enableInput=function(){var e=u();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},t.disableInput=function(){var e=u();if("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},t.showValidationError=function(e){var t=o.querySelector("."+i.validationerror);t.innerHTML=e,E(t);var n=u();g(n),w(n,"error")},t.resetValidationError=function(){var e=o.querySelector("."+i.validationerror);B(e);var t=u();t&&C(t,"error")},t.enableButtons(),t.hideLoading(),t.resetValidationError();var H,N=["input","select","radio","checkbox","textarea"];for(f=0;f<N.length;f++){var j=i[N[f]];for(H=k(o,j);H.attributes.length>0;)H.removeAttribute(H.attributes[0].name);for(var K in e.inputAttributes)H.setAttribute(K,e.inputAttributes[K]);H.className=j,e.inputClass&&w(H,e.inputClass),S(H)}var W;switch(e.input){case"text":case"email":case"password":case"file":H=k(o,i.input),H.value=e.inputValue,H.placeholder=e.inputPlaceholder,H.type=e.input,x(H);break;case"select":var U=k(o,i.select);if(U.innerHTML="",e.inputPlaceholder){var z=document.createElement("option");z.innerHTML=e.inputPlaceholder,z.value="",z.disabled=!0,z.selected=!0,U.appendChild(z)}W=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),U.appendChild(o)}x(U),U.focus()};break;case"radio":var R=k(o,i.radio);R.innerHTML="",W=function(t){for(var n in t){var o=1,r=document.createElement("input"),a=document.createElement("label"),l=document.createElement("span");r.type="radio",r.name=i.radio,r.value=n,r.id=i.radio+"-"+o++,e.inputValue===n&&(r.checked=!0),l.innerHTML=t[n],a.appendChild(r),a.appendChild(l),a["for"]=r.id,R.appendChild(a)}x(R);var c=R.querySelectorAll("input");c.length&&c[0].focus()};break;case"checkbox":var Z=k(o,i.checkbox),$=o.querySelector("#"+i.checkbox);$.value=1,$.checked=Boolean(e.inputValue);var _=Z.getElementsByTagName("span");_.length&&Z.removeChild(_[0]),_=document.createElement("span"),_.innerHTML=e.inputPlaceholder,Z.appendChild(_),x(Z);break;case"textarea":var F=k(o,i.textarea);F.value=e.inputValue,F.placeholder=e.inputPlaceholder,x(F);break;case null:break;default:console.error('Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox", "textarea" or "file", got '+typeof arguments[0])}"select"!==e.input&&"radio"!==e.input||(e.inputOptions instanceof Promise?(t.showLoading(),e.inputOptions.then(function(e){t.hideLoading(),W(e)})):"object"==typeof e.inputOptions?W(e.inputOptions):console.error("Unexpected type of inputOptions! Expected object or Promise, got "+e.inputOptions)),I(),D(e.animation,e.onOpen),l(-1,1)})}function t(){var n=arguments,o=f();return null===o&&(t.init(),o=f()),b(o,"visible")&&V(),e.apply(this,n)}var n="swal2-",o=function(e){var t={};for(var o in e)t[e[o]]=n+e[o];return t},i=o(["container","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","select","radio","checkbox","textarea","validationerror"]),r=o(["success","warning","info","question","error"]),a={title:"",text:"",html:"",type:null,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,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,onOpen:null,onClose:null},l='<div class="'+i.overlay+'" tabIndex="-1"></div><div class="'+i.modal+'" style="display: none" tabIndex="-1"><div class="'+i.icon+" "+r.error+'"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="'+i.icon+" "+r.question+'">?</div><div class="'+i.icon+" "+r.warning+'">!</div><div class="'+i.icon+" "+r.info+'">i</div><div class="'+i.icon+" "+r.success+'"><span class="line tip"></span> <span class="line long"></span><div class="placeholder"></div> <div class="fix"></div></div><img class="'+i.image+'"><h2></h2><div class="'+i.content+'"></div><input class="'+i.input+'"><select class="'+i.select+'"></select><div class="'+i.radio+'"></div><label for="'+i.checkbox+'" class="'+i.checkbox+'"><input type="checkbox" id="'+i.checkbox+'"></label><textarea class="'+i.textarea+'"></textarea><div class="'+i.validationerror+'"></div><hr class="'+i.spacer+'"><button class="'+i.confirm+'">OK</button><button class="'+i.cancel+'">Cancel</button><span class="'+i.close+'">&times;</span></div>',c=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},s=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 i=parseInt(e.substr(2*o,2),16);i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),n+=("00"+i).substr(i.length)}return n},u=n+"mediaquery",d={previousWindowKeyDown:null,previousActiveElement:null},p=function(e){return document.querySelector("."+e)},f=function(){return p(i.modal)},m=function(){return p(i.overlay)},v=function(){return p(i.confirm)},y=function(){return p(i.cancel)},h=function(){return p(i.close)},b=function(e,t){return e.classList.contains(t)},g=function(e){e.focus();var t=e.value;e.value="",e.value=t},w=function(e,t){if(e&&t){var n=t.split(/\s+/);for(var o in n)e.classList.add(n[o])}},C=function(e,t){if(e&&t){var n=t.split(/\s+/);for(var o in n)e.classList.remove(n[o])}},k=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(b(e.childNodes[n],t))return e.childNodes[n]},x=function(e){e.style.opacity="",e.style.display="block"},E=function(e){if(e&&!e.length)return x(e);for(var t=0;t<e.length;++t)x(e[t])},S=function(e){e.style.opacity="",e.style.display="none"},B=function(e){if(e&&!e.length)return S(e);for(var t=0;t<e.length;++t)S(e[t])},L=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},q=function(e){var t=e.style.display;e.style.left="-9999px",e.style.display="block";var n=e.clientHeight;return e.style.left="",e.style.display=t,"-"+parseInt(n/2,10)+"px"},A=function(e,t){if(+e.style.opacity<1){t=t||16,e.style.opacity=0,e.style.display="block";var n=+new Date,o=function(){var i=+e.style.opacity+(new Date-n)/100;e.style.opacity=i>1?1:i,n=+new Date,+e.style.opacity<1&&setTimeout(o,t)};o()}},M=function(e,t){if(+e.style.opacity>0){t=t||16;var n=e.style.opacity,o=+new Date,i=function(){var r=new Date-o,a=+e.style.opacity-r/(100*n);e.style.opacity=a,o=+new Date,+e.style.opacity>0?setTimeout(i,t):S(e)};i()}},T=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()},P=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},O=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",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}(),V=function(){var e=f();window.onkeydown=d.previousWindowKeyDown,d.previousActiveElement&&d.previousActiveElement.focus(),clearTimeout(e.timeout);var t=document.getElementsByTagName("head")[0],n=document.getElementById(u);n&&t.removeChild(n)},H=c({},a),N=function(e){var t,n=f();n.style.width=e.width+"px",n.style.padding=e.padding+"px",n.style.marginLeft=-e.width/2+"px",n.style.background=e.background;var o=document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",a.id=u;var l=5,c=e.width+parseInt(e.width*(l/100)*2,10);a.innerHTML="@media screen and (max-width: "+c+"px) {."+i.modal+" {width: auto !important;left: "+l+"% !important;right: "+l+"% !important;margin-left: 0 !important;}}",o.appendChild(a);var s=n.querySelector("h2"),d=n.querySelector("."+i.content),p=v(),m=y(),h=n.querySelector("."+i.spacer),b=n.querySelector("."+i.close);if(s.innerHTML=e.title.split("\n").join("<br>"),e.text||e.html){if("object"==typeof e.html)if(d.innerHTML="",0 in e.html)for(t=0;t in e.html;t++)d.appendChild(e.html[t]);else d.appendChild(e.html);else d.innerHTML=e.html||e.text.split("\n").join("<br>");E(d)}else B(d);if(e.showCloseButton?E(b):B(b),n.className=i.modal,e.customClass&&w(n,e.customClass),B(n.querySelectorAll("."+i.icon)),e.type){var g=!1;for(var k in r)if(e.type===k){g=!0;break}if(!g)return console.error("Unknown alert type: "+e.type),!1;var x=n.querySelector("."+i.icon+"."+r[e.type]);switch(E(x),e.type){case"success":w(x,"animate"),w(x.querySelector(".tip"),"animate-success-tip"),w(x.querySelector(".long"),"animate-success-long");break;case"error":w(x,"animate-error-icon"),w(x.querySelector(".x-mark"),"animate-x-mark");break;case"warning":w(x,"pulse-warning")}}var S=n.querySelector("."+i.image);e.imageUrl?(S.setAttribute("src",e.imageUrl),E(S),e.imageWidth&&S.setAttribute("width",e.imageWidth),e.imageHeight&&S.setAttribute("height",e.imageHeight),e.imageClass&&w(S,e.imageClass)):B(S),e.showCancelButton?m.style.display="inline-block":B(m),e.showConfirmButton?L(p,"display"):B(p),e.showConfirmButton||e.showCancelButton?E(h):B(h),p.innerHTML=e.confirmButtonText,m.innerHTML=e.cancelButtonText,e.buttonsStyling&&(p.style.backgroundColor=e.confirmButtonColor,m.style.backgroundColor=e.cancelButtonColor),p.className=i.confirm,w(p,e.confirmButtonClass),m.className=i.cancel,w(m,e.cancelButtonClass),e.buttonsStyling?(w(p,"styled"),w(m,"styled")):(C(p,"styled"),C(m,"styled"),p.style.backgroundColor=p.style.borderLeftColor=p.style.borderRightColor="",m.style.backgroundColor=m.style.borderLeftColor=m.style.borderRightColor=""),e.animation===!0?C(n,"no-animation"):w(n,"no-animation")},D=function(e,t){var n=f();e?(A(m(),10),w(n,"show-swal2"),C(n,"hide-swal2")):E(m()),E(n),d.previousActiveElement=document.activeElement,w(n,"visible"),null!==t&&"function"==typeof t&&t.call(this,n)},I=function(){var e=f();e.style.marginTop=q(e)};return t.queue=function(e){return new Promise(function(n,o){!function i(r,a){r<e.length?t(e[r]).then(function(){i(r+1,a)},function(e){o(e)}):n()}(0)})},t.close=t.closeModal=function(e){var t=f();C(t,"show-swal2"),w(t,"hide-swal2"),C(t,"visible");var n=t.querySelector("."+i.icon+"."+r.success);C(n,"animate"),C(n.querySelector(".tip"),"animate-success-tip"),C(n.querySelector(".long"),"animate-success-long");var o=t.querySelector("."+i.icon+"."+r.error);C(o,"animate-error-icon"),C(o.querySelector(".x-mark"),"animate-x-mark");var a=t.querySelector("."+i.icon+"."+r.warning);C(a,"pulse-warning"),V(),O&&!b(t,"no-animation")?t.addEventListener(O,function l(){t.removeEventListener(O,l),b(t,"hide-swal2")&&(S(t),M(m(),0))}):(S(t),S(m())),null!==e&&"function"==typeof e&&e.call(this,t)},t.clickConfirm=function(){v().click()},t.clickCancel=function(){y().click()},t.init=function(){if("undefined"==typeof document)return void console.log("SweetAlert2 requires document to initialize");if(!document.getElementsByClassName(i.container).length){var e=document.createElement("div");e.className=i.container,e.innerHTML=l,document.body.appendChild(e);var n=f(),o=k(n,i.input),r=k(n,i.select),a=n.querySelector("#"+i.checkbox),c=k(n,i.textarea);o.oninput=function(){t.resetValidationError()},o.onkeyup=function(e){e.stopPropagation(),13===e.keyCode&&t.clickConfirm()},r.onchange=function(){t.resetValidationError()},a.onchange=function(){t.resetValidationError()},c.oninput=function(){t.resetValidationError()},window.addEventListener("resize",I,!1)}},t.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");c(H,e)},t.resetDefaults=function(){H=c({},a)},t.version="4.0.10",window.sweetAlert=window.swal=t,function(){"complete"===document.readyState||"interactive"===document.readyState&&document.body?t.init():document.addEventListener("DOMContentLoaded",function e(){document.removeEventListener("DOMContentLoaded",e,!1),t.init()},!1)}(),"function"==typeof Promise&&(Promise.prototype.done=function(){return this["catch"](function(){})}),t});
{
"name": "sweetalert2",
"version": "4.0.9",
"version": "4.0.10",
"repository": "https://github.com/limonte/sweetalert2.git",

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

@@ -53,15 +53,19 @@ import { swalPrefix, swalClasses } from './classes.js';

export var addClass = function(elem, className) {
if (className && !hasClass(elem, className)) {
elem.className += ' ' + className;
if (!elem || !className) {
return;
}
var classes = className.split(/\s+/);
for (var i in classes) {
elem.classList.add(classes[i]);
}
};
export var removeClass = function(elem, className) {
var newClass = ' ' + elem.className.replace(/[\t\r\n]/g, ' ') + ' ';
if (hasClass(elem, className)) {
while (newClass.indexOf(' ' + className + ' ') >= 0) {
newClass = newClass.replace(' ' + className + ' ', ' ');
}
elem.className = newClass.replace(/^\s+|\s+$/g, '');
if (!elem || !className) {
return;
}
var classes = className.split(/\s+/);
for (var i in classes) {
elem.classList.remove(classes[i]);
}
};

@@ -68,0 +72,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