From 9acddbda521c9026d1a7253c3da23a26eb5e2a8a Mon Sep 17 00:00:00 2001 From: Younes ENNAJI Date: Sun, 1 Mar 2026 21:11:13 +0000 Subject: [PATCH] docs: update CHANGELOG and Livewire docs with event system Add documentation for the event dispatching system: - Update CHANGELOG.md with unreleased features - Add Toastr events section (click, close, show, hidden) - Add Noty events section (click, close, show, hover) - Add Notyf events section (click, dismiss) - Add Theme events section (generic and theme-specific click) - Include code examples for Livewire event listeners --- CHANGELOG.md | 7 ++ docs/pages/livewire.html | 205 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 212 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 490d795b..77c172de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## [Unreleased](https://github.com/php-flasher/php-flasher/compare/v2.1.4...2.x) +* feature [Flasher] Add event dispatching system for all notification adapters and themes with Livewire integration: + - [Toastr] Dispatch events: `flasher:toastr:click`, `flasher:toastr:close`, `flasher:toastr:show`, `flasher:toastr:hidden` + - [Noty] Dispatch events: `flasher:noty:click`, `flasher:noty:close`, `flasher:noty:show`, `flasher:noty:hover` + - [Notyf] Dispatch events: `flasher:notyf:click`, `flasher:notyf:dismiss` + - [Themes] Dispatch events: `flasher:theme:click` (generic) and `flasher:theme:{name}:click` (specific) + - [Laravel] Add LivewireListener classes for all adapters and themes to enable Livewire event handling + ## [v2.1.3](https://github.com/php-flasher/php-flasher/compare/v2.1.2...v2.1.3) - 2025-01-25 * bug [#208](https://github.com/php-flasher/php-flasher/issues/208) [Flasher] Add GitHub workflow for automatic publishing of assets to NPM. See [PR #211](https://github.com/php-flasher/php-flasher/pull/211) by [ToshY](https://github.com/ToshY) diff --git a/docs/pages/livewire.html b/docs/pages/livewire.html index fabb938c..b543dc7d 100644 --- a/docs/pages/livewire.html +++ b/docs/pages/livewire.html @@ -444,6 +444,211 @@ class UserComponent extends Component +

Toastr Events

+

+ For Toastr notifications, you can listen to the following events: +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
EventDescription
toastr:clickFired when user clicks the notification
toastr:closeFired when notification is closed by user
toastr:showFired when notification is shown
toastr:hiddenFired when notification is hidden
+
+ + +
+
+
+
+
+
+
+
ToastrEventsComponent.php
+
+
+
<?php
+
+namespace App\Livewire;
+
+use Livewire\Attributes\On;
+use Livewire\Component;
+
+class ToastrEventsComponent extends Component
+{
+    #[On('toastr:click')]
+    public function onToastrClick(array $payload): void
+    {
+        // Handle notification click
+    }
+
+    #[On('toastr:close')]
+    public function onToastrClose(array $payload): void
+    {
+        // Handle notification close
+    }
+
+    #[On('toastr:show')]
+    public function onToastrShow(array $payload): void
+    {
+        // Handle notification shown
+    }
+
+    #[On('toastr:hidden')]
+    public function onToastrHidden(array $payload): void
+    {
+        // Handle notification hidden
+    }
+}
+
+
+ +

Noty Events

+

+ For Noty notifications, you can listen to the following events: +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
EventDescription
noty:clickFired when user clicks the notification
noty:closeFired when notification is closed
noty:showFired when notification is shown
noty:hoverFired when user hovers over the notification
+
+ +

Notyf Events

+

+ For Notyf notifications, you can listen to the following events: +

+ +
+ + + + + + + + + + + + + + + + + +
EventDescription
notyf:clickFired when user clicks the notification
notyf:dismissFired when notification is dismissed
+
+ +

Theme Events

+

+ For PHPFlasher built-in themes, you can listen to the following events. Two types of events are dispatched: + a generic event and a theme-specific event. +

+ +
+ + + + + + + + + + + + + + + + + +
EventDescription
theme:clickGeneric event fired when any theme notification is clicked
theme:{name}:clickSpecific event fired for a particular theme (e.g., theme:flasher:click)
+
+ + +
+
+
+
+
+
+
+
ThemeEventsComponent.php
+
+
+
<?php
+
+namespace App\Livewire;
+
+use Livewire\Attributes\On;
+use Livewire\Component;
+
+class ThemeEventsComponent extends Component
+{
+    // Listen to clicks on any theme notification
+    #[On('theme:click')]
+    public function onThemeClick(array $payload): void
+    {
+        // Handle notification click
+    }
+
+    // Listen to clicks on a specific theme (e.g., 'flasher')
+    #[On('theme:flasher:click')]
+    public function onFlasherThemeClick(array $payload): void
+    {
+        // Handle flasher theme notification click
+    }
+}
+
+
+

Event Payload

Each listener method accepts an array $payload parameter, which contains: