Files
trafficpumper/public/js/filament/notifications/notifications.js
T

2 lines
6.0 KiB
JavaScript
Raw Normal View History

2026-08-29 15:53:53 +03:00
(()=>{function c(e,t=()=>{}){let i=!1;return function(){i?t.apply(this,arguments):(i=!0,e.apply(this,arguments))}}var d=e=>{e.data("notificationComponent",({notification:t})=>({isShown:!1,computedStyle:null,transitionDuration:null,transitionEasing:null,unsubscribeLivewireHook:null,init(){this.computedStyle=window.getComputedStyle(this.$el),this.transitionDuration=parseFloat(this.computedStyle.transitionDuration)*1e3,this.transitionEasing=this.computedStyle.transitionTimingFunction,this.configureTransitions(),this.configureAnimations(),t.duration&&t.duration!=="persistent"&&setTimeout(()=>{if(!this.$el.matches(":hover")){this.close();return}this.$el.addEventListener("mouseleave",()=>this.close())},t.duration),this.isShown=!0},configureTransitions(){let i=this.computedStyle.display,s=()=>{e.mutateDom(()=>{this.$el.style.setProperty("display",i),this.$el.style.setProperty("visibility","visible")}),this.$el._x_isShown=!0},n=()=>{e.mutateDom(()=>{this.$el._x_isShown?this.$el.style.setProperty("visibility","hidden"):this.$el.style.setProperty("display","none")})},r=c(o=>o?s():n(),o=>{this.$el._x_toggleAndCascadeWithTransitions(this.$el,o,s,n)});e.effect(()=>r(this.isShown))},configureAnimations(){this.$el.classList.contains("fi-inline")||(this.unsubscribeLivewireHook=Livewire.interceptMessage(({message:i,onSuccess:s})=>{i.component.snapshot.data.isFilamentNotificationsComponent&&requestAnimationFrame(()=>{let n=()=>this.$el.getBoundingClientRect().top,r=n();s(({onRender:o})=>{o(()=>{if(!this.isShown)return;this.$el.getAnimations().forEach(p=>p.finish());let l=n();r!==l&&(window.matchMedia("(prefers-reduced-motion: reduce)").matches||this.$el.animate([{transform:`translateY(${r-l}px)`},{transform:"translateY(0px)"}],{duration:this.transitionDuration,easing:this.transitionEasing}))})})})}))},close(i=!1){let s=()=>window.dispatchEvent(new CustomEvent("notificationClosed",{detail:{id:t.id}}));if(i===!0){this.isShown=!1,s();return}if(this.$root.classList.contains("fi-inline")){s();return}this.isShown=!1,setTimeout(s,this.transitionDuration)},markAsRead(){window.dispatchEvent(new CustomEvent("markedNotificationAsRead",{detail:{id:t.id}}))},markAsUnread(){window.dispatchEvent(new CustomEvent("markedNotificationAsUnread",{detail:{id:t.id}}))},destroy(){this.unsubscribeLivewireHook?.()}}))};var h=class{constructor(){return this.id(crypto.randomUUID?.()??"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+t/4).toString(16))),this}id(t){return this._id=t,this}title(t){return this._title=t,this}body(t){return this._body=t,this}actions(t){return this._actions=t,this}status(t){return this._status=t,this}color(t){return this._color=t,this}icon(t){return this._icon=t,this}iconColor(t){return this._iconColor=t,this}duration(t){return this._duration=t,this}seconds(t){return this.duration(t*1e3),this}persistent(){return this.duration("persistent"),this}danger(){return this.status("danger"),this}info(){return this.status("info"),this}success(){return this.status("success"),this}warning(){return this.status("warning"),this}view(t){return this._view=t,this}viewData(t){return this._viewData=t,this}toJSON(){return{id:this._id,title:this._title,body:this._body,actions:this._actions?.map(t=>t.toJSON()),status:this._status,color:this._color,icon:this._icon,iconColor:this._iconColor,duration:this._duration,view:this._view,viewData:this._viewData}}send(){return window.dispatchEvent(new CustomEvent("notificationSent",{detail:{notification:this.toJSON()}})),this}},a=class{constructor(t){return this.name(t),this}name(t){return this._name=t,this}color(t){return this._color=t,this}dispatch(t,i){return this.event(t),this.eventData(i),this}dispatchSelf(t,i){return this.dispatch(t,i),this._dispatchDirection="self",this}dispatchTo(t,i,s){return this.dispatch(i,s),this._dispatchDirection="to",this._dispatchToComponent=t,this}emit(t,i){return this.dispatch(t,i),this}emitSelf(t,i){return this.dispatchSelf(t,i),this}emitTo(t,i,s){return this.dispatchTo(t,i,s),this}dispatchDirection(t){return this._dispatchD