refactor: update modal event dispatching and CSS structure

This commit is contained in:
Majid Al Zariey
2025-08-18 16:13:55 +03:00
parent 6f7252ac49
commit 435f509ac7
4 changed files with 17 additions and 5 deletions
+1 -1
View File
@@ -1 +1 @@
(()=>{var n=({livewireId:i})=>({actionNestingIndex:null,init(){window.addEventListener("sync-action-modals",t=>{t.detail.id===i&&this.syncActionModals(t.detail.newActionNestingIndex)})},syncActionModals(t){if(this.actionNestingIndex===t){this.actionNestingIndex!==null&&this.$nextTick(()=>this.openModal());return}if(this.actionNestingIndex!==null&&this.closeModal(),this.actionNestingIndex=t,this.actionNestingIndex!==null){if(!this.$el.querySelector(`#${this.generateModalId(t)}`)){this.$nextTick(()=>this.openModal());return}this.openModal()}},generateModalId(t){return`fi-${i}-action-`+t},openModal(){let t=this.generateModalId(this.actionNestingIndex);this.$dispatch("open-modal",{id:t})},closeModal(){let t=this.generateModalId(this.actionNestingIndex);this.$dispatch("close-modal-quietly",{id:t})}});document.addEventListener("alpine:init",()=>{window.Alpine.data("filamentActionModals",n)});})();
(()=>{var n=({livewireId:e})=>({actionNestingIndex:null,init(){window.addEventListener("sync-action-modals",t=>{t.detail.id===e&&this.syncActionModals(t.detail.newActionNestingIndex)})},syncActionModals(t){if(this.actionNestingIndex===t){this.actionNestingIndex!==null&&this.$nextTick(()=>this.openModal());return}if(this.actionNestingIndex!==null&&this.closeModal(),this.actionNestingIndex=t,this.actionNestingIndex!==null){if(!this.$el.querySelector(`#${this.generateModalId(t)}`)){this.$nextTick(()=>this.openModal());return}this.openModal()}},generateModalId(t){return`fi-${e}-action-`+t},openModal(){let t=this.generateModalId(this.actionNestingIndex);document.dispatchEvent(new CustomEvent("open-modal",{bubbles:!0,composed:!0,detail:{id:t}}))},closeModal(){let t=this.generateModalId(this.actionNestingIndex);document.dispatchEvent(new CustomEvent("close-modal-quietly",{bubbles:!0,composed:!0,detail:{id:t}}))}});document.addEventListener("alpine:init",()=>{window.Alpine.data("filamentActionModals",n)});})();
@@ -52,12 +52,24 @@ export default ({ livewireId }) => ({
openModal() {
const id = this.generateModalId(this.actionNestingIndex)
this.$dispatch('open-modal', { id })
document.dispatchEvent(
new CustomEvent('open-modal', {
bubbles: true,
composed: true,
detail: { id },
}),
)
},
closeModal() {
const id = this.generateModalId(this.actionNestingIndex)
this.$dispatch('close-modal-quietly', { id })
document.dispatchEvent(
new CustomEvent('close-modal-quietly', {
bubbles: true,
composed: true,
detail: { id },
}),
)
},
})
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
.fi-modal {
&.fi-modal-slide-over,
&.fi-width-screen {
& .fi-modal-window {
> .fi-modal-window-ctn > .fi-modal-window {
@apply h-dvh;
}