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 3.3.5 to 3.3.6

9

dist/sweetalert2.common.js
/*!
* sweetalert2 v3.3.4
* sweetalert2 v3.3.6
* Released under the MIT License.

@@ -73,3 +73,3 @@ */

background: '#fff',
input: null, // 'text' | 'email' | 'password' | 'select' | 'radio' | 'checkbox' | 'textarea'
input: null, // 'text' | 'email' | 'password' | 'select' | 'radio' | 'checkbox' | 'textarea' | 'file'
inputPlaceholder: '',

@@ -503,2 +503,3 @@ inputValue: '',

case 'password':
case 'file':
input = getChildByClass(modal, swalClasses.input);

@@ -748,2 +749,4 @@ input.value = params.inputValue;

return input.checked ? input.value : null;
case 'file':
return input.files.length ? input.files[0] : null;
default:

@@ -1214,3 +1217,3 @@ return params.inputAutoTrim? input.value.trim() : input.value;

sweetAlert.version = '3.3.4';
sweetAlert.version = '3.3.6';

@@ -1217,0 +1220,0 @@ window.sweetAlert = window.swal = sweetAlert;

/*!
* sweetalert2 v3.3.4
* sweetalert2 v3.3.6
* Released under the MIT License.

@@ -77,3 +77,3 @@ */

background: '#fff',
input: null, // 'text' | 'email' | 'password' | 'select' | 'radio' | 'checkbox' | 'textarea'
input: null, // 'text' | 'email' | 'password' | 'select' | 'radio' | 'checkbox' | 'textarea' | 'file'
inputPlaceholder: '',

@@ -507,2 +507,3 @@ inputValue: '',

case 'password':
case 'file':
input = getChildByClass(modal, swalClasses.input);

@@ -752,2 +753,4 @@ input.value = params.inputValue;

return input.checked ? input.value : null;
case 'file':
return input.files.length ? input.files[0] : null;
default:

@@ -1218,3 +1221,3 @@ return params.inputAutoTrim? input.value.trim() : input.value;

sweetAlert.version = '3.3.4';
sweetAlert.version = '3.3.6';

@@ -1221,0 +1224,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({},M);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}P(e),V(),N(e.animation);var o=m();return new Promise(function(r){function a(e,t){for(var n=0;n<B.length;n++)if(e+=t,e===B.length?e=0:-1===e&&(e=B.length-1),B[e].offsetWidth||B[e].offsetHeight||B[e].getClientRects().length)return void B[e].focus()}function l(n){var o=n||window.event,i=o.keyCode||o.which;if(-1!==[9,13,32,27].indexOf(i)){for(var l=o.target||o.srcElement,c=-1,s=0;s<B.length;s++)if(l===B[s]){c=s;break}9===i?(o.shiftKey?a(c,-1):a(c,1),A(o)):13===i||32===i?-1===c&&fireClick(S,o):27===i&&e.allowEscapeKey===!0&&(t.closeModal(),r(void 0))}}e.timer&&(o.timeout=setTimeout(function(){t.closeModal(),r(void 0)},e.timer));var c=function(){switch(e.input){case"select":return g(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 g(o,i.textarea);default:return g(o,i.input)}},u=function(){var t=c();switch(e.input){case"checkbox":return t.checked?1:0;case"radio":return t.checked?t.value:null;default:return e.inputAutoTrim?t.value.trim():t.value}};e.input&&setTimeout(function(){v(c())},0);var p,m=function(n){e.showLoaderOnConfirm&&t.showLoading(),e.preConfirm?e.preConfirm(n,e.extraParams).then(function(e){r(e||n),t.closeModal()},function(){t.hideLoading()}):(r(n),t.closeModal())},w=function(n){var a=n||window.event,l=a.target||a.srcElement,c=y(l,i.confirm),d=y(l,i.cancel),p=y(o,"visible");switch(a.type){case"mouseover":case"mouseup":case"focus":e.buttonsStyling&&(c?l.style.backgroundColor=s(e.confirmButtonColor,-.1):d&&(l.style.backgroundColor=s(e.cancelButtonColor,-.1)));break;case"mouseout":case"blur":e.buttonsStyling&&(c?l.style.backgroundColor=e.confirmButtonColor:d&&(l.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(c?l.style.backgroundColor=s(e.confirmButtonColor,-.2):d&&(l.style.backgroundColor=s(e.cancelButtonColor,-.2)));break;case"click":if(c&&p)if(e.input){var f=u();e.inputValidator?(t.disableInput(),e.inputValidator(f,e.extraParams).then(function(){t.enableInput(),m(f)},function(e){t.enableInput(),t.showValidationError(e)})):m(f)}else m(!0);else d&&p&&(t.closeModal(),r(!1))}},k=o.querySelectorAll("button");for(p=0;p<k.length;p++)k[p].onclick=w,k[p].onmouseover=w,k[p].onmouseout=w,k[p].onmousedown=w;d.previousDocumentClick=document.onclick,document.onclick=function(n){var o=n||window.event,a=o.target||o.srcElement;(y(a,i.close)||a===f()&&e.allowOutsideClick)&&(t.closeModal(),r(void 0))};var S=o.querySelector("button."+i.confirm),E=o.querySelector("button."+i.cancel),B=[S,E].concat(Array.prototype.slice.call(o.querySelectorAll("button:not([class^="+n+"]), input:not([type=hidden]), textarea, select")));for(p=0;p<B.length;p++)B[p].onfocus=w,B[p].onblur=w;e.reverseButtons&&S.parentNode.insertBefore(E,S),a(-1,1),d.previousWindowKeyDown=window.onkeydown,window.onkeydown=l,e.buttonsStyling&&(S.style.borderLeftColor=e.confirmButtonColor,S.style.borderRightColor=e.confirmButtonColor),t.showLoading=t.enableLoading=function(){h(S,"loading"),h(o,"loading"),E.disabled=!0},t.hideLoading=t.disableLoading=function(){b(S,"loading"),b(o,"loading"),E.disabled=!1},t.enableButtons=function(){S.disabled=!1,E.disabled=!1},t.disableButtons=function(){S.disabled=!0,E.disabled=!0},t.enableInput=function(){var e=c();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=c();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,C(t);var n=c();v(n),h(n,"error")},t.resetValidationError=function(){var e=o.querySelector("."+i.validationerror);x(e);var t=c();b(t,"error")},t.enableButtons(),t.hideLoading(),t.resetValidationError()})}function t(){var n=arguments,o=m();return null===o&&(t.init(),o=m()),y(o,"visible")&&T(),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},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={previousDocumentClick:null,previousWindowKeyDown:null,previousActiveElement:null},p=function(e){return document.querySelector("."+e)},m=function(){return p(i.modal)},f=function(){return p(i.overlay)},y=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},v=function(e){e.focus();var t=e.value;e.value="",e.value=t},h=function(e,t){t&&!y(e,t)&&(e.className+=" "+t)},b=function(e,t){var n=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(y(e,t)){for(;n.indexOf(" "+t+" ")>=0;)n=n.replace(" "+t+" "," ");e.className=n.replace(/^\s+|\s+$/g,"")}},g=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(e.childNodes[n].classList.contains(t))return e.childNodes[n]},w=function(e){e.style.opacity="",e.style.display="block"},C=function(e){if(e&&!e.length)return w(e);for(var t=0;t<e.length;++t)w(e[t])},k=function(e){e.style.opacity="",e.style.display="none"},x=function(e){if(e&&!e.length)return k(e);for(var t=0;t<e.length;++t)k(e[t])},S=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},E=function(e){e.style.left="-9999px",e.style.display="block";var t=e.clientHeight,n=parseInt(getComputedStyle(e).getPropertyValue("padding-top"),10);return e.style.left="",e.style.display="none","-"+parseInt(t/2+n,10)+"px"},B=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()}},q=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):k(e)};i()}},A=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},L=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}(),T=function(){var e=m();window.onkeydown=d.previousWindowKeyDown,document.onclick=d.previousDocumentClick,d.previousActiveElement&&d.previousActiveElement.focus(),clearTimeout(e.timeout);var t=document.getElementsByTagName("head")[0],n=document.getElementById(u);n&&t.removeChild(n)},M=c({},a),P=function(e){var t,n=m();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=n.querySelector("button."+i.confirm),f=n.querySelector("button."+i.cancel),y=n.querySelector("."+i.spacer),v=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>");C(d)}else x(d);if(e.showCloseButton?C(v):x(v),n.className=i.modal,e.customClass&&h(n,e.customClass),x(n.querySelectorAll("."+i.icon)),e.type){var E=!1;for(var B in r)if(e.type===B){E=!0;break}if(!E)return console.error("Unknown alert type: "+e.type),!1;var q=n.querySelector("."+i.icon+"."+r[e.type]);switch(C(q),e.type){case"success":h(q,"animate"),h(q.querySelector(".tip"),"animate-success-tip"),h(q.querySelector(".long"),"animate-success-long");break;case"error":h(q,"animate-error-icon"),h(q.querySelector(".x-mark"),"animate-x-mark");break;case"warning":h(q,"pulse-warning")}}var A=n.querySelector("."+i.image);e.imageUrl?(A.setAttribute("src",e.imageUrl),C(A),e.imageWidth&&A.setAttribute("width",e.imageWidth),e.imageHeight&&A.setAttribute("height",e.imageHeight),e.imageClass&&h(A,e.imageClass)):x(A);var L,T=["input","select","radio","checkbox","textarea"];for(t=0;t<T.length;t++){var M=i[T[t]];for(L=g(n,M);L.attributes.length>0;)L.removeAttribute(L.attributes[0].name);for(var P in e.inputAttributes)L.setAttribute(P,e.inputAttributes[P]);L.className=M,e.inputClass&&h(L,e.inputClass),k(L)}switch(e.input){case"text":case"email":case"password":L=g(n,i.input),L.value=e.inputValue,L.placeholder=e.inputPlaceholder,L.type=e.input,w(L);break;case"select":var N=g(n,i.select);if(N.innerHTML="",e.inputPlaceholder){var V=document.createElement("option");V.innerHTML=e.inputPlaceholder,V.value="",V.disabled=!0,V.selected=!0,N.appendChild(V)}for(var H in e.inputOptions){var O=document.createElement("option");O.value=H,O.innerHTML=e.inputOptions[H],e.inputValue===H&&(O.selected=!0),N.appendChild(O)}w(N);break;case"radio":var D=g(n,i.radio);D.innerHTML="";for(var I in e.inputOptions){var j=1,K=document.createElement("input"),W=document.createElement("label"),U=document.createElement("span");K.type="radio",K.name=i.radio,K.value=I,K.id=i.radio+"-"+j++,e.inputValue===I&&(K.checked=!0),U.innerHTML=e.inputOptions[I],W.appendChild(K),W.appendChild(U),W["for"]=K.id,D.appendChild(W)}w(D);break;case"checkbox":var z=g(n,i.checkbox),R=n.querySelector("#"+i.checkbox);R.value=1,R.checked=Boolean(e.inputValue);var Z=z.getElementsByTagName("span");Z.length&&z.removeChild(Z[0]),Z=document.createElement("span"),Z.innerHTML=e.inputPlaceholder,z.appendChild(Z),w(z);break;case"textarea":var $=g(n,i.textarea);$.value=e.inputValue,$.placeholder=e.inputPlaceholder,w($);break;case null:break;default:console.error('Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox" or "textarea", got '+typeof arguments[0])}e.showCancelButton?f.style.display="inline-block":x(f),e.showConfirmButton?S(p,"display"):x(p),e.showConfirmButton||e.showCancelButton?C(y):x(y),p.innerHTML=e.confirmButtonText,f.innerHTML=e.cancelButtonText,e.buttonsStyling&&(p.style.backgroundColor=e.confirmButtonColor,f.style.backgroundColor=e.cancelButtonColor),p.className=i.confirm,h(p,e.confirmButtonClass),f.className=i.cancel,h(f,e.cancelButtonClass),e.buttonsStyling?(h(p,"styled"),h(f,"styled")):(b(p,"styled"),b(f,"styled"),p.style.backgroundColor=p.style.borderLeftColor=p.style.borderRightColor="",f.style.backgroundColor=f.style.borderLeftColor=f.style.borderRightColor=""),e.animation===!0?b(n,"no-animation"):h(n,"no-animation")},N=function(e){var t=m();e?(B(f(),10),h(t,"show-swal2"),b(t,"hide-swal2")):C(f()),C(t),d.previousActiveElement=document.activeElement,h(t,"visible")},V=function(){var e=m();e.style.marginTop=E(e)};return t.queue=function(e){return new Promise(function(n,o){!function i(r,a){r<e.length?t(e[r]).then(function(e){e?i(r+1,a):o()}):n()}(0)})},t.close=t.closeModal=function(){var e=m();b(e,"show-swal2"),h(e,"hide-swal2"),b(e,"visible");var t=e.querySelector("."+i.icon+"."+r.success);b(t,"animate"),b(t.querySelector(".tip"),"animate-success-tip"),b(t.querySelector(".long"),"animate-success-long");var n=e.querySelector("."+i.icon+"."+r.error);b(n,"animate-error-icon"),b(n.querySelector(".x-mark"),"animate-x-mark");var o=e.querySelector("."+i.icon+"."+r.warning);b(o,"pulse-warning"),T(),L&&!y(e,"no-animation")?e.addEventListener(L,function a(){e.removeEventListener(L,a),y(e,"hide-swal2")&&(k(e),q(f(),0))}):(k(e),k(f()))},t.clickConfirm=function(){var e=m(),t=e.querySelector("button."+i.confirm);t.click()},t.clickCancel=function(){var e=m(),t=e.querySelector("button."+i.cancel);t.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=m(),o=g(n,i.input),r=g(n,i.select),a=n.querySelector("#"+i.checkbox),c=g(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.onchange=function(){t.resetValidationError()}}},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(M,e)},t.resetDefaults=function(){M=c({},a)},t.version="3.3.4",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)}(),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({},M);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}P(e),V(),N(e.animation);var o=m();return new Promise(function(r){function a(e,t){for(var n=0;n<B.length;n++)if(e+=t,e===B.length?e=0:-1===e&&(e=B.length-1),B[e].offsetWidth||B[e].offsetHeight||B[e].getClientRects().length)return void B[e].focus()}function l(n){var o=n||window.event,i=o.keyCode||o.which;if(-1!==[9,13,32,27].indexOf(i)){for(var l=o.target||o.srcElement,c=-1,s=0;s<B.length;s++)if(l===B[s]){c=s;break}9===i?(o.shiftKey?a(c,-1):a(c,1),A(o)):13===i||32===i?-1===c&&fireClick(S,o):27===i&&e.allowEscapeKey===!0&&(t.closeModal(),r(void 0))}}e.timer&&(o.timeout=setTimeout(function(){t.closeModal(),r(void 0)},e.timer));var c=function(){switch(e.input){case"select":return g(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 g(o,i.textarea);default:return g(o,i.input)}},u=function(){var t=c();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(){v(c())},0);var p,m=function(n){e.showLoaderOnConfirm&&t.showLoading(),e.preConfirm?e.preConfirm(n,e.extraParams).then(function(e){r(e||n),t.closeModal()},function(){t.hideLoading()}):(r(n),t.closeModal())},w=function(n){var a=n||window.event,l=a.target||a.srcElement,c=y(l,i.confirm),d=y(l,i.cancel),p=y(o,"visible");switch(a.type){case"mouseover":case"mouseup":case"focus":e.buttonsStyling&&(c?l.style.backgroundColor=s(e.confirmButtonColor,-.1):d&&(l.style.backgroundColor=s(e.cancelButtonColor,-.1)));break;case"mouseout":case"blur":e.buttonsStyling&&(c?l.style.backgroundColor=e.confirmButtonColor:d&&(l.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(c?l.style.backgroundColor=s(e.confirmButtonColor,-.2):d&&(l.style.backgroundColor=s(e.cancelButtonColor,-.2)));break;case"click":if(c&&p)if(e.input){var f=u();e.inputValidator?(t.disableInput(),e.inputValidator(f,e.extraParams).then(function(){t.enableInput(),m(f)},function(e){t.enableInput(),t.showValidationError(e)})):m(f)}else m(!0);else d&&p&&(t.closeModal(),r(!1))}},k=o.querySelectorAll("button");for(p=0;p<k.length;p++)k[p].onclick=w,k[p].onmouseover=w,k[p].onmouseout=w,k[p].onmousedown=w;d.previousDocumentClick=document.onclick,document.onclick=function(n){var o=n||window.event,a=o.target||o.srcElement;(y(a,i.close)||a===f()&&e.allowOutsideClick)&&(t.closeModal(),r(void 0))};var S=o.querySelector("button."+i.confirm),E=o.querySelector("button."+i.cancel),B=[S,E].concat(Array.prototype.slice.call(o.querySelectorAll("button:not([class^="+n+"]), input:not([type=hidden]), textarea, select")));for(p=0;p<B.length;p++)B[p].onfocus=w,B[p].onblur=w;e.reverseButtons&&S.parentNode.insertBefore(E,S),a(-1,1),d.previousWindowKeyDown=window.onkeydown,window.onkeydown=l,e.buttonsStyling&&(S.style.borderLeftColor=e.confirmButtonColor,S.style.borderRightColor=e.confirmButtonColor),t.showLoading=t.enableLoading=function(){h(S,"loading"),h(o,"loading"),E.disabled=!0},t.hideLoading=t.disableLoading=function(){b(S,"loading"),b(o,"loading"),E.disabled=!1},t.enableButtons=function(){S.disabled=!1,E.disabled=!1},t.disableButtons=function(){S.disabled=!0,E.disabled=!0},t.enableInput=function(){var e=c();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=c();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,C(t);var n=c();v(n),h(n,"error")},t.resetValidationError=function(){var e=o.querySelector("."+i.validationerror);x(e);var t=c();b(t,"error")},t.enableButtons(),t.hideLoading(),t.resetValidationError()})}function t(){var n=arguments,o=m();return null===o&&(t.init(),o=m()),y(o,"visible")&&T(),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},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={previousDocumentClick:null,previousWindowKeyDown:null,previousActiveElement:null},p=function(e){return document.querySelector("."+e)},m=function(){return p(i.modal)},f=function(){return p(i.overlay)},y=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},v=function(e){e.focus();var t=e.value;e.value="",e.value=t},h=function(e,t){t&&!y(e,t)&&(e.className+=" "+t)},b=function(e,t){var n=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(y(e,t)){for(;n.indexOf(" "+t+" ")>=0;)n=n.replace(" "+t+" "," ");e.className=n.replace(/^\s+|\s+$/g,"")}},g=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(e.childNodes[n].classList.contains(t))return e.childNodes[n]},w=function(e){e.style.opacity="",e.style.display="block"},C=function(e){if(e&&!e.length)return w(e);for(var t=0;t<e.length;++t)w(e[t])},k=function(e){e.style.opacity="",e.style.display="none"},x=function(e){if(e&&!e.length)return k(e);for(var t=0;t<e.length;++t)k(e[t])},S=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},E=function(e){e.style.left="-9999px",e.style.display="block";var t=e.clientHeight,n=parseInt(getComputedStyle(e).getPropertyValue("padding-top"),10);return e.style.left="",e.style.display="none","-"+parseInt(t/2+n,10)+"px"},B=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()}},q=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):k(e)};i()}},A=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},L=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}(),T=function(){var e=m();window.onkeydown=d.previousWindowKeyDown,document.onclick=d.previousDocumentClick,d.previousActiveElement&&d.previousActiveElement.focus(),clearTimeout(e.timeout);var t=document.getElementsByTagName("head")[0],n=document.getElementById(u);n&&t.removeChild(n)},M=c({},a),P=function(e){var t,n=m();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=n.querySelector("button."+i.confirm),f=n.querySelector("button."+i.cancel),y=n.querySelector("."+i.spacer),v=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>");C(d)}else x(d);if(e.showCloseButton?C(v):x(v),n.className=i.modal,e.customClass&&h(n,e.customClass),x(n.querySelectorAll("."+i.icon)),e.type){var E=!1;for(var B in r)if(e.type===B){E=!0;break}if(!E)return console.error("Unknown alert type: "+e.type),!1;var q=n.querySelector("."+i.icon+"."+r[e.type]);switch(C(q),e.type){case"success":h(q,"animate"),h(q.querySelector(".tip"),"animate-success-tip"),h(q.querySelector(".long"),"animate-success-long");break;case"error":h(q,"animate-error-icon"),h(q.querySelector(".x-mark"),"animate-x-mark");break;case"warning":h(q,"pulse-warning")}}var A=n.querySelector("."+i.image);e.imageUrl?(A.setAttribute("src",e.imageUrl),C(A),e.imageWidth&&A.setAttribute("width",e.imageWidth),e.imageHeight&&A.setAttribute("height",e.imageHeight),e.imageClass&&h(A,e.imageClass)):x(A);var L,T=["input","select","radio","checkbox","textarea"];for(t=0;t<T.length;t++){var M=i[T[t]];for(L=g(n,M);L.attributes.length>0;)L.removeAttribute(L.attributes[0].name);for(var P in e.inputAttributes)L.setAttribute(P,e.inputAttributes[P]);L.className=M,e.inputClass&&h(L,e.inputClass),k(L)}switch(e.input){case"text":case"email":case"password":case"file":L=g(n,i.input),L.value=e.inputValue,L.placeholder=e.inputPlaceholder,L.type=e.input,w(L);break;case"select":var N=g(n,i.select);if(N.innerHTML="",e.inputPlaceholder){var V=document.createElement("option");V.innerHTML=e.inputPlaceholder,V.value="",V.disabled=!0,V.selected=!0,N.appendChild(V)}for(var H in e.inputOptions){var O=document.createElement("option");O.value=H,O.innerHTML=e.inputOptions[H],e.inputValue===H&&(O.selected=!0),N.appendChild(O)}w(N);break;case"radio":var D=g(n,i.radio);D.innerHTML="";for(var I in e.inputOptions){var j=1,K=document.createElement("input"),W=document.createElement("label"),U=document.createElement("span");K.type="radio",K.name=i.radio,K.value=I,K.id=i.radio+"-"+j++,e.inputValue===I&&(K.checked=!0),U.innerHTML=e.inputOptions[I],W.appendChild(K),W.appendChild(U),W["for"]=K.id,D.appendChild(W)}w(D);break;case"checkbox":var z=g(n,i.checkbox),R=n.querySelector("#"+i.checkbox);R.value=1,R.checked=Boolean(e.inputValue);var Z=z.getElementsByTagName("span");Z.length&&z.removeChild(Z[0]),Z=document.createElement("span"),Z.innerHTML=e.inputPlaceholder,z.appendChild(Z),w(z);break;case"textarea":var $=g(n,i.textarea);$.value=e.inputValue,$.placeholder=e.inputPlaceholder,w($);break;case null:break;default:console.error('Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox" or "textarea", got '+typeof arguments[0])}e.showCancelButton?f.style.display="inline-block":x(f),e.showConfirmButton?S(p,"display"):x(p),e.showConfirmButton||e.showCancelButton?C(y):x(y),p.innerHTML=e.confirmButtonText,f.innerHTML=e.cancelButtonText,e.buttonsStyling&&(p.style.backgroundColor=e.confirmButtonColor,f.style.backgroundColor=e.cancelButtonColor),p.className=i.confirm,h(p,e.confirmButtonClass),f.className=i.cancel,h(f,e.cancelButtonClass),e.buttonsStyling?(h(p,"styled"),h(f,"styled")):(b(p,"styled"),b(f,"styled"),p.style.backgroundColor=p.style.borderLeftColor=p.style.borderRightColor="",f.style.backgroundColor=f.style.borderLeftColor=f.style.borderRightColor=""),e.animation===!0?b(n,"no-animation"):h(n,"no-animation")},N=function(e){var t=m();e?(B(f(),10),h(t,"show-swal2"),b(t,"hide-swal2")):C(f()),C(t),d.previousActiveElement=document.activeElement,h(t,"visible")},V=function(){var e=m();e.style.marginTop=E(e)};return t.queue=function(e){return new Promise(function(n,o){!function i(r,a){r<e.length?t(e[r]).then(function(e){e?i(r+1,a):o()}):n()}(0)})},t.close=t.closeModal=function(){var e=m();b(e,"show-swal2"),h(e,"hide-swal2"),b(e,"visible");var t=e.querySelector("."+i.icon+"."+r.success);b(t,"animate"),b(t.querySelector(".tip"),"animate-success-tip"),b(t.querySelector(".long"),"animate-success-long");var n=e.querySelector("."+i.icon+"."+r.error);b(n,"animate-error-icon"),b(n.querySelector(".x-mark"),"animate-x-mark");var o=e.querySelector("."+i.icon+"."+r.warning);b(o,"pulse-warning"),T(),L&&!y(e,"no-animation")?e.addEventListener(L,function a(){e.removeEventListener(L,a),y(e,"hide-swal2")&&(k(e),q(f(),0))}):(k(e),k(f()))},t.clickConfirm=function(){var e=m(),t=e.querySelector("button."+i.confirm);t.click()},t.clickCancel=function(){var e=m(),t=e.querySelector("button."+i.cancel);t.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=m(),o=g(n,i.input),r=g(n,i.select),a=n.querySelector("#"+i.checkbox),c=g(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.onchange=function(){t.resetValidationError()}}},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(M,e)},t.resetDefaults=function(){M=c({},a)},t.version="3.3.6",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)}(),t});
{
"name": "sweetalert2",
"version": "3.3.5",
"version": "3.3.6",
"repository": "https://github.com/limonte/sweetalert2.git",

@@ -45,3 +45,4 @@ "homepage": "https://limonte.github.io/sweetalert2/",

"test": "gulp test",
"postinstall": "if [ -d .git ]; then git ls-files dist | tr '\\n' ' ' | xargs git update-index --assume-unchanged; fi"
"assume-dist-unchanged": "git ls-files dist | tr '\\n' ' ' | xargs git update-index --assume-unchanged",
"no-assume-dist-unchanged": "git ls-files dist | tr '\\n' ' ' | xargs git update-index --no-assume-unchanged"
},

@@ -48,0 +49,0 @@ "bugs": "https://github.com/limonte/sweetalert2/issues",

@@ -143,3 +143,3 @@ SweetAlert2 [![Build Status](https://travis-ci.org/limonte/sweetalert2.svg?branch=master)](https://travis-ci.org/limonte/sweetalert2)

| `background` | `"#fff"` | Modal window background (CSS `background` property). |
| `input` | `null` | Input field type, can be `"text"`, `"email"`, `"password"`, `"textarea"`, `"select"`, `"radio"` and `"checkbox"`. |
| `input` | `null` | Input field type, can be `"text"`, `"email"`, `"password"`, `"textarea"`, `"select"`, `"radio"`, `"checkbox"` and `"file"`. |
| `inputPlaceholder` | `""` | Input field placeholder. |

@@ -146,0 +146,0 @@ | `inputValue` | `""` | Input field initial value. |

@@ -168,2 +168,3 @@ 'use strict';

case 'password':
case 'file':
input = dom.getChildByClass(modal, swalClasses.input);

@@ -413,2 +414,4 @@ input.value = params.inputValue;

return input.checked ? input.value : null;
case 'file':
return input.files.length ? input.files[0] : null;
default:

@@ -415,0 +418,0 @@ return params.inputAutoTrim? input.value.trim() : input.value;

@@ -32,3 +32,3 @@ import { swalClasses, iconTypes } from './classes.js';

background: '#fff',
input: null, // 'text' | 'email' | 'password' | 'select' | 'radio' | 'checkbox' | 'textarea'
input: null, // 'text' | 'email' | 'password' | 'select' | 'radio' | 'checkbox' | 'textarea' | 'file'
inputPlaceholder: '',

@@ -35,0 +35,0 @@ inputValue: '',

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

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