@syncfusion/ej2-notifications
Version:
A package of Essential JS 2 notification components such as Toast and Badge which used to notify important information to end-users.
12 lines (11 loc) • 31.1 kB
JavaScript
/*!
* filename: ej2-notifications.min.js
* version : 29.1.33
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
* licensing@syncfusion.com. Any infringement will be prosecuted under
* applicable laws.
*/
this.ej=this.ej||{},this.ej.notifications=function(t,e,s,i){"use strict";var n=function(){var t=function(e,s){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(e,s)};return function(e,s){function i(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(i.prototype=s.prototype,new i)}}(),o=function(t,e,s,i){var n,o=arguments.length,r=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,s,i);else for(var l=t.length-1;l>=0;l--)(n=t[l])&&(r=(o<3?n(r):o>3?n(e,s,r):n(e,s))||r);return o>3&&r&&Object.defineProperty(e,s,r),r},r="e-toast",l="e-toast-container",a="e-toast-message",h="e-toast-progress",c="e-toast-close-icon",p=function(t){function s(){return null!==t&&t.apply(this,arguments)||this}return n(s,t),o([e.Property("Left")],s.prototype,"X",void 0),o([e.Property("Top")],s.prototype,"Y",void 0),s}(e.ChildProperty),d=function(t){function s(){return null!==t&&t.apply(this,arguments)||this}return n(s,t),o([e.Property(null)],s.prototype,"model",void 0),o([e.Property(null)],s.prototype,"click",void 0),s}(e.ChildProperty),u=function(t){function s(){return null!==t&&t.apply(this,arguments)||this}return n(s,t),o([e.Property("FadeIn")],s.prototype,"effect",void 0),o([e.Property(600)],s.prototype,"duration",void 0),o([e.Property("ease")],s.prototype,"easing",void 0),s}(e.ChildProperty),m=function(t){function s(){return null!==t&&t.apply(this,arguments)||this}return n(s,t),o([e.Complex({effect:"FadeIn",duration:600,easing:"ease"},u)],s.prototype,"show",void 0),o([e.Complex({effect:"FadeOut",duration:600,easing:"ease"},u)],s.prototype,"hide",void 0),s}(e.ChildProperty),f=function(t){function u(e,s){var i=t.call(this,e,s)||this;return i.toastCollection=[],i.needsID=!0,i}return n(u,t),u.prototype.getModuleName=function(){return"toast"},u.prototype.getPersistData=function(){return this.addOnPersist([])},u.prototype.destroy=function(){this.hide("All"),this.element.classList.remove(l),e.setStyleAttribute(this.element,{position:"","z-index":""}),e.isNullOrUndefined(this.refElement)||e.isNullOrUndefined(this.refElement.parentElement)||(this.refElement.parentElement.insertBefore(this.element,this.refElement),e.detach(this.refElement),this.refElement=void 0),this.isBlazorServer()||t.prototype.destroy.call(this)},u.prototype.preRender=function(){this.isDevice=e.Browser.isDevice,"300px"===this.width&&(this.width=this.isDevice&&screen.width<768?"100%":"300px"),e.isNullOrUndefined(this.target)&&(this.target=document.body),this.enableRtl&&!this.isBlazorServer()&&this.element.classList.add("e-rtl")},u.prototype.render=function(){this.progressObj=[],this.intervalId=[],this.contentTemplate=null,this.toastTemplate=null,this.renderComplete(),this.initRenderClass=this.element.className},u.prototype.show=function(t){var s;if(e.isNullOrUndefined(t)||(this.templateChanges(t),s=JSON.parse(JSON.stringify(t)),e.extend(this,this,t)),e.isNullOrUndefined(this.toastContainer)){this.toastContainer=this.getContainer();var i="string"==typeof this.target?document.querySelector(this.target):"object"==typeof this.target?this.target:document.body;if(e.isNullOrUndefined(i))return;"BODY"===i.tagName?this.toastContainer.style.position="fixed":(this.toastContainer.style.position="absolute",i.style.position="relative"),this.setPositioning(this.position),i.appendChild(this.toastContainer)}if(this.isBlazorServer()&&this.element.classList.contains("e-control"))return void this.isToastModel(t);this.toastEle=this.createElement("div",{className:r,id:e.getUniqueID("toast")}),this.setWidthHeight(),this.setCSSClass(this.cssClass),e.isNullOrUndefined(this.template)||""===this.template?this.personalizeToast():this.templateRendering(),this.setProgress(),this.setCloseButton(),this.setAria(),this.appendToTarget(t),this.isDevice&&screen.width<768&&new e.Touch(this.toastEle,{swipe:this.swipeHandler.bind(this)}),e.isNullOrUndefined(s)||(e.extend(s,{element:[this.toastEle]},!0),this.toastCollection.push(s)),this.isReact&&this.renderReactTemplates()},u.prototype.showToast=function(t,e){this.toastEle=this.element.querySelector("#"+t),this.show(e)},u.prototype.isToastModel=function(t){this.toastContainer=this.element,this.setPositioning(this.position);var s=this;e.isNullOrUndefined(s.element.lastElementChild)||this.setProgress(),this.setAria(),this.appendToTarget(t)},u.prototype.swipeHandler=function(t){var s=e.closest(t.originalEvent.target,"."+r+":not(."+l+")"),i=this.animation.hide.effect;e.isNullOrUndefined(s)||("Right"===t.swipeDirection?(this.animation.hide.effect="SlideRightOut",this.hideToast("swipe",s)):"Left"===t.swipeDirection&&(this.animation.hide.effect="SlideLeftOut",this.hideToast("swipe",s)),this.animation.hide.effect=i)},u.prototype.templateChanges=function(t){e.isUndefined(t.content)||e.isNullOrUndefined(this.contentTemplate)||this.content===t.content||this.clearContentTemplate(),e.isUndefined(t.template)||e.isNullOrUndefined(this.toastTemplate)||this.template===t.template||this.clearToastTemplate()},u.prototype.setCSSClass=function(t){if(t){var s=-1!==t.indexOf(",")?",":" ";e.classList(this.toastEle,t.split(s),[]),this.toastContainer&&e.classList(this.toastContainer,t.split(s),[])}},u.prototype.setWidthHeight=function(){"300px"===this.width?this.toastEle.style.width=e.formatUnit(this.width):"100%"===this.width?this.toastContainer.classList.add("e-toast-full-width"):(this.toastEle.style.width=e.formatUnit(this.width),this.toastContainer.classList.remove("e-toast-full-width")),this.toastEle.style.height=e.formatUnit(this.height)},u.prototype.templateRendering=function(){this.fetchEle(this.toastEle,this.template,"template")},u.prototype.sanitizeHelper=function(t){if(this.enableHtmlSanitizer){var s=e.SanitizeHtmlHelper.beforeSanitize(),i={cancel:!1,helper:null};e.extend(s,s,i),this.trigger("beforeSanitizeHtml",s),s.cancel&&!e.isNullOrUndefined(s.helper)?t=s.helper(t):s.cancel||(t=e.SanitizeHtmlHelper.serializeValue(s,t))}return t},u.prototype.hide=function(t){this.hideToast("",t)},u.prototype.hideToast=function(t,s){if(!e.isNullOrUndefined(this.toastContainer)&&0!==this.toastContainer.childElementCount)if("string"!=typeof s||"All"!==s)e.isNullOrUndefined(s)&&(s=this.newestOnTop?this.toastContainer.lastElementChild:this.toastContainer.firstElementChild),this.destroyToast(s,t);else for(var i=0;i<this.toastContainer.childElementCount;i++)this.destroyToast(this.toastContainer.children[i],t)},u.prototype.fetchEle=function(t,s,i){s="string"==typeof s?this.sanitizeHelper(s):s;var n,o,r,l;if(l=t.classList.contains("e-toast-title")?this.element.id+"title":t.classList.contains("e-toast-content")?this.element.id+"content":this.element.id+"template",o="content"===i?this.contentTemplate:this.toastTemplate,!e.isNullOrUndefined(o))return t.appendChild(o.cloneNode(!0)),t;try{if("function"!=typeof s&&document.querySelectorAll(s).length>0){var a=null;"title"!==i&&(a=document.querySelector(s),t.appendChild(a),a.style.display="");var h=e.isNullOrUndefined(a)?o:a.cloneNode(!0);"content"===i?this.contentTemplate=h:this.toastTemplate=h}else n=e.compile(s)}catch(t){n="object"==typeof s?e.compile(s):e.compile(e.initializeCSPTemplate(function(){return s}))}if(!e.isNullOrUndefined(n))if(this.isBlazorServer()){r=n({},this,i,l,!0)}else r=n({},this,i,null,!0);return e.isNullOrUndefined(r)||!(r.length>0)||e.isNullOrUndefined(r[0].tagName)&&1===r.length?"function"!=typeof s&&0===t.childElementCount&&(t.innerHTML=s):[].slice.call(r).forEach(function(s){e.isNullOrUndefined(s.tagName)||(s.style.display=""),t.appendChild(s)}),t},u.prototype.clearProgress=function(t){e.isNullOrUndefined(this.intervalId[t])||(clearInterval(this.intervalId[t]),delete this.intervalId[t]),e.isNullOrUndefined(this.progressObj[t])||(clearInterval(this.progressObj[t].intervalId),delete this.progressObj[t])},u.prototype.removeToastContainer=function(t){t&&this.toastContainer.classList.contains("e-toast-util")&&e.detach(this.toastContainer)},u.prototype.clearContainerPos=function(t){var s=this;if(this.isBlazorServer())return void(this.toastContainer=null);this.customPosition?(e.setStyleAttribute(this.toastContainer,{left:"",top:""}),this.removeToastContainer(t),this.toastContainer=null,this.customPosition=!1):([r+"-top-left",r+"-top-right",r+"-bottom-left",r+"-bottom-right",r+"-bottom-center",r+"-top-center",r+"-full-width"].forEach(function(t){!e.isNullOrUndefined(s.toastContainer)&&s.toastContainer.classList.contains(t)&&s.toastContainer.classList.remove(t)}),this.removeToastContainer(t),this.toastContainer=null),e.isNullOrUndefined(this.contentTemplate)||this.clearContentTemplate(),e.isNullOrUndefined(this.toastTemplate)||this.clearToastTemplate()},u.prototype.clearContentTemplate=function(){this.contentTemplate.style.display="none",document.body.appendChild(this.contentTemplate),this.contentTemplate=null},u.prototype.clearToastTemplate=function(){this.toastTemplate.style.display="none",document.body.appendChild(this.toastTemplate),this.toastTemplate=null},u.prototype.isBlazorServer=function(){return e.isBlazor()&&this.isServerRendered},u.prototype.destroyToast=function(t,s){for(var i,n=this,o=0;o<this.toastCollection.length;o++)this.toastCollection[o].element[0]===t&&(i=this.toastCollection[o],this.toastCollection.splice(o,1));var r={options:this,cancel:!1,type:s,element:t,toastContainer:this.toastContainer},l=this.animation.hide,a={duration:l.duration,name:"None"===l.effect&&"Enable"===e.animationMode?"FadeOut":l.effect,timingFunction:l.easing},c=parseInt(t.id.split("toast_")[1],10),p=this.isBlazorServer()?{options:i,toastContainer:this.toastContainer}:{options:i,toastContainer:this.toastContainer,toastObj:this};this.trigger("beforeClose",r,function(s){s.cancel||(e.isNullOrUndefined(n.progressObj[c])||e.isNullOrUndefined(t.querySelector("."+h))||(n.progressObj[c].progressEle.style.width="0%"),a.end=function(){n.clearProgress(c),n.isBlazorServer()&&!e.isNullOrUndefined(i)||e.detach(t),n.trigger("close",p),0===n.toastContainer.childElementCount&&n.clearContainerPos(!0),l=null,a=null},new e.Animation(a).animate(t))})},u.prototype.personalizeToast=function(){this.setIcon(),this.setTitle(),this.setContent(),this.actionButtons()},u.prototype.setAria=function(){e.attributes(this.toastEle,{role:"alert"})},u.prototype.setPositioning=function(t){this.isBlazorServer()||(isNaN(parseFloat(t.X))&&isNaN(parseFloat(t.Y))?this.toastContainer.classList.add(r+"-"+t.Y.toString().toLowerCase()+"-"+t.X.toString().toLowerCase()):(this.customPosition=!0,e.setStyleAttribute(this.toastContainer,{left:e.formatUnit(t.X),top:e.formatUnit(t.Y)})))},u.prototype.setCloseButton=function(){if(this.showCloseButton){var t={close:"Close"};this.l10n=new e.L10n("toast",t,this.locale),this.l10n.setLocale(this.locale);var s=this.l10n.getConstant("close"),i=this.createElement("div",{className:c+" e-icons ",attrs:{tabindex:"0","aria-label":s,role:"button"}});this.toastEle.classList.add("e-toast-header-close-icon"),this.toastEle.appendChild(i)}},u.prototype.setProgress=function(){if(this.timeOut>0){var t=parseInt(this.toastEle.id.split("toast_")[1],10);this.intervalId[t]=window.setTimeout(this.destroyToast.bind(this,this.toastEle),this.timeOut),this.progressObj[t]={hideEta:null,intervalId:null,maxHideTime:null,element:null,timeOutId:null,progressEle:null},this.progressObj[t].maxHideTime=parseFloat(this.timeOut+""),this.progressObj[t].hideEta=(new Date).getTime()+this.progressObj[t].maxHideTime,this.progressObj[t].element=this.toastEle,this.extendedTimeout>0&&(e.EventHandler.add(this.toastEle,"mouseover",this.toastHoverAction.bind(this,t)),e.EventHandler.add(this.toastEle,"mouseleave",this.delayedToastProgress.bind(this,t)),this.progressObj[t].timeOutId=this.intervalId[t]),this.showProgressBar&&(this.progressBarEle=this.createElement("div",{className:h}),this.toastEle.insertBefore(this.progressBarEle,this.toastEle.children[0]),this.progressObj[t].intervalId=setInterval(this.updateProgressBar.bind(this,this.progressObj[t]),10),this.progressObj[t].progressEle=this.progressBarEle)}},u.prototype.toastHoverAction=function(t){clearTimeout(this.progressObj[t].timeOutId),clearInterval(this.progressObj[t].intervalId),this.progressObj[t].hideEta=0;var s=this.progressObj[t].element;e.isNullOrUndefined(s.querySelector("."+h))||(this.progressObj[t].progressEle.style.width="0%")},u.prototype.delayedToastProgress=function(t){var s=this.progressObj[t];if(!e.isNullOrUndefined(s)){var i=s.element;s.timeOutId=window.setTimeout(this.destroyToast.bind(this,i),this.extendedTimeout),s.maxHideTime=parseFloat(this.extendedTimeout+""),s.hideEta=(new Date).getTime()+s.maxHideTime,e.isNullOrUndefined(i.querySelector("."+h))||(s.intervalId=setInterval(this.updateProgressBar.bind(this,s),10))}},u.prototype.updateProgressBar=function(t){var e=(t.hideEta-(new Date).getTime())/t.maxHideTime*100;e="Ltr"===this.progressDirection?100-e:e,t.progressEle.style.width=e+"%"},u.prototype.setIcon=function(){if(!e.isNullOrUndefined(this.icon)&&0!==this.icon.length){var t=this.createElement("div",{className:"e-toast-icon e-icons "+this.icon});this.toastEle.classList.add("e-toast-header-icon"),this.toastEle.appendChild(t)}},u.prototype.setTitle=function(){if(!e.isNullOrUndefined(this.title)){var t=this.createElement("div",{className:"e-toast-title"});t=this.fetchEle(t,this.title,"title");var s=this.createElement("div",{className:a});s.appendChild(t),this.toastEle.appendChild(s)}},u.prototype.setContent=function(){var t=this.createElement("div",{className:"e-toast-content"}),s=this.element;if(e.isNullOrUndefined(this.content)||""===this.content){var i=""!==this.element.innerHTML.replace(/\s/g,"");if((s.children.length>0||i)&&(!s.firstElementChild||!s.firstElementChild.classList.contains(r))){this.innerEle=document.createDocumentFragment();for(var n=this.createElement("div");0!==s.childNodes.length;)this.innerEle.appendChild(this.element.childNodes[0]);t.appendChild(this.innerEle),[].slice.call(t.children).forEach(function(t){n.appendChild(t.cloneNode(!0))}),this.content=n,this.appendMessageContainer(t)}}else"object"!=typeof this.content||e.isNullOrUndefined(this.content.tagName)?(t=this.fetchEle(t,this.content,"content"),this.appendMessageContainer(t)):(t.appendChild(this.content),this.content=this.content.cloneNode(!0),this.appendMessageContainer(t))},u.prototype.appendMessageContainer=function(t){if(this.toastEle.querySelectorAll("."+a).length>0)this.toastEle.querySelector("."+a).appendChild(t);else{var e=this.createElement("div",{className:a});e.appendChild(t),this.toastEle.appendChild(e)}},u.prototype.actionButtons=function(){var t=this,i=this.createElement("div",{className:"e-toast-actions"});[].slice.call(this.buttons).forEach(function(n){if(!e.isNullOrUndefined(n.model)){var o=t.createElement("button");o.setAttribute("type","button"),(e.isNullOrUndefined(n.model.cssClass)||0===n.model.cssClass.length)&&(n.model.cssClass="e-primary "+t.cssClass),o.classList.add("e-small"),new s.Button(n.model,o),e.isNullOrUndefined(n.click)||"function"!=typeof n.click||e.EventHandler.add(o,"click",n.click),i.appendChild(o)}}),i.childElementCount>0&&this.appendMessageContainer(i)},u.prototype.appendToTarget=function(t){var s=this,n=this.isBlazorServer()?{options:t,element:this.toastEle,cancel:!1}:{options:t,toastObj:this,element:this.toastEle,cancel:!1};this.trigger("beforeOpen",n,function(n){if(n.cancel){if(s.isBlazorServer()){var o=parseInt(s.toastEle.id.split("toast_")[1],10);s.clearProgress(o),e.detach(s.toastEle),0===s.toastContainer.childElementCount&&s.clearContainerPos()}}else s.isBlazorServer()||(s.toastEle.style.display="none"),s.newestOnTop&&0!==s.toastContainer.childElementCount?s.toastContainer.insertBefore(s.toastEle,s.toastContainer.children[0]):s.isBlazorServer()||s.toastContainer.appendChild(s.toastEle),e.removeClass([s.toastEle],"e-blazor-toast-hidden"),e.EventHandler.add(s.toastEle,"click",s.clickHandler,s),e.EventHandler.add(s.toastEle,"keydown",s.keyDownHandler,s),s.toastContainer.style.zIndex=i.getZindexPartial(s.toastContainer)+"",s.displayToast(s.toastEle,t)})},u.prototype.clickHandler=function(t){var s=this;this.isBlazorServer()||t.stopPropagation();var i=t.target,n=e.closest(i,"."+r),o=this.isBlazorServer()?{element:n,cancel:!1,clickToClose:!1,originalEvent:t}:{element:n,cancel:!1,clickToClose:!1,originalEvent:t,toastObj:this},l=i.classList.contains(c);this.trigger("click",o,function(t){(l&&!t.cancel||t.clickToClose)&&s.destroyToast(n,"click")})},u.prototype.keyDownHandler=function(t){if(t.target.classList.contains(c)&&(13===t.keyCode||32===t.keyCode)){var s=t.target,i=e.closest(s,"."+r);this.destroyToast(i,"key")}},u.prototype.displayToast=function(t,s){var i=this,n=this.animation.show,o={duration:n.duration,name:"None"===n.effect&&"Enable"===e.animationMode?"FadeIn":n.effect,timingFunction:n.easing},r=this.isBlazorServer()?{options:s,element:this.toastEle}:{options:s,toastObj:this,element:this.toastEle};o.begin=function(){t.style.display=""},o.end=function(){i.trigger("open",r)},new e.Animation(o).animate(t)},u.prototype.getContainer=function(){return this.element.classList.add(l),this.element},u.prototype.onPropertyChanged=function(t,e){for(var s=this.element,i=0,n=Object.keys(t);i<n.length;i++)switch(n[i]){case"enableRtl":t.enableRtl?s.classList.add("e-rtl"):s.classList.remove("e-rtl")}},o([e.Property("300px")],u.prototype,"width",void 0),o([e.Property("auto")],u.prototype,"height",void 0),o([e.Property(null)],u.prototype,"title",void 0),o([e.Property(null)],u.prototype,"content",void 0),o([e.Property(!0)],u.prototype,"enableHtmlSanitizer",void 0),o([e.Property(null)],u.prototype,"icon",void 0),o([e.Property(null)],u.prototype,"cssClass",void 0),o([e.Property(null)],u.prototype,"template",void 0),o([e.Property(!0)],u.prototype,"newestOnTop",void 0),o([e.Property(!1)],u.prototype,"showCloseButton",void 0),o([e.Property(!1)],u.prototype,"showProgressBar",void 0),o([e.Property(5e3)],u.prototype,"timeOut",void 0),o([e.Property("Rtl")],u.prototype,"progressDirection",void 0),o([e.Property(1e3)],u.prototype,"extendedTimeout",void 0),o([e.Complex({},m)],u.prototype,"animation",void 0),o([e.Complex({},p)],u.prototype,"position",void 0),o([e.Collection([{}],d)],u.prototype,"buttons",void 0),o([e.Property(null)],u.prototype,"target",void 0),o([e.Event()],u.prototype,"created",void 0),o([e.Event()],u.prototype,"beforeSanitizeHtml",void 0),o([e.Event()],u.prototype,"destroyed",void 0),o([e.Event()],u.prototype,"open",void 0),o([e.Event()],u.prototype,"beforeOpen",void 0),o([e.Event()],u.prototype,"beforeClose",void 0),o([e.Event()],u.prototype,"close",void 0),o([e.Event()],u.prototype,"click",void 0),u=o([e.NotifyPropertyChanges],u)}(e.Component);!function(t){function s(t,s,i){var n;document.querySelector("."+l)?n=document.querySelector("."+l):(n=e.createElement("div",{className:r+" "+l+" e-toast-util"}),document.body.appendChild(n));var o;if("string"==typeof t){var a=void 0,h=void 0;if(e.isNullOrUndefined(s))a="",h="";else switch(s){case"Warning":a="e-toast-warning",h="e-toast-warning-icon";break;case"Success":a="e-toast-success",h="e-toast-success-icon";break;case"Error":a="e-toast-danger",h="e-toast-error-icon";break;case"Information":a="e-toast-info",h="e-toast-info-icon"}o={content:t,cssClass:a,icon:h,timeOut:e.isNullOrUndefined(i)?5e3:i}}else o=t;var c=new f(o);return c.appendTo(n),c.show(),c}t.show=s}(t.ToastUtility||(t.ToastUtility={}));var y=function(){var t=function(e,s){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(e,s)};return function(e,s){function i(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(i.prototype=s.prototype,new i)}}(),v=function(t,e,s,i){var n,o=arguments.length,r=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,s,i);else for(var l=t.length-1;l>=0;l--)(n=t[l])&&(r=(o<3?n(r):o>3?n(e,s,r):n(e,s))||r);return o>3&&r&&Object.defineProperty(e,s,r),r};!function(t){t.Normal="Normal",t.Success="Success",t.Info="Info",t.Warning="Warning",t.Error="Error"}(t.Severity||(t.Severity={})),function(t){t.Text="Text",t.Outlined="Outlined",t.Filled="Filled"}(t.Variant||(t.Variant={}));var C="e-hidden",g=function(t){function s(e,s){var i=t.call(this,e,s)||this;return i.initialRender=!0,i}return y(s,t),s.prototype.getModuleName=function(){return"message"},s.prototype.getPersistData=function(){return this.addOnPersist([])},s.prototype.preRender=function(){var t={close:"Close"};this.l10n=new e.L10n("message",t,this.locale)},s.prototype.render=function(){this.innerContent=this.element.innerHTML,this.element.innerHTML="",this.msgElement=this.createElement("div",{className:"e-msg-content-wrap"}),this.initialize(),this.wireEvents(),this.renderComplete(),this.renderReactTemplates(),this.initialRender=!1},s.prototype.initialize=function(){this.element.setAttribute("role","alert"),this.setCssClass(),this.setIcon(),this.setContent(),this.setCloseIcon(),this.setSeverity(),this.setVariant(),this.setVisible(),this.enableRtl&&this.element.classList.add("e-rtl")},s.prototype.setIcon=function(){this.showIcon&&(this.iconElement=this.createElement("span",{className:"e-msg-icon"}),this.element.classList.contains("e-content-center")?this.msgElement.appendChild(this.iconElement):this.element.appendChild(this.iconElement))},s.prototype.setCloseIcon=function(){this.showCloseIcon&&(this.closeIcon=this.createElement("button",{attrs:{type:"button",class:"e-msg-close-icon"}}),this.element.appendChild(this.closeIcon),this.setTitle())},s.prototype.setTitle=function(){this.l10n.setLocale(this.locale);var t=this.l10n.getConstant("close");this.closeIcon.setAttribute("title",t),this.closeIcon.setAttribute("aria-label",t)},s.prototype.setContent=function(){this.txtElement=this.createElement("div",{className:"e-msg-content"}),this.element.classList.contains("e-content-center")?(this.msgElement.appendChild(this.txtElement),this.element.appendChild(this.msgElement)):this.element.appendChild(this.txtElement),this.setTemplate()},s.prototype.setTemplate=function(){var t;if(e.isNullOrUndefined(this.content)||""===this.content)this.txtElement.innerHTML=this.innerContent;else if(!e.isNullOrUndefined(this.content)&&""!==this.content&&("string"==typeof this.content||"string"!=typeof this.content))if(this.isVue||"string"!=typeof this.content){if(t=e.compile(this.content),!e.isNullOrUndefined(t)){var s=t({},this,"content",this.element.id+"content",!0);s&&(s=Array.prototype.slice.call(s),e.append(s,this.txtElement),this.renderReactTemplates())}}else this.txtElement.innerHTML=this.content},s.prototype.setSeverity=function(){var t=["e-success","e-warning","e-info","e-error"];e.removeClass([this.element],t),"Success"===this.severity?e.addClass([this.element],"e-success"):"Warning"===this.severity?e.addClass([this.element],"e-warning"):"Error"===this.severity?e.addClass([this.element],"e-error"):"Info"===this.severity&&e.addClass([this.element],"e-info")},s.prototype.setVariant=function(){var t=["e-filled","e-outlined"];e.removeClass([this.element],t),"Outlined"===this.variant?e.addClass([this.element],"e-outlined"):"Filled"===this.variant&&e.addClass([this.element],"e-filled")},s.prototype.setCssClass=function(t){t&&e.removeClass([this.element],t.split(" ")),this.cssClass&&e.addClass([this.element],this.cssClass.split(" "))},s.prototype.setVisible=function(){this.visible?e.removeClass([this.element],C):(e.addClass([this.element],C),this.initialRender||this.trigger("closed",{event:event,isInteracted:!1,element:this.element}))},s.prototype.clickHandler=function(t){this.closeMessage(t)},s.prototype.keyboardHandler=function(t){32!==t.keyCode&&13!==t.keyCode||this.closeMessage(t)},s.prototype.closeMessage=function(t){e.addClass([this.element],C),this.setProperties({visible:!1},!0);var s={event:t,isInteracted:!0,element:this.element};this.trigger("closed",s)},s.prototype.wireEvents=function(){this.showCloseIcon&&(e.EventHandler.add(this.closeIcon,"click",this.clickHandler,this),e.EventHandler.add(this.closeIcon,"keydown",this.keyboardHandler,this))},s.prototype.unWireEvents=function(){this.showCloseIcon&&(e.EventHandler.remove(this.closeIcon,"click",this.clickHandler),e.EventHandler.remove(this.closeIcon,"keydown",this.keyboardHandler))},s.prototype.onPropertyChanged=function(t,s){for(var i=0,n=Object.keys(t);i<n.length;i++)switch(n[i]){case"cssClass":this.setCssClass(s.cssClass);break;case"content":this.txtElement.innerHTML="",this.setTemplate();break;case"enableRtl":this.enableRtl?this.element.classList.add("e-rtl"):this.element.classList.remove("e-rtl");break;case"locale":this.showCloseIcon&&this.setTitle();break;case"showIcon":!this.showIcon&&this.element.getElementsByClassName("e-msg-icon").length>0&&e.detach(this.iconElement),this.showIcon&&(this.iconElement=this.createElement("span",{className:"e-msg-icon"}),this.element.insertBefore(this.iconElement,this.txtElement));break;case"showCloseIcon":this.showCloseIcon||e.isNullOrUndefined(this.closeIcon)?(this.setCloseIcon(),this.wireEvents()):(this.unWireEvents(),e.detach(this.closeIcon));break;case"severity":this.setSeverity();break;case"variant":this.setVariant();break;case"visible":this.setVisible()}},s.prototype.destroy=function(){var s=e.isNullOrUndefined(this.cssClass)?[""]:this.cssClass.split(" "),i=["e-success","e-warning","e-info","e-error","e-rtl",C,"e-outlined","e-filled"],n=1===s.length&&""===s[0]?i:i.concat(s);e.removeClass([this.element],n),this.element.removeAttribute("role"),this.unWireEvents(),e.isNullOrUndefined(this.iconElement)||e.detach(this.iconElement),e.detach(this.txtElement),e.isNullOrUndefined(this.closeIcon)||e.detach(this.closeIcon),t.prototype.destroy.call(this)},v([e.Property(null)],s.prototype,"content",void 0),v([e.Property("")],s.prototype,"cssClass",void 0),v([e.Property(!0)],s.prototype,"showIcon",void 0),v([e.Property(!1)],s.prototype,"showCloseIcon",void 0),v([e.Property("Normal")],s.prototype,"severity",void 0),v([e.Property("Text")],s.prototype,"variant",void 0),v([e.Property(!0)],s.prototype,"visible",void 0),v([e.Event()],s.prototype,"created",void 0),v([e.Event()],s.prototype,"destroyed",void 0),v([e.Event()],s.prototype,"closed",void 0),s=v([e.NotifyPropertyChanges],s)}(e.Component),E=function(){var t=function(e,s){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(e,s)};return function(e,s){function i(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(i.prototype=s.prototype,new i)}}(),b=function(t,e,s,i){var n,o=arguments.length,r=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,s,i);else for(var l=t.length-1;l>=0;l--)(n=t[l])&&(r=(o<3?n(r):o>3?n(e,s,r):n(e,s))||r);return o>3&&r&&Object.defineProperty(e,s,r),r},O={TEXTSHAPE:"e-skeleton-text",CIRCLESHAPE:"e-skeleton-circle",SQUARESHAPE:"e-skeleton-square",RECTANGLESHAPE:"e-skeleton-rectangle",WAVEEFFECT:"e-shimmer-wave",PULSEEFFECT:"e-shimmer-pulse",FADEEFFECT:"e-shimmer-fade",VISIBLENONE:"e-visible-none"};!function(t){t.Text="Text",t.Circle="Circle",t.Square="Square",t.Rectangle="Rectangle"}(t.SkeletonType||(t.SkeletonType={})),function(t){t.Wave="Wave",t.Fade="Fade",t.Pulse="Pulse",t.None="None"}(t.ShimmerEffect||(t.ShimmerEffect={}));var T=function(t){function s(e,s){return t.call(this,e,s)||this}return E(s,t),s.prototype.getModuleName=function(){return"skeleton"},s.prototype.getPersistData=function(){return this.addOnPersist([])},s.prototype.preRender=function(){this.element.id||(this.element.id=e.getUniqueID("e-"+this.getModuleName())),this.updateCssClass(),e.attributes(this.element,{role:"alert","aria-busy":"true","aria-live":"polite","aria-label":this.label})},s.prototype.render=function(){this.initialize()},s.prototype.onPropertyChanged=function(t,s){for(var i=0,n=Object.keys(t);i<n.length;i++)switch(n[i]){case"width":case"height":this.updateDimension();break;case"shape":this.updateShape();break;case"shimmerEffect":this.updateEffect();break;case"visible":this.updateVisibility();break;case"label":this.element.setAttribute("aria-label",this.label);break;case"cssClass":s.cssClass&&e.removeClass([this.element],s.cssClass.split(" ")),this.updateCssClass()}},s.prototype.destroy=function(){t.prototype.destroy.call(this);var s=["role","aria-live","aria-busy","aria-label"],i=[];this.cssClass&&(i=i.concat(this.cssClass.split(" ")));for(var n=0;n<s.length;n++)this.element.removeAttribute(s[parseInt(n.toString(),10)]);i=(i=i.concat(this.element.classList.value.match(/(e-skeleton-[^\s]+)/g)||[])).concat(this.element.classList.value.match(/(e-shimmer-[^\s]+)/g)||[]),e.removeClass([this.element],i)},s.prototype.initialize=function(){this.updateShape(),this.updateEffect(),this.updateVisibility()},s.prototype.updateShape=function(){if(!e.isNullOrUndefined(this.shape)){var t=O[this.shape.toUpperCase()+"SHAPE"],s=this.element.classList.value.match(/(e-skeleton-[^\s]+)/g)||[];this.updateDimension(),s&&e.removeClass([this.element],s),e.addClass([this.element],[t])}},s.prototype.updateDimension=function(){var t=!this.width&&["Text","Rectangle"].indexOf(this.shape)>-1?"100%":e.formatUnit(this.width),s=["Circle","Square"].indexOf(this.shape)>-1?t:e.formatUnit(this.height);this.element.style.width=t,this.element.style.height=s},s.prototype.updateEffect=function(){var t=this.element.classList.value.match(/(e-shimmer-[^\s]+)/g)||[];t&&e.removeClass([this.element],t),e.isNullOrUndefined(this.shimmerEffect)||e.addClass([this.element],[O[this.shimmerEffect.toUpperCase()+"EFFECT"]])},s.prototype.updateVisibility=function(){this.element.classList[this.visible?"remove":"add"](O.VISIBLENONE)},s.prototype.updateCssClass=function(){this.cssClass&&e.addClass([this.element],this.cssClass.split(" "))},b([e.Property("")],s.prototype,"width",void 0),b([e.Property("")],s.prototype,"height",void 0),b([e.Property(!0)],s.prototype,"visible",void 0),b([e.Property("Text")],s.prototype,"shape",void 0),b([e.Property("Wave")],s.prototype,"shimmerEffect",void 0),b([e.Property("Loading...")],s.prototype,"label",void 0),b([e.Property("")],s.prototype,"cssClass",void 0),s=b([e.NotifyPropertyChanges],s)}(e.Component);return t.ButtonModelProps=d,t.Message=g,t.Skeleton=T,t.Toast=f,t.ToastAnimationSettings=m,t.ToastAnimations=u,t.ToastPosition=p,t}({},ej.base,ej.buttons,ej.popups),this.ejs=ej;
//# sourceMappingURL=ej2-notifications.min.js.map