add sweet-alert package
This commit is contained in:
parent
2bb496e46a
commit
38ced461fc
|
@ -9,7 +9,8 @@
|
|||
"guzzlehttp/guzzle": "^7.2",
|
||||
"laravel/framework": "^10.0",
|
||||
"laravel/sanctum": "^3.2",
|
||||
"laravel/tinker": "^2.8"
|
||||
"laravel/tinker": "^2.8",
|
||||
"realrashid/sweet-alert": "^7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "bfe12996eeecb6fdc8713a9fd9d431f8",
|
||||
"content-hash": "36d47ca0654f6d7aa9d0c9fbc7ef90a4",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
|
@ -3178,6 +3178,96 @@
|
|||
],
|
||||
"time": "2024-04-27T21:32:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "realrashid/sweet-alert",
|
||||
"version": "v7.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/realrashid/sweet-alert.git",
|
||||
"reference": "7890f3d3a0f45ea65b90300a823681a99a1d2dd6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/realrashid/sweet-alert/zipball/7890f3d3a0f45ea65b90300a823681a99a1d2dd6",
|
||||
"reference": "7890f3d3a0f45ea65b90300a823681a99a1d2dd6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"laravel/framework": "^5.6|^6.0|^7.0|^8.0|^9.0|^9.11|9.14.*|^10.0|^11.0",
|
||||
"php": "^7.2|^8.0|^8.1|^8.2|^8.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/thanks": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"aliases": {
|
||||
"Alert": "RealRashid\\SweetAlert\\Facades\\Alert"
|
||||
},
|
||||
"providers": [
|
||||
"RealRashid\\SweetAlert\\SweetAlertServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"RealRashid\\SweetAlert\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Rashid Ali",
|
||||
"email": "realrashid05@gmail.com",
|
||||
"homepage": "https://realrashid.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Laravel Sweet Alert Is A Package For Laravel Provides An Easy Way To Display Alert Messages Using The SweetAlert2 Library.",
|
||||
"homepage": "https://github.com/realrashid/sweet-alert",
|
||||
"keywords": [
|
||||
"alert",
|
||||
"laravel",
|
||||
"laravel-package",
|
||||
"notifier",
|
||||
"noty",
|
||||
"sweet-alert",
|
||||
"sweet-alert2",
|
||||
"toast"
|
||||
],
|
||||
"support": {
|
||||
"docs": "https://realrashid.github.io/sweet-alert/",
|
||||
"email": "realrashid05@gmail.com",
|
||||
"issues": "https://github.com/realrashid/sweet-alert/issues",
|
||||
"source": "https://github.com/realrashid/sweet-alert"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://ko-fi.com/realrashid",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://www.buymeacoffee.com/realrashid",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://issuehunt.io/r/realrashid",
|
||||
"type": "issuehunt"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/realrashid/sweet-alert",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-06-15T16:17:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v6.4.13",
|
||||
|
|
|
@ -185,6 +185,7 @@
|
|||
/*
|
||||
* Package Service Providers...
|
||||
*/
|
||||
RealRashid\SweetAlert\SweetAlertServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
|
@ -210,6 +211,7 @@
|
|||
|
||||
'aliases' => Facade::defaultAliases()->merge([
|
||||
// 'ExampleClass' => App\Example\ExampleClass::class,
|
||||
'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
|
||||
])->toArray(),
|
||||
|
||||
];
|
||||
|
|
|
@ -0,0 +1,267 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Theme
|
||||
|--------------------------------------------------------------------------
|
||||
| The theme to use for SweetAlert2 popups.
|
||||
| Available themes: dark, minimal, borderless, bootstrap-4, material-ui, wordpress-admin, bulma.
|
||||
|
|
||||
*/
|
||||
|
||||
'theme' => env('SWEET_ALERT_THEME', 'default'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CDN LINK
|
||||
|--------------------------------------------------------------------------
|
||||
| By default SweetAlert2 use its local sweetalert.all.js
|
||||
| file.
|
||||
| However, you can use its cdn if you want.
|
||||
|
|
||||
*/
|
||||
|
||||
'cdn' => env('SWEET_ALERT_CDN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Always load the sweetalert.all.js
|
||||
|--------------------------------------------------------------------------
|
||||
| There might be situations where you will always want the sweet alert
|
||||
| js package to be there for you. (for eg. you might use it heavily to
|
||||
| show notifications or you might want to use the native js) then this
|
||||
| might be handy.
|
||||
|
|
||||
*/
|
||||
|
||||
'alwaysLoadJS' => env('SWEET_ALERT_ALWAYS_LOAD_JS', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Never load the sweetalert.all.js
|
||||
|--------------------------------------------------------------------------
|
||||
| If you want to handle the sweet alert js package by yourself
|
||||
| (for eg. you might want to use laravel mix) then this can be
|
||||
| handy.
|
||||
|
|
||||
| alwaysLoadJs = true & neverLoadJs = true => js will not be loaded
|
||||
| alwaysLoadJs = true & neverLoadJs = false => js will be loaded
|
||||
| alwaysLoadJs = false & neverLoadJs = false => js will be loaded when
|
||||
| you set alert/toast by using the facade/helper functions.
|
||||
*/
|
||||
|
||||
'neverLoadJS' => env('SWEET_ALERT_NEVER_LOAD_JS', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| AutoClose Timer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is for the all Modal windows.
|
||||
| For specific modal just use the autoClose() helper method.
|
||||
|
|
||||
*/
|
||||
|
||||
'timer' => env('SWEET_ALERT_TIMER', 5000),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Width
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Modal window width, including paddings (box-sizing: border-box).
|
||||
| Can be in px or %.
|
||||
| The default width is 32rem.
|
||||
| This is for the all Modal windows.
|
||||
| for particular modal just use the width() helper method.
|
||||
*/
|
||||
|
||||
'width' => env('SWEET_ALERT_WIDTH', '32rem'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Height Auto
|
||||
|--------------------------------------------------------------------------
|
||||
| By default, SweetAlert2 sets html's and body's CSS height to auto !important.
|
||||
| If this behavior isn't compatible with your project's layout,
|
||||
| set heightAuto to false.
|
||||
|
|
||||
*/
|
||||
|
||||
'height_auto' => env('SWEET_ALERT_HEIGHT_AUTO', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Padding
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Modal window padding.
|
||||
| Can be in px or %.
|
||||
| The default padding is 1.25rem.
|
||||
| This is for the all Modal windows.
|
||||
| for particular modal just use the padding() helper method.
|
||||
*/
|
||||
|
||||
'padding' => env('SWEET_ALERT_PADDING', '1.25rem'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Background
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Modal window background
|
||||
| (CSS background property).
|
||||
| The default background is '#fff'.
|
||||
*/
|
||||
|
||||
'background' => env('SWEET_ALERT_BACKGROUND', '#fff'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Animation
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom animation with [Animate.css](https://daneden.github.io/animate.css/)
|
||||
| If set to false, modal CSS animation will be use default ones.
|
||||
| For specific modal just use the animation() helper method.
|
||||
|
|
||||
*/
|
||||
|
||||
'animation' => [
|
||||
'enable' => env('SWEET_ALERT_ANIMATION_ENABLE', false),
|
||||
],
|
||||
|
||||
'animatecss' => env('SWEET_ALERT_ANIMATECSS', 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ShowConfirmButton
|
||||
|--------------------------------------------------------------------------
|
||||
| If set to false, a "Confirm"-button will not be shown.
|
||||
| It can be useful when you're using custom HTML description.
|
||||
| This is for the all Modal windows.
|
||||
| For specific modal just use the showConfirmButton() helper method.
|
||||
|
|
||||
*/
|
||||
|
||||
'show_confirm_button' => env('SWEET_ALERT_CONFIRM_BUTTON', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ShowCloseButton
|
||||
|--------------------------------------------------------------------------
|
||||
| If set to true, a "Close"-button will be shown,
|
||||
| which the user can click on to dismiss the modal.
|
||||
| This is for the all Modal windows.
|
||||
| For specific modal just use the showCloseButton() helper method.
|
||||
|
|
||||
*/
|
||||
|
||||
'show_close_button' => env('SWEET_ALERT_CLOSE_BUTTON', false),
|
||||
|
||||
/*
|
||||
|-----------------------------------------------------------------------
|
||||
| Confirm/Cancel Button Text
|
||||
|-----------------------------------------------------------------------
|
||||
| Change the default text of the modal buttons.
|
||||
| The texts translations will be handled by Laravel at runtime.
|
||||
| This is for the all Modal windows.
|
||||
| For specific modal just use the confirmButtonText() and
|
||||
| cancelButtonText() helper methods.
|
||||
*/
|
||||
|
||||
'button_text' => [
|
||||
'confirm' => env('SWEET_ALERT_CONFIRM_BUTTON_TEXT', 'OK'),
|
||||
'cancel' => env('SWEET_ALERT_CANCEL_BUTTON_TEXT', 'Cancel'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Toast position
|
||||
|--------------------------------------------------------------------------
|
||||
| Modal window or toast position, can be 'top',
|
||||
| 'top-start', 'top-end', 'center', 'center-start',
|
||||
| 'center-end', 'bottom', 'bottom-start', or 'bottom-end'.
|
||||
| For specific modal just use the position() helper method.
|
||||
|
|
||||
*/
|
||||
|
||||
'toast_position' => env('SWEET_ALERT_TOAST_POSITION', 'top-end'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Progress Bar
|
||||
|--------------------------------------------------------------------------
|
||||
| If set to true, a progress bar at the bottom of a popup will be shown.
|
||||
| It can be useful with toasts.
|
||||
|
|
||||
*/
|
||||
|
||||
'timer_progress_bar' => env('SWEET_ALERT_TIMER_PROGRESS_BAR', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
| Modal window or toast, config for the Middleware
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => [
|
||||
|
||||
'autoClose' => env('SWEET_ALERT_MIDDLEWARE_AUTO_CLOSE', false),
|
||||
|
||||
'toast_position' => env('SWEET_ALERT_MIDDLEWARE_TOAST_POSITION', 'top-end'),
|
||||
|
||||
'toast_close_button' => env('SWEET_ALERT_MIDDLEWARE_TOAST_CLOSE_BUTTON', true),
|
||||
|
||||
'timer' => env('SWEET_ALERT_MIDDLEWARE_ALERT_CLOSE_TIME', 6000),
|
||||
|
||||
'auto_display_error_messages' => env('SWEET_ALERT_AUTO_DISPLAY_ERROR_MESSAGES', true),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Class
|
||||
|--------------------------------------------------------------------------
|
||||
| A custom CSS class for the modal:
|
||||
|
|
||||
*/
|
||||
|
||||
'customClass' => [
|
||||
|
||||
'container' => env('SWEET_ALERT_CONTAINER_CLASS'),
|
||||
'popup' => env('SWEET_ALERT_POPUP_CLASS'),
|
||||
'header' => env('SWEET_ALERT_HEADER_CLASS'),
|
||||
'title' => env('SWEET_ALERT_TITLE_CLASS'),
|
||||
'closeButton' => env('SWEET_ALERT_CLOSE_BUTTON_CLASS'),
|
||||
'icon' => env('SWEET_ALERT_ICON_CLASS'),
|
||||
'image' => env('SWEET_ALERT_IMAGE_CLASS'),
|
||||
'content' => env('SWEET_ALERT_CONTENT_CLASS'),
|
||||
'input' => env('SWEET_ALERT_INPUT_CLASS'),
|
||||
'actions' => env('SWEET_ALERT_ACTIONS_CLASS'),
|
||||
'confirmButton' => env('SWEET_ALERT_CONFIRM_BUTTON_CLASS'),
|
||||
'cancelButton' => env('SWEET_ALERT_CANCEL_BUTTON_CLASS'),
|
||||
'footer' => env('SWEET_ALERT_FOOTER_CLASS'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| confirmDelete
|
||||
|--------------------------------------------------------------------------
|
||||
| customize the configuration options of the confirmation popup.
|
||||
|
|
||||
*/
|
||||
|
||||
'confirm_delete_confirm_button_text' => env('SWEET_ALERT_CONFIRM_DELETE_CONFIRM_BUTTON_TEXT', 'Yes, delete it!'),
|
||||
'confirm_delete_confirm_button_color' => env('SWEET_ALERT_CONFIRM_DELETE_CONFIRM_BUTTON_COLOR'),
|
||||
'confirm_delete_cancel_button_color' => env('SWEET_ALERT_CONFIRM_DELETE_CANCEL_BUTTON_COLOR', '#d33'),
|
||||
'confirm_delete_cancel_button_text' => env('SWEET_ALERT_CONFIRM_DELETE_CANCEL_BUTTON_TEXT', 'Cancel'),
|
||||
'confirm_delete_show_cancel_button' => env('SWEET_ALERT_CONFIRM_DELETE_SHOW_CANCEL_BUTTON', true),
|
||||
'confirm_delete_show_close_button' => env('SWEET_ALERT_CONFIRM_DELETE_SHOW_CLOSE_BUTTON', false),
|
||||
'confirm_delete_icon' => env('SWEET_ALERT_CONFIRM_DELETE_ICON', 'warning'),
|
||||
'confirm_delete_show_loader_on_confirm' => env('SWEET_ALERT_CONFIRM_DELETE_SHOW_LOADER_ON_CONFIRM', true),
|
||||
|
||||
|
||||
];
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,44 @@
|
|||
@if (config('sweetalert.alwaysLoadJS') === true || Session::has('alert.config') || Session::has('alert.delete'))
|
||||
@if (config('sweetalert.animation.enable'))
|
||||
<link rel="stylesheet" href="{{ config('sweetalert.animatecss') }}">
|
||||
@endif
|
||||
|
||||
@if (config('sweetalert.theme') != 'default')
|
||||
<link href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-{{ config('sweetalert.theme') }}" rel="stylesheet">
|
||||
@endif
|
||||
|
||||
@if (config('sweetalert.neverLoadJS') === false)
|
||||
<script src="{{ $cdn ?? asset('vendor/sweetalert/sweetalert.all.js') }}"></script>
|
||||
@endif
|
||||
|
||||
@if (Session::has('alert.delete') || Session::has('alert.config'))
|
||||
<script>
|
||||
document.addEventListener('click', function(event) {
|
||||
// Check if the clicked element or its parent has the attribute
|
||||
var target = event.target;
|
||||
var confirmDeleteElement = target.closest('[data-confirm-delete]');
|
||||
|
||||
if (confirmDeleteElement) {
|
||||
event.preventDefault();
|
||||
Swal.fire({!! Session::pull('alert.delete') !!}).then(function(result) {
|
||||
if (result.isConfirmed) {
|
||||
var form = document.createElement('form');
|
||||
form.action = confirmDeleteElement.href;
|
||||
form.method = 'POST';
|
||||
form.innerHTML = `
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
`;
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@if (Session::has('alert.config'))
|
||||
Swal.fire({!! Session::pull('alert.config') !!});
|
||||
@endif
|
||||
</script>
|
||||
@endif
|
||||
@endif
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue