Merge pull request #271 from php-flasher/dev

dev
This commit is contained in:
Younes ENNAJI
2025-03-23 13:35:11 +00:00
committed by GitHub
37 changed files with 349 additions and 171 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"dist/main.css": "/dist/main.28df35f9.css", "dist/main.css": "/dist/main.fdaa6615.css",
"dist/main.js": "/dist/main.3be5bc06.js", "dist/main.js": "/dist/main.70b93173.js",
"dist/455.3a7b4474.css": "/dist/455.3a7b4474.css", "dist/455.3a7b4474.css": "/dist/455.3a7b4474.css",
"dist/455.095e6545.js": "/dist/455.095e6545.js", "dist/455.095e6545.js": "/dist/455.095e6545.js",
"dist/411.29cd993e.css": "/dist/411.29cd993e.css", "dist/411.29cd993e.css": "/dist/411.29cd993e.css",
+12 -4
View File
@@ -49,6 +49,7 @@
Add elegant notifications to your Laravel or Symfony applications with just <span class="bg-indigo-50 text-indigo-700 px-2 py-1 rounded">one line of code</span>. Perfect for developers of all skill levels. Add elegant notifications to your Laravel or Symfony applications with just <span class="bg-indigo-50 text-indigo-700 px-2 py-1 rounded">one line of code</span>. Perfect for developers of all skill levels.
</p> </p>
<!--
<div class="flex flex-wrap gap-3 justify-center mb-8"> <div class="flex flex-wrap gap-3 justify-center mb-8">
<a href="#quick-start" class="px-5 py-3 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-lg transition-colors duration-200 shadow-md hover:shadow-lg flex items-center"> <a href="#quick-start" class="px-5 py-3 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-lg transition-colors duration-200 shadow-md hover:shadow-lg flex items-center">
<i class="fa-solid fa-rocket mr-2"></i> Get Started <i class="fa-solid fa-rocket mr-2"></i> Get Started
@@ -57,6 +58,7 @@
<i class="fa-brands fa-github mr-2"></i> View on GitHub <i class="fa-brands fa-github mr-2"></i> View on GitHub
</a> </a>
</div> </div>
-->
<div class="flex flex-wrap justify-center gap-3"> <div class="flex flex-wrap justify-center gap-3">
<a href="https://www.linkedin.com/in/younes--ennaji/" class="text-slate-500 hover:text-indigo-700 transition-colors duration-200"> <a href="https://www.linkedin.com/in/younes--ennaji/" class="text-slate-500 hover:text-indigo-700 transition-colors duration-200">
@@ -454,7 +456,7 @@
</div> </div>
<div class="text-center mt-10"> <div class="text-center mt-10">
<a href="/libraries/" class="inline-flex items-center px-6 py-3 bg-white border border-slate-200 hover:bg-slate-50 text-slate-700 rounded-lg font-medium transition-colors duration-200 shadow-sm"> <a href="/library/toastr/" class="inline-flex items-center px-6 py-3 bg-white border border-slate-200 hover:bg-slate-50 text-slate-700 rounded-lg font-medium transition-colors duration-200 shadow-sm">
<i class="fa-solid fa-th-large mr-2"></i> Compare all libraries <i class="fa-solid fa-th-large mr-2"></i> Compare all libraries
</a> </a>
</div> </div>
@@ -482,9 +484,9 @@
<div> <div>
<pre class="bg-slate-50 rounded-lg p-4 text-sm overflow-x-auto"><code class="language-php">namespace App\Http\Controllers; <pre class="bg-slate-50 rounded-lg p-4 text-sm overflow-x-auto"><code class="language-php">namespace App\Http\Controllers;
class ProfileController extends Controller class ProfileController
{ {
public function update(Request $request) public function update()
{ {
// Update user profile logic // Update user profile logic
@@ -494,6 +496,12 @@ class ProfileController extends Controller
// Or add a title // Or add a title
flash()->success('Your changes have been saved.', 'Profile Updated'); flash()->success('Your changes have been saved.', 'Profile Updated');
// Or add a title and options
flash()
->option('timeout', 5000)
->option('position', 'top-right')
->success('Changes saved with custom settings');
// Change notification options // Change notification options
flash()->options([ flash()->options([
'timeout' => 5000, 'timeout' => 5000,
@@ -657,7 +665,7 @@ document.getElementById('contact-form').addEventListener('submit', async functio
</a> </a>
<!-- Documentation --> <!-- Documentation -->
<a href="/docs/" class="group bg-white rounded-xl shadow-md hover:shadow-lg transition-all duration-300 border border-slate-100 p-8 flex flex-col items-center text-center transform hover:-translate-y-1"> <a href="/laravel" class="group bg-white rounded-xl shadow-md hover:shadow-lg transition-all duration-300 border border-slate-100 p-8 flex flex-col items-center text-center transform hover:-translate-y-1">
<div class="w-16 h-16 bg-amber-50 rounded-full flex items-center justify-center mb-5 group-hover:bg-amber-100 transition-colors"> <div class="w-16 h-16 bg-amber-50 rounded-full flex items-center justify-center mb-5 group-hover:bg-amber-100 transition-colors">
<i class="fa-solid fa-book-open text-amber-600 text-3xl"></i> <i class="fa-solid fa-book-open text-amber-600 text-3xl"></i>
</div> </div>
+5 -5
View File
@@ -340,21 +340,21 @@ class ContactForm extends Component
&lt;label for="name" class="block text-sm font-medium text-gray-700"&gt;Name&lt;/label&gt; &lt;label for="name" class="block text-sm font-medium text-gray-700"&gt;Name&lt;/label&gt;
&lt;input type="text" id="name" wire:model="name" &lt;input type="text" id="name" wire:model="name"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm"&gt; class="mt-1 block w-full rounded-md border-gray-300 shadow-sm"&gt;
@error('name') &lt;span class="text-red-500 text-xs"&gt;{{ $message }}&lt;/span&gt; @enderror @error('name') &lt;span class="text-red-500 text-xs"&gt;{% raw %}{{ $message }}{% endraw %}&lt;/span&gt; @enderror
&lt;/div&gt; &lt;/div&gt;
&lt;div&gt; &lt;div&gt;
&lt;label for="email" class="block text-sm font-medium text-gray-700"&gt;Email&lt;/label&gt; &lt;label for="email" class="block text-sm font-medium text-gray-700"&gt;Email&lt;/label&gt;
&lt;input type="email" id="email" wire:model="email" &lt;input type="email" id="email" wire:model="email"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm"&gt; class="mt-1 block w-full rounded-md border-gray-300 shadow-sm"&gt;
@error('email') &lt;span class="text-red-500 text-xs"&gt;{{ $message }}&lt;/span&gt; @enderror @error('email') &lt;span class="text-red-500 text-xs"&gt;{% raw %}{{ $message }}{% endraw %}&lt;/span&gt; @enderror
&lt;/div&gt; &lt;/div&gt;
&lt;div&gt; &lt;div&gt;
&lt;label for="message" class="block text-sm font-medium text-gray-700"&gt;Message&lt;/label&gt; &lt;label for="message" class="block text-sm font-medium text-gray-700"&gt;Message&lt;/label&gt;
&lt;textarea id="message" wire:model="message" rows="4" &lt;textarea id="message" wire:model="message" rows="4"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm"&gt;&lt;/textarea&gt; class="mt-1 block w-full rounded-md border-gray-300 shadow-sm"&gt;&lt;/textarea&gt;
@error('message') &lt;span class="text-red-500 text-xs"&gt;{{ $message }}&lt;/span&gt; @enderror @error('message') &lt;span class="text-red-500 text-xs"&gt;{% raw %}{{ $message }}{% endraw %}&lt;/span&gt; @enderror
&lt;/div&gt; &lt;/div&gt;
&lt;div&gt; &lt;div&gt;
@@ -684,7 +684,7 @@ class TasksComponent extends Component
<div class="text-white opacity-80 text-xs font-medium">nav-link.blade.php</div> <div class="text-white opacity-80 text-xs font-medium">nav-link.blade.php</div>
</div> </div>
<div> <div>
<pre class="bg-slate-50 rounded-lg p-4 text-sm overflow-x-auto"><code class="language-html">&lt;a href="{{ route('dashboard') }}" wire:navigate&gt;Dashboard&lt;/a&gt; <pre class="bg-slate-50 rounded-lg p-4 text-sm overflow-x-auto"><code class="language-html">&lt;a href="{% raw %}{{ route('dashboard') }}{% endraw %}" wire:navigate&gt;Dashboard&lt;/a&gt;
&lt;!-- In your component --&gt; &lt;!-- In your component --&gt;
&lt;script&gt; &lt;script&gt;
@@ -827,7 +827,7 @@ class PublishArticle extends Component
<pre class="bg-slate-50 rounded-lg p-3 text-xs overflow-x-auto"><code class="language-php">@if (session('status')) <pre class="bg-slate-50 rounded-lg p-3 text-xs overflow-x-auto"><code class="language-php">@if (session('status'))
&lt;script&gt; &lt;script&gt;
document.addEventListener('livewire:initialized', () => { document.addEventListener('livewire:initialized', () => {
flasher.success('{{ session('status') }}'); flasher.success('{% raw %}{{ session('status') }}{% endraw %}');
}); });
&lt;/script&gt; &lt;/script&gt;
@endif</code></pre> @endif</code></pre>
+2 -2
View File
@@ -2,10 +2,10 @@
"entrypoints": { "entrypoints": {
"main": { "main": {
"css": [ "css": [
"/dist/main.28df35f9.css" "/dist/main.fdaa6615.css"
], ],
"js": [ "js": [
"/dist/main.3be5bc06.js" "/dist/main.70b93173.js"
] ]
} }
} }
-1
View File
File diff suppressed because one or more lines are too long
-2
View File
File diff suppressed because one or more lines are too long
+2
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+21 -21
View File
@@ -16,10 +16,10 @@
"@flasher/flasher-toastr": "file:../src/Toastr/Prime/Resources", "@flasher/flasher-toastr": "file:../src/Toastr/Prime/Resources",
"@hotwired/stimulus": "^3.2.2", "@hotwired/stimulus": "^3.2.2",
"@symfony/stimulus-bridge": "^3.2.3", "@symfony/stimulus-bridge": "^3.2.3",
"@symfony/webpack-encore": "^5.0.1", "@symfony/webpack-encore": "^5.1.0",
"noty": "^3.2.0-beta-deprecated", "noty": "^3.2.0-beta-deprecated",
"notyf": "^3.10.0", "notyf": "^3.10.0",
"prismjs": "^1.29.0", "prismjs": "^1.30.0",
"sweetalert2": "^11.6.13", "sweetalert2": "^11.6.13",
"toastr": "^2.1.4" "toastr": "^2.1.4"
}, },
@@ -432,14 +432,14 @@
} }
}, },
"node_modules/@babel/helpers": { "node_modules/@babel/helpers": {
"version": "7.26.9", "version": "7.26.10",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.9.tgz", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.10.tgz",
"integrity": "sha512-Mz/4+y8udxBKdmzt/UjPACs4G3j5SshJJEFFKxlCGPydG4JAHXxjWjAwjd09tf6oINvl1VfMJo+nB7H2YKQ0dA==", "integrity": "sha512-UPYc3SauzZ3JGgj87GgZ89JVdC5dj0AoetR5Bw6wj4niittNyFh6+eOGonYvJ1ao6B8lEa3Q3klS7ADZ53bc5g==",
"license": "MIT", "license": "MIT",
"peer": true, "peer": true,
"dependencies": { "dependencies": {
"@babel/template": "^7.26.9", "@babel/template": "^7.26.9",
"@babel/types": "^7.26.9" "@babel/types": "^7.26.10"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
@@ -1544,9 +1544,9 @@
} }
}, },
"node_modules/@babel/runtime": { "node_modules/@babel/runtime": {
"version": "7.26.9", "version": "7.26.10",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.9.tgz", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.10.tgz",
"integrity": "sha512-aA63XwOkcl4xxQa3HjPMqOP6LiK0ZDv3mUPYEFXkpHbaFjtGggE1A61FjFzJnB+p7/oy2gA8E+rcBNl/zC1tMg==", "integrity": "sha512-2WJMeRQPHKSPemqk/awGrAiuFfzBmOIPXKizAsVhWH9YJqLZ0H+HS4c8loHGgW6utJ3E/ejXQUsiGaQy2NZ9Fw==",
"license": "MIT", "license": "MIT",
"peer": true, "peer": true,
"dependencies": { "dependencies": {
@@ -1591,9 +1591,9 @@
} }
}, },
"node_modules/@babel/types": { "node_modules/@babel/types": {
"version": "7.26.9", "version": "7.26.10",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.9.tgz", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.10.tgz",
"integrity": "sha512-Y3IR1cRnOxOCDvMmNiym7XpXQ93iGDDPHx+Zj+NM+rg0fBaShfQLkg+hKPaZCEvg5N/LeCo4+Rj/i3FuJsIQaw==", "integrity": "sha512-emqcG3vHrpxUKTrxcblR36dcrcoRDvKmnL/dCL6ZsHaShW80qxCAcNhzQZrpeM765VzEos+xOi4s+r4IXzTwdQ==",
"license": "MIT", "license": "MIT",
"peer": true, "peer": true,
"dependencies": { "dependencies": {
@@ -2661,9 +2661,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/axios": { "node_modules/axios": {
"version": "1.7.9", "version": "1.8.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.4.tgz",
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", "integrity": "sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -6327,9 +6327,9 @@
} }
}, },
"node_modules/prismjs": { "node_modules/prismjs": {
"version": "1.29.0", "version": "1.30.0",
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz", "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz",
"integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==", "integrity": "sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=6" "node": ">=6"
@@ -7119,9 +7119,9 @@
} }
}, },
"node_modules/sweetalert2": { "node_modules/sweetalert2": {
"version": "11.17.2", "version": "11.6.13",
"resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.17.2.tgz", "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.6.13.tgz",
"integrity": "sha512-HKxDr1IyV3Lxr3W6sb61qm/p2epFIEdr5EKwteRFHnIg6f8nHFl2kX++DBVz16Mac+fFiU3hMpjq1L6yE2Ge5w==", "integrity": "sha512-n5yVF0FNx1lm4XzpPyb1HIaiptzODfVyeCzmB809tpK+1bPdoKoevKOxYjrtId75DV7xuIp4r6cjn8xUAB8dPQ==",
"license": "MIT", "license": "MIT",
"funding": { "funding": {
"type": "individual", "type": "individual",
+2 -2
View File
@@ -20,10 +20,10 @@
"@flasher/flasher-toastr": "file:../src/Toastr/Prime/Resources", "@flasher/flasher-toastr": "file:../src/Toastr/Prime/Resources",
"@hotwired/stimulus": "^3.2.2", "@hotwired/stimulus": "^3.2.2",
"@symfony/stimulus-bridge": "^3.2.3", "@symfony/stimulus-bridge": "^3.2.3",
"@symfony/webpack-encore": "^5.0.1", "@symfony/webpack-encore": "^5.1.0",
"noty": "^3.2.0-beta-deprecated", "noty": "^3.2.0-beta-deprecated",
"notyf": "^3.10.0", "notyf": "^3.10.0",
"prismjs": "^1.29.0", "prismjs": "^1.30.0",
"sweetalert2": "^11.6.13", "sweetalert2": "^11.6.13",
"toastr": "^2.1.4" "toastr": "^2.1.4"
}, },
+4 -4
View File
@@ -26,7 +26,7 @@
"@rollup/plugin-strip": "^3.0.4", "@rollup/plugin-strip": "^3.0.4",
"@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.2", "@rollup/plugin-typescript": "^12.1.2",
"@types/node": "^22.13.10", "@types/node": "^22.13.11",
"@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0", "@typescript-eslint/parser": "^7.18.0",
"all-contributors-cli": "^6.26.1", "all-contributors-cli": "^6.26.1",
@@ -3859,9 +3859,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.13.10", "version": "22.13.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.10.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.11.tgz",
"integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==", "integrity": "sha512-iEUCUJoU0i3VnrCmgoWCXttklWcvoCIx4jzcP22fioIVSdTmjgoEvmAO/QPw6TcS9k5FrNgn4w7q5lGOd1CT5g==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
+1 -1
View File
@@ -54,7 +54,7 @@
"@rollup/plugin-strip": "^3.0.4", "@rollup/plugin-strip": "^3.0.4",
"@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.2", "@rollup/plugin-typescript": "^12.1.2",
"@types/node": "^22.13.10", "@types/node": "^22.13.11",
"@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0", "@typescript-eslint/parser": "^7.18.0",
"all-contributors-cli": "^6.26.1", "all-contributors-cli": "^6.26.1",
+22 -9
View File
@@ -39,17 +39,27 @@ class AbstractPlugin {
normalizedTitle = normalizedOptions.title; normalizedTitle = normalizedOptions.title;
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else { } else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
} else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -57,10 +67,13 @@ class AbstractPlugin {
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '' plugin: ''
+22 -9
View File
@@ -42,17 +42,27 @@
normalizedTitle = normalizedOptions.title; normalizedTitle = normalizedOptions.title;
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else { } else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
} else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -60,10 +70,13 @@
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '' plugin: ''
+1 -1
View File
@@ -1 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("noty")):"function"==typeof define&&define.amd?define(["@flasher/flasher","noty"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Noty=t(e.flasher,e.Noty)}(this,(function(e,t){"use strict";class s{success(e,t,s){this.flash("success",e,t,s)}error(e,t,s){this.flash("error",e,t,s)}info(e,t,s){this.flash("info",e,t,s)}warning(e,t,s){this.flash("warning",e,t,s)}flash(e,t,s,o){let i,n,r,a={};if("object"==typeof e?(a=Object.assign({},e),i=a.type,n=a.message,r=a.title,delete a.type,delete a.message,delete a.title):"object"==typeof t?(a=Object.assign({},t),i=e,n=a.message,r=a.title,delete a.message,delete a.title):"object"==typeof s?(a=Object.assign({},s),i=e,n=t,r=a.title,delete a.title):(i=e,n=t,r=s,a=o||{}),!i)throw new Error("Type is required for notifications");if(null==n)throw new Error("Message is required for notifications");const l={type:i,message:n,title:r||i,options:a,metadata:{plugin:""}};this.renderOptions(a),this.renderEnvelopes([l])}}const o=new class extends s{constructor(){super(...arguments),this.defaultOptions={timeout:1e4}}renderEnvelopes(e){(null==e?void 0:e.length)&&e.forEach((e=>{try{const s=Object.assign({text:e.message,type:e.type},this.defaultOptions);e.options&&Object.assign(s,e.options);const o=new t(s);o.show();const i=o.layoutDom;i&&"object"==typeof i.dataset&&(i.dataset.turboTemporary="")}catch(t){console.error("PHPFlasher Noty: Error rendering notification",t,e)}}))}renderOptions(e){e&&(Object.assign(this.defaultOptions,e),t.overrideDefaults(this.defaultOptions))}};return e.addPlugin("noty",o),o})); !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("noty")):"function"==typeof define&&define.amd?define(["@flasher/flasher","noty"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Noty=t(e.flasher,e.Noty)}(this,(function(e,t){"use strict";class s{success(e,t,s){this.flash("success",e,t,s)}error(e,t,s){this.flash("error",e,t,s)}info(e,t,s){this.flash("info",e,t,s)}warning(e,t,s){this.flash("warning",e,t,s)}flash(e,t,s,o){let i,n,r,l={};if("object"==typeof e?(l=Object.assign({},e),i=l.type,n=l.message,r=l.title,delete l.type,delete l.message,delete l.title):"object"==typeof t?(l=Object.assign({},t),i=e,n=l.message,r=l.title,delete l.message,delete l.title):(i=e,n=t,null==s?(r=void 0,l=o||{}):"string"==typeof s?(r=s,l=o||{}):"object"==typeof s&&(l=Object.assign({},s),"title"in l?(r=l.title,delete l.title):r=void 0,o&&"object"==typeof o&&(l=Object.assign(Object.assign({},l),o)))),!i)throw new Error("Type is required for notifications");if(null==n)throw new Error("Message is required for notifications");null==r&&(r=i.charAt(0).toUpperCase()+i.slice(1));const a={type:i,message:n,title:r,options:l,metadata:{plugin:""}};this.renderOptions(l),this.renderEnvelopes([a])}}const o=new class extends s{constructor(){super(...arguments),this.defaultOptions={timeout:1e4}}renderEnvelopes(e){(null==e?void 0:e.length)&&e.forEach((e=>{try{const s=Object.assign({text:e.message,type:e.type},this.defaultOptions);e.options&&Object.assign(s,e.options);const o=new t(s);o.show();const i=o.layoutDom;i&&"object"==typeof i.dataset&&(i.dataset.turboTemporary="")}catch(t){console.error("PHPFlasher Noty: Error rendering notification",t,e)}}))}renderOptions(e){e&&(Object.assign(this.defaultOptions,e),t.overrideDefaults(this.defaultOptions))}};return e.addPlugin("noty",o),o}));
+1 -1
View File
@@ -1 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("noty")):"function"==typeof define&&define.amd?define(["@flasher/flasher","noty"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Noty=t(e.flasher,e.Noty)}(this,(function(e,t){"use strict";class s{success(e,t,s){this.flash("success",e,t,s)}error(e,t,s){this.flash("error",e,t,s)}info(e,t,s){this.flash("info",e,t,s)}warning(e,t,s){this.flash("warning",e,t,s)}flash(e,t,s,o){let i,n,r,a={};if("object"==typeof e?(a=Object.assign({},e),i=a.type,n=a.message,r=a.title,delete a.type,delete a.message,delete a.title):"object"==typeof t?(a=Object.assign({},t),i=e,n=a.message,r=a.title,delete a.message,delete a.title):"object"==typeof s?(a=Object.assign({},s),i=e,n=t,r=a.title,delete a.title):(i=e,n=t,r=s,a=o||{}),!i)throw new Error("Type is required for notifications");if(null==n)throw new Error("Message is required for notifications");const l={type:i,message:n,title:r||i,options:a,metadata:{plugin:""}};this.renderOptions(a),this.renderEnvelopes([l])}}const o=new class extends s{constructor(){super(...arguments),this.defaultOptions={timeout:1e4}}renderEnvelopes(e){(null==e?void 0:e.length)&&e.forEach((e=>{try{const s=Object.assign({text:e.message,type:e.type},this.defaultOptions);e.options&&Object.assign(s,e.options);const o=new t(s);o.show();const i=o.layoutDom;i&&"object"==typeof i.dataset&&(i.dataset.turboTemporary="")}catch(t){console.error("PHPFlasher Noty: Error rendering notification",t,e)}}))}renderOptions(e){e&&(Object.assign(this.defaultOptions,e),t.overrideDefaults(this.defaultOptions))}};return e.addPlugin("noty",o),o})); !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("noty")):"function"==typeof define&&define.amd?define(["@flasher/flasher","noty"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Noty=t(e.flasher,e.Noty)}(this,(function(e,t){"use strict";class s{success(e,t,s){this.flash("success",e,t,s)}error(e,t,s){this.flash("error",e,t,s)}info(e,t,s){this.flash("info",e,t,s)}warning(e,t,s){this.flash("warning",e,t,s)}flash(e,t,s,o){let i,n,r,l={};if("object"==typeof e?(l=Object.assign({},e),i=l.type,n=l.message,r=l.title,delete l.type,delete l.message,delete l.title):"object"==typeof t?(l=Object.assign({},t),i=e,n=l.message,r=l.title,delete l.message,delete l.title):(i=e,n=t,null==s?(r=void 0,l=o||{}):"string"==typeof s?(r=s,l=o||{}):"object"==typeof s&&(l=Object.assign({},s),"title"in l?(r=l.title,delete l.title):r=void 0,o&&"object"==typeof o&&(l=Object.assign(Object.assign({},l),o)))),!i)throw new Error("Type is required for notifications");if(null==n)throw new Error("Message is required for notifications");null==r&&(r=i.charAt(0).toUpperCase()+i.slice(1));const a={type:i,message:n,title:r,options:l,metadata:{plugin:""}};this.renderOptions(l),this.renderEnvelopes([a])}}const o=new class extends s{constructor(){super(...arguments),this.defaultOptions={timeout:1e4}}renderEnvelopes(e){(null==e?void 0:e.length)&&e.forEach((e=>{try{const s=Object.assign({text:e.message,type:e.type},this.defaultOptions);e.options&&Object.assign(s,e.options);const o=new t(s);o.show();const i=o.layoutDom;i&&"object"==typeof i.dataset&&(i.dataset.turboTemporary="")}catch(t){console.error("PHPFlasher Noty: Error rendering notification",t,e)}}))}renderOptions(e){e&&(Object.assign(this.defaultOptions,e),t.overrideDefaults(this.defaultOptions))}};return e.addPlugin("noty",o),o}));
+22 -9
View File
@@ -38,17 +38,27 @@ class AbstractPlugin {
normalizedTitle = normalizedOptions.title; normalizedTitle = normalizedOptions.title;
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else { } else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
} else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -56,10 +66,13 @@ class AbstractPlugin {
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '' plugin: ''
+22 -9
View File
@@ -42,17 +42,27 @@
normalizedTitle = normalizedOptions.title; normalizedTitle = normalizedOptions.title;
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else { } else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
} else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -60,10 +70,13 @@
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '' plugin: ''
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+36 -15
View File
@@ -101,7 +101,7 @@ export abstract class AbstractPlugin implements PluginInterface {
* *
* This method handles different parameter formats to provide a flexible API: * This method handles different parameter formats to provide a flexible API:
* - flash(type, message, title, options) * - flash(type, message, title, options)
* - flash(type, message, options) - title in options * - flash(type, message, options) - title in options or just options
* - flash(type, options) - message and title in options * - flash(type, options) - message and title in options
* - flash(options) - type, message, and title in options * - flash(options) - type, message, and title in options
* *
@@ -141,21 +141,37 @@ export abstract class AbstractPlugin implements PluginInterface {
delete normalizedOptions.message delete normalizedOptions.message
delete normalizedOptions.title delete normalizedOptions.title
} }
// Case: flash(type, message, {title, ...options}) // Case: flash(type, message, title|options, options?)
else if (typeof title === 'object') {
normalizedOptions = { ...title }
normalizedType = type
normalizedMessage = message
normalizedTitle = normalizedOptions.title as string
delete normalizedOptions.title
}
// Case: flash(type, message, title, options)
else { else {
normalizedType = type normalizedType = type
normalizedMessage = message normalizedMessage = message as string
normalizedTitle = title
normalizedOptions = options || {} // Determine if the third parameter is a title string or options object
if (title === undefined || title === null) {
// No third parameter
normalizedTitle = undefined
normalizedOptions = options || {}
} else if (typeof title === 'string') {
// Third parameter is a title string
normalizedTitle = title
normalizedOptions = options || {}
} else if (typeof title === 'object') {
// Third parameter is an options object
normalizedOptions = { ...title }
// If options has a title property, use it and remove from options
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title as string
delete normalizedOptions.title
} else {
normalizedTitle = undefined
}
// Merge with any options provided in the fourth parameter
if (options && typeof options === 'object') {
normalizedOptions = { ...normalizedOptions, ...options }
}
}
} }
// Validate required parameters // Validate required parameters
@@ -167,11 +183,16 @@ export abstract class AbstractPlugin implements PluginInterface {
throw new Error('Message is required for notifications') throw new Error('Message is required for notifications')
} }
// Set title to type if not provided
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1)
}
// Create standardized envelope // Create standardized envelope
const envelope: Envelope = { const envelope: Envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '', plugin: '',
+25 -10
View File
@@ -70,18 +70,30 @@ class AbstractPlugin {
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} }
else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
}
else { else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
}
else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
}
else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
}
else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -89,10 +101,13 @@ class AbstractPlugin {
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '', plugin: '',
+25 -10
View File
@@ -76,18 +76,30 @@
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} }
else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
}
else { else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
}
else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
}
else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
}
else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -95,10 +107,13 @@
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '', plugin: '',
File diff suppressed because one or more lines are too long
+25 -10
View File
@@ -38,18 +38,30 @@ class AbstractPlugin {
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} }
else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
}
else { else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
}
else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
}
else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
}
else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -57,10 +69,13 @@ class AbstractPlugin {
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '', plugin: '',
File diff suppressed because one or more lines are too long
@@ -71,17 +71,27 @@ class AbstractPlugin {
normalizedTitle = normalizedOptions.title; normalizedTitle = normalizedOptions.title;
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else { } else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
} else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -89,10 +99,13 @@ class AbstractPlugin {
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '' plugin: ''
+22 -9
View File
@@ -74,17 +74,27 @@
normalizedTitle = normalizedOptions.title; normalizedTitle = normalizedOptions.title;
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else { } else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
} else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -92,10 +102,13 @@
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '' plugin: ''
@@ -1 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("sweetalert2")):"function"==typeof define&&define.amd?define(["@flasher/flasher","sweetalert2"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).sweetalert=t(e.flasher,e.Swal)}(this,(function(e,t){"use strict";function r(e,t,r,s){return new(r||(r=Promise))((function(i,n){function o(e){try{a(s.next(e))}catch(e){n(e)}}function l(e){try{a(s.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,l)}a((s=s.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s{success(e,t,r){this.flash("success",e,t,r)}error(e,t,r){this.flash("error",e,t,r)}info(e,t,r){this.flash("info",e,t,r)}warning(e,t,r){this.flash("warning",e,t,r)}flash(e,t,r,s){let i,n,o,l={};if("object"==typeof e?(l=Object.assign({},e),i=l.type,n=l.message,o=l.title,delete l.type,delete l.message,delete l.title):"object"==typeof t?(l=Object.assign({},t),i=e,n=l.message,o=l.title,delete l.message,delete l.title):"object"==typeof r?(l=Object.assign({},r),i=e,n=t,o=l.title,delete l.title):(i=e,n=t,o=r,l=s||{}),!i)throw new Error("Type is required for notifications");if(null==n)throw new Error("Message is required for notifications");const a={type:i,message:n,title:o||i,options:l,metadata:{plugin:""}};this.renderOptions(l),this.renderEnvelopes([a])}}const i=new class extends s{renderEnvelopes(e){return r(this,void 0,void 0,(function*(){this.sweetalert||this.initializeSweetAlert();try{for(const t of e)yield this.renderEnvelope(t)}catch(e){console.error("PHPFlasher SweetAlert: Error rendering envelopes",e)}}))}renderOptions(e){try{this.sweetalert=this.sweetalert||t.mixin(Object.assign({timer:e.timer||1e4,timerProgressBar:e.timerProgressBar||!0},e)),this.setupTurboCompatibility()}catch(e){console.error("PHPFlasher SweetAlert: Error applying options",e)}}renderEnvelope(e){return r(this,void 0,void 0,(function*(){var t;try{let{options:r}=e;r=Object.assign(Object.assign({},r),{icon:(null==r?void 0:r.icon)||e.type,text:(null==r?void 0:r.text)||e.message});const s=yield null===(t=this.sweetalert)||void 0===t?void 0:t.fire(r);this.dispatchResultEvent(s,e)}catch(t){console.error("PHPFlasher SweetAlert: Error rendering envelope",t,e)}}))}initializeSweetAlert(){this.sweetalert||this.renderOptions({timer:1e4,timerProgressBar:!0})}setupTurboCompatibility(){document.addEventListener("turbo:before-cache",(()=>{if(t.isVisible()){const e=t.getPopup();e&&e.style.setProperty("animation-duration","0ms"),t.close()}}))}dispatchResultEvent(e,t){e&&window.dispatchEvent(new CustomEvent("flasher:sweetalert:promise",{detail:{promise:e,envelope:t}}))}};return e.addPlugin("sweetalert",i),i})); !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("sweetalert2")):"function"==typeof define&&define.amd?define(["@flasher/flasher","sweetalert2"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).sweetalert=t(e.flasher,e.Swal)}(this,(function(e,t){"use strict";function r(e,t,r,s){return new(r||(r=Promise))((function(i,n){function o(e){try{a(s.next(e))}catch(e){n(e)}}function l(e){try{a(s.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,l)}a((s=s.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s{success(e,t,r){this.flash("success",e,t,r)}error(e,t,r){this.flash("error",e,t,r)}info(e,t,r){this.flash("info",e,t,r)}warning(e,t,r){this.flash("warning",e,t,r)}flash(e,t,r,s){let i,n,o,l={};if("object"==typeof e?(l=Object.assign({},e),i=l.type,n=l.message,o=l.title,delete l.type,delete l.message,delete l.title):"object"==typeof t?(l=Object.assign({},t),i=e,n=l.message,o=l.title,delete l.message,delete l.title):(i=e,n=t,null==r?(o=void 0,l=s||{}):"string"==typeof r?(o=r,l=s||{}):"object"==typeof r&&(l=Object.assign({},r),"title"in l?(o=l.title,delete l.title):o=void 0,s&&"object"==typeof s&&(l=Object.assign(Object.assign({},l),s)))),!i)throw new Error("Type is required for notifications");if(null==n)throw new Error("Message is required for notifications");null==o&&(o=i.charAt(0).toUpperCase()+i.slice(1));const a={type:i,message:n,title:o,options:l,metadata:{plugin:""}};this.renderOptions(l),this.renderEnvelopes([a])}}const i=new class extends s{renderEnvelopes(e){return r(this,void 0,void 0,(function*(){this.sweetalert||this.initializeSweetAlert();try{for(const t of e)yield this.renderEnvelope(t)}catch(e){console.error("PHPFlasher SweetAlert: Error rendering envelopes",e)}}))}renderOptions(e){try{this.sweetalert=this.sweetalert||t.mixin(Object.assign({timer:e.timer||1e4,timerProgressBar:e.timerProgressBar||!0},e)),this.setupTurboCompatibility()}catch(e){console.error("PHPFlasher SweetAlert: Error applying options",e)}}renderEnvelope(e){return r(this,void 0,void 0,(function*(){var t;try{let{options:r}=e;r=Object.assign(Object.assign({},r),{icon:(null==r?void 0:r.icon)||e.type,text:(null==r?void 0:r.text)||e.message});const s=yield null===(t=this.sweetalert)||void 0===t?void 0:t.fire(r);this.dispatchResultEvent(s,e)}catch(t){console.error("PHPFlasher SweetAlert: Error rendering envelope",t,e)}}))}initializeSweetAlert(){this.sweetalert||this.renderOptions({timer:1e4,timerProgressBar:!0})}setupTurboCompatibility(){document.addEventListener("turbo:before-cache",(()=>{if(t.isVisible()){const e=t.getPopup();e&&e.style.setProperty("animation-duration","0ms"),t.close()}}))}dispatchResultEvent(e,t){e&&window.dispatchEvent(new CustomEvent("flasher:sweetalert:promise",{detail:{promise:e,envelope:t}}))}};return e.addPlugin("sweetalert",i),i}));
@@ -1 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("sweetalert2")):"function"==typeof define&&define.amd?define(["@flasher/flasher","sweetalert2"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).sweetalert=t(e.flasher,e.Swal)}(this,(function(e,t){"use strict";function r(e,t,r,s){return new(r||(r=Promise))((function(i,n){function o(e){try{a(s.next(e))}catch(e){n(e)}}function l(e){try{a(s.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,l)}a((s=s.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s{success(e,t,r){this.flash("success",e,t,r)}error(e,t,r){this.flash("error",e,t,r)}info(e,t,r){this.flash("info",e,t,r)}warning(e,t,r){this.flash("warning",e,t,r)}flash(e,t,r,s){let i,n,o,l={};if("object"==typeof e?(l=Object.assign({},e),i=l.type,n=l.message,o=l.title,delete l.type,delete l.message,delete l.title):"object"==typeof t?(l=Object.assign({},t),i=e,n=l.message,o=l.title,delete l.message,delete l.title):"object"==typeof r?(l=Object.assign({},r),i=e,n=t,o=l.title,delete l.title):(i=e,n=t,o=r,l=s||{}),!i)throw new Error("Type is required for notifications");if(null==n)throw new Error("Message is required for notifications");const a={type:i,message:n,title:o||i,options:l,metadata:{plugin:""}};this.renderOptions(l),this.renderEnvelopes([a])}}const i=new class extends s{renderEnvelopes(e){return r(this,void 0,void 0,(function*(){this.sweetalert||this.initializeSweetAlert();try{for(const t of e)yield this.renderEnvelope(t)}catch(e){console.error("PHPFlasher SweetAlert: Error rendering envelopes",e)}}))}renderOptions(e){try{this.sweetalert=this.sweetalert||t.mixin(Object.assign({timer:e.timer||1e4,timerProgressBar:e.timerProgressBar||!0},e)),this.setupTurboCompatibility()}catch(e){console.error("PHPFlasher SweetAlert: Error applying options",e)}}renderEnvelope(e){return r(this,void 0,void 0,(function*(){var t;try{let{options:r}=e;r=Object.assign(Object.assign({},r),{icon:(null==r?void 0:r.icon)||e.type,text:(null==r?void 0:r.text)||e.message});const s=yield null===(t=this.sweetalert)||void 0===t?void 0:t.fire(r);this.dispatchResultEvent(s,e)}catch(t){console.error("PHPFlasher SweetAlert: Error rendering envelope",t,e)}}))}initializeSweetAlert(){this.sweetalert||this.renderOptions({timer:1e4,timerProgressBar:!0})}setupTurboCompatibility(){document.addEventListener("turbo:before-cache",(()=>{if(t.isVisible()){const e=t.getPopup();e&&e.style.setProperty("animation-duration","0ms"),t.close()}}))}dispatchResultEvent(e,t){e&&window.dispatchEvent(new CustomEvent("flasher:sweetalert:promise",{detail:{promise:e,envelope:t}}))}};return e.addPlugin("sweetalert",i),i})); !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("sweetalert2")):"function"==typeof define&&define.amd?define(["@flasher/flasher","sweetalert2"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).sweetalert=t(e.flasher,e.Swal)}(this,(function(e,t){"use strict";function r(e,t,r,s){return new(r||(r=Promise))((function(i,n){function o(e){try{a(s.next(e))}catch(e){n(e)}}function l(e){try{a(s.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,l)}a((s=s.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s{success(e,t,r){this.flash("success",e,t,r)}error(e,t,r){this.flash("error",e,t,r)}info(e,t,r){this.flash("info",e,t,r)}warning(e,t,r){this.flash("warning",e,t,r)}flash(e,t,r,s){let i,n,o,l={};if("object"==typeof e?(l=Object.assign({},e),i=l.type,n=l.message,o=l.title,delete l.type,delete l.message,delete l.title):"object"==typeof t?(l=Object.assign({},t),i=e,n=l.message,o=l.title,delete l.message,delete l.title):(i=e,n=t,null==r?(o=void 0,l=s||{}):"string"==typeof r?(o=r,l=s||{}):"object"==typeof r&&(l=Object.assign({},r),"title"in l?(o=l.title,delete l.title):o=void 0,s&&"object"==typeof s&&(l=Object.assign(Object.assign({},l),s)))),!i)throw new Error("Type is required for notifications");if(null==n)throw new Error("Message is required for notifications");null==o&&(o=i.charAt(0).toUpperCase()+i.slice(1));const a={type:i,message:n,title:o,options:l,metadata:{plugin:""}};this.renderOptions(l),this.renderEnvelopes([a])}}const i=new class extends s{renderEnvelopes(e){return r(this,void 0,void 0,(function*(){this.sweetalert||this.initializeSweetAlert();try{for(const t of e)yield this.renderEnvelope(t)}catch(e){console.error("PHPFlasher SweetAlert: Error rendering envelopes",e)}}))}renderOptions(e){try{this.sweetalert=this.sweetalert||t.mixin(Object.assign({timer:e.timer||1e4,timerProgressBar:e.timerProgressBar||!0},e)),this.setupTurboCompatibility()}catch(e){console.error("PHPFlasher SweetAlert: Error applying options",e)}}renderEnvelope(e){return r(this,void 0,void 0,(function*(){var t;try{let{options:r}=e;r=Object.assign(Object.assign({},r),{icon:(null==r?void 0:r.icon)||e.type,text:(null==r?void 0:r.text)||e.message});const s=yield null===(t=this.sweetalert)||void 0===t?void 0:t.fire(r);this.dispatchResultEvent(s,e)}catch(t){console.error("PHPFlasher SweetAlert: Error rendering envelope",t,e)}}))}initializeSweetAlert(){this.sweetalert||this.renderOptions({timer:1e4,timerProgressBar:!0})}setupTurboCompatibility(){document.addEventListener("turbo:before-cache",(()=>{if(t.isVisible()){const e=t.getPopup();e&&e.style.setProperty("animation-duration","0ms"),t.close()}}))}dispatchResultEvent(e,t){e&&window.dispatchEvent(new CustomEvent("flasher:sweetalert:promise",{detail:{promise:e,envelope:t}}))}};return e.addPlugin("sweetalert",i),i}));
+22 -9
View File
@@ -39,17 +39,27 @@ class AbstractPlugin {
normalizedTitle = normalizedOptions.title; normalizedTitle = normalizedOptions.title;
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else { } else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
} else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -57,10 +67,13 @@ class AbstractPlugin {
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '' plugin: ''
+22 -9
View File
@@ -42,17 +42,27 @@
normalizedTitle = normalizedOptions.title; normalizedTitle = normalizedOptions.title;
delete normalizedOptions.message; delete normalizedOptions.message;
delete normalizedOptions.title; delete normalizedOptions.title;
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
normalizedType = type;
normalizedMessage = message;
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else { } else {
normalizedType = type; normalizedType = type;
normalizedMessage = message; normalizedMessage = message;
normalizedTitle = title; if (title === undefined || title === null) {
normalizedOptions = options || {}; normalizedTitle = undefined;
normalizedOptions = options || {};
} else if (typeof title === 'string') {
normalizedTitle = title;
normalizedOptions = options || {};
} else if (typeof title === 'object') {
normalizedOptions = Object.assign({}, title);
if ('title' in normalizedOptions) {
normalizedTitle = normalizedOptions.title;
delete normalizedOptions.title;
} else {
normalizedTitle = undefined;
}
if (options && typeof options === 'object') {
normalizedOptions = Object.assign(Object.assign({}, normalizedOptions), options);
}
}
} }
if (!normalizedType) { if (!normalizedType) {
throw new Error('Type is required for notifications'); throw new Error('Type is required for notifications');
@@ -60,10 +70,13 @@
if (normalizedMessage === undefined || normalizedMessage === null) { if (normalizedMessage === undefined || normalizedMessage === null) {
throw new Error('Message is required for notifications'); throw new Error('Message is required for notifications');
} }
if (normalizedTitle === undefined || normalizedTitle === null) {
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
}
const envelope = { const envelope = {
type: normalizedType, type: normalizedType,
message: normalizedMessage, message: normalizedMessage,
title: normalizedTitle || normalizedType, title: normalizedTitle,
options: normalizedOptions, options: normalizedOptions,
metadata: { metadata: {
plugin: '' plugin: ''
+1 -1
View File
@@ -1 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("toastr")):"function"==typeof define&&define.amd?define(["@flasher/flasher","toastr"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).toastr=t(e.flasher,e.toastr)}(this,(function(e,t){"use strict";class r{success(e,t,r){this.flash("success",e,t,r)}error(e,t,r){this.flash("error",e,t,r)}info(e,t,r){this.flash("info",e,t,r)}warning(e,t,r){this.flash("warning",e,t,r)}flash(e,t,r,s){let o,i,n,a={};if("object"==typeof e?(a=Object.assign({},e),o=a.type,i=a.message,n=a.title,delete a.type,delete a.message,delete a.title):"object"==typeof t?(a=Object.assign({},t),o=e,i=a.message,n=a.title,delete a.message,delete a.title):"object"==typeof r?(a=Object.assign({},r),o=e,i=t,n=a.title,delete a.title):(o=e,i=t,n=r,a=s||{}),!o)throw new Error("Type is required for notifications");if(null==i)throw new Error("Message is required for notifications");const l={type:o,message:i,title:n||o,options:a,metadata:{plugin:""}};this.renderOptions(a),this.renderEnvelopes([l])}}const s=new class extends r{renderEnvelopes(e){(null==e?void 0:e.length)&&this.isDependencyAvailable()&&e.forEach((e=>{try{const{message:r,title:s,type:o,options:i}=e,n=t[o](r,s,i);if(n&&n.parent)try{const e=n.parent();e&&"function"==typeof e.attr&&e.attr("data-turbo-temporary","")}catch(e){console.error("PHPFlasher Toastr: Error setting Turbo compatibility",e)}}catch(t){console.error("PHPFlasher Toastr: Error rendering notification",t,e)}}))}renderOptions(e){if(this.isDependencyAvailable())try{t.options=Object.assign({timeOut:e.timeOut||1e4,progressBar:e.progressBar||!0},e)}catch(e){console.error("PHPFlasher Toastr: Error applying options",e)}}isDependencyAvailable(){return!(!window.jQuery&&!window.$)||(console.error("PHPFlasher Toastr: jQuery is required but not loaded. Make sure jQuery is loaded before using Toastr."),!1)}};return e.addPlugin("toastr",s),s})); !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("toastr")):"function"==typeof define&&define.amd?define(["@flasher/flasher","toastr"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).toastr=t(e.flasher,e.toastr)}(this,(function(e,t){"use strict";class s{success(e,t,s){this.flash("success",e,t,s)}error(e,t,s){this.flash("error",e,t,s)}info(e,t,s){this.flash("info",e,t,s)}warning(e,t,s){this.flash("warning",e,t,s)}flash(e,t,s,r){let o,i,n,a={};if("object"==typeof e?(a=Object.assign({},e),o=a.type,i=a.message,n=a.title,delete a.type,delete a.message,delete a.title):"object"==typeof t?(a=Object.assign({},t),o=e,i=a.message,n=a.title,delete a.message,delete a.title):(o=e,i=t,null==s?(n=void 0,a=r||{}):"string"==typeof s?(n=s,a=r||{}):"object"==typeof s&&(a=Object.assign({},s),"title"in a?(n=a.title,delete a.title):n=void 0,r&&"object"==typeof r&&(a=Object.assign(Object.assign({},a),r)))),!o)throw new Error("Type is required for notifications");if(null==i)throw new Error("Message is required for notifications");null==n&&(n=o.charAt(0).toUpperCase()+o.slice(1));const l={type:o,message:i,title:n,options:a,metadata:{plugin:""}};this.renderOptions(a),this.renderEnvelopes([l])}}const r=new class extends s{renderEnvelopes(e){(null==e?void 0:e.length)&&this.isDependencyAvailable()&&e.forEach((e=>{try{const{message:s,title:r,type:o,options:i}=e,n=t[o](s,r,i);if(n&&n.parent)try{const e=n.parent();e&&"function"==typeof e.attr&&e.attr("data-turbo-temporary","")}catch(e){console.error("PHPFlasher Toastr: Error setting Turbo compatibility",e)}}catch(t){console.error("PHPFlasher Toastr: Error rendering notification",t,e)}}))}renderOptions(e){if(this.isDependencyAvailable())try{t.options=Object.assign({timeOut:e.timeOut||1e4,progressBar:e.progressBar||!0},e)}catch(e){console.error("PHPFlasher Toastr: Error applying options",e)}}isDependencyAvailable(){return!(!window.jQuery&&!window.$)||(console.error("PHPFlasher Toastr: jQuery is required but not loaded. Make sure jQuery is loaded before using Toastr."),!1)}};return e.addPlugin("toastr",r),r}));
+1 -1
View File
@@ -1 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("toastr")):"function"==typeof define&&define.amd?define(["@flasher/flasher","toastr"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).toastr=t(e.flasher,e.toastr)}(this,(function(e,t){"use strict";class r{success(e,t,r){this.flash("success",e,t,r)}error(e,t,r){this.flash("error",e,t,r)}info(e,t,r){this.flash("info",e,t,r)}warning(e,t,r){this.flash("warning",e,t,r)}flash(e,t,r,s){let o,i,n,a={};if("object"==typeof e?(a=Object.assign({},e),o=a.type,i=a.message,n=a.title,delete a.type,delete a.message,delete a.title):"object"==typeof t?(a=Object.assign({},t),o=e,i=a.message,n=a.title,delete a.message,delete a.title):"object"==typeof r?(a=Object.assign({},r),o=e,i=t,n=a.title,delete a.title):(o=e,i=t,n=r,a=s||{}),!o)throw new Error("Type is required for notifications");if(null==i)throw new Error("Message is required for notifications");const l={type:o,message:i,title:n||o,options:a,metadata:{plugin:""}};this.renderOptions(a),this.renderEnvelopes([l])}}const s=new class extends r{renderEnvelopes(e){(null==e?void 0:e.length)&&this.isDependencyAvailable()&&e.forEach((e=>{try{const{message:r,title:s,type:o,options:i}=e,n=t[o](r,s,i);if(n&&n.parent)try{const e=n.parent();e&&"function"==typeof e.attr&&e.attr("data-turbo-temporary","")}catch(e){console.error("PHPFlasher Toastr: Error setting Turbo compatibility",e)}}catch(t){console.error("PHPFlasher Toastr: Error rendering notification",t,e)}}))}renderOptions(e){if(this.isDependencyAvailable())try{t.options=Object.assign({timeOut:e.timeOut||1e4,progressBar:e.progressBar||!0},e)}catch(e){console.error("PHPFlasher Toastr: Error applying options",e)}}isDependencyAvailable(){return!(!window.jQuery&&!window.$)||(console.error("PHPFlasher Toastr: jQuery is required but not loaded. Make sure jQuery is loaded before using Toastr."),!1)}};return e.addPlugin("toastr",s),s})); !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("toastr")):"function"==typeof define&&define.amd?define(["@flasher/flasher","toastr"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).toastr=t(e.flasher,e.toastr)}(this,(function(e,t){"use strict";class s{success(e,t,s){this.flash("success",e,t,s)}error(e,t,s){this.flash("error",e,t,s)}info(e,t,s){this.flash("info",e,t,s)}warning(e,t,s){this.flash("warning",e,t,s)}flash(e,t,s,r){let o,i,n,a={};if("object"==typeof e?(a=Object.assign({},e),o=a.type,i=a.message,n=a.title,delete a.type,delete a.message,delete a.title):"object"==typeof t?(a=Object.assign({},t),o=e,i=a.message,n=a.title,delete a.message,delete a.title):(o=e,i=t,null==s?(n=void 0,a=r||{}):"string"==typeof s?(n=s,a=r||{}):"object"==typeof s&&(a=Object.assign({},s),"title"in a?(n=a.title,delete a.title):n=void 0,r&&"object"==typeof r&&(a=Object.assign(Object.assign({},a),r)))),!o)throw new Error("Type is required for notifications");if(null==i)throw new Error("Message is required for notifications");null==n&&(n=o.charAt(0).toUpperCase()+o.slice(1));const l={type:o,message:i,title:n,options:a,metadata:{plugin:""}};this.renderOptions(a),this.renderEnvelopes([l])}}const r=new class extends s{renderEnvelopes(e){(null==e?void 0:e.length)&&this.isDependencyAvailable()&&e.forEach((e=>{try{const{message:s,title:r,type:o,options:i}=e,n=t[o](s,r,i);if(n&&n.parent)try{const e=n.parent();e&&"function"==typeof e.attr&&e.attr("data-turbo-temporary","")}catch(e){console.error("PHPFlasher Toastr: Error setting Turbo compatibility",e)}}catch(t){console.error("PHPFlasher Toastr: Error rendering notification",t,e)}}))}renderOptions(e){if(this.isDependencyAvailable())try{t.options=Object.assign({timeOut:e.timeOut||1e4,progressBar:e.progressBar||!0},e)}catch(e){console.error("PHPFlasher Toastr: Error applying options",e)}}isDependencyAvailable(){return!(!window.jQuery&&!window.$)||(console.error("PHPFlasher Toastr: jQuery is required but not loaded. Make sure jQuery is loaded before using Toastr."),!1)}};return e.addPlugin("toastr",r),r}));