You've already forked php-flasher
mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-04-05 12:32:55 +01:00
fix flasher options
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"dist/main.css": "/dist/main.fdaa6615.css",
|
||||
"dist/main.js": "/dist/main.8dd6f4c9.js",
|
||||
"dist/main.js": "/dist/main.70b93173.js",
|
||||
"dist/455.3a7b4474.css": "/dist/455.3a7b4474.css",
|
||||
"dist/455.095e6545.js": "/dist/455.095e6545.js",
|
||||
"dist/411.29cd993e.css": "/dist/411.29cd993e.css",
|
||||
|
||||
+12
-4
@@ -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.
|
||||
</p>
|
||||
|
||||
<!--
|
||||
<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">
|
||||
<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
|
||||
</a>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<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">
|
||||
@@ -454,7 +456,7 @@
|
||||
</div>
|
||||
|
||||
<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
|
||||
</a>
|
||||
</div>
|
||||
@@ -482,9 +484,9 @@
|
||||
<div>
|
||||
<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
|
||||
|
||||
@@ -494,6 +496,12 @@ class ProfileController extends Controller
|
||||
// Or add a title
|
||||
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
|
||||
flash()->options([
|
||||
'timeout' => 5000,
|
||||
@@ -657,7 +665,7 @@ document.getElementById('contact-form').addEventListener('submit', async functio
|
||||
</a>
|
||||
|
||||
<!-- 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">
|
||||
<i class="fa-solid fa-book-open text-amber-600 text-3xl"></i>
|
||||
</div>
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
"/dist/main.fdaa6615.css"
|
||||
],
|
||||
"js": [
|
||||
"/dist/main.8dd6f4c9.js"
|
||||
"/dist/main.70b93173.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
File diff suppressed because one or more lines are too long
Vendored
-2
File diff suppressed because one or more lines are too long
+22
-9
@@ -39,17 +39,27 @@ class AbstractPlugin {
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
} else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
} else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -57,10 +67,13 @@ class AbstractPlugin {
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: ''
|
||||
|
||||
+22
-9
@@ -42,17 +42,27 @@
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
} else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
} else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -60,10 +70,13 @@
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: ''
|
||||
|
||||
+1
-1
@@ -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
@@ -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
@@ -38,17 +38,27 @@ class AbstractPlugin {
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
} else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
} else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -56,10 +66,13 @@ class AbstractPlugin {
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: ''
|
||||
|
||||
+22
-9
@@ -42,17 +42,27 @@
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
} else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
} else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -60,10 +70,13 @@
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: ''
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
@@ -101,7 +101,7 @@ export abstract class AbstractPlugin implements PluginInterface {
|
||||
*
|
||||
* This method handles different parameter formats to provide a flexible API:
|
||||
* - 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(options) - type, message, and title in options
|
||||
*
|
||||
@@ -141,21 +141,37 @@ export abstract class AbstractPlugin implements PluginInterface {
|
||||
delete normalizedOptions.message
|
||||
delete normalizedOptions.title
|
||||
}
|
||||
// Case: flash(type, message, {title, ...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)
|
||||
// Case: flash(type, message, title|options, options?)
|
||||
else {
|
||||
normalizedType = type
|
||||
normalizedMessage = message
|
||||
normalizedTitle = title
|
||||
normalizedOptions = options || {}
|
||||
normalizedMessage = message as string
|
||||
|
||||
// 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
|
||||
@@ -167,11 +183,16 @@ export abstract class AbstractPlugin implements PluginInterface {
|
||||
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
|
||||
const envelope: Envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: '',
|
||||
|
||||
+25
-10
@@ -70,18 +70,30 @@ class AbstractPlugin {
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
}
|
||||
else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
}
|
||||
else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -89,10 +101,13 @@ class AbstractPlugin {
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: '',
|
||||
|
||||
Vendored
+25
-10
@@ -76,18 +76,30 @@
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
}
|
||||
else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
}
|
||||
else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -95,10 +107,13 @@
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: '',
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+25
-10
@@ -38,18 +38,30 @@ class AbstractPlugin {
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
}
|
||||
else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
}
|
||||
else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -57,10 +69,13 @@ class AbstractPlugin {
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: '',
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -71,17 +71,27 @@ class AbstractPlugin {
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
} else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
} else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -89,10 +99,13 @@ class AbstractPlugin {
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: ''
|
||||
|
||||
+22
-9
@@ -74,17 +74,27 @@
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
} else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
} else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -92,10 +102,13 @@
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
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
@@ -39,17 +39,27 @@ class AbstractPlugin {
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
} else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
} else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -57,10 +67,13 @@ class AbstractPlugin {
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: ''
|
||||
|
||||
+22
-9
@@ -42,17 +42,27 @@
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.message;
|
||||
delete normalizedOptions.title;
|
||||
} else if (typeof title === 'object') {
|
||||
normalizedOptions = Object.assign({}, title);
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = normalizedOptions.title;
|
||||
delete normalizedOptions.title;
|
||||
} else {
|
||||
normalizedType = type;
|
||||
normalizedMessage = message;
|
||||
normalizedTitle = title;
|
||||
normalizedOptions = options || {};
|
||||
if (title === undefined || title === null) {
|
||||
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) {
|
||||
throw new Error('Type is required for notifications');
|
||||
@@ -60,10 +70,13 @@
|
||||
if (normalizedMessage === undefined || normalizedMessage === null) {
|
||||
throw new Error('Message is required for notifications');
|
||||
}
|
||||
if (normalizedTitle === undefined || normalizedTitle === null) {
|
||||
normalizedTitle = normalizedType.charAt(0).toUpperCase() + normalizedType.slice(1);
|
||||
}
|
||||
const envelope = {
|
||||
type: normalizedType,
|
||||
message: normalizedMessage,
|
||||
title: normalizedTitle || normalizedType,
|
||||
title: normalizedTitle,
|
||||
options: normalizedOptions,
|
||||
metadata: {
|
||||
plugin: ''
|
||||
|
||||
+1
-1
@@ -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
@@ -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}));
|
||||
|
||||
Reference in New Issue
Block a user