mailwolt/resources/js/plugins/GlassToastra/livewire-adapter.js

13 lines
610 B
JavaScript

// resources/js/plugins/GlassToastra/livewire-adapter.js
import { showToast } from '../../ui/toast';
document.addEventListener('livewire:init', () => {
window.addEventListener('toast', (e) => showToast(e?.detail || {}));
window.addEventListener('toast.update', (e) => showToast(e?.detail || {})); // gleiche id => ersetzt Karte
window.addEventListener('toast.clear', (e) => window.toastraGlass?.clear(e?.detail?.position));
window.addEventListener('toast.reload', (e) => setTimeout(() => window.location.reload(), e.delay || 0));
});
// optional global
window.showToast = showToast;