🆙 Add cms i using 🆙

This commit is contained in:
Remco
2025-11-25 22:42:56 +01:00
parent 94704e0925
commit d44196149e
35591 changed files with 3601123 additions and 0 deletions
@@ -0,0 +1,75 @@
export default ({ livewireId }) => ({
actionNestingIndex: null,
init() {
window.addEventListener('sync-action-modals', (event) => {
if (event.detail.id !== livewireId) {
return
}
this.syncActionModals(event.detail.newActionNestingIndex)
})
},
syncActionModals(newActionNestingIndex) {
if (this.actionNestingIndex === newActionNestingIndex) {
// https://github.com/filamentphp/filament/issues/16474
this.actionNestingIndex !== null &&
this.$nextTick(() => this.openModal())
return
}
if (this.actionNestingIndex !== null) {
this.closeModal()
}
this.actionNestingIndex = newActionNestingIndex
if (this.actionNestingIndex === null) {
return
}
if (
!this.$el.querySelector(
`#${this.generateModalId(newActionNestingIndex)}`,
)
) {
this.$nextTick(() => this.openModal())
return
}
this.openModal()
},
generateModalId(actionNestingIndex) {
// HTML IDs must start with a letter, so if the Livewire component ID starts
// with a number, we need to make sure it does not fail by prepending `fi-`.
return `fi-${livewireId}-action-` + actionNestingIndex
},
openModal() {
const id = this.generateModalId(this.actionNestingIndex)
document.dispatchEvent(
new CustomEvent('open-modal', {
bubbles: true,
composed: true,
detail: { id },
}),
)
},
closeModal() {
const id = this.generateModalId(this.actionNestingIndex)
document.dispatchEvent(
new CustomEvent('close-modal-quietly', {
bubbles: true,
composed: true,
detail: { id },
}),
)
},
})
@@ -0,0 +1,5 @@
import modals from './components/modals.js'
document.addEventListener('alpine:init', () => {
window.Alpine.data('filamentActionModals', modals)
})